]> git.mxchange.org Git - friendica.git/blob - mod/notifications.php
notifications.php: reduce code duplication
[friendica.git] / mod / notifications.php
1 <?php
2 include_once("include/NotificationsManager.php");
3 include_once("include/bbcode.php");
4 include_once("include/contact_selectors.php");
5 include_once("include/Scrape.php");
6
7 function notifications_post(&$a) {
8
9         if(! local_user()) {
10                 goaway(z_root());
11         }
12
13         $request_id = (($a->argc > 1) ? $a->argv[1] : 0);
14
15         if($request_id === "all")
16                 return;
17
18         if($request_id) {
19
20                 $r = q("SELECT * FROM `intro` WHERE `id` = %d  AND `uid` = %d LIMIT 1",
21                         intval($request_id),
22                         intval(local_user())
23                 );
24
25                 if(count($r)) {
26                         $intro_id = $r[0]['id'];
27                         $contact_id = $r[0]['contact-id'];
28                 }
29                 else {
30                         notice( t('Invalid request identifier.') . EOL);
31                         return;
32                 }
33
34                 // If it is a friend suggestion, the contact is not a new friend but an existing friend
35                 // that should not be deleted.
36
37                 $fid = $r[0]['fid'];
38
39                 if($_POST['submit'] == t('Discard')) {
40                         $r = q("DELETE FROM `intro` WHERE `id` = %d",
41                                 intval($intro_id)
42                         );
43                         if(! $fid) {
44
45                                 // The check for blocked and pending is in case the friendship was already approved
46                                 // and we just want to get rid of the now pointless notification
47
48                                 $r = q("DELETE FROM `contact` WHERE `id` = %d AND `uid` = %d AND `self` = 0 AND `blocked` = 1 AND `pending` = 1",
49                                         intval($contact_id),
50                                         intval(local_user())
51                                 );
52                         }
53                         goaway('notifications/intros');
54                 }
55                 if($_POST['submit'] == t('Ignore')) {
56                         $r = q("UPDATE `intro` SET `ignore` = 1 WHERE `id` = %d",
57                                 intval($intro_id));
58                         goaway('notifications/intros');
59                 }
60         }
61 }
62
63 function notifications_content(&$a) {
64
65         if(! local_user()) {
66                 notice( t('Permission denied.') . EOL);
67                 return;
68         }
69
70         nav_set_selected('notifications');
71
72         $json = (($a->argc > 1 && $a->argv[$a->argc - 1] === 'json') ? true : false);
73
74         $nm = new NotificationsManager();
75
76         $o = '';
77         // get the nav tabs for the notification pages
78         $tabs = $nm->getTabs();
79         $notif_content = array();
80
81         if( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
82                 nav_set_selected('introductions');
83
84                 if(($a->argc > 2) && ($a->argv[2] == 'all'))
85                         $sql_extra = '';
86                 else
87                         $sql_extra = " AND `ignore` = 0 ";
88
89                 $notif_header = t('Notifications');
90                 $notif_tpl = get_markup_template('notifications.tpl');
91
92                 $notif_ignored_lnk .= '<a href="' . ((strlen($sql_extra)) ? 'notifications/intros/all' : 'notifications/intros' ) . '" id="notifications-show-hide-link" >'
93                         . ((strlen($sql_extra)) ? t('Show Ignored Requests') : t('Hide Ignored Requests')) . '</a></div>' . "\r\n";
94
95                 $r = q("SELECT COUNT(*) AS `total` FROM `intro`
96                         WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ",
97                                 intval($_SESSION['uid'])
98                 );
99                 if($r && count($r)) {
100                         $a->set_pager_total($r[0]['total']);
101                         $a->set_pager_itemspage(20);
102                 }
103
104                 /// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact
105
106                 $r = q("SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*, `fcontact`.`name` AS `fname`,`fcontact`.`url` AS `furl`,`fcontact`.`photo` AS `fphoto`,`fcontact`.`request` AS `frequest`,
107                                 `gcontact`.`location` AS `glocation`, `gcontact`.`about` AS `gabout`,
108                                 `gcontact`.`keywords` AS `gkeywords`, `gcontact`.`gender` AS `ggender`,
109                                 `gcontact`.`network` AS `gnetwork`
110                         FROM `intro`
111                                 LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id`
112                                 LEFT JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl`
113                                 LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
114                         WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ",
115                                 intval($_SESSION['uid']));
116
117                 if(($r !== false) && (count($r))) {
118
119                         $sugg = get_markup_template('suggestions.tpl');
120                         $tpl = get_markup_template("intros.tpl");
121
122                         foreach($r as $rr) {
123
124                                 if($rr['fid']) {
125
126                                         $return_addr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : ''));
127
128                                         $notif_content[] = replace_macros($sugg, array(
129                                                 '$str_notifytype' => t('Notification type: '),
130                                                 '$notify_type' => t('Friend Suggestion'),
131                                                 '$intro_id' => $rr['intro_id'],
132                                                 '$madeby' => sprintf( t('suggested by %s'),$rr['name']),
133                                                 '$contact_id' => $rr['contact-id'],
134                                                 '$photo' => ((x($rr,'fphoto')) ? proxy_url($rr['fphoto'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
135                                                 '$fullname' => $rr['fname'],
136                                                 '$url' => zrl($rr['furl']),
137                                                 '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''),
138                                                 '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')),
139
140                                                 '$knowyou' => $knowyou,
141                                                 '$approve' => t('Approve'),
142                                                 '$note' => $rr['note'],
143                                                 '$request' => $rr['frequest'] . '?addr=' . $return_addr,
144                                                 '$ignore' => t('Ignore'),
145                                                 '$discard' => t('Discard'),
146
147                                         ));
148
149                                         continue;
150
151                                 }
152                                 $friend_selected = (($rr['network'] !== NETWORK_OSTATUS) ? ' checked="checked" ' : ' disabled ');
153                                 $fan_selected = (($rr['network'] === NETWORK_OSTATUS) ? ' checked="checked" disabled ' : '');
154                                 $dfrn_tpl = get_markup_template('netfriend.tpl');
155
156                                 $knowyou   = '';
157                                 $dfrn_text = '';
158
159                                 if($rr['network'] === NETWORK_DFRN || $rr['network'] === NETWORK_DIASPORA) {
160                                         if($rr['network'] === NETWORK_DFRN) {
161                                                 $lbl_knowyou = t('Claims to be known to you: ');
162                                                 $knowyou = (($rr['knowyou']) ? t('yes') : t('no'));
163                                                 $helptext = t('Shall your connection be bidirectional or not? "Friend" implies that you allow to read and you subscribe to their posts. "Fan/Admirer" means that you allow to read but you do not want to read theirs. Approve as: ');
164                                         } else {
165                                                 $knowyou = '';
166                                                 $helptext = t('Shall your connection be bidirectional or not? "Friend" implies that you allow to read and you subscribe to their posts. "Sharer" means that you allow to read but you do not want to read theirs. Approve as: ');
167                                         }
168
169                                         $dfrn_text = replace_macros($dfrn_tpl,array(
170                                                 '$intro_id' => $rr['intro_id'],
171                                                 '$friend_selected' => $friend_selected,
172                                                 '$fan_selected' => $fan_selected,
173                                                 '$approve_as' => $helptext,
174                                                 '$as_friend' => t('Friend'),
175                                                 '$as_fan' => (($rr['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Fan/Admirer'))
176                                         ));
177                                 }
178
179                                 $header = $rr["name"];
180
181                                 $ret = probe_url($rr["url"]);
182
183                                 if ($rr['gnetwork'] == "")
184                                         $rr['gnetwork'] = $ret["network"];
185
186                                 if ($ret["addr"] != "")
187                                         $header .= " <".$ret["addr"].">";
188
189                                 $header .= " (".network_to_name($rr['gnetwork'], $rr['url']).")";
190
191                                 // Don't show these data until you are connected. Diaspora is doing the same.
192                                 if($rr['gnetwork'] === NETWORK_DIASPORA) {
193                                         $rr['glocation'] = "";
194                                         $rr['gabout'] = "";
195                                         $rr['ggender'] = "";
196                                 }
197
198                                 $notif_content[] = replace_macros($tpl, array(
199                                         '$header' => htmlentities($header),
200                                         '$str_notifytype' => t('Notification type: '),
201                                         '$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')),
202                                         '$dfrn_text' => $dfrn_text,
203                                         '$dfrn_id' => $rr['issued-id'],
204                                         '$uid' => $_SESSION['uid'],
205                                         '$intro_id' => $rr['intro_id'],
206                                         '$contact_id' => $rr['contact-id'],
207                                         '$photo' => ((x($rr,'photo')) ? proxy_url($rr['photo'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"),
208                                         '$fullname' => $rr['name'],
209                                         '$location' => bbcode($rr['glocation'], false, false),
210                                         '$location_label' => t('Location:'),
211                                         '$about' => bbcode($rr['gabout'], false, false),
212                                         '$about_label' => t('About:'),
213                                         '$keywords' => $rr['gkeywords'],
214                                         '$keywords_label' => t('Tags:'),
215                                         '$gender' => $rr['ggender'],
216                                         '$gender_label' => t('Gender:'),
217                                         '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''),
218                                         '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')),
219                                         '$url' => $rr['url'],
220                                         '$zrl' => zrl($rr['url']),
221                                         '$url_label' => t('Profile URL'),
222                                         '$addr' => $rr['addr'],
223                                         '$lbl_knowyou' => $lbl_knowyou,
224                                         '$lbl_network' => t('Network:'),
225                                         '$network' => network_to_name($rr['gnetwork'], $rr['url']),
226                                         '$knowyou' => $knowyou,
227                                         '$approve' => t('Approve'),
228                                         '$note' => $rr['note'],
229                                         '$ignore' => t('Ignore'),
230                                         '$discard' => t('Discard'),
231
232                                 ));
233                         }
234                 }
235                 else
236                         info( t('No introductions.') . EOL);
237
238         } else if (($a->argc > 1) && ($a->argv[1] == 'network')) {
239
240                 $notif_header = t('Network Notifications');
241                 $notif_tpl = get_markup_template('notifications.tpl');
242
243                 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
244                                 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
245                                 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
246                                 FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
247                                 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND `pitem`.`parent` != 0 AND
248                                  `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" ,
249                         intval(local_user())
250                 );
251
252 //              $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
253 //              $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
254 //              $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
255 //              $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
256 //              $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
257
258                 if ($r) {
259
260                         $notifs = array(
261                                 'notifications' => $r,
262                                 'ident' => 'network',
263                         );
264
265 //                      foreach ($r as $it) {
266 //                              switch($it['verb']){
267 //                                      case ACTIVITY_LIKE:
268 //                                              $notif_content[] = replace_macros($tpl_item_likes,array(
269 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
270 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
271 //                                                      '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
272 //                                                      '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
273 //                                                      '$item_when' => relative_date($it['created'])
274 //                                              ));
275 //                                              break;
276 //
277 //                                      case ACTIVITY_DISLIKE:
278 //                                              $notif_content[] = replace_macros($tpl_item_dislikes,array(
279 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
280 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
281 //                                                      '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
282 //                                                      '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
283 //                                                      '$item_when' => relative_date($it['created'])
284 //                                              ));
285 //                                              break;
286 //
287 //                                      case ACTIVITY_FRIEND:
288 //
289 //                                              $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
290 //                                              $obj = parse_xml_string($xmlhead.$it['object']);
291 //                                              $it['fname'] = $obj->title;
292 //
293 //                                              $notif_content[] = replace_macros($tpl_item_friends,array(
294 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
295 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
296 //                                                      '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
297 //                                                      '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
298 //                                                      '$item_when' => relative_date($it['created'])
299 //                                              ));
300 //                                              break;
301 //
302 //                                      default:
303 //                                              $item_text = (($it['id'] == $it['parent'])
304 //                                                      ? sprintf( t("%s created a new post"), $it['author-name'])
305 //                                                      : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
306 //                                              $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
307 //
308 //                                              $notif_content[] = replace_macros($tpl,array(
309 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
310 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
311 //                                                      '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
312 //                                                      '$item_text' => $item_text,
313 //                                                      '$item_when' => relative_date($it['created'])
314 //                                              ));
315 //                              }
316 //                      }
317
318                 } else {
319
320                         $notif_nocontent = t('No more network notifications.');
321                 }
322
323         } else if (($a->argc > 1) && ($a->argv[1] == 'system')) {
324
325                 $notif_header = t('System Notifications');
326                 $notif_tpl = get_markup_template('notifications.tpl');
327
328                 $not_tpl = get_markup_template('notify.tpl');
329                 require_once('include/bbcode.php');
330
331                 $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc",
332                         intval(local_user())
333                 );
334
335                 if (count($r) > 0) {
336 //                      foreach ($r as $it) {
337 //                              $notif_content[] = replace_macros($not_tpl,array(
338 //                                      '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
339 //                                      '$item_image' => proxy_url($it['photo'], false, PROXY_SIZE_MICRO),
340 //                                      '$item_text' => strip_tags(bbcode($it['msg'])),
341 //                                      '$item_when' => relative_date($it['date'])
342 //                              ));
343 //                      }
344                         $notifs = array(
345                                 'notifications' => $r,
346                                 'ident' => 'system',
347                         );
348
349                 } else {
350                         $notif_nocontent = t('No more system notifications.');
351                 }
352
353         } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) {
354
355                 $notif_header = t('Personal Notifications');
356                 $notif_tpl = get_markup_template('notifications.tpl');
357
358                 $myurl = $a->get_baseurl(true) . '/profile/'. $a->user['nickname'];
359                 $myurl = substr($myurl,strpos($myurl,'://')+3);
360                 $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
361                 $diasp_url = str_replace('/profile/','/u/',$myurl);
362                 $sql_extra .= sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ",
363                         dbesc($myurl . '$'),
364                         dbesc($myurl . '\\]'),
365                         dbesc($diasp_url . '\\]')
366                 );
367
368
369                 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
370                                 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
371                                 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
372                                 FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
373                                 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1
374                                 $sql_extra
375                                 AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" ,
376                         intval(local_user())
377                 );
378
379 //              $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
380 //              $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
381 //              $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
382 //              $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
383 //              $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
384
385                 if (count($r) > 0) {
386                         $notifs =array(
387                                 'notifications' => $r,
388                                 'ident' => 'personal'
389                         );
390
391
392 //                      foreach ($r as $it) {
393 //                              switch($it['verb']){
394 //                                      case ACTIVITY_LIKE:
395 //                                              $notif_content[] = replace_macros($tpl_item_likes,array(
396 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
397 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
398 //                                                      '$item_image' => $it['author-avatar'],
399 //                                                      '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
400 //                                                      '$item_when' => relative_date($it['created'])
401 //                                              ));
402 //                                              break;
403 //
404 //                                      case ACTIVITY_DISLIKE:
405 //                                              $notif_content[] = replace_macros($tpl_item_dislikes,array(
406 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
407 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
408 //                                                      '$item_image' => $it['author-avatar'],
409 //                                                      '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
410 //                                                      '$item_when' => relative_date($it['created'])
411 //                                              ));
412 //                                              break;
413 //
414 //                                      case ACTIVITY_FRIEND:
415 //
416 //                                              $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
417 //                                              $obj = parse_xml_string($xmlhead.$it['object']);
418 //                                              $it['fname'] = $obj->title;
419 //
420 //                                              $notif_content[] = replace_macros($tpl_item_friends,array(
421 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
422 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
423 //                                                      '$item_image' => $it['author-avatar'],
424 //                                                      '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
425 //                                                      '$item_when' => relative_date($it['created'])
426 //                                              ));
427 //                                              break;
428 //
429 //                                      default:
430 //                                              $item_text = (($it['id'] == $it['parent'])
431 //                                                      ? sprintf( t("%s created a new post"), $it['author-name'])
432 //                                                      : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
433 //                                              $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
434 //
435 //                                              $notif_content[] = replace_macros($tpl,array(
436 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
437 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
438 //                                                      '$item_image' => $it['author-avatar'],
439 //                                                      '$item_text' => $item_text,
440 //                                                      '$item_when' => relative_date($it['created'])
441 //                                              ));
442 //                              }
443 //                      }
444
445                 } else {
446
447                         $notif_nocontent = t('No more personal notifications.');
448                 }
449
450         } else if (($a->argc > 1) && ($a->argv[1] == 'home')) {
451
452                 $notif_header = t('Home Notifications');
453                 $notif_tpl = get_markup_template('notifications.tpl');
454
455                 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
456                                 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
457                                 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
458                                 FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
459                                 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
460                                  `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 ORDER BY `item`.`created` DESC",
461                         intval(local_user())
462                 );
463
464 //              $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
465 //              $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
466 //              $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
467 //              $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
468
469                 if (count($r) > 0) {
470
471                         $notifs = array(
472                                 'notifications' => $r,
473                                 'ident' => 'home',
474                         );
475
476 //                      foreach ($r as $it) {
477 //                              switch($it['verb']){
478 //                                      case ACTIVITY_LIKE:
479 //                                              $notif_content[] = replace_macros($tpl_item_likes,array(
480 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
481 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
482 //                                                      '$item_image' => $it['author-avatar'],
483 //                                                      '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
484 //                                                      '$item_when' => relative_date($it['created'])
485 //                                              ));
486 //
487 //                                              break;
488 //                                      case ACTIVITY_DISLIKE:
489 //                                              $notif_content[] = replace_macros($tpl_item_dislikes,array(
490 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
491 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
492 //                                                      '$item_image' => $it['author-avatar'],
493 //                                                      '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
494 //                                                      '$item_when' => relative_date($it['created'])
495 //                                              ));
496 //
497 //                                              break;
498 //                                      case ACTIVITY_FRIEND:
499 //
500 //                                              $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
501 //                                              $obj = parse_xml_string($xmlhead.$it['object']);
502 //                                              $it['fname'] = $obj->title;
503 //
504 //                                              $notif_content[] = replace_macros($tpl_item_friends,array(
505 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
506 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
507 //                                                      '$item_image' => $it['author-avatar'],
508 //                                                      '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
509 //                                                      '$item_when' => relative_date($it['created'])
510 //                                              ));
511 //
512 //                                              break;
513 //                                      default:
514 //                                              $notif_content[] = replace_macros($tpl_item_comments,array(
515 //                                                      //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
516 //                                                      '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
517 //                                                      '$item_image' => $it['author-avatar'],
518 //                                                      '$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']),
519 //                                                      '$item_when' => relative_date($it['created'])
520 //                                              ));
521 //                              }
522 //                      }
523
524                 } else {
525                         $notif_nocontent = t('No more home notifications.');
526                 }
527
528         }
529
530         if(count($notifs['notifications']) > 0 )
531                 $notif_content =$nm->format ($notifs);
532
533         $o .= replace_macros($notif_tpl, array(
534                 '$notif_header' => $notif_header,
535                 '$tabs' => $tabs,
536                 '$notif_content' => $notif_content,
537                 '$notif_nocontent' => $notif_nocontent,
538                 '$notif_ignored_lnk' => $notif_ignored_lnk,
539         ));
540
541         $o .= paginate($a);
542         return $o;
543 }