diff --git a/boot.php b/boot.php index 8434d34c70..adfeeb415f 100644 --- a/boot.php +++ b/boot.php @@ -1896,31 +1896,6 @@ function is_site_admin() { return false; } - -function load_contact_links($uid) { - - $a = get_app(); - - $ret = array(); - - if(! $uid || x($a->contacts,'empty')) - return; - - $r = q("SELECT `id`,`network`,`url`,`thumb`, `rel` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `thumb` != ''", - intval($uid) - ); - if(count($r)) { - foreach($r as $rr){ - $url = normalise_link($rr['url']); - $ret[$url] = $rr; - } - } else - $ret['empty'] = true; - - $a->contacts = $ret; - return; -} - /** * @brief Returns querystring as string from a mapped array. * diff --git a/include/api.php b/include/api.php index 488e858445..f32dc97c6c 100644 --- a/include/api.php +++ b/include/api.php @@ -270,8 +270,6 @@ api_login($a); } - load_contact_links(api_user()); - logger('API call for ' . $a->user['username'] . ': ' . $a->query_string); logger('API parameters: ' . print_r($_REQUEST,true)); diff --git a/include/conversation.php b/include/conversation.php index 8bbd57dbbf..18bc94074f 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -495,8 +495,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { else $return_url = $_SESSION['return_url'] = $a->query_string; - load_contact_links(local_user()); - $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview); call_hooks('conversation_start',$cb); @@ -618,13 +616,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { else $profile_avatar = $item['author-avatar']; - // This was the old method. We leave it here at the moment - //$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); - //if(($normalised != 'mailbox') && (x($a->contacts[$normalised]))) - // $profile_avatar = $a->contacts[$normalised]['thumb']; - //else - // $profile_avatar = $a->remove_baseurl(((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb'])); - $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location',$locate); @@ -821,15 +812,7 @@ function best_link_url($item,&$sparkle,$ssl_state = false) { $clean_url = normalise_link($item['author-link']); - if((local_user()) && (local_user() == $item['uid'])) { - if(isset($a->contacts) && x($a->contacts,$clean_url)) { - if($a->contacts[$clean_url]['network'] === NETWORK_DFRN) { - $best_url = 'redir/'.$a->contacts[$clean_url]['id']; - $sparkle = true; - } else - $best_url = $a->contacts[$clean_url]['url']; - } - } elseif (local_user()) { + if (local_user()) { $r = q("SELECT `id` FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `nurl` = '%s' LIMIT 1", dbesc(NETWORK_DFRN), intval(local_user()), dbesc(normalise_link($clean_url))); if ($r) { @@ -854,11 +837,9 @@ function item_photo_menu($item){ $ssl_state = false; - if(local_user()) { + if(local_user()) $ssl_state = true; - if(! count($a->contacts)) - load_contact_links(local_user()); - } + $sub_link=""; $poke_link=""; $contact_url=""; @@ -866,6 +847,7 @@ function item_photo_menu($item){ $status_link=""; $photos_link=""; $posts_link=""; + $network = ""; if((local_user()) && local_user() == $item['uid'] && $item['parent'] == $item['id'] && (! $item['self'])) { $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; @@ -876,46 +858,32 @@ function item_photo_menu($item){ if($profile_link === 'mailbox') $profile_link = ''; + $cid = 0; + $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"]; + } + if($sparkle) { - $cid = intval(basename($profile_link)); - $status_link = $profile_link . "?url=status"; - $photos_link = $profile_link . "?url=photos"; - $profile_link = $profile_link . "?url=profile"; - $pm_url = 'message/new/' . $cid; + $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(local_user() && local_user() == $item['uid'] && link_compare($item['url'],$item['author-link'])) { - $cid = $item['contact-id']; - } else { - $r = q("SELECT `id`, `network` 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"]; - if ($r[0]["network"] == NETWORK_DIASPORA) - $pm_url = 'message/new/' . $cid; - - } else - $cid = 0; - } - } - if(($cid) && (! $item['self'])) { - $poke_link = 'poke/?f=&c=' . $cid; - $contact_url = 'contacts/' . $cid; - $posts_link = 'contacts/' . $cid . '/posts'; - - $clean_url = normalise_link($item['author-link']); - - if((local_user()) && (local_user() == $item['uid'])) { - if(isset($a->contacts) && x($a->contacts,$clean_url)) { - if($a->contacts[$clean_url]['network'] === NETWORK_DIASPORA) { - $pm_url = 'message/new/' . $cid; - } - } - } + 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 (local_user()) { @@ -929,10 +897,10 @@ function item_photo_menu($item){ t("Send PM") => $pm_url ); - if ($a->contacts[$clean_url]['network'] === NETWORK_DFRN) + if ($network == NETWORK_DFRN) $menu[t("Poke")] = $poke_link; - if ((($cid == 0) OR ($a->contacts[$clean_url]['rel'] == CONTACT_IS_FOLLOWER)) AND + 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 diff --git a/mod/content.php b/mod/content.php index cecdfd0001..71ed927636 100644 --- a/mod/content.php +++ b/mod/content.php @@ -423,12 +423,6 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { else $profile_avatar = $item['author-avatar']; - //$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); - //if(($normalised != 'mailbox') && (x($a->contacts[$normalised]))) - // $profile_avatar = $a->contacts[$normalised]['thumb']; - //else - // $profile_avatar = $a->remove_baseurl(((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb'])); - $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location',$locate); @@ -801,12 +795,6 @@ function render_content(&$a, $items, $mode, $update, $preview = false) { else $profile_avatar = $item['author-avatar']; - //$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); - //if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) - // $profile_avatar = $a->contacts[$normalised]['thumb']; - //else - // $profile_avatar = $a->remove_baseurl(((strlen($item['author-avatar']) && $diff_author) ? $item['author-avatar'] : $thumb)); - $like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : ''); diff --git a/object/Item.php b/object/Item.php index a27ff32f9c..9dc35e82f1 100644 --- a/object/Item.php +++ b/object/Item.php @@ -157,13 +157,6 @@ class Item extends BaseObject { else $profile_avatar = $item['author-avatar']; - // This was the old method. We leave it here at the moment - //$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); - //if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) - // $profile_avatar = $a->contacts[$normalised]['thumb']; - //else - // $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->remove_baseurl($this->get_data_value('thumb'))); - $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location',$locate); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));