diff --git a/doc/Addons.md b/doc/Addons.md index 91765ec484..b43a8a915d 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -281,7 +281,7 @@ $data = [ 'submit' => [ 'catavatar-usecat' => DI::l10n()->t('Use Cat as Avatar'), 'catavatar-morecat' => DI::l10n()->t('Another random Cat!'), - 'catavatar-emailcat' => DI::pConfig()->get(local_user(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null, + 'catavatar-emailcat' => DI::pConfig()->get(Session::getLocalUser(), 'catavatar', 'seed', false) ? DI::l10n()->t('Reset to email Cat') : null, ], ]; ``` diff --git a/doc/Developer-Domain-Driven-Design.md b/doc/Developer-Domain-Driven-Design.md index 1e77dd2f0b..a4af436884 100644 --- a/doc/Developer-Domain-Driven-Design.md +++ b/doc/Developer-Domain-Driven-Design.md @@ -30,7 +30,7 @@ function doSomething(array $intros) } } -$intros = \Friendica\Database\DBA::selectToArray('intros', [], ['uid' => local_user()]); +$intros = \Friendica\Database\DBA::selectToArray('intros', [], ['uid' => Session::getLocalUser()]); doSomething($intros); ``` @@ -47,7 +47,7 @@ function doSomething(\Friendica\Contact\Introductions\Collection\Introductions $ } /** @var $intros \Friendica\Contact\Introductions\Collection\Introductions */ -$intros = \Friendica\DI::intro()->selecForUser(local_user()); +$intros = \Friendica\DI::intro()->selecForUser(Session::getLocalUser()); doSomething($intros); ``` diff --git a/doc/themes.md b/doc/themes.md index 7abd787e6c..60f4fdb96d 100644 --- a/doc/themes.md +++ b/doc/themes.md @@ -123,13 +123,13 @@ The selected 1st part will be saved in the database by the theme_post function. function theme_post(App $a){ // non local users shall not pass - if (! local_user()) { + if (!Session::getLocalUser()) { return; } // if the one specific submit button was pressed then proceed if (isset($_POST['duepuntozero-settings-submit'])){ // and save the selection key into the personal config of the user - DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']); + DI::pConfig()->set(Session::getLocalUser(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']); } } @@ -137,7 +137,7 @@ Now that this information is set in the database, what should friendica do with For this, have a look at the theme.php file of the *duepunto zero*. There you'll find somethink alike - $colorset = DI::pConfig()->get( local_user(), 'duepuntozero','colorset'); + $colorset = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero','colorset'); if (!$colorset) $colorset = DI::config()->get('duepuntozero', 'colorset'); if ($colorset) { diff --git a/src/Navigation/Notifications/Factory/FormattedNavNotification.php b/src/Navigation/Notifications/Factory/FormattedNavNotification.php index dbd808ba7c..8457b92564 100644 --- a/src/Navigation/Notifications/Factory/FormattedNavNotification.php +++ b/src/Navigation/Notifications/Factory/FormattedNavNotification.php @@ -23,6 +23,7 @@ namespace Friendica\Navigation\Notifications\Factory; use Friendica\BaseFactory; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\Model\Contact; use Friendica\Navigation\Notifications\Entity; use Friendica\Navigation\Notifications\Exception\NoMessageException; @@ -71,7 +72,7 @@ class FormattedNavNotification extends BaseFactory */ public function createFromParams(array $contact, string $message, \DateTime $date, Uri $href, bool $seen = false): ValueObject\FormattedNavNotification { - $contact['photo'] = Contact::getAvatarUrlForUrl($contact['url'], local_user(), Proxy::SIZE_MICRO); + $contact['photo'] = Contact::getAvatarUrlForUrl($contact['url'], Session::getLocalUser(), Proxy::SIZE_MICRO); $dateMySQL = $date->format(DateTimeFormat::MYSQL); diff --git a/src/Navigation/Notifications/Factory/FormattedNotify.php b/src/Navigation/Notifications/Factory/FormattedNotify.php index 8f0fc5bb1f..4868ce1b9a 100644 --- a/src/Navigation/Notifications/Factory/FormattedNotify.php +++ b/src/Navigation/Notifications/Factory/FormattedNotify.php @@ -27,6 +27,7 @@ use Friendica\BaseFactory; use Friendica\Content\Text\BBCode; use Friendica\Core\L10n; use Friendica\Core\Protocol; +use Friendica\Core\Session; use Friendica\Database\Database; use Friendica\Model\Contact; use Friendica\Model\Item; @@ -210,7 +211,7 @@ class FormattedNotify extends BaseFactory $formattedNotifications = new FormattedNotifies(); try { - $Notifies = $this->notify->selectForUser(local_user(), $conditions, $params); + $Notifies = $this->notify->selectForUser(Session::getLocalUser(), $conditions, $params); foreach ($Notifies as $Notify) { $formattedNotifications[] = new ValueObject\FormattedNotify( @@ -243,7 +244,7 @@ class FormattedNotify extends BaseFactory */ public function getNetworkList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies { - $condition = ['wall' => false, 'uid' => local_user()]; + $condition = ['wall' => false, 'uid' => Session::getLocalUser()]; if (!$seen) { $condition['unseen'] = true; @@ -256,7 +257,7 @@ class FormattedNotify extends BaseFactory $formattedNotifications = new FormattedNotifies(); try { - $userPosts = Post::selectForUser(local_user(), $fields, $condition, $params); + $userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params); while ($userPost = $this->dba->fetch($userPosts)) { $formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost)); } @@ -279,7 +280,7 @@ class FormattedNotify extends BaseFactory */ public function getPersonalList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies { - $condition = ['wall' => false, 'uid' => local_user(), 'author-id' => public_contact()]; + $condition = ['wall' => false, 'uid' => Session::getLocalUser(), 'author-id' => Session::getPublicContact()]; if (!$seen) { $condition['unseen'] = true; @@ -292,7 +293,7 @@ class FormattedNotify extends BaseFactory $formattedNotifications = new FormattedNotifies(); try { - $userPosts = Post::selectForUser(local_user(), $fields, $condition, $params); + $userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params); while ($userPost = $this->dba->fetch($userPosts)) { $formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost)); } @@ -315,7 +316,7 @@ class FormattedNotify extends BaseFactory */ public function getHomeList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies { - $condition = ['wall' => true, 'uid' => local_user()]; + $condition = ['wall' => true, 'uid' => Session::getLocalUser()]; if (!$seen) { $condition['unseen'] = true; @@ -328,7 +329,7 @@ class FormattedNotify extends BaseFactory $formattedNotifications = new FormattedNotifies(); try { - $userPosts = Post::selectForUser(local_user(), $fields, $condition, $params); + $userPosts = Post::selectForUser(Session::getLocalUser(), $fields, $condition, $params); while ($userPost = $this->dba->fetch($userPosts)) { $formattedItem = $this->formatItem($userPost); diff --git a/src/Navigation/Notifications/Factory/Introduction.php b/src/Navigation/Notifications/Factory/Introduction.php index cfadce5a8f..1b718ad1a5 100644 --- a/src/Navigation/Notifications/Factory/Introduction.php +++ b/src/Navigation/Notifications/Factory/Introduction.php @@ -29,6 +29,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; use Friendica\Core\Protocol; +use Friendica\Core\Session; use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Database\Database; use Friendica\Model\Contact; @@ -142,7 +143,7 @@ class Introduction extends BaseFactory 'url' => $intro['furl'], 'zrl' => Contact::magicLink($intro['furl']), 'hidden' => $intro['hidden'] == 1, - 'post_newfriend' => (intval($this->pConfig->get(local_user(), 'system', 'post_newfriend')) ? '1' : 0), + 'post_newfriend' => (intval($this->pConfig->get(Session::getLocalUser(), 'system', 'post_newfriend')) ? '1' : 0), 'note' => $intro['note'], 'request' => $intro['frequest'] . '?addr=' . $return_addr]); @@ -167,7 +168,7 @@ class Introduction extends BaseFactory 'about' => BBCode::convert($intro['about'], false), 'keywords' => $intro['keywords'], 'hidden' => $intro['hidden'] == 1, - 'post_newfriend' => (intval($this->pConfig->get(local_user(), 'system', 'post_newfriend')) ? '1' : 0), + 'post_newfriend' => (intval($this->pConfig->get(Session::getLocalUser(), 'system', 'post_newfriend')) ? '1' : 0), 'url' => $intro['url'], 'zrl' => Contact::magicLink($intro['url']), 'addr' => $intro['addr'], diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 98d195ca18..4261ad84e0 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -27,6 +27,7 @@ use Exception; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Protocol; +use Friendica\Core\Session; use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; @@ -316,7 +317,7 @@ class Probe } if ($uid == -1) { - $uid = local_user(); + $uid = Session::getLocalUser(); } if (empty($network) || ($network == Protocol::ACTIVITYPUB)) { diff --git a/src/Object/Post.php b/src/Object/Post.php index bbce296727..a86539f1df 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -104,14 +104,14 @@ class Post if (!empty($data['children'])) { foreach ($data['children'] as $item) { // Only add will be displayed - if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) { + if ($item['network'] === Protocol::MAIL && Session::getLocalUser() != $item['uid']) { continue; } elseif (!DI::contentItem()->isVisibleActivity($item)) { continue; } // You can always comment on Diaspora and OStatus items - if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (local_user() == $item['uid'])) { + if (in_array($item['network'], [Protocol::OSTATUS, Protocol::DIASPORA]) && (Session::getLocalUser() == $item['uid'])) { $item['writable'] = true; } @@ -206,7 +206,7 @@ class Post $lock = ($item['private'] == Item::PRIVATE) ? $privacy : false; $connector = !in_array($item['network'], Protocol::NATIVE_SUPPORT) ? DI::l10n()->t('Connector Message') : false; - $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE; + $shareable = in_array($conv->getProfileOwner(), [0, Session::getLocalUser()]) && $item['private'] != Item::PRIVATE; $announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]); // On Diaspora only toplevel posts can be reshared @@ -216,7 +216,7 @@ class Post $edpost = false; - if (local_user()) { + if (Session::getLocalUser()) { if (Strings::compareLink(DI::session()->get('my_url'), $item['author-link'])) { if ($item['event-id'] != 0) { $edpost = ['events/event/' . $item['event-id'], DI::l10n()->t('Edit')]; @@ -224,7 +224,7 @@ class Post $edpost = ['editpost/' . $item['id'], DI::l10n()->t('Edit')]; } } - $dropping = in_array($item['uid'], [0, local_user()]); + $dropping = in_array($item['uid'], [0, Session::getLocalUser()]); } // Editing on items of not subscribed users isn't currently possible @@ -234,7 +234,7 @@ class Post $edpost = false; } - if (($this->getDataValue('uid') == local_user()) || $this->isVisiting()) { + if (($this->getDataValue('uid') == Session::getLocalUser()) || $this->isVisiting()) { $dropping = true; } @@ -249,7 +249,7 @@ class Post $drop = false; $block = false; - if (local_user()) { + if (Session::getLocalUser()) { $drop = [ 'dropping' => $dropping, 'pagedrop' => $item['pagedrop'], @@ -258,7 +258,7 @@ class Post ]; } - if (!$item['self'] && local_user()) { + if (!$item['self'] && Session::getLocalUser()) { $block = [ 'blocking' => true, 'block' => DI::l10n()->t('Block %s', $item['author-name']), @@ -266,7 +266,7 @@ class Post ]; } - $filer = local_user() ? DI::l10n()->t('Save to folder') : false; + $filer = Session::getLocalUser() ? DI::l10n()->t('Save to folder') : false; $profile_name = $item['author-name']; if (!empty($item['author-link']) && empty($item['author-name'])) { @@ -327,8 +327,8 @@ class Post $tagger = ''; if ($this->isToplevel()) { - if (local_user()) { - $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], local_user()); + if (Session::getLocalUser()) { + $ignored = PostModel\ThreadUser::getIgnored($item['uri-id'], Session::getLocalUser()); if ($item['mention'] || $ignored) { $ignore = [ 'do' => DI::l10n()->t('Ignore thread'), @@ -351,7 +351,7 @@ class Post 'starred' => DI::l10n()->t('Starred'), ]; - if ($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) { + if ($conv->getProfileOwner() == Session::getLocalUser() && ($item['uid'] != 0)) { if ($origin && in_array($item['private'], [Item::PUBLIC, Item::UNLISTED])) { $ispinned = ($item['featured'] ? 'pinned' : 'unpinned'); @@ -397,17 +397,17 @@ class Post $body_html = Item::prepareBody($item, true); - list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, local_user()); + list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item, Session::getLocalUser()); if (!empty($item['title'])) { $title = $item['title']; - } elseif (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { + } elseif (!empty($item['content-warning']) && DI::pConfig()->get(Session::getLocalUser(), 'system', 'disable_cw', false)) { $title = ucfirst($item['content-warning']); } else { $title = ''; } - if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { + if (DI::pConfig()->get(Session::getLocalUser(), 'system', 'hide_dislike')) { $buttons['dislike'] = false; } @@ -434,7 +434,7 @@ class Post } // Fetching of Diaspora posts doesn't always work. There are issues with reshares and possibly comments - if (!local_user() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) { + if (!Session::getLocalUser() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) { $remote_comment = [DI::l10n()->t('Comment this item on your system'), DI::l10n()->t('Remote comment'), str_replace('{uri}', urlencode($item['uri']), DI::session()->get('remote_comment'))]; @@ -642,7 +642,7 @@ class Post /* * Only add what will be displayed */ - if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) { + if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) { return false; } elseif ($activity->match($item->getDataValue('verb'), Activity::LIKE) || $activity->match($item->getDataValue('verb'), Activity::DISLIKE)) { @@ -850,7 +850,7 @@ class Post // This will allow us to comment on wall-to-wall items owned by our friends // and community forums even if somebody else wrote the post. // bug #517 - this fixes for conversation owner - if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == local_user()) { + if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == Session::getLocalUser()) { return true; } @@ -898,20 +898,20 @@ class Post { $a = DI::app(); - if (!local_user()) { + if (!Session::getLocalUser()) { return ''; } $owner = User::getOwnerDataById($a->getLoggedInUserId()); $item = $this->getData(); - if (!empty($item['content-warning']) && Feature::isEnabled(local_user(), 'add_abstract')) { + if (!empty($item['content-warning']) && Feature::isEnabled(Session::getLocalUser(), 'add_abstract')) { $text = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $item['content-warning'] . "[/abstract]\n"; } else { $text = ''; } - if (!Feature::isEnabled(local_user(), 'explicit_mentions')) { + if (!Feature::isEnabled(Session::getLocalUser(), 'explicit_mentions')) { return $text; } @@ -958,7 +958,7 @@ class Post */ $qcomment = null; if (Addon::isEnabled('qcomment')) { - $words = DI::pConfig()->get(local_user(), 'qcomment', 'words'); + $words = DI::pConfig()->get(Session::getLocalUser(), 'qcomment', 'words'); $qcomment = $words ? explode("\n", $words) : []; } diff --git a/src/Object/Thread.php b/src/Object/Thread.php index dd10a6aece..a628749001 100644 --- a/src/Object/Thread.php +++ b/src/Object/Thread.php @@ -23,6 +23,7 @@ namespace Friendica\Object; use Friendica\Core\Logger; use Friendica\Core\Protocol; +use Friendica\Core\Session; use Friendica\DI; use Friendica\Protocol\Activity; use Friendica\Security\Security; @@ -75,7 +76,7 @@ class Thread switch ($mode) { case 'network': case 'notes': - $this->profile_owner = local_user(); + $this->profile_owner = Session::getLocalUser(); $this->writable = true; break; case 'profile': @@ -168,7 +169,7 @@ class Thread /* * Only add will be displayed */ - if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) { + if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) { Logger::info('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').'); return false; } @@ -201,7 +202,7 @@ class Thread $result = []; foreach ($this->parents as $item) { - if ($item->getDataValue('network') === Protocol::MAIL && local_user() != $item->getDataValue('uid')) { + if ($item->getDataValue('network') === Protocol::MAIL && Session::getLocalUser() != $item->getDataValue('uid')) { continue; } diff --git a/src/Security/BasicAuth.php b/src/Security/BasicAuth.php index fc31d34b07..257e52d46e 100644 --- a/src/Security/BasicAuth.php +++ b/src/Security/BasicAuth.php @@ -191,7 +191,7 @@ class BasicAuth Hook::callAll('logged_in', $record); - self::$current_user_id = local_user(); + self::$current_user_id = Session::getLocalUser(); return self::$current_user_id; } diff --git a/src/Security/Security.php b/src/Security/Security.php index 5fda54d46c..f0b33501f9 100644 --- a/src/Security/Security.php +++ b/src/Security/Security.php @@ -40,12 +40,12 @@ class Security return false; } - $uid = local_user(); + $uid = Session::getLocalUser(); if ($uid == $owner) { return true; } - if (local_user() && ($owner == 0)) { + if (Session::getLocalUser() && ($owner == 0)) { return true; } @@ -93,7 +93,7 @@ class Security */ public static function getPermissionsSQLByUserId(int $owner_id, bool $accessible = false) { - $local_user = local_user(); + $local_user = Session::getLocalUser(); $remote_contact = Session::getRemoteContactID($owner_id); $acc_sql = ''; diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index cc6a078fe1..72271c06f1 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -24,6 +24,7 @@ namespace Friendica\Util; use DateTime; use DateTimeZone; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; @@ -238,7 +239,7 @@ class Temporal bool $required = false): string { // First day of the week (0 = Sunday) - $firstDay = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0); + $firstDay = DI::pConfig()->get(Session::getLocalUser(), 'system', 'first_day_of_week', 0); $lang = substr(DI::l10n()->getCurrentLang(), 0, 2); diff --git a/view/theme/duepuntozero/config.php b/view/theme/duepuntozero/config.php index 7d2c3f4256..1a2d231f43 100644 --- a/view/theme/duepuntozero/config.php +++ b/view/theme/duepuntozero/config.php @@ -1,19 +1,36 @@ . + * */ use Friendica\App; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; function theme_content(App $a) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } - $colorset = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset'); + $colorset = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero', 'colorset'); $user = true; return clean_form($a, $colorset, $user); @@ -21,12 +38,12 @@ function theme_content(App $a) function theme_post(App $a) { - if (! local_user()) { + if (! Session::getLocalUser()) { return; } if (isset($_POST['duepuntozero-settings-submit'])) { - DI::pConfig()->set(local_user(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']); + DI::pConfig()->set(Session::getLocalUser(), 'duepuntozero', 'colorset', $_POST['duepuntozero_colorset']); } } @@ -59,7 +76,7 @@ function clean_form(App $a, &$colorset, $user) ]; if ($user) { - $color = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset'); + $color = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero', 'colorset'); } else { $color = DI::config()->get('duepuntozero', 'colorset'); } diff --git a/view/theme/duepuntozero/theme.php b/view/theme/duepuntozero/theme.php index 327a1e73ba..70190eb02c 100644 --- a/view/theme/duepuntozero/theme.php +++ b/view/theme/duepuntozero/theme.php @@ -21,6 +21,7 @@ use Friendica\App; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; /* @@ -34,7 +35,7 @@ function duepuntozero_init(App $a) { $colorset = null; if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) { - $colorset = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset'); + $colorset = DI::pConfig()->get(Session::getLocalUser(), 'duepuntozero', 'colorset'); if (!$colorset) $colorset = DI::config()->get('duepuntozero', 'colorset'); // user setting have priority, then node settings } diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index 2dcf002048..4c7a13542b 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -21,13 +21,14 @@ use Friendica\App; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; require_once 'view/theme/frio/php/Image.php'; function theme_post(App $a) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } @@ -47,12 +48,12 @@ function theme_post(App $a) 'always_open_compose', ] as $field) { if (isset($_POST['frio_' . $field])) { - DI::pConfig()->set(local_user(), 'frio', $field, $_POST['frio_' . $field]); + DI::pConfig()->set(Session::getLocalUser(), 'frio', $field, $_POST['frio_' . $field]); } } - DI::pConfig()->set(local_user(), 'frio', 'css_modified', time()); + DI::pConfig()->set(Session::getLocalUser(), 'frio', 'css_modified', time()); } } @@ -88,13 +89,13 @@ function theme_admin_post(App $a) function theme_content(): string { - if (!local_user()) { + if (!Session::getLocalUser()) { return ''; } $arr = [ - 'scheme' => DI::pConfig()->get(local_user(), 'frio', 'scheme', - DI::pConfig()->get(local_user(), 'frio', 'schema', + 'scheme' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'scheme', + DI::pConfig()->get(Session::getLocalUser(), 'frio', 'schema', DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema') ) @@ -102,15 +103,15 @@ function theme_content(): string ), 'share_string' => '', - 'scheme_accent' => DI::pConfig()->get(local_user(), 'frio', 'scheme_accent' , DI::config()->get('frio', 'scheme_accent')), - 'nav_bg' => DI::pConfig()->get(local_user(), 'frio', 'nav_bg' , DI::config()->get('frio', 'nav_bg')), - 'nav_icon_color' => DI::pConfig()->get(local_user(), 'frio', 'nav_icon_color' , DI::config()->get('frio', 'nav_icon_color')), - 'link_color' => DI::pConfig()->get(local_user(), 'frio', 'link_color' , DI::config()->get('frio', 'link_color')), - 'background_color' => DI::pConfig()->get(local_user(), 'frio', 'background_color' , DI::config()->get('frio', 'background_color')), - 'contentbg_transp' => DI::pConfig()->get(local_user(), 'frio', 'contentbg_transp' , DI::config()->get('frio', 'contentbg_transp')), - 'background_image' => DI::pConfig()->get(local_user(), 'frio', 'background_image' , DI::config()->get('frio', 'background_image')), - 'bg_image_option' => DI::pConfig()->get(local_user(), 'frio', 'bg_image_option' , DI::config()->get('frio', 'bg_image_option')), - 'always_open_compose' => DI::pConfig()->get(local_user(), 'frio', 'always_open_compose', DI::config()->get('frio', 'always_open_compose', false)), + 'scheme_accent' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'scheme_accent' , DI::config()->get('frio', 'scheme_accent')), + 'nav_bg' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'nav_bg' , DI::config()->get('frio', 'nav_bg')), + 'nav_icon_color' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'nav_icon_color' , DI::config()->get('frio', 'nav_icon_color')), + 'link_color' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'link_color' , DI::config()->get('frio', 'link_color')), + 'background_color' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'background_color' , DI::config()->get('frio', 'background_color')), + 'contentbg_transp' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'contentbg_transp' , DI::config()->get('frio', 'contentbg_transp')), + 'background_image' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'background_image' , DI::config()->get('frio', 'background_image')), + 'bg_image_option' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'bg_image_option' , DI::config()->get('frio', 'bg_image_option')), + 'always_open_compose' => DI::pConfig()->get(Session::getLocalUser(), 'frio', 'always_open_compose', DI::config()->get('frio', 'always_open_compose', false)), ]; return frio_form($arr); @@ -118,7 +119,7 @@ function theme_content(): string function theme_admin(): string { - if (!local_user()) { + if (!Session::getLocalUser()) { return ''; } diff --git a/view/theme/frio/php/scheme.php b/view/theme/frio/php/scheme.php index 994f2eb147..26c3588776 100644 --- a/view/theme/frio/php/scheme.php +++ b/view/theme/frio/php/scheme.php @@ -34,6 +34,7 @@ * 'overwrites' => Variables which overwriting custom settings */ +use Friendica\Core\Session; use Friendica\DI; use Friendica\Util\Strings; @@ -42,7 +43,7 @@ function get_scheme_info($scheme) $theme = DI::app()->getCurrentTheme(); $themepath = 'view/theme/' . $theme . '/'; if (empty($scheme)) { - $scheme = DI::pConfig()->get(local_user(), 'frio', 'scheme', DI::pConfig()->get(local_user(), 'frio', 'schema', '---')); + $scheme = DI::pConfig()->get(Session::getLocalUser(), 'frio', 'scheme', DI::pConfig()->get(Session::getLocalUser(), 'frio', 'schema', '---')); } $scheme = Strings::sanitizeFilePathItem($scheme); diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index 2913a15533..ce1e376e66 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -215,8 +215,8 @@ function frio_remote_nav(App $a, array &$nav_info) $fields = ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated']; if ($a->isLoggedIn()) { $remoteUser = Contact::selectFirst($fields, ['uid' => $a->getLoggedInUserId(), 'self' => true]); - } elseif (!local_user() && remote_user()) { - $remoteUser = Contact::getById(remote_user(), $fields); + } elseif (!Session::getLocalUser() && Session::getRemoteUser()) { + $remoteUser = Contact::getById(Session::getRemoteUser(), $fields); $nav_info['nav']['remote'] = DI::l10n()->t('Guest'); } elseif (Profile::getMyURL()) { $remoteUser = Contact::getByURL($homelink, null, $fields); @@ -233,7 +233,7 @@ function frio_remote_nav(App $a, array &$nav_info) $server_url = $remoteUser['baseurl']; } - if (!local_user() && !empty($server_url) && !is_null($remoteUser)) { + if (!Session::getLocalUser() && !empty($server_url) && !is_null($remoteUser)) { // user menu $nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')]; $nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')]; @@ -257,8 +257,8 @@ function frio_display_item(App $a, &$arr) // Add follow to the item menu $followThread = []; if ( - local_user() - && in_array($arr['item']['uid'], [0, local_user()]) + Session::getLocalUser() + && in_array($arr['item']['uid'], [0, Session::getLocalUser()]) && $arr['item']['gravity'] == Item::GRAVITY_PARENT && !$arr['item']['self'] && !$arr['item']['mention'] diff --git a/view/theme/quattro/config.php b/view/theme/quattro/config.php index 64284eaa06..48ef298f98 100644 --- a/view/theme/quattro/config.php +++ b/view/theme/quattro/config.php @@ -1,35 +1,52 @@ . + * */ use Friendica\App; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; function theme_content(App $a) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } - $align = DI::pConfig()->get(local_user(), 'quattro', 'align' ); - $color = DI::pConfig()->get(local_user(), 'quattro', 'color' ); - $tfs = DI::pConfig()->get(local_user(),"quattro","tfs"); - $pfs = DI::pConfig()->get(local_user(),"quattro","pfs"); + $align = DI::pConfig()->get(Session::getLocalUser(), 'quattro', 'align' ); + $color = DI::pConfig()->get(Session::getLocalUser(), 'quattro', 'color' ); + $tfs = DI::pConfig()->get(Session::getLocalUser(),"quattro","tfs"); + $pfs = DI::pConfig()->get(Session::getLocalUser(),"quattro","pfs"); return quattro_form($a,$align, $color, $tfs, $pfs); } function theme_post(App $a) { - if (! local_user()) { + if (! Session::getLocalUser()) { return; } if (isset($_POST['quattro-settings-submit'])){ - DI::pConfig()->set(local_user(), 'quattro', 'align', $_POST['quattro_align']); - DI::pConfig()->set(local_user(), 'quattro', 'color', $_POST['quattro_color']); - DI::pConfig()->set(local_user(), 'quattro', 'tfs', $_POST['quattro_tfs']); - DI::pConfig()->set(local_user(), 'quattro', 'pfs', $_POST['quattro_pfs']); + DI::pConfig()->set(Session::getLocalUser(), 'quattro', 'align', $_POST['quattro_align']); + DI::pConfig()->set(Session::getLocalUser(), 'quattro', 'color', $_POST['quattro_color']); + DI::pConfig()->set(Session::getLocalUser(), 'quattro', 'tfs', $_POST['quattro_tfs']); + DI::pConfig()->set(Session::getLocalUser(), 'quattro', 'pfs', $_POST['quattro_pfs']); } } diff --git a/view/theme/vier/config.php b/view/theme/vier/config.php index 5891aa32f4..28aebf9700 100644 --- a/view/theme/vier/config.php +++ b/view/theme/vier/config.php @@ -1,17 +1,34 @@ . + * */ use Friendica\App; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\DI; require_once __DIR__ . '/theme.php'; function theme_content(App $a) { - if (!local_user()) { + if (!Session::getLocalUser()) { return; } @@ -19,7 +36,7 @@ function theme_content(App $a) return; } - $style = DI::pConfig()->get(local_user(), 'vier', 'style'); + $style = DI::pConfig()->get(Session::getLocalUser(), 'vier', 'style'); if ($style == "") { $style = DI::config()->get('vier', 'style'); @@ -42,18 +59,18 @@ function theme_content(App $a) function theme_post(App $a) { - if (! local_user()) { + if (! Session::getLocalUser()) { return; } if (isset($_POST['vier-settings-submit'])) { - DI::pConfig()->set(local_user(), 'vier', 'style', $_POST['vier_style']); - DI::pConfig()->set(local_user(), 'vier', 'show_pages', $_POST['vier_show_pages']); - DI::pConfig()->set(local_user(), 'vier', 'show_profiles', $_POST['vier_show_profiles']); - DI::pConfig()->set(local_user(), 'vier', 'show_helpers', $_POST['vier_show_helpers']); - DI::pConfig()->set(local_user(), 'vier', 'show_services', $_POST['vier_show_services']); - DI::pConfig()->set(local_user(), 'vier', 'show_friends', $_POST['vier_show_friends']); - DI::pConfig()->set(local_user(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']); + DI::pConfig()->set(Session::getLocalUser(), 'vier', 'style', $_POST['vier_style']); + DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_pages', $_POST['vier_show_pages']); + DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_profiles', $_POST['vier_show_profiles']); + DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_helpers', $_POST['vier_show_helpers']); + DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_services', $_POST['vier_show_services']); + DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_friends', $_POST['vier_show_friends']); + DI::pConfig()->set(Session::getLocalUser(), 'vier', 'show_lastusers', $_POST['vier_show_lastusers']); } } diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index a548d0a7dc..ec82cf428d 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -1,5 +1,22 @@ . + * * Name: Vier * Version: 1.2 * Author: Fabio @@ -14,6 +31,7 @@ use Friendica\Content\ForumManager; use Friendica\Core\Addon; use Friendica\Core\Renderer; use Friendica\Core\Search; +use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -35,7 +53,7 @@ function vier_init(App $a) DI::mode()->has(App\Mode::MAINTENANCEDISABLED) && ( $args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '') - || $args->get(0) === 'network' && local_user() + || $args->get(0) === 'network' && Session::getLocalUser() ) ) { vier_community_info(); @@ -97,8 +115,8 @@ EOT; function get_vier_config($key, $default = false, $admin = false) { - if (local_user() && !$admin) { - $result = DI::pConfig()->get(local_user(), "vier", $key); + if (Session::getLocalUser() && !$admin) { + $result = DI::pConfig()->get(Session::getLocalUser(), "vier", $key); if (!is_null($result)) { return $result; } @@ -127,7 +145,7 @@ function vier_community_info() // comunity_profiles if ($show_profiles) { - $contacts = Contact\Relation::getSuggestions(local_user(), 0, 9); + $contacts = Contact\Relation::getSuggestions(Session::getLocalUser(), 0, 9); $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl'); if (DBA::isResult($contacts)) { @@ -174,7 +192,7 @@ function vier_community_info() } //right_aside FIND FRIENDS - if ($show_friends && local_user()) { + if ($show_friends && Session::getLocalUser()) { $nv = []; $nv['findpeople'] = DI::l10n()->t('Find People'); $nv['desc'] = DI::l10n()->t('Enter name or interest'); @@ -193,8 +211,8 @@ function vier_community_info() } //Community_Pages at right_aside - if ($show_pages && local_user()) { - $aside['$page'] = ForumManager::widget('network/forum', local_user());; + if ($show_pages && Session::getLocalUser()) { + $aside['$page'] = ForumManager::widget('network/forum', Session::getLocalUser());; } // END Community Page