Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2004 Christian Jul Jensen <christian(at)jul(dot)net> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00032 class tx_sysworkflows_executor { 00033 var $BE_USER; 00034 00035 function createNewRecord($table,$pid) { 00036 $data[$table]['NEW'] = array(); 00037 $data[$table]['NEW']['pid'] = $pid; 00038 $tce = $this->callTCE($data, array(), true); 00039 if ($tce->substNEWwithIDs['NEW']) { 00040 return $table.':'.$tce->substNEWwithIDs['NEW']; 00041 } 00042 } //createNewRecord 00043 00044 function createNewVersionOfRecord($table,$uid) { 00045 $cmd[$table][$uid]['version']['action'] = 'new'; 00046 $cmd[$table][$uid]['version']['label'] = 'workflow'; 00047 $tce = $this->callTCE(array(), $cmd, true); 00048 return $table.':'.$tce->copyMappingArray[$table][$uid]; 00049 } //createNewVersionOfRecord 00050 00054 function publishNewRecord($table,$uid,$newPid=null,$doNotUnhide=false,$workflowRecord=Array()) { 00055 $dataArr = array(); 00056 $cmdArr = array(); 00057 if (!$doNotUnhide) { 00058 if (is_array($TCA[$table]['ctrl']['enablecolumns']) && $TCA[$table]['ctrl']['enablecolumns']['disabled']) { 00059 $dataArr[$table][$uid][$TCA[$table]['ctrl']['enablecolumns']['disabled']] = 0; 00060 } else { 00061 debug('tried to unhide but table: '.$table.' does not support it ('.__FILE__.','.__LINE__.')'); 00062 } 00063 } 00064 if($newPid) { 00065 $targetPage = t3lib_BEfunc::getRecord('pages', $newPid); 00066 if (is_array($targetPage)) { 00067 $cmdArr[$table][$uid]['move'] = $targetPage['uid']; 00068 } 00069 } 00070 if ($table == "pages" && $workflowRecord['final_set_perms']) { 00071 $dataArr[$table][$uid]['perms_userid'] = $workflowRecord['final_perms_userid']; 00072 $dataArr[$table][$uid]['perms_groupid'] = $workflowRecord['final_perms_groupid']; 00073 $dataArr[$table][$uid]['perms_user'] = $workflowRecord['final_perms_user']; 00074 $dataArr[$table][$uid]['perms_group'] = $workflowRecord['final_perms_group']; 00075 $dataArr[$table][$uid]['perms_everybody'] = $workflowRecord['final_perms_everybody']; 00076 } 00077 $this->callTCE($dataArr,$cmdArr); 00078 } //publishNewRecord 00079 00080 function publishNewVersion($table,$t3ver_oid,$uid) { 00081 $cmdArr = array(); 00082 $cmdArr[$table][$t3ver_oid]['version'] 00083 = array( 00084 'swapWith' => $uid, 00085 'action' => 'swap', 00086 'swapContent' => '1', 00087 ); 00088 $this->callTCE(array(),$cmdArr); 00089 } //publicNewVersion 00090 00091 function callTCE($dataArr,$cmdArr,$return=null) { 00092 //sanity check - since the setting depends on the client. 00093 assert('is_a($this->BE_USER,\'t3lib_beuserauth\')'); 00094 00095 // Perform it (as ADMIN) 00096 $tce = t3lib_div::makeInstance('t3lib_TCEmain'); 00097 $tce->stripslashes_values = 0; 00098 $TCAdefaultOverride = $this->BE_USER->getTSConfigProp('TCAdefaults'); 00099 if (is_array($TCAdefaultOverride)) { 00100 $tce->setDefaultsFromUserTS($TCAdefaultOverride); 00101 } 00102 $tce->start($dataArr, $cmdArr, $this->BE_USER); 00103 $tce->admin = 1; // Set ADMIN permission for this operation. 00104 if(is_array($dataArr)) { 00105 $tce->process_datamap(); 00106 } 00107 if(is_array($cmdArr)) { 00108 $tce->process_cmdmap(); 00109 } 00110 if($return) { 00111 return $tce; 00112 } else { 00113 unset($tce); 00114 } 00115 } //callTCE 00116 00117 } 00118 //load XCLASS? 00119 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sys_workflows/class.tx_sysworkflows_executor.php']) { 00120 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sys_workflows/class.tx_sysworkflows_executor.php']); 00121 } 00122 00123 ?>