X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=MessagePreview.php;h=f59cde177e0f2f376661919f83a9a373777494a8;hp=ec47b343d4762987ecf4c6221205ff496f294e0c;hb=refs%2Fheads%2Fwip_alan_T5884_add_photo_to_report;hpb=6db489de3c13740e3c59d13e0cdd5366858cb5e9 diff --git a/MessagePreview.php b/MessagePreview.php index ec47b343..f59cde17 100644 --- a/MessagePreview.php +++ b/MessagePreview.php @@ -18,7 +18,7 @@ class Pman_Core_MessagePreview extends Pman return true; } - function get() + function get($v, $opts=array()) { if(empty($_REQUEST['_id']) || empty($_REQUEST['_table'])){ $this->jerr('Missing Options'); @@ -34,7 +34,7 @@ class Pman_Core_MessagePreview extends Pman } - function post() + function post($v) { if(empty($_REQUEST['_id']) || empty($_REQUEST['_table'])){ $this->jerr('Missing Options'); @@ -44,6 +44,28 @@ class Pman_Core_MessagePreview extends Pman $this->coreEmailSendTest(); } + $cn = DB_DataObject::factory('core_notify'); + $cn->setFrom(array( + 'evtype' => "{$_REQUEST['_table']}::SendPreviewEmail", + 'onid' => $_REQUEST['_id'], + 'ontable' => $_REQUEST['_table'], + 'person_id' => $this->authUser->id, + 'person_table' => 'Person', + 'act_when' => $cn->sqlValue("NOW()"), + 'act_start' => $cn->sqlValue("NOW()") + )); + + $cn->insert(); + + $sent = $cn->sendManual(); + + if(get_class($sent) != 'Pman_Core_NotifySend_Exception_Success'){ + $this->jerr($sent->getMessage()); + } + + $this->jok("SUCCESS"); + + /* $mid = $_REQUEST['_id']; $mlq = DB_DataObject::factory($_REQUEST['_table']); @@ -62,7 +84,7 @@ class Pman_Core_MessagePreview extends Pman } $this->jerr('error!!:' . $sent->toString()); - + */ } function coreEmailSendTest() @@ -88,9 +110,17 @@ class Pman_Core_MessagePreview extends Pman if(!method_exists($x, $method)){ $this->jerr("{$method} does not exists in {$cls}"); } - + $content = $x->{$method}($this, $this->authUser); - $this->send($content); + $content['bcc'] = array(); + + $sent = $core_email->send($content); + + if(is_object($sent)){ + $this->jerr("Error sending email - " . $sent->toString()); + } + + $this->jok('SUCCESS'); } }