Merge pull request #8155 from nupplaphil/task/move_notifications

Move mod/notifications to Module\Notification
This commit is contained in:
Hypolite Petovan 2020-01-24 12:10:49 -05:00 committed by GitHub
commit 188720c3cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 794 additions and 686 deletions

View File

@ -5905,7 +5905,7 @@ function api_friendica_notification($type)
if ($a->argc!==3) {
throw new BadRequestException("Invalid argument count");
}
$notes = DI::notify()->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50);
$notes = DI::notification()->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50);
if ($type == "xml") {
$xmlnotes = [];
@ -5947,7 +5947,7 @@ function api_friendica_notification_seen($type)
$id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
$nm = DI::notify();
$nm = DI::notification();
$note = $nm->getByID($id);
if (is_null($note)) {
throw new BadRequestException("Invalid argument");

View File

@ -516,7 +516,7 @@ function notification($params)
$notify_id = DBA::lastInsertId();
$itemlink = DI::baseUrl().'/notify/view/'.$notify_id;
$itemlink = DI::baseUrl().'/notification/view/'.$notify_id;
$msg = Renderer::replaceMacros($epreamble, ['$itemlink' => $itemlink]);
$msg_cache = format_notification_message($datarray['name_cache'], strip_tags(BBCode::convert($msg)));

View File

@ -1,375 +0,0 @@
<?php
/**
* @file mod/notifications.php
* The notifications module
*/
use Friendica\App;
use Friendica\Content\ContactSelector;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Notify;
use Friendica\Module\Security\Login;
/** @var array Array of URL parameters */
const URL_TYPES = [
Notify::NETWORK => 'network',
Notify::SYSTEM => 'system',
Notify::HOME => 'home',
Notify::PERSONAL => 'personal',
Notify::INTRO => 'intros',
];
/** @var array Array of the allowed notifies and their printable name */
const PRINT_TYPES = [
Notify::NETWORK => 'Network',
Notify::SYSTEM => 'System',
Notify::HOME => 'Home',
Notify::PERSONAL => 'Personal',
Notify::INTRO => 'Introductions',
];
/** @var array The array of access keys for notify pages */
const ACCESS_KEYS = [
Notify::NETWORK => 'w',
Notify::SYSTEM => 'y',
Notify::HOME => 'h',
Notify::PERSONAL => 'r',
Notify::INTRO => 'i',
];
function notifications_post(App $a)
{
if (!local_user()) {
DI::baseUrl()->redirect();
}
$request_id = (($a->argc > 1) ? $a->argv[1] : 0);
if ($request_id === 'all') {
return;
}
if ($request_id) {
$intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]);
switch ($_POST['submit']) {
case DI::l10n()->t('Discard'):
$intro->discard();
break;
case DI::l10n()->t('Ignore'):
$intro->ignore();
break;
}
DI::baseUrl()->redirect('notifications/intros');
}
}
function notifications_content(App $a)
{
if (!local_user()) {
notice(DI::l10n()->t('Permission denied.') . EOL);
return Login::form();
}
$page = ($_REQUEST['page'] ?? 0) ?: 1;
$show = ($_REQUEST['show'] ?? '') === 'all';
Nav::setSelected('notifications');
$json = (($a->argc > 1 && $a->argv[$a->argc - 1] === 'json') ? true : false);
$nm = DI::notify();
$o = '';
// Get the nav tabs for the notification pages
$tabs = getTabs(DI::args()->get(1, ''));
$notif_content = [];
$notif_nocontent = '';
// Notification results per page
$perpage = 20;
$startrec = ($page * $perpage) - $perpage;
$notif_header = DI::l10n()->t('Notifications');
$all = false;
// Get introductions
if ((($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
Nav::setSelected('introductions');
$id = 0;
if (!empty($a->argv[2]) && intval($a->argv[2]) != 0) {
$id = (int)$a->argv[2];
}
$all = (($a->argc > 2) && ($a->argv[2] == 'all'));
$notifs = $nm->getIntroList($all, $startrec, $perpage, $id);
// Get the network notifications
} elseif (($a->argc > 1) && ($a->argv[1] == 'network')) {
$notif_header = DI::l10n()->t('Network Notifications');
$notifs = $nm->getNetworkList($show, $startrec, $perpage);
// Get the system notifications
} elseif (($a->argc > 1) && ($a->argv[1] == 'system')) {
$notif_header = DI::l10n()->t('System Notifications');
$notifs = $nm->getSystemList($show, $startrec, $perpage);
// Get the personal notifications
} elseif (($a->argc > 1) && ($a->argv[1] == 'personal')) {
$notif_header = DI::l10n()->t('Personal Notifications');
$notifs = $nm->getPersonalList($show, $startrec, $perpage);
// Get the home notifications
} elseif (($a->argc > 1) && ($a->argv[1] == 'home')) {
$notif_header = DI::l10n()->t('Home Notifications');
$notifs = $nm->getHomeList($show, $startrec, $perpage);
// fallback - redirect to main page
} else {
DI::baseUrl()->redirect('notifications');
}
// Set the pager
$pager = new Pager(DI::args()->getQueryString(), $perpage);
// Add additional informations (needed for json output)
$notifs['items_page'] = $pager->getItemsPerPage();
$notifs['page'] = $pager->getPage();
// Json output
if (intval($json) === 1) {
System::jsonExit($notifs);
}
$notif_tpl = Renderer::getMarkupTemplate('notifications.tpl');
$notif_show_lnk = [
'href' => ($show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all' ),
'text' => ($show ? DI::l10n()->t('Show unread') : DI::l10n()->t('Show all')),
];
// Process the data for template creation
if (($notifs['ident'] ?? '') == 'introductions') {
$sugg = Renderer::getMarkupTemplate('suggestions.tpl');
$tpl = Renderer::getMarkupTemplate('intros.tpl');
// The link to switch between ignored and normal connection requests
$notif_show_lnk = [
'href' => (!$all ? 'notifications/intros/all' : 'notifications/intros' ),
'text' => (!$all ? DI::l10n()->t('Show Ignored Requests') : DI::l10n()->t('Hide Ignored Requests'))
];
// Loop through all introduction notifications.This creates an array with the output html for each
// introduction
foreach ($notifs['notifications'] as $notif) {
// There are two kind of introduction. Contacts suggested by other contacts and normal connection requests.
// We have to distinguish between these two because they use different data.
switch ($notif['label']) {
case 'friend_suggestion':
$notif_content[] = Renderer::replaceMacros($sugg, [
'$type' => $notif['label'],
'$str_notifytype' => DI::l10n()->t('Notification type:'),
'$notify_type'=> $notif['notify_type'],
'$intro_id' => $notif['intro_id'],
'$lbl_madeby' => DI::l10n()->t('Suggested by:'),
'$madeby' => $notif['madeby'],
'$madeby_url' => $notif['madeby_url'],
'$madeby_zrl' => $notif['madeby_zrl'],
'$madeby_addr'=> $notif['madeby_addr'],
'$contact_id' => $notif['contact_id'],
'$photo' => $notif['photo'],
'$fullname' => $notif['name'],
'$url' => $notif['url'],
'$zrl' => $notif['zrl'],
'$lbl_url' => DI::l10n()->t('Profile URL'),
'$addr' => $notif['addr'],
'$hidden' => ['hidden', DI::l10n()->t('Hide this contact from others'), ($notif['hidden'] == 1), ''],
'$knowyou' => $notif['knowyou'],
'$approve' => DI::l10n()->t('Approve'),
'$note' => $notif['note'],
'$request' => $notif['request'],
'$ignore' => DI::l10n()->t('Ignore'),
'$discard' => DI::l10n()->t('Discard'),
]);
break;
// Normal connection requests
default:
$friend_selected = (($notif['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled ');
$fan_selected = (($notif['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : '');
$lbl_knowyou = '';
$knowyou = '';
$helptext = '';
$helptext2 = '';
$helptext3 = '';
if ($notif['network'] === Protocol::DFRN) {
$lbl_knowyou = DI::l10n()->t('Claims to be known to you: ');
$knowyou = (($notif['knowyou']) ? DI::l10n()->t('yes') : DI::l10n()->t('no'));
$helptext = DI::l10n()->t('Shall your connection be bidirectional or not?');
$helptext2 = DI::l10n()->t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notif['name'], $notif['name']);
$helptext3 = DI::l10n()->t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notif['name']);
} elseif ($notif['network'] === Protocol::DIASPORA) {
$helptext = DI::l10n()->t('Shall your connection be bidirectional or not?');
$helptext2 = DI::l10n()->t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notif['name'], $notif['name']);
$helptext3 = DI::l10n()->t('Accepting %s as a sharer allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notif['name']);
}
$dfrn_tpl = Renderer::getMarkupTemplate('netfriend.tpl');
$dfrn_text = Renderer::replaceMacros($dfrn_tpl, [
'$intro_id' => $notif['intro_id'],
'$friend_selected' => $friend_selected,
'$fan_selected'=> $fan_selected,
'$approve_as1' => $helptext,
'$approve_as2' => $helptext2,
'$approve_as3' => $helptext3,
'$as_friend' => DI::l10n()->t('Friend'),
'$as_fan' => (($notif['network'] == Protocol::DIASPORA) ? DI::l10n()->t('Sharer') : DI::l10n()->t('Subscriber'))
]);
$contact = DBA::selectFirst('contact', ['network', 'protocol'], ['id' => $notif['contact_id']]);
if (($contact['network'] != Protocol::DFRN) || ($contact['protocol'] == Protocol::ACTIVITYPUB)) {
$action = 'follow_confirm';
} else {
$action = 'dfrn_confirm';
}
$header = $notif['name'];
if ($notif['addr'] != '') {
$header .= ' <' . $notif['addr'] . '>';
}
$header .= ' (' . ContactSelector::networkToName($notif['network'], $notif['url']) . ')';
if ($notif['network'] != Protocol::DIASPORA) {
$discard = DI::l10n()->t('Discard');
} else {
$discard = '';
}
$notif_content[] = Renderer::replaceMacros($tpl, [
'$type' => $notif['label'],
'$header' => $header,
'$str_notifytype' => DI::l10n()->t('Notification type:'),
'$notify_type' => $notif['notify_type'],
'$dfrn_text' => $dfrn_text,
'$dfrn_id' => $notif['dfrn_id'],
'$uid' => $notif['uid'],
'$intro_id' => $notif['intro_id'],
'$contact_id' => $notif['contact_id'],
'$photo' => $notif['photo'],
'$fullname' => $notif['name'],
'$location' => $notif['location'],
'$lbl_location'=> DI::l10n()->t('Location:'),
'$about' => $notif['about'],
'$lbl_about' => DI::l10n()->t('About:'),
'$keywords' => $notif['keywords'],
'$lbl_keywords'=> DI::l10n()->t('Tags:'),
'$gender' => $notif['gender'],
'$lbl_gender' => DI::l10n()->t('Gender:'),
'$hidden' => ['hidden', DI::l10n()->t('Hide this contact from others'), ($notif['hidden'] == 1), ''],
'$url' => $notif['url'],
'$zrl' => $notif['zrl'],
'$lbl_url' => DI::l10n()->t('Profile URL'),
'$addr' => $notif['addr'],
'$lbl_knowyou' => $lbl_knowyou,
'$lbl_network' => DI::l10n()->t('Network:'),
'$network' => ContactSelector::networkToName($notif['network'], $notif['url']),
'$knowyou' => $knowyou,
'$approve' => DI::l10n()->t('Approve'),
'$note' => $notif['note'],
'$ignore' => DI::l10n()->t('Ignore'),
'$discard' => $discard,
'$action' => $action,
]);
break;
}
}
if (count($notifs['notifications']) == 0) {
info(DI::l10n()->t('No introductions.') . EOL);
}
// Normal notifications (no introductions)
} elseif (!empty($notifs['notifications'])) {
// Loop trough ever notification This creates an array with the output html for each
// notification and apply the correct template according to the notificationtype (label).
foreach ($notifs['notifications'] as $notif) {
$notification_templates = [
'like' => 'notifications_likes_item.tpl',
'dislike' => 'notifications_dislikes_item.tpl',
'attend' => 'notifications_attend_item.tpl',
'attendno' => 'notifications_attend_item.tpl',
'attendmaybe' => 'notifications_attend_item.tpl',
'friend' => 'notifications_friends_item.tpl',
'comment' => 'notifications_comments_item.tpl',
'post' => 'notifications_posts_item.tpl',
'notify' => 'notify.tpl',
];
$tpl_notif = Renderer::getMarkupTemplate($notification_templates[$notif['label']]);
$notif_content[] = Renderer::replaceMacros($tpl_notif, [
'$item_label' => $notif['label'],
'$item_link' => $notif['link'],
'$item_image' => $notif['image'],
'$item_url' => $notif['url'],
'$item_text' => $notif['text'],
'$item_when' => $notif['when'],
'$item_ago' => $notif['ago'],
'$item_seen' => $notif['seen'],
]);
}
} else {
$notif_nocontent = DI::l10n()->t('No more %s notifications.', $notifs['ident']);
}
$o .= Renderer::replaceMacros($notif_tpl, [
'$notif_header' => $notif_header,
'$tabs' => $tabs,
'$notif_content' => $notif_content,
'$notif_nocontent' => $notif_nocontent,
'$notif_show_lnk' => $notif_show_lnk,
'$notif_paginate' => $pager->renderMinimal(count($notif_content))
]);
return $o;
}
/**
* List of pages for the Notifications TabBar
*
* @param string $selected The selected notification tab
*
* @return array with with notifications TabBar data
* @throws Exception
*/
function getTabs(string $selected = '')
{
$tabs = [];
foreach (URL_TYPES as $type => $url) {
$tabs[] = [
'label' => DI::l10n()->t(PRINT_TYPES[$type]),
'url' => 'notifications/' . $url,
'sel' => (($selected == $url) ? 'active' : ''),
'id' => $type . '-tab',
'accesskey' => ACCESS_KEYS[$type],
];
}
return $tabs;
}

View File

@ -443,7 +443,7 @@ function ping_get_notifications($uid)
);
}
$notification["href"] = DI::baseUrl() . "/notify/view/" . $notification["id"];
$notification["href"] = DI::baseUrl() . "/notification/view/" . $notification["id"];
if ($notification["visible"]
&& !$notification["deleted"]

View File

@ -257,11 +257,11 @@ abstract class DI
}
/**
* @return Model\Notify
* @return Model\Notification
*/
public static function notify()
public static function notification()
{
return self::$dice->create(Model\Notify::class);
return self::$dice->create(Model\Notification::class);
}
/**

View File

@ -25,9 +25,9 @@ use Friendica\Network\HTTPException;
* Methods for read and write notifications from/to database
* or for formatting notifications
*/
final class Notify
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 NETWORK = 'network';
@ -110,10 +110,10 @@ final class Notify
$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)) {
return $this->setExtra($this->dba->toArray($stmtNotifies));
if ($this->dba->isResult($stmtNotifications)) {
return $this->setExtra($this->dba->toArray($stmtNotifications));
}
return false;
@ -172,8 +172,8 @@ final class Notify
/**
* Format the notification query in an usable array
*
* @param array $notifies The array from the db query
* @param string $ident The notifications identifier (e.g. network)
* @param array $notifications The array from the db query
* @param string $ident The notifications identifier (e.g. network)
*
* @return array
* string 'label' => The type of the notification
@ -186,127 +186,127 @@ final class Notify
* bool 'seen' => Is the notification marked as "seen"
* @throws Exception
*/
private function formatList(array $notifies, string $ident = "")
private function formatList(array $notifications, string $ident = "")
{
$formattedNotifies = [];
$formattedNotifications = [];
foreach ($notifies as $notify) {
foreach ($notifications as $notification) {
// Because we use different db tables for the notification query
// we have sometimes $notify['unseen'] and sometimes $notify['seen].
// So we will have to transform $notify['unseen']
if (array_key_exists('unseen', $notify)) {
$notify['seen'] = ($notify['unseen'] > 0 ? false : true);
// we have sometimes $notification['unseen'] and sometimes $notification['seen].
// So we will have to transform $notification['unseen']
if (array_key_exists('unseen', $notification)) {
$notification['seen'] = ($notification['unseen'] > 0 ? false : true);
}
// For feed items we use the user's contact, since the avatar is mostly self choosen.
if (!empty($notify['network']) && $notify['network'] == Protocol::FEED) {
$notify['author-avatar'] = $notify['contact-avatar'];
if (!empty($notification['network']) && $notification['network'] == Protocol::FEED) {
$notification['author-avatar'] = $notification['contact-avatar'];
}
// Depending on the identifier of the notification we need to use different defaults
switch ($ident) {
case self::SYSTEM:
$default_item_label = 'notify';
$default_item_link = $this->baseUrl->get(true) . '/notify/view/' . $notify['id'];
$default_item_image = ProxyUtils::proxifyUrl($notify['photo'], false, ProxyUtils::SIZE_MICRO);
$default_item_url = $notify['url'];
$default_item_text = strip_tags(BBCode::convert($notify['msg']));
$default_item_when = DateTimeFormat::local($notify['date'], 'r');
$default_item_ago = Temporal::getRelativeDate($notify['date']);
$default_item_label = 'notification';
$default_item_link = $this->baseUrl->get(true) . '/notification/view/' . $notification['id'];
$default_item_image = ProxyUtils::proxifyUrl($notification['photo'], false, ProxyUtils::SIZE_MICRO);
$default_item_url = $notification['url'];
$default_item_text = strip_tags(BBCode::convert($notification['msg']));
$default_item_when = DateTimeFormat::local($notification['date'], 'r');
$default_item_ago = Temporal::getRelativeDate($notification['date']);
break;
case self::HOME:
$default_item_label = 'comment';
$default_item_link = $this->baseUrl->get(true) . '/display/' . $notify['parent-guid'];
$default_item_image = ProxyUtils::proxifyUrl($notify['author-avatar'], false, ProxyUtils::SIZE_MICRO);
$default_item_url = $notify['author-link'];
$default_item_text = $this->l10n->t("%s commented on %s's post", $notify['author-name'], $notify['parent-author-name']);
$default_item_when = DateTimeFormat::local($notify['created'], 'r');
$default_item_ago = Temporal::getRelativeDate($notify['created']);
$default_item_link = $this->baseUrl->get(true) . '/display/' . $notification['parent-guid'];
$default_item_image = ProxyUtils::proxifyUrl($notification['author-avatar'], false, ProxyUtils::SIZE_MICRO);
$default_item_url = $notification['author-link'];
$default_item_text = $this->l10n->t("%s commented on %s's post", $notification['author-name'], $notification['parent-author-name']);
$default_item_when = DateTimeFormat::local($notification['created'], 'r');
$default_item_ago = Temporal::getRelativeDate($notification['created']);
break;
default:
$default_item_label = (($notify['id'] == $notify['parent']) ? 'post' : 'comment');
$default_item_link = $this->baseUrl->get(true) . '/display/' . $notify['parent-guid'];
$default_item_image = ProxyUtils::proxifyUrl($notify['author-avatar'], false, ProxyUtils::SIZE_MICRO);
$default_item_url = $notify['author-link'];
$default_item_text = (($notify['id'] == $notify['parent'])
? $this->l10n->t("%s created a new post", $notify['author-name'])
: $this->l10n->t("%s commented on %s's post", $notify['author-name'], $notify['parent-author-name']));
$default_item_when = DateTimeFormat::local($notify['created'], 'r');
$default_item_ago = Temporal::getRelativeDate($notify['created']);
$default_item_label = (($notification['id'] == $notification['parent']) ? 'post' : 'comment');
$default_item_link = $this->baseUrl->get(true) . '/display/' . $notification['parent-guid'];
$default_item_image = ProxyUtils::proxifyUrl($notification['author-avatar'], false, ProxyUtils::SIZE_MICRO);
$default_item_url = $notification['author-link'];
$default_item_text = (($notification['id'] == $notification['parent'])
? $this->l10n->t("%s created a new post", $notification['author-name'])
: $this->l10n->t("%s commented on %s's post", $notification['author-name'], $notification['parent-author-name']));
$default_item_when = DateTimeFormat::local($notification['created'], 'r');
$default_item_ago = Temporal::getRelativeDate($notification['created']);
}
// Transform the different types of notification in an usable array
switch ($notify['verb']) {
switch ($notification['verb']) {
case Activity::LIKE:
$formattedNotify = [
$formattedNotification = [
'label' => 'like',
'link' => $this->baseUrl->get(true) . '/display/' . $notify['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notify['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notify['author-link'],
'text' => $this->l10n->t("%s liked %s's post", $notify['author-name'], $notify['parent-author-name']),
'link' => $this->baseUrl->get(true) . '/display/' . $notification['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notification['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notification['author-link'],
'text' => $this->l10n->t("%s liked %s's post", $notification['author-name'], $notification['parent-author-name']),
'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $notify['seen']
'seen' => $notification['seen']
];
break;
case Activity::DISLIKE:
$formattedNotify = [
$formattedNotification = [
'label' => 'dislike',
'link' => $this->baseUrl->get(true) . '/display/' . $notify['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notify['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notify['author-link'],
'text' => $this->l10n->t("%s disliked %s's post", $notify['author-name'], $notify['parent-author-name']),
'link' => $this->baseUrl->get(true) . '/display/' . $notification['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notification['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notification['author-link'],
'text' => $this->l10n->t("%s disliked %s's post", $notification['author-name'], $notification['parent-author-name']),
'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $notify['seen']
'seen' => $notification['seen']
];
break;
case Activity::ATTEND:
$formattedNotify = [
$formattedNotification = [
'label' => 'attend',
'link' => $this->baseUrl->get(true) . '/display/' . $notify['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notify['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notify['author-link'],
'text' => $this->l10n->t("%s is attending %s's event", $notify['author-name'], $notify['parent-author-name']),
'link' => $this->baseUrl->get(true) . '/display/' . $notification['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notification['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notification['author-link'],
'text' => $this->l10n->t("%s is attending %s's event", $notification['author-name'], $notification['parent-author-name']),
'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $notify['seen']
'seen' => $notification['seen']
];
break;
case Activity::ATTENDNO:
$formattedNotify = [
$formattedNotification = [
'label' => 'attendno',
'link' => $this->baseUrl->get(true) . '/display/' . $notify['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notify['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notify['author-link'],
'text' => $this->l10n->t("%s is not attending %s's event", $notify['author-name'], $notify['parent-author-name']),
'link' => $this->baseUrl->get(true) . '/display/' . $notification['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notification['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notification['author-link'],
'text' => $this->l10n->t("%s is not attending %s's event", $notification['author-name'], $notification['parent-author-name']),
'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $notify['seen']
'seen' => $notification['seen']
];
break;
case Activity::ATTENDMAYBE:
$formattedNotify = [
$formattedNotification = [
'label' => 'attendmaybe',
'link' => $this->baseUrl->get(true) . '/display/' . $notify['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notify['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notify['author-link'],
'text' => $this->l10n->t("%s may attend %s's event", $notify['author-name'], $notify['parent-author-name']),
'link' => $this->baseUrl->get(true) . '/display/' . $notification['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notification['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notification['author-link'],
'text' => $this->l10n->t("%s may attend %s's event", $notification['author-name'], $notification['parent-author-name']),
'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $notify['seen']
'seen' => $notification['seen']
];
break;
case Activity::FRIEND:
if (!isset($notify['object'])) {
$formattedNotify = [
if (!isset($notification['object'])) {
$formattedNotification = [
'label' => 'friend',
'link' => $default_item_link,
'image' => $default_item_image,
@ -314,31 +314,31 @@ final class Notify
'text' => $default_item_text,
'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $notify['seen']
'seen' => $notification['seen']
];
break;
}
/// @todo Check if this part here is used at all
$this->logger->info('Complete data.', ['notify' => $notify, 'callStack' => System::callstack(20)]);
$this->logger->info('Complete data.', ['notification' => $notification, 'callStack' => System::callstack(20)]);
$xmlHead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
$obj = XML::parseString($xmlHead . $notify['object']);
$notify['fname'] = $obj->title;
$xmlHead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
$obj = XML::parseString($xmlHead . $notification['object']);
$notification['fname'] = $obj->title;
$formattedNotify = [
$formattedNotification = [
'label' => 'friend',
'link' => $this->baseUrl->get(true) . '/display/' . $notify['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notify['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notify['author-link'],
'text' => $this->l10n->t("%s is now friends with %s", $notify['author-name'], $notify['fname']),
'link' => $this->baseUrl->get(true) . '/display/' . $notification['parent-guid'],
'image' => ProxyUtils::proxifyUrl($notification['author-avatar'], false, ProxyUtils::SIZE_MICRO),
'url' => $notification['author-link'],
'text' => $this->l10n->t("%s is now friends with %s", $notification['author-name'], $notification['fname']),
'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $notify['seen']
'seen' => $notification['seen']
];
break;
default:
$formattedNotify = [
$formattedNotification = [
'label' => $default_item_label,
'link' => $default_item_link,
'image' => $default_item_image,
@ -346,23 +346,23 @@ final class Notify
'text' => $default_item_text,
'when' => $default_item_when,
'ago' => $default_item_ago,
'seen' => $notify['seen']
'seen' => $notification['seen']
];
}
$formattedNotifies[] = $formattedNotify;
$formattedNotifications[] = $formattedNotification;
}
return $formattedNotifies;
return $formattedNotifications;
}
/**
* Get network notifications
*
* @param bool $seen False => only include notifications into the query
* @param bool $seen False => 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
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
* @return array [string, array]
* string 'ident' => Notification identifier
@ -372,8 +372,8 @@ final class Notify
*/
public function getNetworkList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
{
$ident = self::NETWORK;
$notifies = [];
$ident = self::NETWORK;
$notifications = [];
$condition = ['wall' => false, 'uid' => local_user()];
@ -388,11 +388,11 @@ final class Notify
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
if ($this->dba->isResult($items)) {
$notifies = $this->formatList(Item::inArray($items), $ident);
$notifications = $this->formatList(Item::inArray($items), $ident);
}
$arr = [
'notifications' => $notifies,
'notifications' => $notifications,
'ident' => $ident,
];
@ -402,10 +402,10 @@ final class Notify
/**
* Get system notifications
*
* @param bool $seen False => only include notifications into the query
* @param bool $seen False => 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
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
* @return array [string, array]
* string 'ident' => Notification identifier
@ -415,8 +415,8 @@ final class Notify
*/
public function getSystemList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
{
$ident = self::SYSTEM;
$notifies = [];
$ident = self::SYSTEM;
$notifications = [];
$filter = ['uid' => local_user()];
if (!$seen) {
@ -427,17 +427,17 @@ final class Notify
$params['order'] = ['date' => 'DESC'];
$params['limit'] = [$start, $limit];
$stmtNotifies = $this->dba->select('notify',
$stmtNotifications = $this->dba->select('notify',
['id', 'url', 'photo', 'msg', 'date', 'seen', 'verb'],
$filter,
$params);
if ($this->dba->isResult($stmtNotifies)) {
$notifies = $this->formatList($this->dba->toArray($stmtNotifies), $ident);
if ($this->dba->isResult($stmtNotifications)) {
$notifications = $this->formatList($this->dba->toArray($stmtNotifications), $ident);
}
$arr = [
'notifications' => $notifies,
'notifications' => $notifications,
'ident' => $ident,
];
@ -447,10 +447,10 @@ final class Notify
/**
* Get personal notifications
*
* @param bool $seen False => only include notifications into the query
* @param bool $seen False => 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
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
* @return array [string, array]
* string 'ident' => Notification identifier
@ -460,8 +460,8 @@ final class Notify
*/
public function getPersonalList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
{
$ident = self::PERSONAL;
$notifies = [];
$ident = self::PERSONAL;
$notifications = [];
$myurl = str_replace('http://', '', DI::app()->contact['nurl']);
$diasp_url = str_replace('/profile/', '/u/', $myurl);
@ -480,11 +480,11 @@ final class Notify
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
if ($this->dba->isResult($items)) {
$notifies = $this->formatList(Item::inArray($items), $ident);
$notifications = $this->formatList(Item::inArray($items), $ident);
}
$arr = [
'notifications' => $notifies,
'notifications' => $notifications,
'ident' => $ident,
];
@ -494,10 +494,10 @@ final class Notify
/**
* Get home notifications
*
* @param bool $seen False => only include notifications into the query
* @param bool $seen False => 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
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
* @return array [string, array]
* string 'ident' => Notification identifier
@ -507,8 +507,8 @@ final class Notify
*/
public function getHomeList(bool $seen = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT)
{
$ident = self::HOME;
$notifies = [];
$ident = self::HOME;
$notifications = [];
$condition = ['wall' => true, 'uid' => local_user()];
@ -523,11 +523,11 @@ final class Notify
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
if ($this->dba->isResult($items)) {
$notifies = $this->formatList(Item::inArray($items), $ident);
$notifications = $this->formatList(Item::inArray($items), $ident);
}
$arr = [
'notifications' => $notifies,
'notifications' => $notifications,
'ident' => $ident,
];
@ -553,9 +553,9 @@ final class Notify
public function getIntroList(bool $all = false, int $start = 0, int $limit = self::DEFAULT_PAGE_LIMIT, int $id = 0)
{
/// @todo sanitize wording according to SELF::INTRO
$ident = 'introductions';
$notifies = [];
$sql_extra = "";
$ident = 'introductions';
$notifications = [];
$sql_extra = "";
if (empty($id)) {
if (!$all) {
@ -568,7 +568,7 @@ final class Notify
}
/// @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`.*,
`fcontact`.`name` AS `fname`, `fcontact`.`url` AS `furl`, `fcontact`.`addr` AS `faddr`,
`fcontact`.`photo` AS `fphoto`, `fcontact`.`request` AS `frequest`,
@ -585,13 +585,13 @@ final class Notify
$start,
$limit
);
if ($this->dba->isResult($stmtNotifies)) {
$notifies = $this->formatIntroList($this->dba->toArray($stmtNotifies));
if ($this->dba->isResult($stmtNotifications)) {
$notifications = $this->formatIntroList($this->dba->toArray($stmtNotifications));
}
$arr = [
'ident' => $ident,
'notifications' => $notifies,
'notifications' => $notifications,
];
return $arr;
@ -623,7 +623,7 @@ final class Notify
$intro = [
'label' => 'friend_suggestion',
'notify_type' => $this->l10n->t('Friend Suggestion'),
'str_type' => $this->l10n->t('Friend Suggestion'),
'intro_id' => $intro['intro_id'],
'madeby' => $intro['name'],
'madeby_url' => $intro['url'],
@ -657,7 +657,7 @@ final class Notify
}
$intro = [
'label' => (($intro['network'] !== Protocol::OSTATUS) ? 'friend_request' : 'follower'),
'notify_type' => (($intro['network'] !== Protocol::OSTATUS) ? $this->l10n->t('Friend/Connect Request') : $this->l10n->t('New Follower')),
'str_type' => (($intro['network'] !== Protocol::OSTATUS) ? $this->l10n->t('Friend/Connect Request') : $this->l10n->t('New Follower')),
'dfrn_id' => $intro['issued-id'],
'uid' => $_SESSION['uid'],
'intro_id' => $intro['intro_id'],

View File

@ -0,0 +1,165 @@
<?php
namespace Friendica\Module;
use Exception;
use Friendica\BaseModule;
use Friendica\Content\Pager;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Notification;
use Friendica\Network\HTTPException\ForbiddenException;
/**
* Base Module for each tab of the notification display
*
* General possibility to print it as JSON as well
*/
abstract class BaseNotifications extends BaseModule
{
/** @var array Array of URL parameters */
const URL_TYPES = [
Notification::NETWORK => 'network',
Notification::SYSTEM => 'system',
Notification::HOME => 'home',
Notification::PERSONAL => 'personal',
Notification::INTRO => 'intros',
];
/** @var array Array of the allowed notifications and their printable name */
const PRINT_TYPES = [
Notification::NETWORK => 'Network',
Notification::SYSTEM => 'System',
Notification::HOME => 'Home',
Notification::PERSONAL => 'Personal',
Notification::INTRO => 'Introductions',
];
/** @var array The array of access keys for notification pages */
const ACCESS_KEYS = [
Notification::NETWORK => 'w',
Notification::SYSTEM => 'y',
Notification::HOME => 'h',
Notification::PERSONAL => 'r',
Notification::INTRO => 'i',
];
/** @var int The default count of items per page */
const ITEMS_PER_PAGE = 20;
/** @var boolean True, if ALL entries should get shown */
protected static $showAll;
/** @var int The determined start item of the current page */
protected static $firstItemNum;
/**
* Collects all notifications from the backend
*
* @return array The determined notification array
* ['header', 'notifications']
*/
abstract public static function getNotifications();
public static function init(array $parameters = [])
{
if (!local_user()) {
throw new ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$page = ($_REQUEST['page'] ?? 0) ?: 1;
self::$firstItemNum = ($page * self::ITEMS_PER_PAGE) - self::ITEMS_PER_PAGE;
self::$showAll = ($_REQUEST['show'] ?? '') === 'all';
}
public static function post(array $parameters = [])
{
$request_id = DI::args()->get(1);
if ($request_id === 'all') {
return;
}
if ($request_id) {
$intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]);
switch ($_POST['submit']) {
case DI::l10n()->t('Discard'):
$intro->discard();
break;
case DI::l10n()->t('Ignore'):
$intro->ignore();
break;
}
DI::baseUrl()->redirect('notifications/intros');
}
}
public static function rawContent(array $parameters = [])
{
// If the last argument of the query is NOT json, return
if (DI::args()->get(DI::args()->getArgc() - 1) !== 'json') {
return;
}
System::jsonExit(static::getNotifications()['notifs'] ?? []);
}
/**
* Shows the printable result of notifications for a specific tab
*
* @param string $header The notification header
* @param array $notifications The array with the notifications
* @param string $noContent The string in case there are no notifications
* @param array $showLink The possible links at the top
*
* @return string The rendered output
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
protected static function printContent(string $header, array $notifications, string $noContent, array $showLink)
{
// Get the nav tabs for the notification pages
$tabs = self::getTabs();
// Set the pager
$pager = new Pager(DI::args()->getQueryString(), self::ITEMS_PER_PAGE);
$notif_tpl = Renderer::getMarkupTemplate('notifications/notifications.tpl');
return Renderer::replaceMacros($notif_tpl, [
'$header' => $header ?? DI::l10n()->t('Notifications'),
'$tabs' => $tabs,
'$notifications' => $notifications,
'$noContent' => $noContent,
'$showLink' => $showLink,
'$paginate' => $pager->renderMinimal(count($notifications))
]);
}
/**
* List of pages for the Notifications TabBar
*
* @return array with with notifications TabBar data
* @throws Exception
*/
private static function getTabs()
{
$selected = DI::args()->get(1, '');
$tabs = [];
foreach (self::URL_TYPES as $type => $url) {
$tabs[] = [
'label' => DI::l10n()->t(self::PRINT_TYPES[$type]),
'url' => 'notifications/' . $url,
'sel' => (($selected == $url) ? 'active' : ''),
'id' => $type . '-tab',
'accesskey' => self::ACCESS_KEYS[$type],
];
}
return $tabs;
}
}

View File

@ -0,0 +1,194 @@
<?php
namespace Friendica\Module\Notifications;
use Friendica\Content\ContactSelector;
use Friendica\Content\Nav;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseNotifications;
/**
* Prints notifications about introduction
*/
class Introductions extends BaseNotifications
{
/**
* @inheritDoc
*/
public static function getNotifications()
{
$id = (int)DI::args()->get(2, 0);
$all = DI::args()->get(2) == 'all';
$notifications = DI::notification()->getIntroList($all, self::$firstItemNum, self::ITEMS_PER_PAGE, $id);
return [
'header' => DI::l10n()->t('Notifications'),
'notifications' => $notifications,
];
}
public static function content(array $parameters = [])
{
Nav::setSelected('introductions');
$all = DI::args()->get(2) == 'all';
$notificationContent = [];
$notificationNoContent = '';
$notificationResult = self::getNotifications();
$notifications = $notificationResult['notifications'] ?? [];
$notificationHeader = $notificationResult['header'] ?? '';
$notificationSuggestions = Renderer::getMarkupTemplate('notifications/suggestions.tpl');
$notificationTemplate = Renderer::getMarkupTemplate('notifications/intros.tpl');
// The link to switch between ignored and normal connection requests
$notificationShowLink = [
'href' => (!$all ? 'notifications/intros/all' : 'notifications/intros'),
'text' => (!$all ? DI::l10n()->t('Show Ignored Requests') : DI::l10n()->t('Hide Ignored Requests'))
];
// Loop through all introduction notifications.This creates an array with the output html for each
// introduction
foreach ($notifications['notifications'] as $notification) {
// There are two kind of introduction. Contacts suggested by other contacts and normal connection requests.
// We have to distinguish between these two because they use different data.
switch ($notification['label']) {
case 'friend_suggestion':
$notificationContent[] = Renderer::replaceMacros($notificationSuggestions, [
'$type' => $notification['label'],
'str_notification_type' => DI::l10n()->t('Notification type:'),
'str_type' => $notification['str_type'],
'$intro_id' => $notification['intro_id'],
'$lbl_madeby' => DI::l10n()->t('Suggested by:'),
'$madeby' => $notification['madeby'],
'$madeby_url' => $notification['madeby_url'],
'$madeby_zrl' => $notification['madeby_zrl'],
'$madeby_addr' => $notification['madeby_addr'],
'$contact_id' => $notification['contact_id'],
'$photo' => $notification['photo'],
'$fullname' => $notification['name'],
'$url' => $notification['url'],
'$zrl' => $notification['zrl'],
'$lbl_url' => DI::l10n()->t('Profile URL'),
'$addr' => $notification['addr'],
'$hidden' => ['hidden', DI::l10n()->t('Hide this contact from others'), ($notification['hidden'] == 1), ''],
'$knowyou' => $notification['knowyou'],
'$approve' => DI::l10n()->t('Approve'),
'$note' => $notification['note'],
'$request' => $notification['request'],
'$ignore' => DI::l10n()->t('Ignore'),
'$discard' => DI::l10n()->t('Discard'),
]);
break;
// Normal connection requests
default:
$friend_selected = (($notification['network'] !== Protocol::OSTATUS) ? ' checked="checked" ' : ' disabled ');
$fan_selected = (($notification['network'] === Protocol::OSTATUS) ? ' checked="checked" disabled ' : '');
$lbl_knowyou = '';
$knowyou = '';
$helptext = '';
$helptext2 = '';
$helptext3 = '';
if ($notification['network'] === Protocol::DFRN) {
$lbl_knowyou = DI::l10n()->t('Claims to be known to you: ');
$knowyou = (($notification['knowyou']) ? DI::l10n()->t('yes') : DI::l10n()->t('no'));
$helptext = DI::l10n()->t('Shall your connection be bidirectional or not?');
$helptext2 = DI::l10n()->t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notification['name'], $notification['name']);
$helptext3 = DI::l10n()->t('Accepting %s as a subscriber allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notification['name']);
} elseif ($notification['network'] === Protocol::DIASPORA) {
$helptext = DI::l10n()->t('Shall your connection be bidirectional or not?');
$helptext2 = DI::l10n()->t('Accepting %s as a friend allows %s to subscribe to your posts, and you will also receive updates from them in your news feed.', $notification['name'], $notification['name']);
$helptext3 = DI::l10n()->t('Accepting %s as a sharer allows them to subscribe to your posts, but you will not receive updates from them in your news feed.', $notification['name']);
}
$dfrn_tpl = Renderer::getMarkupTemplate('notifications/netfriend.tpl');
$dfrn_text = Renderer::replaceMacros($dfrn_tpl, [
'$intro_id' => $notification['intro_id'],
'$friend_selected' => $friend_selected,
'$fan_selected' => $fan_selected,
'$approve_as1' => $helptext,
'$approve_as2' => $helptext2,
'$approve_as3' => $helptext3,
'$as_friend' => DI::l10n()->t('Friend'),
'$as_fan' => (($notification['network'] == Protocol::DIASPORA) ? DI::l10n()->t('Sharer') : DI::l10n()->t('Subscriber'))
]);
$contact = DBA::selectFirst('contact', ['network', 'protocol'], ['id' => $notification['contact_id']]);
if (($contact['network'] != Protocol::DFRN) || ($contact['protocol'] == Protocol::ACTIVITYPUB)) {
$action = 'follow_confirm';
} else {
$action = 'dfrn_confirm';
}
$header = $notification['name'];
if ($notification['addr'] != '') {
$header .= ' <' . $notification['addr'] . '>';
}
$header .= ' (' . ContactSelector::networkToName($notification['network'], $notification['url']) . ')';
if ($notification['network'] != Protocol::DIASPORA) {
$discard = DI::l10n()->t('Discard');
} else {
$discard = '';
}
$notificationContent[] = Renderer::replaceMacros($notificationTemplate, [
'$type' => $notification['label'],
'$header' => $header,
'str_notification_type' => DI::l10n()->t('Notification type:'),
'str_type' => $notification['notifytype'],
'$dfrn_text' => $dfrn_text,
'$dfrn_id' => $notification['dfrn_id'],
'$uid' => $notification['uid'],
'$intro_id' => $notification['intro_id'],
'$contact_id' => $notification['contact_id'],
'$photo' => $notification['photo'],
'$fullname' => $notification['name'],
'$location' => $notification['location'],
'$lbl_location' => DI::l10n()->t('Location:'),
'$about' => $notification['about'],
'$lbl_about' => DI::l10n()->t('About:'),
'$keywords' => $notification['keywords'],
'$lbl_keywords' => DI::l10n()->t('Tags:'),
'$gender' => $notification['gender'],
'$lbl_gender' => DI::l10n()->t('Gender:'),
'$hidden' => ['hidden', DI::l10n()->t('Hide this contact from others'), ($notification['hidden'] == 1), ''],
'$url' => $notification['url'],
'$zrl' => $notification['zrl'],
'$lbl_url' => DI::l10n()->t('Profile URL'),
'$addr' => $notification['addr'],
'$lbl_knowyou' => $lbl_knowyou,
'$lbl_network' => DI::l10n()->t('Network:'),
'$network' => ContactSelector::networkToName($notification['network'], $notification['url']),
'$knowyou' => $knowyou,
'$approve' => DI::l10n()->t('Approve'),
'$note' => $notification['note'],
'$ignore' => DI::l10n()->t('Ignore'),
'$discard' => $discard,
'$action' => $action,
]);
break;
}
}
if (count($notifications['notifications']) == 0) {
info(DI::l10n()->t('No introductions.') . EOL);
$notificationNoContent = DI::l10n()->t('No more %s notifications.', $notifications['ident']);
}
return self::printContent($notificationHeader, $notificationContent, $notificationNoContent, $notificationShowLink);
}
}

View File

@ -8,9 +8,9 @@ use Friendica\DI;
use Friendica\Network\HTTPException;
/**
* Interacting with the /notify command
* Interacting with the /notification command
*/
class Notify extends BaseModule
class Notification extends BaseModule
{
public static function init(array $parameters = [])
{
@ -21,11 +21,9 @@ class Notify extends BaseModule
public static function rawContent(array $parameters = [])
{
$a = DI::app();
// @TODO: Replace with parameter from router
if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
$success = DI::notify()->setAllSeen();
if (DI::args()->get(1) === 'mark' && DI::args()->get(2) === 'all') {
$success = DI::notification()->setAllSeen();
header('Content-type: application/json; charset=utf-8');
echo json_encode([
@ -36,22 +34,20 @@ class Notify extends BaseModule
}
/**
* Redirect to the notifications main page or to the url for the chosen notify
* Redirect to the notifications main page or to the url for the chosen notifications
*
* @return string|void
* @throws HTTPException\InternalServerErrorException
*/
public static function content(array $parameters = [])
{
$a = DI::app();
// @TODO: Replace with parameter from router
if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
$notificationsManager = DI::notify();
if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) {
$notificationManager = DI::notification();
// @TODO: Replace with parameter from router
$note = $notificationsManager->getByID($a->argv[2]);
$note = $notificationManager->getByID(DI::args()->get(2));
if (!empty($note)) {
$notificationsManager->setSeen($note);
$notificationManager->setSeen($note);
if (!empty($note['link'])) {
System::externalRedirect($note['link']);
}

View File

@ -0,0 +1,118 @@
<?php
namespace Friendica\Module\Notifications;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseNotifications;
/**
* Prints all notification types except introduction:
* - Network
* - System
* - Personal
* - Home
*/
class Notifications extends BaseNotifications
{
/**
* {@inheritDoc}
*/
public static function getNotifications()
{
$nm = DI::notification();
$notificationHeader = '';
// Get the network notifications
if ((DI::args()->get(1) == 'network')) {
$notificationHeader = DI::l10n()->t('Network Notifications');
$notifications = $nm->getNetworkList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE);
// Get the system notifications
} elseif ((DI::args()->get(1) == 'system')) {
$notificationHeader = DI::l10n()->t('System Notifications');
$notifications = $nm->getSystemList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE);
// Get the personal notifications
} elseif ((DI::args()->get(1) == 'personal')) {
$notificationHeader = DI::l10n()->t('Personal Notifications');
$notifications = $nm->getPersonalList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE);
// Get the home notifications
} elseif ((DI::args()->get(1) == 'home')) {
$notificationHeader = DI::l10n()->t('Home Notifications');
$notifications = $nm->getHomeList(self::$showAll, self::$firstItemNum, self::ITEMS_PER_PAGE);
// fallback - redirect to main page
} else {
DI::baseUrl()->redirect('notifications');
}
// Set the pager
$pager = new Pager(DI::args()->getQueryString(), self::ITEMS_PER_PAGE);
// Add additional informations (needed for json output)
$notifications['items_page'] = $pager->getItemsPerPage();
$notifications['page'] = $pager->getPage();
return [
'header' => $notificationHeader,
'notifications' => $notifications,
];
}
public static function content(array $parameters = [])
{
Nav::setSelected('notifications');
$notificationContent = [];
$notificationNoContent = '';
$notificationResult = self::getNotifications();
$notifications = $notificationResult['notifications'] ?? [];
$notificationHeader = $notificationResult['header'] ?? '';
if (!empty($notifications['notifications'])) {
// Loop trough ever notification This creates an array with the output html for each
// notification and apply the correct template according to the notificationtype (label).
foreach ($notifications['notifications'] as $notification) {
$notification_templates = [
'like' => 'notifications/likes_item.tpl',
'dislike' => 'notifications/dislikes_item.tpl',
'attend' => 'notifications/attend_item.tpl',
'attendno' => 'notifications/attend_item.tpl',
'attendmaybe' => 'notifications/attend_item.tpl',
'friend' => 'notifications/friends_item.tpl',
'comment' => 'notifications/comments_item.tpl',
'post' => 'notifications/posts_item.tpl',
'notification' => 'notifications/notification.tpl',
];
$notificationTemplate = Renderer::getMarkupTemplate($notification_templates[$notification['label']]);
$notificationContent[] = Renderer::replaceMacros($notificationTemplate, [
'$item_label' => $notification['label'],
'$item_link' => $notification['link'],
'$item_image' => $notification['image'],
'$item_url' => $notification['url'],
'$item_text' => $notification['text'],
'$item_when' => $notification['when'],
'$item_ago' => $notification['ago'],
'$item_seen' => $notification['seen'],
]);
}
} else {
$notificationNoContent = DI::l10n()->t('No more %s notifications.', $notifications['ident']);
}
$notificationShowLink = [
'href' => (self::$showAll ? 'notifications/' . $notifications['ident'] : 'notifications/' . $notifications['ident'] . '?show=all'),
'text' => (self::$showAll ? DI::l10n()->t('Show unread') : DI::l10n()->t('Show all')),
];
return self::printContent($notificationHeader, $notificationContent, $notificationNoContent, $notificationShowLink);
}
}

View File

@ -167,10 +167,20 @@ return [
'/nodeinfo/{version}' => [Module\NodeInfo::class, [R::GET]],
'/nogroup' => [Module\Group::class, [R::GET]],
'/notify' => [
'[/]' => [Module\Notifications\Notify::class, [R::GET]],
'/view/{id:\d+}' => [Module\Notifications\Notify::class, [R::GET]],
'/mark/all' => [Module\Notifications\Notify::class, [R::GET]],
'/notifications' => [
'/network[/json]' => [Module\Notifications\Notifications::class, [R::GET, R::POST]],
'/system[/json]' => [Module\Notifications\Notifications::class, [R::GET, R::POST]],
'/personal[/json]' => [Module\Notifications\Notifications::class, [R::GET, R::POST]],
'/home[/json]' => [Module\Notifications\Notifications::class, [R::GET, R::POST]],
'/intros[/json]' => [Module\Notifications\Introductions::class, [R::GET, R::POST]],
'/intros/all[/json]' => [Module\Notifications\Introductions::class, [R::GET, R::POST]],
'/intros/{contact:\d+}[/json]' => [Module\Notifications\Introductions::class, [R::GET, R::POST]],
],
'/notification' => [
'[/]' => [Module\Notifications\Notification::class, [R::GET]],
'/view/{id:\d+}' => [Module\Notifications\Notification::class, [R::GET]],
'/mark/all' => [Module\Notifications\Notification::class, [R::GET]],
],
'/objects/{guid}' => [Module\Objects::class, [R::GET]],

View File

@ -274,7 +274,7 @@ code, key {
}
/* notifications unseen */
.notify-unseen { background-color: #cceeFF; }
.notification-unseen { background-color: #cceeFF; }
/* autocomplete popup */
ul.acpopup {

View File

@ -299,19 +299,19 @@ $(function() {
var notification_id = 0;
// Insert notifs into the notifications-menu
$(data.notifications).each(function(key, notif) {
var text = notif.message.format('<span class="contactname">' + notif.name + '</span>');
var contact = ('<a href="' + notif.url + '"><span class="contactname">' + notif.name + '</span></a>');
var seenclass = (notif.seen == 1) ? "notify-seen" : "notify-unseen";
$(data.notifications).each(function(key, notification) {
var text = notification.message.format('<span class="contactname">' + notification.name + '</span>');
var contact = ('<a href="' + notification.url + '"><span class="contactname">' + notification.name + '</span></a>');
var seenclass = (notification.seen == 1) ? "notification-seen" : "notification-unseen";
var html = notifications_tpl.format(
notif.href, // {0} // link to the source
notif.photo, // {1} // photo of the contact
notification.href, // {0} // link to the source
notification.photo, // {1} // photo of the contact
text, // {2} // preformatted text (autor + text)
notif.date, // {3} // date of notification (time ago)
notification.date, // {3} // date of notification (time ago)
seenclass, // {4} // visited status of the notification
new Date(notif.timestamp*1000), // {5} // date of notification
notif.url, // {6} // profile url of the contact
notif.message.format(contact), // {7} // preformatted html (text including author profile url)
new Date(notification.timestamp*1000), // {5} // date of notification
notification.url, // {6} // profile url of the contact
notification.message.format(contact), // {7} // preformatted html (text including author profile url)
'' // {8} // Deprecated
);
nnm.append(html);
@ -948,8 +948,8 @@ function checkboxhighlight(box) {
}
}
function notifyMarkAll() {
$.get('notify/mark/all', function(data) {
function notificationMarkAll() {
$.get('notification/mark/all', function(data) {
if (timer) {
clearTimeout(timer);
}

View File

@ -34,7 +34,7 @@
<a accesskey="c" id="nav-community-link" class="nav-commlink {{$nav.community.2}} {{$sel.community}}" href="{{$nav.community.0}}" title="{{$nav.community.3}}" >{{$nav.community.1}}</a>
{{/if}}
{{if $nav.introductions}}
<a id="nav-notify-link" class="nav-commlink {{$nav.introductions.2}} {{$sel.introductions}}" href="{{$nav.introductions.0}}" title="{{$nav.introductions.3}}" >{{$nav.introductions.1}}</a>
<a id="nav-notification-link" class="nav-commlink {{$nav.introductions.2}} {{$sel.introductions}}" href="{{$nav.introductions.0}}" title="{{$nav.introductions.3}}" >{{$nav.introductions.1}}</a>
<span id="intro-update" class="nav-ajax-left"></span>
{{/if}}
{{if $nav.messages}}
@ -49,10 +49,10 @@
{{if $nav.notifications}}
<a accesskey="f" id="nav-notifications-linkmenu" class="nav-commlink" href="{{$nav.notifications.0}}" rel="#nav-notifications-menu" title="{{$nav.notifications.1}}">{{$nav.notifications.1}}</a>
<span id="notify-update" class="nav-ajax-left"></span>
<span id="notification-update" class="nav-ajax-left"></span>
<ul id="nav-notifications-menu" class="menu-popup">
<li id="nav-notifications-see-all"><a href="{{$nav.notifications.all.0}}">{{$nav.notifications.all.1}}</a></li>
<li id="nav-notifications-mark-all"><a href="#" onclick="notifyMarkAll(); return false;">{{$nav.notifications.mark.3}}</a></li>
<li id="nav-notifications-mark-all"><a href="#" onclick="notificationMarkAll(); return false;">{{$nav.notifications.mark.3}}</a></li>
<li class="empty">{{$emptynotifications}}</li>
</ul>
{{/if}}

View File

@ -1,25 +0,0 @@
<h1>{{$notif_header}}</h1>
{{if $tabs }}{{include file="common_tabs.tpl"}}{{/if}}
<div class="notif-network-wrapper">
{{* The "show ignored" link *}}
{{if $notif_show_lnk}}<a href="{{$notif_show_lnk.href}}" id="notifications-show-hide-link">{{$notif_show_lnk.text}}</a>{{/if}}
{{* The notifications *}}
{{if $notif_content}}
{{foreach $notif_content as $notification}}
{{$notification nofilter}}
{{/foreach}}
{{/if}}
{{* If no notifications messages available *}}
{{if $notif_nocontent}}
<div class="notif_nocontent">{{$notif_nocontent}}</div>
{{/if}}
{{* The pager *}}
{{$notif_paginate nofilter}}
</div>

View File

@ -2,7 +2,7 @@
<div class="intro-wrapper" id="intro-{{$contact_id}}" >
<p class="intro-desc">{{$str_notifytype}} {{$notify_type}}</p>
<p class="intro-desc">{{$str_notification_type}} {{$str_type}}</p>
<img id="photo-{{$contact_id}}" class="intro-photo" src="{{$photo}}" width="175" height=175" title="{{$fullname}}" alt="{{$fullname}}" />
<dl><dt>{{$lbl_url}}</dt><dd><a target="blank" href="{{$zrl}}">{{$url}}</a></dd></dl>
{{if $location}}<dl><dt>{{$lbl_location}}</dt><dd>{{$location}}</dd></dl>{{/if}}

View File

@ -0,0 +1,25 @@
<h1>{{$header}}</h1>
{{if $tabs }}{{include file="common_tabs.tpl"}}{{/if}}
<div class="notif-network-wrapper">
{{* The "show ignored" link *}}
{{if $showLink}}<a href="{{$showLink.href}}" id="notifications-show-hide-link">{{$showLink.text}}</a>{{/if}}
{{* The notifications *}}
{{if $notifications}}
{{foreach $notifications as $notification}}
{{$notification nofilter}}
{{/foreach}}
{{/if}}
{{* If no notifications messages available *}}
{{if $noContent}}
<div class="notification_nocontent">{{$noContent}}</div>
{{/if}}
{{* The pager *}}
{{$paginate nofilter}}
</div>

View File

@ -2,7 +2,7 @@
<div class="intro-wrapper" >
<p class="intro-desc">{{$str_notifytype}} {{$notify_type}}</p>
<p class="intro-desc">{{$str_notification_type}} {{$str_type}}</p>
{{if $madeby}}<div class="intro-madeby">{{$lbl_madeby}} {{$madeby}}</div>{{/if}}
<div class="intro-fullname" >{{$fullname}}</div>
<a class="intro-url-link" href="{{$url}}" ><img class="intro-photo lframe" src="{{$photo}}" width="175" height="175" title="{{$fullname}}" alt="{{$fullname}}" /></a>

View File

@ -114,7 +114,7 @@
<div class="settings-content-block">
<div id="settings-notifications">
<div id="settings-notify-desc">{{$lbl_not}}</div>
<div id="settings-notification-desc">{{$lbl_not}}</div>
<div class="group">
{{include file="field_intcheckbox.tpl" field=$notify1}}

View File

@ -133,7 +133,7 @@ input#dfrn-url {
background:#444;
}
.notify-seen {
.notification-seen {
background:#111;
}

View File

@ -784,7 +784,7 @@ input#dfrn-url {
#settings-notifications label {
margin-left: 20px;
}
#settings-notify-desc, #settings-activity-desc {
#settings-notification-desc, #settings-activity-desc {
font-weight: bold;
margin-bottom: 15px;
}
@ -2781,7 +2781,7 @@ aside input[type='text'] {
#crepair-url-label,
#crepair-request-label,
#crepair-confirm-label,
#crepair-notify-label,
#crepair-notification-label,
#crepair-photo-label,
#crepair-poll-label {
float: left;
@ -3316,7 +3316,7 @@ div.jGrowl div.info {
margin-right: -20px;
}
.nav-notify {
.nav-notification {
display: none;
position: absolute;
font-size: 10px;
@ -3326,7 +3326,7 @@ div.jGrowl div.info {
min-width: 15px;
text-align: right;
}
.nav-notify.show {
.nav-notification.show {
display: block;
}
#nav-notifications-menu {
@ -3372,7 +3372,7 @@ div.jGrowl div.info {
padding: 7px 7px 0px 0px;
}
.notify-seen {
.notification-seen {
background: #DDDDDD;
}

View File

@ -34,7 +34,7 @@
<a accesskey="c" id="nav-community-link" class="nav-commlink {{$nav.community.2}} {{$sel.community}}" href="{{$nav.community.0}}" title="{{$nav.community.3}}" >{{$nav.community.1}}</a>
{{/if}}
{{if $nav.introductions}}
<a id="nav-notify-link" class="nav-commlink {{$nav.introductions.2}} {{$sel.introductions}}" href="{{$nav.introductions.0}}" title="{{$nav.introductions.3}}" >{{$nav.introductions.1}}</a>
<a id="nav-notification-link" class="nav-commlink {{$nav.introductions.2}} {{$sel.introductions}}" href="{{$nav.introductions.0}}" title="{{$nav.introductions.3}}" >{{$nav.introductions.1}}</a>
<span id="intro-update" class="nav-ajax-left"></span>
{{/if}}
{{if $nav.messages}}
@ -48,10 +48,10 @@
{{if $nav.notifications}}
<a accesskey="f" id="nav-notifications-linkmenu" class="nav-commlink" href="{{$nav.notifications.0}}" rel="#nav-notifications-menu" title="{{$nav.notifications.1}}">{{$nav.notifications.1}}</a>
<span id="notify-update" class="nav-ajax-left"></span>
<span id="notification-update" class="nav-ajax-left"></span>
<ul id="nav-notifications-menu" class="menu-popup">
<li id="nav-notifications-see-all"><a href="{{$nav.notifications.all.0}}">{{$nav.notifications.all.1}}</a></li>
<li id="nav-notifications-mark-all"><a href="#" onclick="notifyMarkAll(); return false;">{{$nav.notifications.mark.3}}</a></li>
<li id="nav-notifications-mark-all"><a href="#" onclick="notificationMarkAll(); return false;">{{$nav.notifications.mark.3}}</a></li>
<li class="empty">{{$emptynotifications}}</li>
</ul>
{{/if}}

View File

@ -512,7 +512,7 @@ nav.navbar .nav>li>a:focus{
text-decoration: none;
text-align: left
}
#topbar-first .topbar-nav .nav-segment .nav-notify {
#topbar-first .topbar-nav .nav-segment .nav-notification {
position: absolute;
top: 4px;
right: -2px;
@ -640,7 +640,7 @@ nav.navbar a, nav.navbar .btn-link {
font-size: 12px;
}
#topbar-first #nav-notifications-menu li.notify-unseen {
#topbar-first #nav-notifications-menu li.notification-unseen {
border-left: 3px solid #f3fcfd;
background-color: #f3fcfd;
}
@ -682,7 +682,7 @@ nav.navbar a, nav.navbar .btn-link {
#topbar-first .account .user-title span {
color: $nav_icon_color;
}
#topbar-first .account #main-menu .nav-notify {
#topbar-first .account #main-menu .nav-notification {
position: absolute;
top: 4px;
right: -2px;

View File

@ -25,7 +25,7 @@ aside .widget, .form-control, .panel, .nav-container, .wall-item-content, .e-con
font-family: ".SFNSText-Regular","San Francisco","Roboto","Segoe UI","Helvetica Neue","Lucida Grande",Helvetica,Arial,sans-serif;
}
#topbar-first #nav-notifications-menu li.notify-unseen {
#topbar-first #nav-notifications-menu li.notification-unseen {
border-left: 3px solid #f3fcfd;
background-color: antiquewhite;
}

View File

@ -40,11 +40,11 @@
<ul class="nav navbar-nav navbar-left" role="menubar">
<li id="nav-communication" class="nav-segment" role="presentation">
{{if $nav.network}}
<a accesskey="n" role="menuitem" class="nav-menu {{$sel.network}}" href="{{$nav.network.0}}" data-toggle="tooltip" aria-label="{{$nav.network.3}}" title="{{$nav.network.3}}"><i class="fa fa-lg fa-th" aria-hidden="true"></i><span id="net-update" class="nav-network-badge badge nav-notify"></span></a>
<a accesskey="n" role="menuitem" class="nav-menu {{$sel.network}}" href="{{$nav.network.0}}" data-toggle="tooltip" aria-label="{{$nav.network.3}}" title="{{$nav.network.3}}"><i class="fa fa-lg fa-th" aria-hidden="true"></i><span id="net-update" class="nav-network-badge badge nav-notification"></span></a>
{{/if}}
{{if $nav.home}}
<a accesskey="p" role="menuitem" class="nav-menu {{$sel.home}}" href="{{$nav.home.0}}" data-toggle="tooltip" aria-label="{{$nav.home.3}}" title="{{$nav.home.3}}"><i class="fa fa-lg fa-home" aria-hidden="true"></i><span id="home-update" class="nav-home-badge badge nav-notify"></span></a>
<a accesskey="p" role="menuitem" class="nav-menu {{$sel.home}}" href="{{$nav.home.0}}" data-toggle="tooltip" aria-label="{{$nav.home.3}}" title="{{$nav.home.3}}"><i class="fa fa-lg fa-home" aria-hidden="true"></i><span id="home-update" class="nav-home-badge badge nav-notification"></span></a>
{{/if}}
{{if $nav.community}}
@ -54,7 +54,7 @@
<li id="nav-personal" class="nav-segment hidden-xs" role="presentation">
{{if $nav.messages}}
<a role="menuitem" id="nav-messages-link" href="{{$nav.messages.0}}" data-toggle="tooltip" aria-label="{{$nav.messages.1}}" title="{{$nav.messages.1}}" class="nav-menu {{$sel.messages}}"><i class="fa fa-envelope fa-lg" aria-hidden="true"></i><span id="mail-update" class="nav-mail-badge badge nav-notify"></span></a>
<a role="menuitem" id="nav-messages-link" href="{{$nav.messages.0}}" data-toggle="tooltip" aria-label="{{$nav.messages.1}}" title="{{$nav.messages.1}}" class="nav-menu {{$sel.messages}}"><i class="fa fa-envelope fa-lg" aria-hidden="true"></i><span id="mail-update" class="nav-mail-badge badge nav-notification"></span></a>
{{/if}}
{{if $nav.events}}
@ -63,7 +63,7 @@
{{if $nav.contacts}}
<a role="menuitem" id="nav-contacts-link" class="nav-menu {{$sel.contacts}} {{$nav.contacts.2}}" href="{{$nav.contacts.0}}" data-toggle="tooltip" aria-label="{{$nav.contacts.1}}" title="{{$nav.contacts.1}}" ><i class="fa fa-users fa-lg" aria-hidden="true"></i></a>
<span id="intro-update" class="nav-intro-badge badge nav-notify" onclick="window.location.href = '{{$nav.introductions.0}}' " data-toggle="tooltip" aria-label="{{$nav.introductions.3}}" title="{{$nav.introductions.3}}"></span>
<span id="intro-update" class="nav-intro-badge badge nav-notification" onclick="window.location.href = '{{$nav.introductions.0}}' " data-toggle="tooltip" aria-label="{{$nav.introductions.3}}" title="{{$nav.introductions.3}}"></span>
{{/if}}
</li>
@ -73,7 +73,7 @@
<a href="{{$nav.notifications.0}}" rel="#nav-notifications-menu" data-toggle="tooltip" aria-label="{{$nav.notifications.1}}" title="{{$nav.notifications.1}}" role="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" aria-controls="nav-notifications-menu">
<i class="fa fa-bell fa-lg" aria-hidden="true"></i>
<span role="menuitem" class="sr-only">{{$nav.notifications.1}}</span>
<span id="notify-update" class="nav-notify-badge badge nav-notify dropdown" data-toggle="dropdown"></span>
<span id="notification-update" class="nav-notification-badge badge nav-notification dropdown" data-toggle="dropdown"></span>
</a>
{{* The notifications dropdown menu. There are two parts of menu. The second is at the bottom of this file. It is loaded via js. Look at nav-notifications-template *}}
@ -84,7 +84,7 @@
<div class="arrow"></div>
{{$nav.notifications.1}}
<div class="dropdown-header-link">
<button role="menuitem" type="button" class="btn-link" onclick="notifyMarkAll();" data-toggle="tooltip" aria-label="{{$nav.notifications.mark.3}}" title="{{$nav.notifications.mark.3}}">{{$nav.notifications.mark.1}}</button>
<button role="menuitem" type="button" class="btn-link" onclick="notificationMarkAll();" data-toggle="tooltip" aria-label="{{$nav.notifications.mark.3}}" title="{{$nav.notifications.mark.3}}">{{$nav.notifications.mark.1}}</button>
</div>
</li>
@ -143,11 +143,11 @@
<li role="presentation"><a role="menuitem" href="{{$nav.notifications.all.0}}" title="{{$nav.notifications.1}}"><i class="fa fa-bell fa-fw" aria-hidden="true"></i> {{$nav.notifications.1}}</a></li>
{{/if}}
{{if $nav.messages}}
<li role="presentation"><a role="menuitem" class="nav-commlink {{$nav.messages.2}} {{$sel.messages}}" href="{{$nav.messages.0}}" title="{{$nav.messages.3}}" ><i class="fa fa-envelope fa-fw" aria-hidden="true"></i> {{$nav.messages.1}} <span id="mail-update-li" class="nav-mail-badge badge nav-notify"></span></a></li>
<li role="presentation"><a role="menuitem" class="nav-commlink {{$nav.messages.2}} {{$sel.messages}}" href="{{$nav.messages.0}}" title="{{$nav.messages.3}}" ><i class="fa fa-envelope fa-fw" aria-hidden="true"></i> {{$nav.messages.1}} <span id="mail-update-li" class="nav-mail-badge badge nav-notification"></span></a></li>
{{/if}}
<li role="presentation" class="divider"></li>
{{if $nav.contacts}}
<li role="presentation"><a role="menuitem" id="nav-menu-contacts-link" class="nav-link {{$nav.contacts.2}}" href="{{$nav.contacts.0}}" title="{{$nav.contacts.3}}"><i class="fa fa-users fa-fw" aria-hidden="true"></i> {{$nav.contacts.1}}</a><span id="intro-update-li" class="nav-intro-badge badge nav-notify"></span></li>
<li role="presentation"><a role="menuitem" id="nav-menu-contacts-link" class="nav-link {{$nav.contacts.2}}" href="{{$nav.contacts.0}}" title="{{$nav.contacts.3}}"><i class="fa fa-users fa-fw" aria-hidden="true"></i> {{$nav.contacts.1}}</a><span id="intro-update-li" class="nav-intro-badge badge nav-notification"></span></li>
{{/if}}
{{if $nav.delegation}}
<li role="presentation"><a role="menuitem" id="nav-delegation-link" class="nav-commlink {{$nav.delegation.2}} {{$sel.delegation}}" href="{{$nav.delegation.0}}" title="{{$nav.delegation.3}}"><i class="fa fa-flag fa-fw" aria-hidden="true"></i> {{$nav.delegation.1}}</a></li>

View File

@ -1,30 +0,0 @@
<script type="text/javascript" src="view/theme/frio/frameworks/jquery-color/jquery.color.js"></script>
<script type="text/javascript" src="view/theme/frio/js/mod_notifications.js"></script>
<div class="generic-page-wrapper">
{{include file="section_title.tpl" title=$notif_header}}
{{if $tabs }}{{include file="common_tabs.tpl"}}{{/if}}
<div class="notif-network-wrapper">
{{* The "show ignored" link *}}
{{if $notif_show_lnk}}<a href="{{$notif_show_lnk.href}}" id="notifications-show-hide-link">{{$notif_show_lnk.text}}</a>{{/if}}
{{* The notifications *}}
{{if $notif_content}}
<ul class="notif-network-list media-list">
{{foreach $notif_content as $notification}}
<li>{{$notification nofilter}}</li>
{{/foreach}}
</ul>
{{/if}}
{{* If no notifications messages available *}}
{{if $notif_nocontent}}
<div class="notif_nocontent">{{$notif_nocontent}}</div>
{{/if}}
</div>
{{* The pager *}}
{{$notif_paginate nofilter}}
</div>

View File

@ -0,0 +1,2 @@
{{include file="notifications/notification.tpl"}}

View File

@ -0,0 +1,2 @@
{{include file="notifications/notification.tpl"}}

View File

@ -0,0 +1,2 @@
{{include file="notifications/notification.tpl"}}

View File

@ -0,0 +1,2 @@
{{include file="notifications/notification.tpl"}}

View File

@ -19,7 +19,7 @@
</form>
</div>
<div class='intro-enty-name'><h4 class="media-heading"><a href="{{$zrl}}">{{$fullname}}</a></h4></div>
<div class="intro-desc"><span class="intro-desc-label">{{$str_notifytype}}</span>&nbsp;{{$notify_type}}</div>
<div class="intro-desc"><span class="intro-desc-label">{{$str_notification_type}}</span>&nbsp;{{$str_type}}</div>
{{* if the contact was suggestested by another contact, the contact who made the suggestion is displayed*}}
{{if $madeby}}<div class="intro-madeby"><span class="intro-madeby-label">{{$lbl_madeby}}</span>&nbsp;<a href="{{$madeby_zrl}}">{{$madeby}}</a></div>{{/if}}

View File

@ -0,0 +1,2 @@
{{include file="notifications/notification.tpl"}}

View File

@ -0,0 +1,2 @@
{{include file="notifications/notification.tpl"}}

View File

@ -0,0 +1,30 @@
<script type="text/javascript" src="../../frameworks/jquery-color/jquery.color.js"></script>
<script type="text/javascript" src="../../js/mod_notifications.js"></script>
<div class="generic-page-wrapper">
{{include file="section_title.tpl" title=$header}}
{{if $tabs }}{{include file="common_tabs.tpl"}}{{/if}}
<div class="notif-network-wrapper">
{{* The "show ignored" link *}}
{{if $showLink}}<a href="{{$showLink.href}}" id="notifications-show-hide-link">{{$showLink.text}}</a>{{/if}}
{{* The notifications *}}
{{if $notifications}}
<ul class="notif-network-list media-list">
{{foreach $notifications as $notification}}
<li>{{$notification nofilter}}</li>
{{/foreach}}
</ul>
{{/if}}
{{* If no notifications messages available *}}
{{if $noContent}}
<div class="notification_nocontent">{{$noContent}}</div>
{{/if}}
</div>
{{* The pager *}}
{{$paginate nofilter}}
</div>

View File

@ -0,0 +1,2 @@
{{include file="notifications/notification.tpl"}}

View File

@ -0,0 +1,2 @@
{{include file="notifications/intros.tpl"}}

View File

@ -1,2 +0,0 @@
{{include file="notify.tpl"}}

View File

@ -1,2 +0,0 @@
{{include file="notify.tpl"}}

View File

@ -1,2 +0,0 @@
{{include file="notify.tpl"}}

View File

@ -1,2 +0,0 @@
{{include file="notify.tpl"}}

View File

@ -1,2 +0,0 @@
{{include file="notify.tpl"}}

View File

@ -1,2 +0,0 @@
{{include file="notify.tpl"}}

View File

@ -1,2 +0,0 @@
{{include file="notify.tpl"}}

View File

@ -169,7 +169,7 @@
<div class="section-content-tools-wrapper">
<div id="settings-notifications">
<div id="settings-notify-desc"><h4>{{$lbl_not}}</h4></div>
<div id="settings-notification-desc"><h4>{{$lbl_not}}</h4></div>
<div class="group">
{{include file="field_intcheckbox.tpl" field=$notify1}}

View File

@ -1,2 +0,0 @@
{{include file="intros.tpl"}}

View File

@ -627,7 +627,7 @@ nav .nav-menu-icon img {
width: 22px;
height: 22px;
}
nav .nav-menu-icon .nav-notify {
nav .nav-menu-icon .nav-notification {
top: 3px;
}
nav .nav-menu {
@ -641,7 +641,7 @@ nav .nav-menu {
nav .nav-menu.selected {
border-bottom: 3px solid #9eabb0;
}
nav .nav-notify {
nav .nav-notification {
display: none;
position: absolute;
background-color: #19aeff;
@ -655,7 +655,7 @@ nav .nav-notify {
min-width: 15px;
text-align: right;
}
nav .nav-notify.show {
nav .nav-notification.show {
display: block;
}
nav #nav-help-link,

View File

@ -627,7 +627,7 @@ nav .nav-menu-icon img {
width: 22px;
height: 22px;
}
nav .nav-menu-icon .nav-notify {
nav .nav-menu-icon .nav-notification {
top: 3px;
}
nav .nav-menu {
@ -641,7 +641,7 @@ nav .nav-menu {
nav .nav-menu.selected {
border-bottom: 3px solid #9eabb0;
}
nav .nav-notify {
nav .nav-notification {
display: none;
position: absolute;
background-color: #dc0000;
@ -655,7 +655,7 @@ nav .nav-notify {
min-width: 15px;
text-align: right;
}
nav .nav-notify.show {
nav .nav-notification.show {
display: block;
}
nav #nav-help-link,

View File

@ -627,7 +627,7 @@ nav .nav-menu-icon img {
width: 22px;
height: 22px;
}
nav .nav-menu-icon .nav-notify {
nav .nav-menu-icon .nav-notification {
top: 3px;
}
nav .nav-menu {
@ -641,7 +641,7 @@ nav .nav-menu {
nav .nav-menu.selected {
border-bottom: 3px solid #9eabb0;
}
nav .nav-notify {
nav .nav-notification {
display: none;
position: absolute;
background-color: #86608e;
@ -655,7 +655,7 @@ nav .nav-notify {
min-width: 15px;
text-align: right;
}
nav .nav-notify.show {
nav .nav-notification.show {
display: block;
}
nav #nav-help-link,

View File

@ -180,7 +180,7 @@ nav {
}
img { width: 22px; height: 22px; }
.nav-notify { top: 3px; }
.nav-notification { top: 3px; }
}
.nav-menu {
@ -196,7 +196,7 @@ nav {
}
.nav-notify {
.nav-notification {
display: none;
position: absolute;
background-color: @NavbarNotifBg;

View File

@ -29,14 +29,14 @@
{{if $nav.network}}
<li id="nav-network-link" class="nav-menu {{$sel.network}}">
<a accesskey="n" class="{{$nav.network.2}}" href="{{$nav.network.0}}" title="{{$nav.network.3}}" >{{$nav.network.1}}</a>
<span id="net-update" class="nav-notify"></span>
<span id="net-update" class="nav-notification"></span>
</li>
{{/if}}
{{if $nav.home}}
<li id="nav-home-link" class="nav-menu {{$sel.home}}">
<a accesskey="p" class="{{$nav.home.2}}" href="{{$nav.home.0}}" title="{{$nav.home.3}}" >{{$nav.home.1}}</a>
<span id="home-update" class="nav-notify"></span>
<span id="home-update" class="nav-notification"></span>
</li>
{{/if}}
@ -45,7 +45,7 @@
<a class="{{$nav.introductions.2}}" href="{{$nav.introductions.0}}" title="{{$nav.introductions.3}}" >
<span class="icon s22 intro">{{$nav.introductions.1}}</a>
</a>
<span id="intro-update" class="nav-notify"></span>
<span id="intro-update" class="nav-notification"></span>
</li>
{{/if}}
@ -54,16 +54,16 @@
<a class="{{$nav.messages.2}}" href="{{$nav.messages.0}}" title="{{$nav.messages.3}}" >
<span class="icon s22 mail">{{$nav.messages.1}}</a>
</a>
<span id="mail-update" class="nav-notify"></span>
<span id="mail-update" class="nav-notification"></span>
</li>
{{/if}}
{{if $nav.notifications}}
<li id="nav-notifications-linkmenu" class="nav-menu-icon"><a accesskey="f" href="{{$nav.notifications.0}}" rel="#nav-notifications-menu" title="{{$nav.notifications.1}}"><span class="icon s22 notify">{{$nav.notifications.1}}</span></a>
<span id="notify-update" class="nav-notify"></span>
<span id="notification-update" class="nav-notification"></span>
<ul id="nav-notifications-menu" class="menu-popup">
<!-- TODO: better icons! -->
<li id="nav-notifications-mark-all" class="toolbar"><a href="#" onclick="notifyMarkAll(); return false;" title="{{$nav.notifications.mark.3}}"><span class="icon s10 edit"></span></a></a><a href="{{$nav.notifications.all.0}}" title="{{$nav.notifications.all.1}}"><span class="icon s10 plugin"></span></a></li>
<li id="nav-notifications-mark-all" class="toolbar"><a href="#" onclick="notificationMarkAll(); return false;" title="{{$nav.notifications.mark.3}}"><span class="icon s10 edit"></span></a></a><a href="{{$nav.notifications.all.0}}" title="{{$nav.notifications.all.1}}"><span class="icon s10 plugin"></span></a></li>
<li class="empty">{{$emptynotifications}}</li>
</ul>
</li>

View File

@ -616,7 +616,7 @@ ul#user-menu-popup li a.nav-sep {
padding-left: 11px;
}
#notify-update {
#notification-update {
background-position: 0px -168px;
}
@ -4211,7 +4211,7 @@ a.active {
margin-right: -20px;
}
.nav-notify {
.nav-notification {
display: none;
position: absolute;
font-size: 10px;
@ -4221,7 +4221,7 @@ a.active {
min-width: 15px;
text-align: right;
}
.nav-notify.show {
.nav-notification.show {
display: block;
}
#nav-notifications-menu {
@ -4353,11 +4353,11 @@ a.active {
filter: alpha(opacity=100);
}
.notify-seen {
.notification-seen {
background: #000000;
}
.notify-seen a {
.notification-seen a {
color: #efefef !important;
}
@ -4604,7 +4604,7 @@ div #datebrowse-sidebar.widget {
}
#settings-activity-desc,
#settings-notify-desc {
#settings-notification-desc {
margin: 10px 10px 10px 0;
font-weight: bold;
}

View File

@ -8,10 +8,10 @@
<!-- {{if $nav.notifications}}<a id="intro-update" class="nav-ajax-update" href="{{$nav.notifications.0}}" title="{{$nav.notifications.1}}"></a>{{/if}} -->
{{if $nav.introductions}}<a id="intro-update" class="nav-ajax-update" href="{{$nav.introductions.0}}" title="{{$nav.introductions.1}}"></a>{{/if}}
{{if $nav.messages}}<a id="mail-update" class="nav-ajax-update" href="{{$nav.messages.0}}" title="{{$nav.messages.1}}"></a>{{/if}}
{{if $nav.notifications}}<a rel="#nav-notifications-menu" id="notify-update" class="nav-ajax-update" href="{{$nav.notifications.0}}" title="{{$nav.notifications.1}}"></a>{{/if}}
{{if $nav.notifications}}<a rel="#nav-notifications-menu" id="notification-update" class="nav-ajax-update" href="{{$nav.notifications.0}}" title="{{$nav.notifications.1}}"></a>{{/if}}
<ul id="nav-notifications-menu" class="menu-popup">
<li id="nav-notifications-mark-all"><a href="#" onclick="notifyMarkAll(); return false;">{{$nav.notifications.mark.3}}</a></li>
<li id="nav-notifications-mark-all"><a href="#" onclick="notificationMarkAll(); return false;">{{$nav.notifications.mark.3}}</a></li>
<li id="nav-notifications-see-all"><a href="{{$nav.notifications.all.0}}">{{$nav.notifications.all.1}}</a></li>
<li class="empty">{{$emptynotifications}}</li>
</ul>
@ -38,7 +38,7 @@
<li><a id="nav-directory-link" class="nav-link {{$nav.directory.2}}" href="{{$nav.directory.0}}">{{$nav.directory.1}}</a></li>
{{if $nav.apps}}<li><a id="nav-apps-link" class="nav-link {{$nav.apps.2}}" href="{{$nav.apps.0}}">{{$nav.apps.1}}</a></li>{{/if}}
{{if $nav.notifications}}<li><a id="nav-notify-link" class="nav-commlink nav-sep {{$nav.notifications.2}}" href="{{$nav.notifications.0}}">{{$nav.notifications.1}}</a></li>{{/if}}
{{if $nav.notifications}}<li><a id="nav-notification-link" class="nav-commlink nav-sep {{$nav.notifications.2}}" href="{{$nav.notifications.0}}">{{$nav.notifications.1}}</a></li>{{/if}}
{{if $nav.messages}}<li><a id="nav-messages-link" class="nav-commlink {{$nav.messages.2}}" href="{{$nav.messages.0}}">{{$nav.messages.1}}</a></li>{{/if}}
{{if $nav.contacts}}<li><a id="nav-contacts-link" class="nav-commlink {{$nav.contacts.2}}" href="{{$nav.contacts.0}}">{{$nav.contacts.1}}</a></li>{{/if}}

View File

@ -29,7 +29,7 @@ nav {
background-color: #1C2126 !important;
}
nav .nav-notify {
nav .nav-notification {
background-color: #2C77AE !important
}
@ -89,11 +89,11 @@ table.smiley-preview{
}
/* Notifications */
li.notify-unseen {
li.notification-unseen {
background-color: #252C33;
}
li.notify-seen {
li.notification-seen {
background-color: #1C2126;
}

View File

@ -23,7 +23,7 @@ nav a:hover,
font: bold 11px/16px Arial;
}
nav .nav-notify {
nav .nav-notification {
/* background-color: #427FED; */
background-color: #CB4437;
top: -3px;
@ -33,7 +33,7 @@ nav .nav-notify {
border-radius: 10px;
}
nav .nav-menu-icon .nav-notify {
nav .nav-menu-icon .nav-notification {
top: 0px;
}

View File

@ -60,7 +60,7 @@ nav a:hover,
font: bold 11px/16px Arial;
}
nav .nav-notify {
nav .nav-notification {
background-color: #CB4437;
top: -3px;
right: -4px;
@ -69,7 +69,7 @@ nav .nav-notify {
border-radius: 10px;
}
nav .nav-menu-icon .nav-notify {
nav .nav-menu-icon .nav-notification {
top: 0px;
}

View File

@ -17,7 +17,7 @@ nav a:hover,
color: #fff;
}
nav .nav-notify {
nav .nav-notification {
background-color: #F80;
top: 0px;
right: -5px;
@ -25,7 +25,7 @@ nav .nav-notify {
border-radius: 5px 5px 5px 5px;
}
nav .nav-menu-icon .nav-notify {
nav .nav-menu-icon .nav-notification {
top: 0px;
}

View File

@ -687,8 +687,8 @@ nav .nav-menu img {
margin-right: 4px;
}
nav .nav-menu > a > .nav-notify,
nav .nav-menu-icon > a > .nav-notify {
nav .nav-menu > a > .nav-notification,
nav .nav-menu-icon > a > .nav-notification {
position: absolute;
top: 3px;
right: -5px;
@ -741,7 +741,7 @@ nav .nav-menu:hover {
margin-right: -20px;
}
nav .nav-notify {
nav .nav-notification {
display: none;
background-color: #F80;
-moz-border-radius: 5px 5px 5px 5px;
@ -753,7 +753,7 @@ nav .nav-notify {
text-align: center;
color: white;
}
nav .nav-notify.show {
nav .nav-notification.show {
display: inline-block;
}
@ -845,9 +845,9 @@ nav #nav-user-linkmenu {
padding: 5px 10px; */
}
.notify-unseen {background-color: #FFF; }
.notification-unseen {background-color: #FFF; }
.notify-seen {
.notification-seen {
background: none repeat scroll 0 0 #EEE;
}

View File

@ -17,7 +17,7 @@
<a accesskey="p" class="{{$nav.home.2}}" href="{{$nav.home.0}}" title="{{$nav.home.3}}" >
<span class="desktop-view">{{$nav.home.1}}</span>
<i class="icon s22 icon-home mobile-view"><span class="sr-only">{{$nav.home.1}}</span></i>
<span id="home-update" class="nav-notify"></span>
<span id="home-update" class="nav-notification"></span>
</a>
</li>
{{/if}}
@ -26,7 +26,7 @@
<a accesskey="n" class="{{$nav.network.2}}" href="{{$nav.network.0}}" title="{{$nav.network.3}}" >
<span class="desktop-view">{{$nav.network.1}}</span>
<i class="icon s22 icon-th mobile-view"><span class="sr-only">{{$nav.network.1}}</span></i>
<span id="net-update" class="nav-notify"></span>
<span id="net-update" class="nav-notification"></span>
</a>
</li>
{{/if}}
@ -56,7 +56,7 @@
<li role="menu" aria-haspopup="true" id="nav-messages-linkmenu" class="nav-menu-icon">
<a href="{{$nav.messages.0}}" title="{{$nav.messages.1}}">
<span class="icon s22 icon-envelope"><span class="sr-only">{{$nav.messages.1}}</span></span>
<span id="mail-update" class="nav-notify"></span>
<span id="mail-update" class="nav-notification"></span>
</a>
</li>
{{/if}}
@ -66,10 +66,10 @@
<li role="menu" aria-haspopup="true" id="nav-notifications-linkmenu" class="nav-menu-icon">
<a title="{{$nav.notifications.1}}">
<span class="icon s22 icon-bell tilted-icon"><span class="sr-only">{{$nav.notifications.1}}</span></span>
<span id="notify-update" class="nav-notify"></span>
<span id="notification-update" class="nav-notification"></span>
</a>
<ul id="nav-notifications-menu" class="menu-popup">
<li role="menuitem" id="nav-notifications-mark-all"><a onclick="notifyMarkAll(); return false;">{{$nav.notifications.mark.1}}</a></li>
<li role="menuitem" id="nav-notifications-mark-all"><a onclick="notificationMarkAll(); return false;">{{$nav.notifications.mark.1}}</a></li>
<li role="menuitem" id="nav-notifications-see-all"><a href="{{$nav.notifications.all.0}}">{{$nav.notifications.all.1}}</a></li>
<li role="menuitem" class="empty">{{$emptynotifications}}</li>
</ul>
@ -78,12 +78,12 @@
{{if $userinfo}}
<li role="menu" aria-haspopup="true" id="nav-user-linkmenu" class="nav-menu">
<a accesskey="u" title="{{$sitelocation}}"><img src="{{$userinfo.icon}}" alt="{{$userinfo.name}}"><span id="nav-user-linklabel">{{$userinfo.name}}</span><span id="intro-update" class="nav-notify"></span></a>
<a accesskey="u" title="{{$sitelocation}}"><img src="{{$userinfo.icon}}" alt="{{$userinfo.name}}"><span id="nav-user-linklabel">{{$userinfo.name}}</span><span id="intro-update" class="nav-notification"></span></a>
<ul id="nav-user-menu" class="menu-popup">
<li role="menuitem"> <a class="{{$nav.search.2}}" href="{{$nav.search.0}}" title="{{$nav.search.3}}" >{{$nav.search.1}}</a> </li>
{{if $nav.introductions}}<li role="menuitem"><a class="{{$nav.introductions.2}}" href="{{$nav.introductions.0}}" title="{{$nav.introductions.3}}" >{{$nav.introductions.1}}</a><span id="intro-update-li" class="nav-notify"></span></li>{{/if}}
{{if $nav.introductions}}<li role="menuitem"><a class="{{$nav.introductions.2}}" href="{{$nav.introductions.0}}" title="{{$nav.introductions.3}}" >{{$nav.introductions.1}}</a><span id="intro-update-li" class="nav-notification"></span></li>{{/if}}
{{if $nav.contacts}}<li role="menuitem"><a class="{{$nav.contacts.2}}" href="{{$nav.contacts.0}}" title="{{$nav.contacts.3}}" >{{$nav.contacts.1}}</a></li>{{/if}}
{{if $nav.messages}}<li role="menuitem"><a class="{{$nav.messages.2}}" href="{{$nav.messages.0}}" title="{{$nav.messages.3}}" >{{$nav.messages.1}} <span id="mail-update-li" class="nav-notify"></span></a></li>{{/if}}
{{if $nav.messages}}<li role="menuitem"><a class="{{$nav.messages.2}}" href="{{$nav.messages.0}}" title="{{$nav.messages.3}}" >{{$nav.messages.1}} <span id="mail-update-li" class="nav-notification"></span></a></li>{{/if}}
{{if $nav.delegation}}<li role="menuitem"><a class="{{$nav.delegation.2}}" href="{{$nav.delegation.0}}" title="{{$nav.delegation.3}}">{{$nav.delegation.1}}</a></li>{{/if}}
{{if $nav.usermenu.1}}<li role="menuitem"><a class="{{$nav.usermenu.1.2}}" href="{{$nav.usermenu.1.0}}" title="{{$nav.usermenu.1.3}}">{{$nav.usermenu.1.1}}</a></li>{{/if}}
{{if $nav.settings}}<li role="menuitem"><a class="{{$nav.settings.2}}" href="{{$nav.settings.0}}" title="{{$nav.settings.3}}">{{$nav.settings.1}}</a></li>{{/if}}