Merge branch '2016.11' into 2016.11-develop
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 9 May 2017 18:09:25 +0000 (20:09 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 9 May 2017 18:09:25 +0000 (20:09 +0200)
Change-Id: I94b7119b02ffc31fb1c70278c9bc7293df4d5bb2

1  2 
tine20/Addressbook/Setup/Update/Release9.php
tine20/Felamimail/Config.php
tine20/Felamimail/Controller/Account.php
tine20/Felamimail/Controller/Folder.php
tine20/Felamimail/Controller/Message/Send.php
tine20/Inventory/Model/InventoryItem.php
tine20/Tinebase/Config.php
tine20/Tinebase/User.php

Simple merge
@@@ -96,14 -82,7 +96,14 @@@ class Tinebase_Config extends Tinebase_
       * @var string
       */
      const USERBACKEND = 'Tinebase_User_BackendConfiguration';
 -    
 +
 +    /**
 +     * sync options for user backend
 +     *
 +     * @var string
 +     */
 +    const SYNCOPTIONS = 'syncOptions';
-     
++
      /**
       * user backend type config
       * 
      const SYNC_USER_CONTACT_DATA = 'syncUserContactData';
  
      /**
-     
 +     * configure if user contact photo should be synced from sync backend, default yes
 +     *
 +     * @var string
 +     */
 +    const SYNC_USER_CONTACT_PHOTO = 'syncUserContactPhoto';
 +
 +    /**
 +     * configure if deleted users from sync back should be deleted in sql backend, default yes
 +     *
 +     * @var string
 +     */
 +    const SYNC_DELETED_USER = 'syncDeletedUser';
++
++    /**
+      * configure when user should be removed from sql after it is removed from sync backend
+      *
+      * @var boolean
+      */
+     const SYNC_USER_DELETE_AFTER = 'syncUserDeleteAfter';
      /**
       * Config key for session ip validation -> if this is set to FALSE no Zend_Session_Validator_IpAddress is registered
       * 
              'setByAdminModule'      => false,
              'setBySetupModule'      => true,
          ),
 -        self::SYNC_USER_DELETE_AFTER => array(
 -            //_('Sync user: delete after X months)
 -            'label'                 => 'Sync user: delete after X months',
 -            //_('Removed users should be deleted after X months')
 -            'description'           => 'Removed users should be deleted after X months',
 -            'type'                  => 'integer',
 -            'clientRegistryInclude' => FALSE,
 -            'setByAdminModule'      => FALSE,
 -            'setBySetupModule'      => FALSE,
 -            'default'               => 12,
 -        ),
+         self::SYNC_USER_CONTACT_DATA => array(
+             //_('Sync contact data from sync backend')
+             'label'                 => 'Sync contact data from sync backend',
+             //_('Sync user contact data from sync backend')
+             'description'           => 'Sync user contact data from sync backend',
+             'type'                  => 'bool',
+             'clientRegistryInclude' => FALSE,
+             'setByAdminModule'      => FALSE,
+             'setBySetupModule'      => FALSE,
+             'default'               => TRUE
+         ),
          self::SESSIONIPVALIDATION => array(
                                     //_('IP Session Validator')
              'label'                 => 'IP Session Validator',
@@@ -800,13 -825,11 +800,13 @@@ class Tinebase_User implements Tinebase
                  if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                      . ' User already expired ' . print_r($user->toArray(), true));
  
-                 // TODO make time span configurable?
-                 if ($user->accountExpires->isEarlier($now->subYear(1))) {
+                 $deleteAfterMonths = Tinebase_Config::getInstance()->get(Tinebase_Config::SYNC_USER_DELETE_AFTER);
+                 if ($user->accountExpires->isEarlier($now->subMonth($deleteAfterMonths))) {
                      // if he or she is already expired longer than configured expiry, we remove them!
 -                    Tinebase_User::getInstance()->deleteUserInSqlBackend($userToDelete);
 +                    // this will trigger the plugin Addressbook which will make a soft delete and especially runs the addressbook sync backends if any configured
 +                    Tinebase_User::getInstance()->deleteUser($userToDelete);
  
 +                    // now we make the addressbook hard delete, which is ok, because we went through the addressbook_controller_contact::delete already
                      if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true && ! empty($user->contact_id)) {
                          if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                              . ' Deleting user contact of ' . $user->accountLoginName);