sync
authorAlan Knowles <alan@akbkhome.com>
Wed, 6 Apr 2011 04:41:48 +0000 (12:41 +0800)
committerAlan Knowles <alan@akbkhome.com>
Wed, 6 Apr 2011 04:41:48 +0000 (12:41 +0800)
DataObjects/Core_notify.php
DataObjects/Core_watch.php

index 91a0c42..9f2f294 100644 (file)
@@ -13,7 +13,7 @@ CREATE TABLE  core_notify  (
   `person_id` int(11)  NOT NULL DEFAULT 0,
   `msgid` varchar(128)  NOT NULL  DEFAULT '',
   `sent` DATETIME  NOT NULL,
-  `bounced` int(4)  NOT NULL DEFAULT 0,
+  `event_id` int(11)  NOT NULL DEFAULT 0,
   PRIMARY KEY (`id`),
   INDEX `lookup`(`act_when`, `msgid`)
 );
@@ -47,5 +47,5 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
         return $c;
         
     }
-
+  
 }
\ No newline at end of file
index 0babeae..b0e77c4 100644 (file)
@@ -31,6 +31,35 @@ class Pman_Core_DataObjects_Core_watch extends DB_DataObject
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
     
+    
+    function notify($ontable , $onid, $whereAdd)
+    {
+        $w = DB_DataObject::factory('core_watch');
+        $w->whereAdd($whereAdd);
+        $w->selectAdd();
+        $w->selectAdd('distinct(person_id) as person_id');
+        $people = $w->fetchAll('person_id');
+        $nn = DB_DataObject::Factory('core_notify');
+        $nn->ontable = $ontable;
+        $nn->onid = $onid;
+        foreach($people as $p) {
+            $n = clone($nn);
+            $n->person_id = $p;
+            $nf = clone($n);
+            $nf->whereAdd('sent < act_when');
+            if ($nf->count()) {
+                // we have a item in the queue for that waiting to be sent..
+                continue;
+            }
+            $n->act_when = date("Y-m-d H:i:s");
+            $n->insert();
+            
+            
+        }
+        
+        
+        
+    }
     /***
      * The purpose of this is to gather all the events that have
      * occured in the system (where watches exist)