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[int_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[int_langId()]; if (!isset($title)) { switch ($module) { case 'stat': $title = $_stat[$module_key][int_langId()]; break; case 'sites': $title = $_sites[$module_key][int_langId()]; break; } } if (!in_array($module_key . '_' . $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_key . '_' . $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(); }
function modules_select() { $root_id = 0; $id = (int) get('id', 0); if ($id) { $root_id = sql_getValue("SELECT root_id FROM tree WHERE id=" . $id); } if (!$root_id) { $pid = (int) get('pid', 0); if ($pid) { $root_id = sql_getValue("SELECT root_id FROM tree WHERE id=" . $pid); } } $function_modules = $root_id ? $GLOBALS['cfg']['function_modules'][$root_id] : array(); $mods = array('' => $this->str('_default_module')); foreach ($function_modules as $k => $v) { $mods[$k] = utf($v['name'][int_langId()]); } return $mods; }
function ordSuffix($num) { if (int_langId() == 0) { return $num . '-е'; } $sLastChar = substr($num, -1); $sSecondToLastChar = substr($num, -2, 1); if ($sSecondToLastChar != 1) { switch ($sLastChar) { case 1: $suffix = 'st'; break; case 2: $suffix = 'nd'; break; case 3: $suffix = 'rd'; break; default: $suffix = 'th'; break; } } else { $suffix = 'th'; } return $num . $suffix; }
function EditForm() { $id = (int) get('id', 0); if ($id) { $row = $this->getRow($id); $type = $row['html'] ? 'html' : 'img'; } else { $row['id'] = $id; $row['visible'] = 1; $row['target'] = 1; $row['position'] = ''; $row['root_id'] = get('root_id', '100'); $columns = sql_getRows('SHOW COLUMNS FROM banners', true); if (isset($columns['alt_image'])) { $row['alt_image'] = ''; } if (isset($columns['show_at_sites'])) { $row['show_at_sites'] = ''; } $type = 'image'; } $GLOBALS['title'] = $this->str($id ? 'edit' : 'add'); $this->AddStrings($row); $row['visible_checked'] = $row['visible'] ? 'checked' : ''; if (!empty($row['pages'])) { $row['pages_checked'] = 'checked'; } if (isset($row['image']) && is_file(".." . $row['image'])) { $ext = strtolower(get_file_ext($row['image'])); $size = getimagesize(".." . $row['image']); // Рисуем картинку if ($ext == '.gif' || $ext == '.jpg' || $ext == '.png') { $row['img_preview'] = '<img src="' . $row['image'] . '" ' . $size[3] . ' alt="" />'; } elseif ($ext == '.swf') { $row['img_preview'] = str_replace(array('{filename}', '{width}', '{height}'), array($row['image'], $size[0], $size[1]), $this->swf_code); } } if (isset($row['alt_image']) && is_file(".." . $row['alt_image'])) { $ext = strtolower(get_file_ext($row['alt_image'])); $size = getimagesize(".." . $row['alt_image']); // Рисуем картинку if ($ext == '.gif' || $ext == '.jpg' || $ext == '.png') { $row['alt_img_preview'] = '<img src="' . $row['alt_image'] . '" ' . $size[3] . ' alt="" />'; } } $row['options_target'] = $this->GetArrayOptions(array('_self', '_blank'), $row['target'], true, true); // Список положений баннера foreach ($this->position as $key => $val) { $options_pos[$key] = utf($val['display'][int_langId()]); } $row['options_pos'] = $this->GetArrayOptions($options_pos, $row['position'], true, false); // Список сайтов if (isset($row['show_at_sites'])) { global $site_domains; $sites = array(); $root = domainRootID(); foreach ($site_domains as $key => $val) { foreach ($val['langs'] as $l) { if ($l['root_id'] != $root) { $sites[$l['root_id']] = (LANG_SELECT && !empty($val['descr_' . lang()]) ? $val['descr_' . lang()] : (!empty($val['descr']) ? $val['descr'] : $val['name'])) . ' (' . $l['descr'] . ')'; } } } $row['sites'] = $sites; if (!empty($row['show_at_sites'])) { $row['show_at_sites'] = explode(",", $row['show_at_sites']); } } // Список вариантов для редактирования баннеров $options_type = array('img', 'html'); $row['options_type'] = $this->GetArrayOptions($options_type, $type, false, true); // Текст для HTML баннера include_fckeditor(); $oFCKeditor = new FCKeditor(); $oFCKeditor->ToolbarSet = 'Common'; $oFCKeditor->Value = isset($row['html']) ? $row['html'] : ''; $row['html'] = $oFCKeditor->ReturnFCKeditor('fld[html]', '100%', '300px'); return $this->Parse($row, $this->name . '.editform.tmpl'); }
function getPrivs($group_id) { $group_id = (int) $group_id; $sql = "\n\t\t\tSELECT\n\t\t\t\tpriv_code\n\t\t\tFROM\n\t\t\t\tauth_groups_privs\n\t\t\tWHERE\n\t\t\t\tgroup_id = " . $group_id; $user_privs = sql_getRows($sql); $module_info = $this->getModulesInfo(); $modules = array(); foreach ($module_info as $module_name => $module) { if (!is_array($module['privs']) || empty($module['privs'])) { continue; } $modules[$module_name] = array(); $modules[$module_name]['module_name'] = $module_name; // @todo поправить определение названия модуля $modules[$module_name]['module_title'] = $GLOBALS['cfg']['modules'][$module_name]['display'][int_langId()]; foreach ($module['privs'] as $priv_code => $display) { $modules[$module_name]['privs'][] = array('priv_title' => $display[int_langId()], 'priv_code' => $priv_code, 'checked' => in_array($priv_code, $user_privs)); } } return $modules; }
function EditForm() { $id = (int) get('id', 0); if ($id) { $row = $this->getRow($id); $type = $row['html'] ? 'html' : 'img'; } else { $row['id'] = $id; $row['visible'] = 1; $row['target'] = 1; $row['position'] = ''; $row['root_id'] = get('root_id', '100'); $type = 'image'; } $GLOBALS['title'] = $this->str($id ? 'edit' : 'add'); $this->AddStrings($row); $row['visible_checked'] = $row['visible'] ? 'checked' : ''; if (!empty($row['pages'])) { $row['pages_checked'] = 'checked'; } if (isset($row['image']) && is_file(".." . $row['image'])) { $ext = strtolower(get_file_ext($row['image'])); $size = getimagesize(".." . $row['image']); // Рисуем картинку if ($ext == '.gif' || $ext == '.jpg' || $ext == '.png') { $row['img_preview'] = '<img src="' . $row['image'] . '" ' . $size[3] . ' alt="" />'; } elseif ($ext == '.swf') { $row['img_preview'] = str_replace(array('{filename}', '{width}', '{height}'), array($row['image'], $size[0], $size[1]), $this->swf_code); } } $row['options_target'] = $this->GetArrayOptions(array('_self', '_blank'), $row['target'], true, true); // Список положений баннера foreach ($this->position as $key => $val) { $options_pos[$key] = utf($val['display'][int_langId()]); } $row['options_pos'] = $this->GetArrayOptions($options_pos, $row['position'], true, false); // Список вариантов для редактирования баннеров $options_type = array('img', 'html'); $row['options_type'] = $this->GetArrayOptions($options_type, $type, false, true); // Текст для HTML баннера include_fckeditor(); $oFCKeditor = new FCKeditor(); $oFCKeditor->ToolbarSet = 'Common'; $oFCKeditor->Value = $row['html']; $row['html'] = $oFCKeditor->ReturnFCKeditor('fld[html]', '100%', '300px'); return $this->Parse($row, $this->name . '.editform.tmpl'); }
/** * Список всех доступных для данного пользователя модулей * * @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; }
function editForm() { global $actions, $str, $intlang; $page = get('page', '', 'gp'); $id = get('id', 0, 'pg'); // загружаем список tab и для каждого вызываем loadTab include_once elem($page . "/" . $page); $class_name = 'T' . ucfirst($page); $this->object =& Registry::get($class_name); $act_title = $str[strtolower($class_name)]['title']; if (isset($str[strtolower($class_name)]['title_editform'])) { $act_title = $str[strtolower($class_name)]['title'] = $str[strtolower($class_name)]['title_editform']; } // Если это форма редактирования открыта через фрейм, то поищем спец elem для класса if (isset($_GET['frame']) && $_GET['frame'] == 'view' && elem($_GET['page'] . "/elem_main_" . $_GET['page_name'])) { $this->tabs['tab0'] = array('display' => array('ru' => 'Основное', 'en' => 'Main'), 'conf' => array('elem' => "elem_main_" . $_GET['page_name'], 'elem_type' => 'single', 'target' => 'cnt')); } else { $this->getTabs(); } // id записи $data['id'] = $id; // submodule $data['thisname'] = $data['page'] = $this->submodule; $data['thisname'] = str_replace('/', '', $data['thisname']); // это нужно только для вложенных модулей $data['tablename'] = $this->table; $data['last'] = get('last', '', 'gp'); global $oed_vars; if (isset($oed_vars['first'])) { $data['first'] = $oed_vars['first']; } if (isset($oed_vars['last'])) { $data['last'] = $oed_vars['last']; } // контент вкладок foreach ($this->tabs as $key => $value) { if (isset($_GET['frame']) && $_GET['frame'] == 'view') { // Для форм, открытых в fancybox, надо оставить только основной таб // Возможно в будущем научимся и другие вкладки сохранять if ($value['conf']['elem'] != 'elem_main' && strpos($value['conf']['elem'], 'elem_main_') === false) { unset($this->tabs[$key]); continue; } } $this->loadTab($key); $tab_cfg = $this->getTabCfg($value); if ($value['conf']['elem_type'] != 'single') { $data['noform'] = true; } $data['form_content'][$key]['content'] = $this->ShowTab($key); $data['form_content'][$key]['name'] = isset($value['display'][int_lang()]) ? $value['display'][int_lang()] : (isset($this->object->elements_titles[$value['conf']['elem']]) ? $this->object->elements_titles[$value['conf']['elem']][int_langId()] : $value['conf']['elem']); $data['form_content'][$key]['select'] = $key == 'tab0' ? 'select' : ''; } // Если это дерево разделов, то отобразим путь (хлебные крошки) if ($page == "tree") { $pid = get('pid', 0, 'pg'); $data['path'] = $this->object->GetPath($id ? $id : $pid); } // Сама форма $content = $this->Parse($data, 'ed.cnt.tmpl'); $cnt = Parse(array('content' => $content), 'cnt.tmpl'); // Кнопки $actions = array('title' => $act_title[$intlang], 'window_icons' => $this->WindowIcons(), 'actions_bot' => $this->GetActions($actions[$this->object->name . '.editform'], 'bot'), 'cnt' => $cnt); return Parse($actions, 'act.tmpl'); }