- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/internals/site.php
- Класс: BitrixLandingInternalsSiteTable
- Вызов: SiteTable::OnBeforeDelete
static function OnBeforeDelete(EntityEvent $event)
{
if (self::$disableCallback)
{
return true;
}
$result = new EntityEventResult();
$primary = $event->getParameter('primary');
$siteController = self::getSiteController();
if ($primary)
{
// check delete access
$hasAccess = Rights::hasAccessForSite(
$primary['ID'],
Rights::ACCESS_TYPES['delete'],
true
);
if (!$hasAccess)
{
$result->setErrors(array(
new EntityEntityError(
Loc::getMessage('LANDING_TABLE_ERROR_ACCESS_DENIED_DELETED'),
'ACCESS_DENIED'
)
));
return $result;
}
// check if site is not empty
$res = LandingTable::getList(array(
'select' => array(
'ID'
),
'filter' => array(
'SITE_ID' => $primary['ID'],
'CHECK_PERMISSIONS' => 'N'
)
));
if ($res->fetch())
{
$result->setErrors(array(
new EntityEntityError(
Loc::getMessage('LANDING_TABLE_ERROR_SITE_IS_NOT_EMPTY'),
'SITE_IS_NOT_EMPTY'
)
));
return $result;
}
// check lock status
if (BitrixLandingLock::isSiteDeleteLocked($primary['ID']))
{
$result->setErrors(array(
new EntityEntityError(
Loc::getMessage('LANDING_TABLE_ERROR_SITE_IS_LOCK'),
'SITE_IS_LOCK'
)
));
return $result;
}
// delete in b24.site
if (Manager::isB24())
{
$res = self::getList(array(
'select' => array(
'DOMAIN_ID',
'DOMAIN_NAME' => 'DOMAIN.DOMAIN',
'DOMAIN_PROVIDER' => 'DOMAIN.PROVIDER'
),
'filter' => array(
'ID' => $primary['ID'],
'DELETED' => ['Y', 'N'],
'CHECK_PERMISSIONS' => 'N'
)
));
if ($row = $res->fetch())
{
if ($row['DOMAIN_PROVIDER'] && ModuleManager::isModuleInstalled('bitrix24'))
{
$result->setErrors([
new EntityEntityError(
Loc::getMessage('LANDING_TABLE_ERROR_ACCESS_DENIED_DELETED'),
'ACCESS_DENIED_DELETED'
)
]);
return $result;
}
$domainId = $row['DOMAIN_ID'];
$domainName = $row['DOMAIN_NAME'];
$eventManager = BitrixMainEventManager::getInstance();
$eventManager->addEventHandler(
'landing',
'\' . __NAMESPACE__ . '\Site::onAfterDelete',
function(EntityEvent $event) use ($domainId, $domainName, $result, $siteController)
{
$res = self::getList(array(
'select' => array(
'ID'
),
'filter' => array(
'DOMAIN_ID' => $domainId,
'DELETED' => ['Y', 'N']
)
));
if (!$res->fetch())
{
DomainTable::delete($domainId);
try
{
$siteController::deleteDomain($domainName);
}
catch (SystemException $ex)
{
$result->setErrors(array(
self::customizeControllerError($ex)
));
return $result;
}
}
}
);
}
}
}
return $result;
}