Index: typo3/sysext/scheduler/res/gfx/stop.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: typo3/sysext/scheduler/res/gfx/stop.png ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream Index: typo3/sysext/scheduler/mod1/locallang.xml =================================================================== --- typo3/sysext/scheduler/mod1/locallang.xml (revision 6303) +++ typo3/sysext/scheduler/mod1/locallang.xml (working copy) @@ -59,6 +59,7 @@ + @@ -77,7 +78,9 @@ - + + + Index: typo3/sysext/scheduler/mod1/index.php =================================================================== --- typo3/sysext/scheduler/mod1/index.php (revision 6303) +++ typo3/sysext/scheduler/mod1/index.php (working copy) @@ -226,6 +226,10 @@ $this->deleteTask(); $content .= $this->listTasks(); break; + case 'stop': + $this->stopTask(); + $content .= $this->listTasks(); + break; case 'list': default: $content .= $this->listTasks(); @@ -530,6 +534,41 @@ } } + /** + * Clears the registered running executions from the task + * Note that this doesn't actually stop the running script. It just unmarks + * all executions. + * TODO: find a way to really kill the running task + * + * @return void + */ + protected function stopTask() { + try { + // Try to fetch the task and stop it + /** + * @var tx_scheduler_Task + */ + $task = $this->scheduler->fetchTask($this->submittedData['uid']); + if ($task->isExecutionRunning()) { + // If the task is indeed currently running, clear marked executions + + $result = $task->unmarkAllExecutions(); + if ($result) { + $this->addMessage($GLOBALS['LANG']->getLL('msg.stopSuccess')); + } else { + $this->addMessage($GLOBALS['LANG']->getLL('msg.stopError'), t3lib_FlashMessage::ERROR); + } + } else { + // The task is not running, nothing to unmark + + $this->addMessage($GLOBALS['LANG']->getLL('msg.maynotStopNonRunningTask'), t3lib_FlashMessage::WARNING); + } + } catch (Exception $e) { + // The task was not found, for some reason + $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.taskNotFound'), $this->submittedData['uid']), t3lib_FlashMessage::ERROR); + } + } + /** * Return a form to add a new task or edit an existing one * @@ -925,6 +964,7 @@ // Define action icons $editAction = 'backPath, 'gfx/edit2.gif') . ' alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit') . '" /> '; $deleteAction = 'backPath, 'gfx/garbage.gif') . ' alt="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:delete') . '" />'; + $stopAction = 'backPath, t3lib_extMgm::extRelPath('scheduler') . '/res/gfx/stop.png') . ' alt="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:stop') . '" />'; // Define some default values $lastExecution = '-'; $isRunning = false; @@ -1011,7 +1051,7 @@ // Show no action links (edit, delete) if task is running $actions = $editAction . $deleteAction; if ($isRunning) { - $actions = ' '; + $actions = $stopAction; } // Check the disable status Index: typo3/sysext/scheduler/doc/manual.sxw =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: typo3/sysext/scheduler/class.tx_scheduler_task.php =================================================================== --- typo3/sysext/scheduler/class.tx_scheduler_task.php (revision 6303) +++ typo3/sysext/scheduler/class.tx_scheduler_task.php (working copy) @@ -405,6 +405,23 @@ $GLOBALS['TYPO3_DB']->sql_free_result($res); } + /** + * Clears all marked executions + * + * @return boolean True if the clearing succeeded, false otherwise + */ + public function unmarkAllExecutions() { + // Set the serialized executions field to empty + $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery( + 'tx_scheduler_task', + 'uid = ' . intval($this->taskUid), + array( + 'serialized_executions' => '' + ) + ); + return $result; + } + /** * Saves the details of the task to the database. *