]> git.mxchange.org Git - friendica.git/commitdiff
Using getter/setter functions
authorMichael <heluecht@pirati.ca>
Sat, 24 Jul 2021 20:34:07 +0000 (20:34 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 24 Jul 2021 20:34:07 +0000 (20:34 +0000)
14 files changed:
mod/display.php
mod/notes.php
mod/redir.php
src/App.php
src/Content/Widget.php
src/Model/Item.php
src/Model/Profile.php
src/Module/Contact/Poke.php
src/Module/Item/Compose.php
src/Module/Magic.php
src/Module/Update/Profile.php
src/Object/Post.php
src/Object/Thread.php
src/Security/Authentication.php

index 6abf4c019dcb4b760c474e60674feb5fe074dd6d..6b30391d652dc8082b5c1a1692685a309acb2b5b 100644 (file)
@@ -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'];
                }
index 2759164bc49eb903d6becfb3255229715049b2c7..945d0c935d325c00cf664b482a46fd0855144793 100644 (file)
@@ -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',
index ca0fe71a829de221b6b634f7825ddcf204b9b438..557bbe4443173452cc8b292ca9530054a51c9f09 100644 (file)
@@ -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;
index aba922804c3fc2ef9c08ef9b6e3b1826fb7cf62c..8190bcbaee0d992e24adcfb566fad00467d2d10d 100644 (file)
@@ -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
         *
index 88afbe9e5284de70d45d1214eb25488aed7781f2..a899644c3ce5a80c27ad2de9e13667e0dce320e4 100644 (file)
@@ -334,7 +334,7 @@ class Widget
        {
                $a = DI::app();
 
-               $uid = intval($a->profile_owner);
+               $uid = intval($a->getProfileOwner());
 
                if (!Feature::isEnabled($uid, 'categories')) {
                        return '';
index 477d8f3bea8c9daf3f77a040af5a58db3ec5463d..327c60d5cfb4afdb54ef9300709caf8a2129e5c9 100644 (file)
@@ -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']);
                                }
index 980cd204e343209876179c77a900e186122ed8b6..62df630dc8d5d5904cda6a0911b5238a19469b41 100644 (file)
@@ -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();
                }
index f8f58fe48ceb6ba7ccf627c2096c30e1827d1dd2..955d4bab0e7cc2fa465c5bb6e078b8f6498b19ee 100644 (file)
@@ -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);
 
index 21dd5625c147a7acfd4c4cbd5d981f30220b1ce2..e06c4ba0c1513b8957eb4d8c3542b26b41a43c5f 100644 (file)
@@ -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, [
index 81d6def33855c719a3c0109b24e9fb002973eda5..5b4676dd561966b7d9fb28d5cbc10bf3a9d13c3d 100644 (file)
@@ -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;
index 4ec6a977b27bfa7a0354721f888edbc5d1ae09e6..e9e8681af5725aa5cc99f7d4481c3cbfd56b1b8f 100644 (file)
@@ -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);
        }
index a56a73a266410a4b72590e931c4083874b6306bf..a7071ad794d298eaf7a3d0a0ef36f2176a3df8fe 100644 (file)
@@ -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();
 
index a73803b525536f8eb10153cbb534e7195a416b3a..a848586fe54032409c1dbc4688fca23b92581f3a 100644 (file)
@@ -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':
index 29ea4621c681f9c6b925e64016a7db1aba00c4ba..3ad9a28999ae59819c45238b7f3821890744034e 100644 (file)
@@ -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']);
                }