foreach($arMRubricList as $RKey => $arRubric)
{
//echo '$arRubric -> ';
//echo"<pre>";print_r($arRubric);echo"</pre>";
if(CPostingTemplate::IsExists($arRubric["TEMPLATE"]))
{
$strFileName= $_SERVER["DOCUMENT_ROOT"]."/".$arRubric["TEMPLATE"]."/lang/".$arSite["LANGUAGE_ID"]."/template.php";
if(file_exists($strFileName))
include($strFileName);
//Execute template
$strFileName= $_SERVER["DOCUMENT_ROOT"]."/".$arRubric["TEMPLATE"]."/template.php";
if(file_exists($strFileName))
{
ob_start();
$arFields = @include($strFileName);
$strBody = ob_get_contents();
ob_end_clean();
}
}
if(is_array($arFields))
{
//echo '$arFields -> ';
//echo"<pre>";print_r($arFields);echo"</pre>";
$cPosting=new CPosting;
$arFields["BODY"] = $strBody;
$arFields["RUB_ID"] = array($arRubric["ID"]);
$arFields["MSG_CHARSET"] = $arLang["CHARSET"];
[COLOR=#FF0000]$arFields["STATUS"] = "D"; // realy need[/COLOR]
//echo '$arFields -> ';
//echo"<pre>";print_r($arFields);echo"</pre>";
$ID = $cPosting->Add($arFields);
if($ID>0)
{
if($cPosting->ChangeStatus($ID, "P"))
{
echo 'true ChangeStatus<br />';
$arEmailStatuses = CPosting::GetEmailStatuses($ID);
echo"<pre>";print_r($arEmailStatuses);echo"</pre>";
$time = ConvertTimeStamp(time()+10, "FULL");
CAgent::AddAgent("CPosting::AutoSend(".$ID.",true);", "subscribe", "N", 0, $time, "Y", $time);
/*
$res = $cPosting->SendMessage($ID, 10, 10);
if(!$res)
{
echo "<hr />false SendMessage<br />";
echo $cPosting->LAST_ERROR.'<br />';
} else {
echo "<hr /><h1><font color=blue>SendMessage</font></h1><br />";
}
*/
} else {
echo "false change status<br />";
echo $cPosting->LAST_ERROR.'<br />';
}
} else {
echo "false add posting<br />";
echo $cPosting->LAST_ERROR.'<br />';
}
}
} |