_data['password'])) { unset($this->_data['password']); } else { $this->_data['salt'] = substr(md5(time()), 0, 8); $this->_data['password'] = $this->_encryptPass($this->_data['password'], $this->_data['salt']); } } protected function _insertDependency() { return $this->_updateDependency(); } protected function _updateDependency() { $this->_updateIds( $this->_getTableName('User2Permission'), 'userId', 'permissionId', $this->_data['permission'] ); $this->_updateIds( $this->_getTableName('User2Department'), 'userId', 'departmentId', $this->_data['departmentId'] ); return $this; } protected function _addDependenciesFromDb(&$data) { $data['permission'] = $this->_addDependenciesByKey('User2Permission', 'permissionId'); $data['departmentId'] = $this->_addDependenciesByKey('User2Department', 'departmentId'); return parent::_addDependenciesFromDb($data); } protected function _addDependenciesByKey($table, $col) { $select = $this->_db->select(); $select->from($this->_getPair($table), $col); $select->where('userId = ?', $this->getPrimaryKey(), Qs_Db::INT_TYPE); return $this->_db->fetchCol($select); } public function getDepartment4Select() { $select = $this->_db->select(); $select->from($this->_getPair('Department'), array('id', 'name')); $select->where('parentId = ?', 0, Qs_Db::INT_TYPE); $select->joinLeft( $this->_getPair('DepartmentAndProcessSorter'), 'Department.id = DepartmentAndProcessSorter.departmentId', array() ); $select->order('Department.name'); return $this->_db->fetchPairs($select); } }