function init() { parent::init(); $this->view->isAdminController = true; $template_path = $this->_theme_locations['admin']['current_theme']['path'] . "/tpl_controllers/" . $this->getRequest()->getModuleName(); $this->view->setScriptPath($template_path); $this->view->base_path = substr($_SERVER['SCRIPT_FILENAME'], 0, strrpos($_SERVER['SCRIPT_FILENAME'], "/")); $this->view->admin_theme_path = $this->_theme_locations['admin']['current_theme']['path']; $this->view->admin_theme_url = $this->_theme_locations['admin']['current_theme']['url']; $this->view->admin_theme_global_path = $this->_theme_locations['admin']['current_theme']['path']."/tpl_common"; $this->view->admin_theme_controller_path = $this->_theme_locations['admin']['current_theme']['path'].'/tpl_controllers/'.$this->getRequest()->getControllerName(); $this->view->admin_theme_module_path = $this->_theme_locations['admin']['current_theme']['path'].'/tpl_controllers'; $this->view->default_admin_theme_path = $this->_theme_locations['admin']['default_theme']['path']; $this->view->default_admin_theme_url = $this->_theme_locations['admin']['default_theme']['url']; $this->view->default_admin_theme_global_path = $this->_theme_locations['admin']['default_theme']['path']."/tpl_common"; $this->view->default_admin_theme_controller_path = $this->_theme_locations['admin']['default_theme']['path'].'/tpl_controllers/'.$this->getRequest()->getControllerName(); $this->view->default_admin_theme_module_path = $this->_theme_locations['admin']['default_theme']['path'].'/tpl_controllers'; $request = $this->getRequest(); if ($request->has('dev') && $request->dev == true) $this->view->isDeveloper = true; $this->view->current_path = $this->_theme_locations['admin']['current_theme']['path'] . "/tpl_controllers/" . $this->getRequest()->getControllerName(); $roles_table = new Roles(); $locale_table = new Locales(); if ($this->_identity->isAdmin) { $bypass = array(); $globalRoles = explode(",", RivetyCore_Registry::get('global_role_shortnames')); $inherited_roles = array(); foreach ($this->my_roles as $role => $value) { $ids = $roles_table->getAllAncestors($value['id']); $inherited_roles = array_merge($inherited_roles, $ids, array($value['id'])); $all_shortnames = array(array("id" => $value['id'], "shortname" => $value['shortname'])); foreach ($ids as $bp) { $all_shortnames[] = array("id" => $bp, "shortname" => $roles_table->getShortnameById($bp)); } $all_locales = $locale_table->getLocaleCodesArray(true); foreach ($all_shortnames as $sn) { if (array_key_exists(strtolower(substr($sn['shortname'], -5)),$all_locales) && strtolower(substr($sn['shortname'], -5)) == strtolower($this->locale_code)) { $bypass[] = $sn['id']; // if current locale, get other locale restricted roles for that locale for navigation } if (strtolower(substr($sn['shortname'], -6)) == "global" || in_array($sn['shortname'],$globalRoles) || in_array($sn['id'],$globalRoles)) { $bypass[] = $sn['id']; } } } $inherited_roles = array_unique($inherited_roles); sort($inherited_roles); $this->view->all_roles = array_unique($inherited_roles); $bypass = array_unique($bypass); sort($bypass); $this->view->bypass = $bypass; if (@RivetyCore_ResourceCheck::isAllowed("locale_specific_admin_role", "default", $this->_identity->username)) { $this->_bumpRegionalAccess($bypass); } // This variable is set in $this->_bumpRegionalAccess() if (isset($this->restricted_role_id) && count($this->restricted_role_id) > 0) { $restr = array(); foreach ($this->restricted_role_id as $role ) { $restr[] = $role['id']; } $tmp_ids = array_unique($restr); $nav_parent_role_ids = array(); foreach($tmp_ids as $nav_role){ $nav_parent_role_ids = array_merge($nav_parent_role_ids, $roles_table->getAllAncestors($nav_role)); } $nav_role_ids = array_merge($nav_parent_role_ids, $tmp_ids, $bypass); $unique_ids = array_unique($nav_role_ids); $nav_table = new Navigation($unique_ids, $this->locale_code); $cache = new RivetyCore_Cache(); $cache_name = 'navigation_admin_'.$this->locale_code.'-'.md5(implode($unique_ids,"-")); // MD5 The Unique IDs to shorten the cache name $cache_tags = array('navigation', 'admin_navigation', $this->locale_code); $nav_items_temp = $cache->load($cache_name); if ($nav_items_temp === false || !isset($nav_items_temp)) { $nav_items_temp = array(); foreach ($unique_ids as $nav_role_id) { $nav_items_temp = array_merge($nav_items_temp, $nav_table->getNavTree($nav_role_id)); } $cache->save($nav_items_temp, $cache_name, $cache_tags); } $navparams = array('nav_items' => $nav_items_temp, 'request' => $this->_request, 'locale_code' => $this->locale_code); $navparams = $this->_rivety_plugin->doFilter('controller_nav', $navparams); // FILTER HOOK $this->view->nav_items = $navparams['nav_items']; $this->view->access = $this->restricted_role_id; } else { $access = array(); $roles = $inherited_roles; foreach ($roles as $role) { $in = $this->_checkMatch($role); if (count($in) > 0) { foreach ($in as $i) { $access[] = array("id"=>$i,"shortname"=>$roles_table->getShortnameById($i)); } } } $this->view->access = $access; } } }
private function move($request, $adjustment) { if ($request->has('nav_id') && $request->has('role_id')) { $nav_id = $request->nav_id; $role_id = $request->role_id; $class_name = "Navigation"; $params = array($role_id, $this->locale_code); RivetyCore_Sort::adjustSortValue($class_name, $nav_id, $adjustment, 'id', 'sort_order', $params); $where_clause = $request->has('parent_id') ? "parent_id = " . $request->parent_id . " and role_id = " . $role_id : "parent_id = 0 and role_id = " . $role_id; RivetyCore_Sort::reNumber($class_name, "parent_id = " . $request->parent_id . " and role_id = " . $role_id, 'id', 'sort_order', 10, $params); RivetyCore_Cache::removeByTags(array('navigation')); $this->_redirect("/default/navigation/editrole/id/" . $role_id); } else { $this->_redirect("/default/auth/missing"); } }