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