Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-7391: Replace the deprecated print_error by moodle exception #488

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions classes/output/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion classes/view_assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function outputview() {
*/
public function validatecontent() {
if ($this->content === null) {
print_error('invalidhvp', 'mod_hvp');
throw new \moodle_exception('invalidhvp');
}
}

Expand Down
4 changes: 2 additions & 2 deletions embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions review.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -53,7 +53,7 @@
[$id]);

if ($hvp === false) {
print_error('invalidhvp', 'mod_hvp');
throw new \moodle_exception('invalidhvp');
}

// Set page properties.
Expand Down
10 changes: 5 additions & 5 deletions share.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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'));
}
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down