|
@@ 427-434 (lines=8) @@
|
| 424 |
|
// If the task is currently running, it may not be deleted |
| 425 |
|
if ($task->isExecutionRunning()) { |
| 426 |
|
$this->addMessage($this->getLanguageService()->getLL('msg.maynotDeleteRunningTask'), FlashMessage::ERROR); |
| 427 |
|
} else { |
| 428 |
|
if ($this->scheduler->removeTask($task)) { |
| 429 |
|
$this->getBackendUser()->writelog(4, 0, 0, 0, 'Scheduler task "%s" (UID: %s, Class: "%s") was deleted', [$task->getTaskTitle(), $task->getTaskUid(), $task->getTaskClassName()]); |
| 430 |
|
$this->addMessage($this->getLanguageService()->getLL('msg.deleteSuccess')); |
| 431 |
|
} else { |
| 432 |
|
$this->addMessage($this->getLanguageService()->getLL('msg.deleteError'), FlashMessage::ERROR); |
| 433 |
|
} |
| 434 |
|
} |
| 435 |
|
} catch (\UnexpectedValueException $e) { |
| 436 |
|
// The task could not be unserialized properly, simply update the database record |
| 437 |
|
$taskUid = (int)$this->submittedData['uid']; |
|
@@ 1174-1179 (lines=6) @@
|
| 1171 |
|
} |
| 1172 |
|
// Save to database |
| 1173 |
|
$result = $this->scheduler->saveTask($task); |
| 1174 |
|
if ($result) { |
| 1175 |
|
$this->getBackendUser()->writelog(4, 0, 0, 0, 'Scheduler task "%s" (UID: %s, Class: "%s") was updated', [$task->getTaskTitle(), $task->getTaskUid(), $task->getTaskClassName()]); |
| 1176 |
|
$this->addMessage($this->getLanguageService()->getLL('msg.updateSuccess')); |
| 1177 |
|
} else { |
| 1178 |
|
$this->addMessage($this->getLanguageService()->getLL('msg.updateError'), FlashMessage::ERROR); |
| 1179 |
|
} |
| 1180 |
|
} else { |
| 1181 |
|
// A new task is being created |
| 1182 |
|
// Create an instance of chosen class |
|
@@ 1208-1217 (lines=10) @@
|
| 1205 |
|
$task->setTaskGroup($this->submittedData['task_group']); |
| 1206 |
|
// Add to database |
| 1207 |
|
$result = $this->scheduler->addTask($task); |
| 1208 |
|
if ($result) { |
| 1209 |
|
$this->getBackendUser()->writelog(4, 0, 0, 0, 'Scheduler task "%s" (UID: %s, Class: "%s") was added', [$task->getTaskTitle(), $task->getTaskUid(), $task->getTaskClassName()]); |
| 1210 |
|
$this->addMessage($this->getLanguageService()->getLL('msg.addSuccess')); |
| 1211 |
|
|
| 1212 |
|
// set the uid of the just created task so that we |
| 1213 |
|
// can continue editing after initial saving |
| 1214 |
|
$this->submittedData['uid'] = $task->getTaskUid(); |
| 1215 |
|
} else { |
| 1216 |
|
$this->addMessage($this->getLanguageService()->getLL('msg.addError'), FlashMessage::ERROR); |
| 1217 |
|
} |
| 1218 |
|
} |
| 1219 |
|
} |
| 1220 |
|
|