X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FModule%2FNotifications%2FPing.php;h=603d6408c7bde7c008f73772441ab63d15fd76e4;hb=0a45bdd3b71ec0f8744abb3830858a91a4bca146;hp=15c775d201fa3f78a978e337b95cc33f669db641;hpb=360614d2cf3aceeb763ef1281ad5236878f5d735;p=friendica.git diff --git a/src/Module/Notifications/Ping.php b/src/Module/Notifications/Ping.php index 15c775d201..603d6408c7 100644 --- a/src/Module/Notifications/Ping.php +++ b/src/Module/Notifications/Ping.php @@ -24,7 +24,7 @@ namespace Friendica\Module\Notifications; use Friendica\App; use Friendica\BaseModule; use Friendica\Contact\Introduction\Repository\Introduction; -use Friendica\Content\ForumManager; +use Friendica\Content\GroupManager; use Friendica\Core\Cache\Capability\ICanCache; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Config\Capability\IManageConfigValues; @@ -35,7 +35,7 @@ use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Core\System; use Friendica\Database\Database; use Friendica\Database\DBA; -use Friendica\Model\Group; +use Friendica\Model\Circle; use Friendica\Model\Post; use Friendica\Model\User; use Friendica\Model\Verb; @@ -52,6 +52,7 @@ use Friendica\Network\HTTPException; use Friendica\Protocol\Activity; use Friendica\Util\DateTimeFormat; use Friendica\Util\Profiler; +use Friendica\Util\Strings; use GuzzleHttp\Psr7\Uri; use Psr\Log\LoggerInterface; @@ -108,15 +109,15 @@ class Ping extends BaseModule $network_count = 0; $register_count = 0; $sysnotify_count = 0; + $circles_unseen = []; $groups_unseen = []; - $forums_unseen = []; $event_count = 0; $today_event_count = 0; $birthday_count = 0; $today_birthday_count = 0; - // Suppress notification display for forum accounts + // Suppress notification display for group accounts if ($this->session->getLocalUserId() && $this->session->get('page_flags', '') != User::PAGE_FLAGS_COMMUNITY) { if ($this->pconfig->get($this->session->getLocalUserId(), 'system', 'detailed_notif')) { $notifications = $this->notificationRepo->selectDetailedForUser($this->session->getLocalUserId()); @@ -151,18 +152,18 @@ class Ping extends BaseModule } } - $compute_group_counts = $this->config->get('system','compute_group_counts'); - if ($network_count && $compute_group_counts) { - // Find out how unseen network posts are spread across groups - foreach (Group::countUnseen() as $group_count) { - if ($group_count['count'] > 0) { - $groups_unseen[] = $group_count; + $compute_circle_counts = $this->config->get('system','compute_group_counts') ?? $this->config->get('system','compute_circle_counts'); + if ($network_count && $compute_circle_counts) { + // Find out how unseen network posts are spread across circles + foreach (Circle::countUnseen() as $circle_count) { + if ($circle_count['count'] > 0) { + $circles_unseen[] = $circle_count; } } - foreach (ForumManager::countUnseenItems() as $forum_count) { - if ($forum_count['count'] > 0) { - $forums_unseen[] = $forum_count; + foreach (GroupManager::countUnseenItems() as $group_count) { + if ($group_count['count'] > 0) { + $groups_unseen[] = $group_count; } } } @@ -174,7 +175,7 @@ class Ping extends BaseModule $myurl = $this->session->getMyUrl(); $mail_count = $this->database->count('mail', ["`uid` = ? AND NOT `seen` AND `from-url` != ?", $this->session->getLocalUserId(), $myurl]); - if (intval($this->config->get('config', 'register_policy')) === Register::APPROVE && $this->app->isSiteAdmin()) { + if (intval($this->config->get('config', 'register_policy')) === Register::APPROVE && $this->session->isSiteAdmin()) { $registrations = \Friendica\Model\Register::getPending(); $register_count = count($registrations); } @@ -244,7 +245,7 @@ class Ping extends BaseModule $registration['url'], $this->l10n->t('{0} requested registration'), new \DateTime($registration['created'], new \DateTimeZone('UTC')), - new Uri($this->baseUrl->get(true) . '/moderation/users/pending') + new Uri($this->baseUrl . '/moderation/users/pending') ); } } else { @@ -253,7 +254,7 @@ class Ping extends BaseModule $registrations[0]['url'], $this->l10n->t('{0} and %d others requested registration', count($registrations) - 1), new \DateTime($registrations[0]['created'], new \DateTimeZone('UTC')), - new Uri($this->baseUrl->get(true) . '/moderation/users/pending') + new Uri($this->baseUrl . '/moderation/users/pending') ); } @@ -289,15 +290,15 @@ class Ping extends BaseModule $data['events-today'] = $today_event_count; $data['birthdays'] = $birthday_count; $data['birthdays-today'] = $today_birthday_count; + $data['circles'] = $circles_unseen; $data['groups'] = $groups_unseen; - $data['forums'] = $forums_unseen; $data['notification'] = ($notification_count < 50) ? $notification_count : '49+'; $data['notifications'] = $navNotifications; $data['sysmsgs'] = [ - 'notice' => $this->systemMessages->flushNotices(), - 'info' => $this->systemMessages->flushInfos(), + 'notice' => array_map([Strings::class, 'escapeHtml'], $this->systemMessages->flushNotices()), + 'info' => array_map([Strings::class, 'escapeHtml'], $this->systemMessages->flushInfos()), ]; if (isset($_GET['callback'])) {