]> git.mxchange.org Git - friendica.git/blobdiff - mod/ping.php
Move forbidden_nicknames default to config file
[friendica.git] / mod / ping.php
index 146411206f601370312353ed07436fbcee96b48e..196758b0dfbc007ba6d14057629a0d534a445572 100644 (file)
@@ -15,6 +15,7 @@ use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Group;
+use Friendica\Model\Item;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Temporal;
 use Friendica\Util\XML;
@@ -127,20 +128,14 @@ function ping_init(App $a)
 
                $notifs = ping_get_notifications(local_user());
 
-               $items_unseen = q(
-                       "SELECT `item`.`id`, `item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
-                               `item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
-                               `pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`
-                               FROM `item` INNER JOIN `item` AS `pitem` ON  `pitem`.`id` = `item`.`parent`
-                               WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
-                                `item`.`deleted` = 0 AND `item`.`uid` = %d AND `pitem`.`parent` != 0
-                               AND `item`.`contact-id` != %d
-                               ORDER BY `item`.`created` DESC",
-                       intval(local_user()),
-                       intval(local_user())
-               );
+               $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()];
+               $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
+                       'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall'];
+               $params = ['order' => ['created' => true]];
+               $items = Item::selectForUser(local_user(), $fields, $condition, $params);
 
-               if (DBM::is_result($items_unseen)) {
+               if (DBM::is_result($items)) {
+                       $items_unseen = Item::inArray($items);
                        $arr = ['items' => $items_unseen];
                        Addon::callHooks('network_ping', $arr);
 
@@ -283,6 +278,7 @@ function ping_init(App $a)
                if (DBM::is_result($intros)) {
                        foreach ($intros as $intro) {
                                $notif = [
+                                       'id'      => 0,
                                        'href'    => System::baseUrl() . '/notifications/intros/' . $intro['id'],
                                        'name'    => $intro['name'],
                                        'url'     => $intro['url'],
@@ -298,6 +294,7 @@ function ping_init(App $a)
                if (DBM::is_result($mails)) {
                        foreach ($mails as $mail) {
                                $notif = [
+                                       'id'      => 0,
                                        'href'    => System::baseUrl() . '/message/' . $mail['id'],
                                        'name'    => $mail['from-name'],
                                        'url'     => $mail['from-url'],
@@ -313,6 +310,7 @@ function ping_init(App $a)
                if (DBM::is_result($regs)) {
                        foreach ($regs as $reg) {
                                $notif = [
+                                       'id'      => 0,
                                        'href'    => System::baseUrl() . '/admin/users/',
                                        'name'    => $reg['name'],
                                        'url'     => $reg['url'],
@@ -442,7 +440,7 @@ function ping_get_notifications($uid)
 
        do {
                $r = q(
-                       "SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted`
+                       "SELECT `notify`.*, `item`.`visible`, `item`.`deleted`
                        FROM `notify` LEFT JOIN `item` ON `item`.`id` = `notify`.`iid`
                        WHERE `notify`.`uid` = %d AND `notify`.`msg` != ''
                        AND NOT (`notify`.`type` IN (%d, %d))
@@ -469,10 +467,6 @@ function ping_get_notifications($uid)
                                $notification["visible"] = true;
                        }
 
-                       if (is_null($notification["spam"])) {
-                               $notification["spam"] = 0;
-                       }
-
                        if (is_null($notification["deleted"])) {
                                $notification["deleted"] = 0;
                        }
@@ -495,9 +489,8 @@ function ping_get_notifications($uid)
                        $notification["href"] = System::baseUrl() . "/notify/view/" . $notification["id"];
 
                        if ($notification["visible"]
-                               && !$notification["spam"]
                                && !$notification["deleted"]
-                               && !(x($result, $notification["parent"]) && is_array($result[$notification["parent"]]))
+                               && !(x($result, $notification["parent"]) && !empty($result[$notification["parent"]]))
                        ) {
                                // Should we condense the notifications or show them all?
                                if (PConfig::get(local_user(), 'system', 'detailed_notif')) {