Bitrix Site Manager

CPostingTemplate::Execute

CPostingTemplate::Execute();

The method Execute selects a scheduled template for the subscription issue generation.

First, the method selects all subscriptions marked as active and automatic. Then, each subscription is checked whether it needs to be posted. When the method encounters a subscription which satisfy all requirements, it calls CPostingTemplate::AddPosting on this subscription and terminates.

This method should be called from the cron script or an agent function.

Parameters

No parameters.

Return Values

If at least one active automatic subscription could be found, the method returns a string to be called from the agent. Otherwise, an empty string is returned.

Example

The following is an example of using the method in a PHP script for the cron.


#!/usr/bin/php
<?php

//Specify your DOCUMENT_ROOT here!
$_SERVER["DOCUMENT_ROOT"] = "/opt/www/html";

$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS", true);
set_time_limit(0);
define("LANG", "en");
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if (CModule::IncludeModule("subscribe"))
    CPostingTemplate::Execute();
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
?>