Пример #1
0
 function init()
 {
     parent::init();
     $this->view->full_name_length = Bolts_Registry::get('full_name_length');
     $this->view->username_length = Bolts_Registry::get('username_length');
     $this->_users_table = new Users();
     if ($this->_auth->hasIdentity()) {
         $default = $this->_identity->username;
     } else {
         $default = null;
     }
     $request = $this->getRequest();
     $this->_username = $request->getParam('username', $default);
     $this->_user = $this->_users_table->fetchByUsername($this->_username);
     if (!is_null($this->_user)) {
         $this->view->nav_username = $this->_username;
         $this->view->user = $this->_user->toArray();
     }
 }
Пример #2
0
 function init()
 {
     parent::init();
 }
Пример #3
0
 function init()
 {
     parent::init();
     $template_path = $this->_theme_locations['admin']['current_theme']['path'] . "/modules/" . $this->getRequest()->getModuleName();
     $this->view->setScriptPath($template_path);
     $this->view->isAdminController = true;
     $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'] . "/global";
     $this->view->admin_theme_controller_path = $this->_theme_locations['admin']['current_theme']['path'] . '/modules/' . $this->getRequest()->getModuleName() . "/" . $this->getRequest()->getControllerName();
     $this->view->admin_theme_module_path = $this->_theme_locations['admin']['current_theme']['path'] . '/modules/' . $this->getRequest()->getModuleName();
     $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'] . "/global";
     $this->view->default_admin_theme_controller_path = $this->_theme_locations['admin']['default_theme']['path'] . '/modules/' . $this->getRequest()->getModuleName() . "/" . $this->getRequest()->getControllerName();
     $this->view->default_admin_theme_module_path = $this->_theme_locations['admin']['default_theme']['path'] . '/modules/' . $this->getRequest()->getModuleName();
     $request = $this->getRequest();
     if ($request->has('dev') && $request->dev == true) {
         $this->view->isDeveloper = true;
     }
     $this->view->current_path = $template_path . "/" . $this->getRequest()->getControllerName();
     $roles_table = new Roles();
     $locale_table = new Locales();
     if ($this->_identity->isAdmin) {
         $bypass = array();
         $globalRoles = explode(",", Bolts_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 (@Bolts_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 Bolts_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->_Bolts_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;
         }
     }
 }