Merge branch '2013.10' into 2014.11
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 3 Dec 2015 12:39:29 +0000 (13:39 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 3 Dec 2015 12:39:29 +0000 (13:39 +0100)
1  2 
tine20/Tinebase/User.php
tine20/Tinebase/js/widgets/dialog/EditDialog.js

diff --combined tine20/Tinebase/User.php
@@@ -239,7 -239,7 +239,7 @@@ class Tinebase_Use
          }
          
          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;
      }
                      self::createContactForSyncedUser($currentUser);
                  }
              }
 -        
 +            
 +            Tinebase_Timemachine_ModificationLog::setRecordMetaData($currentUser, 'update');
              $syncedUser = $userBackend->updateUserInSqlBackend($currentUser);
              if (! empty($user->container_id)) {
                  $syncedUser->container_id = $user->container_id;
              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
              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__
          } 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');
              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.');
      }
  
      /**
          $deletedInSyncBackend = array_diff($userIdsInSqlBackend, $usersInSyncBackend->getArrayOfIds());
  
          if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
-             . ' About to delete ' . count($deletedInSyncBackend) . ' users in SQL backend...');
+             . ' About to delete / expire ' . count($deletedInSyncBackend) . ' users in SQL backend...');
  
          foreach ($deletedInSyncBackend as $userToDelete) {
              $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $userToDelete, 'Tinebase_Model_FullUser');
  
+             if (in_array($user->accountLoginName, self::getSystemUsernames())) {
+                 return;
+             }
              // at first, we expire the user
              $now = Tinebase_DateTime::now();
              if (! $user->accountExpires) {
                  if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
-                     . ' Set expiry date to ' . $now);
+                     . ' Set expiry date of ' . $user->accountLoginName . ' to ' . $now);
                  $user->accountExpires = $now;
                  Tinebase_User::getInstance()->updateUserInSqlBackend($user);
              } else {
      }
  
      /**
+      * returns login_names of system users
+      *
+      * @return array
+      */
+     public static function getSystemUsernames()
+     {
+         return array('cronuser', 'calendarscheduling');
+     }
+     /**
       * get all user passwords from ldap
       * - set pw for user (in sql and sql plugins)
       * - do not encrypt the pw again as it is encrypted in LDAP
          // 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);
@@@ -189,7 -189,7 +189,7 @@@ Tine.widgets.dialog.EditDialog = Ext.ex
      deferredRender: false,
      buttonAlign: null,
      bufferResize: 500,
 -    
 +
      /**
       * relations panel
       * 
      },
  
      /**
 +     * Get available model for given application
 +     *
 +     *  @param {Mixed} application
 +     *  @param {Boolean} customFieldModel
 +     */
 +    getApplicationModels: function (application, customFieldModel) {
 +        var models      = [],
 +            useModel,
 +            appName     = Ext.isString(application) ? application : application.get('name'),
 +            app         = Tine.Tinebase.appMgr.get(appName),
 +            trans       = app && app.i18n ? app.i18n : Tine.Tinebase.translation,
 +            appModels   = Tine[appName].Model;
 +
 +        if (appModels) {
 +            for (var model in appModels) {
 +                if (appModels.hasOwnProperty(model) && typeof appModels[model].getMeta === 'function') {
 +                    if (customFieldModel && appModels[model].getField('customfields')) {
 +                        useModel = appModels[model].getMeta('appName') + '_Model_' + appModels[model].getMeta('modelName');
 +
 +                        Tine.log.info('Found model with customfields property: ' + useModel);
 +                        models.push([useModel, trans.n_(appModels[model].getMeta('recordName'), appModels[model].getMeta('recordsName'), 1)]);
 +                    } else if (! customFieldModel) {
 +                        useModel = 'Tine.' + appModels[model].getMeta('appName') + '.Model.' + appModels[model].getMeta('modelName');
 +
 +                        Tine.log.info('Found model: ' + useModel);
 +                        models.push([useModel, trans.n_(appModels[model].getMeta('recordName'), appModels[model].getMeta('recordsName'), 1)]);
 +                    }
 +                }
 +            }
 +        }
 +        return models;
 +    },
 +
 +    /**
       * init actions
       */
      initActions: function() {
      },
      
      /**
+      * vaidates on multiple edit
+      * 
+      * @return {Boolean}
+      */
+     isMultipleValid: function() {
+         return true;
+     },
+     
+     /**
       * @private
       */
      onCancel: function(){