]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Notifications/Ping.php
Merge pull request #12051 from Quix0r/hotfix/one-dollar-to-much
[friendica.git] / src / Module / Notifications / Ping.php
index 57da97b4f7a5e0da28123abf493c4f24b5f33de8..a0fe8e9aee13a33c210ff8fe96420ef35211fcbe 100644 (file)
@@ -90,18 +90,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 (DI::userSession()->getLocalUserId()) {
+                       if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
+                               $notifications = $this->notificationRepo->selectDetailedForUser(DI::userSession()->getLocalUserId());
                        } else {
-                               $notifications = $this->notificationRepo->selectDigestForUser(local_user());
+                               $notifications = $this->notificationRepo->selectDigestForUser(DI::userSession()->getLocalUserId());
                        }
 
                        $condition = [
                                "`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
-                               local_user(), Verb::getID(Activity::FOLLOW)
+                               DI::userSession()->getLocalUserId(), Verb::getID(Activity::FOLLOW)
                        ];
-                       $items = Post::selectForUser(local_user(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]);
+                       $items = Post::selectForUser(DI::userSession()->getLocalUserId(), ['wall', 'uid', 'uri-id'], $condition, ['limit' => 1000]);
                        if (DBA::isResult($items)) {
                                $items_unseen = Post::toArray($items, false);
                                $arr          = ['items' => $items_unseen];
@@ -139,12 +139,12 @@ class Ping extends BaseModule
                                }
                        }
 
-                       $intros = $this->introductionRepo->selectForUser(local_user());
+                       $intros = $this->introductionRepo->selectForUser(DI::userSession()->getLocalUserId());
 
                        $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` != ?", DI::userSession()->getLocalUserId(), $myurl]);
 
                        if (intval(DI::config()->get('config', 'register_policy')) === Register::APPROVE && DI::app()->isSiteAdmin()) {
                                $regs = \Friendica\Model\Register::getPending();
@@ -154,15 +154,13 @@ class Ping extends BaseModule
                                }
                        }
 
-                       $cachekey = 'ping:events:' . local_user();
+                       $cachekey = 'ping:events:' . DI::userSession()->getLocalUserId();
                        $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()]);
-                               if (DBA::isResult($ev)) {
-                                       DI::cache()->set($cachekey, $ev, Duration::HOUR);
-                               }
+                                               DI::userSession()->getLocalUserId(), DateTimeFormat::utc('now + 7 days'), DateTimeFormat::utcNow()]);
+                               DI::cache()->set($cachekey, $ev, Duration::HOUR);
                        }
 
                        if (DBA::isResult($ev)) {
@@ -189,7 +187,7 @@ class Ping extends BaseModule
                                }
                        }
 
-                       $owner = User::getOwnerDataById(local_user());
+                       $owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
 
                        $navNotifications = array_map(function (Entity\Notification $notification) use ($owner) {
                                if (!DI::notify()->NotifyOnDesktop($notification)) {
@@ -216,7 +214,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(DI::userSession()->getLocalUserId(), 'system', 'detailed_notif')) {
                                        foreach ($regs as $reg) {
                                                $navNotifications[] = $this->formattedNavNotification->createFromParams(
                                                        [