From fbb56b9db755be8b542826841b2db9687377746f Mon Sep 17 00:00:00 2001 From: defacer Date: Mon, 24 May 2004 10:49:01 +0000 Subject: [PATCH] Fixed a bug where editing an event did display the "duration in minutes" stuff, but totally ignored it when submitting changes. Also, fixed one warning in the "minutes" field. --- calendar/event.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/calendar/event.php b/calendar/event.php index 1d59d4388c..3257479003 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -104,6 +104,9 @@ $form->timeduration = 0; } } + else if($form->duration == 2) { + $form->timeduration = $form->minutes * 60; + } else { $form->timeduration = 0; } @@ -245,11 +248,20 @@ $form->timeduration = $event->timeduration; $form->id = $event->id; $form->format = $defaultformat; - if($event->timeduration) { + if($event->timeduration > 3600) { + // More than one hour, so default to normal duration mode $form->duration = 1; + $form->minutes = ''; + } + else if($event->timeduration) { + // Up to one hour, "minutes" mode probably is better here + $form->duration = 2; + $form->minutes = $event->timeduration / 60; } else { + // No duration $form->duration = 0; + $form->minutes = ''; } } print_side_block_start(get_string('editevent', 'calendar'), '', 'mycalendar'); @@ -469,7 +481,7 @@ function validate_form(&$form, &$err) { if($form->duration == 2 and !($form->minutes > 0 and $form->minutes < 1000)) { $err['minutes'] = get_string('errorinvalidminutes', 'calendar'); } - if ($form->repeat and !($form->repeats > 1 and $form->repeats < 100)) { + if (!empty($form->repeat) and !($form->repeats > 1 and $form->repeats < 100)) { $err['repeats'] = get_string('errorinvalidrepeats', 'calendar'); } if(!empty($form->courseid)) { -- 2.39.5