X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fping.php;h=64c947e2c63aa760108e3a1ccfc0a25a8cea1887;hb=7789ea25079801ee1425368e9bf2f7ce80d16d88;hp=8e00ae31f177235a7e3be2be73747c881f9b3bab;hpb=2055ee872c3f14c69f4ffa2443c427fcd5d8db94;p=friendica.git diff --git a/mod/ping.php b/mod/ping.php index 8e00ae31f1..64c947e2c6 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -1,6 +1,6 @@ $items_unseen]; Hook::callAll('network_ping', $arr); @@ -185,7 +185,7 @@ function ping_init(App $a) "SELECT `intro`.`id`, `intro`.`datetime`, `contact`.`name`, `contact`.`url`, `contact`.`photo` FROM `intro` INNER JOIN `contact` ON `intro`.`contact-id` = `contact`.`id` - WHERE `intro`.`uid` = %d AND NOT `intro`.`blocked` AND NOT `intro`.`ignore` AND `intro`.`contact-id` != 0 AND `intro`.`fid` = 0", + WHERE `intro`.`uid` = %d AND NOT `intro`.`blocked` AND NOT `intro`.`ignore` AND `intro`.`contact-id` != 0 AND (`intro`.`fid` = 0 OR `intro`.`fid` IS NULL)", intval(local_user()) ); @@ -263,8 +263,8 @@ function ping_init(App $a) $data['birthdays'] = $birthdays; $data['birthdays-today'] = $birthdays_today; - if (DBA::isResult($notifs)) { - foreach ($notifs as $notif) { + if (DBA::isResult($notifications)) { + foreach ($notifications as $notif) { if ($notif['seen'] == 0) { $sysnotify_count ++; } @@ -277,14 +277,14 @@ function ping_init(App $a) $notif = [ 'id' => 0, 'href' => DI::baseUrl() . '/notifications/intros/' . $intro['id'], - 'name' => $intro['name'], + 'name' => BBCode::convert($intro['name']), 'url' => $intro['url'], 'photo' => $intro['photo'], 'date' => $intro['datetime'], 'seen' => false, 'message' => DI::l10n()->t('{0} wants to be your friend'), ]; - $notifs[] = $notif; + $notifications[] = $notif; } } @@ -301,7 +301,7 @@ function ping_init(App $a) 'seen' => false, 'message' => DI::l10n()->t('{0} requested registration'), ]; - $notifs[] = $notif; + $notifications[] = $notif; } } else { $notif = [ @@ -314,7 +314,7 @@ function ping_init(App $a) 'seen' => false, 'message' => DI::l10n()->t('{0} and %d others requested registration', count($regs) - 1), ]; - $notifs[] = $notif; + $notifications[] = $notif; } } @@ -337,28 +337,17 @@ function ping_init(App $a) } return ($adate < $bdate) ? 1 : -1; }; - usort($notifs, $sort_function); - - if (DBA::isResult($notifs)) { - foreach ($notifs as $notif) { - $contact = Contact::getByURL($notif['url'], false, ['micro', 'id', 'avatar']); - $notif['photo'] = Contact::getMicro($contact, $notif['photo']); - - $local_time = DateTimeFormat::local($notif['date']); - - $notifications[] = [ - 'id' => $notif['id'], - 'href' => $notif['href'], - 'name' => $notif['name'], - 'url' => $notif['url'], - 'photo' => $notif['photo'], - 'date' => Temporal::getRelativeDate($notif['date']), - 'message' => $notif['message'], - 'seen' => $notif['seen'], - 'timestamp' => strtotime($local_time) - ]; + usort($notifications, $sort_function); + + array_walk($notifications, function (&$notification) { + if (empty($notification['photo'])) { + $contact = Contact::getByURL($notification['url'], false, ['micro', 'id', 'avatar']); + $notification['photo'] = Contact::getMicro($contact, $notification['photo']); } - } + + $notification['timestamp'] = DateTimeFormat::local($notification['date']); + $notification['date'] = Temporal::getRelativeDate($notification['date']); + }); } $sysmsgs = []; @@ -423,14 +412,14 @@ function ping_get_notifications($uid) do { $r = q( - "SELECT `notify`.*, `item`.`visible`, `item`.`deleted` - FROM `notify` LEFT JOIN `item` ON `item`.`id` = `notify`.`iid` + "SELECT `notify`.*, `post`.`visible`, `post`.`deleted` + FROM `notify` LEFT JOIN `post` ON `post`.`uri-id` = `notify`.`uri-id` WHERE `notify`.`uid` = %d AND `notify`.`msg` != '' AND NOT (`notify`.`type` IN (%d, %d)) AND $seensql `notify`.`seen` ORDER BY `notify`.`date` $order LIMIT %d, 50", intval($uid), - intval(Type::INTRO), - intval(Type::MAIL), + intval(Notification\Type::INTRO), + intval(Notification\Type::MAIL), intval($offset) ); @@ -459,7 +448,7 @@ function ping_get_notifications($uid) $notification["message"] = $notification["msg_cache"]; } else { $notification["name"] = strip_tags(BBCode::convert($notification["name"])); - $notification["message"] = Friendica\Model\Notify::formatMessage($notification["name"], strip_tags(BBCode::convert($notification["msg"]))); + $notification["message"] = Notification::formatMessage($notification["name"], strip_tags(BBCode::convert($notification["msg"]))); q( "UPDATE `notify` SET `name_cache` = '%s', `msg_cache` = '%s' WHERE `id` = %d",