]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Notify.php
Merge pull request #8149 from annando/fix-warning
[friendica.git] / src / Model / Notify.php
index 2ee1a03a48f4f9587e54386d7666bb8693fdd888..a27635a07e722bd161ed0098fb16d58bbd2afd8c 100644 (file)
@@ -4,14 +4,14 @@ namespace Friendica\Model;
 
 use Exception;
 use Friendica\App;
-use Friendica\BaseObject;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
-use Friendica\Core\Config\PConfiguration;
-use Friendica\Core\L10n\L10n;
+use Friendica\Core\PConfig\IPConfig;
+use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\Database;
+use Friendica\DI;
 use Friendica\Protocol\Activity;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Proxy as ProxyUtils;
@@ -22,10 +22,10 @@ use Psr\Log\LoggerInterface;
 use Friendica\Network\HTTPException;
 
 /**
- * @brief Methods for read and write notifications from/to database
+ * Methods for read and write notifications from/to database
  *  or for formatting notifications
  */
-final class Notify extends BaseObject
+final class Notify
 {
        /** @var int The default limit of notifies per page */
        const DEFAULT_PAGE_LIMIT = 80;
@@ -71,13 +71,13 @@ final class Notify extends BaseObject
        private $args;
        /** @var App\BaseURL */
        private $baseUrl;
-       /** @var PConfiguration */
+       /** @var IPConfig */
        private $pConfig;
        /** @var LoggerInterface */
        private $logger;
 
        public function __construct(Database $dba, L10n $l10n, App\Arguments $args, App\BaseURL $baseUrl,
-                                   PConfiguration $pConfig, LoggerInterface $logger)
+                                   IPConfig $pConfig, LoggerInterface $logger)
        {
                $this->dba     = $dba;
                $this->l10n    = $l10n;
@@ -164,7 +164,7 @@ final class Notify extends BaseObject
        }
 
        /**
-        * @brief set seen state of $note of local_user()
+        * set seen state of $note of local_user()
         *
         * @param array $note note array
         * @param bool  $seen optional true or false, default true
@@ -197,7 +197,7 @@ final class Notify extends BaseObject
        }
 
        /**
-        * @brief List of pages for the Notifications TabBar
+        * List of pages for the Notifications TabBar
         *
         * @return array with with notifications TabBar data
         * @throws Exception
@@ -238,7 +238,7 @@ final class Notify extends BaseObject
         *                       bool 'seen' => Is the notification marked as "seen"
         * @throws Exception
         */
-       private function formatNotifies(array $notifies, string $ident = "")
+       private function formatList(array $notifies, string $ident = "")
        {
                $formattedNotifies = [];
 
@@ -422,7 +422,7 @@ final class Notify extends BaseObject
         *
         * @throws Exception
         */
-       public function getNetworkNotifies(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
+       public function getNetworkList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
        {
                $ident    = self::NETWORK;
                $notifies = [];
@@ -440,7 +440,7 @@ final class Notify extends BaseObject
                $items = Item::selectForUser(local_user(), $fields, $condition, $params);
 
                if ($this->dba->isResult($items)) {
-                       $notifies = $this->formatNotifies(Item::inArray($items), $ident);
+                       $notifies = $this->formatList(Item::inArray($items), $ident);
                }
 
                $arr = [
@@ -465,7 +465,7 @@ final class Notify extends BaseObject
         *
         * @throws Exception
         */
-       public function getSystemNotifies(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
+       public function getSystemList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
        {
                $ident    = self::SYSTEM;
                $notifies = [];
@@ -485,7 +485,7 @@ final class Notify extends BaseObject
                        $params);
 
                if ($this->dba->isResult($stmtNotifies)) {
-                       $notifies = $this->formatNotifies($this->dba->toArray($stmtNotifies), $ident);
+                       $notifies = $this->formatList($this->dba->toArray($stmtNotifies), $ident);
                }
 
                $arr = [
@@ -510,12 +510,12 @@ final class Notify extends BaseObject
         *
         * @throws Exception
         */
-       public function getPersonalNotifies(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
+       public function getPersonalList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
        {
                $ident    = self::PERSONAL;
                $notifies = [];
 
-               $myurl     = str_replace('http://', '', self::getApp()->contact['nurl']);
+               $myurl     = str_replace('http://', '', DI::app()->contact['nurl']);
                $diasp_url = str_replace('/profile/', '/u/', $myurl);
 
                $condition = ["NOT `wall` AND `uid` = ? AND (`item`.`author-id` = ? OR `item`.`tag` REGEXP ? OR `item`.`tag` REGEXP ?)",
@@ -532,7 +532,7 @@ final class Notify extends BaseObject
                $items = Item::selectForUser(local_user(), $fields, $condition, $params);
 
                if ($this->dba->isResult($items)) {
-                       $notifies = $this->formatNotifies(Item::inArray($items), $ident);
+                       $notifies = $this->formatList(Item::inArray($items), $ident);
                }
 
                $arr = [
@@ -544,7 +544,7 @@ final class Notify extends BaseObject
        }
 
        /**
-        * @brief Get home notifications
+        * Get home notifications
         *
         * @param bool $seen    False => only include notifications into the query
         *                            which aren't marked as "seen"
@@ -557,12 +557,12 @@ final class Notify extends BaseObject
         *
         * @throws Exception
         */
-       public function getHomeNotifies(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
+       public function getHomeList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
        {
                $ident    = self::HOME;
                $notifies = [];
 
-               $condition = ['wall' => false, 'uid' => local_user()];
+               $condition = ['wall' => true, 'uid' => local_user()];
 
                if (!$seen) {
                        $condition['unseen'] = true;
@@ -575,7 +575,7 @@ final class Notify extends BaseObject
                $items = Item::selectForUser(local_user(), $fields, $condition, $params);
 
                if ($this->dba->isResult($items)) {
-                       $notifies = $this->formatNotifies(Item::inArray($items), $ident);
+                       $notifies = $this->formatList(Item::inArray($items), $ident);
                }
 
                $arr = [
@@ -587,7 +587,7 @@ final class Notify extends BaseObject
        }
 
        /**
-        * @brief Get introductions
+        * Get introductions
         *
         * @param bool $all     If false only include introductions into the query
         *                      which aren't marked as ignored
@@ -602,7 +602,7 @@ final class Notify extends BaseObject
         * @throws ImagickException
         * @throws Exception
         */
-       public function getIntroNotifies(bool $all = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT, int $id = 0)
+       public function getIntroList(bool $all = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT, int $id = 0)
        {
                /// @todo sanitize wording according to SELF::INTRO
                $ident     = 'introductions';
@@ -638,7 +638,7 @@ final class Notify extends BaseObject
                        $limit
                );
                if ($this->dba->isResult($stmtNotifies)) {
-                       $notifies = $this->formatIntros($this->dba->toArray($stmtNotifies));
+                       $notifies = $this->formatIntroList($this->dba->toArray($stmtNotifies));
                }
 
                $arr = [
@@ -650,7 +650,7 @@ final class Notify extends BaseObject
        }
 
        /**
-        * @brief Format the notification query in an usable array
+        * Format the notification query in an usable array
         *
         * @param array $intros The array from the db query
         *
@@ -658,7 +658,7 @@ final class Notify extends BaseObject
         * @throws HTTPException\InternalServerErrorException
         * @throws ImagickException
         */
-       private function formatIntros(array $intros)
+       private function formatIntroList(array $intros)
        {
                $knowyou = '';
 
@@ -669,7 +669,7 @@ final class Notify extends BaseObject
                        // We have to distinguish between these two because they use different data.
                        // Contact suggestions
                        if ($intro['fid']) {
-                               $return_addr = bin2hex(self::getApp()->user['nickname'] . '@' .
+                               $return_addr = bin2hex(DI::app()->user['nickname'] . '@' .
                                                       $this->baseUrl->getHostName() .
                                                       (($this->baseUrl->getURLPath()) ? '/' . $this->baseUrl->getURLPath() : ''));
 
@@ -738,8 +738,8 @@ final class Notify extends BaseObject
        }
 
        /**
-        * @brief Check for missing contact data and try to fetch the data from
-        *     from other sources
+        * Check for missing contact data and try to fetch the data from
+        * from other sources
         *
         * @param array $intro The input array with the intro data
         *