function nc_sub_class_get_classInfo($perm, $Array, $classTemplatesArr, $edit_class_select) { $nc_core = nc_Core::get_object(); $classInfo = ''; if ($perm->isSupervisor()) { $class_href = $nc_core->SUB_FOLDER . $nc_core->HTTP_ROOT_PATH . "admin/#"; if (!$Array['SrcMirror']) { $fspref = nc_get_file_mode('Class', $Array['Class_ID']) ? '_fs' : ''; $class_href .= !$Array['System_Table_ID'] ? "dataclass" . $fspref . ".edit(" . $Array['Class_ID'] . ")" : "systemclass" . $fspref . ".edit(" . $Array['System_Table_ID'] . ")"; } else { $class_href .= "object.list({$Array['SrcMirror']})"; } $classInfo = "\n <div>\n " . (!$Array['System_Table_ID'] ? $Array['SrcMirror'] ? CONTROL_CONTENT_SUBCLASS_MIRROR : CONTROL_CLASS_CLASS : CONTROL_CLASS_SYSTEM_TABLE) . ":\n <b>\n <a href='{$class_href}' target='_blank'>\n " . $Array["Class_Name"] . "\n </a>\n </b>\n </div><br />"; } if (!empty($classTemplatesArr)) { $classInfo .= "\n <div>\n <div>\n " . CONTROL_CLASS_CLASS_TEMPLATE . ":\n </div>\n\n <div>\n <select name='Class_Template_ID' id='Class_Template_ID' onchange=\"if (this.options[this.selectedIndex].value) {loadClassCustomSettings(this.options[this.selectedIndex].value); document.getElementById('classtemplateEditLink').disabled = (this.options[this.selectedIndex].value==" . $Array['Class_ID'] . " ? true : false)}\">\n <option value='{$Array['Class_ID']}'>" . CONTROL_CLASS_CLASS_DONT_USE_TEMPLATE . "</option>"; foreach ($classTemplatesArr as $classTemplate) { $classInfo .= "<option value='{$classTemplate['Class_ID']}'" . ($Array['Class_Template_ID'] == $classTemplate['Class_ID'] ? " selected" : "") . ">{$classTemplate['Class_Name']}</option>"; } $classInfo .= "</select>\n <button type='button' onclick=\"window.open('{$nc_core->SUB_FOLDER}{$nc_core->HTTP_ROOT_PATH}admin/#classtemplate" . (nc_get_file_mode('Class', $Array['Class_ID']) ? '_fs' : '') . ".edit(' + document.getElementById('Class_Template_ID').value + ')', 1)\" id='classtemplateEditLink'" . (!$Array['Class_Template_ID'] ? " disabled" : "") . ">" . CONTROL_CLASS_CLASS_TEMPLATE_BUTTON_EDIT . "</button></a>\n </div><br />\n\n " . ($edit_class_select ? "<div>{$edit_class_select}</div>" : '') . "\n </div>"; } return $classInfo; }
/** * функция удаляет макет * */ function DeleteTemplates() { global $nc_core, $db, $UI_CONFIG; while (list($key, $val) = each($_POST)) { if (substr($key, 0, 6) != "Delete") { continue; } $val = intval($val); if (!$val) { continue; } $val = (int) $val; $File_Mode = nc_get_file_mode('Template', $val); if ($File_Mode) { $template_editor = new nc_template_editor($nc_core->TEMPLATE_FOLDER, $nc_core->db); $template_editor->load_template($val); $template_editor->delete_template(); } $UI_CONFIG = new ui_config_template('delete', $val); $arr_templates = nc_get_template_children($val); if (count($arr_templates) > 1) { foreach ($arr_templates as $int_template_id) { // execute core action $nc_core->event->execute("dropTemplatePrep", $int_template_id); if (!$db->query("DELETE FROM `Template` WHERE `Template_ID` = '" . $int_template_id . "'")) { $SelectArray = $db->get_var("select Description from Template where Template_ID='" . $int_template_id . "'"); nc_print_status(CONTROL_TEMPLATE_ERR_CANTDEL . " " . $SelectArray . ". " . TOOLS_PATCH_ERROR, 'error'); } else { // execute core action $nc_core->event->execute("dropTemplate", $int_template_id); } DeleteSystemTableFiles('Template', $int_template_id); $UI_CONFIG->treeChanges['deleteNode'][] = "template-{$int_template_id}"; } } else { // execute core action $nc_core->event->execute("dropTemplatePrep", $val); if (!$db->query("delete from Template where Template_ID='" . $val . "'")) { $SelectArray = $db->get_var("select Description from Template where Template_ID='" . $val . "'"); nc_print_status(CONTROL_TEMPLATE_ERR_CANTDEL . " " . $SelectArray . ". " . TOOLS_PATCH_ERROR, 'error'); } else { // execute core action $nc_core->event->execute("dropTemplate", $val); } DeleteSystemTableFiles('Template', $val); $UI_CONFIG->treeChanges['deleteNode'][] = "template-{$val}"; } } }
function nc_get_class_template_form_select_by_array(array $class_date, $class_current_id) { $nc_core = nc_Core::get_object(); $result = '<div>' . CONTROL_CLASS_CLASS_TEMPLATE_EDIT_MODE . '</div>'; $result .= "\n<div>\n"; $result .= " <select id='Edit_Class_Template' name='Edit_Class_Template'>\n <option value='0'>" . CONTROL_CLASS_CLASS_TEMPLATE_EDIT_MODE_DONT_USE . "</option>\n"; foreach ($class_date as $class_id => $class_name) { $selected = $class_current_id == $class_id ? ' selected' : ''; $result .= " <option{$selected} value='{$class_id}'>{$class_name}</option>\n"; } $result .= " </select> <button id='nc_button_Edit_Class_Template' type='button' onclick=\"window.open('{$nc_core->SUB_FOLDER}{$nc_core->HTTP_ROOT_PATH}admin/#classtemplate" . (nc_get_file_mode('Class', $class_id) ? '_fs' : '') . ".edit(' + document.getElementById('Edit_Class_Template').value + ')', 1)\" id='classtemplateEditLink' >" . CONTROL_CLASS_CLASS_TEMPLATE_BUTTON_EDIT . " </button><br />\n"; $result .= "</div>\n\n <script type='text/javascript'>\n \$nc('#Edit_Class_Template').change(function() {\n if (\$nc(this).val() == 0) {\n \$nc('#nc_button_Edit_Class_Template').attr('disabled', 'disabled');\n } else {\n \$nc('#nc_button_Edit_Class_Template').attr('disabled', '');\n }\n });\n\n if (\$nc('#Edit_Class_Template').val() == 0) {\n \$nc('#nc_button_Edit_Class_Template').attr('disabled', 'disabled');\n }\n </script>"; return $result; }
/** * @param $id * @param array $params * @return bool * @throws nc_Exception_DB_Error */ public function update($id, $params = array()) { $nc_core = nc_Core::get_object(); $db = $this->db; $id = intval($id); if (!$id || !is_array($params)) { return false; } $File_Mode = nc_get_file_mode('Class', $id); if ($File_Mode) { $class_editor = new nc_class_editor($nc_core->CLASS_TEMPLATE_FOLDER, $db); } if ($params['action_type'] == 1) { $params_int = array('CacheForUser'); $params_text = array('Class_Name', 'Class_Group'); } else { $params_int = array('AllowTags', 'RecordsPerPage', 'System_Table_ID', 'NL2BR', 'UseCaptcha', 'UseAltTitle'); $params_text = array('FormPrefix', 'FormSuffix', 'RecordTemplate', 'SortBy', 'RecordTemplateFull', 'TitleTemplate', 'AddTemplate', 'EditTemplate', 'AddActionTemplate', 'EditActionTemplate', 'SearchTemplate', 'FullSearchTemplate', 'SubscribeTemplate', 'Settings', 'AddCond', 'EditCond', 'SubscribeCond', 'DeleteCond', 'CheckActionTemplate', 'DeleteActionTemplate', 'CustomSettingsTemplate', 'ClassDescription', 'DeleteTemplate', 'TitleList'); } if ($File_Mode) { $class_editor->load($id); $class_editor->save_fields($only_isset_post = true); $params_text = $class_editor->get_clear_fields($params_text); } $query = array(); foreach ($params as $k => $v) { if (!in_array($k, $params_int) && !in_array($k, $params_text)) { continue; } $query[] = "`" . $db->escape($k) . "` = '" . $db->prepare($v) . "'"; } if (!empty($query)) { $ClassTemplate = $db->get_var("SELECT `ClassTemplate` FROM `Class` WHERE `Class_ID` = '" . $id . "' "); @$nc_core->event->execute("updateSystemTablePrep", 3); if (!$ClassTemplate) { $nc_core->event->execute("updateClassPrep", $id); } else { $nc_core->event->execute("updateClassTemplatePrep", $ClassTemplate, $id); } $db->query("UPDATE `Class` SET " . join(",\n ", $query) . " WHERE `Class_ID` = " . $id); if ($db->is_error) { throw new nc_Exception_DB_Error($db->last_query, $db->last_error); } if (!$ClassTemplate) { $nc_core->event->execute("updateClass", $id); } else { $nc_core->event->execute("updateClassTemplate", $ClassTemplate, $id); } @$nc_core->event->execute("updateSystemTable", 3); } $this->data = array(); return true; }
} $File_Mode = +$_REQUEST['fs']; if (in_array($phase, array(3, 5, 7))) { if (!$nc_core->token->verify()) { if ($_POST["NC_HTTP_REQUEST"] || NC_ADMIN_ASK_PASSWORD === false) { // AJAX call header($_SERVER['SERVER_PROTOCOL'] . " 401 Authorization Required"); exit; } BeginHtml($Title2, $Title2, ""); nc_print_status(NETCAT_TOKEN_INVALID, 'error'); EndHtml(); exit; } } $File_Mode = nc_get_file_mode('Template', $phase == 3 ? $_POST['ParentTemplateID'] : $TemplateID); switch ($phase) { case 1: # покажем список всех темплейтов BeginHtml($Title2, $Title2, "http://" . $DOC_DOMAIN . "/management/design/"); $perm->ExitIfNotAccess(NC_PERM_TEMPLATE, 0, 0, 0, 0); $UI_CONFIG = new ui_config_template('list', $TemplateID); FullTemplateList(); break; case 2: # покажем форму добавления темплейта BeginHtml($Title6, $Title3 . $Delimeter . $Title6, "http://" . $DOC_DOMAIN . "/management/design/form/"); $perm->ExitIfNotAccess(NC_PERM_TEMPLATE, 0, 0, 0, 0); TemplateForm(0, 3, 1, $File_Mode); break; case 3:
function nc_classtemplate_make_trash($class_id) { $component = new nc_Component($class_id); $File_Mode = nc_get_file_mode('Class', $class_id); // поля, которые могут попасть в ленту $fields = $component->get_fields(); $string_fields = $component->get_fields(NC_FIELDTYPE_STRING); $text_fields = $component->get_fields(NC_FIELDTYPE_TEXT); // ищем поле для titl'a $title = ''; if (!empty($string_fields)) { foreach ($string_fields as $v) { if (nc_preg_match('/(titl|caption|name|subject)/i', $v['name'])) { $title = 'f_' . $v['name']; break; } } } if (empty($title) && !empty($string_fields)) { $title = 'f_' . $string_fields[0]['name']; } elseif (empty($title) && empty($string_fields) && !empty($text_fields)) { $title = 'f_' . $text_fields[0]['name']; } elseif (empty($title) && !empty($fields)) { $title = 'f_' . $fields[0]['name'] . ($fields[0]['type'] == 6 ? '_name' : NULL); } elseif (empty($title)) { $title = 'f_RowID'; } $record = $File_Mode ? '<?php echo "' : ''; $record .= '$f_AdminButtons $' . $title . "<br /><br />\r\n"; $record .= $File_Mode ? '"; ?>' : ''; return array('RecordTemplate' => $record); }
# проверочка if (!($_POST['act'] && $_POST['classID']) || !($perm->isSupervisor() || $perm->isDirector())) { exit; } # переназначаем $classID, потому что после предыдущего инклуда он слетает на 1, т.к. не задан! $classID = $_POST['classID']; # если параметр - системная таблица if ($_POST['systemTableID']) { $systemTableID = $_POST['systemTableID']; if ($systemTableID == 3) { $user_table_mode = true; } } # данные о полях в этом компоненте require $ROOT_FOLDER . "message_fields.php"; $File_Mode = nc_get_file_mode('Class', $classID); switch ($action) { case "add": case "change": case "search": case "message": # получаем код формы if ($File_Mode) { $result = nc_fields_form_fs($action); } else { $result = nc_fields_form($action); } break; case "addcond": case "editcond": # получаем код формы
$cc = intval($nc_core->input->fetch_get_post('cc')); $type_id = intval($nc_core->input->fetch_get_post('type_id')); $date_b = intval($nc_core->input->fetch_get_post('date_b')); $date_e = intval($nc_core->input->fetch_get_post('date_e')); if (!$cc) { exit; } if (!is_object($perm) || !$perm->isSubClass($cc, MASK_DELETE)) { exit; } // удаленные объекты $nc_trashed_objs = $db->get_results("\nSELECT `tr`.`Type`, `tr`.`Trash_ID`, `tr`.`Message_ID`, `tr`.`Class_ID`, `tr`.`Sub_Class_ID`, `tr`.`XML_Filename`, `tr`.`XML_Filesize`, `tr`.`IP`, `tr`.`UserAgent`, `tr`.`User_ID`, `u`.`" . $nc_core->AUTHORIZE_BY . "` as `Login`, DATE_FORMAT( `tr`.`Created`,'%d.%m.%Y, %H:%i') as `Created`\nFROM `Trash_Data` as `tr`\nLEFT JOIN `User` as `u` ON `tr`.`User_ID` = `u`.`User_ID`\nWHERE `tr`.`Type` = '" . $type_id . "'\n AND `tr`.`Sub_Class_ID` = '" . $cc . "'\n" . ($date_b ? " AND UNIX_TIMESTAMP(`tr`.`Created`) > " . $date_b : "") . ($date_e ? " AND UNIX_TIMESTAMP(`tr`.`Created`) < " . $date_e : ""), ARRAY_A); // Определяем номер компонента $class_id = $nc_trashed_objs[0]['Class_ID']; // $type_id = $nc_trashed_objs[0]['Type']; $File_Mode = nc_get_file_mode('Class', $class_id); if ($type_id == nc_Trash::TYPE_MESSAGE) { $trash_class = $db->get_row("\n SELECT `FormPrefix`,\n `FormSuffix`,\n `RecordTemplate`,\n `File_Mode`,\n `File_Path`,\n `File_Hash`,\n 'ClassTemplate'\n FROM `Class`\n WHERE `ClassTemplate` = " . $class_id . "\n AND `Type` = 'trash'\n LIMIT 1", ARRAY_A); if (empty($trash_class)) { die(NETCAT_TRASH_TEMPLATE_DOESNT_EXIST . ". <br />\n <a href='" . $nc_core->ADMIN_PATH . "class/index.php?" . $nc_core->token->get_url() . "&Type=trash&base=auto&phase=141&from_trash=1&ClassID=" . $class_id . ($File_Mode ? "&fs=1" : "") . "'>" . CONTROL_CLASS_COMPONENT_TEMPLATE_CREATE_FOR_TRASH . "</a>"); } if ($trash_class['File_Mode']) { $file_class = new nc_class_view($nc_core->CLASS_TEMPLATE_FOLDER, $nc_core->db); $file_class->load($trash_class['ClassTemplate'], $trash_class['File_Path'], $trash_class['File_Hash']); $nc_parent_class_folder_path = nc_get_path_to_main_parent_folder($trash_class['File_Path']); } } $messages = array(); $fields = array(); if (!empty($nc_trashed_objs)) { foreach ($nc_trashed_objs as $k => $obj) {
function nc_subclass_show_export($type, $sub_id, $cc_id, $show_name = 0, $from_sub = 0) { $nc_core = nc_Core::get_object(); $db = $nc_core->db; $sub_id = +$sub_id; $cc_id = +$cc_id; if (!in_array($type, array('rss', 'xml'))) { return; } $Array = $db->get_row("SELECT `Allow" . strtoupper($type) . "`, `Sub_Class_Name`,`Class_ID`, `EnglishName` FROM `Sub_Class` WHERE `Sub_Class_ID` = '" . $cc_id . "' ", ARRAY_A); $class_id = $Array['Class_ID']; $name = $show_name ? "<b>" . $Array['Sub_Class_Name'] . "</b> " : ""; $export_class_id = $db->get_var("SELECT `Class_ID` FROM `Class` WHERE `Type` = '" . $type . "' AND `ClassTemplate` = '" . $class_id . "' "); $File_Mode = nc_get_file_mode('Class', $class_id); $html = "<div>"; if (!$export_class_id) { $html .= "<font>" . sprintf(constant("CONTROL_CLASS_COMPONENT_TEMPLATE_FOR_" . strtoupper($type) . "_DOESNT_EXIST"), $name) . "</font>"; $html .= "<br/>"; $html .= "<a onClick='parent.nc_form(this.href); location.reload(); return false;' href='" . $nc_core->ADMIN_PATH . "class/index.php?fs={$File_Mode}&" . $nc_core->token->get_url() . "&from_sub=" . $sub_id . ($from_sub ? "" : "&from_cc=" . $cc_id) . "&Type=" . $type . "&base=auto&phase=1411&ClassID=" . $class_id . "'>" . constant("CONTROL_CLASS_COMPONENT_TEMPLATE_CREATE_FOR_" . strtoupper($type)) . "</a>"; } else { $host = $nc_core->catalogue->get_by_id($nc_core->sub_class->get_by_id($cc_id, 'Catalogue_ID'), 'Domain'); if (nc_module_check_by_keyword('routing')) { $link = "http://{$host}" . nc_routing::get_infoblock_path($cc_id, 'index', $type); } else { $link = $nc_core->SUB_FOLDER . $db->get_var("SELECT `Hidden_URL` FROM `Subdivision` WHERE `Subdivision_ID` = '" . $sub_id . "' "); $link = 'http://' . $host . $link . $Array['EnglishName'] . "." . $type; } $html .= "<input type='checkbox' id='Allow" . strtoupper($type) . "" . $cc_id . "' name='Allow" . strtoupper($type) . "" . $cc_id . "' value='1' " . ($Array["Allow" . strtoupper($type) . ""] ? " checked" : "") . " /><label for='Allow" . strtoupper($type) . "" . $cc_id . "'>" . constant("CONTROL_CLASS_COMPONENT_TEMPLATE_TURN_ON_" . strtoupper($type)) . " " . $name . "</label>"; $html .= " ( "; if ($Array["Allow" . strtoupper($type) . ""]) { $html .= "<a target='_blank' href='" . $link . "'>" . CONTROL_CLASS_COMPONENT_TEMPLATE_VIEW . "</a>, "; } $html .= " <a onClick='parent.nc_form(this.href); return false; ' href='" . $nc_core->ADMIN_PATH . "class/index.php?fs=" . $File_Mode . "&phase=4&ClassID=" . $export_class_id . "'>" . CONTROL_CLASS_COMPONENT_TEMPLATE_EDIT . "</a> )"; } $html .= "</div>"; return $html; }