|
|
@@ -20,6 +20,7 @@ use Opentalent\OtCore\Utility\FileUtility;
|
|
|
use PDO;
|
|
|
use RuntimeException;
|
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
+use Throwable;
|
|
|
use TYPO3\CMS\Core\Cache\CacheManager;
|
|
|
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
|
|
|
use TYPO3\CMS\Core\Crypto\PasswordHashing\InvalidPasswordHashException;
|
|
|
@@ -1745,7 +1746,7 @@ class SiteController extends ActionController
|
|
|
// @see https://ressources.opentalent.fr/display/EX/Droits+des+BE+Users
|
|
|
foreach ($pages as $page) {
|
|
|
|
|
|
- if ($page['is_siteroot']) {
|
|
|
+ if ($page['ot_page_type'] === OtPageTypeEnum::ROOT) {
|
|
|
|
|
|
$adminPerms = self::PERM_SHOW + self::PERM_EDIT_CONTENT + self::PERM_EDIT_PAGE;
|
|
|
if ($isPremium) {
|
|
|
@@ -1753,26 +1754,14 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
$editorsPerms = self::PERM_SHOW + self::PERM_EDIT_CONTENT;
|
|
|
|
|
|
- } else if (
|
|
|
- $page['slug'] === '/footer' ||
|
|
|
- $page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->legal' ||
|
|
|
- $page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->contact' ||
|
|
|
- $page['slug'] === '/plan-du-site'
|
|
|
- ) {
|
|
|
+ } else if ($page['ot_page_type'] === OtPageTypeEnum::MANDATORY_NON_EDITABLE) {
|
|
|
$adminPerms = self::PERM_SHOW;
|
|
|
if ($isPremium) {
|
|
|
$adminPerms += self::PERM_NEW;
|
|
|
}
|
|
|
$editorsPerms = self::PERM_SHOW;
|
|
|
|
|
|
- } else if (
|
|
|
- $page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->members' ||
|
|
|
- $page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->membersCa' ||
|
|
|
- $page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->structures' ||
|
|
|
- $page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->events' ||
|
|
|
- $page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->structuresEvents' ||
|
|
|
- $page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->structureDetails'
|
|
|
- ) {
|
|
|
+ } else if ($page['ot_page_type'] === OtPageTypeEnum::MANDATORY_EDITABLE) {
|
|
|
$adminPerms = self::PERM_SHOW;
|
|
|
if ($isPremium) {
|
|
|
$adminPerms += self::PERM_NEW + self::PERM_EDIT_PAGE;
|
|
|
@@ -1836,11 +1825,40 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function deleteNonMandatoryPages(int $organizationId): void
|
|
|
+ /**
|
|
|
+ * Delete all the pages created by the users, leaving only the starting mandatory pages.
|
|
|
+ *
|
|
|
+ * @param int $organizationId
|
|
|
+ * @return int
|
|
|
+ * @throws NoSuchRecordException
|
|
|
+ * @throws NoSuchWebsiteException
|
|
|
+ * @throws \Doctrine\DBAL\Exception
|
|
|
+ * @throws Throwable
|
|
|
+ */
|
|
|
+ public function deleteUserCreatedPagesAction(int $organizationId): int
|
|
|
{
|
|
|
- $pages = $this->otPageRepository->getPageWithSubpages($organizationId);
|
|
|
+ $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
|
|
|
+ $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid']);
|
|
|
+
|
|
|
+ $pages = $this->otPageRepository->getPageWithSubpages($rootUid);
|
|
|
|
|
|
+ $this->connectionPool->getConnectionByName('Default')->beginTransaction();
|
|
|
+
|
|
|
+ try {
|
|
|
+ foreach($pages as $page) {
|
|
|
+ if ($page['ot_page_type'] === OtPageTypeEnum::USER_CREATED->value) {
|
|
|
+ $this->delete('tt_content', 'pid', $page['uid'], true);
|
|
|
+ $this->delete('pages', 'uid', $page['uid'], true);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ $this->connectionPool->getConnectionByName('Default')->commit();
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ $this->connectionPool->getConnectionByName('Default')->rollBack();
|
|
|
+ throw $e;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $rootUid;
|
|
|
}
|
|
|
|
|
|
/**
|