- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/agent.php
- Класс: BitrixLandingfor
- Вызов: for::clearRecycle
static function clearRecycle(?int $days = null): string
{
Rights::setGlobalOff();
$days = !is_null($days)
? $days
: (int) Manager::getOption('deleted_lifetime_days');
$date = new DateTime;
$date->add('-' . $days . ' days');
// check folders to delete
$foldersToDelete = [-1];
$res = Folder::getList([
'select' => [
'ID'
],
'filter' => [
'=DELETED' => 'Y',
' $date
]
]);
while ($row = $res->fetch())
{
$foldersToDelete[] = $row['ID'];
$foldersToDelete = array_merge($foldersToDelete, self::getSubFolders($row['ID']));
}
// first delete landings
$res = Landing::getList([
'select' => [
'ID', 'FOLDER_ID'
],
'filter' => [
[
'LOGIC' => 'OR',
[
'=DELETED' => 'Y',
' $date
],
[
'=SITE.DELETED' => 'Y',
' $date
],
[
'FOLDER_ID' => $foldersToDelete
]
],
'=DELETED' => ['Y', 'N'],
'=SITE.DELETED' => ['Y', 'N'],
'CHECK_PERMISSIONS' => 'N'
],
'order' => [
'DATE_MODIFY' => 'desc'
]
]);
while ($row = $res->fetch())
{
Lock::lockDeleteLanding($row['ID'], false);
Landing::delete($row['ID'], true)->isSuccess();
}
// delete folders
foreach (array_unique($foldersToDelete) as $folderId)
{
if ($folderId > 0)
{
Folder::delete($folderId)->isSuccess();
}
}
// then delete sites
$res = Site::getList([
'select' => [
'ID'
],
'filter' => [
'=DELETED' => 'Y',
' $date,
'CHECK_PERMISSIONS' => 'N'
],
'order' => [
'DATE_MODIFY' => 'desc'
]
]);
while ($row = $res->fetch())
{
Lock::lockDeleteSite($row['ID'], false);
Site::delete($row['ID'])->isSuccess();
}
Rights::setGlobalOn();
return __CLASS__ . '::' . __FUNCTION__ . '();';
}