[FEATURE] Description-field for scheduler-jobs 10/24610/3
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 11 Oct 2013 22:05:36 +0000 (00:05 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 12 Oct 2013 10:15:01 +0000 (12:15 +0200)
Adds a description-textfield for tasks. This will be displayed
in the scheduler-list. The description can either be shown as
hover (default) or below the job-name, configurable through
the extension-settings for "scheduler".

Change-Id: If0191da43677fc261cb73257e3ede848a5375d69
Resolves: #52696
Releases: 6.2
Reviewed-on: https://review.typo3.org/24610
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/Classes/Scheduler.php
typo3/sysext/scheduler/Classes/Task/AbstractTask.php
typo3/sysext/scheduler/ext_conf_template.txt
typo3/sysext/scheduler/ext_tables.sql

index cf3df77..89c4601 100644 (file)
@@ -565,6 +565,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                $task = unserialize($taskRecord['serialized_task_object']);
                                // Set some task information
                                $taskInfo['disable'] = $taskRecord['disable'];
+                               $taskInfo['description'] = $taskRecord['description'];
                                // Check that the task object is valid
                                if ($this->scheduler->isValidTaskObject($task)) {
                                        // The task object is valid, process with fetching current data
@@ -775,6 +776,16 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                        '0' => array('<td class="td-label">', '</td>')
                );
                $tr++;
+               // Description
+               $label = '<label for="task_description">' . $GLOBALS['LANG']->getLL('label.description') . '</label>';
+               $table[$tr][] = BackendUtility::wrapInHelp($this->cshKey, 'task_description', $label);
+               $table[$tr][] = '<textarea name="tx_scheduler[description]">' . htmlspecialchars($taskInfo['description']) . '</textarea>';
+               $tableLayout[$tr] = array(
+                       'tr' => array('<tr id="task_description_row">', '</tr>'),
+                       'defCol' => $defaultCell,
+                       '0' => array('<td class="td-label">', '</td>')
+               );
+               $tr++;
                // Display additional fields
                foreach ($allAdditionalFields as $class => $fields) {
                        if ($class == $taskInfo['class']) {
@@ -1056,7 +1067,15 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                                        $table[$tr][] = $actions;
                                        $table[$tr][] = $schedulerRecord['uid'];
                                        $table[$tr][] = $executionStatusOutput;
-                                       $table[$tr][] = $name;
+                                       if ($schedulerRecord['description'] !== '') {
+                                               if (!empty($this->scheduler->extConf['listShowTaskDescriptionAsHover'])) {
+                                                       $table[$tr][] = '<span title="' . htmlspecialchars($schedulerRecord['description']) . '">' . $name . '</span>';
+                                               } else {
+                                                       $table[$tr][] = $name . '<br />' . nl2br(htmlspecialchars($schedulerRecord['description'])) . '<br />';
+                                               }
+                                       } else {
+                                               $table[$tr][] = $name;
+                                       }
                                        $table[$tr][] = $execType;
                                        $table[$tr][] = $frequency;
                                        $table[$tr][] = $multiple;
@@ -1139,6 +1158,8 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                        }
                        // Set disable flag
                        $task->setDisabled($this->submittedData['disable']);
+                       // Set description
+                       $task->setDescription($this->submittedData['description']);
                        // Save additional input values
                        if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$this->submittedData['class']]['additionalFields'])) {
                                /** @var $providerObject \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface */
@@ -1176,6 +1197,8 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                        }
                        // Set disable flag
                        $task->setDisabled($this->submittedData['disable']);
+                       // Set description
+                       $task->setDescription($this->submittedData['description']);
                        // Add to database
                        $result = $this->scheduler->addTask($task);
                        if ($result) {
index 11ca473..2228248 100644 (file)
@@ -233,6 +233,7 @@ class Scheduler implements \TYPO3\CMS\Core\SingletonInterface {
                        $fields = array(
                                'nextexecution' => $executionTime,
                                'disable' => $task->isDisabled(),
+                               'description' => $task->getDescription(),
                                'serialized_task_object' => serialize($task)
                        );
                        $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_scheduler_task', 'uid = ' . $taskUid, $fields);
index 694a866..fbc3310 100644 (file)
@@ -69,6 +69,13 @@ abstract class AbstractTask {
        protected $executionTime = 0;
 
        /**
+        * Description for the task
+        *
+        * @var string
+        */
+       protected $description = '';
+
+       /**
         * Constructor
         */
        public function __construct() {
@@ -188,6 +195,25 @@ abstract class AbstractTask {
        }
 
        /**
+        * This method is used to set the description of the task
+        *
+        * @param string $description Description
+        * @return void
+        */
+       public function setDescription($description) {
+               $this->description = $description;
+       }
+
+       /**
+        * This method returns the description of the task
+        *
+        * @return string Description
+        */
+       public function getDescription() {
+               return $this->description;
+       }
+
+       /**
         * Sets the internal reference to the singleton instance of the Scheduler
         *
         * @return void
index ef47da0..78ef2dd 100644 (file)
@@ -9,3 +9,6 @@ showSampleTasks = 1
 
 # cat=basic//; type=boolean; label=Use "at"-daemon: This allows automatic scheduling of the next execution of the scheduler. Your system must have the at daemon installed and configured for the user PHP runs with.
 useAtdaemon = 0
+
+# cat=basic//; type=boolean; label=Show description of tasks as hover: If disabled descriptions of tasks will be shown below the job-name in the scheduler-list
+listShowTaskDescriptionAsHover = 1
index bbe3a63..4fe7e64 100755 (executable)
@@ -5,6 +5,7 @@ CREATE TABLE tx_scheduler_task (
        uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment,
        crdate int(11) unsigned DEFAULT '0' NOT NULL,
        disable tinyint(4) unsigned DEFAULT '0' NOT NULL,
+       description text NOT NULL,
        nextexecution int(11) unsigned DEFAULT '0' NOT NULL,
        lastexecution_time int(11) unsigned DEFAULT '0' NOT NULL,
        lastexecution_failure text NOT NULL,