]> git.mxchange.org Git - friendica.git/blob - mod/notifications.php
Merge pull request #549 from fermionic/20121222-use-smarty-template-engine
[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 LIMIT 1", 
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 LIMIT 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 LIMIT 1",
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                 ),
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                                         $includes = array(
149                                                 '$field_checkbox' => 'field_checkbox.tpl',
150                                         );
151                                         $includes = set_template_includes($a->theme['template_engine'], $includes);
152
153                                         $notif_content .= replace_macros($sugg,$includes + 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                                         else
188                                                 $knowyou = '';
189                                         $dfrn_text = replace_macros($dfrn_tpl,array(
190                                                 '$intro_id' => $rr['intro_id'],
191                                                 '$friend_selected' => $friend_selected,
192                                                 '$fan_selected' => $fan_selected,
193                                                 '$approve_as' => t('Approve as: '),
194                                                 '$as_friend' => t('Friend'),
195                                                 '$as_fan' => (($rr['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Fan/Admirer'))
196                                         ));
197                                 }                       
198
199                                 $includes = array(
200                                         '$field_checkbox' => 'field_checkbox.tpl',
201                                 );
202                                 $includes = set_template_includes($a->theme['template_engine'], $includes);
203
204                                 $notif_content .= replace_macros($tpl,$includes + array(
205                                         '$str_notifytype' => t('Notification type: '),
206                                         '$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')),
207                                         '$dfrn_text' => $dfrn_text,     
208                                         '$dfrn_id' => $rr['issued-id'],
209                                         '$uid' => $_SESSION['uid'],
210                                         '$intro_id' => $rr['intro_id'],
211                                         '$contact_id' => $rr['contact-id'],
212                                         '$photo' => ((x($rr,'photo')) ? $rr['photo'] : "images/person-175.jpg"),
213                                         '$fullname' => $rr['name'],
214                                         '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''),
215                                         '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')),
216                                         '$url' => zrl($rr['url']),
217                                         '$knowyou' => $knowyou,
218                                         '$approve' => t('Approve'),
219                                         '$note' => $rr['note'],
220                                         '$ignore' => t('Ignore'),
221                                         '$discard' => t('Discard'),
222
223                                 ));
224                         }
225                 }
226                 else
227                         info( t('No introductions.') . EOL);
228
229                 $includes = array(
230                         '$common_tabs' => 'common_tabs.tpl',
231                 );
232                 $includes = set_template_includes($a->theme['template_engine'], $includes);
233
234                 $o .= replace_macros($notif_tpl,$includes + array(
235                         '$notif_header' => t('Notifications'),
236                         '$tabs_data' => $tabs,
237                         '$notif_content' => $notif_content,
238                 ));
239                 
240                 $o .= paginate($a);
241                 return $o;
242                                 
243         } else if (($a->argc > 1) && ($a->argv[1] == 'network')) {
244                 
245                 $notif_tpl = get_markup_template('notifications.tpl');
246                 
247                 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, 
248                                 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, 
249                                 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` 
250                                 FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
251                                 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND `pitem`.`parent` != 0
252                                  `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" ,
253                         intval(local_user())
254                 );
255                 
256                 $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
257                 $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
258                 $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
259                 $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
260                 $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
261                 
262                 $notif_content = '';
263                 
264                 if ($r) {
265                         
266                         foreach ($r as $it) {
267                                 switch($it['verb']){
268                                         case ACTIVITY_LIKE:
269                                                 $notif_content .= replace_macros($tpl_item_likes,array(
270                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
271                                                         '$item_image' => $it['author-avatar'],
272                                                         '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
273                                                         '$item_when' => relative_date($it['created'])
274                                                 ));
275                                                 break;
276                                                 
277                                         case ACTIVITY_DISLIKE:
278                                                 $notif_content .= replace_macros($tpl_item_dislikes,array(
279                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
280                                                         '$item_image' => $it['author-avatar'],
281                                                         '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
282                                                         '$item_when' => relative_date($it['created'])
283                                                 ));
284                                                 break;
285                                                 
286                                         case ACTIVITY_FRIEND:
287                                         
288                                                 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
289                                                 $obj = parse_xml_string($xmlhead.$it['object']);
290                                                 $it['fname'] = $obj->title;
291                                                 
292                                                 $notif_content .= replace_macros($tpl_item_friends,array(
293                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
294                                                         '$item_image' => $it['author-avatar'],
295                                                         '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
296                                                         '$item_when' => relative_date($it['created'])
297                                                 ));
298                                                 break;
299                                                 
300                                         default:
301                                                 $item_text = (($it['id'] == $it['parent'])
302                                                         ? sprintf( t("%s created a new post"), $it['author-name'])
303                                                         : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
304                                                 $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
305
306                                                 $notif_content .= replace_macros($tpl,array(
307                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
308                                                         '$item_image' => $it['author-avatar'],
309                                                         '$item_text' => $item_text,
310                                                         '$item_when' => relative_date($it['created'])
311                                                 ));
312                                 }
313                         }
314                         
315                 } else {
316                         
317                         $notif_content = t('No more network notifications.');
318                 }
319                 
320                 $includes = array(
321                         '$common_tabs' => 'common_tabs.tpl',
322                 );
323                 $includes = set_template_includes($a->theme['template_engine'], $includes);
324
325                 $o .= replace_macros($notif_tpl,$includes + array(
326                         '$notif_header' => t('Network Notifications'),
327                         '$tabs_data' => $tabs,
328                         '$notif_content' => $notif_content,
329                 ));
330                 
331         } else if (($a->argc > 1) && ($a->argv[1] == 'system')) {
332                 
333                 $notif_tpl = get_markup_template('notifications.tpl');
334                 
335                 $not_tpl = get_markup_template('notify.tpl');
336                 require_once('include/bbcode.php');
337
338                 $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc",
339                         intval(local_user())
340                 );
341                 
342                 if (count($r) > 0) {
343                         foreach ($r as $it) {
344                                 $notif_content .= replace_macros($not_tpl,array(
345                                         '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
346                                         '$item_image' => $it['photo'],
347                                         '$item_text' => strip_tags(bbcode($it['msg'])),
348                                         '$item_when' => relative_date($it['date'])
349                                 ));
350                         }
351                 } else {
352                         $notif_content .= t('No more system notifications.');
353                 }
354                 
355                 $includes = array(
356                         '$common_tabs' => 'common_tabs.tpl',
357                 );
358                 $includes = set_template_includes($a->theme['template_engine'], $includes);
359
360                 $o .= replace_macros($notif_tpl,$includes + array(
361                         '$notif_header' => t('System Notifications'),
362                         '$tabs_data' => $tabs,
363                         '$notif_content' => $notif_content,
364                 ));
365
366         } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) {
367                 
368                 $notif_tpl = get_markup_template('notifications.tpl');
369                 
370                 $myurl = $a->get_baseurl(true) . '/profile/'. $a->user['nickname'];
371                 $myurl = substr($myurl,strpos($myurl,'://')+3);
372                 $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
373                 $diasp_url = str_replace('/profile/','/u/',$myurl);
374                 $sql_extra .= sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ",
375                         dbesc($myurl . '$'),
376                         dbesc($myurl . '\\]'),
377                         dbesc($diasp_url . '\\]')
378                 );
379
380
381                 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, 
382                                 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, 
383                                 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` 
384                                 FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
385                                 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 
386                                 $sql_extra
387                                 AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" ,
388                         intval(local_user())
389                 );
390                 
391                 $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
392                 $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
393                 $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
394                 $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
395                 $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
396                 
397                 $notif_content = '';
398                 
399                 if (count($r) > 0) {
400                         
401                         foreach ($r as $it) {
402                                 switch($it['verb']){
403                                         case ACTIVITY_LIKE:
404                                                 $notif_content .= replace_macros($tpl_item_likes,array(
405                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
406                                                         '$item_image' => $it['author-avatar'],
407                                                         '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
408                                                         '$item_when' => relative_date($it['created'])
409                                                 ));
410                                                 break;
411                                                 
412                                         case ACTIVITY_DISLIKE:
413                                                 $notif_content .= replace_macros($tpl_item_dislikes,array(
414                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
415                                                         '$item_image' => $it['author-avatar'],
416                                                         '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
417                                                         '$item_when' => relative_date($it['created'])
418                                                 ));
419                                                 break;
420                                                 
421                                         case ACTIVITY_FRIEND:
422                                         
423                                                 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
424                                                 $obj = parse_xml_string($xmlhead.$it['object']);
425                                                 $it['fname'] = $obj->title;
426                                                 
427                                                 $notif_content .= replace_macros($tpl_item_friends,array(
428                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
429                                                         '$item_image' => $it['author-avatar'],
430                                                         '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
431                                                         '$item_when' => relative_date($it['created'])
432                                                 ));
433                                                 break;
434                                                 
435                                         default:
436                                                 $item_text = (($it['id'] == $it['parent'])
437                                                         ? sprintf( t("%s created a new post"), $it['author-name'])
438                                                         : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
439                                                 $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
440
441                                                 $notif_content .= replace_macros($tpl,array(
442                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
443                                                         '$item_image' => $it['author-avatar'],
444                                                         '$item_text' => $item_text,
445                                                         '$item_when' => relative_date($it['created'])
446                                                 ));
447                                 }
448                         }
449                         
450                 } else {
451                         
452                         $notif_content = t('No more personal notifications.');
453                 }
454                 
455                 $includes = array(
456                         '$common_tabs' => 'common_tabs.tpl',
457                 );
458                 $includes = set_template_includes($a->theme['template_engine'], $includes);
459
460                 $o .= replace_macros($notif_tpl,$includes + array(
461                         '$notif_header' => t('Personal Notifications'),
462                         '$tabs_data' => $tabs,
463                         '$notif_content' => $notif_content,
464                 ));
465                 
466
467
468
469
470
471         } else if (($a->argc > 1) && ($a->argv[1] == 'home')) {
472                 
473                 $notif_tpl = get_markup_template('notifications.tpl');
474                 
475                 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, 
476                                 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, 
477                                 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink` 
478                                 FROM `item` INNER JOIN `item` as `pitem` ON  `pitem`.`id`=`item`.`parent`
479                                 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
480                                  `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 ORDER BY `item`.`created` DESC",
481                         intval(local_user())
482                 );
483                 
484                 $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
485                 $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
486                 $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
487                 $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
488                 
489                 $notif_content = '';
490                 
491                 if (count($r) > 0) {
492                         
493                         foreach ($r as $it) {
494                                 switch($it['verb']){
495                                         case ACTIVITY_LIKE:
496                                                 $notif_content .= replace_macros($tpl_item_likes,array(
497                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
498                                                         '$item_image' => $it['author-avatar'],
499                                                         '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
500                                                         '$item_when' => relative_date($it['created'])
501                                                 ));
502
503                                                 break;
504                                         case ACTIVITY_DISLIKE:
505                                                 $notif_content .= replace_macros($tpl_item_dislikes,array(
506                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
507                                                         '$item_image' => $it['author-avatar'],
508                                                         '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
509                                                         '$item_when' => relative_date($it['created'])
510                                                 ));
511
512                                                 break;
513                                         case ACTIVITY_FRIEND:
514                                         
515                                                 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
516                                                 $obj = parse_xml_string($xmlhead.$it['object']);
517                                                 $it['fname'] = $obj->title;
518                                                 
519                                                 $notif_content .= replace_macros($tpl_item_friends,array(
520                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
521                                                         '$item_image' => $it['author-avatar'],
522                                                         '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
523                                                         '$item_when' => relative_date($it['created'])
524                                                 ));
525
526                                                 break;
527                                         default:
528                                                 $notif_content .= replace_macros($tpl_item_comments,array(
529                                                         '$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
530                                                         '$item_image' => $it['author-avatar'],
531                                                         '$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']),
532                                                         '$item_when' => relative_date($it['created'])
533                                                 ));
534                                 }
535                         }
536                                 
537                 } else {
538                         $notif_content = t('No more home notifications.');
539                 }
540                 
541                 $includes = array(
542                         '$common_tabs' => 'common_tabs.tpl',
543                 );
544                 $includes = set_template_includes($a->theme['template_engine'], $includes);
545
546                 $o .= replace_macros($notif_tpl,$includes + array(
547                         '$notif_header' => t('Home Notifications'),
548                         '$tabs_data' => $tabs,
549                         '$notif_content' => $notif_content,
550                 ));
551         }
552
553         $o .= paginate($a);
554         return $o;
555 }