/**
  * Set the association of the object
  *
  * @param ObjReference $objRef
  * @param BizDataObj $asscObj
  * @return void
  */
 protected function setAssociation($objRef, $asscObj)
 {
     $this->association["AsscObjName"] = $asscObj->objectName;
     $this->association["Relationship"] = $objRef->relationship;
     $this->association["Table"] = $objRef->table;
     $this->association["Column"] = $objRef->column;
     $this->association["FieldRef"] = $objRef->fieldRef;
     $this->association["FieldRefVal"] = $asscObj->getFieldValue($objRef->fieldRef);
     $this->association["CondColumn"] = $objRef->condColumn;
     $this->association["CondValue"] = $objRef->condValue;
     $this->association["Condition"] = $objRef->condition;
     if ($objRef->relationship == "M-M" || $objRef->relationship == "Self-Self") {
         $this->association["XTable"] = $objRef->xTable;
         $this->association["XColumn1"] = $objRef->xColumn1;
         $this->association["XColumn2"] = $objRef->xColumn2;
         $this->association["XKeyColumn"] = $objRef->xKeyColumn;
         $this->association["XDataObj"] = $objRef->xDataObj;
     }
 }
Exemple #2
0
 /**
  * Get reference object with given object name
  *
  * @param string $objName name of the object reference
  * @return obejct the instance of reference object
  */
 public function getRefObject($objName)
 {
     return $this->bizDataObj->getRefObject($objName);
 }
 /**
  * Pick the joined object's current record to the current record
  *
  * @param BizDataObj $joinDataObj
  * @param string $joinName name of join (optional)
  * @return array return a modified record with joined record data
  */
 public function joinRecord($joinDataObj, $joinName = "")
 {
     // get the maintable of the joindataobj
     $joinTable = $joinDataObj->mainTableName;
     $joinRecord = null;
     $returnRecord = array();
     // find the proper join according to join name and the maintable
     foreach ($this->tableJoins as $tableJoin) {
         if (($joinName == $tableJoin->objectName || $joinName == "") && $tableJoin->table == $joinTable) {
             // populate the column-fieldvalue to columnRef-fieldvalue
             // get the field mapping to the column, then get the field value
             $joinFieldName = $joinDataObj->bizRecord->getFieldByColumn($tableJoin->column);
             // joined-main table
             if (!$joinFieldName) {
                 continue;
             }
             if (!$joinRecord) {
                 $joinRecord = $joinDataObj->getActiveRecord();
             }
             $refFieldName = $this->bizRecord->getFieldByColumn($tableJoin->columnRef);
             // join table
             $returnRecord[$refFieldName] = $joinRecord[$joinFieldName];
             // populate joinRecord's field to current record
             foreach ($this->bizRecord as $fld) {
                 if ($fld->join == $tableJoin->objectName) {
                     // use join column to match joinRecord field's column
                     $jfldname = $joinDataObj->bizRecord->getFieldByColumn($fld->column);
                     // joined-main table
                     $returnRecord[$fld->objectName] = $joinRecord[$jfldname];
                 }
             }
             break;
         }
     }
     // return a modified record with joined record data
     return $returnRecord;
 }
 protected function loadFullMenuTree()
 {
     if (self::$fullMenuTree != null) {
         return;
     }
     $cache_id = 'FULL_MENU_LIST';
     $cacheSvc = Openbiz::getService(CACHE_SERVICE, 1);
     $cacheSvc->init($this->objectName, 600);
     // cache for 10 mins
     if ($cacheSvc->test($cache_id)) {
         self::$fullMenuTree = $cacheSvc->load($cache_id);
         return;
     }
     $rs = parent::directFetch();
     foreach ($rs as $record) {
         if (empty($record['PId'])) {
             $record['PId'] = "__root__";
         }
         unset($record['create_by']);
         unset($record['create_time']);
         unset($record['update_by']);
         unset($record['update_time']);
         unset($record['name']);
         unset($record['parent']);
         self::$fullMenuTree[$record['Id']] = $record;
     }
     foreach (self::$fullMenuTree as $mId => $record) {
         self::$fullMenuTree[$record['PId']]['children'][] = $mId;
     }
     //print_r(self::$fullMenuTree);
     $cacheSvc->save(self::$fullMenuTree, $cache_id);
     // put it in apc or file cache
 }