mail preview (basic functionality)
This commit is contained in:
parent
c4a9b61da6
commit
f111c5c325
@ -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.
|
||||
|
@ -1146,6 +1146,25 @@ function preview_post() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function preview_mail() {
|
||||
$("#mail-preview").val("1");
|
||||
$("#mail-preview-content").show();
|
||||
$.post(
|
||||
"mail",
|
||||
$("#prvmail-form").serialize(),
|
||||
function(data) {
|
||||
if(data.preview) {
|
||||
$("#mail-preview-content").html(data.preview);
|
||||
$("#mail-preview-content" + " a").click(function() { return false; });
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
$("#mail-preview").val("0");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function unpause() {
|
||||
// unpause auto reloads if they are currently stopped
|
||||
totStopped = false;
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
<input type="hidden" id="inp-prvmail-expires" name="expires" value="{{$defexpire}}" />
|
||||
<input type="hidden" name="media_str" id="jot-media" value="" />
|
||||
<input type="hidden" name="preview" id="mail-preview" value="0" />
|
||||
|
||||
{{if $new}}
|
||||
<div class="form-group">
|
||||
@ -35,9 +36,16 @@
|
||||
</div>
|
||||
|
||||
<div id="prvmail-submit-wrapper" class="form-group">
|
||||
<div id="prvmail-submit" class="pull-right">
|
||||
<div id="prvmail-submit-div" class="pull-right">
|
||||
<button class="btn btn-primary btn-sm" type="submit" id="prvmail-submit" name="submit" value="{{$submit}}">{{$submit}}</button>
|
||||
</div>
|
||||
|
||||
<div id="prvmail-preview-div" class="pull-right">
|
||||
<button class="btn btn-default btn-sm" id="prvmail-preview" title="{{$preview}}" onclick="preview_mail(); return false;"><i class="fa fa-eye"></i></button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div id="prvmail-tools" class="btn-toolbar pull-left">
|
||||
<div class="btn-group">
|
||||
<button id="main-editor-bold" class="btn btn-default btn-sm" title="{{$bold}}" onclick="inserteditortag('b', 'prvmail-text'); return false;">
|
||||
@ -101,6 +109,7 @@
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div id="mail-preview-content" style="display: none;"></div>
|
||||
</form>
|
||||
</div>
|
||||
{{if $new}}
|
||||
|
Reference in New Issue
Block a user