DataObjects/Core_event_audit.php
[Pman.Core] / DataObjects / Projects.php
index ee45bfd..e398f61 100644 (file)
@@ -22,9 +22,9 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
     public $file_location;                   // string(254)  not_null
     public $open_date;                       // date(10)  binary
     public $open_by;                         // int(11)  not_null
+    public $close_date;                      // date(10)  binary
     public $countries;                       // string(128)  not_null
     public $languages;                       // string(128)  not_null
-    public $close_date;                      // date(10)  binary
     public $agency_id;                       // int(11)  not_null
 
     
@@ -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,32 +147,20 @@ 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)
         
-        if ($au->company()->comptype == 'SUPPLIER') {
-            $pr = DB_DataObject::factory('CampaignAssign');
-            $pr->supplier_id = $au->company_id;
-            $prjs = $pr->fetchAll('project_id');
-             if (count($prjs)) {
-                $this->whereAdd("
-                     (Projects.id IN (".implode(',', $prjs).")) 
-                ");
-            }  else {
-                $this->whereAdd("1=0"); // can see nothing!!!
-            }
-        }
-        if ($au->company()->comptype == 'CLIENT') {
-            $this->client_id = $au->company()->id; // can see nothing!!!
-            
-        }
+       
+        
+        
+        
                  
         
         
@@ -291,8 +281,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 +297,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 +322,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..
      */