add optional download attachment url property to ics
authorCornelius Weiß <c.weiss@metaways.de>
Tue, 4 Jul 2017 16:20:15 +0000 (18:20 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Tue, 4 Jul 2017 22:09:16 +0000 (00:09 +0200)
* as workaround for broken clients
* improve sync force

Change-Id: I4c4c3ee4b8ecf92d74a6eca845360a4a9d57dd6d
Reviewed-on: http://gerrit.tine20.com/customers/5014
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
tests/tine20/Addressbook/Backend/SqlTest.php
tests/tine20/Calendar/Backend/SqlTest.php
tine20/Calendar/Backend/Sql.php
tine20/Calendar/Convert/Event/VCalendar/Abstract.php
tine20/Tinebase/Backend/Sql/Abstract.php
tine20/Tinebase/Frontend/Cli.php

index 8489813..56d090f 100644 (file)
@@ -376,6 +376,19 @@ class Addressbook_Backend_SqlTest extends PHPUnit_Framework_TestCase
         ));
         return $contact;
     }
+
+    /**
+     * testIncreaseSeqForContainerId
+     */
+    public function testIncreaseSeqsForContainerId()
+    {
+        $contact = $this->testCreateContact();
+        $this->_backend->increaseSeqsForContainerId($contact->container_id);
+
+        $updatedConcact = $this->_backend->get($contact->getId());
+
+        $this->assertEquals($contact->seq + 1, $updatedConcact->seq);
+    }
 }        
 
 if (PHPUnit_MAIN_METHOD == 'Addressbook_Backend_SqlTest::main') {
index d02bec9..8ca4318 100644 (file)
@@ -301,4 +301,17 @@ class Calendar_Backend_SqlTest extends Calendar_TestCase
         $this->_backend->get($event1->getId());
         $this->assertEquals(0, $event1->is_deleted);
     }
+
+    /**
+     * testIncreaseSeqForContainerId
+     */
+    public function testIncreaseSeqsForContainerId()
+    {
+        $event = $this->testCreateEvent();
+        $this->_backend->increaseSeqsForContainerId($event->container_id);
+
+        $updatedEvent = $this->_backend->get($event->getId());
+
+        $this->assertEquals($event->seq + 1, $updatedEvent->seq);
+    }
 }
index a288211..e2eab9c 100644 (file)
@@ -974,6 +974,27 @@ class Calendar_Backend_Sql extends Tinebase_Backend_Sql_Abstract
     }
 
     /**
+     * increases seq by one for all records for given container
+     *
+     * @param string $containerId
+     * @return void
+     */
+    public function increaseSeqsForContainerId($containerId)
+    {
+        $stmt = $this->_db->query('SELECT ev.id FROM tine20_cal_events AS ev WHERE ev.is_deleted = 0 AND ' .
+            'ev.recurid IS NULL AND (ev.container_id = ' . $this->_db->quote($containerId) . ' OR ev.id IN (
+            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");
+    }
+
+    /**
      * returns the seq of one event
      *
      * @param string $eventId
index 5b9b699..d225275 100644 (file)
@@ -326,10 +326,12 @@ class Calendar_Convert_Event_VCalendar_Abstract extends Tinebase_Convert_VCalend
                     'SIZE'       => $attachment->size,
                     'FILENAME'   => $filename
                 ), 'TEXT');
-                
+
                 $vevent->add($attach);
             }
-            
+            if (isset($this->_options['addAttachmentsURL']) && $this->_options['addAttachmentsURL']) {
+                $vevent->add($vcalendar->createProperty('URL', $baseUrl));
+            }
         }
         
         $vcalendar->add($vevent);
index c129a74..d296279 100644 (file)
@@ -1708,7 +1708,21 @@ abstract class Tinebase_Backend_Sql_Abstract extends Tinebase_Backend_Abstract i
         }
         return $result;
     }
-    
+
+    /**
+     * increases seq by one for all records for given container
+     *
+     * @param string $containerId
+     * @return void
+     */
+    public function increaseSeqsForContainerId($containerId)
+    {
+        $seq = $this->_db->quoteIdentifier('seq');
+        $where = $this->_db->quoteInto($this->_db->quoteIdentifier('container_id') . ' = ?', $containerId);
+
+        $this->_db->query("UPDATE {$this->_tablePrefix}{$this->_tableName} SET $seq = $seq +1 WHERE $where");
+    }
+
     /**
      * save value in in-class cache
      * 
index 1d52293..a7f3182 100644 (file)
@@ -135,6 +135,10 @@ class Tinebase_Frontend_Cli extends Tinebase_Frontend_Cli_Abstract
             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') . ')';