allow sync force via userID
authorCornelius Weiß <c.weiss@metaways.de>
Thu, 6 Jul 2017 11:52:10 +0000 (13:52 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Thu, 6 Jul 2017 12:13:43 +0000 (14:13 +0200)
Change-Id: I0656b02cd19e698f714c6a86316fa895823cff0f
Reviewed-on: http://gerrit.tine20.com/customers/5038
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Calendar/Backend/Sql.php
tine20/Tinebase/Frontend/Cli.php

index e2eab9c..5a7c093 100644 (file)
@@ -986,11 +986,9 @@ class Calendar_Backend_Sql extends Tinebase_Backend_Sql_Abstract
             SELECT cal_event_id FROM tine20_cal_attendee WHERE displaycontainer_id = ' . $this->_db->quote($containerId) . ')) GROUP BY ev.id');
 
         $result = $stmt->fetchAll();
-        print_r($result);
 
         $seq = $this->_db->quoteIdentifier('seq');
         $where = $this->_db->quoteInto($this->_db->quoteIdentifier('id') . ' IN (?)', $result);
-        echo $where;
         $this->_db->query("UPDATE {$this->_tablePrefix}{$this->_tableName} SET $seq = $seq +1 WHERE $where");
     }
 
index 3101496..46d01dc 100644 (file)
@@ -120,6 +120,14 @@ class Tinebase_Frontend_Cli extends Tinebase_Frontend_Cli_Abstract
     public function forceSyncTokenResync($_opts)
     {
         $args = $this->_parseArgs($_opts, array());
+        $container = Tinebase_Container::getInstance();
+
+        if (isset($args['userIds'])) {
+            $args['userIds'] = !is_array($args['userIds']) ? array($args['userIds']) : $args['userIds'];
+            $args['containerIds'] = $container->search(new Tinebase_Model_ContainerFilter(array(
+                array('field' => 'owner_id', 'operator' => 'in', 'value' => $args['userIds'])
+            )))->getId();
+        }
 
         if (isset($args['containerIds'])) {
             $resultStr = '';
@@ -130,18 +138,20 @@ class Tinebase_Frontend_Cli extends Tinebase_Frontend_Cli_Abstract
 
             $db = Tinebase_Core::getDb();
 
-            $container = Tinebase_Container::getInstance();
+
             $contentBackend = $container->getContentBackend();
             foreach($args['containerIds'] as $id) {
                 $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction($db);
 
                 $containerData = $container->get($id);
                 $recordsBackend = Tinebase_Core::getApplicationInstance($containerData->model)->getBackend();
-                $recordsBackend->increaseSeqsForContainerId($id);
-
-                $container->increaseContentSequence($id);
-                $resultStr .= ($resultStr!==''?', ':'') . $id . '(' . $contentBackend->deleteByProperty($id, 'container_id') . ')';
+                if (method_exists($recordsBackend, 'increaseSeqsForContainerId')) {
+                    $recordsBackend->increaseSeqsForContainerId($id);
 
+                    $container->increaseContentSequence($id);
+                    $resultStr .= ($resultStr !== '' ? ', ' : '') . $id . '(' . $contentBackend->deleteByProperty($id,
+                            'container_id') . ')';
+                }
                 Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
             }