|
@@ -737,14 +737,14 @@ class SiteController extends ActionController
|
|
|
* with no possibility of undoing anything. In this case, you'll have to confirm your intention
|
|
* with no possibility of undoing anything. In this case, you'll have to confirm your intention
|
|
|
* by creating a file in the Typo3 root directory, named 'DEL####' (#### is the organization id)
|
|
* by creating a file in the Typo3 root directory, named 'DEL####' (#### is the organization id)
|
|
|
*
|
|
*
|
|
|
- * $redirectTo is the optional organization id to whom requests will be redirected
|
|
|
|
|
|
|
+ * If $redirectToParent is set to true, the website's url will be redirected to its parent's website
|
|
|
*
|
|
*
|
|
|
* The $force parameter, if true, will both bypass the 'DEL###' file confirmation and recursively delete the
|
|
* The $force parameter, if true, will both bypass the 'DEL###' file confirmation and recursively delete the
|
|
|
* user_upload and form_definitions of the website. <!> USE WITH CAUTION
|
|
* user_upload and form_definitions of the website. <!> USE WITH CAUTION
|
|
|
*
|
|
*
|
|
|
* @param int $organizationId
|
|
* @param int $organizationId
|
|
|
* @param bool $hard
|
|
* @param bool $hard
|
|
|
- * @param int|null $redirectTo
|
|
|
|
|
|
|
+ * @param bool $redirectToParent If set to true, the website's url will be redirected to its parent's website
|
|
|
* @param bool $force
|
|
* @param bool $force
|
|
|
* @return int
|
|
* @return int
|
|
|
* @throws NoSuchRecordException
|
|
* @throws NoSuchRecordException
|
|
@@ -752,7 +752,7 @@ 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): int
|
|
|
|
|
|
|
+ public function deleteSiteAction(int $organizationId, bool $hard=false, bool $redirectToParent=true, bool $force = false): int
|
|
|
{
|
|
{
|
|
|
$website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
|
|
$website = $this->otWebsiteRepository->getWebsiteByOrganizationId($organizationId);
|
|
|
$websiteUid = $website['uid'];
|
|
$websiteUid = $website['uid'];
|
|
@@ -776,13 +776,13 @@ class SiteController extends ActionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Prepare the redirection
|
|
// Prepare the redirection
|
|
|
- if ($redirectTo) {
|
|
|
|
|
- if ($redirectTo == $organizationId) {
|
|
|
|
|
- throw new \InvalidArgumentException('redirectTo value has to be different from the organizationId');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if ($redirectToParent) {
|
|
|
$originDomain = $this->otWebsiteRepository->resolveWebsiteDomain($website);
|
|
$originDomain = $this->otWebsiteRepository->resolveWebsiteDomain($website);
|
|
|
|
|
|
|
|
- $targetOrganizationWebsite = $this->otWebsiteRepository->getWebsiteByOrganizationId($redirectTo);
|
|
|
|
|
|
|
+ $organization = $this->fetchOrganization($organizationId);
|
|
|
|
|
+
|
|
|
|
|
+ $targetOrganizationId = $organization->getParentId();
|
|
|
|
|
+ $targetOrganizationWebsite = $this->otWebsiteRepository->getWebsiteByOrganizationId($targetOrganizationId);
|
|
|
$targetDomain = $this->otWebsiteRepository->resolveWebsiteDomain($targetOrganizationWebsite);
|
|
$targetDomain = $this->otWebsiteRepository->resolveWebsiteDomain($targetOrganizationWebsite);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -930,7 +930,7 @@ class SiteController extends ActionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Add the redirection
|
|
// Add the redirection
|
|
|
- if ($redirectTo) {
|
|
|
|
|
|
|
+ if ($redirectToParent) {
|
|
|
$this->addRedirection($originDomain, $targetDomain);
|
|
$this->addRedirection($originDomain, $targetDomain);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1124,7 +1124,7 @@ class SiteController extends ActionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// remove eventual redirection from this site to another
|
|
// remove eventual redirection from this site to another
|
|
|
- $originUrl = $this->getSiteInfosAction($organizationId)->getBaseUrl();
|
|
|
|
|
|
|
+ $originUrl = $this->otWebsiteRepository->resolveWebsiteDomain($website);
|
|
|
$this->removeRedirectionsFrom($originUrl);
|
|
$this->removeRedirectionsFrom($originUrl);
|
|
|
|
|
|
|
|
// Try to commit the result
|
|
// Try to commit the result
|
|
@@ -1993,7 +1993,8 @@ class SiteController extends ActionController
|
|
|
|
|
|
|
|
private function fetchOrganizationExtraData(int $organizationId) {
|
|
private function fetchOrganizationExtraData(int $organizationId) {
|
|
|
|
|
|
|
|
- $db_host = $_SERVER['HTTP_HOST'] != 'local.sub.opentalent.fr' ? 'prod-back' : 'db';
|
|
|
|
|
|
|
+ $db_host = ($_SERVER['HTTP_HOST'] == 'typo3' |
|
|
|
|
|
+ $_SERVER['HTTP_HOST'] == 'local.sub.opentalent.fr') ? 'db' : 'prod-back';
|
|
|
|
|
|
|
|
$cnn = new PDO(
|
|
$cnn = new PDO(
|
|
|
"mysql:host=" . $db_host . ";dbname=opentalent",
|
|
"mysql:host=" . $db_host . ";dbname=opentalent",
|