Browse Source

https://assistance.opentalent.fr/browse/V8-2007

Olivier Massot 4 years ago
parent
commit
816b63228c

+ 15 - 36
ot_admin/Classes/Controller/SiteController.php

@@ -2176,9 +2176,10 @@ class SiteController extends ActionController
             'deleted' => 0,
             'deleted' => 0,
             'lang' => 'fr',
             'lang' => 'fr',
             'usergroup' => $siteGroupUid . ',' . $adminGroupUid,
             'usergroup' => $siteGroupUid . ',' . $adminGroupUid,
-            'userMods' => '',   // inherited from the base AdminGroup
-            'db_mountpoints' => $rootUid,
-            'options' => 2,
+            'userMods' => null,   // inherited from the base AdminGroup
+            'db_mountpoints' => null, // inherited from the editors group
+            'file_mountpoints' => null, // inherited from the editors group
+            'options' => 3,  // allow to inherit both db and file mountpoints from groups
             'tx_opentalent_opentalentId' => $userData['id'],
             'tx_opentalent_opentalentId' => $userData['id'],
             'tx_opentalent_organizationId' => $organizationId,
             'tx_opentalent_organizationId' => $organizationId,
             'tx_opentalent_generationDate' => date('Y/m/d H:i:s')
             'tx_opentalent_generationDate' => date('Y/m/d H:i:s')
@@ -2286,20 +2287,13 @@ class SiteController extends ActionController
         if (!$withRestrictions) {
         if (!$withRestrictions) {
             $queryBuilder->getRestrictions()->removeAll();
             $queryBuilder->getRestrictions()->removeAll();
         }
         }
-        $beGroups = $queryBuilder
-            ->select('uid', 'subgroup')
+        $editorsGroupUid = $queryBuilder
+            ->select('uid')
             ->from('be_groups')
             ->from('be_groups')
             ->where('FIND_IN_SET(' . $rootUid . ', db_mountpoints) > 0')
             ->where('FIND_IN_SET(' . $rootUid . ', db_mountpoints) > 0')
+            ->andWhere('(FIND_IN_SET(' . $editorsGroups[0] . ', subgroup) > 0 OR FIND_IN_SET(' . $editorsGroups[1] . ', subgroup) > 0)')
             ->execute()
             ->execute()
-            ->fetchAll();
-
-        $editorsGroupUid = null;
-        foreach ($beGroups as $beGroup) {
-            // the editor group shall be a subgroup of one of the Editors group, and have this website mounted
-            if (in_array($beGroup['subgroup'], $editorsGroups)) {
-                $editorsGroupUid = $beGroup['uid'];
-            }
-        }
+            ->fetchColumn(0);
 
 
         if ($editorsGroupUid == null) {
         if ($editorsGroupUid == null) {
             throw new NoSuchRecordException("No editors be_group found " .
             throw new NoSuchRecordException("No editors be_group found " .
@@ -2334,35 +2328,20 @@ class SiteController extends ActionController
             if (!$withRestrictions) {
             if (!$withRestrictions) {
                 $queryBuilder->getRestrictions()->removeAll();
                 $queryBuilder->getRestrictions()->removeAll();
             }
             }
-            $beUsers = $queryBuilder
-                ->select('uid', 'usergroup')
+            $adminUid = $queryBuilder
+                ->select('uid')
                 ->from('be_users')
                 ->from('be_users')
-                ->where('FIND_IN_SET(' . $rootUid . ', db_mountpoints) > 0')
+                ->where('FIND_IN_SET(' . $editorsGroupUid . ', usergroup) > 0')
+                ->andWhere('(FIND_IN_SET(' . $adminGroups[0] . ', usergroup) > 0 OR FIND_IN_SET(' . $adminGroups[1] . ', usergroup) > 0)')
                 ->execute()
                 ->execute()
-                ->fetchAll();
-
-            foreach ($beUsers as $beUser) {
-                // the admin shall be both in the website editors group and in the Admin group
-                $isAdmin = false;
-                $isInThisWebsiteGroup = false;
-                foreach (explode(',', $beUser['usergroup']) as $group) {
-                    if (in_array($group, $adminGroups)) {
-                        $isAdmin = true;
-                    }
-                    if ($group == $editorsGroupUid) {
-                        $isInThisWebsiteGroup = true;
-                    }
-                }
+                ->fetchColumn(0);
+            return $adminUid;
 
 
-                if ($isAdmin && $isInThisWebsiteGroup) {
-                    $adminUid = $beUser['uid'];
-                }
-            }
         } catch (NoSuchRecordException $e) {
         } catch (NoSuchRecordException $e) {
             // the editors group does not exist
             // the editors group does not exist
         }
         }
 
 
-        // Try to find if there is a be_user who still is in the v8.7 architecture
+        // [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);
             $organizationId = $this->findOrganizationIdUidFor($rootUid);
 
 

+ 1 - 1
ot_core/Classes/Page/OtPageRepository.php

@@ -228,7 +228,7 @@ class OtPageRepository
         }
         }
 
 
         $mountpoints = $be_user->returnWebmounts();
         $mountpoints = $be_user->returnWebmounts();
-        $mountpoints = array_filter($mountpoints, function($m) { return $m != 0; });
+        $mountpoints = array_filter($mountpoints, function($m) { return is_numeric($m) && (int)$m > 0; });
 
 
         return $mountpoints;
         return $mountpoints;
     }
     }