Skip to content
Snippets Groups Projects
Unverified Commit 93c35903 authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Improve usage of notifications

parent e26d3d1c
Branches
Tags
No related merge requests found
......@@ -493,7 +493,7 @@ class workflow_settings {
* @throws \coding_exception
*/
private function handle_trigger_instance_form() {
global $OUTPUT, $PAGE;
global $PAGE;
$subpluginname = null;
$triggertomodify = null;
$triggersettings = null;
......@@ -509,9 +509,9 @@ class workflow_settings {
if ($form->is_submitted() && $form->is_validated() && $data = $form->get_submitted_data()) {
// In case the workflow was active, we do not allow changes to the steps or trigger.
if (!workflow_manager::is_editable($this->workflowid)) {
echo $OUTPUT->notification(
\core\notification::add(
get_string('active_workflow_not_changeable', 'tool_lifecycle'),
'warning');
\core\notification::WARNING);
} else {
if (!empty($data->id)) {
$triggertomodify = trigger_manager::get_instance($data->id);
......@@ -566,7 +566,7 @@ class workflow_settings {
* @return bool True, if no further action handling or output should be conducted.
*/
private function handle_step_instance_form() {
global $OUTPUT, $PAGE;
global $PAGE;
$steptomodify = null;
$subpluginname = null;
$stepsettings = null;
......@@ -582,9 +582,9 @@ class workflow_settings {
} else if ($form->is_submitted() && $form->is_validated() && $data = $form->get_submitted_data()) {
// In case the workflow was active, we do not allow changes to the steps or trigger.
if (!workflow_manager::is_editable($this->workflowid)) {
echo $OUTPUT->notification(
\core\notification::add(
get_string('active_workflow_not_changeable', 'tool_lifecycle'),
'warning');
\core\notification::WARNING);
} else {
if (!empty($data->id)) {
$step = step_manager::get_step_instance($data->id);
......
......@@ -220,7 +220,6 @@ class step_manager extends subplugin_manager {
* @param int $subpluginid id of the step instance
*/
public static function handle_action($action, $subpluginid) {
global $OUTPUT;
if ($step = self::get_step_instance($subpluginid)) {
if (!workflow_manager::is_active($step->workflowid)) {
if ($action === action::UP_STEP) {
......@@ -233,7 +232,8 @@ class step_manager extends subplugin_manager {
self::remove($subpluginid);
}
} else {
echo $OUTPUT->notification(get_string('active_workflow_not_changeable', 'tool_lifecycle'), 'warning');
\core\notification::add(get_string('active_workflow_not_changeable', 'tool_lifecycle'),
\core\notification::WARNING);
}
}
}
......
......@@ -243,7 +243,6 @@ class trigger_manager extends subplugin_manager {
* @param int $subpluginid id of the step instance
*/
public static function handle_action($action, $subpluginid) {
global $OUTPUT;
if ($trigger = self::get_instance($subpluginid)) {
if (!workflow_manager::is_active($trigger->workflowid)) {
if ($action === action::UP_TRIGGER) {
......@@ -256,7 +255,8 @@ class trigger_manager extends subplugin_manager {
self::remove($subpluginid);
}
} else {
echo $OUTPUT->notification(get_string('active_workflow_not_changeable', 'tool_lifecycle'), 'warning');
\core\notification::add(get_string('active_workflow_not_changeable', 'tool_lifecycle'),
\core\notification::WARNING);
}
}
}
......
......@@ -200,11 +200,11 @@ class workflow_manager {
* @param int $workflowid id of the workflow
*/
public static function activate_workflow($workflowid) {
global $DB, $OUTPUT;
global $DB;
if (!self::is_valid($workflowid)) {
echo $OUTPUT->notification(
\core\notification::add(
get_string('invalid_workflow_cannot_be_activated', 'tool_lifecycle'),
'warning');
\core\notification::WARNING);
return;
}
$transaction = $DB->start_delegated_transaction();
......@@ -230,7 +230,6 @@ class workflow_manager {
* @param int $workflowid id of the workflow
*/
public static function handle_action($action, $workflowid) {
global $OUTPUT;
if (!empty($action)) {
require_sesskey();
}
......@@ -257,8 +256,8 @@ class workflow_manager {
self::is_removable($workflowid)) {
self::remove($workflowid);
} else {
echo $OUTPUT->notification(get_string('workflow_not_removeable', 'tool_lifecycle')
, 'warning'); // TODO these notifications aren't shown properly currently.
\core\notification::add(get_string('workflow_not_removeable', 'tool_lifecycle')
, \core\notification::WARNING);
}
} else {
// If no action has been called. Continue.
......
......@@ -57,10 +57,9 @@ class tool_lifecycle_renderer extends plugin_renderer_base {
* @param array $errors
*/
public function render_workflow_upload_form($form, $errors = array()) {
global $OUTPUT;
$this->header(get_string('adminsettings_edit_workflow_definition_heading', 'tool_lifecycle'));
foreach ($errors as $error) {
echo $OUTPUT->notification($error);
\core\notification::add($error, \core\notification::ERROR);
}
echo $form->render();
$this->footer();
......
......@@ -99,7 +99,7 @@ class interactionduplicate extends interactionlibbase {
* - rollback: the step has finished and respective controller class should rollback the process.
*/
public function handle_interaction($process, $step, $action = 'default') {
global $PAGE, $DB, $OUTPUT;
global $PAGE, $DB;
$form = new form_duplicate($PAGE->url, $process->id, $step->id);
if ($form->is_cancelled()) {
return step_interactive_response::rollback();
......@@ -111,7 +111,7 @@ class interactionduplicate extends interactionlibbase {
}
$foundcoursenamestring = implode(',', $foundcoursenames);
echo $OUTPUT->notification(get_string('shortnametaken', '', $foundcoursenamestring));
\core\notification::add(get_string('shortnametaken', '', $foundcoursenamestring));
$this->render_form($form);
return step_interactive_response::still_processing();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment