<?
AddEventHandler("main", "OnAfterUserAdd", "OnAfterUserAddHandler");
function OnAfterUserAddHandler(&$arFields)
{
if($arFields["ID"]>0)
{
if(CModule::IncludeModule("subscribe")) {
$USER_ID = $arFields["ID"];
$EMAIL = $arFields["EMAIL"];
$arFilter = array(
"ACTIVE" => "Y",
"LID" => "s1",
"VISIBLE"=>"Y",
);
$rsRubrics = CRubric::GetList(array(), $arFilter);
$arRubrics = array();
while($arRubric = $rsRubrics->GetNext()) $arRubrics[] = $arRubric["ID"];
$obSubscription = new CSubscription;
$rsSubscription = $obSubscription->GetList(array(), array("USER_ID" => $USER_ID));
$arSubscription = $rsSubscription->Fetch();
AddMessage2Log("Произвольный текст сообщения: ".$arSubscription."");
if(is_array($arSubscription))
{
$rs = $obSubscription->Update(
$arSubscription["ID"],
array(
"FORMAT" => "html",
"RUB_ID" => $arRubrics,
),
false
);
}
else
{
$ID = $obSubscription->Add(array(
"USER_ID" => $USER_ID,
"ACTIVE" => "Y",
"EMAIL" => $EMAIL,
"FORMAT" => "html",
"CONFIRMED" => "Y",
"SEND_CONFIRM" => "N",
"RUB_ID" => $arRubrics,
));
}
}
}
}
?>