Skip to content

Commit

Permalink
Replace deprecated print_error() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Oct 22, 2024
1 parent 1ef0c8b commit 0bdc6a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions admin/translators.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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') {
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -160,5 +160,5 @@
echo $OUTPUT->footer();

} else {
print_error('error_unknown_action', 'local_amos');
throw new \moodle_exception('error_unknown_action', 'local_amos');
}
10 changes: 5 additions & 5 deletions contrib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -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);
}

Expand Down
12 changes: 6 additions & 6 deletions stash.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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);
Expand Down Expand Up @@ -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");
Expand All @@ -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();
}

Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 0bdc6a5

Please sign in to comment.