Skip to content

Commit 0cdfc33

Browse files
committed
MBS-7391: Replace the deprecated print_error by moodle exception
1 parent 29dba91 commit 0cdfc33

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

classes/output/mobile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public static function mobile_course_view($args) {
4747
// Verify course context.
4848
$cm = get_coursemodule_from_id('hvp', $cmid);
4949
if (!$cm) {
50-
print_error('invalidcoursemodule');
50+
throw new \moodle_exception('invalidcoursemodule');
5151
}
5252
$course = $DB->get_record('course', array('id' => $cm->course));
5353
if (!$course) {
54-
print_error('coursemisconf');
54+
throw new \moodle_exception('coursemisconf');
5555
}
5656
require_course_login($course, false, $cm, true, true);
5757
$context = context_module::instance($cm->id);

classes/view_assets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function outputview() {
342342
*/
343343
public function validatecontent() {
344344
if ($this->content === null) {
345-
print_error('invalidhvp', 'mod_hvp');
345+
throw new \moodle_exception('invalidhvp');
346346
}
347347
}
348348

embed.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
// Verify course context.
4343
$cm = get_coursemodule_from_id('hvp', $id);
4444
if (!$cm) {
45-
print_error('invalidcoursemodule');
45+
throw new \moodle_exception('invalidcoursemodule');
4646
}
4747
$course = $DB->get_record('course', array('id' => $cm->course));
4848
if (!$course) {
49-
print_error('coursemisconf');
49+
throw new \moodle_exception('coursemisconf');
5050
}
5151

5252
try {

grade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
$userid = optional_param('userid', 0, PARAM_INT);
3131

3232
if (! $cm = get_coursemodule_from_id('hvp', $id)) {
33-
print_error('invalidcoursemodule');
33+
throw new \moodle_exception('invalidcoursemodule');
3434
}
3535
if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
36-
print_error('coursemisconf');
36+
throw new \moodle_exception('coursemisconf');
3737
}
3838
require_course_login($course, false, $cm);
3939

@@ -53,7 +53,7 @@
5353
array($cm->instance));
5454

5555
if ($hvp === false) {
56-
print_error('invalidhvp', 'mod_hvp');
56+
throw new \moodle_exception('invalidhvp');
5757
}
5858

5959
// Redirect to report if a specific user is chosen.

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// Load Course.
3434
$course = $DB->get_record('course', array('id' => $id));
3535
if (!$course) {
36-
print_error('invalidcourseid');
36+
throw new \moodle_exception('invalidcourseid');
3737
}
3838

3939
// Require login.

review.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
$userid = optional_param('user', (int) $USER->id, PARAM_INT);
3030

3131
if (!$cm = get_coursemodule_from_instance('hvp', $id)) {
32-
print_error('invalidcoursemodule');
32+
throw new \moodle_exception('invalidcoursemodule');
3333
}
3434
if (!$course = $DB->get_record('course', ['id' => $cm->course])) {
35-
print_error('coursemisconf');
35+
throw new \moodle_exception('coursemisconf');
3636
}
3737
require_login($course, false, $cm);
3838

@@ -53,7 +53,7 @@
5353
[$id]);
5454

5555
if ($hvp === false) {
56-
print_error('invalidhvp', 'mod_hvp');
56+
throw new \moodle_exception('invalidhvp');
5757
}
5858

5959
// Set page properties.

share.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
// Verify course context.
3131
$cm = get_coursemodule_from_id('hvp', $id);
3232
if (!$cm) {
33-
print_error('invalidcoursemodule');
33+
throw new \moodle_exception('invalidcoursemodule');
3434
}
3535
$course = $DB->get_record('course', array('id' => $cm->course));
3636
if (!$course) {
37-
print_error('coursemisconf');
37+
throw new \moodle_exception('coursemisconf');
3838
}
3939
require_course_login($course, true, $cm);
4040
$context = context_module::instance($cm->id);
@@ -43,7 +43,7 @@
4343
// Check if Hub registered, if not redirect to hub registration.
4444
if (empty(get_config('mod_hvp', 'site_uuid')) || empty(get_config('mod_hvp', 'hub_secret'))) {
4545
if (!has_capability('mod/hvp:contenthubregistration', \context_system::instance())) {
46-
print_error('nohubregistration', 'mod_hvp');
46+
throw new \moodle_exception('nohubregistration');
4747
}
4848
redirect(new moodle_url('/mod/hvp/content_hub_registration.php'));
4949
}
@@ -60,10 +60,10 @@
6060
}
6161
$token = required_param('_token', PARAM_RAW);
6262
if (!\H5PCore::validToken('share_' . $id, $token)) {
63-
print_error('invalidtoken', 'mod_hvp');
63+
throw new \moodle_exception('invalidtoken');
6464
}
6565
if (empty($content['contentHubId']) || $content['shared'] !== '1') {
66-
print_error('contentnotshared', 'mod_hvp');
66+
throw new \moodle_exception('contentnotshared');
6767
}
6868

6969
$core = \mod_hvp\framework::instance();

view.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
// Verify course context.
3131
$cm = get_coursemodule_from_id('hvp', $id);
3232
if (!$cm) {
33-
print_error('invalidcoursemodule');
33+
throw new \moodle_exception('invalidcoursemodule');
3434
}
3535
$course = $DB->get_record('course', array('id' => $cm->course));
3636
if (!$course) {
37-
print_error('coursemisconf');
37+
throw new \moodle_exception('coursemisconf');
3838
}
3939
require_course_login($course, true, $cm);
4040
$context = context_module::instance($cm->id);

0 commit comments

Comments
 (0)