Browse Source

Print_error deprecated - throw exception directly.

MOODLE_38_STABLE
Dan Marsden 4 years ago
parent
commit
16a22424ad
  1. 16
      attendance.php
  2. 4
      classes/structure.php
  3. 1
      db/upgrade.php
  4. 4
      export.php
  5. 5
      messageselect.php
  6. 2
      preferences.php
  7. 4
      renderables.php
  8. 4
      sessions.php
  9. 2
      warnings.php

16
attendance.php

@ -54,7 +54,7 @@ if ($attforsession->rotateqrcode == 1) {
// Check the token.
if ($secrethash !== $_COOKIE[$cookiename]) {
// Flag error.
print_error('qr_cookie_error', 'mod_attendance', $url);
throw new moodle_exception('qr_cookie_error', 'mod_attendance', $url);
}
} else {
// Check password.
@ -73,7 +73,7 @@ if ($attforsession->rotateqrcode == 1) {
setcookie($cookiename, $secrethash, time() + (60 * 5), "/");
} else {
// Flag error.
print_error('qr_pass_wrong', 'mod_attendance', $url);
throw new moodle_exception('qr_pass_wrong', 'mod_attendance', $url);
}
}
}
@ -103,7 +103,7 @@ if ($attforsession->autoassignstatus && (empty($attforsession->studentpassword))
$statusid = attendance_session_get_highest_status($att, $attforsession);
$url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id));
if (empty($statusid)) {
print_error('attendance_no_status', 'mod_attendance', $url);
throw new moodle_exception('attendance_no_status', 'mod_attendance', $url);
}
$take = new stdClass();
$take->status = $statusid;
@ -114,7 +114,7 @@ if ($attforsession->autoassignstatus && (empty($attforsession->studentpassword))
// Redirect back to the view page.
redirect($url, get_string('studentmarked', 'attendance'));
} else {
print_error('attendance_already_submitted', 'mod_attendance', $url);
throw new moodle_exception('attendance_already_submitted', 'mod_attendance', $url);
}
}
@ -136,7 +136,7 @@ if (!empty($qrpass) && !empty($attforsession->autoassignstatus)) {
$fromform->status = attendance_session_get_highest_status($att, $attforsession);
if (empty($fromform->status)) {
$url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id));
print_error('attendance_no_status', 'mod_attendance', $url);
throw new moodle_exception('attendance_no_status', 'mod_attendance', $url);
}
if (!empty($fromform->status)) {
@ -147,7 +147,7 @@ if (!empty($qrpass) && !empty($attforsession->autoassignstatus)) {
// Redirect back to the view page.
redirect($url, get_string('studentmarked', 'attendance'));
} else {
print_error('attendance_already_submitted', 'mod_attendance', $url);
throw new moodle_exception('attendance_already_submitted', 'mod_attendance', $url);
}
}
}
@ -181,7 +181,7 @@ if ($mform->is_cancelled()) {
$fromform->status = attendance_session_get_highest_status($att, $attforsession);
if (empty($fromform->status)) {
$url = new moodle_url('/mod/attendance/view.php', array('id' => $cm->id));
print_error('attendance_no_status', 'mod_attendance', $url);
throw new moodle_exception('attendance_no_status', 'mod_attendance', $url);
}
}
@ -193,7 +193,7 @@ if ($mform->is_cancelled()) {
// Redirect back to the view page.
redirect($url, get_string('studentmarked', 'attendance'));
} else {
print_error('attendance_already_submitted', 'mod_attendance', $url);
throw new moodle_exception('attendance_already_submitted', 'mod_attendance', $url);
}
}

4
classes/structure.php

@ -550,7 +550,7 @@ class mod_attendance_structure {
global $DB;
if (!$sess = $DB->get_record('attendance_sessions', array('id' => $sessionid) )) {
print_error('No such session in this course');
throw new moodle_exception('No such session in this course');
}
$sesstarttime = $formdata->sestime['starthour'] * HOURSECS + $formdata->sestime['startminute'] * MINSECS;
@ -720,7 +720,7 @@ class mod_attendance_structure {
if (substr($key, 0, 7) == 'remarks') {
$sid = substr($key, 7);
if (!(is_numeric($sid))) { // Sanity check on $sid.
print_error('nonnumericid', 'attendance');
throw new moodle_exception('nonnumericid', 'attendance');
}
$sesslog[$sid] = new stdClass();
$sesslog[$sid]->studentid = $sid; // We check is_numeric on this above.

1
db/upgrade.php

@ -650,6 +650,5 @@ function xmldb_attendance_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2021050700, 'attendance');
}
return $result;
}

4
export.php

@ -132,7 +132,7 @@ if ($formdata = $mform->get_data()) {
}
}
} else {
print_error('sessionsnotfound', 'attendance', $att->url_manage());
throw new moodle_exception('sessionsnotfound', 'mod_attendance', $att->url_manage());
}
$setnumber = -1;
@ -207,7 +207,7 @@ if ($formdata = $mform->get_data()) {
}
exit;
} else {
print_error('studentsnotfound', 'attendance', $att->url_manage());
throw new moodle_exception('studentsnotfound', 'mod_attendance', $att->url_manage());
}
}

5
messageselect.php

@ -56,9 +56,8 @@ if (!empty($messagebody['text'])) {
$messagebody = $messagebody['text'];
}
$PAGE->set_url($url);
if (!$course = $DB->get_record('course', array('id' => $id))) {
print_error('invalidcourseid');
}
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
require_login($course);
$coursecontext = context_course::instance($id); // Course context.
$systemcontext = context_system::instance(); // SYSTEM context.

2
preferences.php

@ -93,7 +93,7 @@ switch ($att->pageparams->action) {
break;
case mod_attendance_preferences_page_params::ACTION_DELETE:
if (attendance_has_logs_for_status($att->pageparams->statusid)) {
print_error('cantdeletestatus', 'attendance', "attsettings.php?id=$id");
throw new moodle_exception('cantdeletestatus', 'attendance', "attsettings.php?id=$id");
}
$confirm = optional_param('confirm', null, PARAM_INT);

4
renderables.php

@ -583,11 +583,11 @@ class attendance_user_data implements renderable {
$parts = explode('sess', substr($key, 7));
$stid = $parts[0];
if (!(is_numeric($stid))) { // Sanity check on $stid.
print_error('nonnumericid', 'attendance');
throw new moodle_exception('nonnumericid', 'attendance');
}
$sessid = $parts[1];
if (!(is_numeric($sessid))) { // Sanity check on $sessid.
print_error('nonnumericid', 'attendance');
throw new moodle_exception('nonnumericid', 'attendance');
}
$dbsession = $this->sessionslog[$sessid];

4
sessions.php

@ -148,7 +148,7 @@ switch ($att->pageparams->action) {
}
$sessid = optional_param_array('sessid', '', PARAM_SEQUENCE);
if (empty($sessid)) {
print_error('nosessionsselected', 'attendance', $att->url_manage());
throw new moodle_exception('nosessionsselected', 'mod_attendance', $att->url_manage());
}
$sessionsinfo = $att->get_sessions_info($sessid);
@ -191,7 +191,7 @@ switch ($att->pageparams->action) {
}
if ($slist === '') {
print_error('nosessionsselected', 'attendance', $att->url_manage());
throw new moodle_exception('nosessionsselected', 'mod_attendance', $att->url_manage());
}
break;

2
warnings.php

@ -107,7 +107,7 @@ if ($data = $mform->get_data()) {
$notify = $DB->get_record('attendance_warning', array('id' => $data->notid));
if (!empty($id) && $data->idnumber != $att->id) {
// Someone is trying to update a record for a different attendance.
print_error('invalidcoursemodule');
throw new moodle_exception('invalidcoursemodule');
} else {
$notify = new stdClass();
$notify->id = $data->notid;

Loading…
Cancel
Save