X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=MessagePreview.php;h=e12a031292a12e021c3b46a05bfe97032939c8d8;hp=df5ca571443b4afd3862d5b8fcd5d37d7a8ebe1e;hb=8cd2a9237c684aa16bc21e3ac6d3793c49c65400;hpb=0b0fc2678b3e967078e3eb48c0983c6d926e3b8d diff --git a/MessagePreview.php b/MessagePreview.php index df5ca571..e12a0312 100644 --- a/MessagePreview.php +++ b/MessagePreview.php @@ -18,8 +18,9 @@ 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 +35,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 +45,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 +85,7 @@ class Pman_Core_MessagePreview extends Pman } $this->jerr('error!!:' . $sent->toString()); - + */ } function coreEmailSendTest() @@ -84,11 +107,21 @@ class Pman_Core_MessagePreview extends Pman $x = new $cls; $method = "test_{$core_email->name}"; - $this->jerr("{$method} does not exists in {$cls}"); + 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'); } }