mirror of
https://github.com/friendica/friendica
synced 2024-11-10 02:22:55 +00:00
App->contact is now removed
This commit is contained in:
parent
f60d60e997
commit
30aad250df
16 changed files with 65 additions and 54 deletions
|
@ -261,16 +261,11 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
$page_uid = $item['uid'];
|
||||
}
|
||||
|
||||
$page_contact = DBA::selectFirst('contact', ['id', 'url', 'network', 'name'], ['self' => true, 'uid' => $page_uid]);
|
||||
if (DBA::isResult($page_contact)) {
|
||||
// "$a->page_contact" is only used in "checkWallToWall" in Post.php.
|
||||
// It is used for the wall post feature that has its issues.
|
||||
// It can't work with AP or Diaspora since the creator can't sign the post with their private key.
|
||||
$a->page_contact = $page_contact;
|
||||
if (!empty($page_uid) && ($page_uid != local_user())) {
|
||||
$page_user = User::getById($page_uid);
|
||||
}
|
||||
|
||||
$is_owner = (local_user() && (in_array($page_uid, [local_user(), 0])) ? true : false);
|
||||
$is_owner = local_user() && (in_array($page_uid, [local_user(), 0]));
|
||||
|
||||
if (!empty($page_user['hidewall']) && !$is_owner && !$is_remote_contact) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
|
|
|
@ -64,11 +64,11 @@ function notes_content(App $a, $update = false)
|
|||
'acl_data' => '',
|
||||
];
|
||||
|
||||
$o .= status_editor($a, $x, $a->contact['id']);
|
||||
$o .= status_editor($a, $x, $a->contact_id);
|
||||
}
|
||||
|
||||
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
|
||||
'contact-id'=> $a->contact['id']];
|
||||
'contact-id'=> $a->contact_id];
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
|
||||
|
|
|
@ -890,7 +890,8 @@ function photos_content(App $a)
|
|||
|
||||
if (!$remote_contact && local_user()) {
|
||||
$contact_id = $_SESSION['cid'];
|
||||
$contact = $a->contact;
|
||||
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
|
||||
}
|
||||
|
||||
if ($user['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) {
|
||||
|
|
|
@ -58,7 +58,7 @@ function redir_init(App $a) {
|
|||
|
||||
$contact_url = $contact['url'];
|
||||
|
||||
if (!empty($a->contact['id']) && $a->contact['id'] == $cid) {
|
||||
if (!empty($a->contact_id) && $a->contact_id == $cid) {
|
||||
// Local user is already authenticated.
|
||||
redir_check_url($contact_url, $url);
|
||||
$a->redirect($url ?: $contact_url);
|
||||
|
@ -73,7 +73,7 @@ function redir_init(App $a) {
|
|||
$cid = $contact['id'];
|
||||
}
|
||||
|
||||
if (!empty($a->contact['id']) && $a->contact['id'] == $cid) {
|
||||
if (!empty($a->contact_id) && $a->contact_id == $cid) {
|
||||
// Local user is already authenticated.
|
||||
redir_check_url($contact_url, $url);
|
||||
$target_url = $url ?: $contact_url;
|
||||
|
|
|
@ -57,16 +57,14 @@ use Psr\Log\LoggerInterface;
|
|||
class App
|
||||
{
|
||||
public $profile_owner;
|
||||
public $contact_id;
|
||||
public $user;
|
||||
public $contact;
|
||||
public $page_contact;
|
||||
public $data = [];
|
||||
/** @deprecated 2019.09 - use App\Arguments->getArgv() or Arguments->get() */
|
||||
public $argv;
|
||||
/** @deprecated 2019.09 - use App\Arguments->getArgc() */
|
||||
public $argc;
|
||||
public $timezone;
|
||||
public $identities;
|
||||
public $theme_info = [];
|
||||
// Allow themes to control internal parameters
|
||||
// by changing App values in theme.php
|
||||
|
|
|
@ -289,7 +289,7 @@ class Nav
|
|||
$nav['messages']['outbox'] = ['message/sent', DI::l10n()->t('Outbox'), '', DI::l10n()->t('Outbox')];
|
||||
$nav['messages']['new'] = ['message/new', DI::l10n()->t('New Message'), '', DI::l10n()->t('New Message')];
|
||||
|
||||
if (is_array($a->identities) && count($a->identities) > 1) {
|
||||
if (User::hasIdentities(DI::session()->get('submanage') ?: local_user())) {
|
||||
$nav['delegation'] = ['delegation', DI::l10n()->t('Accounts'), '', DI::l10n()->t('Manage other pages')];
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ class Notification extends BaseFactory
|
|||
private $baseUrl;
|
||||
/** @var L10n */
|
||||
private $l10n;
|
||||
/** @var string */
|
||||
private $nurl;
|
||||
|
||||
public function __construct(LoggerInterface $logger, Database $dba, Repository\Notification $notification, BaseURL $baseUrl, L10n $l10n, App $app, IPConfig $pConfig, ISession $session)
|
||||
{
|
||||
|
@ -74,7 +72,6 @@ class Notification extends BaseFactory
|
|||
$this->notification = $notification;
|
||||
$this->baseUrl = $baseUrl;
|
||||
$this->l10n = $l10n;
|
||||
$this->nurl = $app->contact['nurl'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2685,7 +2685,7 @@ class Item
|
|||
continue;
|
||||
}
|
||||
|
||||
if ((local_user() == $item['uid']) && ($item['private'] == self::PRIVATE) && ($item['contact-id'] != $app->contact['id']) && ($item['network'] == Protocol::DFRN)) {
|
||||
if ((local_user() == $item['uid']) && ($item['private'] == self::PRIVATE) && ($item['contact-id'] != $app->contact_id) && ($item['network'] == Protocol::DFRN)) {
|
||||
$img_url = 'redir/' . $item['contact-id'] . '?url=' . urlencode($mtch[1]);
|
||||
$item['body'] = str_replace($mtch[0], '[img]' . $img_url . '[/img]', $item['body']);
|
||||
}
|
||||
|
|
|
@ -768,7 +768,7 @@ class Profile
|
|||
|
||||
Session::setVisitorsContacts();
|
||||
|
||||
$a->contact = $visitor;
|
||||
$a->contact_id = $visitor['id'];
|
||||
|
||||
Logger::info('Authenticated visitor', ['url' => $visitor['url']]);
|
||||
|
||||
|
@ -829,7 +829,7 @@ class Profile
|
|||
*/
|
||||
Hook::callAll('magic_auth_success', $arr);
|
||||
|
||||
$a->contact = $arr['visitor'];
|
||||
$a->contact_id = $arr['visitor']['id'];
|
||||
|
||||
info(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name']));
|
||||
|
||||
|
|
|
@ -1569,6 +1569,38 @@ class User
|
|||
return $identities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given user id has delegations or is delegated
|
||||
*
|
||||
* @param int $uid
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasIdentities(int $uid):bool
|
||||
{
|
||||
if (empty($uid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = DBA::selectFirst('user', ['parent-uid'], ['uid' => $uid, 'account_removed' => false]);
|
||||
if (!DBA::isResult($user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($user['parent-uid'] != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DBA::exists('user', ['parent-uid' => $uid, 'account_removed' => false])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DBA::exists('manage', ['muid' => $uid])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns statistical information about the current users of this node
|
||||
*
|
||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\XML;
|
||||
|
@ -59,7 +60,7 @@ class Poke extends BaseModule
|
|||
$deny_cid = ($private ? '' : $a->user['deny_cid']);
|
||||
$deny_gid = ($private ? '' : $a->user['deny_gid']);
|
||||
|
||||
$actor = $a->contact;
|
||||
$actor = Contact::getById($a->contact_id);
|
||||
|
||||
$uri = Model\Item::newURI($uid);
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ class Delegation extends BaseModule
|
|||
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
|
||||
}
|
||||
|
||||
$identities = DI::app()->identities;
|
||||
$identities = User::identities(DI::session()->get('submanage') ?: local_user());
|
||||
|
||||
//getting additinal information for each identity
|
||||
foreach ($identities as $key => $identity) {
|
||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Security\Login;
|
||||
|
@ -86,7 +87,7 @@ class Compose extends BaseModule
|
|||
$compose_title = DI::l10n()->t('Compose new personal note');
|
||||
$type = 'note';
|
||||
$doesFederate = false;
|
||||
$contact_allow_list = [$a->contact['id']];
|
||||
$contact_allow_list = [$a->contact_id];
|
||||
$group_allow_list = [];
|
||||
$contact_deny_list = [];
|
||||
$group_deny_list = [];
|
||||
|
@ -129,6 +130,8 @@ class Compose extends BaseModule
|
|||
DI::page()->registerFooterScript(Theme::getPathForFile('js/linkPreview.js'));
|
||||
DI::page()->registerFooterScript(Theme::getPathForFile('js/compose.js'));
|
||||
|
||||
$contact = Contact::getById($a->contact_id);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('item/compose.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$compose_title'=> $compose_title,
|
||||
|
@ -138,9 +141,9 @@ class Compose extends BaseModule
|
|||
'$type' => $type,
|
||||
'$wall' => $wall,
|
||||
'$default' => '',
|
||||
'$mylink' => DI::baseUrl()->remove($a->contact['url']),
|
||||
'$mylink' => DI::baseUrl()->remove($contact['url']),
|
||||
'$mytitle' => DI::l10n()->t('This is you'),
|
||||
'$myphoto' => DI::baseUrl()->remove($a->contact['thumb']),
|
||||
'$myphoto' => DI::baseUrl()->remove($contact['thumb']),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$edbold' => DI::l10n()->t('Bold'),
|
||||
'$editalic' => DI::l10n()->t('Italic'),
|
||||
|
|
|
@ -65,7 +65,7 @@ class Magic extends BaseModule
|
|||
$contact = DBA::selectFirst('contact', ['id', 'nurl', 'url'], ['id' => $cid]);
|
||||
|
||||
// Redirect if the contact is already authenticated on this site.
|
||||
if (!empty($a->contact) && array_key_exists('id', $a->contact) && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) {
|
||||
if (!empty($a->contact_id) && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) {
|
||||
if ($test) {
|
||||
$ret['success'] = true;
|
||||
$ret['message'] .= 'Local site - you are already authenticated.' . EOL;
|
||||
|
|
|
@ -187,7 +187,7 @@ class Post
|
|||
$edpost = false;
|
||||
|
||||
if (local_user()) {
|
||||
if (Strings::compareLink($a->contact['url'], $item['author-link'])) {
|
||||
if (Strings::compareLink(Session::get('my_url'), $item['author-link'])) {
|
||||
if ($item["event-id"] != 0) {
|
||||
$edpost = ["events/event/" . $item['event-id'], DI::l10n()->t("Edit")];
|
||||
} else {
|
||||
|
@ -936,6 +936,8 @@ class Post
|
|||
$uid = $conv->getProfileOwner();
|
||||
$parent_uid = $this->getDataValue('uid');
|
||||
|
||||
$contact = Contact::getById($a->contact_id);
|
||||
|
||||
$default_text = $this->getDefaultText();
|
||||
|
||||
if (!is_null($parent_uid) && ($uid != $parent_uid)) {
|
||||
|
@ -953,9 +955,9 @@ class Post
|
|||
'$qcomment' => $qcomment,
|
||||
'$default' => $default_text,
|
||||
'$profile_uid' => $uid,
|
||||
'$mylink' => DI::baseUrl()->remove($a->contact['url'] ?? ''),
|
||||
'$mylink' => DI::baseUrl()->remove($contact['url'] ?? ''),
|
||||
'$mytitle' => DI::l10n()->t('This is you'),
|
||||
'$myphoto' => DI::baseUrl()->remove($a->contact['thumb'] ?? ''),
|
||||
'$myphoto' => DI::baseUrl()->remove($contact['thumb'] ?? ''),
|
||||
'$comment' => DI::l10n()->t('Comment'),
|
||||
'$submit' => DI::l10n()->t('Submit'),
|
||||
'$loading' => DI::l10n()->t('Loading...'),
|
||||
|
@ -999,15 +1001,7 @@ class Post
|
|||
|
||||
if ($this->isToplevel()) {
|
||||
if ($conv->getMode() !== 'profile') {
|
||||
if ($this->getDataValue('wall') && !$this->getDataValue('self') && !empty($a->page_contact)) {
|
||||
// On the network page, I am the owner. On the display page it will be the profile owner.
|
||||
// This will have been stored in $a->page_contact by our calling page.
|
||||
// Put this person as the wall owner of the wall-to-wall notice.
|
||||
|
||||
$this->owner_url = Contact::magicLinkByContact($a->page_contact);
|
||||
$this->owner_name = $a->page_contact['name'];
|
||||
$this->wall_to_wall = true;
|
||||
} elseif ($this->getDataValue('owner-link')) {
|
||||
if ($this->getDataValue('owner-link')) {
|
||||
$owner_linkmatch = (($this->getDataValue('owner-link')) && Strings::compareLink($this->getDataValue('owner-link'), $this->getDataValue('author-link')));
|
||||
$alias_linkmatch = (($this->getDataValue('alias')) && Strings::compareLink($this->getDataValue('alias'), $this->getDataValue('author-link')));
|
||||
$owner_namematch = (($this->getDataValue('owner-name')) && $this->getDataValue('owner-name') == $this->getDataValue('author-name'));
|
||||
|
|
|
@ -142,9 +142,9 @@ class Authentication
|
|||
|
||||
if ($this->session->get('authenticated')) {
|
||||
if ($this->session->get('visitor_id') && !$this->session->get('uid')) {
|
||||
$contact = $this->dba->selectFirst('contact', [], ['id' => $this->session->get('visitor_id')]);
|
||||
$contact = $this->dba->selectFirst('contact', ['id'], ['id' => $this->session->get('visitor_id')]);
|
||||
if ($this->dba->isResult($contact)) {
|
||||
$a->contact = $contact;
|
||||
$a->contact_id = $contact['id'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,19 +319,9 @@ class Authentication
|
|||
}
|
||||
}
|
||||
|
||||
$a->identities = User::identities($masterUid);
|
||||
|
||||
if ($login_initial) {
|
||||
$this->logger->info('auth_identities: ' . print_r($a->identities, true));
|
||||
}
|
||||
|
||||
if ($login_refresh) {
|
||||
$this->logger->info('auth_identities refresh: ' . print_r($a->identities, true));
|
||||
}
|
||||
|
||||
$contact = $this->dba->selectFirst('contact', [], ['uid' => $user_record['uid'], 'self' => true]);
|
||||
$contact = $this->dba->selectFirst('contact', ['id'], ['uid' => $user_record['uid'], 'self' => true]);
|
||||
if ($this->dba->isResult($contact)) {
|
||||
$a->contact = $contact;
|
||||
$a->contact_id = $contact['id'];
|
||||
$this->session->set('cid', $contact['id']);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue