DataObjects/Mtrack_change.php
authorAlan Knowles <alan@akkbhome.com>
Wed, 6 Apr 2011 23:35:35 +0000 (07:35 +0800)
committerAlan Knowles <alan@akkbhome.com>
Wed, 6 Apr 2011 23:35:35 +0000 (07:35 +0800)
DataObjects/Mtrack_change.php

index 9998f88..3657fb6 100644 (file)
@@ -195,54 +195,29 @@ class Pman_MTrack_DataObjects_Mtrack_change extends DB_DataObject
         return $a->fetchAll();
     }
     
+    function changesSince($object,$lasttime)
+    {
+        $q = DB_DataObject::factory('mtrack_change');
+        $q->onid = $object->id;
+        $q->ontable = $object->tableName();
+        
+        $q->whereAdd("person_id != $uid"); /// unless they are commits?
+        
+        $q->whereAdd(implode(' OR ', $conds));
+        $q->whereAdd("changedate > '$since'");
+        $q->orderBy('changedate ASC');
+        // we are going to end up with a list of objects that have changed.
+        // eg. a ticket or a repo..
+        
+        $cs_ar = $q->fetchAll();
+        
+        
+    }
+    
     
     function gatherChanges($since, $uid, $ar) {
         // array contains a list of project:X repo:X ticket:X etc..
-        // we need to return a nice list of changes
-        // we can ignore changes done by the user (they do not need emails about stuff they have done..)
-        // although commit messages might be usefull..???? need to work out how we can Flag that.
-        $q = DB_DataObject::factory('mtrack_change');
         
-        $conds = array(); // list of 'OR' conditions
-        foreach($ar as $kv) {
-            list($table,$id) = explode(':', $kv);
-            switch($table) {
-                
-                // this should perhaps call a method on each type its looking up...
-                case 'Project':
-                    // all tickets for that project..
-                    $conds[] = "( 
-                        ontable = 'mtrack_ticket'
-                        AND 
-                        onid IN (
-                            SELECT id from mtrack_ticket where project_id = $id
-                        )
-                    )";
-                    break;
-                
-                case 'Ticket':
-                    $conds[] = "( 
-                        ontable = 'mtrack_ticket'
-                        AND 
-                        onid = $id
-                    )";
-                    break;
-                
-                case 'Repo':
-                    // this means that commits get logged as mtrack_repo change..
-                    $conds[] = "( 
-                        ontable = 'mtrack_repo'
-                        AND 
-                        onid = $id
-                    )";
-                    break;
-                
-                
-                
-            }
-            
-            
-        }
         $q->whereAdd("person_id != $uid"); /// unless they are commits?
         
         $q->whereAdd(implode(' OR ', $conds));