|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces) 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 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * Automatic publishing of workspaces. 00027 * 00028 * @author Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces) 00029 * @package Workspaces 00030 * @subpackage Service 00031 */ 00032 class tx_Workspaces_Service_AutoPublish { 00033 /** 00034 * This method is called by the Scheduler task that triggers 00035 * the autopublication process 00036 * It searches for workspaces whose publication date is in the past 00037 * and publishes them 00038 * 00039 * @return void 00040 */ 00041 public function autoPublishWorkspaces() { 00042 global $TYPO3_CONF_VARS; 00043 00044 // Temporarily set admin rights 00045 // FIXME: once workspaces are cleaned up a better solution should be implemented 00046 $currentAdminStatus = $GLOBALS['BE_USER']->user['admin']; 00047 $GLOBALS['BE_USER']->user['admin'] = 1; 00048 00049 // Select all workspaces that needs to be published / unpublished: 00050 $workspaces = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 00051 'uid,swap_modes,publish_time,unpublish_time', 00052 'sys_workspace', 00053 'pid=0 00054 AND 00055 ((publish_time!=0 AND publish_time<=' . intval($GLOBALS['EXEC_TIME']) . ') 00056 OR (publish_time=0 AND unpublish_time!=0 AND unpublish_time<=' . intval($GLOBALS['EXEC_TIME']) . '))'. 00057 t3lib_BEfunc::deleteClause('sys_workspace') 00058 ); 00059 00060 $workspaceService = t3lib_div::makeInstance('tx_Workspaces_Service_Workspaces'); 00061 00062 foreach ($workspaces as $rec) { 00063 00064 // First, clear start/end time so it doesn't get select once again: 00065 $fieldArray = $rec['publish_time'] != 0 ? array('publish_time' => 0) : array('unpublish_time' => 0); 00066 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_workspace', 'uid=' . intval($rec['uid']), $fieldArray); 00067 00068 // Get CMD array: 00069 $cmd = $workspaceService->getCmdArrayForPublishWS($rec['uid'], $rec['swap_modes'] == 1); // $rec['swap_modes']==1 means that auto-publishing will swap versions, not just publish and empty the workspace. 00070 00071 // Execute CMD array: 00072 $tce = t3lib_div::makeInstance('t3lib_TCEmain'); 00073 $tce->stripslashes_values = 0; 00074 $tce->start(array(), $cmd); 00075 $tce->process_cmdmap(); 00076 } 00077 00078 // Restore admin status 00079 $GLOBALS['BE_USER']->user['admin'] = $currentAdminStatus; 00080 } 00081 } 00082 00083 00084 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/AutoPublish.php'])) { 00085 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/AutoPublish.php']); 00086 } 00087 ?>
1.8.0