3 * Table Definition for core_watch
5 * works with 'core_notify'
8 * $watch->notify($ontable, $onid)
10 * in which case it should create a core_notify event.
15 require_once 'DB/DataObject.php';
17 class Pman_Core_DataObjects_Core_watch extends DB_DataObject
20 /* the code below is auto generated do not remove the above tag */
22 public $__table = 'core_watch'; // table name
23 public $ontable; // string(128) not_null primary_key
24 public $onid; // int(11) not_null primary_key
25 public $person_id; // int(11) not_null primary_key
26 public $event; // string(128) not_null primary_key
27 public $medium; // string(128) not_null primary_key
28 public $active; // int(11) not_null
31 /* the code above is auto generated do not remove the tag below */
33 /** make sure there is a watch for this user.. */
35 function ensureNotify( $ontable, $onid, $person_id, $whereAdd)
37 DB_DAtaObject::debugLevel(1);
38 $w = DB_DataObject::factory('core_watch');
39 $w->person_id = $person_id;
40 if (empty($w->person_id)) {
45 $w->whereAdd($whereAdd);
51 $nw->ontable = $ontable;
54 $nw->medium = 'email';
61 function notify($ontable , $onid, $whereAdd)
63 $w = DB_DataObject::factory('core_watch');
64 $w->whereAdd($whereAdd);
66 $w->selectAdd('distinct(person_id) as person_id');
67 $people = $w->fetchAll('person_id');
68 $nn = DB_DataObject::Factory('core_notify');
69 $nn->ontable = $ontable;
71 foreach($people as $p) {
72 if (!$p) { // no people??? bugs in watch table
78 $nf->whereAdd('sent < act_when');
80 // we have a item in the queue for that waiting to be sent..
83 $n->act_when = date("Y-m-d H:i:s");
93 * The purpose of this is to gather all the events that have
94 * occured in the system (where watches exist)
95 * Do we want to send the user 1 email ?? or multiple...
96 * --> I guess multiple emails..
98 * so we need to return
102 $OBJECT:$ID, $OBJECT:$ID, $OBJECT:$ID, .....
106 * The mailer can then go through and call each object ??
109 * -- Things we can watch..
111 * mtrack_change <- this is a neat log of all events.
112 * which logs these things
113 * Individual Ticket changes (already)
114 * a Project -> which means ticket changes... which again can be discovered via mtrack_changes..
115 * a Repo for Commits (-- which will be handled by mtrack_changes)
116 * Wiki changes.. later...
122 function watched($medium, $watcher = null)
124 $w = DB_DataObject::factory('core_watch');
126 $w->person_id = $watcher;
129 $w->medium = $medium;
130 $ar = $w->fetchAll();
133 if (!isset($ret[$o->person_id])) {
134 $ret[$o->person_id] = array();
136 $ret[$o->person_id][] = $o->ontable .':'. $o->onid;