function Delete($ID, $CHECK_RIGHTS = "Y") { global $DB, $strError; $err_mess = CAllForm::err_mess() . "<br>Function: Delete<br>Line: "; $ID = intval($ID); if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) { // delete form results if (CForm::Reset($ID, "N")) { // delete temporary template $tmp_filename = $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/tmp/form/form_" . $ID . ".php"; if (file_exists($tmp_filename)) { @unlink($tmp_filename); } // delete form statuses $rsStatuses = CFormStatus::GetList($ID, $by, $order, $arFilter, $is_filtered); while ($arStatus = $rsStatuses->Fetch()) { CFormStatus::Delete($arStatus["ID"], "N"); } // delete from fields & questions $rsFields = CFormField::GetList($ID, "ALL", $by, $order, array(), $is_filtered); while ($arField = $rsFields->Fetch()) { CFormField::Delete($arField["ID"], "N"); } // delete form image $strSql = "SELECT IMAGE_ID FROM b_form WHERE ID='{$ID}' and IMAGE_ID>0"; $z = $DB->Query($strSql, false, $err_mess . __LINE__); while ($zr = $z->Fetch()) { CFile::Delete($zr["IMAGE_ID"]); } // delete mail event type and mail templates, assigned to the current form $q = CForm::GetByID($ID); $qr = $q->Fetch(); if (strlen(trim($qr["MAIL_EVENT_TYPE"])) > 0) { // delete mail templates $em = new CEventMessage(); $e = $em->GetList($by = "id", $order = "desc", array("EVENT_NAME" => $qr["MAIL_EVENT_TYPE"], "EVENT_NAME_EXACT_MATCH" => "Y")); while ($er = $e->Fetch()) { $em->Delete($er["ID"]); } // delete mail event type $et = new CEventType(); $et->Delete($qr["MAIL_EVENT_TYPE"]); } // delete site assignment $DB->Query("DELETE FROM b_form_2_site WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__); // delete mail templates assignment $DB->Query("DELETE FROM b_form_2_mail_template WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__); // delete form menu $DB->Query("DELETE FROM b_form_menu WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__); // delete from rights $DB->Query("DELETE FROM b_form_2_group WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__); // and finally delete form $DB->Query("DELETE FROM b_form WHERE ID='{$ID}'", false, $err_mess . __LINE__); return true; } } else { $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED") . "<br>"; } return false; }
function DeleteField($WEB_FORM_ID, $ID, $CHECK_RIGHTS = "Y") { return CFormField::Delete($ID, $CHECK_RIGHTS); }
$arID = array(); $rsData = CFormField::GetList($WEB_FORM_ID, $additional, $by, $order, $arFilter, $is_filtered); while ($arRes = $rsData->Fetch()) { $arID[] = $arRes['ID']; } } foreach ($arID as $ID) { if (strlen($ID) <= 0) { continue; } $ID = IntVal($ID); switch ($_REQUEST['action']) { case "delete": @set_time_limit(0); $DB->StartTransaction(); if (!CFormField::Delete($ID)) { $DB->Rollback(); $lAdmin->AddGroupError(GetMessage("DELETE_ERROR"), $ID); } $DB->Commit(); break; case "activate": case "deactivate": @set_time_limit(0); $DB->StartTransaction(); $arFieldsStore = array("ACTIVE" => $_REQUEST['action'] == "activate" ? "'Y'" : "'N'"); if (!$DB->Update("b_form_field", $arFieldsStore, "WHERE ID='" . $ID . "'", $err_mess . __LINE__)) { $DB->Rollback(); $lAdmin->AddGroupError(GetMessage("DELETE_ERROR"), $ID); } $DB->Commit();
function Delete($ID, $CHECK_RIGHTS = "Y") { global $DB, $strError; $err_mess = CAllForm::err_mess() . "<br>Function: Delete<br>Line: "; $ID = intval($ID); if ($CHECK_RIGHTS != "Y" || CForm::IsAdmin()) { // удаляем результаты формы if (CForm::Reset($ID, "N")) { // удаляем статусы формы $rsStatuses = CFormStatus::GetList($ID, $by, $order, $arFilter, $is_filtered); while ($arStatus = $rsStatuses->Fetch()) { CFormStatus::Delete($arStatus["ID"], "N"); } // удаляем поля и вопросы формы $rsFields = CFormField::GetList($ID, "ALL", $by, $order, array(), $is_filtered); while ($arField = $rsFields->Fetch()) { CFormField::Delete($arField["ID"], "N"); } // удаляем изображения формы $strSql = "SELECT IMAGE_ID FROM b_form WHERE ID='{$ID}' and IMAGE_ID>0"; $z = $DB->Query($strSql, false, $err_mess . __LINE__); while ($zr = $z->Fetch()) { CFile::Delete($zr["IMAGE_ID"]); } // удаляем тип почтового события и почтовые шаблоны приписанные данной форме $q = CForm::GetByID($ID); $qr = $q->Fetch(); if (strlen(trim($qr["MAIL_EVENT_TYPE"])) > 0) { // удалим почтовые шаблоны $em = new CEventMessage(); $e = $em->GetList($by = "id", $order = "desc", array("EVENT_NAME" => $qr["MAIL_EVENT_TYPE"], "EVENT_NAME_EXACT_MATCH" => "Y")); while ($er = $e->Fetch()) { $em->Delete($er["ID"]); } // удалим тип почтового события $et = new CEventType(); $et->Delete($qr["MAIL_EVENT_TYPE"]); } // удаляем привязку к сайтам $DB->Query("DELETE FROM b_form_2_site WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__); // удаляем привязку к почтовым шаблонам $DB->Query("DELETE FROM b_form_2_mail_template WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__); // удаляем меню формы $DB->Query("DELETE FROM b_form_menu WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__); // удаляем права групп $DB->Query("DELETE FROM b_form_2_group WHERE FORM_ID='{$ID}'", false, $err_mess . __LINE__); // удаляем форму $DB->Query("DELETE FROM b_form WHERE ID='{$ID}'", false, $err_mess . __LINE__); return true; } } else { $strError .= GetMessage("FORM_ERROR_ACCESS_DENIED") . "<br>"; } return false; }