Imported workspaces system extension from GitHub repository after commit f1cd6371d96f...
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Classes / Service / Tcemain.php
1 <?php
2
3 /***************************************************************
4 * Copyright notice
5 *
6 * (c) 2010 Tolleiv Nietsch (nietsch@aoemedia.de)
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28
29 /**
30 *
31 * @author Tolleiv Nietsch (nietsch@aoemedia.de)
32 *
33 */
34 class tx_Workspaces_Service_Tcemain {
35
36 /**
37 * In case a sys_workspace_stage record is deleted we do a hard reset
38 * for all existing records in that stage to avoid that any of these end up
39 * as orphan records.
40 *
41 * @param string $command
42 * @param string $table
43 * @param string $id
44 * @param string $value
45 * @param object $tcemain
46 * @return void
47 */
48 public function processCmdmap_postProcess($command, $table, $id, $value, $tcemain) {
49
50 if (strcmp($command, 'delete') || strcmp($table, Tx_Workspaces_Service_Stages::TABLE_STAGE)) {
51 return;
52 }
53
54 $service = t3lib_div::makeInstance('Tx_Workspaces_Service_Stages');
55 // @todo: remove the encode/decode functionality
56 $pseudoStageId = $service->encodeStageUid($id);
57
58 $fields = array('t3ver_stage' => Tx_Workspaces_Service_Stages::STAGE_EDIT_ID);
59
60 foreach($GLOBALS['TCA'] as $tcaTable => $cfg) {
61 if ($GLOBALS['TCA'][$tcaTable]['ctrl']['versioningWS']) {
62
63 $where = 't3ver_stage = ' . intval($pseudoStageId);
64 $where .= ' AND t3ver_wsid > 0 AND pid=-1';
65 $where .= t3lib_BEfunc::deleteClause($tcaTable);
66
67 $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tcaTable, $where, $fields);
68 }
69 }
70 }
71
72 }
73
74 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Tcemain.php']) {
75 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/Tcemain.php']);
76 }
77 ?>