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 * @param $dms dms
* @return boolean true if task was executed succesfully, otherwise false * @return boolean true if task was executed succesfully, otherwise false
*/ */
public function execute($task, $dms) { public function execute($task, $dms, $user) {
$taskparams = $task->getParameter(); $taskparams = $task->getParameter();
return true; return true;
} }

View File

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

View File

@ -73,13 +73,18 @@ foreach($tasks as $task) {
case "run": case "run":
if(method_exists($taskobj, 'execute')) { if(method_exists($taskobj, 'execute')) {
if(!$task->getDisabled()) { if(!$task->getDisabled()) {
if($taskobj->execute($task, $dms)) { if($user = $dms->getUserByLogin('cli_scheduler')) {
if($taskobj->execute($task, $dms, $user)) {
add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful."); add_log_line("Execution of task ".$task->getExtension()."::".$task->getTask()." successful.");
$task->updateLastNextRun(); $task->updateLastNextRun();
} else { } 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, task has been disabled.", PEAR_LOG_ERR);
$task->setDisabled(1); $task->setDisabled(1);
} }
} else {
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);
}
} }
} }
break; break;