Notifies => Notifications

This commit is contained in:
Philipp Holzer 2020-01-24 18:34:29 +01:00
parent 0f932ae723
commit 16b1d3fc08
No known key found for this signature in database
GPG Key ID: D8365C3D36B77D90
2 changed files with 27 additions and 27 deletions

View File

@ -27,7 +27,7 @@ use Friendica\Network\HTTPException;
*/ */
final class Notification final class Notification
{ {
/** @var int The default limit of notifies per page */ /** @var int The default limit of notifications per page */
const DEFAULT_PAGE_LIMIT = 80; const DEFAULT_PAGE_LIMIT = 80;
const NETWORK = 'network'; const NETWORK = 'network';
@ -110,10 +110,10 @@ final class Notification
$dbFilter = array_merge($filter, ['uid' => local_user()]); $dbFilter = array_merge($filter, ['uid' => local_user()]);
$stmtNotifies = $this->dba->select('notify', [], $dbFilter, $params); $stmtNotifications = $this->dba->select('notify', [], $dbFilter, $params);
if ($this->dba->isResult($stmtNotifies)) { if ($this->dba->isResult($stmtNotifications)) {
return $this->setExtra($this->dba->toArray($stmtNotifies)); return $this->setExtra($this->dba->toArray($stmtNotifications));
} }
return false; return false;
@ -188,7 +188,7 @@ final class Notification
*/ */
private function formatList(array $notifications, string $ident = "") private function formatList(array $notifications, string $ident = "")
{ {
$formattedNotifies = []; $formattedNotifications = [];
foreach ($notifications as $notification) { foreach ($notifications as $notification) {
// Because we use different db tables for the notification query // Because we use different db tables for the notification query
@ -350,10 +350,10 @@ final class Notification
]; ];
} }
$formattedNotifies[] = $formattedNotify; $formattedNotifications[] = $formattedNotify;
} }
return $formattedNotifies; return $formattedNotifications;
} }
/** /**
@ -373,7 +373,7 @@ final class Notification
public function getNetworkList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT) public function getNetworkList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
{ {
$ident = self::NETWORK; $ident = self::NETWORK;
$notifies = []; $notifications = [];
$condition = ['wall' => false, 'uid' => local_user()]; $condition = ['wall' => false, 'uid' => local_user()];
@ -388,11 +388,11 @@ final class Notification
$items = Item::selectForUser(local_user(), $fields, $condition, $params); $items = Item::selectForUser(local_user(), $fields, $condition, $params);
if ($this->dba->isResult($items)) { if ($this->dba->isResult($items)) {
$notifies = $this->formatList(Item::inArray($items), $ident); $notifications = $this->formatList(Item::inArray($items), $ident);
} }
$arr = [ $arr = [
'notifications' => $notifies, 'notifications' => $notifications,
'ident' => $ident, 'ident' => $ident,
]; ];
@ -416,7 +416,7 @@ final class Notification
public function getSystemList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT) public function getSystemList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
{ {
$ident = self::SYSTEM; $ident = self::SYSTEM;
$notifies = []; $notifications = [];
$filter = ['uid' => local_user()]; $filter = ['uid' => local_user()];
if (!$seen) { if (!$seen) {
@ -427,17 +427,17 @@ final class Notification
$params['order'] = ['date' => 'DESC']; $params['order'] = ['date' => 'DESC'];
$params['limit'] = [$start, $limit]; $params['limit'] = [$start, $limit];
$stmtNotifies = $this->dba->select('notify', $stmtNotifications = $this->dba->select('notify',
['id', 'url', 'photo', 'msg', 'date', 'seen', 'verb'], ['id', 'url', 'photo', 'msg', 'date', 'seen', 'verb'],
$filter, $filter,
$params); $params);
if ($this->dba->isResult($stmtNotifies)) { if ($this->dba->isResult($stmtNotifications)) {
$notifies = $this->formatList($this->dba->toArray($stmtNotifies), $ident); $notifications = $this->formatList($this->dba->toArray($stmtNotifications), $ident);
} }
$arr = [ $arr = [
'notifications' => $notifies, 'notifications' => $notifications,
'ident' => $ident, 'ident' => $ident,
]; ];
@ -461,7 +461,7 @@ final class Notification
public function getPersonalList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT) public function getPersonalList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
{ {
$ident = self::PERSONAL; $ident = self::PERSONAL;
$notifies = []; $notifications = [];
$myurl = str_replace('http://', '', DI::app()->contact['nurl']); $myurl = str_replace('http://', '', DI::app()->contact['nurl']);
$diasp_url = str_replace('/profile/', '/u/', $myurl); $diasp_url = str_replace('/profile/', '/u/', $myurl);
@ -480,11 +480,11 @@ final class Notification
$items = Item::selectForUser(local_user(), $fields, $condition, $params); $items = Item::selectForUser(local_user(), $fields, $condition, $params);
if ($this->dba->isResult($items)) { if ($this->dba->isResult($items)) {
$notifies = $this->formatList(Item::inArray($items), $ident); $notifications = $this->formatList(Item::inArray($items), $ident);
} }
$arr = [ $arr = [
'notifications' => $notifies, 'notifications' => $notifications,
'ident' => $ident, 'ident' => $ident,
]; ];
@ -508,7 +508,7 @@ final class Notification
public function getHomeList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT) public function getHomeList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
{ {
$ident = self::HOME; $ident = self::HOME;
$notifies = []; $notifications = [];
$condition = ['wall' => true, 'uid' => local_user()]; $condition = ['wall' => true, 'uid' => local_user()];
@ -523,11 +523,11 @@ final class Notification
$items = Item::selectForUser(local_user(), $fields, $condition, $params); $items = Item::selectForUser(local_user(), $fields, $condition, $params);
if ($this->dba->isResult($items)) { if ($this->dba->isResult($items)) {
$notifies = $this->formatList(Item::inArray($items), $ident); $notifications = $this->formatList(Item::inArray($items), $ident);
} }
$arr = [ $arr = [
'notifications' => $notifies, 'notifications' => $notifications,
'ident' => $ident, 'ident' => $ident,
]; ];
@ -554,7 +554,7 @@ final class Notification
{ {
/// @todo sanitize wording according to SELF::INTRO /// @todo sanitize wording according to SELF::INTRO
$ident = 'introductions'; $ident = 'introductions';
$notifies = []; $notifications = [];
$sql_extra = ""; $sql_extra = "";
if (empty($id)) { if (empty($id)) {
@ -568,7 +568,7 @@ final class Notification
} }
/// @todo Fetch contact details by "Contact::getDetailsByUrl" instead of queries to contact, fcontact and gcontact /// @todo Fetch contact details by "Contact::getDetailsByUrl" instead of queries to contact, fcontact and gcontact
$stmtNotifies = $this->dba->p( $stmtNotifications = $this->dba->p(
"SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*, "SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*,
`fcontact`.`name` AS `fname`, `fcontact`.`url` AS `furl`, `fcontact`.`addr` AS `faddr`, `fcontact`.`name` AS `fname`, `fcontact`.`url` AS `furl`, `fcontact`.`addr` AS `faddr`,
`fcontact`.`photo` AS `fphoto`, `fcontact`.`request` AS `frequest`, `fcontact`.`photo` AS `fphoto`, `fcontact`.`request` AS `frequest`,
@ -585,13 +585,13 @@ final class Notification
$start, $start,
$limit $limit
); );
if ($this->dba->isResult($stmtNotifies)) { if ($this->dba->isResult($stmtNotifications)) {
$notifies = $this->formatIntroList($this->dba->toArray($stmtNotifies)); $notifications = $this->formatIntroList($this->dba->toArray($stmtNotifications));
} }
$arr = [ $arr = [
'ident' => $ident, 'ident' => $ident,
'notifications' => $notifies, 'notifications' => $notifications,
]; ];
return $arr; return $arr;

View File

@ -27,7 +27,7 @@ abstract class BaseNotifications extends BaseModule
Notification::INTRO => 'intros', Notification::INTRO => 'intros',
]; ];
/** @var array Array of the allowed notifies and their printable name */ /** @var array Array of the allowed notifications and their printable name */
const PRINT_TYPES = [ const PRINT_TYPES = [
Notification::NETWORK => 'Network', Notification::NETWORK => 'Network',
Notification::SYSTEM => 'System', Notification::SYSTEM => 'System',