• Модуль: subscribe
  • Путь к файлу: ~/bitrix/modules/subscribe/classes/general/subscription.php
  • Класс: CSubscriptionGeneral
  • Вызов: CSubscriptionGeneral::Update
public function Update($ID, $arFields, $SITE_ID=SITE_ID)
{
	global $DB;
	$ID = intval($ID);
	$this->LAST_MESSAGE = "";

	if(!$this->CheckFields($arFields, $ID, $SITE_ID))
		return false;

	if(array_key_exists("USER_ID", $arFields) && (intval($arFields["USER_ID"]) <= 0))
		$arFields["USER_ID"] = false;

	//Check whether email changed. If changed, we must to generate new confirm code.
	$strSql =
		"SELECT EMAIL, CONFIRM_CODE, CONFIRMED FROM b_subscription ".
		"WHERE ID='".$ID."' ";
	$db_check = $DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__); if(!($db_check_arr = $db_check->Fetch())) { $this->LAST_ERROR = GetMessage("class_subscr_perm")."
"; return false; } $CONFIRM_CODE = $arFields["CONFIRM_CODE"]; unset($arFields["CONFIRM_CODE"]); if(!is_set($arFields, "EMAIL") || mb_strtoupper($db_check_arr["EMAIL"]) == mb_strtoupper($arFields["EMAIL"])) { //the same email - check confirm code if($CONFIRM_CODE <> '' && $db_check_arr["CONFIRMED"] <> "Y") { if($CONFIRM_CODE == $db_check_arr["CONFIRM_CODE"]) { //let's confirm the subscription $arFields["CONFIRMED"] = "Y"; $this->LAST_MESSAGE = "CONF"; } else { $this->LAST_ERROR = GetMessage("class_subscr_conf")."
"; return false; } } } else { //new email - new confirm code $arFields["CONFIRM_CODE"] = randString(8); if($arFields["CONFIRMED"]<>"Y") $arFields["CONFIRMED"] = "N"; } $strUpdate = $DB->PrepareUpdate("b_subscription", $arFields); if ($strUpdate <> '') { $strSql = "UPDATE b_subscription SET ". $strUpdate.", ". " DATE_UPDATE=".$DB->GetNowFunction()." ". ($arFields["CONFIRM_CODE"] <> ''? ",". " DATE_CONFIRM=".$DB->GetNowFunction()." " :""). "WHERE ID=".$ID; if(!$DB->Query($strSql, false, "File: ".__FILE__."
Line: ".__LINE__)) return false; } //subscription categories if(is_set($arFields, "RUB_ID")) { if(is_set($arFields,"ALL_SITES") && $arFields["ALL_SITES"]=="Y") $this->UpdateRubrics($ID, $arFields["RUB_ID"]); else $this->UpdateRubrics($ID, $arFields["RUB_ID"], $SITE_ID); } //send confirmation code if needed if($arFields["SEND_CONFIRM"] <> "N" && $arFields["CONFIRM_CODE"] <> '') { $this->ConfirmEvent($ID, $SITE_ID); $this->LAST_MESSAGE = "SENT"; } return true; }