]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed a bug where editing an event did display the "duration in minutes"
authordefacer <defacer>
Mon, 24 May 2004 10:49:01 +0000 (10:49 +0000)
committerdefacer <defacer>
Mon, 24 May 2004 10:49:01 +0000 (10:49 +0000)
stuff, but totally ignored it when submitting changes. Also, fixed one
warning in the "minutes" field.

calendar/event.php

index 1d59d4388c5ec78cc5d7657ad4a43819bd486007..32574790036f5ed6c29da1d3e8af04684d30a26e 100644 (file)
                         $form->timeduration = 0;
                     }
                 }
+                else if($form->duration == 2) {
+                    $form->timeduration = $form->minutes * 60;
+                }
                 else {
                     $form->timeduration = 0;
                 }
                 $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)) {