protected function __construct() { if (isset($_SESSION['sid'])) { $sid = trim($_SESSION['sid']); } else { if (isset($_COOKIE['sid'])) { $sid = trim($_COOKIE['sid']); } else { $sid = NULL; } } if (!is_null($sid)) { $_session = Common_Db::get('Common_Db_Session'); try { $rs = $_session->getById($sid); } catch (Exception $e) { $rs = NULL; } if (isset($rs['sid'])) { $this->sid = $rs['sid']; $this->uid = $rs['uid']; $this->uname = $rs['uname']; //$this->roles = $rs->roles; } } }
public function getFields($entry) { $fields = array(); $entityid = $entry['entryid']; $type = $entry['type']; $_conf = Common_Db::getInstance(Common_Data_Db::$field_config); $insts = $_conf->getList(array('entity_type' => $type)); // Get Fields Data $regex = '#^field_(.+)$#i'; $storage = array(); foreach ($insts as $v) { if (!isset($storage[$v['storage_type']])) { $_db_cfg = Common_Data_Db::getFieldData($v['storage_type']); $_data = Common_Db::getInstance($_db_cfg); $ret = $_data->getById($entityid); //$terms = array(); //foreach ($ret as $v2) { // $terms[] = $v2['field_tid']; // } $storage[$v['storage_type']] = $ret; } switch ($v['field_type']) { case Common_Data_Field_Type::TERM_AUTO: /* if (count($terms) > 0) { $_data = Common_Db::getInstance(Common_Data_Db::$taxonomy_term_data); $ret = $_data->getList(array('in.tid' => $terms), array(), 100); foreach ($ret as $v2) { $fields['field:term'][] = array('tid' => $v2['tid'], 'name' => $v2['name']); } }*/ if (isset($storage[$v['storage_type']]['field_' . $v['field_name']])) { $fields['field:' . $v['field_name']] = $storage[$v['storage_type']]['field_' . $v['field_name']]; } else { $fields['field:' . $v['field_name']] = ''; } break; case Common_Data_Field_Type::TEXT_SUMMARY: if (isset($storage[$v['storage_type']]['field_' . $v['field_name']])) { $fields['field:' . $v['field_name']] = $storage[$v['storage_type']]['field_' . $v['field_name']]; } else { $fields['field:' . $v['field_name']] = ''; } if (isset($storage[$v['storage_type']]['field_' . $v['field_name'] . '_summary'])) { $fields['field:' . $v['field_name'] . '_summary'] = $storage[$v['storage_type']]['field_' . $v['field_name'] . '_summary']; } else { $fields['field:' . $v['field_name'] . '_summary'] = ''; } /* foreach ($ret as $k2 => $v2) { if (preg_match($regex, $k2, $v3)) { $fields['field:'.$v3[1]] = $v2; } }*/ break; default: //... } } return $fields; }
public function getEntry($entryid) { try { $_entry = Common_Db::getInstance(Common_Data_Db::$entry); $entry = $_entry->getById($entryid); $_field = new Common_Data_Field(); $fields = $_field->getFields($entry); $entry = array_merge($entry, $fields); } catch (Exception $e) { throw $e; } return $entry; }
public function update($params, $where) { foreach ($params as $key => $value) { if (!in_array($key, $this->_cols)) { unset($params[$key]); } } try { $_user = Common_Db::get('User_Model_Db_UserProfile'); $_user->update($params, $where); } catch (Exception $e) { throw $e; } }