//there must be at least one newsletter category
if(!is_array($RUB_ID) || count($RUB_ID) == 0)
$strWarning .= "There must be at least one category."."<br>";
if($strWarning == "")
{
$arFields = Array(
"USER_ID" => ($USER->IsAuthorized()? $USER->GetID():false),
"FORMAT" => ($FORMAT <> "html"? "text":"html"),
"EMAIL" => $EMAIL,
"ACTIVE" => "Y",
"RUB_ID" => $RUB_ID
);
$subscr = new CSubscription;
//can add without authorization
$ID = $subscr->Add($arFields);
if($ID>0)
CSubscription::Authorize($ID);
else
$strWarning .= "Error adding subscription: ".$subscr->LAST_ERROR."<br>";
} |