Пример #1
0
 public function __construct()
 {
     $ci =& get_instance();
     $ci->load->library('DX_Auth');
     self::$shop_controllers_path = MAINSITE . "/application/modules/shop/admin/";
     self::$base_controllers_path = MAINSITE . "/application/modules/admin/";
 }
 /**
  * Get installed modules array
  * @return array
  */
 private static function getInstalledMudules()
 {
     if (!self::$installed_modules) {
         $modules = CI::$APP->db->select('id, name')->get('components')->result_array();
         foreach ($modules as $key => $module) {
             $modules[$module['name']] = $module;
             unset($modules[$key]);
         }
         self::$installed_modules = $modules;
     }
     return self::$installed_modules;
 }
Пример #3
0
 public function __construct()
 {
     parent::__construct();
     $lang = new MY_Lang();
     $lang->load('admin');
     $this->load->library('Permitions');
     Permitions::checkPermitions();
     $this->load->library('lib_admin');
     $this->lib_admin->init_settings();
     $this->autoloadModules();
     //        if(!$_SESSION['GETTEXT_EXIST']){
     //            showMessage(lang('To improve performance set php_gettext.dll extension'), lang('Advice'));
     //        }
     //        $this->lang->load('admin');
 }
Пример #4
0
 function FillMenuItems($arMenuItems)
 {
     if (is_array($arMenuItems) and !empty($arMenuItems)) {
         $bCurrentFinded = false;
         foreach ($arMenuItems as $k => $arItem) {
             if (Permitions::CheckPathPerms($arItem[1])) {
                 $arMenuItem = array();
                 $arMenuItem["NAME"] = $arItem[0];
                 $arMenuItem["URL"] = $arItem[1];
                 $arMenuItem["PARAM"] = $arItem[2];
                 $arUrls[$k] = $arMenuItem["URL"];
                 if (getCurDir() == $arItem[1] or getCurPage() == $arItem[1]) {
                     $arMenuItem["CURRENT"] = "Y";
                     $bCurrentFinded = true;
                 } else {
                     $arMenuItem["CURRENT"] = "N";
                 }
                 $arMenuResultItems[$k] = $arMenuItem;
             }
         }
         if (!empty($arUrls) and !$bCurrentFinded) {
             $cur_url = '';
             $cur = '';
             foreach ($arUrls as $n => $url) {
                 if (strstr(getCurPage(), $url) or strstr(getCurDir(), $url)) {
                     if (strlen($cur_url) < strlen($url)) {
                         $cur = $n;
                         $cur_url = $url;
                     }
                 }
             }
             if ($cur != '') {
                 $arMenuResultItems[$cur]["CURRENT"] = "Y";
             }
         }
         return $arMenuResultItems;
     }
 }
Пример #5
0
            break;
    }
}
// Определение режима отображения сайта (пользовательский/админский)
if (!defined('APP_DISPLAY_MODE')) {
    if ($bIsAdmin && isset($_SESSION['SACID_DISPLAY_MODE']) && $_SESSION['SACID_DISPLAY_MODE'] == 'EDIT') {
        define("APP_DISPLAY_MODE", 'EDIT');
    } else {
        define("APP_DISPLAY_MODE", 'NORMAL');
    }
}
/**
 * Файл с пунктами меню администратора
 */
if ($bIsAdmin && APP_DISPLAY_MODE == 'NORMAL') {
    Panel::setItem('?sacid_display_mode=edit', 'Режим редактирования');
    Panel::setItem('/scriptacid/logout.php?logout=Y', 'Выход');
} elseif ($USER->IsAdmin() && APP_DISPLAY_MODE == 'EDIT') {
    Panel::setItem('<js>ChgPageTitle(\'' . $_SERVER['PHP_SELF'] . '\')', 'Изменить заголовок');
    Panel::setItem('<br>');
    Panel::setItem('<js>CreatePage()', 'Создать страницу');
    Panel::setItem('<js>EditPage()', 'Изменить страницу');
    Panel::setItem('<js>DeletePage()', 'Удалить страницу');
    Panel::setItem('<br>');
    Panel::setItem('<js>CreateDir()', 'Создать раздел');
    Panel::setItem('<br>');
    Panel::setItem('?sacid_display_mode=normal', 'Режим просмотра');
}
// Проверяем права пользователя на доступ к данной папке
$bAccessPath = Permitions::CheckPathPerms(getCurDir());
define("ACCESS_PATH", $bAccessPath);
 function _get_role_data($role_id)
 {
     // Load models
     $this->ci->load->model('dx_auth/roles', 'roles');
     $this->ci->load->model('dx_auth/permissions', 'permissions');
     // Clear return value
     $role_name = '';
     $parent_roles_id = array();
     $parent_roles_name = array();
     $permission = array();
     $parent_permissions = array();
     /* Get role_name, parent_roles_id and parent_roles_name */
     // Get role query from role id
     $query = $this->ci->roles->get_role_by_id($role_id);
     // Check if role exist
     if ($query->num_rows() > 0) {
         // Get row
         $role = $query->row();
         // Get role name
         $role_name = $role->name;
         /*
          Code below will search if user role_id have parent_id > 0 (which mean role_id have parent role_id)
          and do it recursively until parent_id reach 0 (no parent) or parent_id not found.
         
          If anyone have better approach than this code, please let me know.
         */
         // Check if role has parent id
         if (isset($role->parent_id) && $role->parent_id > 0) {
             // Add to result array
             $parent_roles_id[] = $role->parent_id;
             // Set variable used in looping
             $finished = FALSE;
             $parent_id = $role->parent_id;
             // Get all parent id
             while ($finished == FALSE) {
                 $i_query = $this->ci->roles->get_role_by_id($parent_id);
                 // If role exist
                 if ($i_query->num_rows() > 0) {
                     // Get row
                     $i_role = $i_query->row();
                     // Check if role doesn't have parent
                     if ($i_role->parent_id == 0) {
                         // Get latest parent name
                         $parent_roles_name[] = $i_role->name;
                         // Stop looping
                         $finished = TRUE;
                     } else {
                         // Change parent id for next looping
                         $parent_id = $i_role->parent_id;
                         // Add to result array
                         $parent_roles_id[] = $parent_id;
                         $parent_roles_name[] = $i_role->name;
                     }
                 } else {
                     // Remove latest parent_roles_id since parent_id not found
                     array_pop($parent_roles_id);
                     // Stop looping
                     $finished = TRUE;
                 }
             }
         }
     }
     /* End of Get role_name, parent_roles_id and parent_roles_name */
     /* Get user and parents permission */
     // Get user role permission
     $permission = $this->ci->permissions->get_permission_data($role_id);
     // Get user role parent permissions
     if (!empty($parent_roles_id)) {
         $parent_permissions = $this->ci->permissions->get_permissions_data($parent_roles_id);
     }
     /* End of Get user and parents permission */
     if ($role_id) {
         $data['role_name'] = Permitions::checkControlPanelAccess($role_id);
     }
     // Set return value
     //$data['role_name'] = $role_name;
     $data['parent_roles_id'] = $parent_roles_id;
     $data['parent_roles_name'] = $parent_roles_name;
     $data['permission'] = $permission;
     $data['parent_permissions'] = $parent_permissions;
     return $data;
 }