DataObjects/core.sql
[Pman.Core] / NotifySend.php
index e033f29..b514d42 100644 (file)
@@ -94,6 +94,10 @@ class Pman_Core_NotifySend extends Pman
             
             die("send repeat to early\n");
         }
+        if (!empty($opts['debug'])) {
+            print_r($w);
+        }
+        
         
         if (!$force && !empty($w->msgid)) {
             $ww = clone($w);
@@ -133,8 +137,9 @@ class Pman_Core_NotifySend extends Pman
             $next_try_min = floor((time() - strtotime($last_event)) / 60) * 2;
         }
         $next_try = $next_try_min . ' MINUTES';
-        
-        $email =  $this->makeEmail($o, $p, $last, $w);
+         
+        // this may modify $p->email. (it will not update it though)
+        $email =  $this->makeEmail($o, $p, $last, $w, $force);
         
         
         if ($email === true)  {
@@ -241,7 +246,7 @@ class Pman_Core_NotifySend extends Pman
             // older that 1 day.
             $retry = 120;
         }
-        
+        $w->to_email = $p->email; 
         //$this->addEvent('NOTIFY', $w, 'GREYLISTED ' . $p->email . ' ' . $res->toString());
         $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES'));
         $w->update($ww);
@@ -275,7 +280,7 @@ class Pman_Core_NotifySend extends Pman
             if ($res === true) {
                 // success....
                 
-                $ev = $this->addEvent('NOTIFY', $w, 'SUCCESS: ' .$email['headers']['Subject']);
+                $ev = $this->addEvent('NOTIFYSENT', $w, "{$w->to_email} - {$email['headers']['Subject']}");
                
                 
                 
@@ -392,9 +397,17 @@ class Pman_Core_NotifySend extends Pman
          
      }
      **/
-    function makeEmail($object, $rcpt, $last_sent_date, $notify)
+    function makeEmail($object, $rcpt, $last_sent_date, $notify, $force =false)
     {
-        return $object->toEmail($rcpt, $last_sent_date, $notify);
+        $m = 'notify'. $notify->evtype;
+        var_dump($m);
+        
+        if (!empty($notify->evtype) && method_exists($object,$m)) {
+            return $object->$m($rcpt, $last_sent_date, $notify, $force);
+        }
+                
+        
+        return $object->toEmail($rcpt, $last_sent_date, $notify, $force);
     }
     
     function debug($str)
@@ -405,5 +418,8 @@ class Pman_Core_NotifySend extends Pman
         }
         echo $str . "\n";
     }
-    
+    function output()
+    {
+        die("done\n");
+    }
 }
\ No newline at end of file