• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/landing.php
  • Класс: BitrixLandingLanding
  • Вызов: Landing::canPublicAfterCopy
private function canPublicAfterCopy(): bool
{
	$siteId = $this->getSiteId();
	$folderId = $this->getFolderId();

	// if permissions enough
	if (!$this->canPublication())
	{
		return false;
	}

	// in root, we can
	if (!$folderId)
	{
		return true;
	}

	// check all folders above the page
	$crumbs = Folder::getBreadCrumbs($folderId, $siteId);
	foreach ($crumbs as $crumb)
	{
		// if folder is active, we don't care about
		if ($crumb['ACTIVE'] === 'Y')
		{
			continue;
		}

		// check active pages in each folder above
		$res = self::getList([
			'select' => [
				'ID'
			],
			'filter' => [
				'=ACTIVE' => 'Y',
				'FOLDER_ID' => $crumb['ID'],
			],
			'limit' => 1
		]);
		if ($res->fetch())
		{
			// if such folder exists we cant public any folder
			return false;
		}

		// check active folders in folders above
		$res = Folder::getList([
			'select' => [
				'ID'
			],
			'filter' => [
				'=ACTIVE' => 'Y',
				'PARENT_ID' => $crumb['ID'],
			],
			'limit' => 1
			]);
		if ($res->fetch())
		{
			// if such folder exists we cant public any folder
			return false;
		}
	}

	// all folders are active or not exists active pages
	return true;
}