From: sam_marshall Date: Thu, 15 Jan 2009 14:30:19 +0000 (+0000) Subject: MDL-17914: Conditional activities should check that available dates in module form... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a561d96ee260bf7dc57cfd63ec85577b1ab12c64;p=moodle.git MDL-17914: Conditional activities should check that available dates in module form are not stupid --- diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index 3507f28c97..2a0283e057 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -248,6 +248,13 @@ class moodleform_mod extends moodleform { } } + // Conditions: Don't let them set dates which make no sense + if (array_key_exists('availablefrom', $data) && + $data['availablefrom'] && $data['availableuntil'] && + $data['availablefrom']>=$data['availableuntil']) { + $errors['availablefrom'] = get_string('badavailabledates', 'condition'); + } + return $errors; } diff --git a/lang/en_utf8/condition.php b/lang/en_utf8/condition.php index b2d1e2d95e..eb5ebb9a92 100644 --- a/lang/en_utf8/condition.php +++ b/lang/en_utf8/condition.php @@ -4,6 +4,7 @@ $string['addcompletions']='Add {no} activity conditions to form'; $string['availabilityconditions']='Restrict availability'; $string['availablefrom']='Only available from'; $string['availableuntil']='Only available until'; +$string['badavailabledates']='Invalid dates. If you set both dates, the \'available from\' date should be before the \'until\' date.'; $string['completion_complete']=' must be marked complete'; $string['completion_incomplete']=' must not be marked complete'; $string['completion_pass']=' must be complete with pass grade';