DataObjects/Core_company.php
[Pman.Core] / DataObjects / Core_project.php
index a1238a4..818a3ee 100644 (file)
@@ -2,9 +2,9 @@
 /**
  * Table Definition for Projects
  */
-require_once 'DB/DataObject.php';
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
 
-class Pman_Core_DataObjects_Core_projects extends DB_DataObject 
+class Pman_Core_DataObjects_Core_project extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -69,7 +69,7 @@ class Pman_Core_DataObjects_Core_projects extends DB_DataObject
 
     function toEventString() {
         $c = $this->client();
-        return ($c->id ? $c->toEventString() : '??'). ':' . $this->name;
+        return ($c && $c->id ? $c->toEventString() : '??'). ':' . $this->name;
     }
     
     /**
@@ -272,6 +272,29 @@ class Pman_Core_DataObjects_Core_projects extends DB_DataObject
             
     }
     
+    
+    
+    function client()
+    {
+        if (!$this->client_id) {
+            return false;
+        }
+        $c = DB_DataObject::factory('core_company');
+        $c->get($this->client_id);
+        return $c;
+    }
+    
+    
+    
+    function team()
+    {
+        $c = DB_DataObject::factory('core_group');
+        $c->get($this->team_id);
+        return $c;
+    }
+    
+    
+    
     // DEPRICATED - use userProjects
     
     function getUserProjects($au, $data='id') // COMPANY BASED!!!!
@@ -282,13 +305,6 @@ class Pman_Core_DataObjects_Core_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..
      */