_data['type'] = $this->_adminType; if ($this->_adminType == self::TYPE_ADMIN) { $this->_data['status'] = self::STATUS_ACTIVE; } if (empty($this->_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']); } return $this; } public function getObjectInfo() { if (($info = parent::getObjectInfo())) { $info['itemTitle'] = $info['firstName'] . ' ' . $info['lastName']; } return $info; } protected function _getFromColumns() { $columns = parent::_getFromColumns(); $columns['permissions'] = $this->_getAssociatedPermissions(); return $columns; } protected function _getAssociatedPermissions() { $select = $this->_db->select(); $select->from($this->_getPair(App_Admin_Acl::getAclTableAlias(), 'acl'), []); $select->joinLeft( $this->_getPair('DAdminAclResource', 'aar'), '`aar`.`id` = `acl`.`aclResourceId`', [ 'permissions' => 'GROUP_CONCAT(`aar`.`title` ORDER BY `aar`.`sorter` SEPARATOR "' . self::PERMISSION_SEPARATOR . '")', ] ); $select->where('`acl`.`adminId` = `' . $this->_tableAlias . '`.`id`'); return new Zend_Db_Expr('(' . $select . ')'); } protected function _prepareRow(array &$row) { if (array_key_exists('permissions', $row)) { $row['permissions'] = explode(self::PERMISSION_SEPARATOR, $row['permissions']); } return parent::_prepareRow($row); } public function _addDependenciesFromDb(array &$data) { parent::_addDependenciesFromDb($data); $data['aclResources'] = $this->_getTable(App_Admin_Acl::getAclTableAlias())->fetchColumn( 'aclResourceId', ['adminId' => $data['id']] ); return $this; } protected function _insertDependency() { parent::_insertDependency(); $this->_saveDependency(); return $this; } protected function _updateDependency() { parent::_updateDependency(); $this->_saveDependency(); return $this; } protected function _saveDependency() { $this->_savePermissions(); return $this; } protected function _savePermissions() { $this->_getTable(App_Admin_Acl::getAclTableAlias())->saveRelationIds( $this->getData('aclResources'), 'aclResourceId', ['adminId' => $this->getPrimaryKey()]); return $this; } }