$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.
*
$this->deleteTask();
$content .= $this->listTasks();
break;
+ case 'stop':
+ $this->stopTask();
+ $content .= $this->listTasks();
+ break;
case 'list':
default:
$content .= $this->listTasks();
}
}
+ /**
+ * 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
*
// Define action icons
$editAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=edit&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit') . '"><img ' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/edit2.gif') . ' alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit') . '" /></a> ';
$deleteAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=delete&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('msg.delete') . '\');" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:delete') . '"><img ' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/garbage.gif') . ' alt="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:delete') . '" /></a>';
+ $stopAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=stop&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('msg.stop') . '\');" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:stop') . '"><img ' . t3lib_iconWorks::skinImg($this->backPath, t3lib_extMgm::extRelPath('scheduler') . '/res/gfx/stop.png') . ' alt="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:stop') . '" /></a>';
// Define some default values
$lastExecution = '-';
$isRunning = false;
// Show no action links (edit, delete) if task is running
$actions = $editAction . $deleteAction;
if ($isRunning) {
- $actions = ' ';
+ $actions = $stopAction;
}
// Check the disable status
<label index="msg.lastRun">The Scheduler was last started (%1$s) on %2$s at %3$s and ended on %4$s at %5$s.</label>
<label index="msg.maynotDeleteRunningTask">A running task may not be deleted.</label>
<label index="msg.maynotEditRunningTask">A running task may not be edited.</label>
+ <label index="msg.maynotStopNonRunningTask">The task is not running. There are no executions to unmark.</label>
<label index="msg.noEmail">Please enter an email address</label>
<label index="msg.noFrequency">No frequency was defined, either as an interval or as a cron command.</label>
<label index="msg.noLastRun">The Scheduler has never yet run or the information about the last run has been lost.</label>
<label index="msg.schedulerUserFound">The backend user "_cli_scheduler" was found.</label>
<label index="msg.schedulerUserFoundButDisabled">The backend user "_cli_scheduler" exists but is currently disabled.</label>
<label index="msg.schedulerUserMissing">The backend user "_cli_scheduler" was not found. <a href="%s" title="Click to create the missing user">Create the user now</a>.</label>
- <label index="msg.singleExecutionMustBeInFuture">The execution time of single execution tasks has to be in the future.</label>
+ <label index="msg.stop">Are you sure you want to mark this task as not running? Note that this will not stop the actual script (if unsure please refer to the manual).</label>
+ <label index="msg.stopError">The task could not be marked as non-running.</label>
+ <label index="msg.stopSuccess">The task was successfully marked as non-running.</label>
<label index="msg.taskNotFound">The requested task (UID: %d) was not found.</label>
<label index="msg.updateSuccess">The task was updated successfully.</label>
<label index="msg.updateError">The task could not be updated.</label>