DataObjects/ProjectDirectory.php
[Pman.Core] / DataObjects / Projects.php
index ee45bfd..deff0bb 100644 (file)
@@ -67,7 +67,8 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
     }
 
     function toEventString() {
-        return $this->name;
+        $c = $this->client();
+        return ($c->id ? $c->toEventString() : '??'). ':' . $this->name;
     }
     
     /**
@@ -118,9 +119,10 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
         }
          // user projects!!!! - make sure they can only see project they are suppsed to..
          // only applies to document stuff..
+        
+        //&& $au->hasPerm('Documents.Documents','S') << this is dependant on the doc modules
           
-        if (!$au->hasPerm('Core.Projects_All','S') &&
-            $au->hasPerm('Documents.Documents','S')) {
+        if (!$au->hasPerm('Core.Projects_All','S') ) {
             
             
             
@@ -128,7 +130,7 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
             $pr->whereAdd("Projects.type IN ('N','X')");
             $prjs = $pr->fetchAll('id');
             
-            
+            DB_DataObject::debugLevel(1);
             $pd = DB_DataObject::factory('ProjectDirectory');
             $pd->joinAdd(DB_DataObject::factory('Projects'), 'LEFT');
             $pd->whereAdd("Projects.type NOT IN ('N','X')");
@@ -145,12 +147,12 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
         }
         
         if (!empty($q['query']['distinct_client_id'])) {
-            DB_DataObjecT::debuglevel(1);
+          // DB_DataObjecT::debuglevel(1);
             $this->selectAdd();
             $this->selectAdd('distinct(client_id)');
-            $this->selectAs(DB_DataObject::factory('Companies'), 'client_id_%s');
+            $this->selectAs(DB_DataObject::factory('Companies'), 'client_id_%s','join_client_id_id');
             $this->groupBy('client_id');
-            
+             
         }
         
         // this is clipping related..  -- we should have an API for addons like this.. (and docs)
@@ -171,6 +173,9 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
             $this->client_id = $au->company()->id; // can see nothing!!!
             
         }
+        
+        
+        
                  
         
         
@@ -291,8 +296,8 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
     }
     
     
-    function toRooArray($f='%s') {
-        $ret = parent::toArray($f);
+    function toRooArray($req= array()) {
+        $ret = parent::toArray();
         // sor tout 
         $ret['countrylist'] = $this->I18toArray('c',$ret['countries']);
         $ret['languagelist'] = $this->I18toArray('l',$ret['languages']);
@@ -307,23 +312,7 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
             ));
         }
         return true;
-    }
-    
-    function fetchAll($k= false) {
-        if ($k !== false) {
-            $this->selectAdd();
-            $this->selectAdd($k);
-        }
-        
-        $this->find();
-        $ret = array();
-        while ($this->fetch()) {
-            $ret[] = $k === false ? clone($this) : $this->$k;
-        }
-        return $ret;
-         
-    }
-    
+    } 
     /**
      * fetch a list of user projects.
      * if you need to filter open/closed.. then add whereAdds before calling
@@ -348,6 +337,13 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
     }
     
     
+    function client()
+    {
+        $c = DB_DataObject::factory('Companies');
+        $c->get($this->client_id);
+        return $c;
+    }
+    
     /**
      * check who is trying to access this. false == access denied..
      */