X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FNotificationsManager.php;h=8ac5d93c729d33779573990638b978af602dcf3e;hb=4913502922391d6c6852ed1d0325461dc500da21;hp=4c6b932deb7714516bfa69735e89936ccaf9dc0a;hpb=ec2c84a4e90324ba2fe30eed955904b943349082;p=friendica.git diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php index 4c6b932deb..8ac5d93c72 100644 --- a/src/Core/NotificationsManager.php +++ b/src/Core/NotificationsManager.php @@ -73,7 +73,7 @@ class NotificationsManager extends BaseObject $dbFilter = array_merge($filter, ['uid' => local_user()]); - $stmtNotifies = DBA::select('notify', [], $dbFilter, $order, $params); + $stmtNotifies = DBA::select('notify', [], $dbFilter, $params); if (DBA::isResult($stmtNotifies)) { return $this->_set_extra(DBA::toArray($stmtNotifies)); @@ -91,7 +91,7 @@ class NotificationsManager extends BaseObject */ public function getByID($id) { - $stmtNotify = DBA::selectFirst('notify', ['id' => $id, 'uid' => local_user()]); + $stmtNotify = DBA::selectFirst('notify', [], ['id' => $id, 'uid' => local_user()]); if (DBA::isResult($stmtNotify)) { return $this->_set_extra([$stmtNotify])[0]; } @@ -108,7 +108,13 @@ class NotificationsManager extends BaseObject */ public function setSeen($note, $seen = true) { - return DBA::update('notify', ['seen' => $seen], ['link' => $note['link'], 'parent' => $note['parent'], 'otype' => $note['otype'], 'uid' => local_user()]); + return DBA::update('notify', ['seen' => $seen], [ + '(`link` = ? OR (`parent` != 0 AND `parent` = ? AND `otype` = ?)) AND `uid` = ?', + $note['link'], + $note['parent'], + $note['otype'], + local_user() + ]); } /** @@ -388,7 +394,7 @@ class NotificationsManager extends BaseObject $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], 'limit' => [$start, $limit]]; + $params = ['order' => ['received' => true], 'limit' => [$start, $limit]]; $items = Item::selectForUser(local_user(), $fields, $condition, $params); @@ -429,6 +435,7 @@ class NotificationsManager extends BaseObject } $params = []; + $params['order'] = ['date' => 'DESC']; $params['limit'] = [$start, $limit]; $stmtNotifies = DBA::select('notify', @@ -478,7 +485,7 @@ class NotificationsManager extends BaseObject $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], 'limit' => [$start, $limit]]; + $params = ['order' => ['received' => true], 'limit' => [$start, $limit]]; $items = Item::selectForUser(local_user(), $fields, $condition, $params); @@ -520,7 +527,7 @@ class NotificationsManager extends BaseObject $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], 'limit' => [$start, $limit]]; + $params = ['order' => ['received' => true], 'limit' => [$start, $limit]]; $items = Item::selectForUser(local_user(), $fields, $condition, $params); if (DBA::isResult($items)) { @@ -556,7 +563,7 @@ class NotificationsManager extends BaseObject $sql_extra = ""; if (!$all) { - $sql_extra = " AND `ignore` = 0 "; + $sql_extra = " AND NOT `ignore` "; } /// @todo Fetch contact details by "Contact::getDetailsByUrl" instead of queries to contact, fcontact and gcontact @@ -571,11 +578,11 @@ class NotificationsManager extends BaseObject LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id` LEFT JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id` - WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 - LIMIT %d, %d", - intval($_SESSION['uid']), - intval($start), - intval($limit) + WHERE `intro`.`uid` = ? $sql_extra AND `intro`.`blocked` = 0 + LIMIT ?, ?", + $_SESSION['uid'], + $start, + $limit ); if (DBA::isResult($stmtNotifies)) { $notifs = $this->formatIntros(DBA::toArray($stmtNotifies));