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