From 320751660d7f17cd80aa2c5360d25d167b331854 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 27 Jul 2016 19:53:22 +0200 Subject: [PATCH 1/3] frio: intro notifications + some restructuring in core for notifications --- mod/notifications.php | 958 ++++++++++---------- view/templates/intros.tpl | 2 +- view/templates/notifications.tpl | 15 +- view/theme/frio/css/style.css | 50 +- view/theme/frio/js/modal.js | 13 + view/theme/frio/templates/intros.tpl | 54 ++ view/theme/frio/templates/notifications.tpl | 25 + 7 files changed, 643 insertions(+), 474 deletions(-) create mode 100644 view/theme/frio/templates/intros.tpl create mode 100644 view/theme/frio/templates/notifications.tpl diff --git a/mod/notifications.php b/mod/notifications.php index e0f07118f7..ae27de864c 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -59,10 +59,6 @@ function notifications_post(&$a) { } } - - - - function notifications_content(&$a) { if(! local_user()) { @@ -76,6 +72,491 @@ function notifications_content(&$a) { $o = ''; + // get the nav tabs for the notification pages + $tabs = notifications_tabs($a); + $notif_content = array(); + + if( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) { + nav_set_selected('introductions'); + if(($a->argc > 2) && ($a->argv[2] == 'all')) + $sql_extra = ''; + else + $sql_extra = " AND `ignore` = 0 "; + + $notif_tpl = get_markup_template('notifications.tpl'); + + $notif_ignored_lnk .= '' + . ((strlen($sql_extra)) ? t('Show Ignored Requests') : t('Hide Ignored Requests')) . '' . "\r\n"; + + $r = q("SELECT COUNT(*) AS `total` FROM `intro` + WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ", + intval($_SESSION['uid']) + ); + if($r && count($r)) { + $a->set_pager_total($r[0]['total']); + $a->set_pager_itemspage(20); + } + + /// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact + + $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`, + `gcontact`.`location` AS `glocation`, `gcontact`.`about` AS `gabout`, + `gcontact`.`keywords` AS `gkeywords`, `gcontact`.`gender` AS `ggender`, + `gcontact`.`network` AS `gnetwork` + FROM `intro` + LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id` + LEFT JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl` + LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id` + WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ", + intval($_SESSION['uid'])); + + if(($r !== false) && (count($r))) { + + $sugg = get_markup_template('suggestions.tpl'); + $tpl = get_markup_template("intros.tpl"); + + foreach($r as $rr) { + + if($rr['fid']) { + + $return_addr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); + + $notif_content[] = replace_macros($sugg, array( + '$str_notifytype' => t('Notification type: '), + '$notify_type' => t('Friend Suggestion'), + '$intro_id' => $rr['intro_id'], + '$madeby' => sprintf( t('suggested by %s'),$rr['name']), + '$contact_id' => $rr['contact-id'], + '$photo' => ((x($rr,'fphoto')) ? proxy_url($rr['fphoto'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"), + '$fullname' => $rr['fname'], + '$url' => zrl($rr['furl']), + '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), + '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')), + + '$knowyou' => $knowyou, + '$approve' => t('Approve'), + '$note' => $rr['note'], + '$request' => $rr['frequest'] . '?addr=' . $return_addr, + '$ignore' => t('Ignore'), + '$discard' => t('Discard'), + + )); + + continue; + + } + $friend_selected = (($rr['network'] !== NETWORK_OSTATUS) ? ' checked="checked" ' : ' disabled '); + $fan_selected = (($rr['network'] === NETWORK_OSTATUS) ? ' checked="checked" disabled ' : ''); + $dfrn_tpl = get_markup_template('netfriend.tpl'); + + $knowyou = ''; + $dfrn_text = ''; + + if($rr['network'] === NETWORK_DFRN || $rr['network'] === NETWORK_DIASPORA) { + if($rr['network'] === NETWORK_DFRN) { + $lbl_knowyou = t('Claims to be known to you: '); + $knowyou = (($rr['knowyou']) ? t('yes') : t('no')); + $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: '); + } else { + $knowyou = ''; + $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: '); + } + + $dfrn_text = replace_macros($dfrn_tpl,array( + '$intro_id' => $rr['intro_id'], + '$friend_selected' => $friend_selected, + '$fan_selected' => $fan_selected, + '$approve_as' => $helptext, + '$as_friend' => t('Friend'), + '$as_fan' => (($rr['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Fan/Admirer')) + )); + } + + $header = $rr["name"]; + + $ret = probe_url($rr["url"]); + + if ($rr['gnetwork'] == "") + $rr['gnetwork'] = $ret["network"]; + + if ($ret["addr"] != "") + $header .= " <".$ret["addr"].">"; + + $header .= " (".network_to_name($rr['gnetwork'], $rr['url']).")"; + + // Don't show these data until you are connected. Diaspora is doing the same. + if($rr['gnetwork'] === NETWORK_DIASPORA) { + $rr['glocation'] = ""; + $rr['gabout'] = ""; + $rr['ggender'] = ""; + } + + $notif_content[] = replace_macros($tpl, array( + '$header' => htmlentities($header), + '$str_notifytype' => t('Notification type: '), + '$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')), + '$dfrn_text' => $dfrn_text, + '$dfrn_id' => $rr['issued-id'], + '$uid' => $_SESSION['uid'], + '$intro_id' => $rr['intro_id'], + '$contact_id' => $rr['contact-id'], + '$photo' => ((x($rr,'photo')) ? proxy_url($rr['photo'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"), + '$fullname' => $rr['name'], + '$location' => bbcode($rr['glocation'], false, false), + '$location_label' => t('Location:'), + '$about' => bbcode($rr['gabout'], false, false), + '$about_label' => t('About:'), + '$keywords' => $rr['gkeywords'], + '$keywords_label' => t('Tags:'), + '$gender' => $rr['ggender'], + '$gender_label' => t('Gender:'), + '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), + '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')), + '$url' => $rr['url'], + '$zrl' => zrl($rr['url']), + '$url_label' => t('Profile URL'), + '$addr' => $rr['addr'], + '$lbl_knowyou' => $lbl_knowyou, + '$lbl_network' => t('Network:'), + '$network' => network_to_name($rr['gnetwork'], $rr['url']), + '$knowyou' => $knowyou, + '$approve' => t('Approve'), + '$note' => $rr['note'], + '$ignore' => t('Ignore'), + '$discard' => t('Discard'), + + )); + } + } + else + info( t('No introductions.') . EOL); + + $o .= replace_macros($notif_tpl, array( + '$notif_header' => t('Notifications'), + '$tabs' => $tabs, + '$notif_ignored_lnk' => $notif_ignored_lnk, + '$notif_content' => $notif_content, + )); + + $o .= paginate($a); + return $o; + + } else if (($a->argc > 1) && ($a->argv[1] == 'network')) { + + $notif_tpl = get_markup_template('notifications.tpl'); + + $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, + `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, + `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid` + FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent` + WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND `pitem`.`parent` != 0 AND + `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" , + intval(local_user()) + ); + + $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); + $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); + $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); + $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); + $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); + + $notif_content = array(); + + if ($r) { + + foreach ($r as $it) { + switch($it['verb']){ + case ACTIVITY_LIKE: + $notif_content[] = replace_macros($tpl_item_likes,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), + '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']), + '$item_when' => relative_date($it['created']) + )); + break; + + case ACTIVITY_DISLIKE: + $notif_content[] = replace_macros($tpl_item_dislikes,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), + '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']), + '$item_when' => relative_date($it['created']) + )); + break; + + case ACTIVITY_FRIEND: + + $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; + $obj = parse_xml_string($xmlhead.$it['object']); + $it['fname'] = $obj->title; + + $notif_content[] = replace_macros($tpl_item_friends,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), + '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']), + '$item_when' => relative_date($it['created']) + )); + break; + + default: + $item_text = (($it['id'] == $it['parent']) + ? sprintf( t("%s created a new post"), $it['author-name']) + : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname'])); + $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments); + + $notif_content[] = replace_macros($tpl,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), + '$item_text' => $item_text, + '$item_when' => relative_date($it['created']) + )); + } + } + + } else { + + $notif_nocontent = t('No more network notifications.'); + } + + $o .= replace_macros($notif_tpl, array( + '$notif_header' => t('Network Notifications'), + '$tabs' => $tabs, + '$notif_content' => $notif_content, + '$notif_nocontent' => $notif_nocontent, + )); + + } else if (($a->argc > 1) && ($a->argv[1] == 'system')) { + + $notif_tpl = get_markup_template('notifications.tpl'); + + $not_tpl = get_markup_template('notify.tpl'); + require_once('include/bbcode.php'); + + $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc", + intval(local_user()) + ); + + if (count($r) > 0) { + foreach ($r as $it) { + $notif_content[] = replace_macros($not_tpl,array( + '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'], + '$item_image' => proxy_url($it['photo'], false, PROXY_SIZE_MICRO), + '$item_text' => strip_tags(bbcode($it['msg'])), + '$item_when' => relative_date($it['date']) + )); + } + } else { + $notif_nocontent = t('No more system notifications.'); + } + + $o .= replace_macros($notif_tpl, array( + '$notif_header' => t('System Notifications'), + '$tabs' => $tabs, + '$notif_content' => $notif_content, + '$notif_nocontent' => $notif_nocontent, + )); + + } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) { + + $notif_tpl = get_markup_template('notifications.tpl'); + + $myurl = $a->get_baseurl(true) . '/profile/'. $a->user['nickname']; + $myurl = substr($myurl,strpos($myurl,'://')+3); + $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); + $diasp_url = str_replace('/profile/','/u/',$myurl); + $sql_extra .= sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ", + dbesc($myurl . '$'), + dbesc($myurl . '\\]'), + dbesc($diasp_url . '\\]') + ); + + + $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, + `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, + `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid` + FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent` + WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 + $sql_extra + AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" , + intval(local_user()) + ); + + $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); + $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); + $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); + $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); + $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); + + $notif_content = array(); + + if (count($r) > 0) { + + foreach ($r as $it) { + switch($it['verb']){ + case ACTIVITY_LIKE: + $notif_content[] = replace_macros($tpl_item_likes,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => $it['author-avatar'], + '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']), + '$item_when' => relative_date($it['created']) + )); + break; + + case ACTIVITY_DISLIKE: + $notif_content[] = replace_macros($tpl_item_dislikes,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => $it['author-avatar'], + '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']), + '$item_when' => relative_date($it['created']) + )); + break; + + case ACTIVITY_FRIEND: + + $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; + $obj = parse_xml_string($xmlhead.$it['object']); + $it['fname'] = $obj->title; + + $notif_content[] = replace_macros($tpl_item_friends,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => $it['author-avatar'], + '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']), + '$item_when' => relative_date($it['created']) + )); + break; + + default: + $item_text = (($it['id'] == $it['parent']) + ? sprintf( t("%s created a new post"), $it['author-name']) + : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname'])); + $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments); + + $notif_content[] = replace_macros($tpl,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => $it['author-avatar'], + '$item_text' => $item_text, + '$item_when' => relative_date($it['created']) + )); + } + } + + } else { + + $notif_nocontent = t('No more personal notifications.'); + } + + $o .= replace_macros($notif_tpl, array( + '$notif_header' => t('Personal Notifications'), + '$tabs' => $tabs, + '$notif_content' => $notif_content, + '$notif_nocontent' => $notif_nocontent, + )); + + + + + + + } else if (($a->argc > 1) && ($a->argv[1] == 'home')) { + + $notif_tpl = get_markup_template('notifications.tpl'); + + $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, + `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, + `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid` + FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent` + WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND + `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 ORDER BY `item`.`created` DESC", + intval(local_user()) + ); + + $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); + $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); + $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); + $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); + + $notif_content = array(); + + if (count($r) > 0) { + + foreach ($r as $it) { + switch($it['verb']){ + case ACTIVITY_LIKE: + $notif_content[] = replace_macros($tpl_item_likes,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => $it['author-avatar'], + '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']), + '$item_when' => relative_date($it['created']) + )); + + break; + case ACTIVITY_DISLIKE: + $notif_content[] = replace_macros($tpl_item_dislikes,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => $it['author-avatar'], + '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']), + '$item_when' => relative_date($it['created']) + )); + + break; + case ACTIVITY_FRIEND: + + $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; + $obj = parse_xml_string($xmlhead.$it['object']); + $it['fname'] = $obj->title; + + $notif_content[] = replace_macros($tpl_item_friends,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => $it['author-avatar'], + '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']), + '$item_when' => relative_date($it['created']) + )); + + break; + default: + $notif_content[] = replace_macros($tpl_item_comments,array( + //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], + '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], + '$item_image' => $it['author-avatar'], + '$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']), + '$item_when' => relative_date($it['created']) + )); + } + } + + } else { + $notif_nocontent = t('No more home notifications.'); + } + + $o .= replace_macros($notif_tpl, array( + '$notif_header' => t('Home Notifications'), + '$tabs' => $tabs, + '$notif_content' => $notif_content, + '$notif_nocontent' => $notif_nocontent, + )); + } + + $o .= paginate($a); + return $o; +} +/** + * @brief List of pages for the Notifications TabBar + * + * @param app $a The + * @return array with with notifications TabBar data + */ +function notifications_tabs($a) { $tabs = array( array( 'label' => t('System'), @@ -114,470 +595,5 @@ function notifications_content(&$a) { ),*/ /*while I can have notifications for messages, this tablist is not place for message page link */ ); - $o = ""; - - - if( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) { - nav_set_selected('introductions'); - if(($a->argc > 2) && ($a->argv[2] == 'all')) - $sql_extra = ''; - else - $sql_extra = " AND `ignore` = 0 "; - - $notif_tpl = get_markup_template('notifications.tpl'); - - $notif_content .= '' - . ((strlen($sql_extra)) ? t('Show Ignored Requests') : t('Hide Ignored Requests')) . '' . "\r\n"; - - $r = q("SELECT COUNT(*) AS `total` FROM `intro` - WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ", - intval($_SESSION['uid']) - ); - if($r && count($r)) { - $a->set_pager_total($r[0]['total']); - $a->set_pager_itemspage(20); - } - - /// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact - - $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`, - `gcontact`.`location` AS `glocation`, `gcontact`.`about` AS `gabout`, - `gcontact`.`keywords` AS `gkeywords`, `gcontact`.`gender` AS `ggender`, - `gcontact`.`network` AS `gnetwork` - FROM `intro` - LEFT JOIN `contact` ON `contact`.`id` = `intro`.`contact-id` - LEFT JOIN `gcontact` ON `gcontact`.`nurl` = `contact`.`nurl` - LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id` - WHERE `intro`.`uid` = %d $sql_extra AND `intro`.`blocked` = 0 ", - intval($_SESSION['uid'])); - - if(($r !== false) && (count($r))) { - - $sugg = get_markup_template('suggestions.tpl'); - $tpl = get_markup_template("intros.tpl"); - - foreach($r as $rr) { - - if($rr['fid']) { - - $return_addr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); - - $notif_content .= replace_macros($sugg, array( - '$str_notifytype' => t('Notification type: '), - '$notify_type' => t('Friend Suggestion'), - '$intro_id' => $rr['intro_id'], - '$madeby' => sprintf( t('suggested by %s'),$rr['name']), - '$contact_id' => $rr['contact-id'], - '$photo' => ((x($rr,'fphoto')) ? proxy_url($rr['fphoto'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"), - '$fullname' => $rr['fname'], - '$url' => zrl($rr['furl']), - '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), - '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')), - - '$knowyou' => $knowyou, - '$approve' => t('Approve'), - '$note' => $rr['note'], - '$request' => $rr['frequest'] . '?addr=' . $return_addr, - '$ignore' => t('Ignore'), - '$discard' => t('Discard'), - - )); - - continue; - - } - $friend_selected = (($rr['network'] !== NETWORK_OSTATUS) ? ' checked="checked" ' : ' disabled '); - $fan_selected = (($rr['network'] === NETWORK_OSTATUS) ? ' checked="checked" disabled ' : ''); - $dfrn_tpl = get_markup_template('netfriend.tpl'); - - $knowyou = ''; - $dfrn_text = ''; - - if($rr['network'] === NETWORK_DFRN || $rr['network'] === NETWORK_DIASPORA) { - if($rr['network'] === NETWORK_DFRN) { - $knowyou = t('Claims to be known to you: ') . (($rr['knowyou']) ? t('yes') : t('no')); - $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: '); - } else { - $knowyou = ''; - $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: '); - } - - $dfrn_text = replace_macros($dfrn_tpl,array( - '$intro_id' => $rr['intro_id'], - '$friend_selected' => $friend_selected, - '$fan_selected' => $fan_selected, - '$approve_as' => $helptext, - '$as_friend' => t('Friend'), - '$as_fan' => (($rr['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Fan/Admirer')) - )); - } - - $header = $rr["name"]; - - $ret = probe_url($rr["url"]); - - if ($rr['gnetwork'] == "") - $rr['gnetwork'] = $ret["network"]; - - if ($ret["addr"] != "") - $header .= " <".$ret["addr"].">"; - - $header .= " (".network_to_name($rr['gnetwork'], $rr['url']).")"; - - // Don't show these data until you are connected. Diaspora is doing the same. - if($rr['gnetwork'] === NETWORK_DIASPORA) { - $rr['glocation'] = ""; - $rr['gabout'] = ""; - $rr['ggender'] = ""; - } - - $notif_content .= replace_macros($tpl, array( - '$header' => htmlentities($header), - '$str_notifytype' => t('Notification type: '), - '$notify_type' => (($rr['network'] !== NETWORK_OSTATUS) ? t('Friend/Connect Request') : t('New Follower')), - '$dfrn_text' => $dfrn_text, - '$dfrn_id' => $rr['issued-id'], - '$uid' => $_SESSION['uid'], - '$intro_id' => $rr['intro_id'], - '$contact_id' => $rr['contact-id'], - '$photo' => ((x($rr,'photo')) ? proxy_url($rr['photo'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"), - '$fullname' => $rr['name'], - '$location' => bbcode($rr['glocation'], false, false), - '$location_label' => t('Location:'), - '$about' => bbcode($rr['gabout'], false, false), - '$about_label' => t('About:'), - '$keywords' => $rr['gkeywords'], - '$keywords_label' => t('Tags:'), - '$gender' => $rr['ggender'], - '$gender_label' => t('Gender:'), - '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), - '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')), - '$url' => $rr['url'], - '$zrl' => zrl($rr['url']), - '$url_label' => t('Profile URL'), - '$knowyou' => $knowyou, - '$approve' => t('Approve'), - '$note' => $rr['note'], - '$ignore' => t('Ignore'), - '$discard' => t('Discard'), - - )); - } - } - else - info( t('No introductions.') . EOL); - - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - )); - - $o .= paginate($a); - return $o; - - } else if (($a->argc > 1) && ($a->argv[1] == 'network')) { - - $notif_tpl = get_markup_template('notifications.tpl'); - - $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, - `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, - `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid` - FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent` - WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND `pitem`.`parent` != 0 AND - `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" , - intval(local_user()) - ); - - $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); - $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); - $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); - $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); - $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); - - $notif_content = ''; - - if ($r) { - - foreach ($r as $it) { - switch($it['verb']){ - case ACTIVITY_LIKE: - $notif_content .= replace_macros($tpl_item_likes,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), - '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']), - '$item_when' => relative_date($it['created']) - )); - break; - - case ACTIVITY_DISLIKE: - $notif_content .= replace_macros($tpl_item_dislikes,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), - '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']), - '$item_when' => relative_date($it['created']) - )); - break; - - case ACTIVITY_FRIEND: - - $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; - $obj = parse_xml_string($xmlhead.$it['object']); - $it['fname'] = $obj->title; - - $notif_content .= replace_macros($tpl_item_friends,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), - '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']), - '$item_when' => relative_date($it['created']) - )); - break; - - default: - $item_text = (($it['id'] == $it['parent']) - ? sprintf( t("%s created a new post"), $it['author-name']) - : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname'])); - $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments); - - $notif_content .= replace_macros($tpl,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO), - '$item_text' => $item_text, - '$item_when' => relative_date($it['created']) - )); - } - } - - } else { - - $notif_content = t('No more network notifications.'); - } - - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('Network Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - )); - - } else if (($a->argc > 1) && ($a->argv[1] == 'system')) { - - $notif_tpl = get_markup_template('notifications.tpl'); - - $not_tpl = get_markup_template('notify.tpl'); - require_once('include/bbcode.php'); - - $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc", - intval(local_user()) - ); - - if (count($r) > 0) { - foreach ($r as $it) { - $notif_content .= replace_macros($not_tpl,array( - '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'], - '$item_image' => proxy_url($it['photo'], false, PROXY_SIZE_MICRO), - '$item_text' => strip_tags(bbcode($it['msg'])), - '$item_when' => relative_date($it['date']) - )); - } - } else { - $notif_content .= t('No more system notifications.'); - } - - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('System Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - )); - - } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) { - - $notif_tpl = get_markup_template('notifications.tpl'); - - $myurl = $a->get_baseurl(true) . '/profile/'. $a->user['nickname']; - $myurl = substr($myurl,strpos($myurl,'://')+3); - $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); - $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra .= sprintf(" AND ( `item`.`author-link` regexp '%s' or `item`.`tag` regexp '%s' or `item`.`tag` regexp '%s' ) ", - dbesc($myurl . '$'), - dbesc($myurl . '\\]'), - dbesc($diasp_url . '\\]') - ); - - - $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, - `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, - `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid` - FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent` - WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 - $sql_extra - AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC" , - intval(local_user()) - ); - - $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); - $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); - $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); - $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); - $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); - - $notif_content = ''; - - if (count($r) > 0) { - - foreach ($r as $it) { - switch($it['verb']){ - case ACTIVITY_LIKE: - $notif_content .= replace_macros($tpl_item_likes,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => $it['author-avatar'], - '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']), - '$item_when' => relative_date($it['created']) - )); - break; - - case ACTIVITY_DISLIKE: - $notif_content .= replace_macros($tpl_item_dislikes,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => $it['author-avatar'], - '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']), - '$item_when' => relative_date($it['created']) - )); - break; - - case ACTIVITY_FRIEND: - - $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; - $obj = parse_xml_string($xmlhead.$it['object']); - $it['fname'] = $obj->title; - - $notif_content .= replace_macros($tpl_item_friends,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => $it['author-avatar'], - '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']), - '$item_when' => relative_date($it['created']) - )); - break; - - default: - $item_text = (($it['id'] == $it['parent']) - ? sprintf( t("%s created a new post"), $it['author-name']) - : sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname'])); - $tpl = (($it['id'] == $it['parent']) ? $tpl_item_posts : $tpl_item_comments); - - $notif_content .= replace_macros($tpl,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => $it['author-avatar'], - '$item_text' => $item_text, - '$item_when' => relative_date($it['created']) - )); - } - } - - } else { - - $notif_content = t('No more personal notifications.'); - } - - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('Personal Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - )); - - - - - - - } else if (($a->argc > 1) && ($a->argv[1] == 'home')) { - - $notif_tpl = get_markup_template('notifications.tpl'); - - $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, - `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` as `object`, - `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`, `pitem`.`guid` as `pguid` - FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent` - WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND - `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1 ORDER BY `item`.`created` DESC", - intval(local_user()) - ); - - $tpl_item_likes = get_markup_template('notifications_likes_item.tpl'); - $tpl_item_dislikes = get_markup_template('notifications_dislikes_item.tpl'); - $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); - $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); - - $notif_content = ''; - - if (count($r) > 0) { - - foreach ($r as $it) { - switch($it['verb']){ - case ACTIVITY_LIKE: - $notif_content .= replace_macros($tpl_item_likes,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => $it['author-avatar'], - '$item_text' => sprintf( t("%s liked %s's post"), $it['author-name'], $it['pname']), - '$item_when' => relative_date($it['created']) - )); - - break; - case ACTIVITY_DISLIKE: - $notif_content .= replace_macros($tpl_item_dislikes,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => $it['author-avatar'], - '$item_text' => sprintf( t("%s disliked %s's post"), $it['author-name'], $it['pname']), - '$item_when' => relative_date($it['created']) - )); - - break; - case ACTIVITY_FRIEND: - - $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; - $obj = parse_xml_string($xmlhead.$it['object']); - $it['fname'] = $obj->title; - - $notif_content .= replace_macros($tpl_item_friends,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => $it['author-avatar'], - '$item_text' => sprintf( t("%s is now friends with %s"), $it['author-name'], $it['fname']), - '$item_when' => relative_date($it['created']) - )); - - break; - default: - $notif_content .= replace_macros($tpl_item_comments,array( - //'$item_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$it['parent'], - '$item_link' => $a->get_baseurl(true).'/display/'.$it['pguid'], - '$item_image' => $it['author-avatar'], - '$item_text' => sprintf( t("%s commented on %s's post"), $it['author-name'], $it['pname']), - '$item_when' => relative_date($it['created']) - )); - } - } - - } else { - $notif_content = t('No more home notifications.'); - } - - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('Home Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - )); - } - - $o .= paginate($a); - return $o; -} + return $tabs; +} \ No newline at end of file diff --git a/view/templates/intros.tpl b/view/templates/intros.tpl index b9f7f15418..fa823ca71a 100644 --- a/view/templates/intros.tpl +++ b/view/templates/intros.tpl @@ -9,7 +9,7 @@ {{if $gender}}
{{$gender_label}}
{{$gender}}
{{/if}} {{if $keywords}}
{{$keywords_label}}
{{$keywords}}
{{/if}} {{if $about}}
{{$about_label}}
{{$about}}
{{/if}} -
{{$knowyou}}
+
{{$lbl_knowyou}} {{$knowyou}}
{{$note}}
diff --git a/view/templates/notifications.tpl b/view/templates/notifications.tpl index 54f9de0c7a..9c671c2a5b 100644 --- a/view/templates/notifications.tpl +++ b/view/templates/notifications.tpl @@ -5,5 +5,18 @@ {{if $tabs }}{{include file="common_tabs.tpl"}}{{/if}}
- {{$notif_content}} + {{* The "show ignored" link *}} + {{if $notif_ignored_lnk}}{{$notif_ignored_lnk}}{{/if}} + + {{* The notifications *}} + {{if $notif_content}} + {{foreach $notif_content as $notification}} + {{$notification}} + {{/foreach}} + {{/if}} + + {{* If no notifications messages available *}} + {{if $notif_nocontent}} +
{{$notif_nocontent}}
+ {{/if}}
diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index ed264ac2d5..67b209f9ec 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -1798,7 +1798,7 @@ ul.dropdown-menu li:hover { .suggest-content-wrapper, .common-content-wrapper, .allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, .directory-content-wrapper, .manage-content-wrapper, .notes-content-wrapper, -.message-content-wrapper, .apps-content-wrapper, .notifications-content-wrapper, +.message-content-wrapper, .apps-content-wrapper, .admin-content-wrapper, .group-content-wrapper, .viewcontacts-content-wrapper { min-height: calc(100vh - 150px); padding: 15px; @@ -2149,6 +2149,54 @@ td.fc-day { .group { margin-left: 20px; } + +/* Notifications */ +ul.notif-network-list { + margin-left: -15px; + margin-right: -15px; +} +ul.notif-network-list > li { + padding-left: 15px; + padding-right: 15px; +} +.intro-wrapper.media { + overflow: visible; + word-wrap: break-word; + margin-top: 0; +} +.intro-photo-wrapper img.intro-photo { + height:80px; + width: 80px; + border-radius: 4px; +} +.intro-actions { + display: flex; +} +.intro-enty-name h4 { + font-size: 15px !important; +} +.intro-wrapper button.intro-action-link { + opacity: 0.1; + transition: all 0.25s ease-in-out; +} +.intro-wrapper button.intro-action-link, +.intro-wrapper button.intro-action-link:hover { + padding-right: 5px; + padding-left: 5px; + color: #555; +} +ul li:hover .intro-wrapper button.intro-action-link { + opacity: 0.8; + transition: all 0.25s ease-in-out; +} +ul li:hover .intro-wrapper button.intro-action-link:hover { + opacity: 1; +} +.intro-desc-label, .intro-url-label, .intro-network-label, +.intro-location-label, .intro-gender-label, .intro-keywords-label, +.intro-about-label, .intro-knowyou-label { + font-weight: bold; +} /* * Overwriting for transparency and other colors */ diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index b58288318d..b29b8d4caa 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -204,6 +204,19 @@ function addToModal(url) { }); } +// Add a element (by it's id) to a bootstrap modal +function addElmToModal(id) { + var elm = $(id).html(); + var modal = $('#modal').modal(); + + modal + .find('#modal-body') + .append(elm) + .modal.show; + + loadModalTitle(); +} + // function to load the html from the edit post page into // the jot modal function editpost(url) { diff --git a/view/theme/frio/templates/intros.tpl b/view/theme/frio/templates/intros.tpl new file mode 100644 index 0000000000..0b09c2dccb --- /dev/null +++ b/view/theme/frio/templates/intros.tpl @@ -0,0 +1,54 @@ + +
+ + {{* Contact Photo *}} + + +
+ {{* The intro actions like approve, ignore, discard intro*}} + + +
{{$str_notifytype}}{{$notify_type}}
+ + {{* Additional information of the contact *}} +
{{$url_label}}: {{$url}}
+ {{if $network}}
{{$lbl_network}} {{$network}}
{{/if}} + {{if $location}}
{{$location_label}} {{$location}}
{{/if}} + {{if $gender}}
{{$gender_label}} {{$gender}}
{{/if}} + {{if $keywords}}
{{$keywords_label}} {{$keywords}}
{{/if}} + {{if $about}}
{{$about_label}} {{$about}}
{{/if}} +
{{$lbl_knowyou}}{{$knowyou}}
+
{{$note}}
+ + {{* This sections contains special settings for contact approval. We hide it by default and load this section in + a bootstrap modal in the case of approval *}} + +
+
+
diff --git a/view/theme/frio/templates/notifications.tpl b/view/theme/frio/templates/notifications.tpl new file mode 100644 index 0000000000..3729e6f8c2 --- /dev/null +++ b/view/theme/frio/templates/notifications.tpl @@ -0,0 +1,25 @@ + +
+ {{include file="section_title.tpl" title=$notif_header}} + + {{if $tabs }}{{include file="common_tabs.tpl"}}{{/if}} + +
+ {{* The "show ignored" link *}} + {{if $notif_ignored_lnk}}{{$notif_ignored_lnk}}{{/if}} + + {{* The notifications *}} + {{if $notif_content}} + + {{/if}} + + {{* If no notifications messages available *}} + {{if $notif_nocontent}} +
{{$notif_nocontent}}
+ {{/if}} +
+
From 819b374401b54c6506ec8905aa8dc653c3202548 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 27 Jul 2016 21:07:54 +0200 Subject: [PATCH 2/3] notifications.php - move some template creation to the end of the file --- mod/notifications.php | 61 +++++++++---------------------------------- 1 file changed, 13 insertions(+), 48 deletions(-) diff --git a/mod/notifications.php b/mod/notifications.php index ae27de864c..fa2c78cf67 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -78,11 +78,13 @@ function notifications_content(&$a) { if( (($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) { nav_set_selected('introductions'); + if(($a->argc > 2) && ($a->argv[2] == 'all')) $sql_extra = ''; else $sql_extra = " AND `ignore` = 0 "; + $notif_header = t('Notifications'); $notif_tpl = get_markup_template('notifications.tpl'); $notif_ignored_lnk .= '' @@ -231,18 +233,9 @@ function notifications_content(&$a) { else info( t('No introductions.') . EOL); - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('Notifications'), - '$tabs' => $tabs, - '$notif_ignored_lnk' => $notif_ignored_lnk, - '$notif_content' => $notif_content, - )); - - $o .= paginate($a); - return $o; - } else if (($a->argc > 1) && ($a->argv[1] == 'network')) { + $notif_header = t('Network Notifications'); $notif_tpl = get_markup_template('notifications.tpl'); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, @@ -260,8 +253,6 @@ function notifications_content(&$a) { $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); - $notif_content = array(); - if ($r) { foreach ($r as $it) { @@ -322,15 +313,9 @@ function notifications_content(&$a) { $notif_nocontent = t('No more network notifications.'); } - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('Network Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - '$notif_nocontent' => $notif_nocontent, - )); - } else if (($a->argc > 1) && ($a->argv[1] == 'system')) { + $notif_header = t('System Notifications'); $notif_tpl = get_markup_template('notifications.tpl'); $not_tpl = get_markup_template('notify.tpl'); @@ -353,15 +338,9 @@ function notifications_content(&$a) { $notif_nocontent = t('No more system notifications.'); } - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('System Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - '$notif_nocontent' => $notif_nocontent, - )); - } else if (($a->argc > 1) && ($a->argv[1] == 'personal')) { + $notif_header = t('Personal Notifications'); $notif_tpl = get_markup_template('notifications.tpl'); $myurl = $a->get_baseurl(true) . '/profile/'. $a->user['nickname']; @@ -391,8 +370,6 @@ function notifications_content(&$a) { $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); $tpl_item_posts = get_markup_template('notifications_posts_item.tpl'); - $notif_content = array(); - if (count($r) > 0) { foreach ($r as $it) { @@ -453,20 +430,9 @@ function notifications_content(&$a) { $notif_nocontent = t('No more personal notifications.'); } - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('Personal Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - '$notif_nocontent' => $notif_nocontent, - )); - - - - - - } else if (($a->argc > 1) && ($a->argv[1] == 'home')) { + $notif_header = t('Home Notifications'); $notif_tpl = get_markup_template('notifications.tpl'); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, @@ -483,8 +449,6 @@ function notifications_content(&$a) { $tpl_item_friends = get_markup_template('notifications_friends_item.tpl'); $tpl_item_comments = get_markup_template('notifications_comments_item.tpl'); - $notif_content = array(); - if (count($r) > 0) { foreach ($r as $it) { @@ -539,14 +503,15 @@ function notifications_content(&$a) { $notif_nocontent = t('No more home notifications.'); } - $o .= replace_macros($notif_tpl, array( - '$notif_header' => t('Home Notifications'), - '$tabs' => $tabs, - '$notif_content' => $notif_content, - '$notif_nocontent' => $notif_nocontent, - )); } + $o .= replace_macros($notif_tpl, array( + '$notif_header' => $notif_header, + '$tabs' => $tabs, + '$notif_content' => $notif_content, + '$notif_nocontent' => $notif_nocontent, + '$notif_ignored_lnk' => $notif_ignored_lnk, + )); $o .= paginate($a); return $o; } From f7fa5f166b3ffc909af36902ea1b9c2075119262 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sat, 30 Jul 2016 11:03:21 +0200 Subject: [PATCH 3/3] notifications.php: unify label strings --- mod/notifications.php | 10 +++++----- view/templates/intros.tpl | 10 +++++----- view/theme/frio/templates/intros.tpl | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/mod/notifications.php b/mod/notifications.php index fa2c78cf67..f3e7c564ab 100644 --- a/mod/notifications.php +++ b/mod/notifications.php @@ -205,18 +205,18 @@ function notifications_content(&$a) { '$photo' => ((x($rr,'photo')) ? proxy_url($rr['photo'], false, PROXY_SIZE_SMALL) : "images/person-175.jpg"), '$fullname' => $rr['name'], '$location' => bbcode($rr['glocation'], false, false), - '$location_label' => t('Location:'), + '$lbl_location' => t('Location:'), '$about' => bbcode($rr['gabout'], false, false), - '$about_label' => t('About:'), + '$lbl_about' => t('About:'), '$keywords' => $rr['gkeywords'], - '$keywords_label' => t('Tags:'), + '$lbl_keywords' => t('Tags:'), '$gender' => $rr['ggender'], - '$gender_label' => t('Gender:'), + '$lbl_gender' => t('Gender:'), '$hidden' => array('hidden', t('Hide this contact from others'), ($rr['hidden'] == 1), ''), '$activity' => array('activity', t('Post a new friend activity'), (intval(get_pconfig(local_user(),'system','post_newfriend')) ? '1' : 0), t('if applicable')), '$url' => $rr['url'], '$zrl' => zrl($rr['url']), - '$url_label' => t('Profile URL'), + '$lbl_url' => t('Profile URL'), '$addr' => $rr['addr'], '$lbl_knowyou' => $lbl_knowyou, '$lbl_network' => t('Network:'), diff --git a/view/templates/intros.tpl b/view/templates/intros.tpl index fa823ca71a..e3933e3815 100644 --- a/view/templates/intros.tpl +++ b/view/templates/intros.tpl @@ -4,11 +4,11 @@

{{$str_notifytype}} {{$notify_type}}

{{$fullname|escape:'html'}} -
{{$url_label}}
{{$url}}
-{{if $location}}
{{$location_label}}
{{$location}}
{{/if}} -{{if $gender}}
{{$gender_label}}
{{$gender}}
{{/if}} -{{if $keywords}}
{{$keywords_label}}
{{$keywords}}
{{/if}} -{{if $about}}
{{$about_label}}
{{$about}}
{{/if}} +
{{$lbl_url}}
{{$url}}
+{{if $location}}
{{$lbl_location}}
{{$location}}
{{/if}} +{{if $gender}}
{{$lbl_gender}}
{{$gender}}
{{/if}} +{{if $keywords}}
{{$lbl_keywords}}
{{$keywords}}
{{/if}} +{{if $about}}
{{$lbl_about}}
{{$about}}
{{/if}}
{{$lbl_knowyou}} {{$knowyou}}
{{$note}}
diff --git a/view/theme/frio/templates/intros.tpl b/view/theme/frio/templates/intros.tpl index 0b09c2dccb..86c7fc342c 100644 --- a/view/theme/frio/templates/intros.tpl +++ b/view/theme/frio/templates/intros.tpl @@ -20,12 +20,12 @@
{{$str_notifytype}}{{$notify_type}}
{{* Additional information of the contact *}} -
{{$url_label}}: {{$url}}
+
{{$lbl_url}}: {{$url}}
{{if $network}}
{{$lbl_network}} {{$network}}
{{/if}} - {{if $location}}
{{$location_label}} {{$location}}
{{/if}} - {{if $gender}}
{{$gender_label}} {{$gender}}
{{/if}} - {{if $keywords}}
{{$keywords_label}} {{$keywords}}
{{/if}} - {{if $about}}
{{$about_label}} {{$about}}
{{/if}} + {{if $location}}
{{$lbl_location}} {{$location}}
{{/if}} + {{if $gender}}
{{$lbl_gender}} {{$gender}}
{{/if}} + {{if $keywords}}
{{$lbl_keywords}} {{$keywords}}
{{/if}} + {{if $about}}
{{$lbl_about}} {{$about}}
{{/if}}
{{$lbl_knowyou}}{{$knowyou}}
{{$note}}