X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=MessagePreview.php;h=6a7e94feeed9e5ab73e7613e066c8550ae8f649c;hp=0baaae6915b497b26f7525628ada34567372db6e;hb=7a9f406ccb8a30b0025d1881f47157ab9d1fd758;hpb=97e7e7d18dc5a4b77655b8e46eedd9009bfcbd2d diff --git a/MessagePreview.php b/MessagePreview.php index 0baaae69..6a7e94fe 100644 --- a/MessagePreview.php +++ b/MessagePreview.php @@ -20,6 +20,7 @@ class Pman_Core_MessagePreview extends Pman function get($v, $opts=array()) { + if(empty($_REQUEST['_id']) || empty($_REQUEST['_table'])){ $this->jerr('Missing Options'); } @@ -51,8 +52,8 @@ class Pman_Core_MessagePreview extends Pman 'ontable' => $_REQUEST['_table'], 'person_id' => $this->authUser->id, 'person_table' => 'Person', - 'act_when' => $cn->sqlValue("NOW()"), - 'act_start' => $cn->sqlValue("NOW()") + 'act_when' => $cn->sqlValue("NOW() + INTERVAL 10 MINUTE"), + 'act_start' => $cn->sqlValue("NOW() + INTERVAL 10 MINUTE") )); $cn->insert(); @@ -104,16 +105,43 @@ class Pman_Core_MessagePreview extends Pman $cls = str_replace('/', '_', $core_email->test_class); $x = new $cls; - print_r($x);exit; + $method = "test_{$core_email->name}"; if(!method_exists($x, $method)){ $this->jerr("{$method} does not exists in {$cls}"); } - + /* $content = $x->{$method}($this, $this->authUser); $content['bcc'] = array(); + */ + + + $cn = DB_DataObject::factory('core_notify'); + $cn->setFrom(array( + 'evtype' => 'Core_email::testData', + '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"); + + + + $sent = $core_email->send($content);