- /**
- * @brief Additional SQL query string for the personal notifications
- *
- * @return string The additional SQL query
- */
- private function personalSqlExtra()
- {
- $myurl = System::baseUrl(true) . '/profile/' . self::getApp()->user['nickname'];
- $myurl = substr($myurl, strpos($myurl, '://') + 3);
- $myurl = str_replace(['www.', '.'], ['', '\\.'], $myurl);
- $diasp_url = str_replace('/profile/', '/u/', $myurl);
- $sql_extra = sprintf(
- " AND ( `item`.`author-link` regexp '%s' OR `item`.`tag` regexp '%s' OR `item`.`tag` regexp '%s' ) ",
- dbesc($myurl . '$'),
- dbesc($myurl . '\\]'),
- dbesc($diasp_url . '\\]')
- );
-
- return $sql_extra;
- }
-
- /**
- * @brief Total number of personal notifications
- * @param int|string $seen If 0 only include notifications into the query
- * which aren't marked as "seen"
- *
- * @return int Number of personal notifications
- */
- private function personalTotal($seen = 0)
- {
- $sql_seen = "";
- $sql_extra = $this->personalSqlExtra();
-
- if ($seen === 0) {
- $sql_seen = " AND `item`.`unseen` = 1 ";
- }
-
- $r = q(
- "SELECT COUNT(*) AS `total`
- 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 ",
- intval(local_user())
- );
- if (DBM::is_result($r)) {
- return $r[0]['total'];
- }
-
- return 0;
- }
-