if (false === $arForm) { require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; echo "<a href='form_list.php?lang=" . LANGUAGE_ID . "' >" . GetMessage("FORM_FORM_LIST") . "</a>"; echo ShowError(GetMessage("FORM_NOT_FOUND")); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"; die; } $txt = "(" . htmlspecialcharsbx($arForm['SID']) . ") " . htmlspecialcharsbx($arForm['NAME']); $link = "form_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $WEB_FORM_ID; $adminChain->AddItem(array("TEXT" => $txt, "LINK" => $link)); $F_RIGHT = CForm::GetPermission($WEB_FORM_ID); if ($F_RIGHT < 25) { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } if ($copy_id > 0 && $F_RIGHT >= 30 && check_bitrix_sessid()) { $new_id = CFormField::Copy($copy_id); if (strlen($strError) <= 0 && intval($new_id) > 0) { LocalRedirect("form_field_edit.php?ID=" . $new_id . "&additional=" . $additional . "&WEB_FORM_ID=" . $WEB_FORM_ID . "&lang=" . LANGUAGE_ID . "&strError=" . urlencode($strError)); } } if ((strlen($_REQUEST['save']) > 0 || strlen($_REQUEST['apply']) > 0) && $_SERVER['REQUEST_METHOD'] == "POST" && $F_RIGHT >= 30 && check_bitrix_sessid()) { $arIMAGE = $_FILES["IMAGE_ID"]; $arIMAGE["MODULE_ID"] = "form"; $arIMAGE["del"] = $_REQUEST['IMAGE_ID_del']; $ACTIVE = $_REQUEST['ACTIVE']; $TITLE = $_REQUEST['TITLE']; $TITLE_TYPE = $_REQUEST['TITLE_TYPE']; $SID = $_REQUEST['SID']; $C_SORT = $_REQUEST['C_SORT']; $REQUIRED = $_REQUEST['REQUIRED']; $FIELD_TYPE = $_REQUEST['FIELD_TYPE'];
function Copy($ID, $CHECK_RIGHTS = "Y") { global $DB, $APPLICATION, $strError; $err_mess = CAllForm::err_mess() . "<br>Function: Copy<br>Line: "; $ID = intval($ID); if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) { $rsForm = CForm::GetByID($ID); $arForm = $rsForm->Fetch(); if (!is_set($arForm, "FORM_TEMPLATE")) { $arForm["FORM_TEMPLATE"] = CForm::GetFormTemplateByID($ID); } // символьный код формы while (true) { $SID = $arForm["SID"]; if (strlen($SID) > 25) { $SID = substr($SID, 0, 25); } $SID .= "_" . RandString(5); $strSql = "SELECT 'x' FROM b_form WHERE SID='" . $DB->ForSql($SID, 50) . "'"; $z = $DB->Query($strSql, false, $err_mess . __LINE__); if (!($zr = $z->Fetch())) { break; } } $arFields = array("NAME" => $arForm["NAME"], "SID" => $SID, "C_SORT" => $arForm["C_SORT"], "FIRST_SITE_ID" => $arForm["FIRST_SITE_ID"], "BUTTON" => $arForm["BUTTON"], "USE_CAPTCHA" => $arForm["USE_CAPTCHA"], "DESCRIPTION" => $arForm["DESCRIPTION"], "DESCRIPTION_TYPE" => $arForm["DESCRIPTION_TYPE"], "SHOW_TEMPLATE" => $arForm["SHOW_TEMPLATE"], "FORM_TEMPLATE" => $arForm["FORM_TEMPLATE"], "USE_DEFAULT_TEMPLATE" => $arForm["USE_DEFAULT_TEMPLATE"], "SHOW_RESULT_TEMPLATE" => $arForm["SHOW_RESULT_TEMPLATE"], "PRINT_RESULT_TEMPLATE" => $arForm["PRINT_RESULT_TEMPLATE"], "EDIT_RESULT_TEMPLATE" => $arForm["EDIT_RESULT_TEMPLATE"], "FILTER_RESULT_TEMPLATE" => $arForm["FILTER_RESULT_TEMPLATE"], "TABLE_RESULT_TEMPLATE" => $arForm["TABLE_RESULT_TEMPLATE"], "STAT_EVENT1" => $arForm["STAT_EVENT1"], "STAT_EVENT2" => $SID, "STAT_EVENT3" => $arForm["STAT_EVENT3"], "arSITE" => CForm::GetSiteArray($ID)); // пункты меню $z = CForm::GetMenuList(array("FORM_ID" => $ID), "N"); while ($zr = $z->Fetch()) { $arFields["arMENU"][$zr["LID"]] = $zr["MENU"]; } // права групп $w = CGroup::GetList($v1 = "dropdown", $v2 = "asc", array("ADMIN" => "N"), $v3); $arGroups = array(); while ($wr = $w->Fetch()) { $arGroups[] = $wr["ID"]; } if (is_array($arGroups)) { foreach ($arGroups as $gid) { $arFields["arGROUP"][$gid] = CForm::GetPermission($ID, array($gid), "Y"); } } // картинка if (intval($arForm["IMAGE_ID"]) > 0) { $arIMAGE = CFile::MakeFileArray(CFile::CopyFile($arForm["IMAGE_ID"])); $arIMAGE["MODULE_ID"] = "form"; $arFields["arIMAGE"] = $arIMAGE; } $NEW_ID = CForm::Set($arFields, 0); if (intval($NEW_ID) > 0) { // статусы $rsStatus = CFormStatus::GetList($ID, $by, $order, array(), $is_filtered); while ($arStatus = $rsStatus->Fetch()) { CFormStatus::Copy($arStatus["ID"], "N", $NEW_ID); } // вопросы/пол¤ $rsField = CFormField::GetList($ID, "ALL", $by, $order, array(), $is_filtered); while ($arField = $rsField->Fetch()) { CFormField::Copy($arField["ID"], "N", $NEW_ID); } } return $NEW_ID; } else { $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED") . "<br>"; } return false; }