Example #1
0
$arResult["~LISTS_URL"] = str_replace(array("#group_id#"), array($arParams["SOCNET_GROUP_ID"]), $arParams["~LISTS_URL"]);
$arResult["LISTS_URL"] = htmlspecialcharsbx($arResult["~LISTS_URL"]);
$arResult["~LIST_URL"] = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#group_id#"), array($arResult["IBLOCK_ID"], 0, $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_URL"]), array("list_section_id" => ""));
$arResult["LIST_URL"] = htmlspecialcharsbx($arResult["~LIST_URL"]);
$arResult["~LIST_EDIT_URL"] = str_replace(array("#list_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_EDIT_URL"]);
$arResult["LIST_EDIT_URL"] = htmlspecialcharsbx($arResult["~LIST_EDIT_URL"]);
$arResult["~LIST_FIELDS_URL"] = str_replace(array("#list_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_FIELDS_URL"]);
$arResult["LIST_FIELDS_URL"] = htmlspecialcharsbx($arResult["~LIST_FIELDS_URL"]);
$arResult["~LIST_FIELD_EDIT_URL"] = str_replace(array("#list_id#", "#field_id#", "#group_id#"), array($arResult["IBLOCK_ID"], "0", $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_FIELD_EDIT_URL"]);
$arResult["LIST_FIELD_EDIT_URL"] = htmlspecialcharsbx($arResult["~LIST_FIELD_EDIT_URL"]);
//Form submitted
if ($_SERVER["REQUEST_METHOD"] == "POST" && check_bitrix_sessid() && isset($_POST["action_button_" . $arResult["GRID_ID"]])) {
    $obList = new CList($arIBlock["ID"]);
    if ($_POST["action_button_" . $arResult["GRID_ID"]] == "delete" && isset($_POST["ID"]) && is_array($_POST["ID"])) {
        foreach ($_POST["ID"] as $ID) {
            $obList->DeleteField($ID);
        }
        //Clear components cache
        $CACHE_MANAGER->ClearByTag("lists_list_" . $arResult["IBLOCK_ID"]);
    }
    if ($_POST["action_button_" . $arResult["GRID_ID"]] == "edit" && isset($_POST["FIELDS"]) && is_array($_POST["FIELDS"])) {
        foreach ($_POST["FIELDS"] as $ID => $tmp) {
            $arField = array("SORT" => $_POST["FIELDS"][$ID]["SORT"], "NAME" => $_POST["FIELDS"][$ID]["NAME"], "IS_REQUIRED" => $_POST["FIELDS"][$ID]["IS_REQUIRED"], "MULTIPLE" => $_POST["FIELDS"][$ID]["MULTIPLE"]);
            $obList->UpdateField($ID, $arField);
        }
        //Clear components cache
        $CACHE_MANAGER->ClearByTag("lists_list_" . $arResult["IBLOCK_ID"]);
    }
    if (!isset($_POST["AJAX_CALL"])) {
        LocalRedirect($arResult["LIST_FIELDS_URL"]);
    }
Example #2
0
            //And go to proper page
            if (isset($_POST["save"])) {
                LocalRedirect($arResult["~LIST_FIELDS_URL"]);
            } elseif ($arResult["FIELD_ID"]) {
                LocalRedirect(CHTTP::urlAddParams(str_replace(array("#list_id#", "#field_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arResult["FIELD_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_FIELD_EDIT_URL"]), array($tab_name => $_POST[$tab_name]), array("skip_empty" => true, "encode" => true)));
            } else {
                LocalRedirect($arResult["~LIST_FIELDS_URL"]);
            }
        } else {
            ShowError($strError);
            $bVarsFromForm = true;
        }
    } elseif (isset($_POST["action"]) && $_POST["action"] === "type_changed") {
        $bVarsFromForm = true;
    } elseif ($arResult["FIELD_ID"] && isset($_POST["action"]) && $_POST["action"] === "delete") {
        $obList->DeleteField($arResult["FIELD_ID"]);
        $obList->Save();
        //Clear components cache
        $CACHE_MANAGER->ClearByTag("lists_list_" . $arIBlock["ID"]);
        LocalRedirect($arResult["~LIST_FIELDS_URL"]);
    } else {
        //Go to lists page
        LocalRedirect($arResult["~LISTS_URL"]);
    }
}
$arResult["TYPES"] = $obList->GetAvailableTypes($arResult["FIELD_ID"]);
$data = array();
if ($bVarsFromForm) {
    //There was an error so display form values
    $data["SORT"] = $_POST["SORT"];
    $data["NAME"] = $_POST["NAME"];