Skip to content

Commit

Permalink
Improvement: Take out coursevalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
georgmaisser committed Jul 12, 2024
1 parent b2bfcb7 commit 8668d63
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions classes/option/fields/courseid.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,44 +135,6 @@ public static function validation(array $data, array $files, array &$errors) {
$data['courseid'] = reset($data['courseid']);
}

// Minus 1 (-1) means we need to create a new course, that's ok.
if (!empty($data['courseid']) && $data['courseid'] != -1) {
if (!$DB->record_exists('course', ['id' => $data['courseid']])) {
$errors['courseid'] = get_string('coursedoesnotexist', 'mod_booking', $data['courseid']);
}
}

// First, we check, if user chose to automatically create a new moodle course.
if (isset($data['courseid']) && $data['courseid'] == -1) {
if (wb_payment::pro_version_is_activated()) {

// URLs needed for error message.
$bookingcustomfieldsurl = new moodle_url('/mod/booking/customfield.php');
$settingsurl = new moodle_url('/admin/settings.php', ['section' => 'modsettingbooking']);

// Object for string.
$a = new stdClass;
$a->bookingcustomfieldsurl = $bookingcustomfieldsurl->out(false);
$a->settingsurl = $settingsurl->out(false);

if (get_config('booking', 'newcoursecategorycfield') == "-1" ||
empty(get_config('booking', 'newcoursecategorycfield'))) {
$errors['courseid'] = get_string('error:newcoursecategorycfieldmissing', 'mod_booking', $a);
} else {
// A custom field for the category for automatically created new Moodle courses has been set.
$newcoursecategorycfield = get_config('booking', 'newcoursecategorycfield');

// So now we need to check, if a value for that custom field was set to in option form.
if (empty($data["customfield_$newcoursecategorycfield"])) {
$errors["customfield_$newcoursecategorycfield"] =
get_string('error:coursecategoryvaluemissing', 'mod_booking');
}
}
} else {
$errors['courseid'] = get_string('infotext:prolicensenecessary', 'mod_booking');
}
}

return $errors;
}

Expand Down

0 comments on commit 8668d63

Please sign in to comment.