- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/integration/trash/template.php
- Класс: BitrixTasksIntegrationTrashTemplate
- Вызов: Template::moveFromTrash
static function moveFromTrash(Entity $entity)
{
$result = new Result();
$connection = Application::getConnection();
try
{
$connection->queryExecute(
'UPDATE '.TemplateTable::getTableName().' SET ZOMBIE='N' WHERE ID='.$entity->getEntityId()
);
}
catch (Exception $e)
{
$result->addError(new Error($e->getMessage(), $e->getCode()));
}
try
{
$template = $connection->query(
'SELECT ID, REPLICATE, REPLICATE_PARAMS FROM '.
TemplateTable::getTableName().
' WHERE ID='.
$entity->getEntityId()
)->fetch();
if ($template["REPLICATE"] == "Y")
{
$name = 'CTasks::RepeatTaskByTemplateId('.$entity->getEntityId().');';
// First, remove all agents for this template
// self::removeAgents($id);
// Set up new agent
$nextTime = CTasks::getNextTime(
unserialize($template['REPLICATE_PARAMS']),
$entity->getEntityId()
); // localtime
if ($nextTime)
{
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
CAgent::AddAgent(
$name,
'tasks',
'N', // is periodic?
86400, // interval (24 hours)
$nextTime, // datecheck
'Y', // is active?
$nextTime // next_exec
);
}
}
}
catch (Exception $e)
{
$result->addError(new Error($e->getMessage(), $e->getCode()));
}
return $result;
}