$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.'));
'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',
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) {
$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);
$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;
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
$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')];
}
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)
{
$this->notification = $notification;
$this->baseUrl = $baseUrl;
$this->l10n = $l10n;
- $this->nurl = $app->contact['nurl'] ?? '';
}
/**
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']);
}
Session::setVisitorsContacts();
- $a->contact = $visitor;
+ $a->contact_id = $visitor['id'];
Logger::info('Authenticated visitor', ['url' => $visitor['url']]);
*/
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']));
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
*
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;
$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);
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) {
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;
$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 = [];
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,
'$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'),
$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;
$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 {
$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)) {
'$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...'),
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'));
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'];
}
}
}
}
- $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']);
}