Skip to content

Commit

Permalink
MDL-21781 fixed idnumber validation - thanks David for spotting the p…
Browse files Browse the repository at this point in the history
…roblem
  • Loading branch information
skodak committed May 31, 2010
1 parent 05a5434 commit 0defeb1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cohort/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ public function validation($data, $files) {
$errors = parent::validation($data, $files);

$idnumber = trim($data['idnumber']);
if ($data['id']) {
if ($idnumber === '') {
// fine, empty is ok

} else if ($data['id']) {
$current = $DB->get_record('cohort', array('id'=>$data['id']), '*', MUST_EXIST);
if ($current->idnumber !== $idnumber) {
if ($DB->record_exists('cohort', array('idnumber'=>$idnumber))) {
$errors['idnumber'] = get_string('duplicateidnumber', 'cohort');
}
}

} else {
if ($DB->record_exists('cohort', array('idnumber'=>$idnumber))) {
$errors['idnumber'] = get_string('duplicateidnumber', 'cohort');
Expand Down Expand Up @@ -105,4 +109,4 @@ protected function get_category_options($currentcontextid) {
return $options;
}
}

0 comments on commit 0defeb1

Please sign in to comment.