$arWarning[] = $res["MESSAGE"]; } else { $bDoSubscribe = false; } } //if anonymous users are not permitted then the user must be authorized if ($arParams["ALLOW_ANONYMOUS"] == "N" && !$USER->IsAuthorized()) { $arWarning[] = GetMessage("adm_auth_err"); } //there must be at least one newsletter category if (!is_array($_REQUEST["RUB_ID"]) || count($_REQUEST["RUB_ID"]) == 0) { $arWarning[] = GetMessage("adm_auth_err_rub"); } elseif ($arParams["SHOW_HIDDEN"] == "N") { $bAllowSubscription = true; foreach ($_REQUEST["RUB_ID"] as $rub_id) { $rsRubric = CRubric::GetByID($rub_id); if ($arRubric = $rsRubric->Fetch()) { if ($arRubric["VISIBLE"] == "N") { $bAllowSubscription = false; } } } if ($bAllowSubscription === false) { $arWarning[] = GetMessage("subscr_wrong_rubric"); } } if (count($arWarning) <= 0 && $bDoSubscribe) { //Check if subscription already have hidden rubrics and they was not displayed. //In this case we will add those categories to the list in order not to lost. if ($arParams["SHOW_HIDDEN"] == "N" && $ID > 0) { $arNewRubrics = $_REQUEST["RUB_ID"];
$bVarsFromForm = true; } } //Edit/Add part ClearVars(); $str_SORT = 100; $str_ACTIVE = "Y"; $str_AUTO = "N"; $str_DAYS_OF_MONTH = ""; $str_DAYS_OF_WEEK = ""; $str_TIMES_OF_DAY = ""; $str_VISIBLE = "Y"; $str_LAST_EXECUTED = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"); $str_FROM_FIELD = COption::GetOptionString("subscribe", "default_from"); if ($ID > 0) { $rubric = CRubric::GetByID($ID); if (!$rubric->ExtractFields("str_")) { $ID = 0; } } if ($ID > 0 && !$message) { $DAYS_OF_WEEK = explode(",", $str_DAYS_OF_WEEK); } if (!is_array($DAYS_OF_WEEK)) { $DAYS_OF_WEEK = array(); } if ($bVarsFromForm) { $DB->InitTableVarsForEdit("b_list_rubric", "", "str_"); } $APPLICATION->SetTitle($ID > 0 ? GetMessage("rub_title_edit") . $ID : GetMessage("rub_title_add")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
} $ID = IntVal($ID); switch ($_REQUEST['action']) { case "delete": @set_time_limit(0); $DB->StartTransaction(); if (!CRubric::Delete($ID)) { $DB->Rollback(); $lAdmin->AddGroupError(GetMessage("rub_del_err"), $ID); } $DB->Commit(); break; case "activate": case "deactivate": $cData = new CRubric(); if (($rsData = $cData->GetByID($ID)) && ($arFields = $rsData->Fetch())) { $arFields["ACTIVE"] = $_REQUEST['action'] == "activate" ? "Y" : "N"; if (!$cData->Update($ID, $arFields)) { $lAdmin->AddGroupError(GetMessage("rub_save_error") . $cData->LAST_ERROR, $ID); } } else { $lAdmin->AddGroupError(GetMessage("rub_save_error") . " " . GetMessage("rub_no_rubric"), $ID); } break; } } } $cData = new CRubric(); $rsData = $cData->GetList(array($by => $order), $arFilter); $rsData = new CAdminResult($rsData, $sTableID); $rsData->NavStart();