]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Notifications/Introductions.php
Merge pull request #12050 from nupplaphil/bug/notf_session_fix
[friendica.git] / src / Module / Notifications / Introductions.php
index 0a254f63f997f02f80593a606102f57e0dafd4ca..2bd03e3071784772e472d950ad7a5af115d1003d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -21,6 +21,7 @@
 
 namespace Friendica\Module\Notifications;
 
+use Friendica\App;
 use Friendica\App\Arguments;
 use Friendica\App\Mode;
 use Friendica\Content\ContactSelector;
@@ -29,10 +30,15 @@ use Friendica\Content\Text\BBCode;
 use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
+use Friendica\DI;
 use Friendica\Model\User;
 use Friendica\Module\BaseNotifications;
+use Friendica\Module\Response;
 use Friendica\Navigation\Notifications\Factory\Introduction as IntroductionFactory;
 use Friendica\Navigation\Notifications\ValueObject\Introduction;
+use Friendica\Util\Profiler;
+use Psr\Log\LoggerInterface;
 
 /**
  * Prints notifications about introduction
@@ -44,9 +50,9 @@ class Introductions extends BaseNotifications
        /** @var Mode */
        protected $mode;
 
-       public function __construct(Mode $mode, IntroductionFactory $notificationIntro, Arguments $args, L10n $l10n, array $parameters = [])
+       public function __construct(L10n $l10n, App\BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Mode $mode, IntroductionFactory $notificationIntro, IHandleUserSessions $userSession, array $server, array $parameters = [])
        {
-               parent::__construct($args, $l10n, $parameters);
+               parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $userSession, $server, $parameters);
 
                $this->notificationIntro = $notificationIntro;
                $this->mode              = $mode;
@@ -66,12 +72,12 @@ class Introductions extends BaseNotifications
                ];
 
                return [
-                       'header'        => $this->l10n->t('Notifications'),
+                       'header'        => $this->t('Notifications'),
                        'notifications' => $notifications,
                ];
        }
 
-       public function content(): string
+       protected function content(array $request = []): string
        {
                Nav::setSelected('introductions');
 
@@ -90,10 +96,10 @@ class Introductions extends BaseNotifications
                // The link to switch between ignored and normal connection requests
                $notificationShowLink = [
                        'href' => (!$all ? 'notifications/intros/all' : 'notifications/intros'),
-                       'text' => (!$all ? $this->l10n->t('Show Ignored Requests') : $this->l10n->t('Hide Ignored Requests')),
+                       'text' => (!$all ? $this->t('Show Ignored Requests') : $this->t('Hide Ignored Requests')),
                ];
 
-               $owner = User::getOwnerDataById(local_user());
+               $owner = User::getOwnerDataById(DI::userSession()->getLocalUserId());
        
                // Loop through all introduction notifications.This creates an array with the output html for each
                // introduction
@@ -106,10 +112,10 @@ class Introductions extends BaseNotifications
                                case 'friend_suggestion':
                                        $notificationContent[] = Renderer::replaceMacros($notificationSuggestions, [
                                                '$type'                  => $Introduction->getLabel(),
-                                               '$str_notification_type' => $this->l10n->t('Notification type:'),
+                                               '$str_notification_type' => $this->t('Notification type:'),
                                                '$str_type'              => $Introduction->getType(),
                                                '$intro_id'              => $Introduction->getIntroId(),
-                                               '$lbl_madeby'            => $this->l10n->t('Suggested by:'),
+                                               '$lbl_madeby'            => $this->t('Suggested by:'),
                                                '$madeby'                => $Introduction->getMadeBy(),
                                                '$madeby_url'            => $Introduction->getMadeByUrl(),
                                                '$madeby_zrl'            => $Introduction->getMadeByZrl(),
@@ -120,13 +126,13 @@ class Introductions extends BaseNotifications
                                                '$dfrn_url'              => $owner['url'],
                                                '$url'                   => $Introduction->getUrl(),
                                                '$zrl'                   => $Introduction->getZrl(),
-                                               '$lbl_url'               => $this->l10n->t('Profile URL'),
+                                               '$lbl_url'               => $this->t('Profile URL'),
                                                '$addr'                  => $Introduction->getAddr(),
                                                '$action'                => 'follow',
-                                               '$approve'               => $this->l10n->t('Approve'),
+                                               '$approve'               => $this->t('Approve'),
                                                '$note'                  => $Introduction->getNote(),
-                                               '$ignore'                => $this->l10n->t('Ignore'),
-                                               '$discard'               => $this->l10n->t('Discard'),
+                                               '$ignore'                => $this->t('Ignore'),
+                                               '$discard'               => $this->t('Discard'),
                                                '$is_mobile'             => $this->mode->isMobile(),
                                        ]);
                                        break;
@@ -134,8 +140,8 @@ class Introductions extends BaseNotifications
                                // Normal connection requests
                                default:
                                        if ($Introduction->getNetwork() === Protocol::DFRN) {
-                                               $lbl_knowyou = $this->l10n->t('Claims to be known to you: ');
-                                               $knowyou     = ($Introduction->getKnowYou() ? $this->l10n->t('Yes') : $this->l10n->t('No'));
+                                               $lbl_knowyou = $this->t('Claims to be known to you: ');
+                                               $knowyou     = ($Introduction->getKnowYou() ? $this->t('Yes') : $this->t('No'));
                                        } else {
                                                $lbl_knowyou = '';
                                                $knowyou = '';
@@ -143,12 +149,12 @@ class Introductions extends BaseNotifications
 
                                        $convertedName = BBCode::convert($Introduction->getName());
 
-                                       $helptext  = $this->l10n->t('Shall your connection be bidirectional or not?');
-                                       $helptext2 = $this->l10n->t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $convertedName, $convertedName);
-                                       $helptext3 = $this->l10n->t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $convertedName);
+                                       $helptext  = $this->t('Shall your connection be bidirectional or not?');
+                                       $helptext2 = $this->t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $convertedName, $convertedName);
+                                       $helptext3 = $this->t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $convertedName);
                
-                                       $friend = ['duplex', $this->l10n->t('Friend'), '1', $helptext2, true];
-                                       $follower = ['duplex', $this->l10n->t('Subscriber'), '0', $helptext3, false];
+                                       $friend = ['duplex', $this->t('Friend'), '1', $helptext2, true];
+                                       $follower = ['duplex', $this->t('Subscriber'), '0', $helptext3, false];
 
                                        $action = 'follow_confirm';
 
@@ -161,7 +167,7 @@ class Introductions extends BaseNotifications
                                        $header .= ' (' . ContactSelector::networkToName($Introduction->getNetwork(), $Introduction->getUrl()) . ')';
 
                                        if ($Introduction->getNetwork() != Protocol::DIASPORA) {
-                                               $discard = $this->l10n->t('Discard');
+                                               $discard = $this->t('Discard');
                                        } else {
                                                $discard = '';
                                        }
@@ -169,7 +175,7 @@ class Introductions extends BaseNotifications
                                        $notificationContent[] = Renderer::replaceMacros($notificationTemplate, [
                                                '$type'                  => $Introduction->getLabel(),
                                                '$header'                => $header,
-                                               '$str_notification_type' => $this->l10n->t('Notification type:'),
+                                               '$str_notification_type' => $this->t('Notification type:'),
                                                '$str_type'              => $Introduction->getType(),
                                                '$dfrn_id'               => $Introduction->getDfrnId(),
                                                '$uid'                   => $Introduction->getUid(),
@@ -178,26 +184,26 @@ class Introductions extends BaseNotifications
                                                '$photo'                 => $Introduction->getPhoto(),
                                                '$fullname'              => $Introduction->getName(),
                                                '$location'              => $Introduction->getLocation(),
-                                               '$lbl_location'          => $this->l10n->t('Location:'),
+                                               '$lbl_location'          => $this->t('Location:'),
                                                '$about'                 => $Introduction->getAbout(),
-                                               '$lbl_about'             => $this->l10n->t('About:'),
+                                               '$lbl_about'             => $this->t('About:'),
                                                '$keywords'              => $Introduction->getKeywords(),
-                                               '$lbl_keywords'          => $this->l10n->t('Tags:'),
-                                               '$hidden'                => ['hidden', $this->l10n->t('Hide this contact from others'), $Introduction->isHidden(), ''],
+                                               '$lbl_keywords'          => $this->t('Tags:'),
+                                               '$hidden'                => ['hidden', $this->t('Hide this contact from others'), $Introduction->isHidden(), ''],
                                                '$lbl_connection_type'   => $helptext,
                                                '$friend'                => $friend,
                                                '$follower'              => $follower,
                                                '$url'                   => $Introduction->getUrl(),
                                                '$zrl'                   => $Introduction->getZrl(),
-                                               '$lbl_url'               => $this->l10n->t('Profile URL'),
+                                               '$lbl_url'               => $this->t('Profile URL'),
                                                '$addr'                  => $Introduction->getAddr(),
                                                '$lbl_knowyou'           => $lbl_knowyou,
-                                               '$lbl_network'           => $this->l10n->t('Network:'),
+                                               '$lbl_network'           => $this->t('Network:'),
                                                '$network'               => ContactSelector::networkToName($Introduction->getNetwork(), $Introduction->getUrl()),
                                                '$knowyou'               => $knowyou,
-                                               '$approve'               => $this->l10n->t('Approve'),
+                                               '$approve'               => $this->t('Approve'),
                                                '$note'                  => $Introduction->getNote(),
-                                               '$ignore'                => $this->l10n->t('Ignore'),
+                                               '$ignore'                => $this->t('Ignore'),
                                                '$discard'               => $discard,
                                                '$action'                => $action,
                                                '$is_mobile'             => $this->mode->isMobile(),
@@ -207,8 +213,8 @@ class Introductions extends BaseNotifications
                }
 
                if (count($notifications['notifications']) == 0) {
-                       notice($this->l10n->t('No introductions.'));
-                       $notificationNoContent = $this->l10n->t('No more %s notifications.', $notifications['ident']);
+                       DI::sysmsg()->addNotice($this->t('No introductions.'));
+                       $notificationNoContent = $this->t('No more %s notifications.', $notifications['ident']);
                }
 
                return $this->printContent($notificationHeader, $notificationContent, $notificationNoContent, $notificationShowLink);