X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=MessagePreview.php;h=f59cde177e0f2f376661919f83a9a373777494a8;hp=c57a8cf7932c8874693d8b4e36286afd5b5c6adb;hb=refs%2Fheads%2Fwip_alan_T5884_add_photo_to_report;hpb=387141670097e7b9285e075343fc756dda84edf3 diff --git a/MessagePreview.php b/MessagePreview.php index c57a8cf7..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,7 +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); + + $content['bcc'] = array(); + $sent = $core_email->send($content); + + if(is_object($sent)){ + $this->jerr("Error sending email - " . $sent->toString()); + } + $this->jok('SUCCESS'); } }