From 69257f019c20bc31e107d10d7b759dceb521a11d Mon Sep 17 00:00:00 2001 From: = Date: Thu, 2 Mar 2023 13:30:42 +0100 Subject: [PATCH] MBS-7391: Replace the deprecated print_error by moodle exception --- classes/output/mobile.php | 4 ++-- classes/view_assets.php | 2 +- embed.php | 4 ++-- grade.php | 6 +++--- index.php | 2 +- review.php | 6 +++--- share.php | 10 +++++----- view.php | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/classes/output/mobile.php b/classes/output/mobile.php index 3a8f91f1f..7956eab44 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -47,11 +47,11 @@ public static function mobile_course_view($args) { // Verify course context. $cm = get_coursemodule_from_id('hvp', $cmid); if (!$cm) { - print_error('invalidcoursemodule'); + throw new \moodle_exception('invalidcoursemodule'); } $course = $DB->get_record('course', array('id' => $cm->course)); if (!$course) { - print_error('coursemisconf'); + throw new \moodle_exception('coursemisconf'); } require_course_login($course, false, $cm, true, true); $context = context_module::instance($cm->id); diff --git a/classes/view_assets.php b/classes/view_assets.php index 8ce34426d..285f9a3cb 100644 --- a/classes/view_assets.php +++ b/classes/view_assets.php @@ -342,7 +342,7 @@ public function outputview() { */ public function validatecontent() { if ($this->content === null) { - print_error('invalidhvp', 'mod_hvp'); + throw new \moodle_exception('invalidhvp'); } } diff --git a/embed.php b/embed.php index 94667a6c4..b7eacf5cc 100644 --- a/embed.php +++ b/embed.php @@ -42,11 +42,11 @@ // Verify course context. $cm = get_coursemodule_from_id('hvp', $id); if (!$cm) { - print_error('invalidcoursemodule'); + throw new \moodle_exception('invalidcoursemodule'); } $course = $DB->get_record('course', array('id' => $cm->course)); if (!$course) { - print_error('coursemisconf'); + throw new \moodle_exception('coursemisconf'); } try { diff --git a/grade.php b/grade.php index 2f640f8fa..871d5956a 100644 --- a/grade.php +++ b/grade.php @@ -30,10 +30,10 @@ $userid = optional_param('userid', 0, PARAM_INT); if (! $cm = get_coursemodule_from_id('hvp', $id)) { - print_error('invalidcoursemodule'); + throw new \moodle_exception('invalidcoursemodule'); } if (! $course = $DB->get_record('course', array('id' => $cm->course))) { - print_error('coursemisconf'); + throw new \moodle_exception('coursemisconf'); } require_course_login($course, false, $cm); @@ -53,7 +53,7 @@ array($cm->instance)); if ($hvp === false) { - print_error('invalidhvp', 'mod_hvp'); + throw new \moodle_exception('invalidhvp'); } // Redirect to report if a specific user is chosen. diff --git a/index.php b/index.php index 3dc4c7f4c..70ea5a544 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ // Load Course. $course = $DB->get_record('course', array('id' => $id)); if (!$course) { - print_error('invalidcourseid'); + throw new \moodle_exception('invalidcourseid'); } // Require login. diff --git a/review.php b/review.php index 3f52b5ae6..9fb490c39 100644 --- a/review.php +++ b/review.php @@ -29,10 +29,10 @@ $userid = optional_param('user', (int) $USER->id, PARAM_INT); if (!$cm = get_coursemodule_from_instance('hvp', $id)) { - print_error('invalidcoursemodule'); + throw new \moodle_exception('invalidcoursemodule'); } if (!$course = $DB->get_record('course', ['id' => $cm->course])) { - print_error('coursemisconf'); + throw new \moodle_exception('coursemisconf'); } require_login($course, false, $cm); @@ -53,7 +53,7 @@ [$id]); if ($hvp === false) { - print_error('invalidhvp', 'mod_hvp'); + throw new \moodle_exception('invalidhvp'); } // Set page properties. diff --git a/share.php b/share.php index d52e38b92..432f8072f 100644 --- a/share.php +++ b/share.php @@ -30,11 +30,11 @@ // Verify course context. $cm = get_coursemodule_from_id('hvp', $id); if (!$cm) { - print_error('invalidcoursemodule'); + throw new \moodle_exception('invalidcoursemodule'); } $course = $DB->get_record('course', array('id' => $cm->course)); if (!$course) { - print_error('coursemisconf'); + throw new \moodle_exception('coursemisconf'); } require_course_login($course, true, $cm); $context = context_module::instance($cm->id); @@ -43,7 +43,7 @@ // Check if Hub registered, if not redirect to hub registration. if (empty(get_config('mod_hvp', 'site_uuid')) || empty(get_config('mod_hvp', 'hub_secret'))) { if (!has_capability('mod/hvp:contenthubregistration', \context_system::instance())) { - print_error('nohubregistration', 'mod_hvp'); + throw new \moodle_exception('nohubregistration'); } redirect(new moodle_url('/mod/hvp/content_hub_registration.php')); } @@ -60,10 +60,10 @@ } $token = required_param('_token', PARAM_RAW); if (!\H5PCore::validToken('share_' . $id, $token)) { - print_error('invalidtoken', 'mod_hvp'); + throw new \moodle_exception('invalidtoken'); } if (empty($content['contentHubId']) || $content['shared'] !== '1') { - print_error('contentnotshared', 'mod_hvp'); + throw new \moodle_exception('contentnotshared'); } $core = \mod_hvp\framework::instance(); diff --git a/view.php b/view.php index 8368ad793..f2af82266 100644 --- a/view.php +++ b/view.php @@ -30,11 +30,11 @@ // Verify course context. $cm = get_coursemodule_from_id('hvp', $id); if (!$cm) { - print_error('invalidcoursemodule'); + throw new \moodle_exception('invalidcoursemodule'); } $course = $DB->get_record('course', array('id' => $cm->course)); if (!$course) { - print_error('coursemisconf'); + throw new \moodle_exception('coursemisconf'); } require_course_login($course, true, $cm); $context = context_module::instance($cm->id);