[BUGFIX] Make class name consistent
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Service / Tcemain.php
index b5a1357..460f6b8 100644 (file)
@@ -3,7 +3,7 @@
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2010 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
+ *  (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -31,7 +31,7 @@
  * @package Workspaces
  * @subpackage Service
  */
-class tx_Workspaces_Service_Tcemain {
+class Tx_Workspaces_Service_Tcemain {
 
        /**
         * In case a sys_workspace_stage record is deleted we do a hard reset
@@ -49,13 +49,26 @@ class tx_Workspaces_Service_Tcemain {
                if ($command === 'delete') {
                        if ($table === Tx_Workspaces_Service_Stages::TABLE_STAGE) {
                                $this->resetStageOfElements($id);
-                       } elseif ($table === tx_Workspaces_Service_Workspaces::TABLE_WORKSPACE) {
+                       } elseif ($table === Tx_Workspaces_Service_Workspaces::TABLE_WORKSPACE) {
                                $this->flushWorkspaceElements($id);
                        }
                }
        }
 
        /**
+        * hook that is called AFTER all commands of the commandmap was 
+        * executed
+        *
+        * @param t3lib_TCEmain $tcemainObj reference to the main tcemain object
+        * @return      void
+        */
+       public function processCmdmap_afterFinish(t3lib_TCEmain $tcemainObj) {
+               if (TYPO3_UseCachingFramework) {
+                       $this->flushWorkspaceCacheEntriesByWorkspaceId($tcemainObj->BE_USER->workspace);
+               }
+       }
+
+       /**
         * In case a sys_workspace_stage record is deleted we do a hard reset
         * for all existing records in that stage to avoid that any of these end up
         * as orphan records.
@@ -64,16 +77,12 @@ class tx_Workspaces_Service_Tcemain {
         * @return void
         */
        protected function resetStageOfElements($stageId) {
-               $service = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
-                       // @todo: remove the encode/decode functionality
-               $pseudoStageId = $service->encodeStageUid($stageId);
-
                $fields = array('t3ver_stage' => Tx_Workspaces_Service_Stages::STAGE_EDIT_ID);
 
                foreach ($this->getTcaTables() as $tcaTable) {
                        if (t3lib_BEfunc::isTableWorkspaceEnabled($tcaTable)) {
 
-                               $where = 't3ver_stage = ' . intval($pseudoStageId);
+                               $where = 't3ver_stage = ' . intval($stageId);
                                $where .= ' AND t3ver_wsid > 0 AND pid=-1';
                                $where .= t3lib_BEfunc::deleteClause($tcaTable);
 
@@ -133,10 +142,21 @@ class tx_Workspaces_Service_Tcemain {
                return $tceMain;
        }
 
+       /**
+        * Flushes the workspace cache for current workspace and for the virtual "all workspaces" too.
+        * 
+        * @param integer $workspaceId The workspace to be flushed in cache
+        * @return void
+        */
+       protected function flushWorkspaceCacheEntriesByWorkspaceId($workspaceId) {
+               $workspacesCache = $GLOBALS['typo3CacheManager']->getCache('workspaces_cache');
+               $workspacesCache->flushByTag($workspaceId);
+               $workspacesCache->flushByTag(Tx_Workspaces_Service_Workspaces::SELECT_ALL_WORKSPACES);
+       }
 }
 
 
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Tcemain.php']) {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Tcemain.php']);
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Tcemain.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Tcemain.php']);
 }
 ?>
\ No newline at end of file