TYPO3 CMS  TYPO3_6-2
DataHandlerHook.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
38  public function processCmdmap_postProcess($command, $table, $id, $value, \TYPO3\CMS\Core\DataHandling\DataHandler $tcemain) {
39  if ($command === 'delete') {
40  if ($table === \TYPO3\CMS\Workspaces\Service\StagesService::TABLE_STAGE) {
41  $this->resetStageOfElements($id);
42  } elseif ($table === \TYPO3\CMS\Workspaces\Service\WorkspaceService::TABLE_WORKSPACE) {
43  $this->flushWorkspaceElements($id);
44  }
45  }
46  }
47 
55  public function processCmdmap_afterFinish(\TYPO3\CMS\Core\DataHandling\DataHandler $tcemainObj) {
56  $this->flushWorkspaceCacheEntriesByWorkspaceId($tcemainObj->BE_USER->workspace);
57  }
58 
67  protected function resetStageOfElements($stageId) {
68  $fields = array('t3ver_stage' => \TYPO3\CMS\Workspaces\Service\StagesService::STAGE_EDIT_ID);
69  foreach ($this->getTcaTables() as $tcaTable) {
71  $where = 't3ver_stage = ' . (int)$stageId;
72  $where .= ' AND t3ver_wsid > 0 AND pid=-1';
73  $where .= BackendUtility::deleteClause($tcaTable);
74  $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tcaTable, $where, $fields);
75  }
76  }
77  }
78 
85  protected function flushWorkspaceElements($workspaceId) {
86  $command = array();
87  foreach ($this->getTcaTables() as $tcaTable) {
89  $where = '1=1';
90  $where .= BackendUtility::getWorkspaceWhereClause($tcaTable, $workspaceId);
91  $where .= BackendUtility::deleteClause($tcaTable);
92  $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $tcaTable, $where, '', '', '', 'uid');
93  if (is_array($records)) {
94  foreach ($records as $recordId => $_) {
95  $command[$tcaTable][$recordId]['version']['action'] = 'flush';
96  }
97  }
98  }
99  }
100  if (count($command)) {
101  $tceMain = $this->getTceMain();
102  $tceMain->start(array(), $command);
103  $tceMain->process_cmdmap();
104  }
105  }
106 
112  protected function getTcaTables() {
113  return array_keys($GLOBALS['TCA']);
114  }
115 
119  protected function getTceMain() {
120  $tceMain = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
121  $tceMain->stripslashes_values = 0;
122  return $tceMain;
123  }
124 
131  protected function flushWorkspaceCacheEntriesByWorkspaceId($workspaceId) {
132  $workspacesCache = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('workspaces_cache');
133  $workspacesCache->flushByTag($workspaceId);
134  $workspacesCache->flushByTag(\TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES);
135  }
136 
137 }
processCmdmap_afterFinish(\TYPO3\CMS\Core\DataHandling\DataHandler $tcemainObj)
static getWorkspaceWhereClause($table, $workspaceId=NULL)
processCmdmap_postProcess($command, $table, $id, $value, \TYPO3\CMS\Core\DataHandling\DataHandler $tcemain)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static deleteClause($table, $tableAlias='')