puts synced users into default group if group backend is disabled
authorPhilipp Schüle <p.schuele@metaways.de>
Fri, 6 Jun 2014 11:19:30 +0000 (13:19 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 16 Jul 2014 11:00:04 +0000 (13:00 +0200)
Change-Id: I2e32a1876ab9ae5b116e88d607ad704ae5628584
Reviewed-on: http://gerrit.tine20.com/customers/747
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Lars Kneschke <l.kneschke@metaways.de>
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/User.php

index 7253a8c..01727a6 100644 (file)
@@ -449,18 +449,24 @@ class Tinebase_User
         try {
             $group = $groupBackend->getGroupById($user->accountPrimaryGroup);
         } catch (Tinebase_Exception_Record_NotDefined $tern) {
-            try {
-                $group = $groupBackend->getGroupByIdFromSyncBackend($user->accountPrimaryGroup);
-            } catch (Tinebase_Exception_Record_NotDefined $ternd) {
-                throw new Tinebase_Exception('Primary group ' . $user->accountPrimaryGroup . ' not found in sync backend.');
-            }
-            try {
-                $sqlGgroup = $groupBackend->getGroupByName($group->name);
-                throw new Tinebase_Exception('Group already exists but it has a different ID: ' . $group->name);
-                
-            } catch (Tinebase_Exception_Record_NotDefined $tern) {
-                if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Adding group " . $group->name);
-                $group = $groupBackend->addGroupInSqlBackend($group);
+            if ($groupBackend->isDisabledBackend()) {
+                // groups are sql only
+                $group = $groupBackend->getDefaultGroup();
+                $user->accountPrimaryGroup = $group->getId();
+            } else {
+                try {
+                    $group = $groupBackend->getGroupByIdFromSyncBackend($user->accountPrimaryGroup);
+                } catch (Tinebase_Exception_Record_NotDefined $ternd) {
+                    throw new Tinebase_Exception('Primary group ' . $user->accountPrimaryGroup . ' not found in sync backend.');
+                }
+                try {
+                    $sqlGgroup = $groupBackend->getGroupByName($group->name);
+                    throw new Tinebase_Exception('Group already exists but it has a different ID: ' . $group->name);
+                    
+                } catch (Tinebase_Exception_Record_NotDefined $tern) {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Adding group " . $group->name);
+                    $group = $groupBackend->addGroupInSqlBackend($group);
+                }
             }
         }