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