1
1
Fork 0

Fix Issue #2803 - Hovercard view profile link and public directory link

- Change "Edit Contact" link to "View Contact" in `include/Contact.php`
and `include/conversation.php`
- Add zrl parameter to public directory on single user instances
- Improved formatting of modified functions
This commit is contained in:
Hypolite Petovan 2016-10-22 22:49:12 -04:00
parent 5201bbac7e
commit 4b0e76f3b7
3 changed files with 192 additions and 199 deletions

View file

@ -159,7 +159,7 @@ function mark_for_death($contact) {
}
else {
/// @todo
/// @todo
/// We really should send a notification to the owner after 2-3 weeks
/// so they won't be surprised when the contact vanishes and can take
/// remedial action if this was a serious mistake or glitch
@ -288,84 +288,88 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
return($profile);
}
if(! function_exists('contact_photo_menu')){
function contact_photo_menu($contact, $uid = 0) {
if (! function_exists('contact_photo_menu')) {
function contact_photo_menu($contact, $uid = 0)
{
$a = get_app();
$contact_url="";
$pm_url="";
$status_link="";
$photos_link="";
$posts_link="";
$contact_drop_link = "";
$poke_link="";
$contact_url = '';
$pm_url = '';
$status_link = '';
$photos_link = '';
$posts_link = '';
$contact_drop_link = '';
$poke_link = '';
if ($uid == 0)
if ($uid == 0) {
$uid = local_user();
}
if ($contact["uid"] != $uid) {
if ($contact['uid'] != $uid) {
if ($uid == 0) {
$profile_link = zrl($contact['url']);
$menu = Array('profile' => array(t("View Profile"), $profile_link, true));
$menu = Array('profile' => array(t('View Profile'), $profile_link, true));
return $menu;
}
$r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `network` = '%s' AND `uid` = %d",
dbesc($contact["nurl"]), dbesc($contact["network"]), intval($uid));
if ($r)
dbesc($contact['nurl']), dbesc($contact['network']), intval($uid));
if ($r) {
return contact_photo_menu($r[0], $uid);
else {
} else {
$profile_link = zrl($contact['url']);
$connlnk = 'follow/?url='.$contact['url'];
$menu = Array(
'profile' => array(t("View Profile"), $profile_link, true),
'follow' => array(t("Connect/Follow"), $connlnk, true)
);
$menu = array(
'profile' => array(t('View Profile'), $profile_link, true),
'follow' => array(t('Connect/Follow'), $connlnk, true)
);
return $menu;
}
}
$sparkle = false;
if($contact['network'] === NETWORK_DFRN) {
if ($contact['network'] === NETWORK_DFRN) {
$sparkle = true;
$profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
}
else
} else {
$profile_link = $contact['url'];
if($profile_link === 'mailbox')
$profile_link = '';
if($sparkle) {
$status_link = $profile_link . "?url=status";
$photos_link = $profile_link . "?url=photos";
$profile_link = $profile_link . "?url=profile";
}
if (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA)))
$pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
if ($profile_link === 'mailbox') {
$profile_link = '';
}
if ($contact["network"] == NETWORK_DFRN)
if ($sparkle) {
$status_link = $profile_link . '?url=status';
$photos_link = $profile_link . '?url=photos';
$profile_link = $profile_link . '?url=profile';
}
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
$pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
}
if ($contact['network'] == NETWORK_DFRN) {
$poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['id'];
}
$contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
$posts_link = $a->get_baseurl() . "/contacts/" . $contact['id'] . '/posts';
$contact_drop_link = $a->get_baseurl() . "/contacts/" . $contact['id'] . '/drop?confirm=1';
$posts_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/posts';
$contact_drop_link = $a->get_baseurl() . '/contacts/' . $contact['id'] . '/drop?confirm=1';
/**
* menu array:
* "name" => [ "Label", "link", (bool)Should the link opened in a new tab? ]
*/
$menu = Array(
$menu = array(
'status' => array(t("View Status"), $status_link, true),
'profile' => array(t("View Profile"), $profile_link, true),
'photos' => array(t("View Photos"), $photos_link,true),
'network' => array(t("Network Posts"), $posts_link,false),
'edit' => array(t("Edit Contact"), $contact_url, false),
'photos' => array(t("View Photos"), $photos_link, true),
'network' => array(t("Network Posts"), $posts_link, false),
'edit' => array(t("View Contact"), $contact_url, false),
'drop' => array(t("Drop Contact"), $contact_drop_link, false),
'pm' => array(t("Send PM"), $pm_url, false),
'poke' => array(t("Poke"), $poke_link, false),
@ -378,9 +382,11 @@ function contact_photo_menu($contact, $uid = 0) {
$menucondensed = array();
foreach ($menu AS $menuname=>$menuitem)
if ($menuitem[1] != "")
foreach ($menu AS $menuname => $menuitem) {
if ($menuitem[1] != '') {
$menucondensed[$menuname] = $menuitem;
}
}
return $menucondensed;
}}

View file

@ -903,79 +903,86 @@ function best_link_url($item,&$sparkle,$ssl_state = false) {
}
if(! function_exists('item_photo_menu')){
function item_photo_menu($item){
if (! function_exists('item_photo_menu')) {
function item_photo_menu($item)
{
$ssl_state = false;
if(local_user())
if(local_user()) {
$ssl_state = true;
}
$sub_link="";
$poke_link="";
$contact_url="";
$pm_url="";
$status_link="";
$photos_link="";
$posts_link="";
$network = "";
$sub_link = '';
$poke_link = '';
$contact_url = '';
$pm_url = '';
$status_link = '';
$photos_link = '';
$posts_link = '';
$network = '';
if((local_user()) && local_user() == $item['uid'] && $item['parent'] == $item['id'] && (! $item['self'])) {
if ((local_user()) && local_user() == $item['uid'] && $item['parent'] == $item['id'] && (! $item['self'])) {
$sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;';
}
$sparkle = false;
$profile_link = best_link_url($item,$sparkle,$ssl_state);
if($profile_link === 'mailbox')
$profile_link = best_link_url($item, $sparkle, $ssl_state);
if ($profile_link === 'mailbox') {
$profile_link = '';
}
$cid = 0;
$network = "";
$network = '';
$rel = 0;
$r = q("SELECT `id`, `network`, `rel` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1",
intval(local_user()), dbesc(normalise_link($item['author-link'])));
if ($r) {
$cid = $r[0]["id"];
$network = $r[0]["network"];
$rel = $r[0]["rel"];
$cid = $r[0]['id'];
$network = $r[0]['network'];
$rel = $r[0]['rel'];
}
if($sparkle) {
$status_link = $profile_link."?url=status";
$photos_link = $profile_link."?url=photos";
$profile_link = $profile_link."?url=profile";
$status_link = $profile_link . '?url=status';
$photos_link = $profile_link . '?url=photos';
$profile_link = $profile_link . '?url=profile';
$zurl = '';
} else
} else {
$profile_link = zrl($profile_link);
}
if($cid && !$item['self']) {
$poke_link = 'poke/?f=&c='.$cid;
$contact_url = 'contacts/'.$cid;
$posts_link = 'contacts/'.$cid.'/posts';
if ($cid && !$item['self']) {
$poke_link = 'poke/?f=&c=' . $cid;
$contact_url = 'contacts/' . $cid;
$posts_link = 'contacts/' . $cid . '/posts';
if (in_array($network, array(NETWORK_DFRN, NETWORK_DIASPORA)))
$pm_url = 'message/new/'.$cid;
if (in_array($network, array(NETWORK_DFRN, NETWORK_DIASPORA))) {
$pm_url = 'message/new/' . $cid;
}
}
if (local_user()) {
$menu = Array(
t("Follow Thread") => $sub_link,
t("View Status") => $status_link,
t("View Profile") => $profile_link,
t("View Photos") => $photos_link,
t("Network Posts") => $posts_link,
t("Edit Contact") => $contact_url,
t("Send PM") => $pm_url
t('Follow Thread') => $sub_link,
t('View Status') => $status_link,
t('View Profile') => $profile_link,
t('View Photos') => $photos_link,
t('Network Posts') => $posts_link,
t('View Contact') => $contact_url,
t('Send PM') => $pm_url
);
if ($network == NETWORK_DFRN)
if ($network == NETWORK_DFRN) {
$menu[t("Poke")] = $poke_link;
}
if ((($cid == 0) OR ($rel == CONTACT_IS_FOLLOWER)) AND
in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA)))
$menu[t("Connect/Follow")] = "follow?url=".urlencode($item['author-link']);
} else
$menu = array(t("View Profile") => $item['author-link']);
in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
$menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
}
} else {
$menu = array(t('View Profile') => $item['author-link']);
}
$args = array('item' => $item, 'menu' => $menu);
@ -983,13 +990,14 @@ function item_photo_menu($item){
$menu = $args['menu'];
$o = "";
foreach($menu as $k=>$v){
if(strpos($v,'javascript:') === 0) {
$v = substr($v,11);
$o .= "<li role=\"menuitem\"><a onclick=\"$v\">$k</a></li>\n";
$o = '';
foreach ($menu as $k => $v) {
if (strpos($v, 'javascript:') === 0) {
$v = substr($v, 11);
$o .= '<li role="menuitem"><a onclick="' . $v . '">' . $k . '</a></li>' . PHP_EOL;
} elseif ($v!='') {
$o .= '<li role="menuitem"><a href="' . $v . '">' . $k . '</a></li>' . PHP_EOL;
}
elseif ($v!="") $o .= "<li role=\"menuitem\"><a href=\"$v\">$k</a></li>\n";
}
return $o;
}}

View file

@ -44,180 +44,159 @@ function nav(&$a) {
}
function nav_info(&$a) {
function nav_info(&$a)
{
$ssl_state = ((local_user()) ? true : false);
/*
*
* Our network is distributed, and as you visit friends some of the
* sites look exactly the same - it isn't always easy to know where you are.
* Display the current site location as a navigation aid.
*
*/
$myident = ((is_array($a->user) && isset($a->user['nickname'])) ? $a->user['nickname'] . '@' : '');
$sitelocation = $myident . substr($a->get_baseurl($ssl_state),strpos($a->get_baseurl($ssl_state),'//') + 2 );
// nav links: array of array('href', 'text', 'extra css classes', 'title')
$nav = Array();
$nav = array();
/*
* Display login or logout
*/
$nav['usermenu']=array();
// Display login or logout
$nav['usermenu'] = array();
$userinfo = null;
if(local_user()) {
$nav['logout'] = Array('logout',t('Logout'), "", t('End this session'));
if (local_user()) {
$nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
// user menu
$nav['usermenu'][] = Array('profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations'));
$nav['usermenu'][] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
$nav['usermenu'][] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
$nav['usermenu'][] = Array('videos/' . $a->user['nickname'], t('Videos'), "", t('Your videos'));
$nav['usermenu'][] = Array('events/', t('Events'), "", t('Your events'));
$nav['usermenu'][] = Array('notes/', t('Personal notes'), "", t('Your personal notes'));
$nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
$nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
$nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
$nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
$nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
$nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
// user info
$r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
$r = q("SELECT `micro` FROM `contact` WHERE `uid` = %d AND `self` = 1", intval($a->user['uid']));
$userinfo = array(
'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : "images/person-48.jpg"),
'icon' => (count($r) ? $a->remove_baseurl($r[0]['micro']) : 'images/person-48.jpg'),
'name' => $a->user['username'],
);
}
else {
$nav['login'] = Array('login',t('Login'), ($a->module == 'login'?'selected':''), t('Sign in'));
} else {
$nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
}
/*
* "Home" should also take you home from an authenticated remote profile connection
*/
// "Home" should also take you home from an authenticated remote profile connection
$homelink = get_my_url();
if(! $homelink)
if (! $homelink) {
$homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
}
if(($a->module != 'home') && (! (local_user())))
$nav['home'] = array($homelink, t('Home'), "", t('Home Page'));
if (($a->module != 'home') && (! (local_user()))) {
$nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
}
if(($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user()))
$nav['register'] = array('register',t('Register'), "", t('Create an account'));
if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
$nav['register'] = array('register', t('Register'), '', t('Create an account'));
}
$help_url = 'help';
if(! get_config('system','hide_help'))
$nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'));
if (! get_config('system', 'hide_help')) {
$nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
}
if(count($a->apps)>0)
$nav['apps'] = array('apps', t('Apps'), "", t('Addon applications, utilities, games'));
if (count($a->apps) > 0) {
$nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
}
if (local_user() OR !get_config('system','local_search')) {
$nav['search'] = array('search', t('Search'), "", t('Search site content'));
if (local_user() OR !get_config('system', 'local_search')) {
$nav['search'] = array('search', t('Search'), '', t('Search site content'));
$nav['searchoption'] = array(
t("Full Text"),
t("Tags"),
t("Contacts"));
t('Full Text'),
t('Tags'),
t('Contacts'));
if (get_config('system','poco_local_search'))
$nav['searchoption'][] = t("Forums");
if (get_config('system', 'poco_local_search')) {
$nav['searchoption'][] = t('Forums');
}
}
$gdirpath = 'directory';
if(strlen(get_config('system','singleuser'))) {
$gdir = get_config('system','directory');
if(strlen($gdir))
$gdirpath = $gdir;
if (strlen(get_config('system', 'singleuser'))) {
$gdir = get_config('system', 'directory');
if(strlen($gdir)) {
$gdirpath = zrl($gdir, true);
}
} elseif (get_config('system', 'community_page_style') == CP_USERS_ON_SERVER) {
$nav['community'] = array('community', t('Community'), '', t('Conversations on this site'));
} elseif (get_config('system', 'community_page_style') == CP_GLOBAL_COMMUNITY) {
$nav['community'] = array('community', t('Community'), '', t('Conversations on the network'));
}
elseif(get_config('system','community_page_style') == CP_USERS_ON_SERVER)
$nav['community'] = array('community', t('Community'), "", t('Conversations on this site'));
elseif(get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY)
$nav['community'] = array('community', t('Community'), "", t('Conversations on the network'));
if(local_user())
$nav['events'] = Array('events', t('Events'), "", t('Events and Calendar'));
if (local_user()) {
$nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
}
$nav['directory'] = array($gdirpath, t('Directory'), "", t('People directory'));
$nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
$nav['about'] = Array('friendica', t('Information'), "", t('Information about this friendica instance'));
$nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
/*
*
* The following nav links are only show to logged in users
*
*/
// The following nav links are only show to logged in users
if (local_user()) {
$nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
$nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
if(local_user()) {
$nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
$nav['network'] = array('network', t('Network'), "", t('Conversations from your friends'));
$nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), "", t('Load Network page with no filters'));
$nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), "", t('Your posts and conversations'));
if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
/* only show friend requests for normal pages. Other page types have automatic friendship. */
if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP)))
$nav['introductions'] = array('notifications/intros', t('Introductions'), "", t('Friend Requests'));
if(in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
$nav['notifications'] = array('notifications', t('Notifications'), "", t('Notifications'));
$nav['notifications']['all']=array('notifications/system', t('See all notifications'), "", "");
$nav['notifications']['mark'] = array('', t('Mark as seen'), '',t('Mark all system notifications seen'));
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
// only show friend requests for normal pages. Other page types have automatic friendship.
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
$nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
}
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
$nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
$nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
$nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
}
}
$nav['messages'] = array('message', t('Messages'), "", t('Private mail'));
$nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox'));
$nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox'));
$nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message'));
$nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
$nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
$nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
$nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
if(is_array($a->identities) && count($a->identities) > 1) {
$nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages'));
if (is_array($a->identities) && count($a->identities) > 1) {
$nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
}
$nav['delegations'] = Array('delegate', t('Delegations'), "", t('Delegate Page Management'));
$nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
$nav['settings'] = array('settings', t('Settings'),"", t('Account settings'));
$nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
if(feature_enabled(local_user(),'multi_profiles'))
$nav['profiles'] = array('profiles', t('Profiles'),"", t('Manage/Edit Profiles'));
if (feature_enabled(local_user(), 'multi_profiles')) {
$nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
}
$nav['contacts'] = array('contacts', t('Contacts'),"", t('Manage/edit friends and contacts'));
$nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
}
/*
* Admin page
*/
if (is_site_admin()){
$nav['admin'] = array('admin/', t('Admin'), "", t('Site setup and configuration'));
}
if (is_site_admin()) {
$nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
}
$nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
$nav['navigation'] = array('navigation/', t('Navigation'), "", t('Site map'));
/*
*
* Provide a banner/logo/whatever
*
*/
$banner = get_config('system','banner');
if($banner === false)
// Provide a banner/logo/whatever
$banner = get_config('system', 'banner');
if ($banner === false) {
$banner .= '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
}
call_hooks('nav_info', $nav);
return array(
'sitelocation' => $sitelocation,
'nav' => $nav,