X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FNotificationsManager.php;h=bce65a092d94c08f24e186b7bb2a990ab952fbae;hb=4b16de6d8010323cc63cde302b4ee0becb429d3b;hp=610acb93d58a09108fca6e9f65489f895da2ddc0;hpb=125d2f24dd8a9946a4b57bbda000bf15f6b0a60c;p=friendica.git diff --git a/include/NotificationsManager.php b/include/NotificationsManager.php index 610acb93d5..bce65a092d 100644 --- a/include/NotificationsManager.php +++ b/include/NotificationsManager.php @@ -24,7 +24,7 @@ class NotificationsManager { * * @param array $notes array of note arrays from db * @return array Copy of input array with added properties - * + * * Set some extra properties to note array from db: * - timestamp as int in default TZ * - date_rel : relative date string @@ -143,8 +143,7 @@ class NotificationsManager { /** * @brief List of pages for the Notifications TabBar - * - * @param app $a The + * * @return array with with notifications TabBar data */ public function getTabs() { @@ -191,16 +190,17 @@ class NotificationsManager { /** * @brief Format the notification query in an usable array - * + * * @param array $notifs The array from the db query * @param string $ident The notifications identifier (e.g. network) * @return array * string 'label' => The type of the notification * string 'link' => URL to the source * string 'image' => The avatar image - * * string 'url' => The profile url of the contact + * string 'url' => The profile url of the contact * string 'text' => The notification text - * string 'when' => Relative date of the notification + * string 'when' => The date of the notification + * string 'ago' => T relative date of the notification * bool 'seen' => Is the notification marked as "seen" */ private function formatNotifs($notifs, $ident = "") { @@ -226,7 +226,8 @@ class NotificationsManager { $default_item_image = proxy_url($it['photo'], false, PROXY_SIZE_MICRO); $default_item_url = $it['url']; $default_item_text = strip_tags(bbcode($it['msg'])); - $default_item_when = relative_date($it['date']); + $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['date'], 'r'); + $default_item_ago = relative_date($it['date']); break; case 'home': @@ -235,7 +236,8 @@ class NotificationsManager { $default_item_image = proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO); $default_item_url = $it['author-link']; $default_item_text = sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname']); - $default_item_when = relative_date($it['created']); + $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r'); + $default_item_ago = relative_date($it['created']); break; default: @@ -246,7 +248,8 @@ class NotificationsManager { $default_item_text = (($it['id'] == $it['parent']) ? sprintf(t("%s created a new post"), $it['author-name']) : sprintf(t("%s commented on %s's post"), $it['author-name'], $it['pname'])); - $default_item_when = relative_date($it['created']); + $default_item_when = datetime_convert('UTC', date_default_timezone_get(), $it['created'], 'r'); + $default_item_ago = relative_date($it['created']); } @@ -259,7 +262,8 @@ class NotificationsManager { 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'url' => $it['author-link'], 'text' => sprintf(t("%s liked %s's post"), $it['author-name'], $it['pname']), - 'when' => relative_date($it['created']), + 'when' => $default_item_when, + 'ago' => $default_item_ago, 'seen' => $it['seen'] ); break; @@ -271,7 +275,8 @@ class NotificationsManager { 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'url' => $it['author-link'], 'text' => sprintf(t("%s disliked %s's post"), $it['author-name'], $it['pname']), - 'when' => relative_date($it['created']), + 'when' => $default_item_when, + 'ago' => $default_item_ago, 'seen' => $it['seen'] ); break; @@ -283,7 +288,8 @@ class NotificationsManager { 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'url' => $it['author-link'], 'text' => sprintf(t("%s is attending %s's event"), $it['author-name'], $it['pname']), - 'when' => relative_date($it['created']), + 'when' => $default_item_when, + 'ago' => $default_item_ago, 'seen' => $it['seen'] ); break; @@ -295,7 +301,8 @@ class NotificationsManager { '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']), - 'when' => relative_date($it['created']), + 'when' => $default_item_when, + 'ago' => $default_item_ago, 'seen' => $it['seen'] ); break; @@ -307,7 +314,8 @@ class NotificationsManager { 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'url' => $it['author-link'], 'text' => sprintf(t("%s may attend %s's event"), $it['author-name'], $it['pname']), - 'when' => relative_date($it['created']), + 'when' => $default_item_when, + 'ago' => $default_item_ago, 'seen' => $it['seen'] ); break; @@ -323,7 +331,8 @@ class NotificationsManager { 'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), 'url' => $it['author-link'], 'text' => sprintf(t("%s is now friends with %s"), $it['author-name'], $it['fname']), - 'when' => relative_date($it['created']), + 'when' => $default_item_when, + 'ago' => $default_item_ago, 'seen' => $it['seen'] ); break; @@ -336,6 +345,7 @@ class NotificationsManager { 'url' => $default_item_url, 'text' => $default_item_text, 'when' => $default_item_when, + 'ago' => $default_item_ago, 'seen' => $it['seen'] ); } @@ -349,7 +359,7 @@ class NotificationsManager { } /** - * @brief Total number of network notifications + * @brief Total number of network notifications * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" @@ -377,13 +387,13 @@ 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 $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 network notifications @@ -425,7 +435,7 @@ class NotificationsManager { } /** - * @brief Total number of system notifications + * @brief Total number of system notifications * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" @@ -449,13 +459,13 @@ 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 $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 system notifications @@ -491,7 +501,7 @@ class NotificationsManager { /** * @brief Addional SQL query string for the personal notifications - * + * * @return string The additional sql query */ private function _personal_sql_extra() { @@ -509,7 +519,7 @@ class NotificationsManager { } /** - * @brief Total number of personal notifications + * @brief Total number of personal notifications * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" @@ -539,13 +549,13 @@ 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 $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 personal notifications @@ -562,13 +572,13 @@ class NotificationsManager { $sql_seen = " AND `item`.`unseen` = 1 "; $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`, - `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`, - `pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid` + `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`, + `pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid` FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id`=`item`.`parent` 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 ORDER BY `item`.`created` DESC LIMIT %d, %d " , intval(local_user()), intval($start), @@ -577,7 +587,7 @@ class NotificationsManager { if (dbm::is_result($r)) $notifs = $this->formatNotifs($r, $ident); - + $arr = array ( 'notifications' => $notifs, 'ident' => $ident, @@ -588,7 +598,7 @@ class NotificationsManager { } /** - * @brief Total number of home notifications + * @brief Total number of home notifications * @param int|string $seen * If 0 only include notifications into the query * which aren't marked as "seen" @@ -615,13 +625,13 @@ 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 $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 home notifications @@ -662,7 +672,7 @@ class NotificationsManager { } /** - * @brief Total number of introductions + * @brief Total number of introductions * @param bool $all * If false only include introductions into the query * which aren't marked as ignored @@ -687,13 +697,13 @@ 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 - * + * * @return array with * string 'ident' => Notification identifier * int 'total' => Total number of available introductions @@ -738,7 +748,7 @@ class NotificationsManager { /** * @brief Format the notification query in an usable array - * + * * @param array $intros The array from the db query * @return array with the introductions */