]> git.mxchange.org Git - friendica.git/commitdiff
Better detection for remote user
authorMichael Vogel <icarus@dabo.de>
Sun, 29 May 2016 20:02:31 +0000 (22:02 +0200)
committerMichael Vogel <icarus@dabo.de>
Sun, 29 May 2016 20:02:31 +0000 (22:02 +0200)
include/identity.php

index 3e1d831d5bc55f333f4af90b62abf4aa7b8992ff..2cb3bfd4c2c8a24ea9cc0c77be61f5ee1b04393f 100644 (file)
@@ -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;