]> git.mxchange.org Git - friendica.git/commitdiff
old boot.php functions replaced in src/module (2)
authorMichael <heluecht@pirati.ca>
Wed, 19 Oct 2022 04:35:37 +0000 (04:35 +0000)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 19 Oct 2022 13:06:09 +0000 (09:06 -0400)
21 files changed:
src/Module/Admin/BaseUsers.php
src/Module/Contact/Posts.php
src/Module/Contact/Profile.php
src/Module/Contact/Revoke.php
src/Module/Conversation/Community.php
src/Module/Conversation/Network.php
src/Module/Debug/ActivityPubConversion.php
src/Module/Debug/Feed.php
src/Module/Debug/ItemBody.php
src/Module/Debug/Probe.php
src/Module/Debug/WebFinger.php
src/Module/Events/Json.php
src/Module/Filer/RemoveTag.php
src/Module/Filer/SaveTag.php
src/Module/Item/Activity.php
src/Module/Item/Compose.php
src/Module/Item/Follow.php
src/Module/Item/Ignore.php
src/Module/Item/Pin.php
src/Module/Item/Star.php
src/Module/Notifications/Notification.php

index 769f114ce56126e5b9f2d4bbc6744b23c08f5d9b..6f96ea589aae6051532a0315e14cf2fc2eaa2432 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module\Admin;
 
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Register;
@@ -121,7 +122,7 @@ abstract class BaseUsers extends BaseAdmin
                        $user['login_date'] = Temporal::getRelativeDate($user['login_date']);
                        $user['lastitem_date'] = Temporal::getRelativeDate($user['last-item']);
                        $user['is_admin'] = in_array($user['email'], $adminlist);
-                       $user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != local_user();
+                       $user['is_deletable'] = !$user['account_removed'] && intval($user['uid']) != Session::getLocalUser();
                        $user['deleted'] = ($user['account_removed'] ? Temporal::getRelativeDate($user['account_expires_on']) : False);
 
                        return $user;
index 78c88976c04e2fb8eafe611b5c18b90796f6dd24..78cd42b1ab7ed8954072fb3d7da6510e60806c07 100644 (file)
@@ -28,6 +28,7 @@ use Friendica\Content\Nav;
 use Friendica\Content\Widget;
 use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\Model;
 use Friendica\Module\Contact;
@@ -61,13 +62,13 @@ class Posts extends BaseModule
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return Login::form($_SERVER['REQUEST_URI']);
                }
 
                // Backward compatibility: Ensure to use the public contact when the user contact is provided
                // Remove by version 2022.03
-               $data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), local_user());
+               $data = Model\Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
                if (empty($data)) {
                        throw new NotFoundException($this->t('Contact not found.'));
                }
@@ -82,7 +83,7 @@ class Posts extends BaseModule
                        throw new NotFoundException($this->t('Contact not found.'));
                }
 
-               $localRelationship = $this->localRelationship->getForUserContact(local_user(), $contact['id']);
+               $localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
                if ($localRelationship->rel === Model\Contact::SELF) {
                        $this->baseUrl->redirect('profile/' . $contact['nick']);
                }
index 3af591a066fe62555feea1c24e7a8280a7924be8..1fc702edfa739c606af06ef7c63be05bdcfd04d6 100644 (file)
@@ -34,6 +34,7 @@ use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -74,7 +75,7 @@ class Profile extends BaseModule
 
        protected function post(array $request = [])
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return;
                }
 
@@ -82,7 +83,7 @@ class Profile extends BaseModule
 
                // Backward compatibility: The update still needs a user-specific contact ID
                // Change to user-contact table check by version 2022.03
-               $cdata = Contact::getPublicAndUserContactID($contact_id, local_user());
+               $cdata = Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
                if (empty($cdata['user']) || !DBA::exists('contact', ['id' => $cdata['user'], 'deleted' => false])) {
                        return;
                }
@@ -124,20 +125,20 @@ class Profile extends BaseModule
                        $fields['info'] = $_POST['info'];
                }
 
-               if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => local_user()])) {
+               if (!Contact::update($fields, ['id' => $cdata['user'], 'uid' => Session::getLocalUser()])) {
                        DI::sysmsg()->addNotice($this->t('Failed to update contact record.'));
                }
        }
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return Module\Security\Login::form($_SERVER['REQUEST_URI']);
                }
 
                // Backward compatibility: Ensure to use the public contact when the user contact is provided
                // Remove by version 2022.03
-               $data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), local_user());
+               $data = Contact::getPublicAndUserContactID(intval($this->parameters['id']), Session::getLocalUser());
                if (empty($data)) {
                        throw new HTTPException\NotFoundException($this->t('Contact not found.'));
                }
@@ -152,7 +153,7 @@ class Profile extends BaseModule
                        throw new HTTPException\NotFoundException($this->t('Contact not found.'));
                }
 
-               $localRelationship = $this->localRelationship->getForUserContact(local_user(), $contact['id']);
+               $localRelationship = $this->localRelationship->getForUserContact(Session::getLocalUser(), $contact['id']);
 
                if ($localRelationship->rel === Contact::SELF) {
                        $this->baseUrl->redirect('profile/' . $contact['nick'] . '/profile');
@@ -173,12 +174,12 @@ class Profile extends BaseModule
                        if ($cmd === 'block') {
                                if ($localRelationship->blocked) {
                                        // @TODO Backward compatibility, replace with $localRelationship->unblock()
-                                       Contact\User::setBlocked($contact['id'], local_user(), false);
+                                       Contact\User::setBlocked($contact['id'], Session::getLocalUser(), false);
 
                                        $message = $this->t('Contact has been unblocked');
                                } else {
                                        // @TODO Backward compatibility, replace with $localRelationship->block()
-                                       Contact\User::setBlocked($contact['id'], local_user(), true);
+                                       Contact\User::setBlocked($contact['id'], Session::getLocalUser(), true);
                                        $message = $this->t('Contact has been blocked');
                                }
 
@@ -189,12 +190,12 @@ class Profile extends BaseModule
                        if ($cmd === 'ignore') {
                                if ($localRelationship->ignored) {
                                        // @TODO Backward compatibility, replace with $localRelationship->unblock()
-                                       Contact\User::setIgnored($contact['id'], local_user(), false);
+                                       Contact\User::setIgnored($contact['id'], Session::getLocalUser(), false);
 
                                        $message = $this->t('Contact has been unignored');
                                } else {
                                        // @TODO Backward compatibility, replace with $localRelationship->block()
-                                       Contact\User::setIgnored($contact['id'], local_user(), true);
+                                       Contact\User::setIgnored($contact['id'], Session::getLocalUser(), true);
                                        $message = $this->t('Contact has been ignored');
                                }
 
@@ -223,8 +224,8 @@ class Profile extends BaseModule
                        '$baseurl' => $this->baseUrl->get(true),
                ]);
 
-               $contact['blocked']  = Contact\User::isBlocked($contact['id'], local_user());
-               $contact['readonly'] = Contact\User::isIgnored($contact['id'], local_user());
+               $contact['blocked']  = Contact\User::isBlocked($contact['id'], Session::getLocalUser());
+               $contact['readonly'] = Contact\User::isIgnored($contact['id'], Session::getLocalUser());
 
                switch ($localRelationship->rel) {
                        case Contact::FRIEND:   $relation_text = $this->t('You are mutual friends with %s', $contact['name']); break;
@@ -485,7 +486,7 @@ class Profile extends BaseModule
         */
        private static function updateContactFromProbe(int $contact_id)
        {
-               $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, local_user()], 'deleted' => false]);
+               $contact = DBA::selectFirst('contact', ['url'], ['id' => $contact_id, 'uid' => [0, Session::getLocalUser()], 'deleted' => false]);
                if (!DBA::isResult($contact)) {
                        return;
                }
index 4ade2b146a25781d91af4a0ee735b766146de719..d3c594d4c259987e71518f96da0592b1f2eb7d72 100644 (file)
@@ -27,6 +27,7 @@ use Friendica\Content\Nav;
 use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Database\Database;
 use Friendica\DI;
 use Friendica\Model;
@@ -54,11 +55,11 @@ class Revoke extends BaseModule
 
                $this->dba     = $dba;
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return;
                }
 
-               $data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], local_user());
+               $data = Model\Contact::getPublicAndUserContactID($this->parameters['id'], Session::getLocalUser());
                if (!$this->dba->isResult($data)) {
                        throw new HTTPException\NotFoundException($this->t('Unknown contact.'));
                }
@@ -80,7 +81,7 @@ class Revoke extends BaseModule
 
        protected function post(array $request = [])
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\UnauthorizedException();
                }
 
@@ -95,7 +96,7 @@ class Revoke extends BaseModule
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return Login::form($_SERVER['REQUEST_URI']);
                }
 
index 539905503f50259b774e4c04db119e244235a897..2b5583f7303cb717c3a999e45076e57ec46f5d76 100644 (file)
@@ -74,7 +74,7 @@ class Community extends BaseModule
                        '$global_community_hint' => DI::l10n()->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.")
                ]);
 
-               if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
+               if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
                        $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
                        $o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
                }
@@ -111,7 +111,7 @@ class Community extends BaseModule
 
                        DI::page()['aside'] .= Widget::accountTypes('community/' . self::$content, self::$accountTypeString);
        
-                       if (local_user() && DI::config()->get('system', 'community_no_sharer')) {
+                       if (Session::getLocalUser() && DI::config()->get('system', 'community_no_sharer')) {
                                $path = self::$content;
                                if (!empty($this->parameters['accounttype'])) {
                                        $path .= '/' . $this->parameters['accounttype'];
@@ -140,7 +140,7 @@ class Community extends BaseModule
                                ]);
                        }
        
-                       if (Feature::isEnabled(local_user(), 'trending_tags')) {
+                       if (Feature::isEnabled(Session::getLocalUser(), 'trending_tags')) {
                                DI::page()['aside'] .= TrendingTags::getHTML(self::$content);
                        }
 
@@ -157,7 +157,7 @@ class Community extends BaseModule
                        return $o;
                }
 
-               $o .= DI::conversation()->create($items, 'community', false, false, 'commented', local_user());
+               $o .= DI::conversation()->create($items, 'community', false, false, 'commented', Session::getLocalUser());
 
                $pager = new BoundariesPager(
                        DI::l10n(),
@@ -167,7 +167,7 @@ class Community extends BaseModule
                        self::$itemsPerPage
                );
 
-               if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
+               if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
                        $o .= HTML::scrollLoader();
                } else {
                        $o .= $pager->renderMinimal(count($items));
@@ -230,10 +230,10 @@ class Community extends BaseModule
                }
 
                if (DI::mode()->isMobile()) {
-                       self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                       self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
                                DI::config()->get('system', 'itemspage_network_mobile'));
                } else {
-                       self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                       self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
                                DI::config()->get('system', 'itemspage_network'));
                }
 
@@ -335,9 +335,9 @@ class Community extends BaseModule
                        $condition[0] .= " AND `id` = ?";
                        $condition[] = $item_id;
                } else {
-                       if (local_user() && !empty($_REQUEST['no_sharer'])) {
+                       if (Session::getLocalUser() && !empty($_REQUEST['no_sharer'])) {
                                $condition[0] .= " AND NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ?)";
-                               $condition[] = local_user();
+                               $condition[] = Session::getLocalUser();
                        }
        
                        if (isset($max_id)) {
index ed32744d38f83bbb2903e117b20ec787fe15b6d5..a7696a0ec6e6cfc24fa731fbacf0439aa84f8ca2 100644 (file)
@@ -78,7 +78,7 @@ class Network extends BaseModule
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return Login::form();
                }
 
@@ -88,8 +88,8 @@ class Network extends BaseModule
 
                DI::page()['aside'] .= Widget::accountTypes($module, self::$accountTypeString);
                DI::page()['aside'] .= Group::sidebarWidget($module, $module . '/group', 'standard', self::$groupId);
-               DI::page()['aside'] .= ForumManager::widget($module . '/forum', local_user(), self::$forumContactId);
-               DI::page()['aside'] .= Widget::postedByYear($module . '/archive', local_user(), false);
+               DI::page()['aside'] .= ForumManager::widget($module . '/forum', Session::getLocalUser(), self::$forumContactId);
+               DI::page()['aside'] .= Widget::postedByYear($module . '/archive', Session::getLocalUser(), false);
                DI::page()['aside'] .= Widget::networks($module, !self::$forumContactId ? self::$network : '');
                DI::page()['aside'] .= Widget\SavedSearches::getHTML(DI::args()->getQueryString());
                DI::page()['aside'] .= Widget::fileAs('filed', '');
@@ -105,7 +105,7 @@ class Network extends BaseModule
 
                $items = self::getItems($table, $params);
 
-               if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
+               if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
                        $tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
                        $o .= Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
                }
@@ -138,7 +138,7 @@ class Network extends BaseModule
                                $allowedCids[] = (int) self::$forumContactId;
                        } elseif (self::$network) {
                                $condition = [
-                                       'uid'     => local_user(),
+                                       'uid'     => Session::getLocalUser(),
                                        'network' => self::$network,
                                        'self'    => false,
                                        'blocked' => false,
@@ -168,7 +168,7 @@ class Network extends BaseModule
                }
 
                if (self::$groupId) {
-                       $group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => local_user()]);
+                       $group = DBA::selectFirst('group', ['name'], ['id' => self::$groupId, 'uid' => Session::getLocalUser()]);
                        if (!DBA::isResult($group)) {
                                DI::sysmsg()->addNotice(DI::l10n()->t('No such group'));
                        }
@@ -199,9 +199,9 @@ class Network extends BaseModule
                        $ordering = '`commented`';
                }
 
-               $o .= DI::conversation()->create($items, 'network', false, false, $ordering, local_user());
+               $o .= DI::conversation()->create($items, 'network', false, false, $ordering, Session::getLocalUser());
 
-               if (DI::pConfig()->get(local_user(), 'system', 'infinite_scroll')) {
+               if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll')) {
                        $o .= HTML::scrollLoader();
                } else {
                        $pager = new BoundariesPager(
@@ -307,7 +307,7 @@ class Network extends BaseModule
 
                self::$forumContactId = $this->parameters['contact_id'] ?? 0;
 
-               self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(local_user(), 'network.view', 'selected_tab', ''));
+               self::$selectedTab = DI::session()->get('network-tab', DI::pConfig()->get(Session::getLocalUser(), 'network.view', 'selected_tab', ''));
 
                if (!empty($get['star'])) {
                        self::$selectedTab = 'star';
@@ -346,7 +346,7 @@ class Network extends BaseModule
                }
 
                DI::session()->set('network-tab', self::$selectedTab);
-               DI::pConfig()->set(local_user(), 'network.view', 'selected_tab', self::$selectedTab);
+               DI::pConfig()->set(Session::getLocalUser(), 'network.view', 'selected_tab', self::$selectedTab);
 
                self::$accountTypeString = $get['accounttype'] ?? $this->parameters['accounttype'] ?? '';
                self::$accountType = User::getAccountTypeByString(self::$accountTypeString);
@@ -357,10 +357,10 @@ class Network extends BaseModule
                self::$dateTo = $this->parameters['to'] ?? '';
 
                if (DI::mode()->isMobile()) {
-                       self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                       self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
                                DI::config()->get('system', 'itemspage_network_mobile'));
                } else {
-                       self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                       self::$itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
                                DI::config()->get('system', 'itemspage_network'));
                }
 
@@ -385,7 +385,7 @@ class Network extends BaseModule
 
        protected static function getItems(string $table, array $params, array $conditionFields = [])
        {
-               $conditionFields['uid'] = local_user();
+               $conditionFields['uid'] = Session::getLocalUser();
                $conditionStrings = [];
 
                if (!is_null(self::$accountType)) {
@@ -414,7 +414,7 @@ class Network extends BaseModule
                } elseif (self::$forumContactId) {
                        $conditionStrings = DBA::mergeConditions($conditionStrings, 
                                ["((`contact-id` = ?) OR `uri-id` IN (SELECT `parent-uri-id` FROM `post-user-view` WHERE (`contact-id` = ? AND `gravity` = ? AND `vid` = ? AND `uid` = ?)))",
-                               self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), local_user()]);
+                               self::$forumContactId, self::$forumContactId, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Session::getLocalUser()]);
                }
 
                // Currently only the order modes "received" and "commented" are in use
@@ -478,10 +478,10 @@ class Network extends BaseModule
                // level which items you've seen and which you haven't. If you're looking
                // at the top level network page just mark everything seen.
                if (!self::$groupId && !self::$forumContactId && !self::$star && !self::$mention) {
-                       $condition = ['unseen' => true, 'uid' => local_user()];
+                       $condition = ['unseen' => true, 'uid' => Session::getLocalUser()];
                        self::setItemsSeenByCondition($condition);
                } elseif (!empty($parents)) {
-                       $condition = ['unseen' => true, 'uid' => local_user(), 'parent-uri-id' => $parents];
+                       $condition = ['unseen' => true, 'uid' => Session::getLocalUser(), 'parent-uri-id' => $parents];
                        self::setItemsSeenByCondition($condition);
                }
 
index 8593de81c0cf505cf1b4f82a4a7416dc4df51c22..310727d2fe1be7b56221a6defc8127b6411f6690 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module\Debug;
 
 use Friendica\BaseModule;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Util\JsonLD;
@@ -41,7 +42,7 @@ class ActivityPubConversion extends BaseModule
                        try {
                                $source = json_decode($_REQUEST['source'], true);
                                $trust_source = true;
-                               $uid = local_user();
+                               $uid = Session::getLocalUser();
                                $push = false;
 
                                if (!$source) {
index fc9f95f07c713a3c5ee1d1ee95626feb857c146b..97b572a1cafc5b616e0ad0ff7f863a46be7eb59f 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Model;
 use Friendica\Module\Response;
@@ -48,7 +49,7 @@ class Feed extends BaseModule
 
                $this->httpClient = $httpClient;
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        DI::sysmsg()->addNotice($this->t('You must be logged in to use this module'));
                        $baseUrl->redirect();
                }
@@ -60,7 +61,7 @@ class Feed extends BaseModule
                if (!empty($_REQUEST['url'])) {
                        $url = $_REQUEST['url'];
 
-                       $contact = Model\Contact::getByURLForUser($url, local_user(), null);
+                       $contact = Model\Contact::getByURLForUser($url, Session::getLocalUser(), null);
 
                        $xml = $this->httpClient->fetch($contact['poll'], HttpClientAccept::FEED_XML);
 
index a9a3c0b50b0f593022b59568b562cb1d324d79ef..ff392221281e9bfb661c3a70e6768e4a4be28ec4 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module\Debug;
 
 use Friendica\BaseModule;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\Post;
@@ -34,7 +35,7 @@ class ItemBody extends BaseModule
 {
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
                }
 
@@ -44,7 +45,7 @@ class ItemBody extends BaseModule
 
                $itemId = intval($this->parameters['item']);
 
-               $item = Post::selectFirst(['body'], ['uid' => [0, local_user()], 'uri-id' => $itemId]);
+               $item = Post::selectFirst(['body'], ['uid' => [0, Session::getLocalUser()], 'uri-id' => $itemId]);
 
                if (!empty($item)) {
                        if (DI::mode()->isAjax()) {
index fa2cb36873c755eee5bfc5e500da804602602b77..2c04fff91d35a254a57d76f3e07321a00b2b2e40 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module\Debug;
 
 use Friendica\BaseModule;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Network\HTTPException;
 use Friendica\Network\Probe as NetworkProbe;
@@ -34,7 +35,7 @@ class Probe extends BaseModule
 {
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.'));
                }
 
index 3ba04b1fe4910382e1950dceb27ca7cd0aa66173..ae0e4446b3a82e2322a5d998fa190460fc6a51a2 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module\Debug;
 
 use Friendica\BaseModule;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Network\Probe;
 
@@ -33,7 +34,7 @@ class WebFinger extends BaseModule
 {
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new \Friendica\Network\HTTPException\ForbiddenException(DI::l10n()->t('Only logged in users are permitted to perform a probing.'));
                }
 
index dac6e5c1b31ac6f1f96b76f184ef2f27a0408dc2..15950444532dc927324a4f9820927854e82d933e 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Events;
 
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -35,7 +36,7 @@ class Json extends \Friendica\BaseModule
 {
        protected function rawContent(array $request = [])
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\UnauthorizedException();
                }
 
@@ -69,9 +70,9 @@ class Json extends \Friendica\BaseModule
 
                // get events by id or by date
                if ($event_params['event_id']) {
-                       $r = Event::getListById(local_user(), $event_params['event_id']);
+                       $r = Event::getListById(Session::getLocalUser(), $event_params['event_id']);
                } else {
-                       $r = Event::getListByDate(local_user(), $event_params);
+                       $r = Event::getListByDate(Session::getLocalUser(), $event_params);
                }
 
                $links = [];
index 56677e5fc9fc5d13bb3ab03a564c3cec9800340d..b940e69837407700ca71f43ebae2703f1042bcaf 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module\Filer;
 use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\L10n;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\Post;
@@ -55,7 +56,7 @@ class RemoveTag extends BaseModule
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\ForbiddenException();
                }
 
@@ -107,7 +108,7 @@ class RemoveTag extends BaseModule
                        return 404;
                }
 
-               if (!Post\Category::deleteFileByURIId($item['uri-id'], local_user(), $type, $term)) {
+               if (!Post\Category::deleteFileByURIId($item['uri-id'], Session::getLocalUser(), $type, $term)) {
                        $this->systemMessages->addNotice($this->l10n->t('Item was not removed'));
                        return 500;
                }
index c3b9acadd3c05066e2dad16d3e07bf7defc33b10..949bddd699ead1825a88374fa5c25568c9b067f2 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model;
@@ -43,7 +44,7 @@ class SaveTag extends BaseModule
        {
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        DI::sysmsg()->addNotice($this->t('You must be logged in to use this module'));
                        $baseUrl->redirect();
                }
@@ -62,11 +63,11 @@ class SaveTag extends BaseModule
                        if (!DBA::isResult($item)) {
                                throw new HTTPException\NotFoundException();
                        }
-                       Model\Post\Category::storeFileByURIId($item['uri-id'], local_user(), Model\Post\Category::FILE, $term);
+                       Model\Post\Category::storeFileByURIId($item['uri-id'], Session::getLocalUser(), Model\Post\Category::FILE, $term);
                }
 
                // return filer dialog
-               $filetags = Model\Post\Category::getArray(local_user(), Model\Post\Category::FILE);
+               $filetags = Model\Post\Category::getArray(Session::getLocalUser(), Model\Post\Category::FILE);
 
                $tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
                echo Renderer::replaceMacros($tpl, [
index 9f0b91786947858eac48257b1522335dcc2ece03..ed09e8c5dddab02c7b02182f7ff79af2c5b07eee 100644 (file)
@@ -51,13 +51,13 @@ class Activity extends BaseModule
                $itemId =  $this->parameters['id'];
 
                if (in_array($verb, ['announce', 'unannounce'])) {
-                       $item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [local_user(), 0]]);
+                       $item = Post::selectFirst(['network', 'uri-id'], ['id' => $itemId, 'uid' => [Session::getLocalUser(), 0]]);
                        if ($item['network'] == Protocol::DIASPORA) {
-                               Diaspora::performReshare($item['uri-id'], local_user());
+                               Diaspora::performReshare($item['uri-id'], Session::getLocalUser());
                        }
                }
 
-               if (!Item::performActivity($itemId, $verb, local_user())) {
+               if (!Item::performActivity($itemId, $verb, Session::getLocalUser())) {
                        throw new HTTPException\BadRequestException();
                }
 
index bd531d484b596d8becb3055e48596fff20e0082f..41d55ad3541ae65d6166f29c21c5e5565bfd02b7 100644 (file)
@@ -31,6 +31,7 @@ use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Core\Theme;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -88,7 +89,7 @@ class Compose extends BaseModule
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return Login::form('compose');
                }
 
@@ -110,7 +111,7 @@ class Compose extends BaseModule
                        }
                }
 
-               $user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
+               $user = User::getById(Session::getLocalUser(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'default-location']);
 
                $contact_allow_list = $this->ACLFormatter->expand($user['allow_cid']);
                $group_allow_list   = $this->ACLFormatter->expand($user['allow_gid']);
@@ -167,7 +168,7 @@ class Compose extends BaseModule
 
                $contact = Contact::getById($a->getContactId());
 
-               if ($this->pConfig->get(local_user(), 'system', 'set_creation_date')) {
+               if ($this->pConfig->get(Session::getLocalUser(), 'system', 'set_creation_date')) {
                        $created_at = Temporal::getDateTimeField(
                                new \DateTime(DBA::NULL_DATETIME),
                                new \DateTime('now'),
@@ -203,8 +204,8 @@ class Compose extends BaseModule
                                'location_disabled'    => $this->l10n->t('Location services are disabled. Please check the website\'s permissions on your device'),
                                'wait'                 => $this->l10n->t('Please wait'),
                                'placeholdertitle'     => $this->l10n->t('Set title'),
-                               'placeholdercategory'  => Feature::isEnabled(local_user(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
-                               'always_open_compose'  => $this->pConfig->get(local_user(), 'frio', 'always_open_compose',
+                               'placeholdercategory'  => Feature::isEnabled(Session::getLocalUser(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '',
+                               'always_open_compose'  => $this->pConfig->get(Session::getLocalUser(), 'frio', 'always_open_compose',
                                        $this->config->get('frio', 'always_open_compose', false)) ? '' :
                                                $this->l10n->t('You can make this page always open when you use the New Post button in the <a href="/settings/display">Theme Customization settings</a>.'),
                        ],
index d3df85298fa8edc67c6ea1e28ced185380bf67a3..331e5fe760467c93e6c554a8bab3fe5900f2e355 100644 (file)
@@ -48,7 +48,7 @@ class Follow extends BaseModule
 
                $itemId = intval($this->parameters['id']);
 
-               if (!Item::performActivity($itemId, 'follow', local_user())) {
+               if (!Item::performActivity($itemId, 'follow', Session::getLocalUser())) {
                        throw new HTTPException\BadRequestException($l10n->t('Unable to follow this item.'));
                }
 
index 4ccc559eb306edf635b9f111eaa92b25444c2d4b..86e3172b4a89afb28482a303bb961cc159997b2d 100644 (file)
@@ -55,10 +55,10 @@ class Ignore extends BaseModule
                        throw new HTTPException\NotFoundException();
                }
 
-               $ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], local_user());
+               $ignored = !Post\ThreadUser::getIgnored($thread['uri-id'], Session::getLocalUser());
 
-               if (in_array($thread['uid'], [0, local_user()])) {
-                       Post\ThreadUser::setIgnored($thread['uri-id'], local_user(), $ignored);
+               if (in_array($thread['uid'], [0, Session::getLocalUser()])) {
+                       Post\ThreadUser::setIgnored($thread['uri-id'], Session::getLocalUser(), $ignored);
                } else {
                        throw new HTTPException\BadRequestException();
                }
index 3b52b44a127105151a6fb6e7000827de1f7ffa40..22e8a26796b13157629e2525fe868357fe132749 100644 (file)
@@ -53,16 +53,16 @@ class Pin extends BaseModule
                        throw new HTTPException\NotFoundException();
                }
 
-               if (!in_array($item['uid'], [0, local_user()])) {
+               if (!in_array($item['uid'], [0, Session::getLocalUser()])) {
                        throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
                }
 
                $pinned = !$item['featured'];
 
                if ($pinned) {
-                       Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], local_user());
+                       Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], Session::getLocalUser());
                } else {
-                       Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, local_user());
+                       Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, Session::getLocalUser());
                }
 
                // See if we've been passed a return path to redirect to
index 660095103d40103b677964e8cedc47c08b1bb660..02222cb03a0182b09c61e01329e38128c920d521 100644 (file)
@@ -50,13 +50,13 @@ class Star extends BaseModule
                $itemId = intval($this->parameters['id']);
 
 
-               $item = Post::selectFirstForUser(local_user(), ['uid', 'uri-id', 'starred'], ['uid' => [0, local_user()], 'id' => $itemId]);
+               $item = Post::selectFirstForUser(Session::getLocalUser(), ['uid', 'uri-id', 'starred'], ['uid' => [0, Session::getLocalUser()], 'id' => $itemId]);
                if (empty($item)) {
                        throw new HTTPException\NotFoundException();
                }
 
                if ($item['uid'] == 0) {
-                       $stored = Item::storeForUserByUriId($item['uri-id'], local_user(), ['post-reason' => Item::PR_ACTIVITY]);
+                       $stored = Item::storeForUserByUriId($item['uri-id'], Session::getLocalUser(), ['post-reason' => Item::PR_ACTIVITY]);
                        if (!empty($stored)) {
                                $item = Post::selectFirst(['starred'], ['id' => $stored]);
                                if (!DBA::isResult($item)) {
index cacf57ec0987cb02b0768f57bbf26bb26db9326e..15364615fdc225aef0caeb57038d0b18ec3f8c79 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\BaseModule;
 use Friendica\Contact\Introduction\Repository\Introduction;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -72,14 +73,14 @@ class Notification extends BaseModule
         */
        protected function post(array $request = [])
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
                }
 
                $request_id = $this->parameters['id'] ?? false;
 
                if ($request_id) {
-                       $intro = $this->introductionRepo->selectOneById($request_id, local_user());
+                       $intro = $this->introductionRepo->selectOneById($request_id, Session::getLocalUser());
 
                        switch ($_POST['submit']) {
                                case $this->l10n->t('Discard'):
@@ -103,14 +104,14 @@ class Notification extends BaseModule
         */
        protected function rawContent(array $request = [])
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\UnauthorizedException($this->l10n->t('Permission denied.'));
                }
 
                if ($this->args->get(1) === 'mark' && $this->args->get(2) === 'all') {
                        try {
-                               $this->notificationRepo->setAllSeenForUser(local_user());
-                               $success = $this->notifyRepo->setAllSeenForUser(local_user());
+                               $this->notificationRepo->setAllSeenForUser(Session::getLocalUser());
+                               $success = $this->notifyRepo->setAllSeenForUser(Session::getLocalUser());
                        } catch (\Exception $e) {
                                $this->logger->warning('set all seen failed.', ['exception' => $e]);
                                $success = false;
@@ -131,7 +132,7 @@ class Notification extends BaseModule
         */
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        DI::sysmsg()->addNotice($this->l10n->t('You must be logged in to show this page.'));
                        return Login::form();
                }
@@ -150,11 +151,11 @@ class Notification extends BaseModule
        private function handleNotify(int $notifyId)
        {
                $Notify = $this->notifyRepo->selectOneById($notifyId);
-               if ($Notify->uid !== local_user()) {
+               if ($Notify->uid !== Session::getLocalUser()) {
                        throw new HTTPException\ForbiddenException();
                }
 
-               if ($this->pconfig->get(local_user(), 'system', 'detailed_notif')) {
+               if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
                        $Notify->setSeen();
                        $this->notifyRepo->save($Notify);
                } else {
@@ -175,11 +176,11 @@ class Notification extends BaseModule
        private function handleNotification(int $notificationId)
        {
                $Notification = $this->notificationRepo->selectOneById($notificationId);
-               if ($Notification->uid !== local_user()) {
+               if ($Notification->uid !== Session::getLocalUser()) {
                        throw new HTTPException\ForbiddenException();
                }
 
-               if ($this->pconfig->get(local_user(), 'system', 'detailed_notif')) {
+               if ($this->pconfig->get(Session::getLocalUser(), 'system', 'detailed_notif')) {
                        $Notification->setSeen();
                        $this->notificationRepo->save($Notification);
                } else {