From 0a617da044845288a975b8590578b8893cd4dc53 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 29 May 2016 21:29:26 +0200 Subject: [PATCH] Wall message can now redirect to your own page if you are connected. --- include/identity.php | 19 ++++++++++++++++--- mod/message.php | 19 ++++++++++++++++--- view/templates/profile_vcard.tpl | 2 +- view/theme/vier/templates/profile_vcard.tpl | 2 +- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/include/identity.php b/include/identity.php index 888a09ee6f..3e1d831d5b 100644 --- a/include/identity.php +++ b/include/identity.php @@ -246,10 +246,23 @@ function profile_sidebar($profile, $block = 0) { else $subscribe_feed = false; - if(get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user())) + if(get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user())) { $wallmessage = t('Message'); - else + + $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 ($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"]; + + } else { $wallmessage = false; + $wallmessage_link = false; + } // show edit profile to yourself if ($profile['uid'] == local_user() && feature_enabled(local_user(),'multi_profiles')) { @@ -386,6 +399,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 +414,6 @@ function profile_sidebar($profile, $block = 0) { '$contact_block' => $contact_block, )); - $arr = array('profile' => &$profile, 'entry' => &$o); call_hooks('profile_sidebar', $arr); diff --git a/mod/message.php b/mod/message.php index 2d194ed244..f0ab7d2ac9 100644 --- a/mod/message.php +++ b/mod/message.php @@ -305,15 +305,29 @@ function message_content(&$a) { $prename = $preurl = $preid = ''; if($preselect) { - $r = q("select name, url, id from contact where uid = %d and id = %d limit 1", + $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval(local_user()), intval($a->argv[2]) ); + if(!$r) { + $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1", + intval(local_user()), + dbesc(normalise_link(base64_decode($a->argv[2]))) + ); + } + if(!$r) { + $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `addr` = '%s' LIMIT 1", + intval(local_user()), + dbesc(base64_decode($a->argv[2])) + ); + } if(count($r)) { $prename = $r[0]['name']; $preurl = $r[0]['url']; $preid = $r[0]['id']; - } + $preselect = array($preid); + } else + $preselect = false; } $prefill = (($preselect) ? $prename : ''); @@ -342,7 +356,6 @@ function message_content(&$a) { '$wait' => t('Please wait'), '$submit' => t('Submit') )); - return $o; } diff --git a/view/templates/profile_vcard.tpl b/view/templates/profile_vcard.tpl index 0a3a13f9dc..0f1cf070c4 100644 --- a/view/templates/profile_vcard.tpl +++ b/view/templates/profile_vcard.tpl @@ -54,7 +54,7 @@ {{/if}} {{/if}} {{if $wallmessage}} -
  • {{$wallmessage}}
  • +
  • {{$wallmessage}}
  • {{/if}} {{if $subscribe_feed}}
  • {{$subscribe_feed}}
  • diff --git a/view/theme/vier/templates/profile_vcard.tpl b/view/theme/vier/templates/profile_vcard.tpl index a3b08947d0..2d7c72f8c8 100644 --- a/view/theme/vier/templates/profile_vcard.tpl +++ b/view/theme/vier/templates/profile_vcard.tpl @@ -65,7 +65,7 @@ {{/if}} {{/if}} {{if $wallmessage}} -
  • {{$wallmessage}}
  • +
  • {{$wallmessage}}
  • {{/if}} {{if $subscribe_feed}}
  • {{$subscribe_feed}}