From 77f761972011280c427ba7b3e6523bc428a70d22 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 29 May 2016 19:35:23 +0200 Subject: [PATCH 1/5] Issue 1769: Some enhancements for sending wall mails --- mod/message.php | 11 ++++++----- mod/wallmessage.php | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mod/message.php b/mod/message.php index 8108ff96bd..2d194ed244 100644 --- a/mod/message.php +++ b/mod/message.php @@ -446,9 +446,11 @@ function message_content(&$a) { if($message['from-url'] == $myprofile) { $from_url = $myprofile; $sparkle = ''; - } - else { - $from_url = 'redir/' . $message['contact-id']; + } elseif ($message['contact-id'] != 0) { + $from_url = 'redir/'.$message['contact-id']; + $sparkle = ' sparkle'; + } else { + $from_url = $message['from-url']."?zrl=".urlencode($myprofile); $sparkle = ' sparkle'; } @@ -462,8 +464,7 @@ function message_content(&$a) { $subject_e = template_escape($message['title']); $body_e = template_escape(Smilies::replace(bbcode($message['body']))); $to_name_e = template_escape($message['name']); - } - else { + } else { $from_name_e = $message['from-name']; $subject_e = $message['title']; $body_e = Smilies::replace(bbcode($message['body'])); diff --git a/mod/wallmessage.php b/mod/wallmessage.php index b8859badd3..8642624a47 100644 --- a/mod/wallmessage.php +++ b/mod/wallmessage.php @@ -48,7 +48,7 @@ function wallmessage_post(&$a) { $body = str_replace("\r\n","\n",$body); $body = str_replace("\n\n","\n",$body); - + $ret = send_wallmessage($user, $body, $subject, $replyto); switch($ret){ @@ -68,8 +68,8 @@ function wallmessage_post(&$a) { info( t('Message sent.') . EOL ); } -// goaway($a->get_baseurl() . '/profile/' . $user['nickname']); - + goaway('profile/'.$user['nickname']); + } From 0a617da044845288a975b8590578b8893cd4dc53 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 29 May 2016 21:29:26 +0200 Subject: [PATCH 2/5] 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}}
  • From e4ec867df3377acbec6325e7023b814129981d31 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 29 May 2016 22:02:31 +0200 Subject: [PATCH 3/5] 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; From d22d36be7d05d8589a876db6364f79a9589fc06e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 29 May 2016 22:13:08 +0200 Subject: [PATCH 4/5] Now with correct url --- include/identity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/identity.php b/include/identity.php index 2cb3bfd4c2..580539c071 100644 --- a/include/identity.php +++ b/include/identity.php @@ -264,7 +264,7 @@ function profile_sidebar($profile, $block = 0) { if ($r) { $remote_url = $r[0]["url"]; $message_path = preg_replace("=(.*)/profile/(.*)=ism", "$1/message/new/", $remote_url); - $wallmessage_link = $message_path.base64_encode($remote_url); + $wallmessage_link = $message_path.base64_encode($profile["addr"]); } } else { $wallmessage = false; From 7e6598f2c01dc25b9420309dac1ec84160f21a03 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 30 May 2016 07:18:25 +0200 Subject: [PATCH 5/5] Adopted the changes to the other themes as well. --- view/theme/decaf-mobile/templates/profile_vcard.tpl | 2 +- view/theme/duepuntozero/templates/profile_vcard.tpl | 2 +- view/theme/frio/templates/profile_vcard.tpl | 2 +- view/theme/frost-mobile/templates/profile_vcard.tpl | 2 +- view/theme/frost/templates/profile_vcard.tpl | 2 +- view/theme/quattro/templates/profile_vcard.tpl | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/view/theme/decaf-mobile/templates/profile_vcard.tpl b/view/theme/decaf-mobile/templates/profile_vcard.tpl index 6e097c62bf..0ce464dbf5 100644 --- a/view/theme/decaf-mobile/templates/profile_vcard.tpl +++ b/view/theme/decaf-mobile/templates/profile_vcard.tpl @@ -41,7 +41,7 @@
  • {{$connect}}
  • {{/if}} {{if $wallmessage}} -
  • {{$wallmessage}}
  • +
  • {{$wallmessage}}
  • {{/if}} diff --git a/view/theme/duepuntozero/templates/profile_vcard.tpl b/view/theme/duepuntozero/templates/profile_vcard.tpl index bd2e92f9e4..1b084ba872 100644 --- a/view/theme/duepuntozero/templates/profile_vcard.tpl +++ b/view/theme/duepuntozero/templates/profile_vcard.tpl @@ -47,7 +47,7 @@ {{/if}} {{/if}} {{if $wallmessage}} -
  • {{$wallmessage}}
  • +
  • {{$wallmessage}}
  • {{/if}} {{if $subscribe_feed}}
  • {{$subscribe_feed}}
  • diff --git a/view/theme/frio/templates/profile_vcard.tpl b/view/theme/frio/templates/profile_vcard.tpl index 50b03bad11..e0babdc3a5 100644 --- a/view/theme/frio/templates/profile_vcard.tpl +++ b/view/theme/frio/templates/profile_vcard.tpl @@ -49,7 +49,7 @@ {{/if}} {{if $wallmessage}} diff --git a/view/theme/frost/templates/profile_vcard.tpl b/view/theme/frost/templates/profile_vcard.tpl index 1a0c39a826..26730f8253 100644 --- a/view/theme/frost/templates/profile_vcard.tpl +++ b/view/theme/frost/templates/profile_vcard.tpl @@ -43,7 +43,7 @@
  • {{$connect}}
  • {{/if}} {{if $wallmessage}} -
  • {{$wallmessage}}
  • +
  • {{$wallmessage}}
  • {{/if}} {{if $subscribe_feed}}
  • {{$subscribe_feed}}
  • diff --git a/view/theme/quattro/templates/profile_vcard.tpl b/view/theme/quattro/templates/profile_vcard.tpl index f4eae78d2b..ca702380d2 100644 --- a/view/theme/quattro/templates/profile_vcard.tpl +++ b/view/theme/quattro/templates/profile_vcard.tpl @@ -73,7 +73,7 @@ {{/if}} {{/if}} {{if $wallmessage}} -
  • {{$wallmessage}}
  • +
  • {{$wallmessage}}
  • {{/if}} {{if $subscribe_feed}}
  • {{$subscribe_feed}}