• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/volume/event.php
  • Класс: Bitrix\Crm\Volume\Event
  • Вызов: Event::dropEventFiles
static function dropEventFiles($eventId, $deletedBy)
{
	$droppedCount = 0;

	$eventRes = Crm\EventTable::getByPrimary($eventId);
	if ($event = $eventRes->fetch())
	{
		$files = \unserialize($event['FILES'], ['allowed_classes' => false]);
		if (is_array($files))
		{
			for ($i = count($files) - 1; $i >= 0; $i--)
			{
				\CFile::delete((int)$files[$i]);
				$droppedCount ++;

				//todo: How to count fail here

				unset($files[$i]);
			}
			if (count($files) > 0)
			{
				Crm\EventTable::update($eventId, ['FILES' => serialize($files)]);
			}
			else
			{
				Crm\EventTable::update($eventId, ['FILES' => null]);
			}
		}
	}

	return $droppedCount;
}