_role = $role; return $this; } /** * @return string */ public function getRole() { return $this->_role; } public function exec() { $this->_getDataObj()->setRole($this->getRole()); return parent::exec(); } public function _doAutocompleteAjax() { $term = Qs_Request::getGetValue('term'); $data = $this->_getDataObj()->getAutocomplete($term); $this->_displayJson($data); } protected function _getFilterFormOptions() { $options = parent::_getFilterFormOptions(); $options['role'] = $this->getRole(); $roleId = Qs_Request::getGetValue('roleId'); if ($roleId) { $role = $this->getRole(); switch ($role) { case Entity::ROLE_USER: $options['defaults']['roleIdTitle'] = $this->_getDataObj()->getUserNameById($roleId); break; case Entity::ROLE_ADMIN: $options['defaults']['roleIdTitle'] = $this->_getDataObj()->getAdminNameById($roleId); break; case Entity::ROLE_STAFF: throw new Exception('Role "' . $role . '" not implemented.'); break; default: throw new Exception('Unknown role "' . $role . '".'); } } return $options; } protected function _getListOptions() { $options = parent::_getListOptions(); $options['role'] = $this->getRole(); $options['hasRoleId'] = (bool) $this->_getDataObj()->getFilter('roleId'); return $options; } protected function _doList() { $this->_initNavigation(); $this->_addRoleInfo(); parent::_doList(); } protected function _addRoleInfo() { if (($roleId = Qs_Request::getGetValue('roleId'))) { $options = [ 'role' => $this->getRole(), 'roleId' => $roleId, 'doc' => $this->_doc, ]; (new RoleInfoView($options))->exec(); } } protected function _initNavigation() { if (($roleId = Qs_Request::getGetValue('roleId'))) { Qs_Navigation::clean(); Qs_Navigation::add(['title' => $this->_doc->getHeader(), 'url' => $this->url()]); Qs_Navigation::add([ 'title' => 'Sessions of ' . $this->_getDataObj()->getRoleNameById($this->getRole(), $roleId), 'url' => '' ]); Qs_Navigation::enable(); } return $this; } }