User.php
00001 <?php
00012 class Dsao_User extends Dsao_Db_Table_DataHandler_Abstract
00013 {
00014 protected $_identifiers = array('id', array('username', 'emailAddress'));
00015
00016 protected $_propertiesProtected = array('id');
00017
00021 protected $_reserialize = false;
00022
00023 protected $_table = 'user_data';
00024
00025 protected function _checkValidity()
00026 {
00027
00028
00029
00030
00031 $this->_valid = false;
00032
00033 return true;
00034 }
00035
00041 protected function _fetchAll()
00042 {
00043
00044 $select = $this->getTable()->getAdapter()->select()->from('user_data')
00045
00046 ->joinUsing('user_profile', 'id')
00047
00048 ->joinUsing('user_settings', 'id')
00049
00050 ->join('acl_role', 'user_data.idRole = acl_role.id',
00051 array('role' => 'name'));
00052
00053
00054 $this->_addWhere($select, array(), array('table' => 'user_data'));
00055
00056 $result = $this->getTable()->getAdapter()->fetchAll($select);
00057
00058
00059 $this->_parseResult(array_pop($result));
00060 }
00061
00062 public function exists()
00063 {
00064
00065 if (null !== ($exists = parent::exists()))
00066 {
00067 return $exists;
00068 }
00069
00070
00071 $select = $this->getTable()->select(true)->reset(Zend_Db_Select::COLUMNS)
00072 ->columns('id');
00073 $this->_addWhere($select);
00074
00075 return (bool) $select->fetchRow();
00076 }
00077
00083 public function getReserialize()
00084 {
00085
00086 return ($this->_valid ? (bool) $this->_reserialize : false);
00087 }
00088
00089 public function refresh()
00090 {
00091 parent::refresh();
00092
00093 $this->_fetchAll();
00094
00095 return $this;
00096 }
00097
00098 public function insert()
00099 {
00100
00101 throw new Dsao_Exception('dsao_user_insert');
00102 }
00103
00113 public function setReserialize($flag)
00114 {
00115 $this->_reserialize = (bool) $flag;
00116 }
00117
00118 public function update(array $properties = array())
00119 {
00120 parent::update($properties);
00121
00122
00123 $rowUserData = Dsao_Registry::getTable('user_data')->find($this->__get('id'))->current();
00124
00125
00126 $rowUserProfile = $rowUserData->findParentRow
00127 ('Dsao_Db_Table_UserProfile', 'userProfile');
00128 $rowUserSettings = $rowUserData->findParentRow
00129 ('Dsao_Db_Table_UserSettings', 'userSettings');
00130
00131 $data = $this->getData($properties);
00132
00133
00134 $rowUserData->setFromArray($data);
00135 $rowUserProfile->setFromArray($data);
00136 $rowUserSettings->setFromArray($data);
00137
00138
00139 $rowUserData->save();
00140 $rowUserProfile->save();
00141 $rowUserSettings->save();
00142
00143 $this->setSynchronous(true);
00144
00145 return $this;
00146 }
00147 }