Added feature #14994: Add Scheduler task for autopublication of workspaces
authorFrancois Suter <francois.suter@typo3.org>
Tue, 6 Jul 2010 14:13:18 +0000 (14:13 +0000)
committerFrancois Suter <francois.suter@typo3.org>
Tue, 6 Jul 2010 14:13:18 +0000 (14:13 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8111 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/mod/user/ws/class.wslib.php
typo3/mod/user/ws/cli/ws_cli.phpsh [deleted file]
typo3/sysext/version/ext_autoload.php [new file with mode: 0644]
typo3/sysext/version/ext_localconf.php [new file with mode: 0644]
typo3/sysext/version/locallang.xml
typo3/sysext/version/tasks/class.tx_version_tasks_autopublish.php [new file with mode: 0644]

index 79b082e..cd878bd 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2010-07-06 Francois Suter  <francois@typo3.org>
 
        * Added feature #14993: Use TYPO3_REQUESTTYPE also for Install Tool access
+       * Added feature #14994: Add Scheduler task for autopublication of workspaces
 
 2010-07-06  Steffen Kamper  <info@sk-typo3.de>
 
index feadd05..dea0c67 100755 (executable)
@@ -174,7 +174,7 @@ class wslib {
 
        /****************************
         *
-        * CLI functions
+        * Scheduler methods
         *
         ****************************/
 
@@ -182,14 +182,18 @@ class wslib {
         * Main function to call from cli-script
         *
         * @return      void
+        * @deprecated since TYPO3 4.5 - This was meant for an obsolete CLI script. You shouldn't be calling this.
         */
        function CLI_main()     {
+               self::logDeprecatedFunction();
                $this->autoPublishWorkspaces();
        }
 
        /**
-        * CLI internal function:
-        * Will search for workspaces which has timed out regarding publishing and publish them
+        * This method is called by the Scheduler task that triggers
+        * the autopublication process
+        * It searches for workspaces whose publication date is in the past
+        * and publishes them
         *
         * @return      void
         */
diff --git a/typo3/mod/user/ws/cli/ws_cli.phpsh b/typo3/mod/user/ws/cli/ws_cli.phpsh
deleted file mode 100755 (executable)
index 4bde158..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#! /usr/bin/php -q
-<?php
-
-// *****************************************
-// Standard initialization of a CLI module:
-// *****************************************
-
-       // Defining circumstances for CLI mode:
-define('TYPO3_cliMode', TRUE);
-
-       // Defining PATH_thisScript here: Must be the ABSOLUTE path of this script in the right context:
-       // This will work as long as the script is called by it's absolute path!
-define('PATH_thisScript',$_ENV['_']?$_ENV['_']:$_SERVER['_']);
-
-       // Include configuration file:
-require(dirname(PATH_thisScript).'/conf.php');
-
-       // Include init file:
-require(dirname(PATH_thisScript).'/'.$BACK_PATH.'init.php');
-
-
-
-# HERE you run your application!
-require_once(PATH_typo3.'mod/user/ws/class.wslib.php');
-
-$autopubObj = t3lib_div::makeInstance('wslib');
-$autopubObj->CLI_main();
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/version/ext_autoload.php b/typo3/sysext/version/ext_autoload.php
new file mode 100644 (file)
index 0000000..936247c
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+/*
+ * Register necessary classes with autoloader
+ *
+ * $Id: ext_autoload.php 6536 2009-11-25 14:07:18Z stucki $
+ */
+return array(
+       'tx_version_tasks_autopublish' => t3lib_extMgm::extPath('version', 'tasks/class.tx_version_tasks_autopublish.php')
+);
+?>
diff --git a/typo3/sysext/version/ext_localconf.php b/typo3/sysext/version/ext_localconf.php
new file mode 100644 (file)
index 0000000..837a013
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+/* $Id: ext_localconf.php 7251 2010-04-06 18:57:45Z francois $ */
+
+if (!defined ('TYPO3_MODE')) {
+       die ('Access denied.');
+}
+
+       // Register the autopublishing task
+$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_version_tasks_AutoPublish'] = array(
+       'extension'        => $_EXTKEY,
+       'title'            => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:autopublishTask.name',
+       'description'      => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:autopublishTask.description'
+);
+?>
index 732733e..f81e548 100755 (executable)
                        <label index="versionSelect.publish">Publish page</label>
                        <label index="versionSelect.inBranch">Inside branch, no further versioning possible</label>
                        <label index="versionSelect.versionsFound">Versions found on page, no "Page" versioning possible</label>
+                       <label index="autopublishTask.name">Workspaces auto-publication</label>
+                       <label index="autopublishTask.description">This tasks checks any workspace that has a publication date set in the past and automatically publishes it.</label>
                </languageKey>
        </data>
 </T3locallang>
\ No newline at end of file
diff --git a/typo3/sysext/version/tasks/class.tx_version_tasks_autopublish.php b/typo3/sysext/version/tasks/class.tx_version_tasks_autopublish.php
new file mode 100644 (file)
index 0000000..6f5cd66
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2010 Francois Suter <francois@typo3.org>
+*  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 wrapper around the autopublication
+ * mechanism of workspaces, as a Scheduler task
+ *
+ * @author             Francois Suter <francois@typo3.org>
+ * @package            TYPO3
+ * @subpackage tx_version
+ *
+ * $Id: class.tx_scheduler_sleeptask.php 7905 2010-06-13 14:42:33Z ohader $
+ */
+class tx_version_tasks_AutoPublish extends tx_scheduler_Task {
+
+       /**
+        * Method executed from the Scheduler.
+        * Call on the workspace logic to publish workspaces whose publication date
+        * is in the past
+        *
+        * @return      void
+        */
+       public function execute() {
+                       // Load the workspace library class and instatiate it
+               require_once(PATH_typo3 . 'mod/user/ws/class.wslib.php');
+               $autopubObj = t3lib_div::makeInstance('wslib');
+                       // Publish the workspaces that need to be
+               $autopubObj->autoPublishWorkspaces();
+                       // There's no feedback from the publishing process,
+                       // so there can't be any failure.
+                       // TODO: This could certainly be improved.
+               return TRUE;
+       }
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/tasks/class.tx_version_tasks_autopublish.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/version/tasks/class.tx_version_tasks_autopublish.php']);
+}
+?>
\ No newline at end of file