From e4ec867df3377acbec6325e7023b814129981d31 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 29 May 2016 22:02:31 +0200 Subject: [PATCH] Better detection for remote user --- include/identity.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/include/identity.php b/include/identity.php index 3e1d831d5b..2cb3bfd4c2 100644 --- a/include/identity.php +++ b/include/identity.php @@ -246,19 +246,26 @@ function profile_sidebar($profile, $block = 0) { else $subscribe_feed = false; - if(get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user())) { + if (remote_user() OR (get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()))) { $wallmessage = t('Message'); + $wallmessage_link = "wallmessage/".$profile["nickname"]; - $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `rel` = %d", - intval($profile['uid']), - dbesc(normalise_link(get_my_url())), - intval(CONTACT_IS_FRIEND)); + if (remote_user()) { + $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `id` = '%s' AND `rel` = %d", + intval($profile['uid']), + intval(remote_user()), + intval(CONTACT_IS_FRIEND)); + } else { + $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `rel` = %d", + intval($profile['uid']), + dbesc(normalise_link(get_my_url())), + intval(CONTACT_IS_FRIEND)); + } if ($r) { - $message_path = preg_replace("=(.*)/profile/(.*)=ism", "$1/message/new/", get_my_url()); - $wallmessage_link = $message_path.base64_encode(get_my_url()); - } else - $wallmessage_link = "wallmessage/".$profile["nickname"]; - + $remote_url = $r[0]["url"]; + $message_path = preg_replace("=(.*)/profile/(.*)=ism", "$1/message/new/", $remote_url); + $wallmessage_link = $message_path.base64_encode($remote_url); + } } else { $wallmessage = false; $wallmessage_link = false; -- 2.39.5