[FEATURE] Cleanup-job for outdated preview-links
authorTimo Webler <timo.webler@dkd.de>
Mon, 6 Feb 2012 16:44:46 +0000 (17:44 +0100)
committerTolleiv Nietsch <info@tolleiv.de>
Mon, 13 Feb 2012 21:19:58 +0000 (22:19 +0100)
Workspace preview-links should be deleted once they reach
their endtime timestamp

Change-Id: I91074aee5592b23f1a8e0f73a4cca8353244a2df
Resolves: #32215
Reviewed-on: http://review.typo3.org/8866
Reviewed-by: Timo Webler
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
typo3/sysext/workspaces/Classes/Service/CleanupPreviewLinkTask.php [new file with mode: 0644]
typo3/sysext/workspaces/Resources/Private/Language/locallang_mod.xlf
typo3/sysext/workspaces/ext_autoload.php
typo3/sysext/workspaces/ext_localconf.php

diff --git a/typo3/sysext/workspaces/Classes/Service/CleanupPreviewLinkTask.php b/typo3/sysext/workspaces/Classes/Service/CleanupPreviewLinkTask.php
new file mode 100644 (file)
index 0000000..49f1eb8
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (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
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * This class provides a task to cleanup ol preview links.
+ *
+ * @author Timo Webler <timo.webler@dkd.de>
+ * @package Workspaces
+ * @subpackage Service
+ */
+class Tx_Workspaces_Service_CleanupPreviewLinkTask extends tx_scheduler_Task {
+
+       /**
+        * Cleanup old preview links.
+        * endtime < $GLOBALS['EXEC_TIME']
+        *
+        * @return      boolean
+        */
+       public function execute() {
+               $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                               // table
+                       'sys_preview',
+                               // where
+                       'endtime < ' . intval($GLOBALS['EXEC_TIME'])
+               );
+
+               return TRUE;
+       }
+}
+
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/CleanupPreviewLinkTask.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/workspaces/Classes/Service/CleanupPreviewLinkTask.php']);
+}
+?>
\ No newline at end of file
index 565f905..a4f1425 100644 (file)
                        <trans-unit id="autopublishTask.description" xml:space="preserve">
                                <source>This tasks checks any workspace that has a publication date set in the past and automatically publishes it.</source>
                        </trans-unit>
+                       <trans-unit id="cleanupPreviewLinkTask.name" xml:space="preserve">
+                               <source>Workspaces cleanup preview links</source>
+                       </trans-unit>
+                       <trans-unit id="cleanupPreviewLinkTask.description" xml:space="preserve">
+                               <source>This task delete old preview links</source>
+                       </trans-unit>
                        <trans-unit id="stage_ready_to_publish" xml:space="preserve">
                                <source>Ready to publish</source>
                        </trans-unit>
index 77cabb1..1d61b8e 100644 (file)
@@ -15,6 +15,7 @@ return array(
        'tx_workspaces_reports_statusprovider' => $extensionPath . 'Classes/Reports/StatusProvider.php',
        'tx_workspaces_service_autopublish' => $extensionPath . 'Classes/Service/AutoPublish.php',
        'tx_workspaces_service_autopublishtask' => $extensionPath . 'Classes/Service/AutoPublishTask.php',
+       'tx_workspaces_service_cleanuppreviewlinktask' => $extensionPath . 'Classes/Service/CleanupPreviewLinkTask.php',
        'tx_workspaces_service_befunc' => $extensionPath . 'Classes/Service/Befunc.php',
        'tx_workspaces_service_griddata' => $extensionPath . 'Classes/Service/GridData.php',
        'tx_workspaces_service_stages' => $extensionPath . 'Classes/Service/Stages.php',
index c228af9..3d9b3ad 100644 (file)
@@ -15,6 +15,12 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['Tx_Workspaces_S
        'title'            => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xml:autopublishTask.name',
        'description'      => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xml:autopublishTask.description'
 );
+       // Register the cleanup preview links task
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['Tx_Workspaces_Service_CleanupPreviewLinkTask'] = array(
+       'extension'        => $_EXTKEY,
+       'title'            => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xml:cleanupPreviewLinkTask.name',
+       'description'      => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xml:cleanupPreviewLinkTask.description'
+);
 
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['workspaces'] = 'EXT:workspaces/Classes/Service/Tcemain.php:Tx_Workspaces_Service_Tcemain';
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['viewOnClickClass']['workspaces'] = 'EXT:workspaces/Classes/Service/Befunc.php:Tx_Workspaces_Service_Befunc';