Commit 4c0bf256 authored by Evan Goldenberg's avatar Evan Goldenberg
Browse files

don't allow a stop date in the past (bug #518595)


Signed-off-by: default avatarEvan Goldenberg <evang@catalyst.net.nz>
parent e3b870b9
......@@ -39,6 +39,7 @@ $string['title'] = 'View Title';
$string['description'] = 'View Description';
$string['startdate'] = 'Access Start Date/Time';
$string['stopdate'] = 'Access End Date/Time';
$string['stopdatecannotbeinpast'] = 'The stop date cannot be in the past';
$string['startdatemustbebeforestopdate'] = 'The start date must be before the stop date';
$string['unrecogniseddateformat'] = 'Unrecognised date format';
$string['ownerformat'] = 'Name display format';
......
......@@ -310,6 +310,12 @@ function editaccess_validate(Pieform $form, $values) {
if ($item['type'] == 'loggedin' && !$item['startdate'] && !$item['stopdate']) {
$loggedinaccess = true;
}
$now = strptime(date('Y/m/d H:i'), $dateformat);
if ($item['stopdate'] && ptimetotime($now) > ptimetotime($item['stopdate'])) {
$SESSION->add_error_msg(get_string('stopdatecannotbeinpast', 'view'));
$form->set_error('accesslist', '');
break;
}
if ($item['startdate'] && $item['stopdate'] && ptimetotime($item['startdate']) > ptimetotime($item['stopdate'])) {
$SESSION->add_error_msg(get_string('startdatemustbebeforestopdate', 'view'));
$form->set_error('accesslist', '');
......
Markdown is supported
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