Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Tinebase / User.php
index 8f3cde7..ac5c60c 100644 (file)
@@ -239,7 +239,7 @@ class Tinebase_User
         }
         
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ 
-            . ' Created user backend of type ' . $backendType);
+            . ' Created user backend of type ' . get_class($result));
         
         return $result;
     }
@@ -485,7 +485,8 @@ class Tinebase_User
                     self::createContactForSyncedUser($currentUser);
                 }
             }
-        
+            
+            Tinebase_Timemachine_ModificationLog::setRecordMetaData($currentUser, 'update');
             $syncedUser = $userBackend->updateUserInSqlBackend($currentUser);
             if (! empty($user->container_id)) {
                 $syncedUser->container_id = $user->container_id;
@@ -505,20 +506,20 @@ class Tinebase_User
             if ($user->visibility !== Tinebase_Model_FullUser::VISIBILITY_HIDDEN) {
                 self::createContactForSyncedUser($user);
             }
+            Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'create');
             $syncedUser = $userBackend->addUserInSqlBackend($user);
             $userBackend->addPluginUser($syncedUser, $user);
         }
         
         self::syncContactData($syncedUser, $options);
         
-        // sync group memberships
         Tinebase_Group::syncMemberships($syncedUser);
-        
+
         return $syncedUser;
     }
-    
+
     /**
-     * import contactdata(phone, address, fax, birthday. photo)
+     * import contact data(phone, address, fax, birthday. photo)
      * 
      * @param Tinebase_Model_FullUser $syncedUser
      * @param array $options
@@ -557,8 +558,10 @@ class Tinebase_User
             if (! $diff->isEmpty() || ($originalContact->jpegphoto == 0 && ! empty($contact->jpegphoto))) {
                 // add modlog info
                 Tinebase_Timemachine_ModificationLog::setRecordMetaData($contact, 'update');
-                Tinebase_Container::getInstance()->increaseContentSequence($contact->container_id);
-
+                if ($contact->container_id !== null) {
+                    Tinebase_Container::getInstance()->increaseContentSequence($contact->container_id);
+                }
+                
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                     . ' Updating contact data for user ' . $syncedUser->accountLoginName);
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
@@ -572,6 +575,7 @@ class Tinebase_User
         } catch (Addressbook_Exception_NotFound $aenf) {
             self::createContactForSyncedUser($syncedUser);
             $syncedUser = Tinebase_User::getInstance()->updateUserInSqlBackend($syncedUser);
+
         } catch (Tinebase_Exception_NotFound $tenf) {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__
                 . ' Contact information seems to be missing in sync backend');
@@ -732,10 +736,8 @@ class Tinebase_User
             self::_syncDeletedUsers($users);
         }
         
-        // @todo this should be improved: only the cache of synced users + group memberships should be cleaned
-        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ 
-            . ' Finished synchronizing users. Clearing cache after user sync ...');
-        Tinebase_Core::getCache()->clean();
+        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
+            . ' Finished synchronizing users.');
     }
 
     /**
@@ -894,14 +896,19 @@ class Tinebase_User
         // update or create user in local sql backend
         try {
             $userBackend->getUserByProperty('accountLoginName', $adminLoginName);
+            Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'update');
             $user = $userBackend->updateUserInSqlBackend($user);
         } catch (Tinebase_Exception_NotFound $ten) {
             // call addUser here to make sure, sql user plugins (email, ...) are triggered
+            Tinebase_Timemachine_ModificationLog::setRecordMetaData($user, 'create');
             $user = $userBackend->addUser($user);
         }
         
         // set the password for the account
-        Tinebase_User::getInstance()->setPassword($user, $adminPassword);
+        // empty password triggers password change dialogue during first login
+        if (!empty($adminPassword)) {
+            Tinebase_User::getInstance()->setPassword($user, $adminPassword);
+        }
 
         // add the admin account to all groups
         Tinebase_Group::getInstance()->addGroupMember($adminGroup, $user);