]> git.mxchange.org Git - friendica.git/commitdiff
old boot.php functions replaced in src/module
authorMichael <heluecht@pirati.ca>
Wed, 19 Oct 2022 04:31:58 +0000 (04:31 +0000)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 19 Oct 2022 12:53:45 +0000 (08:53 -0400)
21 files changed:
src/Module/Apps.php
src/Module/BaseAdmin.php
src/Module/BaseNotifications.php
src/Module/BaseSearch.php
src/Module/Bookmarklet.php
src/Module/Contact.php
src/Module/Delegation.php
src/Module/Directory.php
src/Module/Feed.php
src/Module/FollowConfirm.php
src/Module/FriendSuggest.php
src/Module/Group.php
src/Module/HCard.php
src/Module/Home.php
src/Module/Invite.php
src/Module/Magic.php
src/Module/NoScrape.php
src/Module/PermissionTooltip.php
src/Module/Photo.php
src/Module/Proxy.php
src/Module/Register.php

index 9ef4268de53a348ab2a3e23780b4065e28745783..36a980c29d2c737650ecec6abe24a1a46459487c 100644 (file)
@@ -28,6 +28,7 @@ use Friendica\Content\Nav;
 use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Util\Profiler;
 use Psr\Log\LoggerInterface;
@@ -42,7 +43,7 @@ class Apps extends BaseModule
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
                $privateaddons = $config->get('config', 'private_addons');
-               if ($privateaddons === "1" && !local_user()) {
+               if ($privateaddons === "1" && !Session::getLocalUser()) {
                        $baseUrl->redirect();
                }
        }
index dd4e108e77677432ff5f7f7c1cd26b509ace93aa..f383941c432822d09b8ed180860a113220bb66f3 100644 (file)
@@ -52,7 +52,7 @@ abstract class BaseAdmin extends BaseModule
         */
        public static function checkAdminAccess(bool $interactive = false)
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        if ($interactive) {
                                DI::sysmsg()->addNotice(DI::l10n()->t('Please login to continue.'));
                                Session::set('return_path', DI::args()->getQueryString());
index 1190e046dfb6ea8742db87fa4a1a4fd258adae1d..9e7456c7b5d813950dd24c3c4acc23754ef9d9db 100644 (file)
@@ -28,6 +28,7 @@ use Friendica\BaseModule;
 use Friendica\Content\Pager;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Navigation\Notifications\ValueObject\FormattedNotify;
 use Friendica\Network\HTTPException\ForbiddenException;
@@ -93,7 +94,7 @@ abstract class BaseNotifications extends BaseModule
        {
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new ForbiddenException($this->t('Permission denied.'));
                }
 
index f14a93b0ff5148dec89cdaf6eb71b179dd270208..3aae68f7b23f63f004c7c4df5e4710520117b745 100644 (file)
@@ -25,6 +25,7 @@ use Friendica\BaseModule;
 use Friendica\Content\Pager;
 use Friendica\Core\Renderer;
 use Friendica\Core\Search;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Model;
 use Friendica\Network\HTTPException;
@@ -82,10 +83,10 @@ class BaseSearch extends BaseModule
                $search = Network::convertToIdn($search);
 
                if (DI::mode()->isMobile()) {
-                       $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
+                       $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network',
                                DI::config()->get('system', 'itemspage_network_mobile'));
                } else {
-                       $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
+                       $itemsPerPage = DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network',
                                DI::config()->get('system', 'itemspage_network'));
                }
 
@@ -125,7 +126,7 @@ class BaseSearch extends BaseModule
 
                        // in case the result is a contact result, add a contact-specific entry
                        if ($result instanceof ContactResult) {
-                               $contact = Model\Contact::getByURLForUser($result->getUrl(), local_user());
+                               $contact = Model\Contact::getByURLForUser($result->getUrl(), Session::getLocalUser());
                                if (!empty($contact)) {
                                        $entries[] = Contact::getContactTemplateVars($contact);
                                }
index 970eb4790f66507d2cf9b1abf53fb3326214db86..7a4ea37a7b9c0a608d64d81490c471a9f654b63b 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Content\PageInfo;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Module\Security\Login;
 use Friendica\Network\HTTPException;
@@ -40,7 +41,7 @@ class Bookmarklet extends BaseModule
 
                $config = DI::config();
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        $output = '<h2>' . DI::l10n()->t('Login') . '</h2>';
                        $output .= Login::form(DI::args()->getQueryString(), intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
                        return $output;
index 97f4b7e258b3f85e753e96c4f25dec2797b82851..25ced78305324bd29fa1560317aa6a091a064aa3 100644 (file)
@@ -28,6 +28,7 @@ use Friendica\Content\Pager;
 use Friendica\Content\Widget;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Core\Theme;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -59,12 +60,12 @@ class Contact extends BaseModule
 
                self::checkFormSecurityTokenRedirectOnError($redirectUrl, 'contact_batch_actions');
 
-               $orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]);
+               $orig_records = Model\Contact::selectToArray(['id', 'uid'], ['id' => $_POST['contact_batch'], 'uid' => [0, Session::getLocalUser()], 'self' => false, 'deleted' => false]);
 
                $count_actions = 0;
                foreach ($orig_records as $orig_record) {
-                       $cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], local_user());
-                       if (empty($cdata) || public_contact() === $cdata['public']) {
+                       $cdata = Model\Contact::getPublicAndUserContactID($orig_record['id'], Session::getLocalUser());
+                       if (empty($cdata) || Session::getPublicContact() === $cdata['public']) {
                                // No action available on your own contact
                                continue;
                        }
@@ -75,7 +76,7 @@ class Contact extends BaseModule
                        }
 
                        if (!empty($_POST['contacts_batch_block'])) {
-                               self::toggleBlockContact($cdata['public'], local_user());
+                               self::toggleBlockContact($cdata['public'], Session::getLocalUser());
                                $count_actions++;
                        }
 
@@ -93,7 +94,7 @@ class Contact extends BaseModule
 
        protected function post(array $request = [])
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return;
                }
 
@@ -113,7 +114,7 @@ class Contact extends BaseModule
         */
        public static function updateContactFromPoll(int $contact_id)
        {
-               $contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => local_user(), 'deleted' => false]);
+               $contact = DBA::selectFirst('contact', ['uid', 'url', 'network'], ['id' => $contact_id, 'uid' => Session::getLocalUser(), 'deleted' => false]);
                if (!DBA::isResult($contact)) {
                        return;
                }
@@ -153,13 +154,13 @@ class Contact extends BaseModule
         */
        private static function toggleIgnoreContact(int $contact_id)
        {
-               $ignored = !Model\Contact\User::isIgnored($contact_id, local_user());
-               Model\Contact\User::setIgnored($contact_id, local_user(), $ignored);
+               $ignored = !Model\Contact\User::isIgnored($contact_id, Session::getLocalUser());
+               Model\Contact\User::setIgnored($contact_id, Session::getLocalUser(), $ignored);
        }
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return Login::form($_SERVER['REQUEST_URI']);
                }
 
@@ -203,7 +204,7 @@ class Contact extends BaseModule
 
                $_SESSION['return_path'] = DI::args()->getQueryString();
 
-               $sql_values = [local_user()];
+               $sql_values = [Session::getLocalUser()];
 
                // @TODO: Replace with parameter from router
                $type = DI::args()->getArgv()[1] ?? '';
@@ -229,7 +230,7 @@ class Contact extends BaseModule
                                $sql_extra = " AND `pending` AND NOT `archive` AND NOT `failed` AND ((`rel` = ?)
                                        OR `id` IN (SELECT `contact-id` FROM `intro` WHERE `intro`.`uid` = ? AND NOT `ignore`))";
                                $sql_values[] = Model\Contact::SHARING;
-                               $sql_values[] = local_user();
+                               $sql_values[] = Session::getLocalUser();
                                break;
                        default:
                                $sql_extra = " AND NOT `archive` AND NOT `blocked` AND NOT `pending`";
@@ -298,8 +299,8 @@ class Contact extends BaseModule
                $stmt = DBA::select('contact', [], $condition, ['order' => ['name'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
 
                while ($contact = DBA::fetch($stmt)) {
-                       $contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], local_user());
-                       $contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], local_user());
+                       $contact['blocked'] = Model\Contact\User::isBlocked($contact['id'], Session::getLocalUser());
+                       $contact['readonly'] = Model\Contact\User::isIgnored($contact['id'], Session::getLocalUser());
                        $contacts[] = self::getContactTemplateVars($contact);
                }
                DBA::close($stmt);
@@ -423,7 +424,7 @@ class Contact extends BaseModule
        public static function getTabsHTML(array $contact, int $active_tab)
        {
                $cid = $pcid = $contact['id'];
-               $data = Model\Contact::getPublicAndUserContactID($contact['id'], local_user());
+               $data = Model\Contact::getPublicAndUserContactID($contact['id'], Session::getLocalUser());
                if (!empty($data['user']) && ($contact['id'] == $data['public'])) {
                        $cid = $data['user'];
                } elseif (!empty($data['public'])) {
@@ -499,8 +500,8 @@ class Contact extends BaseModule
        {
                $alt_text = '';
 
-               if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && local_user()) {
-                       $personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], local_user());
+               if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && Session::getLocalUser()) {
+                       $personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], Session::getLocalUser());
                        if (!empty($personal)) {
                                $contact['uid'] = $personal['uid'];
                                $contact['rel'] = $personal['rel'];
@@ -508,7 +509,7 @@ class Contact extends BaseModule
                        }
                }
 
-               if (!empty($contact['uid']) && !empty($contact['rel']) && local_user() == $contact['uid']) {
+               if (!empty($contact['uid']) && !empty($contact['rel']) && Session::getLocalUser() == $contact['uid']) {
                        switch ($contact['rel']) {
                                case Model\Contact::FRIEND:
                                        $alt_text = DI::l10n()->t('Mutual Friendship');
index fc86e9b64e05a7e874c5835f55742911174d2baa..ba1f0298d70841f7a4258ed7a016354be642b79d 100644 (file)
@@ -38,11 +38,11 @@ class Delegation extends BaseModule
 {
        protected function post(array $request = [])
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        return;
                }
 
-               $uid = local_user();
+               $uid = Session::getLocalUser();
                $orig_record = User::getById(DI::app()->getLoggedInUserId());
 
                if (DI::session()->get('submanage')) {
@@ -114,11 +114,11 @@ class Delegation extends BaseModule
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
 
-               $identities = User::identities(DI::session()->get('submanage', local_user()));
+               $identities = User::identities(DI::session()->get('submanage', Session::getLocalUser()));
 
                //getting additinal information for each identity
                foreach ($identities as $key => $identity) {
index f48e2bf7e3b7c8f314b00056fd62857ac5f710ee..4e62c40ef799205f1c229222e97bdca920d99c07 100644 (file)
@@ -49,7 +49,7 @@ class Directory extends BaseModule
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
                }
 
-               if (local_user()) {
+               if (Session::getLocalUser()) {
                        DI::page()['aside'] .= Widget::findPeople();
                        DI::page()['aside'] .= Widget::follow();
                }
@@ -75,7 +75,7 @@ class Directory extends BaseModule
                        DI::sysmsg()->addNotice(DI::l10n()->t('No entries (some entries may be hidden).'));
                } else {
                        foreach ($profiles['entries'] as $entry) {
-                               $contact = Model\Contact::getByURLForUser($entry['url'], local_user());
+                               $contact = Model\Contact::getByURLForUser($entry['url'], Session::getLocalUser());
                                if (!empty($contact)) {
                                        $entries[] = Contact::getContactTemplateVars($contact);
                                }
index 4c942cd762c1608a0a6a73c62d86e49ca0eaa763..1465e10e7196a349ecf999924b20c8a10d2fa001 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Protocol\Feed as ProtocolFeed;
@@ -46,7 +47,7 @@ class Feed extends BaseModule
        protected function rawContent(array $request = [])
        {
                $last_update = $this->getRequestValue($request, 'last_update', '');
-               $nocache     = !empty($request['nocache']) && local_user();
+               $nocache     = !empty($request['nocache']) && Session::getLocalUser();
 
                $type = null;
                // @TODO: Replace with parameter from router
index 0254bfae3469a6abde0fff3d65bcdb6c6743bcfe..176466dc4343572acb13b4fca9446f9bd1b5e03c 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Model\Contact;
 
@@ -33,7 +34,7 @@ class FollowConfirm extends BaseModule
        protected function post(array $request = [])
        {
                parent::post($request);
-               $uid = local_user();
+               $uid = Session::getLocalUser();
                if (!$uid) {
                        DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                        return;
@@ -43,7 +44,7 @@ class FollowConfirm extends BaseModule
                $duplex   = intval($_POST['duplex']     ?? 0);
                $hidden   = intval($_POST['hidden']     ?? 0);
 
-               $intro = DI::intro()->selectOneById($intro_id, local_user());
+               $intro = DI::intro()->selectOneById($intro_id, Session::getLocalUser());
 
                Contact\Introduction::confirm($intro, $duplex, $hidden);
                DI::intro()->delete($intro);
index 815c4e1ec89c2ca1453e644898d245159c93026e..df509885cdf8c01de29f5690aabeb1e7d1aed145 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\BaseModule;
 use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Core\Worker;
 use Friendica\Database\Database;
 use Friendica\DI;
@@ -53,7 +54,7 @@ class FriendSuggest extends BaseModule
        {
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new ForbiddenException($this->t('Permission denied.'));
                }
 
@@ -67,7 +68,7 @@ class FriendSuggest extends BaseModule
                $cid = intval($this->parameters['contact']);
 
                // We do query the "uid" as well to ensure that it is our contact
-               if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => local_user()])) {
+               if (!$this->dba->exists('contact', ['id' => $cid, 'uid' => Session::getLocalUser()])) {
                        throw new NotFoundException($this->t('Contact not found.'));
                }
 
@@ -77,7 +78,7 @@ class FriendSuggest extends BaseModule
                }
 
                // We do query the "uid" as well to ensure that it is our contact
-               $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => local_user()]);
+               $contact = $this->dba->selectFirst('contact', ['name', 'url', 'request', 'avatar'], ['id' => $suggest_contact_id, 'uid' => Session::getLocalUser()]);
                if (empty($contact)) {
                        DI::sysmsg()->addNotice($this->t('Suggested contact not found.'));
                        return;
@@ -86,7 +87,7 @@ class FriendSuggest extends BaseModule
                $note = Strings::escapeHtml(trim($_POST['note'] ?? ''));
 
                $suggest = $this->friendSuggestRepo->save($this->friendSuggestFac->createNew(
-                       local_user(),
+                       Session::getLocalUser(),
                        $cid,
                        $contact['name'],
                        $contact['url'],
@@ -104,7 +105,7 @@ class FriendSuggest extends BaseModule
        {
                $cid = intval($this->parameters['contact']);
 
-               $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]);
+               $contact = $this->dba->selectFirst('contact', [], ['id' => $cid, 'uid' => Session::getLocalUser()]);
                if (empty($contact)) {
                        DI::sysmsg()->addNotice($this->t('Contact not found.'));
                        $this->baseUrl->redirect();
@@ -120,7 +121,7 @@ class FriendSuggest extends BaseModule
                        AND NOT `archive` 
                        AND NOT `deleted` 
                        AND `notify` != ""',
-                       local_user(),
+                       Session::getLocalUser(),
                        $cid,
                        Protocol::DFRN,
                ]);
index 06ee555a74af728d2b4da220d61cff1913934a29..a583c585a1aba0356c8f7f4724fe27c0249fd9a3 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -38,7 +39,7 @@ class Group extends BaseModule
                        $this->ajaxPost();
                }
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                        DI::baseUrl()->redirect();
                }
@@ -48,9 +49,9 @@ class Group extends BaseModule
                        BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
 
                        $name = trim($request['groupname']);
-                       $r = Model\Group::create(local_user(), $name);
+                       $r = Model\Group::create(Session::getLocalUser(), $name);
                        if ($r) {
-                               $r = Model\Group::getIdByName(local_user(), $name);
+                               $r = Model\Group::getIdByName(Session::getLocalUser(), $name);
                                if ($r) {
                                        DI::baseUrl()->redirect('group/' . $r);
                                }
@@ -64,7 +65,7 @@ class Group extends BaseModule
                if ((DI::args()->getArgc() == 2) && intval(DI::args()->getArgv()[1])) {
                        BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
 
-                       $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user()]);
+                       $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser()]);
                        if (!DBA::isResult($group)) {
                                DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
                                DI::baseUrl()->redirect('contact');
@@ -81,7 +82,7 @@ class Group extends BaseModule
        public function ajaxPost()
        {
                try {
-                       if (!local_user()) {
+                       if (!Session::getLocalUser()) {
                                throw new \Exception(DI::l10n()->t('Permission denied.'), 403);
                        }
 
@@ -89,12 +90,12 @@ class Group extends BaseModule
                                $group_id = $this->parameters['group'];
                                $contact_id = $this->parameters['contact'];
 
-                               if (!Model\Group::exists($group_id, local_user())) {
+                               if (!Model\Group::exists($group_id, Session::getLocalUser())) {
                                        throw new \Exception(DI::l10n()->t('Unknown group.'), 404);
                                }
 
                                // @TODO Backward compatibility with user contacts, remove by version 2022.03
-                               $cdata = Model\Contact::getPublicAndUserContactID($contact_id, local_user());
+                               $cdata = Model\Contact::getPublicAndUserContactID($contact_id, Session::getLocalUser());
                                if (empty($cdata['public'])) {
                                        throw new \Exception(DI::l10n()->t('Contact not found.'), 404);
                                }
@@ -144,7 +145,7 @@ class Group extends BaseModule
        {
                $change = false;
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new \Friendica\Network\HTTPException\ForbiddenException();
                }
 
@@ -159,7 +160,7 @@ class Group extends BaseModule
                }
 
                // Switch to text mode interface if we have more than 'n' contacts or group members
-               $switchtotext = DI::pConfig()->get(local_user(), 'system', 'groupedit_image_limit');
+               $switchtotext = DI::pConfig()->get(Session::getLocalUser(), 'system', 'groupedit_image_limit');
                if (is_null($switchtotext)) {
                        $switchtotext = DI::config()->get('system', 'groupedit_image_limit', 200);
                }
@@ -211,7 +212,7 @@ class Group extends BaseModule
 
                        // @TODO: Replace with parameter from router
                        if (intval(DI::args()->getArgv()[2])) {
-                               if (!Model\Group::exists(DI::args()->getArgv()[2], local_user())) {
+                               if (!Model\Group::exists(DI::args()->getArgv()[2], Session::getLocalUser())) {
                                        DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
                                        DI::baseUrl()->redirect('contact');
                                }
@@ -227,14 +228,14 @@ class Group extends BaseModule
                if ((DI::args()->getArgc() > 2) && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
                        BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
 
-                       if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
+                       if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => Session::getLocalUser(), 'self' => false, 'pending' => false, 'blocked' => false])) {
                                $change = intval(DI::args()->getArgv()[2]);
                        }
                }
 
                // @TODO: Replace with parameter from router
                if ((DI::args()->getArgc() > 1) && intval(DI::args()->getArgv()[1])) {
-                       $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user(), 'deleted' => false]);
+                       $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => Session::getLocalUser(), 'deleted' => false]);
                        if (!DBA::isResult($group)) {
                                DI::sysmsg()->addNotice(DI::l10n()->t('Group not found.'));
                                DI::baseUrl()->redirect('contact');
@@ -317,11 +318,11 @@ class Group extends BaseModule
                }
 
                if ($nogroup) {
-                       $contacts = Model\Contact\Group::listUngrouped(local_user());
+                       $contacts = Model\Contact\Group::listUngrouped(Session::getLocalUser());
                } else {
                        $contacts_stmt = DBA::select('contact', [],
                                ['rel' => [Model\Contact::FOLLOWER, Model\Contact::FRIEND, Model\Contact::SHARING],
-                               'uid' => local_user(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
+                               'uid' => Session::getLocalUser(), 'pending' => false, 'blocked' => false, 'failed' => false, 'self' => false],
                                ['order' => ['name']]
                        );
                        $contacts = DBA::toArray($contacts_stmt);
index cb84c1aa94dec41fc115510e1b1fcd77fb09364a..aee93e34b53533f3af28c8d3abaaee805f2022a4 100644 (file)
@@ -36,7 +36,7 @@ class HCard extends BaseModule
 {
        protected function content(array $request = []): string
        {
-               if ((local_user()) && ($this->parameters['action'] ?? '') === 'view') {
+               if ((Session::getLocalUser()) && ($this->parameters['action'] ?? '') === 'view') {
                        // A logged in user views a profile of a user
                        $nickname = DI::app()->getLoggedInUserNickname();
                } elseif (empty($this->parameters['action'])) {
index e384205f5cb77fb93bcb469f9af1b9b8a7883ddf..87de58a15d5d34c4be1777ad13077d2e6af271c9 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module;
 use Friendica\BaseModule;
 use Friendica\Core\Hook;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Module\Security\Login;
 
@@ -42,7 +43,7 @@ class Home extends BaseModule
 
                Hook::callAll('home_init', $ret);
 
-               if (local_user() && ($app->getLoggedInUserNickname())) {
+               if (Session::getLocalUser() && ($app->getLoggedInUserNickname())) {
                        DI::baseUrl()->redirect('network');
                }
 
index c36a8ad7d8915337986640983caf44092985242a..7d502f85ea0dfcca0c0ae2eba1edae9d06af6651 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module;
 use Friendica\BaseModule;
 use Friendica\Core\Renderer;
 use Friendica\Core\Search;
+use Friendica\Core\Session;
 use Friendica\DI;
 use Friendica\Model;
 use Friendica\Model\User;
@@ -38,7 +39,7 @@ class Invite extends BaseModule
 {
        protected function post(array $request = [])
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
 
@@ -52,7 +53,7 @@ class Invite extends BaseModule
                        $max_invites = 50;
                }
 
-               $current_invites = intval(DI::pConfig()->get(local_user(), 'system', 'sent_invites'));
+               $current_invites = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'sent_invites'));
                if ($current_invites > $max_invites) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Total invitation limit exceeded.'));
                }
@@ -67,13 +68,13 @@ class Invite extends BaseModule
 
                if ($config->get('system', 'invitation_only')) {
                        $invitation_only = true;
-                       $invites_remaining = DI::pConfig()->get(local_user(), 'system', 'invites_remaining');
+                       $invites_remaining = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
                        if ((!$invites_remaining) && (!$app->isSiteAdmin())) {
                                throw new HTTPException\ForbiddenException();
                        }
                }
 
-               $user = User::getById(local_user());
+               $user = User::getById(Session::getLocalUser());
 
                foreach ($recipients as $recipient) {
                        $recipient = trim($recipient);
@@ -90,7 +91,7 @@ class Invite extends BaseModule
                                if (!$app->isSiteAdmin()) {
                                        $invites_remaining--;
                                        if ($invites_remaining >= 0) {
-                                               DI::pConfig()->set(local_user(), 'system', 'invites_remaining', $invites_remaining);
+                                               DI::pConfig()->set(Session::getLocalUser(), 'system', 'invites_remaining', $invites_remaining);
                                        } else {
                                                return;
                                        }
@@ -112,7 +113,7 @@ class Invite extends BaseModule
                        if ($res) {
                                $total++;
                                $current_invites++;
-                               DI::pConfig()->set(local_user(), 'system', 'sent_invites', $current_invites);
+                               DI::pConfig()->set(Session::getLocalUser(), 'system', 'sent_invites', $current_invites);
                                if ($current_invites > $max_invites) {
                                        DI::sysmsg()->addNotice(DI::l10n()->t('Invitation limit exceeded. Please contact your site administrator.'));
                                        return;
@@ -127,7 +128,7 @@ class Invite extends BaseModule
 
        protected function content(array $request = []): string
        {
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
 
@@ -138,7 +139,7 @@ class Invite extends BaseModule
 
                if ($config->get('system', 'invitation_only')) {
                        $inviteOnly = true;
-                       $x = DI::pConfig()->get(local_user(), 'system', 'invites_remaining');
+                       $x = DI::pConfig()->get(Session::getLocalUser(), 'system', 'invites_remaining');
                        if ((!$x) && (!$app->isSiteAdmin())) {
                                throw new HTTPException\ForbiddenException(DI::l10n()->t('You have no more invitations available'));
                        }
index e4ed1e93bf08138a4346d6262eccbe6d08f2e05f..42eae695e15dc810106776b0bab186b1edc1f593 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module;
 use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\L10n;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\Database;
 use Friendica\Model\Contact;
@@ -90,8 +91,8 @@ class Magic extends BaseModule
                }
 
                // OpenWebAuth
-               if (local_user() && $owa) {
-                       $user = User::getById(local_user());
+               if (Session::getLocalUser() && $owa) {
+                       $user = User::getById(Session::getLocalUser());
 
                        // Extract the basepath
                        // NOTE: we need another solution because this does only work
index 363acd38c2decdc7296ac05c391473428d3bebd8..a139d85a6a255ef792a51267b1dd89271e87be9d 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\BaseModule;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -42,7 +43,7 @@ class NoScrape extends BaseModule
                if (isset($this->parameters['nick'])) {
                        // Get infos about a specific nick (public)
                        $which = $this->parameters['nick'];
-               } elseif (local_user() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
+               } elseif (Session::getLocalUser() && isset($this->parameters['profile']) && DI::args()->get(2) == 'view') {
                        // view infos about a known profile (needs a login)
                        $which = $a->getLoggedInUserNickname();
                } else {
index ec449aa15fa2f77d9afeb3859683f615bddfd921..453bb5d3ac70bdf7d2000b98be1db6f755a7652d 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Module;
 
 use Friendica\Core\Hook;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -49,7 +50,7 @@ class PermissionTooltip extends \Friendica\BaseModule
                        throw new HTTPException\BadRequestException(DI::l10n()->t('Wrong type "%s", expected one of: %s', $type, implode(', ', $expectedTypes)));
                }
 
-               $condition = ['id' => $referenceId, 'uid' => [0, local_user()]];
+               $condition = ['id' => $referenceId, 'uid' => [0, Session::getLocalUser()]];
                if ($type == 'item') {
                        $fields = ['uid', 'psid', 'private', 'uri-id'];
                        $model = Post::selectFirst($fields, $condition);
@@ -177,7 +178,7 @@ class PermissionTooltip extends \Friendica\BaseModule
        private function fetchReceivers(int $uriId): string
        {
                $own_url = '';
-               $uid = local_user();
+               $uid = Session::getLocalUser();
                if ($uid) {
                        $owner = User::getOwnerDataById($uid);
                        if (!empty($owner['url'])) {
index 5fdabd33c56757cb45a24e6337bb88916949179a..112f01d4535ae34608dd5e58509b69ee890b9ee1 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module;
 use Friendica\BaseModule;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
@@ -258,7 +259,7 @@ class Photo extends BaseModule
                                        return MPhoto::getPhoto($matches[1], $matches[2]);
                                }
 
-                               return MPhoto::createPhotoForExternalResource($url, (int)local_user(), $media['mimetype'] ?? '');
+                               return MPhoto::createPhotoForExternalResource($url, (int)Session::getLocalUser(), $media['mimetype'] ?? '');
                        case 'media':
                                $media = DBA::selectFirst('post-media', ['url', 'mimetype', 'uri-id'], ['id' => $id, 'type' => Post\Media::IMAGE]);
                                if (empty($media)) {
@@ -269,14 +270,14 @@ class Photo extends BaseModule
                                        return MPhoto::getPhoto($matches[1], $matches[2]);
                                }
 
-                               return MPhoto::createPhotoForExternalResource($media['url'], (int)local_user(), $media['mimetype']);
+                               return MPhoto::createPhotoForExternalResource($media['url'], (int)Session::getLocalUser(), $media['mimetype']);
                        case 'link':
                                $link = DBA::selectFirst('post-link', ['url', 'mimetype'], ['id' => $id]);
                                if (empty($link)) {
                                        return false;
                                }
 
-                               return MPhoto::createPhotoForExternalResource($link['url'], (int)local_user(), $link['mimetype'] ?? '');
+                               return MPhoto::createPhotoForExternalResource($link['url'], (int)Session::getLocalUser(), $link['mimetype'] ?? '');
                        case 'contact':
                                $fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'xmpp', 'addr', 'network', 'failed', 'updated'];
                                $contact = Contact::getById($id, $fields);
index 7aecf682d7cd5507b2e5503a211e3f37f9e38c2b..81d142a08a5523a9b906fca2db8ee3d72038e252 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Core\Logger;
+use Friendica\Core\Session;
 use Friendica\Core\System;
 use Friendica\DI;
 use Friendica\Network\HTTPClient\Client\HttpClientAccept;
@@ -74,7 +75,7 @@ class Proxy extends BaseModule
                        throw new \Friendica\Network\HTTPException\BadRequestException();
                }
 
-               if (!local_user()) {
+               if (!Session::getLocalUser()) {
                        Logger::debug('Redirecting not logged in user to original address', ['url' => $request['url']]);
                        System::externalRedirect($request['url']);
                }
@@ -83,7 +84,7 @@ class Proxy extends BaseModule
                $request['url'] = str_replace(' ', '+', $request['url']);
 
                // Fetch the content with the local user
-               $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
+               $fetchResult = HTTPSignature::fetchRaw($request['url'], Session::getLocalUser(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::IMAGE], 'timeout' => 10]);
                $img_str = $fetchResult->getBody();
 
                if (!$fetchResult->isSuccess() || empty($img_str)) {
@@ -92,7 +93,7 @@ class Proxy extends BaseModule
                        // stop.
                }
 
-               Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => local_user(), 'image' => $request['url']]);
+               Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => Session::getLocalUser(), 'image' => $request['url']]);
 
                $mime = Images::getMimeTypeByData($img_str);
 
index 35faaa7dffb65a762ebc8b6b906aa1623d498a24..0e6ff18f2d35b22681c07037388fa00f25a6ddd6 100644 (file)
@@ -29,6 +29,7 @@ use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -73,20 +74,20 @@ class Register extends BaseModule
                // 'block_extended_register' blocks all registrations, period.
                $block = DI::config()->get('system', 'block_extended_register');
 
-               if (local_user() && $block) {
+               if (Session::getLocalUser() && $block) {
                        DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                        return '';
                }
 
-               if (local_user()) {
-                       $user = DBA::selectFirst('user', ['parent-uid'], ['uid' => local_user()]);
+               if (Session::getLocalUser()) {
+                       $user = DBA::selectFirst('user', ['parent-uid'], ['uid' => Session::getLocalUser()]);
                        if (!empty($user['parent-uid'])) {
                                DI::sysmsg()->addNotice(DI::l10n()->t('Only parent users can create additional accounts.'));
                                return '';
                        }
                }
 
-               if (!local_user() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
+               if (!Session::getLocalUser() && (intval(DI::config()->get('config', 'register_policy')) === self::CLOSED)) {
                        DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                        return '';
                }
@@ -108,7 +109,7 @@ class Register extends BaseModule
                $photo      = $_REQUEST['photo']      ?? '';
                $invite_id  = $_REQUEST['invite_id']  ?? '';
 
-               if (local_user() || DI::config()->get('system', 'no_openid')) {
+               if (Session::getLocalUser() || DI::config()->get('system', 'no_openid')) {
                        $fillwith = '';
                        $fillext  = '';
                        $oidlabel = '';
@@ -179,7 +180,7 @@ class Register extends BaseModule
                        '$form_security_token' => BaseModule::getFormSecurityToken('register'),
                        '$explicit_content' => DI::config()->get('system', 'explicit_content', false),
                        '$explicit_content_note' => DI::l10n()->t('Note: This node explicitly contains adult content'),
-                       '$additional'   => !empty(local_user()),
+                       '$additional'   => !empty(Session::getLocalUser()),
                        '$parent_password' => ['parent_password', DI::l10n()->t('Parent Password:'), '', DI::l10n()->t('Please enter the password of the parent account to legitimize your request.')]
 
                ]);
@@ -202,19 +203,19 @@ class Register extends BaseModule
 
                $additional_account = false;
 
-               if (!local_user() && !empty($arr['post']['parent_password'])) {
+               if (!Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
                        DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                        return;
-               } elseif (local_user() && !empty($arr['post']['parent_password'])) {
+               } elseif (Session::getLocalUser() && !empty($arr['post']['parent_password'])) {
                        try {
-                               Model\User::getIdFromPasswordAuthentication(local_user(), $arr['post']['parent_password']);
+                               Model\User::getIdFromPasswordAuthentication(Session::getLocalUser(), $arr['post']['parent_password']);
                        } catch (\Exception $ex) {
                                DI::sysmsg()->addNotice(DI::l10n()->t("Password doesn't match."));
                                $regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
                                DI::baseUrl()->redirect('register?' . http_build_query($regdata));
                        }
                        $additional_account = true;
-               } elseif (local_user()) {
+               } elseif (Session::getLocalUser()) {
                        DI::sysmsg()->addNotice(DI::l10n()->t('Please enter your password.'));
                        $regdata = ['nickname' => $arr['post']['nickname'], 'username' => $arr['post']['username']];
                        DI::baseUrl()->redirect('register?' . http_build_query($regdata));
@@ -262,7 +263,7 @@ class Register extends BaseModule
                }
 
                if ($additional_account) {
-                       $user = DBA::selectFirst('user', ['email'], ['uid' => local_user()]);
+                       $user = DBA::selectFirst('user', ['email'], ['uid' => Session::getLocalUser()]);
                        if (!DBA::isResult($user)) {
                                DI::sysmsg()->addNotice(DI::l10n()->t('User not found.'));
                                DI::baseUrl()->redirect('register');
@@ -306,7 +307,7 @@ class Register extends BaseModule
                }
 
                if ($additional_account) {
-                       DBA::update('user', ['parent-uid' => local_user()], ['uid' => $user['uid']]);
+                       DBA::update('user', ['parent-uid' => Session::getLocalUser()], ['uid' => $user['uid']]);
                        DI::sysmsg()->addInfo(DI::l10n()->t('The additional account was created.'));
                        DI::baseUrl()->redirect('delegation');
                }