Fixed clearing cache
authormario_matzulla <mario_matzulla@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 1 Mar 2016 10:48:24 +0000 (10:48 +0000)
committermario_matzulla <mario_matzulla@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 1 Mar 2016 10:48:24 +0000 (10:48 +0000)
calling cleanup method of icalendar service

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/caldav/trunk@90664 735d13b6-9817-0410-8766-e36946ffe9aa

Classes/Backend/FakeBeUser.php [new file with mode: 0644]
lib/Sabre/CalDAV/Backend/TYPO3.php

diff --git a/Classes/Backend/FakeBeUser.php b/Classes/Backend/FakeBeUser.php
new file mode 100644 (file)
index 0000000..890695a
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+namespace TYPO3\CMS\Caldav\Backend;
+
+class FakeBeUser {
+       
+       private $pid;
+       
+       public function __construct($pid){
+               $this->pid = $pid;      
+       }
+       
+       public function getTSConfigVal($value) {
+               return $this->pid;
+       }
+       
+       public function writeLog() {
+               return $this->pid;
+       }
+}
\ No newline at end of file
index 2fdfb80..e4daac7 100755 (executable)
@@ -440,11 +440,12 @@ class Sabre_CalDAV_Backend_TYPO3 extends Sabre_CalDAV_Backend_Abstract {
         * @return void
         */
        public function deleteCalendarObject($calendarId, $objectUri) {
-               $stmt = $this->pdo->prepare ( 'SELECT * FROM tx_cal_event WHERE calendar_id = ?' );
+               $stmt = $this->pdo->prepare ( 'SELECT * FROM tx_cal_event WHERE calendar_id = ? AND icsUid = ? AND deleted = 0' );
                $stmt->execute ( array (
-                               $calendarId 
+                               $calendarId,
+                               $objectUri
                ) );
-               $calendarRow = $stmt->fetch ();
+               $eventRow = $stmt->fetch ();
                
                $stmt = $this->pdo->prepare ( 'DELETE FROM tx_cal_event WHERE calendar_id = ? AND icsUid = ? AND deleted = 0' );
                $stmt->execute ( array (
@@ -455,7 +456,10 @@ class Sabre_CalDAV_Backend_TYPO3 extends Sabre_CalDAV_Backend_Abstract {
                $stmt->execute ( array (
                                $calendarId 
                ) );
-               $this->clearCache ( $calendarRow ['pid'] );
+               
+               $service = new \TYPO3\CMS\Cal\Service\ICalendarService ();
+               $service->clearAllImagesAndAttachments($eventRow['uid']);
+               $this->clearCache ( $eventRow ['pid'] );
        }
        private function updateCalEvent($calendarId, $objectUri, $calendarData) {
                $stmt = $this->pdo->prepare ( 'SELECT * FROM tx_cal_calendar WHERE uid = ?' );
@@ -503,14 +507,16 @@ class Sabre_CalDAV_Backend_TYPO3 extends Sabre_CalDAV_Backend_Abstract {
        private function clearCache($pid) {
                $pageTSConf = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig ( $pid );
                $pageIDForPlugin = $pid;
-               
+                       
                if ($pageTSConf ['TCEMAIN.'] ['clearCacheCmd']) {
                        $pageIDForPlugin = $pageTSConf ['TCEMAIN.'] ['clearCacheCmd'];
                }
-               
-               $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance ( 'TYPO3\\CMS\\Core\\DataHandling\\DataHandler' );
-               $tce->stripslashes_values = FALSE;
-               $tce->start(array(), array());
-               //$tce->clear_cacheCmd ( $pageIDForPlugin ); // ID of the page for which to clear the cache
+                       
+               /** @var $tcemain \TYPO3\CMS\Core\DataHandling\DataHandler */
+               $tcemain = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
+               $tcemain->stripslashes_values = 0;
+               $tcemain->start(array(), array(), new \TYPO3\CMS\Caldav\Backend\FakeBeUser($pid));
+               $tcemain->clear_cacheCmd ( $pageIDForPlugin ); // ID of the page for which to clear the cache
        }
+       
 }
\ No newline at end of file