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