_sessionId = $sessionId; return $this; } /** * @return string * @throws Exception */ public function getSessionId() { if (null === $this->_sessionId) { throw new Exception('Unknown Session ID.'); } return $this->_sessionId; } protected function _filter(Zend_Db_Select $select) { parent::_filter($select); $select->where('`' . $this->_tableShortAlias . '`.`sessionId` = ?', $this->getSessionId()); return $this; } public function getSessionInfo($key = null) { static $info; if (null === $info) { $select = $this->_db->select(); $select->from($this->_getPair('ViewControllerLogSession', 'vcls')); $select->where('`vcls`.`id` = ?', $this->getSessionId()); $info = $this->_db->fetchRow($select); } return (null !== $key) ? Qs_Array::get($info, $key) : $info; } public function getRoleTitle($role, $roleId) { $select = $this->_db->select(); $columns = ['CONCAT_WS(" ", `firstName`, `lastName`)']; switch ($role) { case Entity::ROLE_USER: $select->from($this->_getPair('User'), $columns); break; case Entity::ROLE_ADMIN: $select->from($this->_getPair('Admin'), $columns); break; case Entity::ROLE_STAFF: throw new Exception('Role "' . $role . '" not implemented'); break; default: throw new Exception('Unknown role "' . $role . '".'); } $select->where('`id` = ?', $roleId, Qs_Db::INT_TYPE); return $this->_db->fetchOne($select); } public function getListSelect() { if (null === $this->_select) { parent::getListSelect(); $this->_joinApplication($this->_select); } return $this->_select; } protected function _joinApplication(Zend_Db_Select $select) { $select->joinLeft( $this->_getPair('Application', 'a'), '`a`.`class` = `vcl`.`controller`', ['controllerTitle' => 'title'] ); return $this; } public function getMinDate() { $select = $this->_db->select(); $select->from($this->_getPair(), 'MIN(`added`)'); return $this->_db->fetchOne($select); } public function getDataSize() { $config = Qs_Db::getConfig(); $sql = 'SHOW TABLE STATUS ' . 'FROM `' . $config->database->params->dbname . '` ' . "LIKE '{$config->database->tablePrefix}ViewControllerLog%'"; $list = Qs_Db::getInstance()->fetchAll($sql); return Qs_Array::sum($list, 'Data_length') + Qs_Array::sum($list, 'Index_length'); } public function getObjectInfo() { $info = parent::getObjectInfo(); $role = $this->getSessionInfo('role'); $roleId = $this->getSessionInfo('roleId'); $info['itemsName'] = $this->getRoleTitle($role, $roleId) . ' ' . Entity::$roleTitles[$role] . ' ' . $this->getConfig('itemsName'); return $info; } }