|
@@ -12,8 +12,9 @@ use Opentalent\OtCore\Controller\ActionController;
|
|
|
use Opentalent\OtCore\Domain\Model\Organization;
|
|
use Opentalent\OtCore\Domain\Model\Organization;
|
|
|
use Opentalent\OtCore\Domain\Repository\OrganizationRepository;
|
|
use Opentalent\OtCore\Domain\Repository\OrganizationRepository;
|
|
|
use Opentalent\OtCore\Exception\ApiRequestException;
|
|
use Opentalent\OtCore\Exception\ApiRequestException;
|
|
|
|
|
+use Opentalent\OtCore\Website\OtWebsiteRepository;
|
|
|
use Opentalent\OtCore\Utility\FileUtility;
|
|
use Opentalent\OtCore\Utility\FileUtility;
|
|
|
-use Opentalent\OtRouter\Routing\Indexer;
|
|
|
|
|
|
|
+use Opentalent\OtCore\Routing\Indexer;
|
|
|
use PDO;
|
|
use PDO;
|
|
|
use Symfony\Component\Yaml\Yaml;
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
|
|
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
|
|
@@ -104,7 +105,7 @@ class SiteController extends ActionController
|
|
|
/**
|
|
/**
|
|
|
* @var \TYPO3\CMS\Core\Database\ConnectionPool
|
|
* @var \TYPO3\CMS\Core\Database\ConnectionPool
|
|
|
*/
|
|
*/
|
|
|
- private $connectionPool;
|
|
|
|
|
|
|
+ private \TYPO3\CMS\Core\Database\ConnectionPool $connectionPool;
|
|
|
|
|
|
|
|
public function injectConnectionPool(\TYPO3\CMS\Core\Database\ConnectionPool $connectionPool)
|
|
public function injectConnectionPool(\TYPO3\CMS\Core\Database\ConnectionPool $connectionPool)
|
|
|
{
|
|
{
|
|
@@ -114,13 +115,22 @@ class SiteController extends ActionController
|
|
|
/**
|
|
/**
|
|
|
* @var \TYPO3\CMS\Core\Cache\CacheManager
|
|
* @var \TYPO3\CMS\Core\Cache\CacheManager
|
|
|
*/
|
|
*/
|
|
|
- private $cacheManager;
|
|
|
|
|
|
|
+ private \TYPO3\CMS\Core\Cache\CacheManager $cacheManager;
|
|
|
|
|
|
|
|
public function injectCacheManager(\TYPO3\CMS\Core\Cache\CacheManager $cacheManager)
|
|
public function injectCacheManager(\TYPO3\CMS\Core\Cache\CacheManager $cacheManager)
|
|
|
{
|
|
{
|
|
|
$this->cacheManager = $cacheManager;
|
|
$this->cacheManager = $cacheManager;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @var OtWebsiteRepository
|
|
|
|
|
+ */
|
|
|
|
|
+ protected OtWebsiteRepository $otWebsiteRepository;
|
|
|
|
|
+
|
|
|
|
|
+ public function injectOtWebsiteRepository(OtWebsiteRepository $otWebsiteRepository) {
|
|
|
|
|
+ $this->otWebsiteRepository = $otWebsiteRepository;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Index of the pages created during the process
|
|
* Index of the pages created during the process
|
|
|
* >> [slug => uid]
|
|
* >> [slug => uid]
|
|
@@ -157,19 +167,20 @@ class SiteController extends ActionController
|
|
|
*/
|
|
*/
|
|
|
public function getSiteInfosAction(int $organizationId): SiteInfos
|
|
public function getSiteInfosAction(int $organizationId): SiteInfos
|
|
|
{
|
|
{
|
|
|
- $rootUid = $this->findRootUidFor($organizationId);
|
|
|
|
|
- $config = $this->findConfigFor($rootUid);
|
|
|
|
|
|
|
+ $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid']);
|
|
|
|
|
+
|
|
|
$organizationExtraData = $this->fetchOrganizationExtraData($organizationId);
|
|
$organizationExtraData = $this->fetchOrganizationExtraData($organizationId);
|
|
|
|
|
|
|
|
$rootPage = $this->otPageRepository->getPage($rootUid);
|
|
$rootPage = $this->otPageRepository->getPage($rootUid);
|
|
|
|
|
|
|
|
$site = new SiteInfos(
|
|
$site = new SiteInfos(
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
- $rootPage['title'],
|
|
|
|
|
- $config['base'],
|
|
|
|
|
- $rootPage['tx_opentalent_template'],
|
|
|
|
|
- $rootPage['tx_opentalent_template_preferences'],
|
|
|
|
|
- $rootPage['tx_opentalent_matomo_id'],
|
|
|
|
|
|
|
+ $website['organization_name'],
|
|
|
|
|
+ $this->otWebsiteRepository->getWebsiteDomain($website['uid']),
|
|
|
|
|
+ $website['template'],
|
|
|
|
|
+ $website['template_preferences'],
|
|
|
|
|
+ $website['matomo_id'],
|
|
|
self::IS_PRODUCT_PREMIUM[$organizationExtraData['admin']['product']] ?? false,
|
|
self::IS_PRODUCT_PREMIUM[$organizationExtraData['admin']['product']] ?? false,
|
|
|
(bool)$rootPage['deleted'],
|
|
(bool)$rootPage['deleted'],
|
|
|
($rootPage['hidden'] || $rootPage['fe_group'] < 0),
|
|
($rootPage['hidden'] || $rootPage['fe_group'] < 0),
|
|
@@ -236,9 +247,8 @@ class SiteController extends ActionController
|
|
|
$queryBuilder->getRestrictions()->removeAll();
|
|
$queryBuilder->getRestrictions()->removeAll();
|
|
|
$statement = $queryBuilder
|
|
$statement = $queryBuilder
|
|
|
->select('uid')
|
|
->select('uid')
|
|
|
- ->from('pages')
|
|
|
|
|
- ->where($queryBuilder->expr()->eq('tx_opentalent_structure_id', $queryBuilder->createNamedParameter($organization->getId())))
|
|
|
|
|
- ->andWhere('is_siteroot=1')
|
|
|
|
|
|
|
+ ->from('ot_websites')
|
|
|
|
|
+ ->where($queryBuilder->expr()->eq('organization_id', $queryBuilder->createNamedParameter($organization->getId())))
|
|
|
->execute();
|
|
->execute();
|
|
|
if ($statement->rowCount() > 0) {
|
|
if ($statement->rowCount() > 0) {
|
|
|
throw new \RuntimeException("A website with this organization's id already exists: " . $organization->getName() . "\n(if you can't see it, it might have been soft-deleted)");
|
|
throw new \RuntimeException("A website with this organization's id already exists: " . $organization->getName() . "\n(if you can't see it, it might have been soft-deleted)");
|
|
@@ -251,13 +261,19 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// keep tracks of the created folders and files to be able to remove them during a rollback
|
|
// keep tracks of the created folders and files to be able to remove them during a rollback
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // Create the website:
|
|
|
|
|
+ $websiteUid = $this->insertOtWebsite($organization);
|
|
|
|
|
+
|
|
|
// Create the site pages:
|
|
// Create the site pages:
|
|
|
// > Root page
|
|
// > Root page
|
|
|
- $rootUid = $this->insertRootPage($organization);
|
|
|
|
|
|
|
+ $rootUid = $this->insertRootPage(
|
|
|
|
|
+ $websiteUid,
|
|
|
|
|
+ $organization->getName()
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
// > 'Accueil' shortcut
|
|
// > 'Accueil' shortcut
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
'Accueil',
|
|
'Accueil',
|
|
|
'/accueil',
|
|
'/accueil',
|
|
@@ -270,7 +286,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Présentation' page
|
|
// > 'Présentation' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
'Présentation',
|
|
'Présentation',
|
|
|
'/presentation'
|
|
'/presentation'
|
|
@@ -278,7 +294,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Présentation > Qui sommes nous?' page (hidden by default)
|
|
// > 'Présentation > Qui sommes nous?' page (hidden by default)
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Qui sommes nous?',
|
|
'Qui sommes nous?',
|
|
|
'/qui-sommes-nous',
|
|
'/qui-sommes-nous',
|
|
@@ -288,7 +304,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Présentation > Les adhérents' page
|
|
// > 'Présentation > Les adhérents' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Les adhérents',
|
|
'Les adhérents',
|
|
|
'/les-adherents',
|
|
'/les-adherents',
|
|
@@ -297,7 +313,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Présentation > Les membres du CA' page
|
|
// > 'Présentation > Les membres du CA' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Les membres du CA',
|
|
'Les membres du CA',
|
|
|
'/les-membres-du-ca',
|
|
'/les-membres-du-ca',
|
|
@@ -307,7 +323,7 @@ class SiteController extends ActionController
|
|
|
if ($isNetwork) {
|
|
if ($isNetwork) {
|
|
|
// > 'Présentation > Les sociétés adhérentes' page
|
|
// > 'Présentation > Les sociétés adhérentes' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Les sociétés adhérentes',
|
|
'Les sociétés adhérentes',
|
|
|
'/societes-adherentes',
|
|
'/societes-adherentes',
|
|
@@ -317,7 +333,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Présentation > Historique' page (hidden by default)
|
|
// > 'Présentation > Historique' page (hidden by default)
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Historique',
|
|
'Historique',
|
|
|
'/historique',
|
|
'/historique',
|
|
@@ -329,7 +345,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Actualités' page (hidden by default)
|
|
// > 'Actualités' page (hidden by default)
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
'Actualités',
|
|
'Actualités',
|
|
|
'/actualites',
|
|
'/actualites',
|
|
@@ -339,7 +355,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Saison en cours' page
|
|
// > 'Saison en cours' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
'Saison en cours',
|
|
'Saison en cours',
|
|
|
'/saison-en-cours'
|
|
'/saison-en-cours'
|
|
@@ -347,7 +363,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Saison en cours > Les évènements' page
|
|
// > 'Saison en cours > Les évènements' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/saison-en-cours'],
|
|
$this->createdPagesIndex['/saison-en-cours'],
|
|
|
'Les évènements',
|
|
'Les évènements',
|
|
|
'/les-evenements',
|
|
'/les-evenements',
|
|
@@ -357,7 +373,7 @@ class SiteController extends ActionController
|
|
|
if ($isNetwork) {
|
|
if ($isNetwork) {
|
|
|
// > 'Présentation > Les sociétés adhérentes' page
|
|
// > 'Présentation > Les sociétés adhérentes' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Évènements des structures',
|
|
'Évènements des structures',
|
|
|
'/evenements-des-structures',
|
|
'/evenements-des-structures',
|
|
@@ -367,7 +383,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Vie interne' page (restricted, hidden by default)
|
|
// > 'Vie interne' page (restricted, hidden by default)
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
'Vie interne',
|
|
'Vie interne',
|
|
|
'/vie-interne',
|
|
'/vie-interne',
|
|
@@ -380,7 +396,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Footer' page (not in the menu)
|
|
// > 'Footer' page (not in the menu)
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
'Footer',
|
|
'Footer',
|
|
|
'/footer',
|
|
'/footer',
|
|
@@ -393,7 +409,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Footer > Contact' page
|
|
// > 'Footer > Contact' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/footer'],
|
|
$this->createdPagesIndex['/footer'],
|
|
|
'Contact',
|
|
'Contact',
|
|
|
'/contact',
|
|
'/contact',
|
|
@@ -402,7 +418,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Footer > Plan du site' page
|
|
// > 'Footer > Plan du site' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/footer'],
|
|
$this->createdPagesIndex['/footer'],
|
|
|
'Plan du site',
|
|
'Plan du site',
|
|
|
'/plan-du-site'
|
|
'/plan-du-site'
|
|
@@ -410,7 +426,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Footer > Mentions légales' page
|
|
// > 'Footer > Mentions légales' page
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/footer'],
|
|
$this->createdPagesIndex['/footer'],
|
|
|
'Mentions légales',
|
|
'Mentions légales',
|
|
|
'/mentions-legales',
|
|
'/mentions-legales',
|
|
@@ -419,7 +435,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Présentation > Contact' shortcut
|
|
// > 'Présentation > Contact' shortcut
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$this->createdPagesIndex['/presentation'],
|
|
$this->createdPagesIndex['/presentation'],
|
|
|
'Contact',
|
|
'Contact',
|
|
|
'/ecrivez-nous',
|
|
'/ecrivez-nous',
|
|
@@ -432,7 +448,7 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// > 'Page introuvable' page (not in the menu, read-only)
|
|
// > 'Page introuvable' page (not in the menu, read-only)
|
|
|
$this->insertPage(
|
|
$this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $websiteUid,
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
'Page introuvable',
|
|
'Page introuvable',
|
|
|
'/page-introuvable',
|
|
'/page-introuvable',
|
|
@@ -475,23 +491,6 @@ class SiteController extends ActionController
|
|
|
self::CTYPE_SITEMAP
|
|
self::CTYPE_SITEMAP
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- // Build and update the domain
|
|
|
|
|
- if ($mode == self::MODE_PROD) {
|
|
|
|
|
- $domain = $this->getOrganizationDomain($organizationId);
|
|
|
|
|
- } elseif ($mode == self::MODE_DEV) {
|
|
|
|
|
- $domain = $organization->getSubDomain() . '/';
|
|
|
|
|
- } else {
|
|
|
|
|
- throw new RuntimeException('Unknown value for $mode: ' . $mode);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $queryBuilder = $this->connectionPool->getQueryBuilderForTable('sys_domain');
|
|
|
|
|
- $queryBuilder->insert('sys_domain')
|
|
|
|
|
- ->values([
|
|
|
|
|
- 'pid' => $rootUid,
|
|
|
|
|
- 'domainName' => $domain
|
|
|
|
|
- ])
|
|
|
|
|
- ->execute();
|
|
|
|
|
-
|
|
|
|
|
// update sys_template
|
|
// update sys_template
|
|
|
$constants = $this->getTemplateConstants($organizationId, $organizationExtraData);
|
|
$constants = $this->getTemplateConstants($organizationId, $organizationExtraData);
|
|
|
|
|
|
|
@@ -518,7 +517,12 @@ class SiteController extends ActionController
|
|
|
->execute();
|
|
->execute();
|
|
|
|
|
|
|
|
// Create the site config.yaml file
|
|
// Create the site config.yaml file
|
|
|
- $this->writeConfigFile($organizationId, $rootUid, $domain, true);
|
|
|
|
|
|
|
+ $this->writeConfigFile(
|
|
|
|
|
+ $organizationId,
|
|
|
|
|
+ $rootUid,
|
|
|
|
|
+ $organization->getSubDomain() . '.opentalent.fr',
|
|
|
|
|
+ true
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
// Create the user_upload and form_definitions directories and update the sys_filemounts table
|
|
// Create the user_upload and form_definitions directories and update the sys_filemounts table
|
|
|
$uploadRelPath = "/user_upload/" . $organizationId;
|
|
$uploadRelPath = "/user_upload/" . $organizationId;
|
|
@@ -638,10 +642,10 @@ class SiteController extends ActionController
|
|
|
*/
|
|
*/
|
|
|
public function updateSiteAction(int $organizationId, bool $deep=false): int
|
|
public function updateSiteAction(int $organizationId, bool $deep=false): int
|
|
|
{
|
|
{
|
|
|
- $rootUid = $this->findRootUidFor($organizationId);
|
|
|
|
|
|
|
+ $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid']);
|
|
|
|
|
|
|
|
$organization = $this->fetchOrganization($organizationId);
|
|
$organization = $this->fetchOrganization($organizationId);
|
|
|
- $organizationDomain = $this->getOrganizationDomain($organizationId);
|
|
|
|
|
|
|
|
|
|
// This extra-data can not be retrieved from the API for now, but
|
|
// This extra-data can not be retrieved from the API for now, but
|
|
|
// this shall be set up as soon as possible, to avoid requesting
|
|
// this shall be set up as soon as possible, to avoid requesting
|
|
@@ -653,19 +657,28 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// keep tracks of the created folders and files to be able to remove them during a rollback
|
|
// keep tracks of the created folders and files to be able to remove them during a rollback
|
|
|
try {
|
|
try {
|
|
|
- // ## Update the pages table (structure id, structure domain)
|
|
|
|
|
- $sitePages = $this->otPageRepository->getAllSitePages($rootUid);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // ## Update the ot_website table
|
|
|
|
|
+ $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
|
|
|
|
|
+ $queryBuilder->update('ot_websites')
|
|
|
|
|
+ ->set('subdomain', $organization->getSubDomain())
|
|
|
|
|
+ ->set('organization_name', $organization->getName())
|
|
|
|
|
+ ->where($queryBuilder->expr()->eq('uid', $website['uid']))
|
|
|
|
|
+ ->execute();
|
|
|
|
|
+
|
|
|
|
|
+ // ## Update the root page's subpages
|
|
|
|
|
+ $sitePages = $this->otPageRepository->getAllSubpagesForPage($rootUid);
|
|
|
foreach ($sitePages as $page) {
|
|
foreach ($sitePages as $page) {
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
$queryBuilder->update('pages')
|
|
$queryBuilder->update('pages')
|
|
|
- ->set('tx_opentalent_structure_id', $organizationId)
|
|
|
|
|
- ->set('tx_opentalent_structure_domain', $organizationDomain)
|
|
|
|
|
|
|
+ ->set('ot_website_uid', $website['uid'])
|
|
|
->where($queryBuilder->expr()->eq('uid', $page['uid']))
|
|
->where($queryBuilder->expr()->eq('uid', $page['uid']))
|
|
|
->execute();
|
|
->execute();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// ## Update the config.yaml file
|
|
// ## Update the config.yaml file
|
|
|
if ($deep) {
|
|
if ($deep) {
|
|
|
|
|
+ $organizationDomain = $this->otWebsiteRepository->getWebsiteDomain($rootUid);
|
|
|
$this->writeConfigFile($organizationId, $rootUid, $organizationDomain, true);
|
|
$this->writeConfigFile($organizationId, $rootUid, $organizationDomain, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -682,7 +695,7 @@ class SiteController extends ActionController
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
$queryBuilder
|
|
$queryBuilder
|
|
|
->update('pages')
|
|
->update('pages')
|
|
|
- ->set('TSconfig', $this->getRootPageTsConfig($organization))
|
|
|
|
|
|
|
+ ->set('TSconfig', 'TCAdefaults.pages.ot_website_uid=' . $website['uid'])
|
|
|
->where($queryBuilder->expr()->eq('uid', $rootUid))
|
|
->where($queryBuilder->expr()->eq('uid', $rootUid))
|
|
|
->execute();
|
|
->execute();
|
|
|
|
|
|
|
@@ -691,9 +704,9 @@ class SiteController extends ActionController
|
|
|
$this->resetBeUserPermsAction($organizationId, true);
|
|
$this->resetBeUserPermsAction($organizationId, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // ## Reset the routing index
|
|
|
|
|
- $routingIndexer = GeneralUtility::makeInstance(ObjectManager::class)->get(Indexer::class);
|
|
|
|
|
- $routingIndexer->indexRoutesForWebsite($rootUid);
|
|
|
|
|
|
|
+// // ## Reset the routing index
|
|
|
|
|
+// $routingIndexer = GeneralUtility::makeInstance(ObjectManager::class)->get(Indexer::class);
|
|
|
|
|
+// $routingIndexer->indexRoutesForWebsite($rootUid);
|
|
|
|
|
|
|
|
// Try to commit the result
|
|
// Try to commit the result
|
|
|
$commitSuccess = $this->connectionPool->getConnectionByName('Default')->commit();
|
|
$commitSuccess = $this->connectionPool->getConnectionByName('Default')->commit();
|
|
@@ -737,14 +750,17 @@ class SiteController extends ActionController
|
|
|
* @throws \Doctrine\DBAL\DBALException
|
|
* @throws \Doctrine\DBAL\DBALException
|
|
|
* @throws \Throwable
|
|
* @throws \Throwable
|
|
|
*/
|
|
*/
|
|
|
- public function deleteSiteAction(int $organizationId, bool $hard=false, ?int $redirectTo=null, bool $force = false) {
|
|
|
|
|
- $rootUid = $this->findRootUidFor($organizationId);
|
|
|
|
|
|
|
+ public function deleteSiteAction(int $organizationId, bool $hard=false, ?int $redirectTo=null, bool $force = false): int
|
|
|
|
|
+ {
|
|
|
|
|
+ $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
|
|
|
|
|
+ $websiteUid = $website['uid'];
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid']);
|
|
|
|
|
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
$isDeleted = $queryBuilder
|
|
$isDeleted = $queryBuilder
|
|
|
->select('deleted')
|
|
->select('deleted')
|
|
|
- ->from('pages')
|
|
|
|
|
- ->where($queryBuilder->expr()->eq('uid', $rootUid))
|
|
|
|
|
|
|
+ ->from('ot_websites')
|
|
|
|
|
+ ->where($queryBuilder->expr()->eq('uid', $website['uid']))
|
|
|
->execute()
|
|
->execute()
|
|
|
->fetchColumn(0) == 1;
|
|
->fetchColumn(0) == 1;
|
|
|
|
|
|
|
@@ -762,8 +778,10 @@ class SiteController extends ActionController
|
|
|
if ($redirectTo == $organizationId) {
|
|
if ($redirectTo == $organizationId) {
|
|
|
throw new \InvalidArgumentException('redirectTo value has to be different from the organizationId');
|
|
throw new \InvalidArgumentException('redirectTo value has to be different from the organizationId');
|
|
|
}
|
|
}
|
|
|
- $originUrl = $this->getSiteInfosAction($organizationId)->getBaseUrl();
|
|
|
|
|
- $targetUrl = $this->getSiteInfosAction($redirectTo)->getBaseUrl();
|
|
|
|
|
|
|
+ $originUrl = $this->otWebsiteRepository->getWebsiteDomain($websiteUid);
|
|
|
|
|
+
|
|
|
|
|
+ $targetOrganizationWebsite = $this->otWebsiteRepository->getWebsiteByOrganizationId($redirectTo);
|
|
|
|
|
+ $targetUrl = $this->otWebsiteRepository->getWebsiteDomain($targetOrganizationWebsite['uid']);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// start transactions
|
|
// start transactions
|
|
@@ -773,6 +791,7 @@ class SiteController extends ActionController
|
|
|
$renamed = [];
|
|
$renamed = [];
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+
|
|
|
$pages = $this->otPageRepository->getAllSubpagesForPage($rootUid);
|
|
$pages = $this->otPageRepository->getAllSubpagesForPage($rootUid);
|
|
|
foreach($pages as $page) {
|
|
foreach($pages as $page) {
|
|
|
$this->delete('tt_content', 'pid', $page['uid'], $hard);
|
|
$this->delete('tt_content', 'pid', $page['uid'], $hard);
|
|
@@ -780,12 +799,9 @@ class SiteController extends ActionController
|
|
|
}
|
|
}
|
|
|
$this->delete('tt_content', 'pid', $rootUid, $hard);
|
|
$this->delete('tt_content', 'pid', $rootUid, $hard);
|
|
|
$this->delete('pages', 'uid', $rootUid, $hard);
|
|
$this->delete('pages', 'uid', $rootUid, $hard);
|
|
|
- $this->delete('sys_template', 'pid', $rootUid, $hard);
|
|
|
|
|
|
|
|
|
|
- if ($hard) {
|
|
|
|
|
- // there is no 'deleted' field in sys_domain
|
|
|
|
|
- $this->delete('sys_domain', 'pid', $rootUid, $hard);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $this->delete('sys_template', 'pid', $rootUid, $hard);
|
|
|
|
|
+ $this->delete('ot_websites', 'uid', $websiteUid, $hard);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
$adminBeUserUid = $this->findAdminBeUserUid($rootUid);
|
|
$adminBeUserUid = $this->findAdminBeUserUid($rootUid);
|
|
@@ -974,8 +990,11 @@ class SiteController extends ActionController
|
|
|
* @throws \Doctrine\DBAL\ConnectionException
|
|
* @throws \Doctrine\DBAL\ConnectionException
|
|
|
* @throws \Doctrine\DBAL\DBALException
|
|
* @throws \Doctrine\DBAL\DBALException
|
|
|
*/
|
|
*/
|
|
|
- public function undeleteSiteAction(int $organizationId) {
|
|
|
|
|
- $rootUid = $this->findRootUidFor($organizationId);
|
|
|
|
|
|
|
+ public function undeleteSiteAction(int $organizationId): int
|
|
|
|
|
+ {
|
|
|
|
|
+ $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId, false);
|
|
|
|
|
+ $websiteUid = $website['uid'];
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid'], false);
|
|
|
|
|
|
|
|
// start transactions
|
|
// start transactions
|
|
|
$this->connectionPool->getConnectionByName('Default')->beginTransaction();
|
|
$this->connectionPool->getConnectionByName('Default')->beginTransaction();
|
|
@@ -984,8 +1003,14 @@ class SiteController extends ActionController
|
|
|
$renamed = [];
|
|
$renamed = [];
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- $pages = $this->otPageRepository->getAllSubpagesForPage($rootUid);
|
|
|
|
|
|
|
+ $queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content');
|
|
|
|
|
+ $queryBuilder
|
|
|
|
|
+ ->update('ot_websites')
|
|
|
|
|
+ ->set('deleted', 0)
|
|
|
|
|
+ ->where($queryBuilder->expr()->eq('uid', $websiteUid))
|
|
|
|
|
+ ->execute();
|
|
|
|
|
|
|
|
|
|
+ $pages = $this->otPageRepository->getAllSubpagesForPage($rootUid);
|
|
|
foreach($pages as $page) {
|
|
foreach($pages as $page) {
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content');
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('tt_content');
|
|
|
$queryBuilder
|
|
$queryBuilder
|
|
@@ -1030,7 +1055,6 @@ class SiteController extends ActionController
|
|
|
->where($queryBuilder->expr()->eq('path', "'/user_upload/" . $organizationId . "/'"))
|
|
->where($queryBuilder->expr()->eq('path', "'/user_upload/" . $organizationId . "/'"))
|
|
|
->execute();
|
|
->execute();
|
|
|
|
|
|
|
|
-
|
|
|
|
|
try {
|
|
try {
|
|
|
$editorsGroupUid = $this->findEditorsBeGroupUid($rootUid, false);
|
|
$editorsGroupUid = $this->findEditorsBeGroupUid($rootUid, false);
|
|
|
if ($editorsGroupUid !== null) {
|
|
if ($editorsGroupUid !== null) {
|
|
@@ -1128,7 +1152,7 @@ class SiteController extends ActionController
|
|
|
*/
|
|
*/
|
|
|
public function clearSiteCacheAction(int $organizationId, $clearAll=false): int
|
|
public function clearSiteCacheAction(int $organizationId, $clearAll=false): int
|
|
|
{
|
|
{
|
|
|
- $rootUid = $this->findRootUidFor($organizationId);
|
|
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->findRootUidForOrganization($organizationId);
|
|
|
|
|
|
|
|
OtCacheManager::clearSiteCache($rootUid, $clearAll);
|
|
OtCacheManager::clearSiteCache($rootUid, $clearAll);
|
|
|
|
|
|
|
@@ -1141,14 +1165,17 @@ class SiteController extends ActionController
|
|
|
* @param int $organizationId
|
|
* @param int $organizationId
|
|
|
* @param int $rootUid
|
|
* @param int $rootUid
|
|
|
* @return array
|
|
* @return array
|
|
|
|
|
+ * @throws NoSuchWebsiteException
|
|
|
*/
|
|
*/
|
|
|
- private function scanSite(int $organizationId, int $rootUid) {
|
|
|
|
|
|
|
+ private function scanSite(int $organizationId, int $rootUid): array
|
|
|
|
|
+ {
|
|
|
|
|
+ $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($website['uid']);
|
|
|
|
|
|
|
|
$warnings = [];
|
|
$warnings = [];
|
|
|
|
|
|
|
|
- // fetch pages and root page
|
|
|
|
|
- $pages = $this->otPageRepository->getAllSitePages($rootUid);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // fetch and index pages and root page
|
|
|
|
|
+ $pages = $this->otPageRepository->getPageWithSubpages($rootUid);
|
|
|
$rootPage = null;
|
|
$rootPage = null;
|
|
|
$pageIndex = [];
|
|
$pageIndex = [];
|
|
|
foreach ($pages as $page) {
|
|
foreach ($pages as $page) {
|
|
@@ -1161,11 +1188,14 @@ class SiteController extends ActionController
|
|
|
$extraData = $this->fetchOrganizationExtraData($organizationId);
|
|
$extraData = $this->fetchOrganizationExtraData($organizationId);
|
|
|
|
|
|
|
|
// load site's settings (uncomment if needed)
|
|
// load site's settings (uncomment if needed)
|
|
|
- // $config = $this->findConfigFor($rootUid);
|
|
|
|
|
|
|
+ // $config = $this->otWebsiteRepository->findConfigFor($rootUid);
|
|
|
|
|
|
|
|
// Check site's title
|
|
// Check site's title
|
|
|
|
|
+ if (trim($website['organization_name']) != trim($organization->getName())) {
|
|
|
|
|
+ $warnings[] = "Website's organization name is different from what is registered in the Opentalent DB";
|
|
|
|
|
+ }
|
|
|
if (trim($rootPage['title']) != trim($organization->getName())) {
|
|
if (trim($rootPage['title']) != trim($organization->getName())) {
|
|
|
- $warnings[] = "Site's title does not match the organization name";
|
|
|
|
|
|
|
+ $warnings[] = "Root page's title does not match the organization name";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Who is the expected owner among the be_users? there should be only one.
|
|
// Who is the expected owner among the be_users? there should be only one.
|
|
@@ -1265,6 +1295,7 @@ class SiteController extends ActionController
|
|
|
* @param bool $fullScan If true, a 'warnings' entry will be added to the result, and a full scan of
|
|
* @param bool $fullScan If true, a 'warnings' entry will be added to the result, and a full scan of
|
|
|
* the website pages will be performed.
|
|
* the website pages will be performed.
|
|
|
* @return SiteStatus
|
|
* @return SiteStatus
|
|
|
|
|
+ * @throws NoSuchWebsiteException
|
|
|
*/
|
|
*/
|
|
|
public function getSiteStatusAction(int $organizationId, bool $fullScan = false): SiteStatus
|
|
public function getSiteStatusAction(int $organizationId, bool $fullScan = false): SiteStatus
|
|
|
{
|
|
{
|
|
@@ -1306,16 +1337,25 @@ class SiteController extends ActionController
|
|
|
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
|
|
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
|
|
|
* @throws NoSuchWebsiteException
|
|
* @throws NoSuchWebsiteException
|
|
|
*/
|
|
*/
|
|
|
- public function setSiteDomainAction(int $organizationId, string $newDomain, bool $redirect = true): int
|
|
|
|
|
|
|
+ public function setSiteCustomDomainAction(int $organizationId, string $newDomain, bool $redirect = true): int
|
|
|
{
|
|
{
|
|
|
if (!preg_match(self::RX_DOMAIN,$newDomain) &&
|
|
if (!preg_match(self::RX_DOMAIN,$newDomain) &&
|
|
|
!preg_match("/[a-z0-9A-Z-]+\//", $newDomain)) {
|
|
!preg_match("/[a-z0-9A-Z-]+\//", $newDomain)) {
|
|
|
throw new \InvalidArgumentException("The given domain does not seems to be a valid domain: " . $newDomain);
|
|
throw new \InvalidArgumentException("The given domain does not seems to be a valid domain: " . $newDomain);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $infos = $this->getSiteInfosAction($organizationId);
|
|
|
|
|
- $originUrl = $infos->getBaseUrl();
|
|
|
|
|
- $rootUid = $infos->getRootUid();
|
|
|
|
|
|
|
+ $website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
|
|
|
|
|
+ $websiteUid = $website['uid'];
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->getWebsiteRootUid($websiteUid);
|
|
|
|
|
+
|
|
|
|
|
+ // ## Update the ot_website table
|
|
|
|
|
+ $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
|
|
|
|
|
+ $queryBuilder->update('ot_websites')
|
|
|
|
|
+ ->set('custom_domain', $newDomain)
|
|
|
|
|
+ ->where($queryBuilder->expr()->eq('uid', $websiteUid))
|
|
|
|
|
+ ->execute();
|
|
|
|
|
+
|
|
|
|
|
+ $originUrl = $this->otWebsiteRepository->getWebsiteDomain($websiteUid);
|
|
|
|
|
|
|
|
if (preg_replace('/https?:\/\//', '', $originUrl) == preg_replace('/https?:\/\//', '', $newDomain) ) {
|
|
if (preg_replace('/https?:\/\//', '', $originUrl) == preg_replace('/https?:\/\//', '', $newDomain) ) {
|
|
|
throw new \RuntimeException('The new domain should be different of the current one');
|
|
throw new \RuntimeException('The new domain should be different of the current one');
|
|
@@ -1508,7 +1548,7 @@ class SiteController extends ActionController
|
|
|
"and force the admin or group uid at the same time.");
|
|
"and force the admin or group uid at the same time.");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $rootUid = $this->findRootUidFor($organizationId);
|
|
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->findRootUidForOrganization($organizationId);
|
|
|
|
|
|
|
|
$organizationExtraData = $this->fetchOrganizationExtraData($organizationId);
|
|
$organizationExtraData = $this->fetchOrganizationExtraData($organizationId);
|
|
|
$isPremium = self::IS_PRODUCT_PREMIUM[$organizationExtraData['admin']['product']];
|
|
$isPremium = self::IS_PRODUCT_PREMIUM[$organizationExtraData['admin']['product']];
|
|
@@ -1589,7 +1629,7 @@ class SiteController extends ActionController
|
|
|
->execute();
|
|
->execute();
|
|
|
|
|
|
|
|
// fetch pages and root page
|
|
// fetch pages and root page
|
|
|
- $pages = $this->otPageRepository->getAllSitePages($rootUid);
|
|
|
|
|
|
|
+ $pages = $this->otPageRepository->getPageWithSubpages($rootUid);
|
|
|
|
|
|
|
|
// To understand how the rights levels are computed:
|
|
// To understand how the rights levels are computed:
|
|
|
// @see https://ressources.opentalent.fr/display/EX/Droits+des+BE+Users
|
|
// @see https://ressources.opentalent.fr/display/EX/Droits+des+BE+Users
|
|
@@ -1693,7 +1733,7 @@ class SiteController extends ActionController
|
|
|
*/
|
|
*/
|
|
|
public function updateRoutingIndexAction(int $organizationId)
|
|
public function updateRoutingIndexAction(int $organizationId)
|
|
|
{
|
|
{
|
|
|
- $rootUid = $this->findRootUidFor($organizationId);
|
|
|
|
|
|
|
+ $rootUid = $this->otWebsiteRepository->findRootUidForOrganization($organizationId);
|
|
|
|
|
|
|
|
$routingIndexer = GeneralUtility::makeInstance(ObjectManager::class)->get(Indexer::class);
|
|
$routingIndexer = GeneralUtility::makeInstance(ObjectManager::class)->get(Indexer::class);
|
|
|
$routingIndexer->indexRoutesForWebsite($rootUid);
|
|
$routingIndexer->indexRoutesForWebsite($rootUid);
|
|
@@ -1717,89 +1757,29 @@ class SiteController extends ActionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Retrieves the current full domain of the given organization.
|
|
|
|
|
- *
|
|
|
|
|
- * @param int $organizationId
|
|
|
|
|
- * @return string
|
|
|
|
|
- */
|
|
|
|
|
- private function getOrganizationDomain(int $organizationId): string
|
|
|
|
|
- {
|
|
|
|
|
- $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
|
|
- $queryBuilder->getRestrictions()->removeAll();
|
|
|
|
|
- $customDomain = $queryBuilder
|
|
|
|
|
- ->select('domain')
|
|
|
|
|
- ->from('tx_opentalent_custom_domains')
|
|
|
|
|
- ->where($queryBuilder->expr()->eq('organization_id', $organizationId))
|
|
|
|
|
- ->execute()
|
|
|
|
|
- ->fetchColumn(0);
|
|
|
|
|
-
|
|
|
|
|
- if ($customDomain) {
|
|
|
|
|
- return $customDomain;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $organization = $this->fetchOrganization($organizationId);
|
|
|
|
|
-
|
|
|
|
|
- return $organization->getSubDomain() . '.opentalent.fr';
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Try to find the root page uid of the organization's website and return it.
|
|
|
|
|
- * Throw a Opentalent\OtAdmin\NoSuchWebsiteException exception if the website does not exist.
|
|
|
|
|
|
|
+ * Insert a new row in the 'pages' table of the Typo3 DB
|
|
|
|
|
+ * and return its uid
|
|
|
*
|
|
*
|
|
|
- * @param $organizationId
|
|
|
|
|
|
|
+ * @param Organization $organization
|
|
|
* @return int
|
|
* @return int
|
|
|
- * @throws NoSuchWebsiteException
|
|
|
|
|
*/
|
|
*/
|
|
|
- private function findRootUidFor($organizationId): int
|
|
|
|
|
|
|
+ private function insertOtWebsite(Organization $organization): int
|
|
|
{
|
|
{
|
|
|
- $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
|
|
- $queryBuilder->getRestrictions()->removeAll();
|
|
|
|
|
- $rows = $queryBuilder
|
|
|
|
|
- ->select('uid')
|
|
|
|
|
- ->from('pages')
|
|
|
|
|
- ->where('is_siteroot=1')
|
|
|
|
|
- ->andWhere($queryBuilder->expr()->eq('tx_opentalent_structure_id', $organizationId))
|
|
|
|
|
- ->execute()
|
|
|
|
|
- ->fetchAll();
|
|
|
|
|
-
|
|
|
|
|
- if (count($rows) > 1) {
|
|
|
|
|
- throw new \RuntimeException("More than one website match this organization id");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $rootUid = (int)$rows[0]['uid'];
|
|
|
|
|
- if ($rootUid > 0) {
|
|
|
|
|
- return $rootUid;
|
|
|
|
|
- }
|
|
|
|
|
- throw new NoSuchWebsiteException("No website found for organization " . $organizationId);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $values = [
|
|
|
|
|
+ 'organization_id' => $organization->getId(),
|
|
|
|
|
+ 'subdomain' => $organization->getSubDomain(),
|
|
|
|
|
+ 'locale' => 'fr_FR',
|
|
|
|
|
+ 'organization_name' => $organization->getName()
|
|
|
|
|
+ ];
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Try to find the id of the organization owning this website.
|
|
|
|
|
- *
|
|
|
|
|
- * @param $rootUid
|
|
|
|
|
- * @return int
|
|
|
|
|
- * @throws NoSuchWebsiteException
|
|
|
|
|
- */
|
|
|
|
|
- private function findOrganizationIdUidFor($rootUid): int
|
|
|
|
|
- {
|
|
|
|
|
- $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
|
|
- $queryBuilder->getRestrictions()->removeAll();
|
|
|
|
|
- $organizationId = $queryBuilder
|
|
|
|
|
- ->select('tx_opentalent_structure_id')
|
|
|
|
|
- ->from('pages')
|
|
|
|
|
- ->where('is_siteroot=1')
|
|
|
|
|
- ->andWhere($queryBuilder->expr()->eq('uid', $rootUid))
|
|
|
|
|
- ->execute()
|
|
|
|
|
- ->fetchColumn(0);
|
|
|
|
|
|
|
+ $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
|
|
|
|
|
+ $queryBuilder->insert('ot_websites')
|
|
|
|
|
+ ->values($values)
|
|
|
|
|
+ ->execute();
|
|
|
|
|
|
|
|
- if ($organizationId > 0) {
|
|
|
|
|
- return $organizationId;
|
|
|
|
|
- }
|
|
|
|
|
- throw new NoSuchWebsiteException("No organization found for website " . $rootUid);
|
|
|
|
|
|
|
+ return (int)$queryBuilder->getConnection()->lastInsertId();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Determine which folder-type Typo3 page should contain the new website
|
|
* Determine which folder-type Typo3 page should contain the new website
|
|
|
* CREATES IT if needed, and return its uid
|
|
* CREATES IT if needed, and return its uid
|
|
@@ -1860,7 +1840,7 @@ class SiteController extends ActionController
|
|
|
* @param array $moreValues
|
|
* @param array $moreValues
|
|
|
* @return int
|
|
* @return int
|
|
|
*/
|
|
*/
|
|
|
- private function insertPage(Organization $organization,
|
|
|
|
|
|
|
+ private function insertPage(int $website_uid,
|
|
|
int $pid,
|
|
int $pid,
|
|
|
string $title,
|
|
string $title,
|
|
|
string $slug,
|
|
string $slug,
|
|
@@ -1878,8 +1858,7 @@ class SiteController extends ActionController
|
|
|
'slug' => $slug,
|
|
'slug' => $slug,
|
|
|
'backend_layout' => 'flux__grid',
|
|
'backend_layout' => 'flux__grid',
|
|
|
'backend_layout_next_level' => 'flux__grid',
|
|
'backend_layout_next_level' => 'flux__grid',
|
|
|
- 'tx_opentalent_structure_id' => $organization->getId(),
|
|
|
|
|
- 'tx_opentalent_structure_domain' => $this->getOrganizationDomain($organization->getId()),
|
|
|
|
|
|
|
+ 'ot_website_uid' => $website_uid,
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
if ($template) {
|
|
if ($template) {
|
|
@@ -1907,17 +1886,17 @@ class SiteController extends ActionController
|
|
|
* @param Organization $organization
|
|
* @param Organization $organization
|
|
|
* @return int
|
|
* @return int
|
|
|
*/
|
|
*/
|
|
|
- private function insertRootPage(Organization $organization): int
|
|
|
|
|
|
|
+ private function insertRootPage(int $website_uid, string $title): int
|
|
|
{
|
|
{
|
|
|
return $this->insertPage(
|
|
return $this->insertPage(
|
|
|
- $organization,
|
|
|
|
|
|
|
+ $website_uid,
|
|
|
$this->getParentFolderUid(),
|
|
$this->getParentFolderUid(),
|
|
|
- $organization->getName(),
|
|
|
|
|
|
|
+ $title,
|
|
|
'/',
|
|
'/',
|
|
|
self::TEMPLATE_HOME,
|
|
self::TEMPLATE_HOME,
|
|
|
[
|
|
[
|
|
|
'is_siteroot' => 1,
|
|
'is_siteroot' => 1,
|
|
|
- 'TSconfig' => $this->getRootPageTsConfig($organization),
|
|
|
|
|
|
|
+ 'TSconfig' => 'TCAdefaults.pages.ot_website_uid=' . $website_uid,
|
|
|
'tx_opentalent_template' => self::DEFAULT_THEME,
|
|
'tx_opentalent_template' => self::DEFAULT_THEME,
|
|
|
'tx_opentalent_template_preferences' => '{"themeColor":"' . self::DEFAULT_COLOR . '","displayCarousel":"1"}'
|
|
'tx_opentalent_template_preferences' => '{"themeColor":"' . self::DEFAULT_COLOR . '","displayCarousel":"1"}'
|
|
|
]
|
|
]
|
|
@@ -2047,17 +2026,6 @@ class SiteController extends ActionController
|
|
|
"}";
|
|
"}";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Return the TSConfig for the root page of the given organization
|
|
|
|
|
- *
|
|
|
|
|
- * @param Organization $organization
|
|
|
|
|
- * @return string
|
|
|
|
|
- */
|
|
|
|
|
- private function getRootPageTsConfig(Organization $organization): string {
|
|
|
|
|
- return "TCAdefaults.pages.tx_opentalent_structure_id=" . $organization->getId() . "\r\n" .
|
|
|
|
|
- "TCAdefaults.pages.tx_opentalent_structure_domain=" . $this->getOrganizationDomain($organization->getId());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Create the given directory, give its property to the www-data group and
|
|
* Create the given directory, give its property to the www-data group and
|
|
|
* record it as a newly created dir (for an eventual rollback)
|
|
* record it as a newly created dir (for an eventual rollback)
|
|
@@ -2089,75 +2057,6 @@ class SiteController extends ActionController
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Try to find the config file of the website in the less resource-consuming way
|
|
|
|
|
- * and parse it.
|
|
|
|
|
- *
|
|
|
|
|
- * @param int $rootUid
|
|
|
|
|
- * @return array Path of the configuration file and parsed configuration of the website
|
|
|
|
|
- */
|
|
|
|
|
- protected function findConfigFileAndContentFor(int $rootUid): array
|
|
|
|
|
- {
|
|
|
|
|
- $configs_directory = $_ENV['TYPO3_PATH_APP'] . "/config/sites/";
|
|
|
|
|
- $candidates = array_filter(
|
|
|
|
|
- scandir($configs_directory),
|
|
|
|
|
- function ($x) { return $x != '.' && $x != '..'; }
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- // try to filter by directory name
|
|
|
|
|
- foreach ($candidates as $subdir) {
|
|
|
|
|
- if (preg_match('/\.*_' . $rootUid . '$/', $subdir)) {
|
|
|
|
|
- $filename = $configs_directory . $subdir . '/config.yaml';
|
|
|
|
|
- try {
|
|
|
|
|
- $yamlConfig = Yaml::parseFile($filename);
|
|
|
|
|
-
|
|
|
|
|
- if ($yamlConfig['rootPageId'] === $rootUid) {
|
|
|
|
|
- return [$filename, $yamlConfig];
|
|
|
|
|
- }
|
|
|
|
|
- } catch (\Symfony\Component\Yaml\Exception\ParseException $e) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // it wasn't found the easy way, let's look to each file... :(
|
|
|
|
|
- foreach ($candidates as $subdir) {
|
|
|
|
|
- $filename = $configs_directory . $subdir . '/config.yaml';
|
|
|
|
|
- try {
|
|
|
|
|
- $yamlConfig = Yaml::parseFile($filename);
|
|
|
|
|
- if ($yamlConfig['rootPageId'] === $rootUid) {
|
|
|
|
|
- return [$filename, $yamlConfig];
|
|
|
|
|
- }
|
|
|
|
|
- } catch (\Symfony\Component\Yaml\Exception\ParseException $e) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return [null, []];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Similar to findConfigFileAndContentFor(), but only returns the parsed configuration
|
|
|
|
|
- * @param int $rootUid
|
|
|
|
|
- * @return array Configuration of the website
|
|
|
|
|
- */
|
|
|
|
|
- protected function findConfigFor(int $rootUid): array
|
|
|
|
|
- {
|
|
|
|
|
- $pathAndConfig = $this->findConfigFileAndContentFor($rootUid);
|
|
|
|
|
- return $pathAndConfig[1];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Similar to findConfigFileAndContentFor(), but only returns the config file path
|
|
|
|
|
- * @param int $rootUid
|
|
|
|
|
- * @return string Path of the config file of the given website
|
|
|
|
|
- */
|
|
|
|
|
- protected function findConfigFilePathFor(int $rootUid): string
|
|
|
|
|
- {
|
|
|
|
|
- $pathAndConfig = $this->findConfigFileAndContentFor($rootUid);
|
|
|
|
|
- return $pathAndConfig[0];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Create or update the .../sites/.../config.yaml file of the given site
|
|
* Create or update the .../sites/.../config.yaml file of the given site
|
|
|
*
|
|
*
|
|
@@ -2168,7 +2067,7 @@ class SiteController extends ActionController
|
|
|
*/
|
|
*/
|
|
|
private function writeConfigFile(int $organizationId, int $rootUid, string $domain, bool $forceRecreate = false): void
|
|
private function writeConfigFile(int $organizationId, int $rootUid, string $domain, bool $forceRecreate = false): void
|
|
|
{
|
|
{
|
|
|
- $existing = $this->findConfigFileAndContentFor($rootUid);
|
|
|
|
|
|
|
+ $existing = $this->otWebsiteRepository->findConfigFileAndContentFor($rootUid);
|
|
|
$configFilename = $existing[0];
|
|
$configFilename = $existing[0];
|
|
|
$config = $existing[1];
|
|
$config = $existing[1];
|
|
|
|
|
|
|
@@ -2450,9 +2349,9 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
// [For retrocompatibility] Try to find if there is a be_user still in the v8.7 data format
|
|
// [For retrocompatibility] Try to find if there is a be_user still in the v8.7 data format
|
|
|
if ($adminUid == null) {
|
|
if ($adminUid == null) {
|
|
|
- $organizationId = $this->findOrganizationIdUidFor($rootUid);
|
|
|
|
|
|
|
+ $website = $this->otWebsiteRepository->getWebsiteByPageUid($rootUid);
|
|
|
|
|
|
|
|
- $extraData = $this->fetchOrganizationExtraData($organizationId);
|
|
|
|
|
|
|
+ $extraData = $this->fetchOrganizationExtraData($website['organization_id']);
|
|
|
$expectedUsername = $extraData['admin']['username'];
|
|
$expectedUsername = $extraData['admin']['username'];
|
|
|
|
|
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('be_users');
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('be_users');
|