Commit fc686a86 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix startdate/stopdate error message caused by bad date comparison (bug #502408)


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 15796c10
......@@ -292,12 +292,30 @@ function editaccess_validate(Pieform $form, $values) {
if ($item['type'] == 'loggedin' && !$item['startdate'] && !$item['stopdate']) {
$loggedinaccess = true;
}
if ($item['startdate'] && $item['stopdate'] && $item['startdate'] > $item['stopdate']) {
if ($item['startdate'] && $item['stopdate']) {
$starttime = mktime(
$item['startdate']['tm_hour'],
$item['startdate']['tm_min'],
$item['startdate']['tm_sec'],
1,
$item['startdate']['tm_yday'] + 1,
$item['startdate']['tm_year'] + 1900
);
$stoptime = mktime(
$item['stopdate']['tm_hour'],
$item['stopdate']['tm_min'],
$item['stopdate']['tm_sec'],
1,
$item['stopdate']['tm_yday'] + 1,
$item['stopdate']['tm_year'] + 1900
);
if ($starttime > $stoptime) {
$form->set_error('accesslist', get_string('startdatemustbebeforestopdate', 'view'));
break;
}
}
}
}
// Must have logged in user access for copy new user/group settings.
if (($createforgroup || ($institution && $values['copynewuser'])) && !$loggedinaccess) {
$form->set_error('accesslist', get_string('copynewusergroupneedsloggedinaccess', 'view'));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment