Merge branch '2015.11' into 2015.11-develop
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 18 Jan 2017 16:29:32 +0000 (17:29 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 18 Jan 2017 16:29:32 +0000 (17:29 +0100)
Change-Id: Ib86f46539f5d05106be1042b7adf38766d74ba54

1  2 
tine20/Admin/Frontend/Json.php
tine20/Calendar/Backend/Sql.php
tine20/Filemanager/js/NodeTreePanel.js
tine20/Tinebase/Container.php
tine20/Tinebase/Frontend/Cli.php
tine20/Tinebase/Setup/Update/Release9.php
tine20/Tinebase/js/widgets/container/ContainerSelect.js

Simple merge
Simple merge
Simple merge
@@@ -33,78 -33,47 +33,119 @@@ class Tinebase_Frontend_Cli extends Tin
      protected $_applicationsToWorkOn = array();
  
      /**
 +    * @param Zend_Console_Getopt $_opts
 +    * @return boolean success
 +    */
 +    public function rebuildPaths($opts)
 +    {
 +        if (! $this->_checkAdminRight()) {
 +            return -1;
 +        }
 +
 +        $applications = Tinebase_Application::getInstance()->getApplications();
 +        foreach($applications as $application) {
 +            try {
 +                $app = Tinebase_Core::getApplicationInstance($application, '', true);
 +            } catch (Tinebase_Exception_NotFound $tenf) {
 +                continue;
 +            }
 +
 +            if (! $app instanceof Tinebase_Controller_Abstract) {
 +                continue;
 +            }
 +
 +            $pathModels = $app->getModelsUsingPaths();
 +            if (!is_array($pathModels)) {
 +                $pathModels = array();
 +            }
 +            foreach($pathModels as $pathModel) {
 +                $controller = Tinebase_Core::getApplicationInstance($pathModel, '', true);
 +
 +                $_filter = $pathModel . 'Filter';
 +                $_filter = new $_filter();
 +
 +                $iterator = new Tinebase_Record_Iterator(array(
 +                    'iteratable' => $this,
 +                    'controller' => $controller,
 +                    'filter' => $_filter,
 +                    'options' => array('getRelations' => true),
 +                    'function' => 'rebuildPathsIteration',
 +                ));
 +                $result = $iterator->iterate($controller);
 +
 +                if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
 +                    if (false === $result) {
 +                        $result['totalcount'] = 0;
 +                    }
 +                    Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Build paths for ' . $result['totalcount'] . ' records of ' . $pathModel);
 +                }
 +            }
 +        }
 +    }
 +
 +    /**
 +     * rebuild paths for multiple records in an iteration
 +     * @see Tinebase_Record_Iterator / self::rebuildPaths()
 +     *
 +     * @param Tinebase_Record_RecordSet $records
 +     * @param Tinebase_Controller_Abstract $controller
 +     */
 +    public function rebuildPathsIteration(Tinebase_Record_RecordSet $records, Tinebase_Controller_Record_Abstract $controller)
 +    {
 +        foreach ($records as $record) {
 +            try {
 +                $controller->buildPath($record, true);
 +            } catch (Exception $e) {
 +                Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' record path building failed: '
 +                    . $e->getMessage() . PHP_EOL
 +                    . $e->getTraceAsString() . PHP_EOL
 +                    . $record->toArray());
 +            }
 +        }
 +    }
 +
 +    /**
+      * forces containers that support sync token to resync via WebDAV sync tokens
+      *
+      * this will cause 2 BadRequest responses to sync token requests
+      * the first one as soon as the client notices that something changed and sends a sync token request
+      * eventually the client receives a false sync token (as we increased content sequence, but we dont have a content history entry)
+      * eventually not (if something really changed in the calendar in the meantime)
+      *
+      * in case the client got a fake sync token, the clients next sync token request (once something really changed) will fail again
+      * after something really changed valid sync tokens will be handed out again
+      *
+      * @param Zend_Console_Getopt $_opts
+      */
+     public function forceSyncTokenResync($_opts)
+     {
+         $args = $this->_parseArgs($_opts, array());
+         if (isset($args['containerIds'])) {
+             $resultStr = '';
+             if (!is_array($args['containerIds'])) {
+                 $args['containerIds'] = array($args['containerIds']);
+             }
+             $db = Tinebase_Core::getDb();
+             $container = Tinebase_Container::getInstance();
+             $contentBackend = $container->getContentBackend();
+             foreach($args['containerIds'] as $id) {
+                 $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction($db);
+                 $container->increaseContentSequence($id);
+                 $resultStr = ($resultStr!==''?', ':'') . $id . '(' . $contentBackend->deleteByProperty($id, 'container_id') . ')';
+                 Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
+             }
+             echo "\nDeleted containers(num content history records): " . $resultStr . "\n";
+         }
+     }
+     /**
       * clean timemachine_modlog for records that have been pruned (not deleted!)
       */
      public function cleanModlog()
@@@ -86,10 -86,11 +86,10 @@@ class Tinebase_Setup_Update_Release9 ex
              ');
  
              $this->_backend->addIndex('container', $declaration);
 -            $this->setTableVersion('relations', '8');
 +            $this->setTableVersion('container', 10);
          }
 -        $this->setTableVersion('container', '10');
  
-         $this->_setContainerOwners();
+         Tinebase_Container::getInstance()->setContainerOwners();
  
          $this->setApplicationVersion('Tinebase', '9.5');
      }
@@@ -154,9 -152,22 +158,20 @@@ Tine.widgets.container.selectionComboBo
              ]};
              
          }
-         
-         //this.title = String.format(i18n._('Recently used {0}:'), this.containersName);
-         
+         // autoconfig app
+         if (! this.app && this.appName) {
+             this.app = Tine.Tinebase.appMgr.get(this.appName);
+         }
+         if (! this.app && this.recordClass) {
+             this.app = Tine.Tinebase.appMgr.get(this.recordClass.getMeta('appName'));
+         }
+         if (this.app && ! this.appName) {
+             this.appName = this.app.appName;
+         }
+         this.recents = {};
 -        //this.title = String.format(_('Recently used {0}:'), this.containersName);
 -        
          Tine.widgets.container.selectionComboBox.superclass.initComponent.call(this);
          
          if (this.defaultContainer) {