diff --git a/admin/translators.php b/admin/translators.php index 9cf4dd8..a11b80e 100644 --- a/admin/translators.php +++ b/admin/translators.php @@ -43,7 +43,7 @@ $languages = mlang_tools::list_languages(false); if (!isset($languages[$langcode])) { - print_error('error_unknown_language', 'local_amos', '', $langcode); + throw new \moodle_exception('error_unknown_language', 'local_amos', '', $langcode); } if ($action === 'add') { @@ -54,7 +54,7 @@ $actionname = get_string('creditsaddcontributor', 'local_amos'); $selector = new local_amos_contributor_selector('user', []); } else { - print_error('error_unknown_status', 'local_amos', '', $status); + throw new \moodle_exception('error_unknown_status', 'local_amos', '', $status); } } else if ($action === 'del') { @@ -64,7 +64,7 @@ } else if ($status == AMOS_USER_CONTRIBUTOR) { $actionname = get_string('creditsdelcontributor', 'local_amos'); } else { - print_error('error_unknown_status', 'local_amos', '', $status); + throw new \moodle_exception('error_unknown_status', 'local_amos', '', $status); } } @@ -160,5 +160,5 @@ echo $OUTPUT->footer(); } else { - print_error('error_unknown_action', 'local_amos'); + throw new \moodle_exception('error_unknown_action', 'local_amos'); } diff --git a/contrib.php b/contrib.php index e1263ac..d6fcd8f 100644 --- a/contrib.php +++ b/contrib.php @@ -72,7 +72,7 @@ if ($maintainerof !== 'all') { if (!in_array($contribution->lang, $maintainerof)) { - print_error('contributionaccessdenied', 'local_amos'); + throw new \moodle_exception('contributionaccessdenied', 'local_amos'); } } @@ -143,7 +143,7 @@ if ($maintainerof !== 'all') { if (!in_array($contribution->lang, $maintainerof)) { - print_error('contributionaccessdenied', 'local_amos'); + throw new \moodle_exception('contributionaccessdenied', 'local_amos'); } } @@ -190,7 +190,7 @@ if ($maintainerof !== 'all') { if (!in_array($contribution->lang, $maintainerof)) { - print_error('contributionaccessdenied', 'local_amos'); + throw new \moodle_exception('contributionaccessdenied', 'local_amos'); } } @@ -241,7 +241,7 @@ if ($maintainerof !== 'all') { if (!in_array($contribution->lang, $maintainerof)) { - print_error('contributionaccessdenied', 'local_amos'); + throw new \moodle_exception('contributionaccessdenied', 'local_amos'); } } @@ -285,7 +285,7 @@ $listlanguages = mlang_tools::list_languages(); if (empty($listlanguages[$newlang])) { - print_error('err_invalid_target_language', 'local_amos', new moodle_url($PAGE->url, ['id' => $contriborig->id]), + throw new \moodle_exception('err_invalid_target_language', 'local_amos', new moodle_url($PAGE->url, ['id' => $contriborig->id]), null, $newlang); } diff --git a/stash.php b/stash.php index 7a3a90b..cb03edb 100644 --- a/stash.php +++ b/stash.php @@ -59,7 +59,7 @@ require_capability('local/amos:stage', context_system::instance()); $stash = mlang_stash::instance_from_id($apply); if ($stash->ownerid != $USER->id) { - print_error('stashaccessdenied', 'local_amos'); + throw new \moodle_exception('stashaccessdenied', 'local_amos'); die(); } $stage = mlang_persistent_stage::instance_for_user($USER->id, sesskey()); @@ -73,7 +73,7 @@ require_capability('local/amos:stage', context_system::instance()); $stash = mlang_stash::instance_from_id($pop); if ($stash->ownerid != $USER->id) { - print_error('stashaccessdenied', 'local_amos'); + throw new \moodle_exception('stashaccessdenied', 'local_amos'); die(); } $stage = mlang_persistent_stage::instance_for_user($USER->id, sesskey()); @@ -87,7 +87,7 @@ require_sesskey(); $stash = mlang_stash::instance_from_id($drop); if ($stash->ownerid != $USER->id) { - print_error('stashaccessdenied', 'local_amos'); + throw new \moodle_exception('stashaccessdenied', 'local_amos'); die(); } $confirm = optional_param('confirm', false, PARAM_BOOL); @@ -115,7 +115,7 @@ require_sesskey(); $stash = mlang_stash::instance_from_id($download); if ($stash->ownerid != $USER->id) { - print_error('stashaccessdenied', 'local_amos'); + throw new \moodle_exception('stashaccessdenied', 'local_amos'); die(); } $stash->send_zip("stash.zip"); @@ -129,7 +129,7 @@ } else if ($submitdata = $submitform->get_data()) { $stash = mlang_stash::instance_from_id($submitdata->stashid); if ($stash->ownerid != $USER->id) { - print_error('stashaccessdenied', 'local_amos'); + throw new \moodle_exception('stashaccessdenied', 'local_amos'); die(); } @@ -231,7 +231,7 @@ require_sesskey(); $stash = mlang_stash::instance_from_id($submit); if ($stash->ownerid != $USER->id) { - print_error('stashaccessdenied', 'local_amos'); + throw new \moodle_exception('stashaccessdenied', 'local_amos'); die(); } echo $output->heading_with_help(get_string('submitting', 'local_amos'), 'submitting', 'local_amos');