X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fping.php;h=0256500dfe12fd0b92eb683a29c20741bedfc869;hb=a54fea313ff93b43ae0c691df2a8cf9c8c363006;hp=3249624fbeb3c87388f3b64a02df584cbcf83266;hpb=876acd68a0c6f7384c5aa0c78553dd70cd32bd99;p=friendica.git diff --git a/mod/ping.php b/mod/ping.php index 3249624fbe..0256500dfe 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Content\Feature; use Friendica\Content\ForumManager; +use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\L10n; @@ -14,11 +15,11 @@ 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; -require_once 'include/datetime.php'; -require_once 'include/bbcode.php'; require_once 'mod/proxy.php'; require_once 'include/enotify.php'; @@ -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']; + $params = ['order' => ['created' => true]]; + $items = Item::select(local_user(), $fields, $condition, $params); - if (DBM::is_result($items_unseen)) { + if (DBM::is_result($items)) { + $items_unseen = dba::inArray($items); $arr = ['items' => $items_unseen]; Addon::callHooks('network_ping', $arr); @@ -370,7 +365,7 @@ function ping_init(App $a) 'name' => $notif['name'], 'url' => $notif['url'], 'photo' => $notif['photo'], - 'date' => relative_date($notif['date']), + 'date' => Temporal::getRelativeDate($notif['date']), 'message' => $notif['message'], 'seen' => $notif['seen'], 'timestamp' => strtotime($local_time) @@ -442,7 +437,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 +464,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; } @@ -481,8 +472,8 @@ function ping_get_notifications($uid) $notification["name"] = $notification["name_cache"]; $notification["message"] = $notification["msg_cache"]; } else { - $notification["name"] = strip_tags(bbcode($notification["name"])); - $notification["message"] = format_notification_message($notification["name"], strip_tags(bbcode($notification["msg"]))); + $notification["name"] = strip_tags(BBCode::convert($notification["name"])); + $notification["message"] = format_notification_message($notification["name"], strip_tags(BBCode::convert($notification["msg"]))); q( "UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d", @@ -495,7 +486,6 @@ 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"]])) ) { @@ -571,8 +561,8 @@ function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_inf $forums = []; if (count($forums_unseen)) { foreach ($forums_unseen as $key => $item) { - $forums[$count . ':forum'] = $item['count']; - $forums[$count . ':@attributes'] = ['id' => $item['id']]; + $forums[$key . ':forum'] = $item['count']; + $forums[$key . ':@attributes'] = ['id' => $item['id']]; } $data['forums'] = $forums; }