Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

582 lines
21 KiB

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