ShowError(GetMessage("SUBSCR_NO_RUBRIC_FOUND")); return; } $arResult["FORM_ACTION"] = htmlspecialcharsbx(str_replace("#SITE_DIR#", LANG_DIR, $arParams["PAGE"])); $arResult["SHOW_COUNT"] = $arParams["SHOW_COUNT"]; if (strlen($arSubscription["EMAIL"]) > 0) { $arResult["EMAIL"] = htmlspecialcharsbx($arSubscription["EMAIL"]); } else { $arResult["EMAIL"] = htmlspecialcharsbx($USER->GetParam("EMAIL")); } //check whether already authorized $arResult["SHOW_PASS"] = true; if ($arSubscription["ID"] > 0) { //try to authorize user account's subscription if ($arSubscription["USER_ID"] > 0 && !CSubscription::IsAuthorized($arSubscription["ID"])) { CSubscription::Authorize($arSubscription["ID"], ""); } //check authorization if (CSubscription::IsAuthorized($arSubscription["ID"])) { $arResult["SHOW_PASS"] = false; } } $arResult["RUBRICS"] = array(); foreach ($arRubrics as $arRubric) { $bChecked = !is_array($_REQUEST["sf_RUB_ID"]) && in_array($arRubric["ID"], $arSubscriptionRubrics) || !is_array($_REQUEST["sf_RUB_ID"]) && intval($arSubscription["ID"]) == 0 || is_array($_REQUEST["sf_RUB_ID"]) && in_array($arRubric["ID"], $_REQUEST["sf_RUB_ID"]); $arResult["RUBRICS"][] = array("ID" => $arRubric["ID"], "NAME" => $arRubric["NAME"], "DESCRIPTION" => $arRubric["DESCRIPTION"], "CHECKED" => $bChecked, "SUBSCRIBER_COUNT" => $arRubric["SUBSCRIBER_COUNT"]); } if ($arParams["SET_TITLE"] == "Y") { $APPLICATION->SetTitle(GetMessage("SUBSCR_PAGE_TITLE"), array('COMPONENT_NAME' => $this->GetName())); } $this->IncludeComponentTemplate();
} else { $ID = 0; } //try to authorize subscription by CONFIRM_CODE or user password AUTH_PASS if ($ID > 0 && !CSubscription::IsAuthorized($ID)) { if ($arSubscription["USER_ID"] > 0 && !empty($_REQUEST["AUTH_PASS"])) { //trying to login user $rsUser = CUser::GetByID($arSubscription["USER_ID"]); if ($arUser = $rsUser->Fetch()) { $res = $USER->Login($arUser["LOGIN"], $_REQUEST["AUTH_PASS"]); if ($res["TYPE"] == "ERROR") { $arWarning[] = $res["MESSAGE"]; } } } CSubscription::Authorize($ID, empty($_REQUEST["AUTH_PASS"]) ? $_REQUEST["CONFIRM_CODE"] : $_REQUEST["AUTH_PASS"]); } //confirmation code from letter or confirmation form if ($_REQUEST["CONFIRM_CODE"] != "" && $ID > 0 && empty($_REQUEST["action"])) { if ($arSubscription["CONFIRMED"] != "Y" && count($arWarning) == 0) { //subscribtion confirmation if ($obSubscription->Update($ID, array("CONFIRM_CODE" => $_REQUEST["CONFIRM_CODE"]))) { $arSubscription["CONFIRMED"] = "Y"; } if ($obSubscription->LAST_ERROR != "") { $arWarning[] = $obSubscription->LAST_ERROR; } $iMsg = $obSubscription->LAST_MESSAGE; } } //*************************
<?php if (isset($_REQUEST['SITE_ID'])) { define('SITE_ID', !empty($_REQUEST['SITE_ID']) ? $_REQUEST['SITE_ID'] : 's1'); } define("STOP_STATISTICS", true); define('NO_AGENT_CHECK', true); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; use Bitrix\Main\Localization\Loc; use RBCC\Helpers\Common\JS; Loc::loadMessages(__FILE__); $response = array('result' => false, 'title' => GetMessage('SUBSCRIBE_ERROR_TITLE'), 'message' => ''); global $USER; CModule::IncludeModule('subscribe'); if (!isset($_REQUEST['EMAIL']) || empty($_REQUEST['EMAIL'])) { $response['message'] = GetMessage('SUBSCRIBE_EMAIL_IS_EMPTY'); JS::ajax($response); } $subscription = new CSubscription(); $subId = $subscription->Add(array('USER_ID' => $USER->IsAuthorized() ? $USER->GetID() : false, 'EMAIL' => $_REQUEST['EMAIL'])); if ($subId) { @CSubscription::Authorize($subId); $response['result'] = true; $response['title'] = GetMessage('SUBSCRIBE_MESSAGE_TITLE'); $response['message'] = GetMessage('SUBSCRIBE_MESSAGE_TEXT', array('#EMAIL#' => $_REQUEST['EMAIL'])); JS::ajax($response); } else { $response['message'] = strip_tags($subscription->LAST_ERROR); JS::ajax($response); }
<tr> <td><input type="text" class="inputtext" name="sf_EMAIL" size="20" value="<?php echo htmlspecialchars($aSubscr["EMAIL"]); ?> " title="<?php echo GetMessage("subscr_email_title"); ?> "></td> </tr> <?php //check whether already authorized $bShowPass = true; if ($aSubscr["ID"] > 0) { //try to authorize user account's subscription if ($aSubscr["USER_ID"] > 0 && !CSubscription::IsAuthorized($aSubscr["ID"])) { CSubscription::Authorize($aSubscr["ID"], ""); } //check authorization if (CSubscription::IsAuthorized($aSubscr["ID"])) { $bShowPass = false; } } if ($bShowPass) { ?> <tr> <td><font class="text"><?php echo GetMessage("subscr_edit_pass"); ?> </font><font class="starrequired">*</font></td> </tr> <tr>
<?php define("STOP_STATISTICS", true); define("PUBLIC_AJAX_MODE", true); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; /* * Подписка на рассылки */ if (CModule::IncludeModule("subscribe")) { if (isset($_POST['rassylka']) && $_POST['rassylka'] == "Y") { $arFields = array("USER_ID" => $USER->IsAuthorized() ? $USER->GetID() : false, "FORMAT" => $FORMAT != "html" ? "text" : "html", "EMAIL" => $_POST['email'], "ACTIVE" => "Y", "CONFIRMED" => "Y", 'SEND_CONFIRM' => "N"); $subscr = new CSubscription(); //can add without authorization $IDrassylka = $subscr->Add($arFields); if ($ID > 0) { CSubscription::Authorize($IDrassylka); } /*else $strWarning .= "Error adding subscription: ".$subscr->LAST_ERROR."<br>";*/ } } /* * END Подписка на рассылки */ require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";