]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/NotificationsManager.php
Cut and paste is always fun
[friendica.git] / src / Core / NotificationsManager.php
index ea3d4c0cc759054c0da3ecf689b31920decd464e..42d514e618eb227aa0dadd59c10f3de1e9bd600a 100644 (file)
@@ -9,11 +9,11 @@ namespace Friendica\Core;
 use Friendica\Core\Pconfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
+use Friendica\Object\Contact;
 
 require_once 'include/html2plain.php';
 require_once 'include/datetime.php';
 require_once 'include/bbcode.php';
-require_once 'include/Contact.php';
 
 /**
  * @brief Methods for read and write notifications from/to database
@@ -322,7 +322,7 @@ class NotificationsManager
                                                        'link' => System::baseUrl(true).'/display/'.$it['pguid'],
                                                        'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
                                                        'url' => $it['author-link'],
-                                                       'text' => sprintf( t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
+                                                       'text' => sprintf(t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
                                                        'when' => $default_item_when,
                                                        'ago' => $default_item_ago,
                                                        'seen' => $it['seen']
@@ -381,9 +381,9 @@ class NotificationsManager
 
        /**
         * @brief Total number of network notifications
-        * @param int|string $seen
-        *      If 0 only include notifications into the query
-        *      which aren't marked as "seen"
+        * @param int|string $seen If 0 only include notifications into the query
+        *                             which aren't marked as "seen"
+        *
         * @return int Number of network notifications
         */
        private function networkTotal($seen = 0)
@@ -413,9 +413,8 @@ class NotificationsManager
        /**
         * @brief Get network notifications
         *
-        * @param int|string $seen
-        *      If 0 only include notifications into the query
-        *      which aren't marked as "seen"
+        * @param int|string $seen  If 0 only include notifications into the query
+        *                              which aren't marked as "seen"
         * @param int        $start Start the query at this point
         * @param int        $limit Maximum number of query results
         *
@@ -465,9 +464,9 @@ class NotificationsManager
 
        /**
         * @brief Total number of system notifications
-        * @param int|string $seen
-        *      If 0 only include notifications into the query
-        *      which aren't marked as "seen"
+        * @param int|string $seen If 0 only include notifications into the query
+        *                             which aren't marked as "seen"
+        *
         * @return int Number of system notifications
         */
        private function systemTotal($seen = 0)
@@ -493,9 +492,8 @@ class NotificationsManager
        /**
         * @brief Get system notifications
         *
-        * @param int|string $seen
-        *      If 0 only include notifications into the query
-        *      which aren't marked as "seen"
+        * @param int|string $seen  If 0 only include notifications into the query
+        *                              which aren't marked as "seen"
         * @param int        $start Start the query at this point
         * @param int        $limit Maximum number of query results
         *
@@ -541,7 +539,7 @@ class NotificationsManager
         *
         * @return string The additional sql query
         */
-       private function _personal_sql_extra()
+       private function personalSqlExtra()
        {
                $myurl = System::baseUrl(true) . '/profile/'. $this->a->user['nickname'];
                $myurl = substr($myurl, strpos($myurl, '://') + 3);
@@ -559,15 +557,15 @@ class NotificationsManager
 
        /**
         * @brief Total number of personal notifications
-        * @param int|string $seen
-        *      If 0 only include notifications into the query
-        *      which aren't marked as "seen"
+        * @param int|string $seen If 0 only include notifications into the query
+        *                             which aren't marked as "seen"
+        *
         * @return int Number of personal notifications
         */
        private function personalTotal($seen = 0)
        {
                $sql_seen = "";
-               $sql_extra = $this->_personal_sql_extra();
+               $sql_extra = $this->personalSqlExtra();
 
                if ($seen === 0) {
                        $sql_seen = " AND `item`.`unseen` = 1 ";
@@ -579,7 +577,7 @@ class NotificationsManager
                                WHERE `item`.`visible` = 1
                                $sql_extra
                                $sql_seen
-                               AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 " ,
+                               AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ",
                        intval(local_user())
                );
 
@@ -593,9 +591,8 @@ class NotificationsManager
        /**
         * @brief Get personal notifications
         *
-        * @param int|string $seen
-        *      If 0 only include notifications into the query
-        *      which aren't marked as "seen"
+        * @param int|string $seen  If 0 only include notifications into the query
+        *                              which aren't marked as "seen"
         * @param int        $start Start the query at this point
         * @param int        $limit Maximum number of query results
         *
@@ -608,7 +605,7 @@ class NotificationsManager
        {
                $ident = 'personal';
                $total = $this->personalTotal($seen);
-               $sql_extra = $this->_personal_sql_extra();
+               $sql_extra = $this->personalSqlExtra();
                $notifs = array();
                $sql_seen = "";
 
@@ -646,9 +643,9 @@ class NotificationsManager
 
        /**
         * @brief Total number of home notifications
-        * @param int|string $seen
-        *      If 0 only include notifications into the query
-        *      which aren't marked as "seen"
+        * @param int|string $seen If 0 only include notifications into the query
+        *                             which aren't marked as "seen"
+        *
         * @return int Number of home notifications
         */
        private function homeTotal($seen = 0)
@@ -677,9 +674,8 @@ class NotificationsManager
        /**
         * @brief Get home notifications
         *
-        * @param int|string $seen
-        *      If 0 only include notifications into the query
-        *      which aren't marked as "seen"
+        * @param int|string $seen  If 0 only include notifications into the query
+        *                              which aren't marked as "seen"
         * @param int        $start Start the query at this point
         * @param int        $limit Maximum number of query results
         *
@@ -728,9 +724,9 @@ class NotificationsManager
 
        /**
         * @brief Total number of introductions
-        * @param bool $all
-        *      If false only include introductions into the query
-        *      which aren't marked as ignored
+        * @param bool $all If false only include introductions into the query
+        *                      which aren't marked as ignored
+        *
         * @return int Number of introductions
         */
        private function introTotal($all = false)
@@ -757,18 +753,18 @@ class NotificationsManager
        /**
         * @brief Get introductions
         *
-        * @param bool $all
-        *      If false only include introductions into the query
-        *      which aren't marked as ignored
-        * @param int $start Start the query at this point
-        * @param int $limit Maximum number of query results
+        * @param bool $all   If false only include introductions into the query
+        *                        which aren't marked as ignored
+        * @param int  $start Start the query at this point
+        * @param int  $limit Maximum number of query results
         *
         * @return array with
         *      string 'ident' => Notification identifier
         *      int 'total' => Total number of available introductions
         *      array 'notifications' => Introductions
         */
-       public function introNotifs($all = false, $start = 0, $limit = 80) {
+       public function introNotifs($all = false, $start = 0, $limit = 80)
+       {
                $ident = 'introductions';
                $total = $this->introTotal($seen);
                $notifs = array();
@@ -778,7 +774,7 @@ class NotificationsManager
                        $sql_extra = " AND `ignore` = 0 ";
                }
 
-               /// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact
+               /// @todo Fetch contact details by "Contact::getDetailsByUrl" instead of queries to contact, fcontact and gcontact
                $r = q(
                        "SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*,
                                `fcontact`.`name` AS `fname`, `fcontact`.`url` AS `furl`,
@@ -907,7 +903,7 @@ class NotificationsManager
                // If the network and addr is still not available
                // get the missing data data from other sources
                if ($arr['gnetwork'] == "" || $arr['gaddr'] == "") {
-                       $ret = get_contact_details_by_url($arr['url']);
+                       $ret = Contact::getDetailsByURL($arr['url']);
 
                        if ($arr['gnetwork'] == "" && $ret['network'] != "") {
                                $arr['gnetwork'] = $ret['network'];