|
|
@@ -5,6 +5,7 @@ namespace Opentalent\OtAdmin\Controller;
|
|
|
use Doctrine\DBAL\Driver\Exception;
|
|
|
use Opentalent\OtAdmin\Domain\Entity\SiteInfos;
|
|
|
use Opentalent\OtAdmin\Domain\Entity\SiteStatus;
|
|
|
+use Opentalent\OtAdmin\Enum\OtPageTypeEnum;
|
|
|
use Opentalent\OtCore\Exception\InvalidWebsiteConfigurationException;
|
|
|
use Opentalent\OtCore\Exception\NoSuchOrganizationException;
|
|
|
use Opentalent\OtCore\Exception\NoSuchRecordException;
|
|
|
@@ -19,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;
|
|
|
@@ -37,7 +39,7 @@ class SiteController extends ActionController
|
|
|
// Templates names
|
|
|
private const TEMPLATE_HOME = "OpenTalent.OtTemplating->home";
|
|
|
private const TEMPLATE_1COL = "OpenTalent.OtTemplating->1Col";
|
|
|
- private const TEMPLATE_3COL = "OpenTalent.OtTemplating->home";
|
|
|
+ private const TEMPLATE_3COL = "OpenTalent.OtTemplating->3Col";
|
|
|
private const TEMPLATE_EVENTS = "OpenTalent.OtTemplating->events";
|
|
|
private const TEMPLATE_STRUCTURESEVENTS = "OpenTalent.OtTemplating->structuresEvents";
|
|
|
private const TEMPLATE_STRUCTURES = "OpenTalent.OtTemplating->structures";
|
|
|
@@ -290,6 +292,7 @@ class SiteController extends ActionController
|
|
|
$rootUid,
|
|
|
'Accueil',
|
|
|
'/accueil',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
'',
|
|
|
[
|
|
|
'dokType' => self::DOK_SHORTCUT,
|
|
|
@@ -302,7 +305,8 @@ class SiteController extends ActionController
|
|
|
$websiteUid,
|
|
|
$rootUid,
|
|
|
'Présentation',
|
|
|
- '/presentation'
|
|
|
+ '/presentation',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE
|
|
|
);
|
|
|
|
|
|
// > 'Présentation > Qui sommes-nous ?' page (hidden by default)
|
|
|
@@ -311,6 +315,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Qui sommes nous?',
|
|
|
'/qui-sommes-nous',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
'',
|
|
|
['hidden' => 1]
|
|
|
);
|
|
|
@@ -321,6 +326,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Les adhérents',
|
|
|
'/les-adherents',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
self::TEMPLATE_MEMBERS
|
|
|
);
|
|
|
|
|
|
@@ -330,6 +336,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Les membres du CA',
|
|
|
'/les-membres-du-ca',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
self::TEMPLATE_MEMBERSCA
|
|
|
);
|
|
|
|
|
|
@@ -339,6 +346,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Informations Pratiques',
|
|
|
'/informations-pratiques',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
self::TEMPLATE_STRUCTUREDETAILS
|
|
|
);
|
|
|
|
|
|
@@ -349,6 +357,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Les sociétés adhérentes',
|
|
|
'/societes-adherentes',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
self::TEMPLATE_STRUCTURES
|
|
|
);
|
|
|
}
|
|
|
@@ -359,6 +368,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Historique',
|
|
|
'/historique',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
'',
|
|
|
['hidden' => 1]
|
|
|
);
|
|
|
@@ -371,6 +381,7 @@ class SiteController extends ActionController
|
|
|
$rootUid,
|
|
|
'Actualités',
|
|
|
'/actualites',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
self::TEMPLATE_NEWS,
|
|
|
['hidden' => 1]
|
|
|
);
|
|
|
@@ -389,16 +400,18 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/saison-en-cours'],
|
|
|
'Les évènements',
|
|
|
'/les-evenements',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
self::TEMPLATE_EVENTS
|
|
|
);
|
|
|
|
|
|
if ($isNetwork) {
|
|
|
- // > 'Présentation > Les sociétés adhérentes' page
|
|
|
+ // > 'Présentation > Evènements des structures' page
|
|
|
$this->insertPage(
|
|
|
$websiteUid,
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Évènements des structures',
|
|
|
'/evenements-des-structures',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
self::TEMPLATE_STRUCTURESEVENTS
|
|
|
);
|
|
|
}
|
|
|
@@ -409,6 +422,7 @@ class SiteController extends ActionController
|
|
|
$rootUid,
|
|
|
'Vie interne',
|
|
|
'/vie-interne',
|
|
|
+ OtPageTypeEnum::NON_MANDATORY,
|
|
|
'',
|
|
|
[
|
|
|
'hidden' => 1,
|
|
|
@@ -422,6 +436,7 @@ class SiteController extends ActionController
|
|
|
$rootUid,
|
|
|
'Footer',
|
|
|
'/footer',
|
|
|
+ OtPageTypeEnum::MANDATORY_NON_EDITABLE,
|
|
|
'',
|
|
|
[
|
|
|
'dokType' => self::DOK_FOLDER,
|
|
|
@@ -435,6 +450,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/footer'],
|
|
|
'Contact',
|
|
|
'/contact',
|
|
|
+ OtPageTypeEnum::MANDATORY_NON_EDITABLE,
|
|
|
self::TEMPLATE_CONTACT
|
|
|
);
|
|
|
|
|
|
@@ -443,7 +459,8 @@ class SiteController extends ActionController
|
|
|
$websiteUid,
|
|
|
$this->createdPagesIndex['/footer'],
|
|
|
'Plan du site',
|
|
|
- '/plan-du-site'
|
|
|
+ '/plan-du-site',
|
|
|
+ OtPageTypeEnum::MANDATORY_NON_EDITABLE
|
|
|
);
|
|
|
|
|
|
// > 'Footer > Mentions légales' page
|
|
|
@@ -452,6 +469,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/footer'],
|
|
|
'Mentions légales',
|
|
|
'/mentions-legales',
|
|
|
+ OtPageTypeEnum::MANDATORY_NON_EDITABLE,
|
|
|
self::TEMPLATE_LEGAL
|
|
|
);
|
|
|
|
|
|
@@ -461,6 +479,7 @@ class SiteController extends ActionController
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Contact',
|
|
|
'/ecrivez-nous',
|
|
|
+ OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
'',
|
|
|
[
|
|
|
'dokType' => self::DOK_SHORTCUT,
|
|
|
@@ -474,6 +493,7 @@ class SiteController extends ActionController
|
|
|
$rootUid,
|
|
|
'Page introuvable',
|
|
|
'/page-introuvable',
|
|
|
+ OtPageTypeEnum::NON_MANDATORY,
|
|
|
'',
|
|
|
[
|
|
|
'nav_hide' => 1,
|
|
|
@@ -1723,42 +1743,33 @@ class SiteController extends ActionController
|
|
|
$pages = $this->otPageRepository->getPageWithSubpages($rootUid);
|
|
|
|
|
|
// To understand how the rights levels are computed:
|
|
|
- // @see https://ressources.opentalent.fr/display/EX/Droits+des+BE+Users
|
|
|
+ // @see https://gitlab.2iopenservice.com/opentalent/ot_typo3/-/blob/master/doc/be_users.md?ref_type=heads
|
|
|
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;
|
|
|
+ $editorsPerms = self::PERM_SHOW + self::PERM_EDIT_CONTENT + self::PERM_EDIT_PAGE;
|
|
|
if ($isPremium) {
|
|
|
$adminPerms += self::PERM_NEW;
|
|
|
+ $editorsPerms += self::PERM_NEW;
|
|
|
}
|
|
|
- $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;
|
|
|
+ $editorsPerms = self::PERM_SHOW;
|
|
|
if ($isPremium) {
|
|
|
$adminPerms += self::PERM_NEW;
|
|
|
+ $editorsPerms += 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;
|
|
|
+ $editorsPerms = self::PERM_SHOW;
|
|
|
if ($isPremium) {
|
|
|
$adminPerms += self::PERM_NEW + self::PERM_EDIT_PAGE;
|
|
|
+ $editorsPerms += self::PERM_NEW + self::PERM_EDIT_PAGE;
|
|
|
}
|
|
|
- $editorsPerms = self::PERM_SHOW;
|
|
|
|
|
|
} else {
|
|
|
$adminPerms = self::PERM_SHOW + self::PERM_EDIT_CONTENT + self::PERM_EDIT_PAGE;
|
|
|
@@ -1768,7 +1779,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
$editorsPerms = self::PERM_SHOW + self::PERM_EDIT_CONTENT + self::PERM_EDIT_PAGE;
|
|
|
if ($isPremium) {
|
|
|
- $editorsPerms += self::PERM_NEW;
|
|
|
+ $editorsPerms += self::PERM_DELETE + self::PERM_NEW;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1817,6 +1828,42 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 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
|
|
|
+ {
|
|
|
+ $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;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Delete then regenerate all the typo3 sites yaml config files
|
|
|
*
|
|
|
@@ -1995,16 +2042,18 @@ class SiteController extends ActionController
|
|
|
* @param int $pid
|
|
|
* @param string $title
|
|
|
* @param string $slug
|
|
|
+ * @param OtPageTypeEnum $otPageType
|
|
|
* @param string $template
|
|
|
* @param array $moreValues
|
|
|
* @return int
|
|
|
*/
|
|
|
- private function insertPage(int $website_uid,
|
|
|
- int $pid,
|
|
|
- string $title,
|
|
|
- string $slug,
|
|
|
- string $template = '',
|
|
|
- array $moreValues = []
|
|
|
+ private function insertPage(int $website_uid,
|
|
|
+ int $pid,
|
|
|
+ string $title,
|
|
|
+ string $slug,
|
|
|
+ OtPageTypeEnum $otPageType = OtPageTypeEnum::MANDATORY_EDITABLE,
|
|
|
+ string $template = '',
|
|
|
+ array $moreValues = []
|
|
|
): int
|
|
|
{
|
|
|
$defaultValues = [
|
|
|
@@ -2017,6 +2066,7 @@ class SiteController extends ActionController
|
|
|
'backend_layout' => 'flux__grid',
|
|
|
'backend_layout_next_level' => 'flux__grid',
|
|
|
'ot_website_uid' => $website_uid,
|
|
|
+ 'ot_page_type' => $otPageType->value
|
|
|
];
|
|
|
|
|
|
if ($template) {
|
|
|
@@ -2052,6 +2102,7 @@ class SiteController extends ActionController
|
|
|
$this->getParentFolderUid(),
|
|
|
$title,
|
|
|
'/',
|
|
|
+ OtPageTypeEnum::ROOT,
|
|
|
self::TEMPLATE_HOME,
|
|
|
[
|
|
|
'is_siteroot' => 1,
|