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.

580 lines
21 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
9 years ago
11 years ago
11 years ago
9 years ago
9 years ago
11 years ago
11 years ago
  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' => proxy_parse_html(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' => zrl($rr['url']),
  205. '$url_label' => t('Profile URL'),
  206. '$knowyou' => $knowyou,
  207. '$approve' => t('Approve'),
  208. '$note' => $rr['note'],
  209. '$ignore' => t('Ignore'),
  210. '$discard' => t('Discard'),
  211. ));
  212. }
  213. }
  214. else
  215. info( t('No introductions.') . EOL);
  216. $o .= replace_macros($notif_tpl, array(
  217. '$notif_header' => t('Notifications'),
  218. '$tabs' => $tabs,
  219. '$notif_content' => $notif_content,
  220. ));
  221. $o .= paginate($a);
  222. return $o;
  223. } else if (($a->argc > 1) && ($a->argv[1] == 'network')) {
  224. $notif_tpl = get_markup_template('notifications.tpl');
  225. $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
  226. `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
  227. `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
  228. FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
  229. WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND `pitem`.`parent` != 0 AND
  230. `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" ,
  231. intval(local_user())
  232. );
  233. $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
  234. $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
  235. $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
  236. $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
  237. $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
  238. $notif_content = '';
  239. if ($r) {
  240. foreach ($r as $it) {
  241. switch($it['verb']){
  242. case ACTIVITY_LIKE:
  243. $notif_content .= replace_macros($tpl_item_likes,array(
  244. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  245. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  246. '$item_image' => $it['author-avatar'],
  247. '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
  248. '$item_when' => relative_date($it['created'])
  249. ));
  250. break;
  251. case ACTIVITY_DISLIKE:
  252. $notif_content .= replace_macros($tpl_item_dislikes,array(
  253. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  254. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  255. '$item_image' => $it['author-avatar'],
  256. '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
  257. '$item_when' => relative_date($it['created'])
  258. ));
  259. break;
  260. case ACTIVITY_FRIEND:
  261. $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
  262. $obj = parse_xml_string($xmlhead.$it['object']);
  263. $it['fname'] = $obj->title;
  264. $notif_content .= replace_macros($tpl_item_friends,array(
  265. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  266. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  267. '$item_image' => $it['author-avatar'],
  268. '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
  269. '$item_when' => relative_date($it['created'])
  270. ));
  271. break;
  272. default:
  273. $item_text = (($it['id'] == $it['parent'])
  274. ? sprintf( t("%s created a new post"), $it['author-name'])
  275. : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
  276. $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
  277. $notif_content .= replace_macros($tpl,array(
  278. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  279. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  280. '$item_image' => $it['author-avatar'],
  281. '$item_text' => $item_text,
  282. '$item_when' => relative_date($it['created'])
  283. ));
  284. }
  285. }
  286. } else {
  287. $notif_content = t('No more network notifications.');
  288. }
  289. $o .= replace_macros($notif_tpl, array(
  290. '$notif_header' => t('Network Notifications'),
  291. '$tabs' => $tabs,
  292. '$notif_content' => $notif_content,
  293. ));
  294. } else if (($a->argc > 1) && ($a->argv[1] == 'system')) {
  295. $notif_tpl = get_markup_template('notifications.tpl');
  296. $not_tpl = get_markup_template('notify.tpl');
  297. require_once('include/bbcode.php');
  298. $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc",
  299. intval(local_user())
  300. );
  301. if (count($r) > 0) {
  302. foreach ($r as $it) {
  303. $notif_content .= replace_macros($not_tpl,array(
  304. '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
  305. '$item_image' => proxy_url($it['photo']),
  306. '$item_text' => strip_tags(bbcode($it['msg'])),
  307. '$item_when' => relative_date($it['date'])
  308. ));
  309. }
  310. } else {
  311. $notif_content .= t('No more system notifications.');
  312. }
  313. $o .= replace_macros($notif_tpl, array(
  314. '$notif_header' => t('System Notifications'),
  315. '$tabs' => $tabs,
  316. '$notif_content' => $notif_content,
  317. ));
  318. } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) {
  319. $notif_tpl = get_markup_template('notifications.tpl');
  320. $myurl = $a->get_baseurl(true) . '/profile/'. $a->user['nickname'];
  321. $myurl = substr($myurl,strpos($myurl,'://')+3);
  322. $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
  323. $diasp_url = str_replace('/profile/','/u/',$myurl);
  324. $sql_extra .= sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ",
  325. dbesc($myurl . '$'),
  326. dbesc($myurl . '\\]'),
  327. dbesc($diasp_url . '\\]')
  328. );
  329. $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
  330. `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
  331. `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
  332. FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
  333. WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1
  334. $sql_extra
  335. AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" ,
  336. intval(local_user())
  337. );
  338. $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
  339. $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
  340. $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
  341. $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
  342. $tpl_item_posts = get_markup_template('notifications_posts_item.tpl');
  343. $notif_content = '';
  344. if (count($r) > 0) {
  345. foreach ($r as $it) {
  346. switch($it['verb']){
  347. case ACTIVITY_LIKE:
  348. $notif_content .= replace_macros($tpl_item_likes,array(
  349. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  350. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  351. '$item_image' => $it['author-avatar'],
  352. '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
  353. '$item_when' => relative_date($it['created'])
  354. ));
  355. break;
  356. case ACTIVITY_DISLIKE:
  357. $notif_content .= replace_macros($tpl_item_dislikes,array(
  358. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  359. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  360. '$item_image' => $it['author-avatar'],
  361. '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
  362. '$item_when' => relative_date($it['created'])
  363. ));
  364. break;
  365. case ACTIVITY_FRIEND:
  366. $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
  367. $obj = parse_xml_string($xmlhead.$it['object']);
  368. $it['fname'] = $obj->title;
  369. $notif_content .= replace_macros($tpl_item_friends,array(
  370. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  371. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  372. '$item_image' => $it['author-avatar'],
  373. '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
  374. '$item_when' => relative_date($it['created'])
  375. ));
  376. break;
  377. default:
  378. $item_text = (($it['id'] == $it['parent'])
  379. ? sprintf( t("%s created a new post"), $it['author-name'])
  380. : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']));
  381. $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments);
  382. $notif_content .= replace_macros($tpl,array(
  383. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  384. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  385. '$item_image' => $it['author-avatar'],
  386. '$item_text' => $item_text,
  387. '$item_when' => relative_date($it['created'])
  388. ));
  389. }
  390. }
  391. } else {
  392. $notif_content = t('No more personal notifications.');
  393. }
  394. $o .= replace_macros($notif_tpl, array(
  395. '$notif_header' => t('Personal Notifications'),
  396. '$tabs' => $tabs,
  397. '$notif_content' => $notif_content,
  398. ));
  399. } else if (($a->argc > 1) && ($a->argv[1] == 'home')) {
  400. $notif_tpl = get_markup_template('notifications.tpl');
  401. $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
  402. `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`,
  403. `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid`
  404. FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
  405. WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
  406. `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 ORDER BY `item`.`created` DESC",
  407. intval(local_user())
  408. );
  409. $tpl_item_likes = get_markup_template('notifications_likes_item.tpl');
  410. $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl');
  411. $tpl_item_friends = get_markup_template('notifications_friends_item.tpl');
  412. $tpl_item_comments = get_markup_template('notifications_comments_item.tpl');
  413. $notif_content = '';
  414. if (count($r) > 0) {
  415. foreach ($r as $it) {
  416. switch($it['verb']){
  417. case ACTIVITY_LIKE:
  418. $notif_content .= replace_macros($tpl_item_likes,array(
  419. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  420. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  421. '$item_image' => $it['author-avatar'],
  422. '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']),
  423. '$item_when' => relative_date($it['created'])
  424. ));
  425. break;
  426. case ACTIVITY_DISLIKE:
  427. $notif_content .= replace_macros($tpl_item_dislikes,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' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']),
  432. '$item_when' => relative_date($it['created'])
  433. ));
  434. break;
  435. case ACTIVITY_FRIEND:
  436. $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
  437. $obj = parse_xml_string($xmlhead.$it['object']);
  438. $it['fname'] = $obj->title;
  439. $notif_content .= replace_macros($tpl_item_friends,array(
  440. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  441. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  442. '$item_image' => $it['author-avatar'],
  443. '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']),
  444. '$item_when' => relative_date($it['created'])
  445. ));
  446. break;
  447. default:
  448. $notif_content .= replace_macros($tpl_item_comments,array(
  449. //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'],
  450. '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'],
  451. '$item_image' => $it['author-avatar'],
  452. '$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']),
  453. '$item_when' => relative_date($it['created'])
  454. ));
  455. }
  456. }
  457. } else {
  458. $notif_content = t('No more home notifications.');
  459. }
  460. $o .= replace_macros($notif_tpl, array(
  461. '$notif_header' => t('Home Notifications'),
  462. '$tabs' => $tabs,
  463. '$notif_content' => $notif_content,
  464. ));
  465. }
  466. $o .= paginate($a);
  467. return $o;
  468. }