4 use Friendica\Core\NotificationsManager;
5 use Friendica\Core\System;
6 use Friendica\Database\DBM;
8 function notify_init(App $a) {
13 $nm = new NotificationsManager();
15 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
16 $note = $nm->getByID($a->argv[2]);
20 // The friendica client has problems with the GUID. this is some workaround
21 if ($a->is_friendica_app()) {
22 require_once("include/items.php");
23 $urldata = parse_url($note['link']);
24 $guid = basename($urldata["path"]);
25 $itemdata = get_item_id($guid, local_user());
26 if ($itemdata["id"] != 0) {
27 $note['link'] = System::baseUrl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
31 goaway($note['link']);
34 goaway(System::baseUrl(true));
37 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
38 $r = $nm->setAllSeen();
39 $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
46 function notify_content(App $a) {
51 $nm = new NotificationsManager();
53 $notif_tpl = get_markup_template('notifications.tpl');
55 $not_tpl = get_markup_template('notify.tpl');
56 require_once('include/bbcode.php');
58 $r = $nm->getAll(array('seen'=>0));
59 if (DBM::is_result($r) > 0) {
61 $notif_content .= replace_macros($not_tpl,array(
62 '$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
63 '$item_image' => $it['photo'],
64 '$item_text' => strip_tags(bbcode($it['msg'])),
65 '$item_when' => relative_date($it['date'])
69 $notif_content .= t('No more system notifications.');
72 $o .= replace_macros($notif_tpl, array(
73 '$notif_header' => t('System Notifications'),
74 '$tabs' => false, // $tabs,
75 '$notif_content' => $notif_content,