X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fping.php;h=f68040a2cb7da3acd6c6d01e716090d043b890d4;hb=d1d2ee6b2f2a46f1c6495bfe9936146a2bfad403;hp=dd0817d0af0ed63162819e3fbf5b940c099aa8a5;hpb=35d06bd9ebee5bad76d81a1d434090f3e255e20f;p=friendica.git diff --git a/mod/ping.php b/mod/ping.php index dd0817d0af..f68040a2cb 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -6,19 +6,21 @@ 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\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; 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 +129,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); @@ -205,7 +201,7 @@ function ping_init(App $a) ); $mail_count = count($mails); - if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()) { + if (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE && is_site_admin()) { $regs = q( "SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created` FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid` @@ -225,8 +221,8 @@ function ping_init(App $a) WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0 ORDER BY `start` ASC ", intval(local_user()), - dbesc(Temporal::utc('now + 7 days')), - dbesc(Temporal::utcNow()) + dbesc(DateTimeFormat::utc('now + 7 days')), + dbesc(DateTimeFormat::utcNow()) ); if (DBM::is_result($ev)) { Cache::set($cachekey, $ev, CACHE_HOUR); @@ -237,7 +233,7 @@ function ping_init(App $a) $all_events = count($ev); if ($all_events) { - $str_now = Temporal::convert('now', $a->timezone, 'UTC', 'Y-m-d'); + $str_now = DateTimeFormat::timezoneNow($a->timezone, 'Y-m-d'); foreach ($ev as $x) { $bd = false; if ($x['type'] === 'birthday') { @@ -246,7 +242,7 @@ function ping_init(App $a) } else { $events ++; } - if (Temporal::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) { + if (DateTimeFormat::convert($x['start'], ((intval($x['adjust'])) ? $a->timezone : 'UTC'), 'UTC', 'Y-m-d') === $str_now) { $all_events_today ++; if ($bd) { $birthdays_today ++; @@ -283,6 +279,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 +295,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 +311,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'], @@ -362,7 +361,7 @@ function ping_init(App $a) $notif['photo'] = proxy_url($notif['photo'], false, PROXY_SIZE_MICRO); } - $local_time = Temporal::convert($notif['date'], date_default_timezone_get()); + $local_time = DateTimeFormat::local($notif['date']); $notifications[] = [ 'id' => $notif['id'], @@ -370,7 +369,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 +441,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 +468,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 +476,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,9 +490,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')) { @@ -571,8 +565,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; }