restructuring include/message for mail preview
This commit is contained in:
parent
23823811e9
commit
c4a9b61da6
@ -8,7 +8,7 @@ require_once('include/attach.php');
|
|||||||
// send a private message
|
// send a private message
|
||||||
|
|
||||||
|
|
||||||
function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='',$expires = ''){
|
function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE) {
|
||||||
|
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
$is_reply = false;
|
$is_reply = false;
|
||||||
@ -16,6 +16,49 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
|
|||||||
$a = get_app();
|
$a = get_app();
|
||||||
$observer_hash = get_observer_hash();
|
$observer_hash = get_observer_hash();
|
||||||
|
|
||||||
|
if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$match))
|
||||||
|
$attaches = $match[1];
|
||||||
|
|
||||||
|
$attachments = '';
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$jattach = (($attachments) ? json_encode($attachments) : '');
|
||||||
|
|
||||||
|
|
||||||
|
if($preview) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(! $recipient) {
|
if(! $recipient) {
|
||||||
$ret['message'] = t('No recipient provided.');
|
$ret['message'] = t('No recipient provided.');
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -24,12 +67,6 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
|
|||||||
if(! strlen($subject))
|
if(! strlen($subject))
|
||||||
$subject = t('[no subject]');
|
$subject = t('[no subject]');
|
||||||
|
|
||||||
// if(! $expires)
|
|
||||||
// $expires = NULL_DATE;
|
|
||||||
// else
|
|
||||||
// $expires = datetime_convert(date_default_timezone_get(),'UTC',$expires);
|
|
||||||
|
|
||||||
|
|
||||||
if($uid) {
|
if($uid) {
|
||||||
$r = q("select * from channel where channel_id = %d limit 1",
|
$r = q("select * from channel where channel_id = %d limit 1",
|
||||||
intval($uid)
|
intval($uid)
|
||||||
@ -156,31 +193,6 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
|
|||||||
|
|
||||||
$match = false;
|
$match = false;
|
||||||
|
|
||||||
if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$match))
|
|
||||||
$attaches = $match[1];
|
|
||||||
|
|
||||||
$attachments = '';
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$jattach = (($attachments) ? json_encode($attachments) : '');
|
|
||||||
|
|
||||||
if($subject)
|
if($subject)
|
||||||
$subject = str_rot47(base64url_encode($subject));
|
$subject = str_rot47(base64url_encode($subject));
|
||||||
|
Reference in New Issue
Block a user