DataObjects/Core_watch.php
[Pman.Core] / DataObjects / Core_watch.php
1 <?php
2 /**
3  * Table Definition for core_watch
4  */
5 require_once 'DB/DataObject.php';
6
7 class Pman_Core_DataObjects_Core_watch extends DB_DataObject 
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'core_watch';                      // table name
13     public $ontable;                         // string(128)  not_null primary_key
14     public $onid;                            // int(11)  not_null primary_key
15     public $person_id;                         // int(11)  not_null primary_key
16     public $event;                           // string(128)  not_null primary_key
17     public $medium;                          // string(128)  not_null primary_key
18     public $active;                          // int(11)  not_null
19
20     
21     /* the code above is auto generated do not remove the tag below */
22     ###END_AUTOCODE
23     
24     /***
25      * The purpose of this is to gather all the events that have
26      * occured in the system (where watches exist)
27      * Do we want to send the user 1 email ?? or multiple...
28      * --> I guess multiple emails..
29      *
30      * so we need to return
31      *
32      *  array(
33           $USER_ID => array(
34                 $OBJECT:$ID, $OBJECT:$ID, $OBJECT:$ID, .....
35           )
36      * )
37      *
38      * The mailer can then go through and call each object ??
39      *
40      *
41      * -- Things we can watch..
42      *
43      * mtrack_change <- this is a neat log of all events.
44      *  which logs these things
45      *     Individual Ticket changes (already)
46      *     a Project -> which means ticket changes... which again can be discovered via mtrack_changes..
47      *     a Repo for Commits (-- which will be handled by mtrack_changes)
48      *     Wiki changes.. later...
49      *     
50      *
51      *
52      */
53     
54     function watched($medium, $watcher = null)
55     {
56         $w = DB_DataObject::factory('core_watch');
57         if ($watcher) {
58             $w->person_id = $watcher;
59         }
60         $w->active = 1;
61         $w->medium = $medium;
62         $w->selectAdd();
63         $w->selectAdd("person_id, CONCAT(ontable, ':', onid) as onobject");
64         
65         return $this->fetchAll('person_id, onobject');
66     }
67 }