• Модуль: subscribe
  • Путь к файлу: ~/bitrix/modules/subscribe/classes/general/posting.php
  • Класс: CPostingGeneral
  • Вызов: CPostingGeneral::AutoSend
static function AutoSend($ID=false, $limit=false, $site_id=false)
{
	if($ID===false)
	{
		//Here is cron job entry
		$cPosting = new CPosting;
		$rsPosts = $cPosting->GetList(
			array("AUTO_SEND_TIME"=>"ASC", "ID"=>"ASC"),
			array("STATUS_ID"=>"P", "AUTO_SEND_TIME_2"=>ConvertTimeStamp(false, "FULL"))
		);
		while($arPosts=$rsPosts->Fetch())
		{
			if($limit===true)
			{
				$maxcount = COption::GetOptionInt("subscribe", "subscribe_max_emails_per_hit") - self::$current_emails_per_hit;
				if($maxcount <= 0)
					break;
			}
			else
			{
				$maxcount = 0;
			}
			$cPosting->SendMessage($arPosts["ID"], 0, $maxcount);
		}
	}
	else
	{
		if($site_id && $site_id != SITE_ID)
		{
			return "CPosting::AutoSend(".$ID.($limit? ",true": ",false").","".$site_id."");";
		}

		//Here is agent entry
		if($limit===true)
		{
			$maxcount = COption::GetOptionInt("subscribe", "subscribe_max_emails_per_hit") - self::$current_emails_per_hit;
			if($maxcount <= 0)
				return "CPosting::AutoSend(".$ID.",true".($site_id? ","".$site_id.""": "").");";
		}
		else
		{
			$maxcount = 0;
		}

		$cPosting = new CPosting;
		$res = $cPosting->SendMessage($ID, COption::GetOptionString("subscribe", "posting_interval"), $maxcount, true);
		if($res == "CONTINUE")
			return "CPosting::AutoSend(".$ID.($limit? ",true": ",false").($site_id?","".$site_id.""":"").");";
	}
	return "";
}