DataObjects/Core_watch.php
authorAlan Knowles <alan@akbkhome.com>
Fri, 25 Mar 2011 11:10:54 +0000 (19:10 +0800)
committerAlan Knowles <alan@akbkhome.com>
Fri, 25 Mar 2011 11:10:54 +0000 (19:10 +0800)
DataObjects/Core_watch.php

index 5be3d2e..5be7890 100644 (file)
@@ -20,4 +20,48 @@ class Pman_Core_DataObjects_Core_watch extends DB_DataObject
     
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
+    
+    /***
+     * The purpose of this is to gather all the events that have
+     * occured in the system (where watches exist)
+     * Do we want to send the user 1 email ?? or multiple...
+     * --> I guess multiple emails..
+     *
+     * so we need to return
+     *
+     *  array(
+          $USER_ID => array(
+                $OBJECT:$ID, $OBJECT:$ID, $OBJECT:$ID, .....
+          )
+     * )
+     *
+     * The mailer can then go through and call each object ??
+     *
+     *
+     * -- Things we can watch..
+     *
+     * mtrack_change <- this is a neat log of all events.
+     *  which logs these things
+     *     Individual Ticket changes (already)
+     *     a Project -> which means ticket changes... which again can be discovered via mtrack_changes..
+     *     a Repo for Commits (-- which will be handled by mtrack_changes)
+     *     Wiki changes.. later...
+     *     
+     *
+     *
+     */
+    
+    function watched($medium, $watcher = null)
+    {
+        $w = DB_DataObject::factory('core_watch');
+        if ($watcher) {
+            $w->person_id = $watcher;
+        }
+        $w->active = 1;
+        $w->medium = $medium;
+        $w->selectAdd();
+        $w->selectAdd("person_id, CONCAT(ontable, ':', onid) as onobject");
+        
+        return $this->fetchAll('person_id, onobject');
+    }
 }