pass $user to execute() method of task

This commit is contained in:
Uwe Steinmann 2020-05-18 16:24:19 +02:00
parent ff69d6e08e
commit 537327e41d
3 changed files with 11 additions and 6 deletions

View File

@ -186,7 +186,7 @@ class SeedDMS_ExtExample_Task extends SeedDMS_SchedulerTaskBase {
* @param $dms dms
* @return boolean true if task was executed succesfully, otherwise false
*/
public function execute($task, $dms) {
public function execute($task, $dms, $user) {
$taskparams = $task->getParameter();
return true;
}

View File

@ -29,7 +29,7 @@
* @package SeedDMS
*/
class SeedDMS_SchedulerTaskBase {
public function execute($task, $dms) {
public function execute($task, $dms, $user) {
return true;
}
}

View File

@ -73,11 +73,16 @@ foreach($tasks as $task) {
case "run":
if(method_exists($taskobj, 'execute')) {
if(!$task->getDisabled()) {
if($taskobj->execute($task, $dms)) {
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful.");
$task->updateLastNextRun();
if($user = $dms->getUserByLogin('cli_scheduler')) {
if($taskobj->execute($task, $dms, $user)) {
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful.");
$task->updateLastNextRun();
} else {
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed, task has been disabled.", PEAR_LOG_ERR);
$task->setDisabled(1);
}
} else {
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed, task has been disabled.", PEAR_LOG_ERR);
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." failed because of missing user 'cli_scheduler'. Task has been disabled.", PEAR_LOG_ERR);
$task->setDisabled(1);
}
}