`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`)
);
return $c;
}
-
+
}
\ No newline at end of file
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
+ /** make sure there is a watch for this user.. */
+ function ensureNotify( $ontable, $onid, $person_id, $whereAdd)
+ {
+ $w = DB_DataObject::factory('core_watch');
+ $w->ontable = $ontable;
+ $w->onid = $onid;
+ $w->person_id = $personid;
+ $nw = clone($w);
+ $w->whereAdd($whereAdd);
+
+
+ if ($w->count()) {
+ return;
+ }
+ $nw->medium = 'email';
+ $nw->active = 1;
+ $nw->insert();
+
+
+ }
+
+ 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)
ALTER TABLE core_notify CHANGE COLUMN bounced event_id INT(11) DEFAULT 0;
-
+ALTER TABLE core_notify CHANGE COLUMN bounced event_id INT(11) NOT NULL DEFAULT 0;
# - used by email / tracker to handle alises - we have to be carefull adding to this table...