From c229223e0106673ea77bbd7813d875b0b7b919c9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 4 Oct 2015 12:08:23 +0200 Subject: private mail: if receiver is not in abook provide only his webbie to the form --- mod/mail.php | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) (limited to 'mod') diff --git a/mod/mail.php b/mod/mail.php index 0f905f1da..02fe080de 100644 --- a/mod/mail.php +++ b/mod/mail.php @@ -185,56 +185,41 @@ function mail_content(&$a) { $a->page['htmlhead'] .= $header; - $preselect = (isset($a->argv[2])?array($a->argv[2]):false); - $prename = $preurl = $preid = ''; + $prename = ''; + $preid = ''; if(x($_REQUEST,'hash')) { + $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_xchan = '%s' limit 1", intval(local_channel()), dbesc($_REQUEST['hash']) ); - if($r) { - $prename = $r[0]['xchan_name']; - $preurl = $r[0]['xchan_url']; - $preid = $r[0]['abook_xchan']; - $preselect = array($preid); + if(!$r) { + $r = q("select * from xchan where xchan_hash = '%s' and xchan_network = 'zot' limit 1", + dbesc($_REQUEST['hash']) + ); } - } - - if($preselect) { - $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash - where abook_channel = %d and abook_id = %d limit 1", - intval(local_channel()), - intval(argv(2)) - ); if($r) { - $prename = $r[0]['xchan_name']; + $prename = (($r[0]['abook_id']) ? $r[0]['xchan_name'] : $r[0]['xchan_addr']); $preurl = $r[0]['xchan_url']; - $preid = $r[0]['abook_xchan']; + $preid = (($r[0]['abook_id']) ? ($r[0]['xchan_hash']) : ''); + } + else { + notice( t('Requested channel is not in this network') . EOL ); } - } - - $prefill = (($preselect) ? $prename : ''); - if(! $prefill) { - if(array_key_exists('to',$_REQUEST)) - $prefill = $_REQUEST['to']; } - // the ugly select box - - //$select = contact_select('messageto','message-to-select', $preselect, 4, true, false, false, 10); - $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl,array( '$new' => true, '$header' => t('Send Private Message'), '$to' => t('To:'), '$showinputs' => 'true', - '$prefill' => $prefill, + '$prefill' => $prename, '$autocomp' => $autocomp, '$preid' => $preid, '$subject' => t('Subject:'), @@ -367,7 +352,7 @@ function mail_content(&$a) { '$subject' => t('Subject:'), '$subjtxt' => $message['title'], '$readonly' => 'readonly="readonly"', - '$yourmessage' => sprintf(t('Your message for %s'), $message[$recp]['xchan_name']), + '$yourmessage' => sprintf(t('Your message for %s (%s):'), $message[$recp]['xchan_name'], $message[$recp]['xchan_addr']), '$text' => '', '$select' => $select, '$parent' => $message['parent_mid'], -- cgit v1.2.3