diff --git a/src/Module/Admin/Users/Index.php b/src/Module/Admin/Users/Index.php index e8356720d..b381b752e 100644 --- a/src/Module/Admin/Users/Index.php +++ b/src/Module/Admin/Users/Index.php @@ -23,6 +23,7 @@ namespace Friendica\Module\Admin\Users; use Friendica\Content\Pager; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\User; @@ -54,7 +55,7 @@ class Index extends BaseUsers if (!empty($_POST['page_users_delete'])) { foreach ($users as $uid) { - if (local_user() != $uid) { + if (Session::getLocalUser() != $uid) { User::remove($uid); } else { DI::sysmsg()->addNotice(DI::l10n()->t('You can\'t remove yourself')); @@ -85,7 +86,7 @@ class Index extends BaseUsers switch ($action) { case 'delete': - if (local_user() != $uid) { + if (Session::getLocalUser() != $uid) { self::checkFormSecurityTokenRedirectOnError(DI::baseUrl()->get(true), 'admin_users', 't'); // delete user User::remove($uid); diff --git a/src/Module/Contact/Advanced.php b/src/Module/Contact/Advanced.php index d722691ff..2c13800de 100644 --- a/src/Module/Contact/Advanced.php +++ b/src/Module/Contact/Advanced.php @@ -66,7 +66,7 @@ class Advanced extends BaseModule { $cid = $this->parameters['id']; - $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]); + $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => Session::getLocalUser()]); if (empty($contact)) { throw new BadRequestException($this->t('Contact not found.')); } @@ -87,7 +87,7 @@ class Advanced extends BaseModule 'nurl' => $nurl, 'poll' => $poll, ], - ['id' => $contact['id'], 'uid' => local_user()] + ['id' => $contact['id'], 'uid' => Session::getLocalUser()] ); if ($photo) { @@ -105,7 +105,7 @@ class Advanced extends BaseModule { $cid = $this->parameters['id']; - $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => local_user()]); + $contact = Model\Contact::selectFirst([], ['id' => $cid, 'uid' => Session::getLocalUser()]); if (empty($contact)) { throw new BadRequestException($this->t('Contact not found.')); } diff --git a/src/Module/Contact/Contacts.php b/src/Module/Contact/Contacts.php index e26811001..87e107988 100644 --- a/src/Module/Contact/Contacts.php +++ b/src/Module/Contact/Contacts.php @@ -25,6 +25,7 @@ use Friendica\BaseModule; use Friendica\Content\Pager; use Friendica\Content\Widget; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; use Friendica\Model; use Friendica\Model\User; @@ -35,9 +36,7 @@ class Contacts extends BaseModule { protected function content(array $request = []): string { - $app = DI::app(); - - if (!local_user()) { + if (!Session::getLocalUser()) { throw new HTTPException\ForbiddenException(); } @@ -55,7 +54,7 @@ class Contacts extends BaseModule throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found.')); } - $localContactId = Model\Contact::getPublicIdByUserId(local_user()); + $localContactId = Model\Contact::getPublicIdByUserId(Session::getLocalUser()); DI::page()['aside'] = Widget\VCard::getHTML($contact); diff --git a/src/Module/Contact/Conversations.php b/src/Module/Contact/Conversations.php index a8f625473..a2f969c9c 100644 --- a/src/Module/Contact/Conversations.php +++ b/src/Module/Contact/Conversations.php @@ -29,6 +29,7 @@ use Friendica\Content\Nav; use Friendica\Content\Widget; use Friendica\Core\L10n; use Friendica\Core\Protocol; +use Friendica\Core\Session; use Friendica\Core\Theme; use Friendica\Model; use Friendica\Module\Contact; @@ -67,13 +68,13 @@ class Conversations 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.')); } @@ -88,7 +89,7 @@ class Conversations 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']); } diff --git a/src/Module/Contact/Hovercard.php b/src/Module/Contact/Hovercard.php index 440c46c50..43acbdd5f 100644 --- a/src/Module/Contact/Hovercard.php +++ b/src/Module/Contact/Hovercard.php @@ -71,7 +71,7 @@ class Hovercard extends BaseModule // Search for contact data // Look if the local user has got the contact if (Session::isAuthenticated()) { - $contact = Contact::getByURLForUser($contact_url, local_user()); + $contact = Contact::getByURLForUser($contact_url, Session::getLocalUser()); } else { $contact = Contact::getByURL($contact_url, false); } diff --git a/src/Module/Notifications/Introductions.php b/src/Module/Notifications/Introductions.php index ffe5d212f..776c146de 100644 --- a/src/Module/Notifications/Introductions.php +++ b/src/Module/Notifications/Introductions.php @@ -30,6 +30,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\L10n; use Friendica\Core\Protocol; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; use Friendica\Model\User; use Friendica\Module\BaseNotifications; @@ -98,7 +99,7 @@ class Introductions extends BaseNotifications 'text' => (!$all ? $this->t('Show Ignored Requests') : $this->t('Hide Ignored Requests')), ]; - $owner = User::getOwnerDataById(local_user()); + $owner = User::getOwnerDataById(Session::getLocalUser()); // Loop through all introduction notifications.This creates an array with the output html for each // introduction diff --git a/src/Module/Notifications/Ping.php b/src/Module/Notifications/Ping.php index 57da97b4f..e8dd0ce2d 100644 --- a/src/Module/Notifications/Ping.php +++ b/src/Module/Notifications/Ping.php @@ -28,6 +28,7 @@ use Friendica\Content\ForumManager; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Hook; use Friendica\Core\L10n; +use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; @@ -90,18 +91,18 @@ class Ping extends BaseModule $today_birthday_count = 0; - if (local_user()) { - if (DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) { - $notifications = $this->notificationRepo->selectDetailedForUser(local_user()); + if (Session::getLocalUser()) { + if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) { + $notifications = $this->notificationRepo->selectDetailedForUser(Session::getLocalUser()); } else { - $notifications = $this->notificationRepo->selectDigestForUser(local_user()); + $notifications = $this->notificationRepo->selectDigestForUser(Session::getLocalUser()); } $condition = [ "`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)", - local_user(), Verb::getID(Activity::FOLLOW) + Session::getLocalUser(), Verb::getID(Activity::FOLLOW) ]; - $items = Post::selectForUser(local_user(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]); + $items = Post::selectForUser(Session::getLocalUser(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]); if (DBA::isResult($items)) { $items_unseen = Post::toArray($items, false); $arr = ['items' => $items_unseen]; @@ -139,12 +140,12 @@ class Ping extends BaseModule } } - $intros = $this->introductionRepo->selectForUser(local_user()); + $intros = $this->introductionRepo->selectForUser(Session::getLocalUser()); $intro_count = $intros->count(); $myurl = DI::baseUrl() . '/profile/' . DI::app()->getLoggedInUserNickname(); - $mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", local_user(), $myurl]); + $mail_count = DBA::count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", Session::getLocalUser(), $myurl]); if (intval(DI::config()->get('config', 'register_policy')) === Register::APPROVE && DI::app()->isSiteAdmin()) { $regs = \Friendica\Model\Register::getPending(); @@ -154,12 +155,12 @@ class Ping extends BaseModule } } - $cachekey = 'ping:events:' . local_user(); + $cachekey = 'ping:events:' . Session::getLocalUser(); $ev = DI::cache()->get($cachekey); if (is_null($ev)) { $ev = DBA::selectToArray('event', ['type', 'start'], ["`uid` = ? AND `start` < ? AND `finish` > ? AND NOT `ignore`", - local_user(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]); + Session::getLocalUser(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]); if (DBA::isResult($ev)) { DI::cache()->set($cachekey, $ev, Duration::HOUR); } @@ -189,7 +190,7 @@ class Ping extends BaseModule } } - $owner = User::getOwnerDataById(local_user()); + $owner = User::getOwnerDataById(Session::getLocalUser()); $navNotifications = array_map(function (Entity\Notification $notification) use ($owner) { if (!DI::notify()->NotifyOnDesktop($notification)) { @@ -216,7 +217,7 @@ class Ping extends BaseModule } if (DBA::isResult($regs)) { - if (count($regs) <= 1 || DI::pConfig()->get(local_user(), 'system', 'detailed_notif')) { + if (count($regs) <= 1 || DI::pConfig()->get(Session::getLocalUser(), 'system', 'detailed_notif')) { foreach ($regs as $reg) { $navNotifications[] = $this->formattedNavNotification->createFromParams( [ diff --git a/src/Module/OAuth/Authorize.php b/src/Module/OAuth/Authorize.php index 6a574a2ac..1fa142362 100644 --- a/src/Module/OAuth/Authorize.php +++ b/src/Module/OAuth/Authorize.php @@ -22,6 +22,7 @@ namespace Friendica\Module\OAuth; use Friendica\Core\Logger; +use Friendica\Core\Session; use Friendica\DI; use Friendica\Module\BaseApi; use Friendica\Security\OAuth; @@ -70,7 +71,7 @@ class Authorize extends BaseApi unset($redirect_request['pagename']); $redirect = 'oauth/authorize?' . http_build_query($redirect_request); - $uid = local_user(); + $uid = Session::getLocalUser(); if (empty($uid)) { Logger::info('Redirect to login'); DI::app()->redirect('login?return_path=' . urlencode($redirect)); diff --git a/src/Module/Profile/Common.php b/src/Module/Profile/Common.php index a9d2b7e9f..6e4b7c693 100644 --- a/src/Module/Profile/Common.php +++ b/src/Module/Profile/Common.php @@ -56,7 +56,7 @@ class Common extends BaseProfile throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); } - $displayCommonTab = Session::isAuthenticated() && $profile['uid'] != local_user(); + $displayCommonTab = Session::isAuthenticated() && $profile['uid'] != Session::getLocalUser(); if (!$displayCommonTab) { $a->redirect('profile/' . $nickname . '/contacts'); diff --git a/src/Module/Settings/Delegation.php b/src/Module/Settings/Delegation.php index a711c674a..19e62b6f0 100644 --- a/src/Module/Settings/Delegation.php +++ b/src/Module/Settings/Delegation.php @@ -59,14 +59,14 @@ class Delegation extends BaseSettings DI::sysmsg()->addInfo(DI::l10n()->t('Delegation successfully revoked.')); } - DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => local_user()]); + DBA::update('user', ['parent-uid' => $parent_uid], ['uid' => Session::getLocalUser()]); } protected function content(array $request = []): string { parent::content(); - if (!local_user()) { + if (!Session::getLocalUser()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); } @@ -85,11 +85,11 @@ class Delegation extends BaseSettings $user = User::getById($user_id, ['nickname']); if (DBA::isResult($user)) { $condition = [ - 'uid' => local_user(), + 'uid' => Session::getLocalUser(), 'nurl' => Strings::normaliseLink(DI::baseUrl() . '/profile/' . $user['nickname']) ]; if (DBA::exists('contact', $condition)) { - DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]); + DBA::insert('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]); } } else { DI::sysmsg()->addNotice(DI::l10n()->t('Delegate user not found.')); @@ -104,12 +104,12 @@ class Delegation extends BaseSettings DI::baseUrl()->redirect('settings/delegation'); } - DBA::delete('manage', ['uid' => $user_id, 'mid' => local_user()]); + DBA::delete('manage', ['uid' => $user_id, 'mid' => Session::getLocalUser()]); DI::baseUrl()->redirect('settings/delegation'); } // find everybody that currently has delegated management to this account/page - $delegates = DBA::selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', local_user()]); + $delegates = DBA::selectToArray('user', [], ['`uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = ?)', Session::getLocalUser()]); $uids = []; foreach ($delegates as $user) { @@ -120,7 +120,7 @@ class Delegation extends BaseSettings $potentials = []; $nicknames = []; - $condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => local_user(), 'blocked' => false]; + $condition = ['baseurl' => DI::baseUrl(), 'self' => false, 'uid' => Session::getLocalUser(), 'blocked' => false]; $contacts = DBA::select('contact', ['nick'], $condition); while ($contact = DBA::fetch($contacts)) { $nicknames[] = $contact['nick']; @@ -137,8 +137,8 @@ class Delegation extends BaseSettings $parent_user = null; $parent_password = null; - $user = User::getById(local_user(), ['parent-uid', 'email']); - if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => local_user()])) { + $user = User::getById(Session::getLocalUser(), ['parent-uid', 'email']); + if (DBA::isResult($user) && !DBA::exists('user', ['parent-uid' => Session::getLocalUser()])) { $parent_uid = $user['parent-uid']; $parents = [0 => DI::l10n()->t('No parent user')]; @@ -146,7 +146,7 @@ class Delegation extends BaseSettings $condition = ['email' => $user['email'], 'verified' => true, 'blocked' => false, 'parent-uid' => 0]; $parent_users = DBA::selectToArray('user', $fields, $condition); foreach($parent_users as $parent) { - if ($parent['uid'] != local_user()) { + if ($parent['uid'] != Session::getLocalUser()) { $parents[$parent['uid']] = sprintf('%s (%s)', $parent['username'], $parent['nickname']); } } diff --git a/src/Module/Settings/Display.php b/src/Module/Settings/Display.php index 81f496eea..871abb42e 100644 --- a/src/Module/Settings/Display.php +++ b/src/Module/Settings/Display.php @@ -44,7 +44,7 @@ class Display extends BaseSettings self::checkFormSecurityTokenRedirectOnError('/settings/display', 'settings_display'); - $user = User::getById(local_user()); + $user = User::getById(Session::getLocalUser()); $theme = !empty($_POST['theme']) ? trim($_POST['theme']) : $user['theme']; $mobile_theme = !empty($_POST['mobile_theme']) ? trim($_POST['mobile_theme']) : ''; @@ -78,20 +78,20 @@ class Display extends BaseSettings } if ($mobile_theme !== '') { - DI::pConfig()->set(local_user(), 'system', 'mobile_theme', $mobile_theme); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'mobile_theme', $mobile_theme); } - DI::pConfig()->set(local_user(), 'system', 'itemspage_network' , $itemspage_network); - DI::pConfig()->set(local_user(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network); - DI::pConfig()->set(local_user(), 'system', 'update_interval' , $browser_update); - DI::pConfig()->set(local_user(), 'system', 'no_auto_update' , $no_auto_update); - DI::pConfig()->set(local_user(), 'system', 'no_smilies' , !$enable_smile); - DI::pConfig()->set(local_user(), 'system', 'infinite_scroll' , $infinite_scroll); - DI::pConfig()->set(local_user(), 'system', 'no_smart_threading' , !$enable_smart_threading); - DI::pConfig()->set(local_user(), 'system', 'hide_dislike' , !$enable_dislike); - DI::pConfig()->set(local_user(), 'system', 'display_resharer' , $display_resharer); - DI::pConfig()->set(local_user(), 'system', 'stay_local' , $stay_local); - DI::pConfig()->set(local_user(), 'system', 'first_day_of_week' , $first_day_of_week); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'itemspage_network' , $itemspage_network); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'itemspage_mobile_network', $itemspage_mobile_network); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'update_interval' , $browser_update); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_auto_update' , $no_auto_update); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_smilies' , !$enable_smile); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'infinite_scroll' , $infinite_scroll); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'no_smart_threading' , !$enable_smart_threading); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'hide_dislike' , !$enable_dislike); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'display_resharer' , $display_resharer); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'stay_local' , $stay_local); + DI::pConfig()->set(Session::getLocalUser(), 'system', 'first_day_of_week' , $first_day_of_week); if (in_array($theme, Theme::getAllowedList())) { if ($theme == $user['theme']) { @@ -101,7 +101,7 @@ class Display extends BaseSettings theme_post(DI::app()); } } else { - DBA::update('user', ['theme' => $theme], ['uid' => local_user()]); + DBA::update('user', ['theme' => $theme], ['uid' => Session::getLocalUser()]); } } else { DI::sysmsg()->addNotice(DI::l10n()->t('The theme you chose isn\'t available.')); @@ -116,7 +116,7 @@ class Display extends BaseSettings { parent::content(); - if (!local_user()) { + if (!Session::getLocalUser()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); } @@ -130,7 +130,7 @@ class Display extends BaseSettings $default_mobile_theme = 'none'; } - $user = User::getById(local_user()); + $user = User::getById(Session::getLocalUser()); $allowed_themes = Theme::getAllowedList(); @@ -159,26 +159,26 @@ class Display extends BaseSettings $theme_selected = $user['theme'] ?: $default_theme; $mobile_theme_selected = DI::session()->get('mobile-theme', $default_mobile_theme); - $itemspage_network = intval(DI::pConfig()->get(local_user(), 'system', 'itemspage_network')); + $itemspage_network = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_network')); $itemspage_network = (($itemspage_network > 0 && $itemspage_network < 101) ? $itemspage_network : DI::config()->get('system', 'itemspage_network')); - $itemspage_mobile_network = intval(DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network')); + $itemspage_mobile_network = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'itemspage_mobile_network')); $itemspage_mobile_network = (($itemspage_mobile_network > 0 && $itemspage_mobile_network < 101) ? $itemspage_mobile_network : DI::config()->get('system', 'itemspage_network_mobile')); - $browser_update = intval(DI::pConfig()->get(local_user(), 'system', 'update_interval')); + $browser_update = intval(DI::pConfig()->get(Session::getLocalUser(), 'system', 'update_interval')); if (intval($browser_update) != -1) { $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds } - $no_auto_update = DI::pConfig()->get(local_user(), 'system', 'no_auto_update', 0); - $enable_smile = !DI::pConfig()->get(local_user(), 'system', 'no_smilies', 0); - $infinite_scroll = DI::pConfig()->get(local_user(), 'system', 'infinite_scroll', 0); - $enable_smart_threading = !DI::pConfig()->get(local_user(), 'system', 'no_smart_threading', 0); - $enable_dislike = !DI::pConfig()->get(local_user(), 'system', 'hide_dislike', 0); - $display_resharer = DI::pConfig()->get(local_user(), 'system', 'display_resharer', 0); - $stay_local = DI::pConfig()->get(local_user(), 'system', 'stay_local', 0); + $no_auto_update = DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update', 0); + $enable_smile = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smilies', 0); + $infinite_scroll = DI::pConfig()->get(Session::getLocalUser(), 'system', 'infinite_scroll', 0); + $enable_smart_threading = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_smart_threading', 0); + $enable_dislike = !DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike', 0); + $display_resharer = DI::pConfig()->get(Session::getLocalUser(), 'system', 'display_resharer', 0); + $stay_local = DI::pConfig()->get(Session::getLocalUser(), 'system', 'stay_local', 0); - $first_day_of_week = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0); + $first_day_of_week = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0); $weekdays = [ 0 => DI::l10n()->t("Sunday"), 1 => DI::l10n()->t("Monday"), @@ -207,7 +207,7 @@ class Display extends BaseSettings '$form_security_token' => self::getFormSecurityToken('settings_display'), '$baseurl' => DI::baseUrl()->get(true), - '$uid' => local_user(), + '$uid' => Session::getLocalUser(), '$theme' => ['theme', DI::l10n()->t('Display Theme:'), $theme_selected, '', $themes, true], '$mobile_theme' => ['mobile_theme', DI::l10n()->t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false], diff --git a/src/Module/Settings/Profile/Index.php b/src/Module/Settings/Profile/Index.php index eec7468d0..aa14b8e75 100644 --- a/src/Module/Settings/Profile/Index.php +++ b/src/Module/Settings/Profile/Index.php @@ -25,6 +25,7 @@ use Friendica\Core\ACL; use Friendica\Core\Hook; use Friendica\Core\Protocol; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\Core\Theme; use Friendica\Database\DBA; use Friendica\DI; @@ -43,11 +44,11 @@ class Index extends BaseSettings { protected function post(array $request = []) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } - $profile = Profile::getByUID(local_user()); + $profile = Profile::getByUID(Session::getLocalUser()); if (!DBA::isResult($profile)) { return; } @@ -101,12 +102,12 @@ class Index extends BaseSettings } $profileFieldsNew = self::getProfileFieldsFromInput( - local_user(), + Session::getLocalUser(), $_REQUEST['profile_field'], $_REQUEST['profile_field_order'] ); - DI::profileField()->saveCollectionForUser(local_user(), $profileFieldsNew); + DI::profileField()->saveCollectionForUser(Session::getLocalUser(), $profileFieldsNew); $result = Profile::update( [ @@ -124,7 +125,7 @@ class Index extends BaseSettings 'pub_keywords' => $pub_keywords, 'prv_keywords' => $prv_keywords, ], - local_user() + Session::getLocalUser() ); if (!$result) { @@ -137,7 +138,7 @@ class Index extends BaseSettings protected function content(array $request = []): string { - if (!local_user()) { + if (!Session::getLocalUser()) { DI::sysmsg()->addNotice(DI::l10n()->t('You must be logged in to use this module')); return Login::form(); } @@ -146,7 +147,7 @@ class Index extends BaseSettings $o = ''; - $profile = User::getOwnerDataById(local_user()); + $profile = User::getOwnerDataById(Session::getLocalUser()); if (!DBA::isResult($profile)) { throw new HTTPException\NotFoundException(); } @@ -158,7 +159,7 @@ class Index extends BaseSettings $custom_fields = []; - $profileFields = DI::profileField()->selectByUserId(local_user()); + $profileFields = DI::profileField()->selectByUserId(Session::getLocalUser()); foreach ($profileFields as $profileField) { /** @var ProfileField $profileField */ $defaultPermissions = $profileField->permissionSet->withAllowedContacts( diff --git a/src/Module/Settings/Profile/Photo/Crop.php b/src/Module/Settings/Profile/Photo/Crop.php index 5afab9503..68b673f8c 100644 --- a/src/Module/Settings/Profile/Photo/Crop.php +++ b/src/Module/Settings/Profile/Photo/Crop.php @@ -58,7 +58,7 @@ class Crop extends BaseSettings $path = 'profile/' . DI::app()->getLoggedInUserNickname(); - $base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => local_user(), 'scale' => $scale]); + $base_image = Photo::selectFirst([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'scale' => $scale]); if (DBA::isResult($base_image)) { $Image = Photo::getImageForPhoto($base_image); if (empty($Image)) { @@ -67,7 +67,7 @@ class Crop extends BaseSettings if ($Image->isValid()) { // If setting for the default profile, unset the profile photo flag from any other photos I own - DBA::update('photo', ['profile' => 0], ['uid' => local_user()]); + DBA::update('photo', ['profile' => 0], ['uid' => Session::getLocalUser()]); // Normalizing expected square crop parameters $selectionW = $selectionH = min($selectionW, $selectionH); @@ -92,11 +92,11 @@ class Crop extends BaseSettings $Image->scaleDown(300); } - $condition = ['resource-id' => $resource_id, 'uid' => local_user(), 'contact-id' => 0]; + $condition = ['resource-id' => $resource_id, 'uid' => Session::getLocalUser(), 'contact-id' => 0]; $r = Photo::store( $Image, - local_user(), + Session::getLocalUser(), 0, $resource_id, $base_image['filename'], @@ -114,7 +114,7 @@ class Crop extends BaseSettings $r = Photo::store( $Image, - local_user(), + Session::getLocalUser(), 0, $resource_id, $base_image['filename'], @@ -132,7 +132,7 @@ class Crop extends BaseSettings $r = Photo::store( $Image, - local_user(), + Session::getLocalUser(), 0, $resource_id, $base_image['filename'], @@ -146,12 +146,12 @@ class Crop extends BaseSettings Photo::update(['profile' => true], array_merge($condition, ['scale' => 6])); } - Contact::updateSelfFromUserID(local_user(), true); + Contact::updateSelfFromUserID(Session::getLocalUser(), true); DI::sysmsg()->addInfo(DI::l10n()->t('Shift-reload the page or clear browser cache if the new photo does not display immediately.')); // Update global directory in background - Profile::publishUpdate(local_user()); + Profile::publishUpdate(Session::getLocalUser()); } else { DI::sysmsg()->addNotice(DI::l10n()->t('Unable to process image')); } @@ -170,7 +170,7 @@ class Crop extends BaseSettings $resource_id = $this->parameters['guid']; - $photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => local_user()], ['order' => ['scale' => false]]); + $photos = Photo::selectToArray([], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()], ['order' => ['scale' => false]]); if (!DBA::isResult($photos)) { throw new HTTPException\NotFoundException(DI::l10n()->t('Photo not found.')); } @@ -185,14 +185,14 @@ class Crop extends BaseSettings // set an already uloaded photo as profile photo // if photo is in 'Profile Photos', change it in db if ($photos[0]['photo-type'] == Photo::USER_AVATAR && $havescale) { - Photo::update(['profile' => false], ['uid' => local_user()]); + Photo::update(['profile' => false], ['uid' => Session::getLocalUser()]); - Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => local_user()]); + Photo::update(['profile' => true], ['resource-id' => $resource_id, 'uid' => Session::getLocalUser()]); - Contact::updateSelfFromUserID(local_user(), true); + Contact::updateSelfFromUserID(Session::getLocalUser(), true); // Update global directory in background - Profile::publishUpdate(local_user()); + Profile::publishUpdate(Session::getLocalUser()); DI::sysmsg()->addInfo(DI::l10n()->t('Profile picture successfully updated.')); diff --git a/src/Module/Settings/Profile/Photo/Index.php b/src/Module/Settings/Profile/Photo/Index.php index 4f0b5ddad..1e1dbbe67 100644 --- a/src/Module/Settings/Profile/Photo/Index.php +++ b/src/Module/Settings/Profile/Photo/Index.php @@ -92,13 +92,13 @@ class Index extends BaseSettings $filename = ''; - if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) { + if (!Photo::store($Image, Session::getLocalUser(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 0, Photo::USER_AVATAR)) { DI::sysmsg()->addNotice(DI::l10n()->t('Image upload failed.')); } if ($width > 640 || $height > 640) { $Image->scaleDown(640); - if (!Photo::store($Image, local_user(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) { + if (!Photo::store($Image, Session::getLocalUser(), 0, $resource_id, $filename, DI::l10n()->t(Photo::PROFILE_PHOTOS), 1, Photo::USER_AVATAR)) { DI::sysmsg()->addNotice(DI::l10n()->t('Image size reduction [%s] failed.', '640')); } } @@ -118,7 +118,7 @@ class Index extends BaseSettings $newuser = $args->get($args->getArgc() - 1) === 'new'; - $contact = Contact::selectFirst(['avatar'], ['uid' => local_user(), 'self' => true]); + $contact = Contact::selectFirst(['avatar'], ['uid' => Session::getLocalUser(), 'self' => true]); $tpl = Renderer::getMarkupTemplate('settings/profile/photo/index.tpl'); $o = Renderer::replaceMacros($tpl, [ diff --git a/src/Module/Settings/TwoFactor/AppSpecific.php b/src/Module/Settings/TwoFactor/AppSpecific.php index 69b509131..c37cc76c6 100644 --- a/src/Module/Settings/TwoFactor/AppSpecific.php +++ b/src/Module/Settings/TwoFactor/AppSpecific.php @@ -25,6 +25,7 @@ use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; use Friendica\Module\Response; use Friendica\Security\TwoFactor\Model\AppSpecificPassword; @@ -51,11 +52,11 @@ class AppSpecific extends BaseSettings $this->pConfig = $pConfig; - if (!local_user()) { + if (!Session::getLocalUser()) { return; } - $verified = $this->pConfig->get(local_user(), '2fa', 'verified'); + $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified'); if (!$verified) { $this->baseUrl->redirect('settings/2fa'); @@ -69,7 +70,7 @@ class AppSpecific extends BaseSettings protected function post(array $request = []) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } @@ -82,17 +83,17 @@ class AppSpecific extends BaseSettings if (empty($description)) { DI::sysmsg()->addNotice($this->t('App-specific password generation failed: The description is empty.')); $this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); - } elseif (AppSpecificPassword::checkDuplicateForUser(local_user(), $description)) { + } elseif (AppSpecificPassword::checkDuplicateForUser(Session::getLocalUser(), $description)) { DI::sysmsg()->addNotice($this->t('App-specific password generation failed: This description already exists.')); $this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); } else { - $this->appSpecificPassword = AppSpecificPassword::generateForUser(local_user(), $_POST['description'] ?? ''); + $this->appSpecificPassword = AppSpecificPassword::generateForUser(Session::getLocalUser(), $_POST['description'] ?? ''); DI::sysmsg()->addInfo($this->t('New app-specific password generated.')); } break; case 'revoke_all' : - AppSpecificPassword::deleteAllForUser(local_user()); + AppSpecificPassword::deleteAllForUser(Session::getLocalUser()); DI::sysmsg()->addInfo($this->t('App-specific passwords successfully revoked.')); $this->baseUrl->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); break; @@ -102,7 +103,7 @@ class AppSpecific extends BaseSettings if (!empty($_POST['revoke_id'])) { self::checkFormSecurityTokenRedirectOnError('settings/2fa/app_specific', 'settings_2fa_app_specific'); - if (AppSpecificPassword::deleteForUser(local_user(), $_POST['revoke_id'])) { + if (AppSpecificPassword::deleteForUser(Session::getLocalUser(), $_POST['revoke_id'])) { DI::sysmsg()->addInfo($this->t('App-specific password successfully revoked.')); } @@ -112,13 +113,13 @@ class AppSpecific extends BaseSettings protected function content(array $request = []): string { - if (!local_user()) { + if (!Session::getLocalUser()) { return Login::form('settings/2fa/app_specific'); } parent::content(); - $appSpecificPasswords = AppSpecificPassword::getListForUser(local_user()); + $appSpecificPasswords = AppSpecificPassword::getListForUser(Session::getLocalUser()); return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/app_specific.tpl'), [ '$form_security_token' => self::getFormSecurityToken('settings_2fa_app_specific'), diff --git a/src/Module/Settings/TwoFactor/Index.php b/src/Module/Settings/TwoFactor/Index.php index ae4e518fa..d17c7b849 100644 --- a/src/Module/Settings/TwoFactor/Index.php +++ b/src/Module/Settings/TwoFactor/Index.php @@ -22,6 +22,7 @@ namespace Friendica\Module\Settings\TwoFactor; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; use Friendica\Network\HTTPException\FoundException; use Friendica\Security\TwoFactor\Model\AppSpecificPassword; @@ -35,24 +36,24 @@ class Index extends BaseSettings { protected function post(array $request = []) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } self::checkFormSecurityTokenRedirectOnError('settings/2fa', 'settings_2fa'); try { - User::getIdFromPasswordAuthentication(local_user(), $_POST['password'] ?? ''); + User::getIdFromPasswordAuthentication(Session::getLocalUser(), $_POST['password'] ?? ''); - $has_secret = (bool)DI::pConfig()->get(local_user(), '2fa', 'secret'); - $verified = DI::pConfig()->get(local_user(), '2fa', 'verified'); + $has_secret = (bool)DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret'); + $verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified'); switch ($_POST['action'] ?? '') { case 'enable': if (!$has_secret && !$verified) { $Google2FA = new Google2FA(); - DI::pConfig()->set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32)); + DI::pConfig()->set(Session::getLocalUser(), '2fa', 'secret', $Google2FA->generateSecretKey(32)); DI::baseUrl() ->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); @@ -60,9 +61,9 @@ class Index extends BaseSettings break; case 'disable': if ($has_secret) { - RecoveryCode::deleteForUser(local_user()); - DI::pConfig()->delete(local_user(), '2fa', 'secret'); - DI::pConfig()->delete(local_user(), '2fa', 'verified'); + RecoveryCode::deleteForUser(Session::getLocalUser()); + DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'secret'); + DI::pConfig()->delete(Session::getLocalUser(), '2fa', 'verified'); DI::session()->remove('2fa'); DI::sysmsg()->addInfo(DI::l10n()->t('Two-factor authentication successfully disabled.')); @@ -103,14 +104,14 @@ class Index extends BaseSettings protected function content(array $request = []): string { - if (!local_user()) { + if (!Session::getLocalUser()) { return Login::form('settings/2fa'); } parent::content(); - $has_secret = (bool) DI::pConfig()->get(local_user(), '2fa', 'secret'); - $verified = DI::pConfig()->get(local_user(), '2fa', 'verified'); + $has_secret = (bool) DI::pConfig()->get(Session::getLocalUser(), '2fa', 'secret'); + $verified = DI::pConfig()->get(Session::getLocalUser(), '2fa', 'verified'); return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/index.tpl'), [ '$form_security_token' => self::getFormSecurityToken('settings_2fa'), @@ -128,12 +129,12 @@ class Index extends BaseSettings '$recovery_codes_title' => DI::l10n()->t('Recovery codes'), '$recovery_codes_remaining' => DI::l10n()->t('Remaining valid codes'), - '$recovery_codes_count' => RecoveryCode::countValidForUser(local_user()), + '$recovery_codes_count' => RecoveryCode::countValidForUser(Session::getLocalUser()), '$recovery_codes_message' => DI::l10n()->t('
These one-use codes can replace an authenticator app code in case you have lost access to it.
'), '$app_specific_passwords_title' => DI::l10n()->t('App-specific passwords'), '$app_specific_passwords_remaining' => DI::l10n()->t('Generated app-specific passwords'), - '$app_specific_passwords_count' => AppSpecificPassword::countForUser(local_user()), + '$app_specific_passwords_count' => AppSpecificPassword::countForUser(Session::getLocalUser()), '$app_specific_passwords_message' => DI::l10n()->t('These randomly generated passwords allow you to authenticate on apps not supporting two-factor authentication.
'), '$action_title' => DI::l10n()->t('Actions'), diff --git a/src/Module/Settings/TwoFactor/Recovery.php b/src/Module/Settings/TwoFactor/Recovery.php index 04749f2f8..54d24abbf 100644 --- a/src/Module/Settings/TwoFactor/Recovery.php +++ b/src/Module/Settings/TwoFactor/Recovery.php @@ -25,6 +25,7 @@ use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; use Friendica\Module\Response; use Friendica\Security\TwoFactor\Model\RecoveryCode; @@ -49,11 +50,11 @@ class Recovery extends BaseSettings $this->pConfig = $pConfig; - if (!local_user()) { + if (!Session::getLocalUser()) { return; } - $secret = $this->pConfig->get(local_user(), '2fa', 'secret'); + $secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'); if (!$secret) { $this->baseUrl->redirect('settings/2fa'); @@ -67,7 +68,7 @@ class Recovery extends BaseSettings protected function post(array $request = []) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } @@ -75,7 +76,7 @@ class Recovery extends BaseSettings self::checkFormSecurityTokenRedirectOnError('settings/2fa/recovery', 'settings_2fa_recovery'); if ($_POST['action'] == 'regenerate') { - RecoveryCode::regenerateForUser(local_user()); + RecoveryCode::regenerateForUser(Session::getLocalUser()); DI::sysmsg()->addInfo($this->t('New recovery codes successfully generated.')); $this->baseUrl->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); } @@ -84,19 +85,19 @@ class Recovery extends BaseSettings protected function content(array $request = []): string { - if (!local_user()) { + if (!Session::getLocalUser()) { return Login::form('settings/2fa/recovery'); } parent::content(); - if (!RecoveryCode::countValidForUser(local_user())) { - RecoveryCode::generateForUser(local_user()); + if (!RecoveryCode::countValidForUser(Session::getLocalUser())) { + RecoveryCode::generateForUser(Session::getLocalUser()); } - $recoveryCodes = RecoveryCode::getListForUser(local_user()); + $recoveryCodes = RecoveryCode::getListForUser(Session::getLocalUser()); - $verified = $this->pConfig->get(local_user(), '2fa', 'verified'); + $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified'); return Renderer::replaceMacros(Renderer::getMarkupTemplate('settings/twofactor/recovery.tpl'), [ '$form_security_token' => self::getFormSecurityToken('settings_2fa_recovery'), diff --git a/src/Module/Settings/TwoFactor/Trusted.php b/src/Module/Settings/TwoFactor/Trusted.php index 61f97dbd1..5c873c8f9 100644 --- a/src/Module/Settings/TwoFactor/Trusted.php +++ b/src/Module/Settings/TwoFactor/Trusted.php @@ -25,6 +25,7 @@ use Friendica\App; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; use Friendica\Module\BaseSettings; use Friendica\Module\Response; @@ -52,11 +53,11 @@ class Trusted extends BaseSettings $this->pConfig = $pConfig; $this->trustedBrowserRepo = $trustedBrowserRepo; - if (!local_user()) { + if (!Session::getLocalUser()) { return; } - $verified = $this->pConfig->get(local_user(), '2fa', 'verified'); + $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified'); if (!$verified) { $this->baseUrl->redirect('settings/2fa'); @@ -70,7 +71,7 @@ class Trusted extends BaseSettings protected function post(array $request = []) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } @@ -79,7 +80,7 @@ class Trusted extends BaseSettings switch ($_POST['action']) { case 'remove_all': - $this->trustedBrowserRepo->removeAllForUser(local_user()); + $this->trustedBrowserRepo->removeAllForUser(Session::getLocalUser()); DI::sysmsg()->addInfo($this->t('Trusted browsers successfully removed.')); $this->baseUrl->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password')); break; @@ -89,7 +90,7 @@ class Trusted extends BaseSettings if (!empty($_POST['remove_id'])) { self::checkFormSecurityTokenRedirectOnError('settings/2fa/trusted', 'settings_2fa_trusted'); - if ($this->trustedBrowserRepo->removeForUser(local_user(), $_POST['remove_id'])) { + if ($this->trustedBrowserRepo->removeForUser(Session::getLocalUser(), $_POST['remove_id'])) { DI::sysmsg()->addInfo($this->t('Trusted browser successfully removed.')); } @@ -102,7 +103,7 @@ class Trusted extends BaseSettings { parent::content(); - $trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(local_user()); + $trustedBrowsers = $this->trustedBrowserRepo->selectAllByUid(Session::getLocalUser()); $parser = Parser::create(); diff --git a/src/Module/Settings/TwoFactor/Verify.php b/src/Module/Settings/TwoFactor/Verify.php index 86e9af5ae..208fff49d 100644 --- a/src/Module/Settings/TwoFactor/Verify.php +++ b/src/Module/Settings/TwoFactor/Verify.php @@ -54,12 +54,12 @@ class Verify extends BaseSettings $this->pConfig = $pConfig; - if (!local_user()) { + if (!Session::getLocalUser()) { return; } - $secret = $this->pConfig->get(local_user(), '2fa', 'secret'); - $verified = $this->pConfig->get(local_user(), '2fa', 'verified'); + $secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'); + $verified = $this->pConfig->get(Session::getLocalUser(), '2fa', 'verified'); if ($secret && $verified) { $this->baseUrl->redirect('settings/2fa'); @@ -73,7 +73,7 @@ class Verify extends BaseSettings protected function post(array $request = []) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } @@ -82,10 +82,10 @@ class Verify extends BaseSettings $google2fa = new Google2FA(); - $valid = $google2fa->verifyKey($this->pConfig->get(local_user(), '2fa', 'secret'), $_POST['verify_code'] ?? ''); + $valid = $google2fa->verifyKey($this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'), $_POST['verify_code'] ?? ''); if ($valid) { - $this->pConfig->set(local_user(), '2fa', 'verified', true); + $this->pConfig->set(Session::getLocalUser(), '2fa', 'verified', true); DI::session()->set('2fa', true); DI::sysmsg()->addInfo($this->t('Two-factor authentication successfully activated.')); @@ -99,7 +99,7 @@ class Verify extends BaseSettings protected function content(array $request = []): string { - if (!local_user()) { + if (!Session::getLocalUser()) { return Login::form('settings/2fa/verify'); } @@ -107,7 +107,7 @@ class Verify extends BaseSettings $company = 'Friendica'; $holder = DI::session()->get('my_address'); - $secret = $this->pConfig->get(local_user(), '2fa', 'secret'); + $secret = $this->pConfig->get(Session::getLocalUser(), '2fa', 'secret'); $otpauthUrl = (new Google2FA())->getQRCodeUrl($company, $holder, $secret); diff --git a/src/Module/Settings/UserExport.php b/src/Module/Settings/UserExport.php index ccfd08b52..5932640f4 100644 --- a/src/Module/Settings/UserExport.php +++ b/src/Module/Settings/UserExport.php @@ -24,6 +24,7 @@ namespace Friendica\Module\Settings; use Friendica\App; use Friendica\Core\Hook; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; @@ -54,7 +55,7 @@ class UserExport extends BaseSettings */ protected function content(array $request = []): string { - if (!local_user()) { + if (!Session::getLocalUser()) { throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.')); } @@ -100,17 +101,17 @@ class UserExport extends BaseSettings case "backup": header("Content-type: application/json"); header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"'); - self::exportAll(local_user()); + self::exportAll(Session::getLocalUser()); break; case "account": header("Content-type: application/json"); header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '.' . $action . '"'); - self::exportAccount(local_user()); + self::exportAccount(Session::getLocalUser()); break; case "contact": header("Content-type: application/csv"); header('Content-Disposition: attachment; filename="' . DI::app()->getLoggedInUserNickname() . '-contacts.csv' . '"'); - self::exportContactsAsCSV(local_user()); + self::exportContactsAsCSV(Session::getLocalUser()); break; } System::exit(); diff --git a/src/Module/Update/Community.php b/src/Module/Update/Community.php index 0810cbed2..d3648888f 100644 --- a/src/Module/Update/Community.php +++ b/src/Module/Update/Community.php @@ -22,6 +22,7 @@ namespace Friendica\Module\Update; +use Friendica\Core\Session; use Friendica\Core\System; use Friendica\DI; use Friendica\Module\Conversation\Community as CommunityModule; @@ -38,8 +39,8 @@ class Community extends CommunityModule $this->parseRequest(); $o = ''; - if (!empty($_GET['force']) || !DI::pConfig()->get(local_user(), 'system', 'no_auto_update')) { - $o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', local_user()); + if (!empty($_GET['force']) || !DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update')) { + $o = DI::conversation()->create(self::getItems(), 'community', true, false, 'commented', Session::getLocalUser()); } System::htmlUpdateExit($o); diff --git a/src/Module/Update/Profile.php b/src/Module/Update/Profile.php index 4a1360fb9..a05d70482 100644 --- a/src/Module/Update/Profile.php +++ b/src/Module/Update/Profile.php @@ -42,13 +42,13 @@ class Profile extends BaseModule // Ensure we've got a profile owner if updating. $a->setProfileOwner((int)($_GET['p'] ?? 0)); - if (DI::config()->get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->getProfileOwner())) { + if (DI::config()->get('system', 'block_public') && !Session::getLocalUser() && !Session::getRemoteContactID($a->getProfileOwner())) { throw new ForbiddenException(); } $remote_contact = Session::getRemoteContactID($a->getProfileOwner()); - $is_owner = local_user() == $a->getProfileOwner(); - $last_updated_key = "profile:" . $a->getProfileOwner() . ":" . local_user() . ":" . $remote_contact; + $is_owner = Session::getLocalUser() == $a->getProfileOwner(); + $last_updated_key = "profile:" . $a->getProfileOwner() . ":" . Session::getLocalUser() . ":" . $remote_contact; if (!$is_owner && !$remote_contact) { $user = User::getById($a->getProfileOwner(), ['hidewall']); @@ -59,7 +59,7 @@ class Profile extends BaseModule $o = ''; - if (empty($_GET['force']) && DI::pConfig()->get(local_user(), 'system', 'no_auto_update')) { + if (empty($_GET['force']) && DI::pConfig()->get(Session::getLocalUser(), 'system', 'no_auto_update')) { System::htmlUpdateExit($o); } @@ -110,9 +110,9 @@ class Profile extends BaseModule } if ($is_owner) { - $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => local_user()]); + $unseen = Post::exists(['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]); if ($unseen) { - Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => local_user()]); + Item::update(['unseen' => false], ['wall' => true, 'unseen' => true, 'uid' => Session::getLocalUser()]); } }