]> git.mxchange.org Git - friendica.git/blobdiff - include/identity.php
Merge pull request #2554 from annando/1606-mention-class
[friendica.git] / include / identity.php
index 888a09ee6ff88c945384a278a1a0c2b4af3f6dc8..580539c07155cbd4e106b08394b2ada65350401b 100644 (file)
@@ -246,10 +246,30 @@ 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');
-       else
+               $wallmessage_link = "wallmessage/".$profile["nickname"];
+
+               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) {
+                       $remote_url = $r[0]["url"];
+                       $message_path = preg_replace("=(.*)/profile/(.*)=ism", "$1/message/new/", $remote_url);
+                       $wallmessage_link = $message_path.base64_encode($profile["addr"]);
+               }
+       } else {
                $wallmessage = false;
+               $wallmessage_link = false;
+       }
 
        // show edit profile to yourself
        if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) {
@@ -386,6 +406,7 @@ function profile_sidebar($profile, $block = 0) {
                '$remoteconnect'  => $remoteconnect,
                '$subscribe_feed' => $subscribe_feed,
                '$wallmessage' => $wallmessage,
+               '$wallmessage_link' => $wallmessage_link,
                '$account_type' => $account_type,
                '$location' => $location,
                '$gender'   => $gender,
@@ -400,7 +421,6 @@ function profile_sidebar($profile, $block = 0) {
                '$contact_block' => $contact_block,
        ));
 
-
        $arr = array('profile' => &$profile, 'entry' => &$o);
 
        call_hooks('profile_sidebar', $arr);