diff --git a/mod/display.php b/mod/display.php index 6abf4c019d..6b30391d65 100644 --- a/mod/display.php +++ b/mod/display.php @@ -177,9 +177,9 @@ function display_content(App $a, $update = false, $update_uid = 0) $item = Post::selectFirst(['uid', 'parent-uri-id'], ['uri-id' => $uri_id, 'uid' => $update_uid]); if (!empty($item)) { if ($item['uid'] != 0) { - $a->profile_owner = intval($item['uid']); + $a->setProfileOwner($item['uid']); } else { - $a->profile_owner = intval($update_uid); + $a->setProfileOwner($update_uid); } $parent_uri_id = $item['parent-uri-id']; } diff --git a/mod/notes.php b/mod/notes.php index 2759164bc4..945d0c935d 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -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->getContactId()); } $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT, - 'contact-id'=> $a->contact_id]; + 'contact-id'=> $a->getContactId()]; if (DI::mode()->isMobile()) { $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', diff --git a/mod/redir.php b/mod/redir.php index ca0fe71a82..557bbe4443 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -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->getContactId()) && $a->getContactId() == $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->getContactId()) && $a->getContactId() == $cid) { // Local user is already authenticated. redir_check_url($contact_url, $url); $target_url = $url ?: $contact_url; diff --git a/src/App.php b/src/App.php index aba922804c..8190bcbaee 100644 --- a/src/App.php +++ b/src/App.php @@ -56,8 +56,9 @@ use Psr\Log\LoggerInterface; */ class App { - public $profile_owner; - public $contact_id; + private $profile_owner; + private $contact_id; + public $user; public $data = []; /** @deprecated 2019.09 - use App\Arguments->getArgv() or Arguments->get() */ @@ -129,6 +130,26 @@ class App */ private $pConfig; + public function setProfileOwner(int $owner_id) + { + $this->profile_owner = $owner_id; + } + + public function getProfileOwner() + { + return $this->profile_owner; + } + + public function setContactId(int $contact_id) + { + $this->contact_id = $contact_id; + } + + public function getContactId() + { + return $this->contact_id; + } + /** * Returns the current config cache of this node * diff --git a/src/Content/Widget.php b/src/Content/Widget.php index 88afbe9e52..a899644c3c 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -334,7 +334,7 @@ class Widget { $a = DI::app(); - $uid = intval($a->profile_owner); + $uid = intval($a->getProfileOwner()); if (!Feature::isEnabled($uid, 'categories')) { return ''; diff --git a/src/Model/Item.php b/src/Model/Item.php index 477d8f3bea..327c60d5cf 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -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->getContactId()) && ($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']); } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 980cd204e3..62df630dc8 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -219,13 +219,13 @@ class Profile return []; } - $a->profile_owner = $profile['uid']; + $a->setProfileOwner($profile['uid']); DI::page()['title'] = $profile['name'] . ' @ ' . DI::config()->get('config', 'sitename'); if (!DI::pConfig()->get(local_user(), 'system', 'always_my_theme')) { $a->setCurrentTheme($profile['theme']); - $a->setCurrentMobileTheme(DI::pConfig()->get($a->profile_owner, 'system', 'mobile_theme')); + $a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme')); } /* @@ -768,7 +768,7 @@ class Profile Session::setVisitorsContacts(); - $a->contact_id = $visitor['id']; + $a->setContactId($visitor['id']); Logger::info('Authenticated visitor', ['url' => $visitor['url']]); @@ -829,7 +829,7 @@ class Profile */ Hook::callAll('magic_auth_success', $arr); - $a->contact_id = $arr['visitor']['id']; + $a->setContactId($arr['visitor']['id']); info(DI::l10n()->t('OpenWebAuth: %1$s welcomes %2$s', DI::baseUrl()->getHostname(), $visitor['name'])); @@ -871,7 +871,7 @@ class Profile */ public static function getThemeUid(App $a) { - $uid = !empty($a->profile_owner) ? intval($a->profile_owner) : 0; + $uid = !empty($a->getProfileOwner()) ? intval($a->getProfileOwner()) : 0; if (local_user() && (DI::pConfig()->get(local_user(), 'system', 'always_my_theme') || !$uid)) { return local_user(); } diff --git a/src/Module/Contact/Poke.php b/src/Module/Contact/Poke.php index f8f58fe48c..955d4bab0e 100644 --- a/src/Module/Contact/Poke.php +++ b/src/Module/Contact/Poke.php @@ -60,7 +60,7 @@ class Poke extends BaseModule $deny_cid = ($private ? '' : $a->user['deny_cid']); $deny_gid = ($private ? '' : $a->user['deny_gid']); - $actor = Contact::getById($a->contact_id); + $actor = Contact::getById($a->getContactId()); $uri = Model\Item::newURI($uid); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index 21dd5625c1..e06c4ba0c1 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -87,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->getContactId()]; $group_allow_list = []; $contact_deny_list = []; $group_deny_list = []; @@ -130,7 +130,7 @@ 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); + $contact = Contact::getById($a->getContactId()); $tpl = Renderer::getMarkupTemplate('item/compose.tpl'); return Renderer::replaceMacros($tpl, [ diff --git a/src/Module/Magic.php b/src/Module/Magic.php index 81d6def338..5b4676dd56 100644 --- a/src/Module/Magic.php +++ b/src/Module/Magic.php @@ -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_id) && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) { + if (!empty($a->getContactId()) && strpos($contact['nurl'], Strings::normaliseLink(DI::baseUrl()->get())) !== false) { if ($test) { $ret['success'] = true; $ret['message'] .= 'Local site - you are already authenticated.' . EOL; diff --git a/src/Module/Update/Profile.php b/src/Module/Update/Profile.php index 4ec6a977b2..e9e8681af5 100644 --- a/src/Module/Update/Profile.php +++ b/src/Module/Update/Profile.php @@ -40,18 +40,18 @@ class Profile extends BaseModule $a = DI::app(); // Ensure we've got a profile owner if updating. - $a->profile_owner = intval($_GET['p'] ?? 0); + $a->setProfileOwner($_GET['p'] ?? 0); - if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile_owner)) { + if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->getProfileOwner())) { throw new ForbiddenException(); } - $remote_contact = Session::getRemoteContactID($a->profile_owner); - $is_owner = local_user() == $a->profile_owner; - $last_updated_key = "profile:" . $a->profile_owner . ":" . local_user() . ":" . $remote_contact; + $remote_contact = Session::getRemoteContactID($a->getProfileOwner()); + $is_owner = local_user() == $a->getProfileOwner(); + $last_updated_key = "profile:" . $a->getProfileOwner() . ":" . local_user() . ":" . $remote_contact; if (!$is_owner && !$remote_contact) { - $user = User::getById($a->profile_owner, ['hidewall']); + $user = User::getById($a->getProfileOwner(), ['hidewall']); if ($user['hidewall']) { throw new ForbiddenException(DI::l10n()->t('Access to this profile has been restricted.')); } @@ -64,7 +64,7 @@ class Profile extends BaseModule } // Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups - $sql_extra = Item::getPermissionsSQLByUserId($a->profile_owner); + $sql_extra = Item::getPermissionsSQLByUserId($a->getProfileOwner()); $last_updated_array = Session::get('last_updated', []); @@ -88,7 +88,7 @@ class Profile extends BaseModule AND `visible` AND (NOT `deleted` OR `gravity` = ?) AND `wall` $sql_extra4 $sql_extra GROUP BY `parent-uri-id` ORDER BY `received` DESC", - $a->profile_owner, + $a->getProfileOwner(), GRAVITY_ACTIVITY ); @@ -101,7 +101,7 @@ class Profile extends BaseModule $last_updated_array[$last_updated_key] = time(); Session::set('last_updated', $last_updated_array); - if ($is_owner && !$a->profile_owner && !DI::config()->get('theme', 'hide_eventlist')) { + if ($is_owner && !$a->getProfileOwner() && !DI::config()->get('theme', 'hide_eventlist')) { $o .= ProfileModel::getBirthdays(); $o .= ProfileModel::getEventsReminderHTML(); } @@ -115,7 +115,7 @@ class Profile extends BaseModule $items = DBA::toArray($items_stmt); - $o .= conversation($a, $items, 'profile', $a->profile_owner, false, 'received', $a->profile_owner); + $o .= conversation($a, $items, 'profile', $a->getProfileOwner(), false, 'received', $a->getProfileOwner()); System::htmlUpdateExit($o); } diff --git a/src/Object/Post.php b/src/Object/Post.php index a56a73a266..a7071ad794 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -936,7 +936,7 @@ class Post $uid = $conv->getProfileOwner(); $parent_uid = $this->getDataValue('uid'); - $contact = Contact::getById($a->contact_id); + $contact = Contact::getById($a->getContactId()); $default_text = $this->getDefaultText(); diff --git a/src/Object/Thread.php b/src/Object/Thread.php index a73803b525..a848586fe5 100644 --- a/src/Object/Thread.php +++ b/src/Object/Thread.php @@ -79,11 +79,11 @@ class Thread $this->writable = true; break; case 'profile': - $this->profile_owner = $a->profile_owner; + $this->profile_owner = $a->getProfileOwner(); $this->writable = Security::canWriteToUserWall($this->profile_owner); break; case 'display': - $this->profile_owner = $a->profile_owner; + $this->profile_owner = $a->getProfileOwner(); $this->writable = Security::canWriteToUserWall($this->profile_owner) || $writable; break; case 'community': diff --git a/src/Security/Authentication.php b/src/Security/Authentication.php index 29ea4621c6..3ad9a28999 100644 --- a/src/Security/Authentication.php +++ b/src/Security/Authentication.php @@ -144,7 +144,7 @@ class Authentication if ($this->session->get('visitor_id') && !$this->session->get('uid')) { $contact = $this->dba->selectFirst('contact', ['id'], ['id' => $this->session->get('visitor_id')]); if ($this->dba->isResult($contact)) { - $a->contact_id = $contact['id']; + $a->setContactId($contact['id']); } } @@ -312,7 +312,7 @@ class Authentication $contact = $this->dba->selectFirst('contact', ['id'], ['uid' => $user_record['uid'], 'self' => true]); if ($this->dba->isResult($contact)) { - $a->contact_id = $contact['id']; + $a->setContactId($contact['id']); $this->session->set('cid', $contact['id']); }