Report/SendEventErrors.php
[Pman.Admin] / Report / SendEventErrors.php
index 27562ec..b22f97c 100644 (file)
@@ -28,6 +28,28 @@ class Pman_Admin_Report_SendEventErrors extends Pman_Roo
             'min' => 1,
             'max' => 1,
         ),
+        'helo' => array(
+            'desc' => 'mail helo to use',
+            'short' => 'l',
+            'default' => '',
+            'min' => 1,
+            'max' => 1,
+        ),
+        'host' => array(
+            'desc' => 'mail host to use',
+            'short' => 'o',
+            'default' => '',
+            'min' => 1,
+            'max' => 1,
+        ),
+     
+        'list' => array(
+            'desc' => 'list the current actions in the database',
+            'short' => 'L',
+            'default' => '',
+            'min' => 1,
+            'max' => 1,
+        )
     );
     
     function getAuth()
@@ -45,11 +67,10 @@ class Pman_Admin_Report_SendEventErrors extends Pman_Roo
     {
         $this->opts = $opts;
         
-        $this->transObj = DB_DataObject::Factory('core_enum');
-        
-        $this->transObj->query('BEGIN');
-        
-        PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
+          
+        if(!empty($this->opts['list'])){
+            $this->listTypes();
+        }
         
         if(empty($this->opts['group'])){
             $this->jerr('Missing group - try add [-t {group name}]');
@@ -129,11 +150,49 @@ class Pman_Admin_Report_SendEventErrors extends Pman_Roo
             $this->jerr('Nothing to be sent');
         }
         
-        $list = $events->fetchAll();
+        $errors = $events->fetchAll();
         
+        if(!empty($this->opts['host'])){
+            // reset the mail settings..
+            HTML_FlexyFramework::get()->Mail = array(
+                                        'host' => $this->opts['host']
+            );
+        }
         
+        if(!empty($this->opts['helo'])){
+            HTML_FlexyFramework::get()->Mail['helo'] = $this->opts['helo'];
+        }
+        
+        
+        
+        $content = array(
+            'template'      => 'EVENT_ERRORS_REPORT',
+            'rcpts'         => $rcpts,
+            'errors'        => $errors,
+            'subject'       => $subject
+        );
+
+        $sent = DB_DataObject::factory('core_email')->send($content);
+        
+        if(!is_object($sent)){
+            $this->jok("Done");
+        }
         
-        $this->jok("Done");
+        $this->jerr($sent);
+        
+    }
+    
+    function listTypes()
+    {
+         $events = DB_DataObject::factory('Events');
+        $events->selectAdd();
+        $events->selectAdd("
+            DISTINCT(Events.action) AS action
+        ");
+        $ar = $events->fetchAll('action');
+        echo implode("\n", $ar);
+        echo "\n";
+        exit;
         
     }