Project

General

Profile

Feature #4019 » 4019.diff

Ingo Renner, 2009-08-17 18:56

View differences:

class.tx_scheduler_task.php (working copy)
* It MUST be implemented by all classes inheriting from this one
* Note that there is no error handling, errors and failures are expected
* to be handled and logged by the client implementations.
* Should return true on successful execution, false on error.
*
* @return void
* @return boolean Returns true on successful execution, false on error
*/
abstract public function execute();
......
/**
* Removes given execution from list
*
* @param integer $executionID: id of the execution to remove
* @param integer Id of the execution to remove.
* @param boolean Status of the last execution, true for success, false to represent an error.
* @return void
*/
public function unmarkExecution($executionID) {
public function unmarkExecution($executionID, $successfullyExecuted = false) {
// Get the executions for the task
$queryArr = array(
'SELECT' => 'serialized_executions',
......
$GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'tx_scheduler_task',
'uid = ' . intval($this->taskUid),
array('serialized_executions' => $runningExecutionsSerialized)
array(
'serialized_executions' => $runningExecutionsSerialized,
'lastexecution_success' => (int) $successfullyExecuted
)
);
}
}
mod1/index.php (working copy)
$executionStatus = 'disabled';
}
// a failure is the worst thing that could happen, so it must overwrite all other statuses
if (!empty($schedulerRecord['lastexecution_time']) && !$schedulerRecord['lastexecution_success']) {
$executionStatus = 'failure';
}
// formatting the execution status
$executionStatus = '<img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_' . $executionStatus . '.png') . ' alt="' . $GLOBALS['LANG']->getLL('status.' . $executionStatus) . '" />';
......
$content .= '<p class="status-legend">' . $GLOBALS['LANG']->getLL('status.legend') . ':</p>
<ul>
<li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_disabled.png') . ' alt="' . $GLOBALS['LANG']->getLL('status.disabled') . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.disabled') . '</li>
<li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_stopped.png') . ' alt="' . $GLOBALS['LANG']->getLL('status.stopped') . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.stopped') . '</li>
<li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_failure.png') . ' alt="' . $GLOBALS['LANG']->getLL('status.failure') . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.failure') . '</li>
<li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_scheduled.png') . ' alt="' . $GLOBALS['LANG']->getLL('status.scheduled') . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.scheduled') . '</li>
<li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_running.png') . ' alt="' . $GLOBALS['LANG']->getLL('status.running') . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.running') . '</li>
<li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_stopped.png') . ' alt="' . $GLOBALS['LANG']->getLL('status.stopped') . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.stopped') . '</li>
<li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_disabled.png') . ' alt="' . $GLOBALS['LANG']->getLL('status.disabled') . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.disabled') . '</li>
</ul>';
mod1/locallang.xml (working copy)
<label index="status.legend">Status Legend</label>
<label index="status.legend.disabled">Disabled, will not be executed</label>
<label index="status.legend.stopped">Stopped, currently not running</label>
<label index="status.legend.failure">Failure! An error occured during the last execution.</label>
<label index="status.legend.scheduled">Late, runs with next execution</label>
<label index="status.legend.running">Currently running</label>
<label index="status.disabled">disabled</label>
<label index="status.stopped">stopped</label>
<label index="status.failure">failure</label>
<label index="status.scheduled">scheduled</label>
<label index="status.running">running</label>
</languageKey>
ext_tables.sql (working copy)
crid varchar(255) DEFAULT '' NOT NULL,
nextexecution int(11) unsigned DEFAULT '0' NOT NULL,
lastexecution_time int(11) unsigned DEFAULT '0' NOT NULL,
lastexecution_success int(1) unsigned DEFAULT '0' NOT NULL,
lastexecution_context char(3) DEFAULT '' NOT NULL,
serialized_task_object text NOT NULL,
serialized_executions text NOT NULL,
examples/class.tx_scheduler_sleeptask.php (working copy)
}
sleep($time);
return true;
}
}
examples/class.tx_scheduler_testtask.php (working copy)
* @return void
*/
public function execute() {
$success = false;
if (!empty($this->email)) {
// If an email address is defined, send a message to it
......
$mailer->setRecipient($this->email);
$mailer->setHeaders();
$mailer->setContent();
$mailer->sendtheMail();
$success = $mailer->sendtheMail();
} else {
// No email defined, just log the task
t3lib_div::devLog('[tx_scheduler_testtask]: No email address given', 'scheduler', 2);
}
return $success;
}
}
class.tx_scheduler.php (working copy)
$executionID = $task->markExecution();
// Execute task
$task->execute();
$successfullyExecuted = $task->execute();
// Unregister excution
$task->unmarkExecution($executionID);
$task->unmarkExecution($executionID, $successfullyExecuted);
// Log completion of execution
$GLOBALS['BE_USER']->writelog(
(1-1/2)