Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Tinebase / User.php
index cc597b2..e87e742 100644 (file)
@@ -480,7 +480,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;
@@ -500,6 +501,7 @@ 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);
         }
@@ -552,8 +554,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__
@@ -846,14 +850,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);