|
|
@@ -720,7 +720,15 @@ class SiteController extends ActionController
|
|
|
"'/user_upload/" . $organizationId . "/Forms'",
|
|
|
$hard);
|
|
|
|
|
|
- $this->delete('be_users', 'db_mountpoints', $rootUid, $hard);
|
|
|
+ $adminBeUserUid = $this->findAdminBeUserUid($rootUid);
|
|
|
+ if ($adminBeUserUid !== null) {
|
|
|
+ $this->delete('be_users', 'uid', $adminBeUserUid, $hard);
|
|
|
+ }
|
|
|
+
|
|
|
+ $editorsGroupUid = $this->findEditorsBeGroupUid($rootUid);
|
|
|
+ if ($editorsGroupUid !== null) {
|
|
|
+ $this->delete('be_groups', 'uid', $editorsGroupUid, $hard);
|
|
|
+ }
|
|
|
|
|
|
// Look up for the config.yaml file of the website
|
|
|
$configMainDir = $_ENV['TYPO3_PATH_APP'] . '/config/sites';
|
|
|
@@ -948,6 +956,26 @@ class SiteController extends ActionController
|
|
|
->where($queryBuilder->expr()->eq('db_mountpoints', $rootUid))
|
|
|
->execute();
|
|
|
|
|
|
+ $editorsGroupUid = $this->findEditorsBeGroupUid($rootUid, false);
|
|
|
+ if ($editorsGroupUid !== null) {
|
|
|
+ $queryBuilder = $this->connectionPool->getQueryBuilderForTable('be_groups');
|
|
|
+ $queryBuilder
|
|
|
+ ->update('be_groups')
|
|
|
+ ->set('deleted', 0)
|
|
|
+ ->where($queryBuilder->expr()->eq('uid', $editorsGroupUid))
|
|
|
+ ->execute();
|
|
|
+ }
|
|
|
+
|
|
|
+ $adminBeUserUid = $this->findAdminBeUserUid($rootUid, false);
|
|
|
+ if ($adminBeUserUid !== null) {
|
|
|
+ $queryBuilder = $this->connectionPool->getQueryBuilderForTable('be_users');
|
|
|
+ $queryBuilder
|
|
|
+ ->update('be_users')
|
|
|
+ ->set('deleted', 0)
|
|
|
+ ->where($queryBuilder->expr()->eq('uid', $adminBeUserUid))
|
|
|
+ ->execute();
|
|
|
+ }
|
|
|
+
|
|
|
// Look up for the config.yaml file of the website
|
|
|
$configMainDir = $_ENV['TYPO3_PATH_APP'] . '/config/sites';
|
|
|
$configYamlFile = "";
|
|
|
@@ -1574,43 +1602,6 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * CLI action for resetting the rights of admin and editors of every website
|
|
|
- * on all of the existing pages, including deleted ones
|
|
|
- *
|
|
|
- * @param bool $createIfMissing
|
|
|
- * @throws NoSuchRecordException
|
|
|
- * @throws NoSuchWebsiteException
|
|
|
- * @throws \Throwable
|
|
|
- */
|
|
|
- public function resetAllBeUserPermsAction(bool $createIfMissing = false) {
|
|
|
- $this->connectionPool->getConnectionByName('Default')->beginTransaction();
|
|
|
- try {
|
|
|
- $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
- $sites = $queryBuilder
|
|
|
- ->select('tx_opentalent_structure_id')
|
|
|
- ->from('pages')
|
|
|
- ->where('is_siteroot=1')
|
|
|
- ->andWhere($queryBuilder->expr()->gt('tx_opentalent_structure_id', 0))
|
|
|
- ->execute()
|
|
|
- ->fetchAll();
|
|
|
-
|
|
|
- foreach ($sites as $site) {
|
|
|
- $this->setBeUserPerms($site['tx_opentalent_structure_id'], $createIfMissing);
|
|
|
- }
|
|
|
-
|
|
|
- $commitSuccess = $this->connectionPool->getConnectionByName('Default')->commit();
|
|
|
- if (!$commitSuccess) {
|
|
|
- throw new \RuntimeException('Something went wrong while committing the result');
|
|
|
- }
|
|
|
- }
|
|
|
- catch (\Throwable $e) {
|
|
|
- // rollback
|
|
|
- $this->connectionPool->getConnectionByName('Default')->rollback();
|
|
|
- throw $e;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Retrieve the Organization object from the repository and then,
|
|
|
* from the Opentalent API
|
|
|
@@ -2242,22 +2233,25 @@ class SiteController extends ActionController
|
|
|
* for this website
|
|
|
*
|
|
|
* @param int $rootUid
|
|
|
+ * @param bool $withRestrictions
|
|
|
* @return int
|
|
|
* @throws NoSuchRecordException
|
|
|
*/
|
|
|
- protected function findEditorsBeGroupUid(int $rootUid): int {
|
|
|
+ protected function findEditorsBeGroupUid(int $rootUid, bool $withRestrictions=true): int {
|
|
|
$editorsGroups = [
|
|
|
$this->getBaseBeGroupUid(self::BEGROUP_EDITOR_STANDARD),
|
|
|
$this->getBaseBeGroupUid(self::BEGROUP_EDITOR_PREMIUM)
|
|
|
];
|
|
|
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('be_groups');
|
|
|
- $queryBuilder->getRestrictions()->removeAll();
|
|
|
+ if (!$withRestrictions) {
|
|
|
+ $queryBuilder->getRestrictions()->removeAll();
|
|
|
+ }
|
|
|
$beGroups = $queryBuilder
|
|
|
->select('uid', 'subgroup')
|
|
|
->from('be_groups')
|
|
|
->where('FIND_IN_SET(' . $rootUid . ', db_mountpoints) > 0')
|
|
|
- ->andWhere($queryBuilder->expr()->eq('deleted', 0))
|
|
|
+// ->andWhere($queryBuilder->expr()->eq('deleted', 0))
|
|
|
->execute()
|
|
|
->fetchAll();
|
|
|
|
|
|
@@ -2285,7 +2279,7 @@ class SiteController extends ActionController
|
|
|
* @return int
|
|
|
* @throws NoSuchRecordException
|
|
|
*/
|
|
|
- protected function findAdminBeUserUid(int $rootUid): int {
|
|
|
+ protected function findAdminBeUserUid(int $rootUid, bool $withRestrictions=true): int {
|
|
|
$adminGroups = [
|
|
|
$this->getBaseBeGroupUid(self::BEGROUP_ADMIN_STANDARD),
|
|
|
$this->getBaseBeGroupUid(self::BEGROUP_ADMIN_PREMIUM)
|
|
|
@@ -2294,12 +2288,14 @@ class SiteController extends ActionController
|
|
|
$editorsGroupUid = $this->findEditorsBeGroupUid($rootUid);
|
|
|
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('be_users');
|
|
|
- $queryBuilder->getRestrictions()->removeAll();
|
|
|
+ if (!$withRestrictions) {
|
|
|
+ $queryBuilder->getRestrictions()->removeAll();
|
|
|
+ }
|
|
|
$beUsers = $queryBuilder
|
|
|
->select('uid', 'usergroup')
|
|
|
->from('be_users')
|
|
|
->where('FIND_IN_SET(' . $rootUid . ', db_mountpoints) > 0')
|
|
|
- ->andWhere($queryBuilder->expr()->eq('deleted', 0))
|
|
|
+// ->andWhere($queryBuilder->expr()->eq('deleted', 0))
|
|
|
->execute()
|
|
|
->fetchAll();
|
|
|
|