Merge branch '2014.11-develop' into 2015.11
[tine20] / tine20 / Calendar / Backend / Sql.php
index a9d95dd..1acb89b 100644 (file)
@@ -912,4 +912,30 @@ class Calendar_Backend_Sql extends Tinebase_Backend_Sql_Abstract
             }
         }
     }
+
+    /**
+     * @param Tinebase_Model_Container $sourceContainer
+     * @param Tinebase_Model_Container $destinationContainer
+     */
+    public function moveEventsToContainer(Tinebase_Model_Container $sourceContainer, Tinebase_Model_Container $destinationContainer)
+    {
+        $this->_db->update($this->_tablePrefix . $this->_tableName, array('container_id' => $destinationContainer->getId()),
+            $this->_db->quoteInto($this->_db->quoteIdentifier('container_id') . ' = ?', $sourceContainer->getId()));
+
+        $attendeeBackend = new Calendar_Backend_Sql_Attendee();
+        $attendeeBackend->moveEventsToContainer($sourceContainer, $destinationContainer);
+    }
+
+    /**
+     * @param string $oldContactId
+     * @param string $newContactId
+     */
+    public function replaceContactId($oldContactId, $newContactId)
+    {
+        $this->_db->update($this->_tablePrefix . $this->_tableName, array('organizer' => $newContactId),
+            $this->_db->quoteInto($this->_db->quoteIdentifier('organizer') . ' = ?', $oldContactId));
+
+        $attendeeBackend = new Calendar_Backend_Sql_Attendee();
+        $attendeeBackend->replaceContactId($oldContactId, $newContactId);
+    }
 }