MessagePreview.php
authorEdward <edward@roojs.com>
Fri, 21 Feb 2014 11:09:30 +0000 (19:09 +0800)
committerEdward <edward@roojs.com>
Fri, 21 Feb 2014 11:09:30 +0000 (19:09 +0800)
MessagePreview.php

index e5a4f2f..8ab7932 100644 (file)
@@ -20,11 +20,11 @@ class Pman_Core_MessagePreview extends Pman
     
     function get()
     {
-        if(empty($_REQUEST['_id'])){
+        if(empty($_REQUEST['_id']) || empty($_REQUEST['_table'])){
             $this->jerr('Missing Options');
         }
         
-        $mlq = DB_DataObject::factory('core_email');
+        $mlq = DB_DataObject::factory($_REQUEST['_table']);
         
         $mlq->get($_REQUEST['_id']);
         
@@ -33,4 +33,30 @@ class Pman_Core_MessagePreview extends Pman
         $this->showHtml = isset($_REQUEST['_as_html']) ? true : false;
         
     }
+    
+    function post()
+    {
+        if(empty($_REQUEST['_id']) || empty($_REQUEST['_table'])){
+            $this->jerr('Missing Options');
+        }
+        
+        $mid = $_REQUEST['_id'];
+        
+        $mlq = DB_DataObject::factory($_REQUEST['_table']);
+        
+        $mlq->get($_REQUEST['_id']);
+        
+        $content = array(
+            'template' => $mlq->name,
+            'person' => $this->authUser
+        );
+        
+        $sent = DB_DataObject::factory('crm_mailing_list_message')->send($content);
+        
+        if(!is_object($sent)){
+            $this->jok('SUCCESS');
+        }
+        $this->jerr('error!!:' . $sent->toString());
+        
+    }
 }