Пример #1
0
 function ElemInit()
 {
     global $cfg, $sections, $hidden_sections, $_stat, $_sites, $intlang;
     $row = array();
     $modules_in_row = array();
     $i = 0;
     $id = (int) get('id');
     if ($id) {
         $row = sql_getRow("SELECT * FROM `admin_groups` WHERE id='" . $id . "'");
         $row['rights'] = unserialize($row['rights']);
     }
     // ALLOW ->	DEL		INS		UPD		SELECT
     // none  ->	0		0		0		0			=  0
     // view  ->	0		0		0		1           =  1
     // edit	 ->	0		1		1		1           =  7
     // del	 ->	1		1		1		1           = 15
     $row['radios'] = array('0' => '', '1' => '', '7' => '', '15' => '');
     // если указаны скрытые модули - надо их также вывести
     // для возможности задания прав группам пользователей.
     if (isset($hidden_sections)) {
         $sections = array_merge($sections, $hidden_sections);
     }
     foreach ($sections as $key => $section) {
         $row['menu'][$i]['title'] = utf($section[langId()]);
         $row['menu'][$i]['i'] = $i;
         foreach ($section['modules'] as $module_key => $module) {
             if (count(explode("/", $module_key)) > 1) {
                 $arr = explode("/", $module_key);
                 $module = $arr[0];
             }
             if (!is_module_auth($module_key)) {
                 continue;
             }
             // set the title
             unset($title);
             $title = $module[langID()];
             if (!isset($title)) {
                 switch ($module) {
                     case 'stat':
                         $title = $_stat[$module_key][langID()];
                         break;
                     case 'sites':
                         $title = $_sites[$module_key][langID()];
                         break;
                 }
             }
             if (!in_array($module . '_' . $title, $modules_in_row)) {
                 $row['menu'][$i]['rows'][] = array('menu' => $i, 'name' => 'fld[rights][' . $module_key . ']', 'title' => utf($title), 'selected' => !empty($row['rights'][$module_key]) ? $row['rights'][$module_key] : 0);
                 $modules_in_row[] = $module . '_' . $title;
             }
         }
         $i++;
     }
     foreach ($this->elem_str as $str_key => $str_val) {
         $row['str_' . $str_key] = $str_val[$intlang];
     }
     $table = $this->Parse($row, 'admin_groups.editform.tmpl');
     $this->elem_fields['columns']['table'] = array('type' => 'words', 'value' => $table);
     return parent::ElemInit();
 }
Пример #2
0
 /**
  * Список всех доступных для данного пользователя модулей
  *
  * @return array
  */
 function getAllModules()
 {
     global $cfg, $sections, $hidden_sections, $_stat, $_sites;
     $row = array();
     $modules_in_row = array();
     $id = (int) get('id');
     if ($id) {
         $row = $this->getRow($id);
         $row['rights'] = unserialize($row['rights']);
     }
     // если указаны скрытые модули - надо их также вывести
     // для возможности задания прав группам пользователей.
     if (isset($hidden_sections)) {
         $sections = array_merge($sections, $hidden_sections);
     }
     $i = 0;
     foreach ($sections as $key => $section) {
         $row[$i] = array('name' => $section[0], 'items' => array());
         foreach ($section['modules'] as $module_key => $module) {
             $module_name = $module_key;
             if (count(explode("/", $module_key)) > 1) {
                 $arr = explode("/", $module_key);
                 $module_name = $arr[0];
             }
             if (!is_module_auth($module_name)) {
                 continue;
             }
             // set the title
             unset($title);
             $title = $module[int_langId()];
             if (!isset($title)) {
                 switch ($module) {
                     case 'stat':
                         $title = $_stat[$module_name][int_langId()];
                         break;
                     case 'sites':
                         $title = $_sites[$module_name][int_langId()];
                         break;
                 }
             }
             if (!in_array($title, $modules_in_row)) {
                 $row[$i]['items'][] = array('name' => $module_name, 'title' => utf($title));
                 $modules_in_row[] = $title;
             }
         }
         $i++;
     }
     return $row;
 }