X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=DataObjects%2FCore_company.php;h=c1b9a56dd6ff6d8954cf3d77edac01bdaef7a8d6;hp=aca5be848d4448fc36a450ed30657b39263eb7db;hb=HEAD;hpb=e14d01c045097893122e433a0c59268645c38ecd diff --git a/DataObjects/Core_company.php b/DataObjects/Core_company.php index aca5be84..4ae8fb3e 100644 --- a/DataObjects/Core_company.php +++ b/DataObjects/Core_company.php @@ -35,10 +35,17 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject public $country; // string(4) not_null public $is_system; // int(2) + + public $comptype_id; + public $address1; + public $address2; + public $address3; + + /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function applyFilters($q, $au) + function applyFilters($q, $au, $roo) { $tn = $this->tableName(); @@ -79,7 +86,7 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject } if (!empty($q['query']['comptype'])) { - $this->whereAddIn('comptype', explode(',', $q['query']['comptype']), 'string'); + $this->whereAddIn($tn.'.comptype', explode(',', $q['query']['comptype']), 'string'); } @@ -134,7 +141,9 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject { $db = $this->getDatabaseConnection(); $sesPrefix = $db->dsn['database']; - @session_start(); + if (empty($_SERVER['PHP_AUTH_USER'])) { + @session_start(); + } if (!empty($_SESSION[__CLASS__][$sesPrefix .'-auth'])) { // in session... $a = unserialize($_SESSION[__CLASS__][$sesPrefix .'-auth']); @@ -278,7 +287,7 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject $roo->jok('OK'); } - $roo->jerr('EXIST'); + $roo->jerror('NOTICE-EXIST-CHECK','EXIST'); } } @@ -318,7 +327,7 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject $roo->jok('OK'); } - $roo->jerr('EXIST'); + $roo->jerror('NOTICE-EXIST-CHECK','EXIST'); } if(!empty($q['_merge_id'])){ @@ -495,12 +504,38 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject $companies->insert(); $companies->onInsert(array(), $roo); } + + function owner() + { + if (empty($this->owner_id)) { + return false; + } + static $cache = false; + if ($cache !== false && isset($cache[$this->owner_id])) { + return $cache[$this->owner_id]; + } + $o = DB_DataObject::factory('core_company'); + if (!$o->get($this->owner_id)) { + return false; + } + $cache[$this->owner_id] = $o; + return $o; + + } + + /// look up the company which is the system owner... static function lookupOwner() { + static $cache = false; + if ($cache !== false) { + return clone($cache); // no updating this object.. + } + $enum = DB_DataObject::Factory('core_enum')->lookup('COMPTYPE', 'OWNER' ); $companies = DB_DataObject::factory('core_company'); $companies->comptype_id = $enum; if ($companies->find(true)) { + $cache = clone($companies); return $companies; } return false;