diff options
author | zotlabs <mike@macgirvin.com> | 2016-12-13 17:30:02 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2016-12-13 17:30:02 -0800 |
commit | f111c5c325fec1139ee7ea36c691de452469fa5a (patch) | |
tree | 2d70f0df06bb4959257a523c8ed093aaff18a7f2 /Zotlabs/Module/Mail.php | |
parent | c4a9b61da6a86ca58a850967a81d7e4b39a482f6 (diff) | |
download | volse-hubzilla-f111c5c325fec1139ee7ea36c691de452469fa5a.tar.gz volse-hubzilla-f111c5c325fec1139ee7ea36c691de452469fa5a.tar.bz2 volse-hubzilla-f111c5c325fec1139ee7ea36c691de452469fa5a.zip |
mail preview (basic functionality)
Diffstat (limited to 'Zotlabs/Module/Mail.php')
-rw-r--r-- | Zotlabs/Module/Mail.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index c767c8e56..24ab2017c 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -24,6 +24,39 @@ class Mail extends \Zotlabs\Web\Controller { $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); + + + if($preview) { + if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) { + $attachments = array(); + foreach($match[2] as $mtch) { + $hash = substr($mtch,0,strpos($mtch,',')); + $rev = intval(substr($mtch,strpos($mtch,','))); + $r = attach_by_hash_nodata($hash,get_observer_hash(),$rev); + if($r['success']) { + $attachments[] = array( + 'href' => z_root() . '/attach/' . $r['data']['hash'], + 'length' => $r['data']['filesize'], + 'type' => $r['data']['filetype'], + 'title' => urlencode($r['data']['filename']), + 'revision' => $r['data']['revision'] + ); + } + $body = trim(str_replace($match[1],'',$body)); + } + } +logger('previewing'); + echo json_encode(['preview' => smilies(bbcode($body))]); + killme(); + } + + + + + + + + // If we have a raw string for a recipient which hasn't been auto-filled, // it means they probably aren't in our address book, hence we don't know // if we have permission to send them private messages. |