MessagePreview.php
[Pman.Core] / MessagePreview.php
index db0deab..0959af6 100644 (file)
@@ -52,7 +52,7 @@ class Pman_Core_MessagePreview extends Pman
         
         $content = array(
             'template' => $mlq->name,
-            'person' => $this->authUser
+            'rcpts' => 'edward@roojs.com'
         );
         
         $sent = DB_DataObject::factory($_REQUEST['_table'])->send($content);
@@ -72,9 +72,31 @@ class Pman_Core_MessagePreview extends Pman
         if(!$core_email->get($_REQUEST['_id'])){
             $this->jerr('Invalid Message ID');
         }
-        $this->jerr("[{$core_email->name}] does not has test class");
+        
         if(empty($core_email->test_class)){
             $this->jerr("[{$core_email->name}] does not has test class");
         }
+        
+        require_once "{$core_email->test_class}.php";
+        
+        $cls = str_replace('/', '_', $core_email->test_class);
+        
+        $x = new $cls;
+        
+        $method = "test_{$core_email->name}";
+        
+        if(!method_exists($x, $method)){
+            $this->jerr("{$method} does not exists in {$cls}");
+        }
+
+        $content = $x->{$method}($this, $this->authUser);
+        
+        $sent = $core_email->send($content);
+        
+        if(is_object($sent)){
+            $this->jerr("Error sending email - " . $sent->toString());
+        }
+        
+        $this->jok('SUCCESS');
     }
 }