1) { $this->assign('LANGUAGES', $list); } $this->_initSearchForm(); $this->_initKeepSession(); return $this; } public function getMenu() { if (null === $this->_content['menu']) { $this->_content['menu'] = Qs_SiteMap::getMenu(); foreach (array_keys($this->_content['menu']) as $key) { switch ($this->_content['menu'][$key]['id']) { case self::DASHBOARD_PAGE_ID: $this->_prepareDashboardMenu($this->_content['menu'][$key]); break; case self::DEPARTMENT_PROCESS_PAGE_ID: $this->_prepareDepartment($this->_content['menu'][$key]); break; case self::OPTIONS_PAGE_ID: $this->_prepareAdminSection($this->_content['menu'][$key], $key); break; case self::MANAGE_PAGE_ID: $this->_prepareManageSection($this->_content['menu'][$key], $key); break; case self::SEARCH_PAGE_ID: $this->_content['menu'][$key]['search'] = array( 'menuType' => 'input', 'fullAlias' => $this->_content['menu'][$key]['fullAlias'], 'url' => BASE_URL_LANGUAGE . '/' . $this->_content['menu'][$key]['fullAlias'] ); break; default: break; } } if ($this->getAuthData('id')) { $this->_content['menu']['search_tool'] = Qs_Sys_SiteMap::findFirst(null, array('type' => 'Search_Tool_')); } } return $this->_content['menu']; } protected function _prepareAdminSection(&$item, $key) { $item['click'] = false; if ($this->acl->isAllowed($this->getAuthData('id'), 'user', 'edit') || $this->acl->isAllowed($this->getAuthData('id'), 'settings', 'edit')) { foreach ($item['sub'] as $subKey => $sub) { switch ($sub['id']) { case self::USERS_PAGE_ID: if (!$this->acl->isAllowed($this->getAuthData('id'), 'user', 'edit')) { unset($item['sub'][$subKey]); } break; case self::SETTINGS_PAGE_ID: if (!$this->acl->isAllowed($this->getAuthData('id'), 'settings', 'edit')) { unset($item['sub'][$subKey]); } break; } } } else { unset($this->_content['menu'][$key]); } return $this; } protected function _prepareManageSection(&$item, $key) { if (App_User_Auth::getInstance()->isLoggedIn()) { foreach (array_keys($item['sub']) as $subKey) { switch ($item['sub'][$subKey]['id']) { case self::DEPARTMENT_PAGE_ID: $this->_addUrlNew($item['sub'][$subKey], 'department'); break; case self::PART_PAGE_ID: $this->_addUrlNew($item['sub'][$subKey], 'part'); break; case self::CLIENT_PAGE_ID: $this->_addUrlNew($item['sub'][$subKey], 'client'); break; default: break; } } } else { unset($this->_content['menu'][$key]); } return $this; } protected function _addUrlNew(&$item, $type) { if ($this->acl->isAllowed($this->getAuthData('id'), $type, 'add')) { $item['aliasNew'] = $item['fullAlias']; $item['titleNew'] = $type; } return $this; } protected function _prepareDashboardMenu(&$item) { $dashboardObj = new App_Dashboard_Obj(); $userId = $this->getAuthData('id'); $item['menuType'] = 'dashboard'; $item['sub'] = $dashboardObj->getDashboardItems($userId); return $this; } protected function _prepareDepartment(&$item) { $departmentObj = new App_Department_Obj(); $item['menuType'] = 'department'; $leaveEmptyDepartments = $this->acl->isAllowed($this->getAuthData('id'), 'department', 'add') || $this->acl->isAllowed($this->getAuthData('id'), 'process', 'add'); $item['sub'] = $departmentObj->getWideList(0, $leaveEmptyDepartments); $item['click'] = false; return $this; } public function getAuthData($field = false, $default = null) { if ($this->getAuthIdentity()) { return $this->getAuth()->getData($field, $default); } return $default; } protected function _initSearchForm() { $this->addScript('js/app/search.js'); $params = array( array( 'url' => Qs_SiteMap::findFirst(null, array('type' => 'Search_'), null, 'url') ) ); $this->addInitFunction('App_Search.init', $params); return $this; } protected function _initKeepSession() { $interval = (int)Qs_Constant::get('SESSION_REFRESH_INTERVAL'); $interval = $interval ? $interval : 300; $this->addScript('js/lib/keep-session.js'); $this->addInlineScript( 'keepSession', '$(document).ready(function() { (new Qs_KeepSession({interval: ' . $interval . ', url: BASE_URL + "/keep-session"})).start(); });' ); return $this; } }