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