- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/mail/eventmanager.php
- Класс: BitrixMainMailEventManager
- Вызов: EventManager::cleanUpAgent
static function cleanUpAgent()
{
$period = abs(intval(MainConfigOption::get("main", "mail_event_period", 14)));
$periodInSeconds = $period * 24 * 3600;
$connection = MainApplication::getConnection();
$datetime = $connection->getSqlHelper()->addSecondsToDateTime('-' . $periodInSeconds);
$strSql = "DELETE FROM b_event WHERE DATE_EXEC <= " . $datetime;
$connection->query($strSql);
$strSql = "DELETE FROM b_event_attachment "
. " WHERE IS_FILE_COPIED='N'"
. " AND NOT EXISTS(SELECT e.ID FROM b_event e WHERE e.ID=EVENT_ID)";
$connection->query($strSql);
CAgent::addAgent(
self::class . '::cleanUpAttachmentAgent();',
'main',
"N",
60,
"",
"Y"
);
return "CEvent::CleanUpAgent();";
}