DataObjects/Core_notify.php
authorAlan Knowles <alan@roojs.com>
Wed, 14 Oct 2015 06:50:02 +0000 (14:50 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 14 Oct 2015 06:50:02 +0000 (14:50 +0800)
DataObjects/Core_notify.php

index 4c02e6f..dc6bfca 100644 (file)
@@ -193,6 +193,42 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
         }
         
     }
         }
         
     }
+    /**
+     * current state of process
+     *
+     * 0 = pending
+     * 1 = delivered
+     * -1 = failed
+     *
+     *
+     */
+    function state()
+    {
+           
+        if ($this->msgid != '') {
+            return 1;
+        }
+        // msgid is empty now..
+        if ($this->event_id > 0 && strtotime($this->act_when) < time()) {
+            return -1;
+        }
+        return 0; // pending
+            
+            $this->whereAdd("msgid  = '' AND event_id > 0 AND act_when < NOW()");
+            
+            break;
+        case 'PENDING';
+            $this->whereAdd('event_id = 0 OR (event_id  > 0 AND act_when > NOW() )');
+            break;
+        
+        case 'OPENED';
+            $this->whereAdd('is_open > 0');
+            break;
+        
+        
+        
+    }
+    
     
     function applyFilters($q, $au, $roo)
     {
     
     function applyFilters($q, $au, $roo)
     {