]> git.mjollnir.org Git - moodle.git/commitdiff
It is possible to create weekly repeating events but it is not yet possible to edit...
authorgustav_delius <gustav_delius>
Thu, 6 May 2004 16:30:12 +0000 (16:30 +0000)
committergustav_delius <gustav_delius>
Thu, 6 May 2004 16:30:12 +0000 (16:30 +0000)
calendar/event.php
calendar/event_edit.html
calendar/event_new.html
lang/en/calendar.php

index 83d98df884b9b450d30632e0df8ea8f8edf90074..eabd3dfe70c8cc32ce27d4075512201c1b825ff4 100644 (file)
                         $form->timeduration = 0;
                     }
                 }
+                else if ($form->duration == 2) {
+                    $form->timeduration = $form->minutes * 60;
+                }
                 else {
                     $form->timeduration = 0;
                 }
 
                     /// Log the event entry.
                     add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id='.$eventid, $form->name);
-
+                    
+                    if ($form->repeat) {
+                        for($i = 1; $i < $form->repeats; $i++) {
+                            $form->timestart += 604800;  // add one week
+                            /// Get the event id for the log record.
+                            $eventid = insert_record('event', $form, true);
+                            /// Log the event entry.
+                            add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&amp;id='.$eventid, $form->name);
+                        }
+                    }
+                            
                     // OK, now redirect to day view
                     redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$form->startday.'&cal_m='.$form->startmon.'&cal_y='.$form->startyr);
                 }
@@ -430,9 +443,15 @@ function validate_form(&$form, &$err) {
     if(!checkdate($form->startmon, $form->startday, $form->startyr)) {
         $err['timestart'] = get_string('errorinvaliddate', 'calendar');
     }
-    if(!checkdate($form->endmon, $form->endday, $form->endyr)) {
+    if($form->duration == 2 and !checkdate($form->endmon, $form->endday, $form->endyr)) {
         $err['timeduration'] = get_string('errorinvaliddate', 'calendar');
     }
+    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)) {
+        $err['repeats'] = get_string('errorinvalidrepeats', 'calendar');
+    }
     if(!empty($form->courseid)) {
         // Timestamps must be >= course startdate
         $course = get_record('course', 'id', $form->courseid);
index d5e41bc30275e29ef2a62f636010c7a0b52e9292..35bc369c25008ce1723e86572df547467da67d7b 100644 (file)
@@ -1,39 +1 @@
-<form method="post" action="event.php" name="edit">\r
-<table cellpadding=5>\r
-  <tr>\r
-    <td style="vertical-align: top; text-align: right;"><?php print_string('eventname', 'calendar'); ?>:</td>\r
-    <td><input type="text" name="name" size="67" value="<?php p($form->name); ?>" /> <?php if (isset($err['name'])) formerr($err['name']); ?></td>\r
-  </tr>\r
-  <tr>\r
-    <td style="vertical-align: top; text-align: right;"><?php print_string('eventdescription', 'calendar'); ?>:</td>\r
-    <td>\r
-    <?php \r
-        print_textarea($usehtmleditor, 25, 65, 630, 400, "description", $form->description);\r
-        if (isset($err['description'])) formerr($err['description']); \r
-    ?>\r
-    </td>\r
-  </tr>\r
-  <tr>\r
-    <td style="vertical-align: top; text-align: right;"><?php print_string('eventdate', 'calendar'); ?>:</td>\r
-    <td><?php print_date_selector('startday', 'startmon', 'startyr', $form->timestart);?> <?php print_string('eventtime', 'calendar');?> <?php print_time_selector('starthr', 'startmin', $form->timestart) ?>  <?php if (isset($err['timestart'])) formerr($err['timestart']); ?></td>\r
-  </tr>\r
-  <tr>\r
-    <td style="vertical-align: top; text-align: right;"><?php print_string('eventduration', 'calendar'); ?>:</td>\r
-    <td>\r
-      <div><input type="radio" name="duration" value="0" id="duration_none" <?php if($form->duration == 0) echo 'checked="checked"'; ?>/><label for="duration_none"><?php print_string('durationnone', 'calendar'); ?></label></div>\r
-      <div><input type="radio" name="duration" value="1" id="duration_yes" <?php if($form->duration == 1) echo 'checked="checked"'; ?>/><label for="duration_yes"><?php print_string('durationuntil', 'calendar'); ?></label>\r
-        <?php print_date_selector('endday', 'endmon', 'endyr', $form->timestart + $form->timeduration);?> <?php print_string('eventtime', 'calendar');?> <?php print_time_selector('endhr', 'endmin', $form->timestart + $form->timeduration) ?>  <?php if (isset($err['timeduration'])) formerr($err['timeduration']); ?>\r
-      </div>\r
-    </td>\r
-  </tr>\r
-  <tr>\r
-    <td align="center" colspan="2"><p><input type="submit" value="<?php print_string('savechanges') ?>"></p></td>\r
-  </tr>\r
-</table>\r
-<p>\r
-<input type="hidden" name="id" value="<?php echo $form->id; ?>" />\r
-<input type="hidden" name="courseid" value="<?php echo $form->courseid; ?>" />\r
-<input type="hidden" name="format" value="<?php echo $form->format; ?>" />\r
-<input type="hidden" name="action" value="edit" />\r
-</p>\r
-</form>\r
+<form method="post" action="event.php" name="edit">\r<table cellpadding=5>\r  <tr>\r    <td style="vertical-align: top; text-align: right;">\r      <?php print_string('eventname', 'calendar'); ?>:\r    </td>\r    <td>\r      <input type="text" name="name" size="67" value="<?php p($form->name); ?>" /> \r      <?php if (isset($err['name'])) formerr($err['name']); ?>\r    </td>\r  </tr>\r  <tr>\r    <td style="vertical-align: top; text-align: right;">\r      <?php print_string('eventdescription', 'calendar'); ?>:\r    </td>\r    <td>\r      <?php \r          print_textarea($usehtmleditor, 10, 65, 630, 400, "description", $form->description);\r          if (isset($err['description'])) formerr($err['description']); \r      ?>\r    </td>\r  </tr>\r  <tr>\r    <td style="vertical-align: top; text-align: right;"><?php print_string('eventdate', 'calendar'); ?>:</td>\r    <td>\r      <?php print_date_selector('startday', 'startmon', 'startyr', $form->timestart);?> \r      <?php print_string('eventtime', 'calendar');?> \r      <?php print_time_selector('starthr', 'startmin', $form->timestart) ?>  \r      <?php if (isset($err['timestart'])) formerr($err['timestart']); ?>\r    </td>\r  </tr>\r  <tr>\r    <td style="vertical-align: top; text-align: right;">\r      <?php print_string('eventduration', 'calendar'); ?>:\r    </td>\r    <td>\r      <div>\r        <input type="radio" name="duration" value="0" id="duration_none" <?php if($form->duration == 0) echo 'checked="checked"'; ?>/>\r        <label for="duration_none">\r          <?php print_string('durationnone', 'calendar'); ?>\r        </label>\r      </div>\r      <div>\r        <input type="radio" name="duration" value="1" id="duration_yes" <?php if($form->duration == 1) echo 'checked="checked"'; ?>/>\r        <label for="duration_yes">\r          <?php print_string('durationuntil', 'calendar'); ?>\r        </label>\r        <?php print_date_selector('endday', 'endmon', 'endyr', $form->timestart + $form->timeduration);?> \r        <?php print_string('eventtime', 'calendar');?> \r        <?php print_time_selector('endhr', 'endmin', $form->timestart + $form->timeduration) ?>  \r        <?php if (isset($err['timeduration'])) formerr($err['timeduration']); ?>\r      </div>\r      <div>\r        <input type="radio" name="duration" value="2" id="duration_minutes" <?php if($form->duration == 2) echo 'checked="checked"'; ?>/>\r        <label for="duration_minutes"><?php print_string('durationminutes', 'calendar'); ?></label>\r        <input type="text" name="minutes" size="3" value="<?php p($form->minutes); ?>" /> \r        <?php if (isset($err['minutes'])) formerr($err['minutes']); ?>\r      </div>\r    </td>\r  </tr>\r  <tr>\r    <td align="center" colspan="2"><p><input type="submit" value="<?php print_string('savechanges') ?>"></p></td>\r  </tr>\r</table>\r<p>\r<input type="hidden" name="id" value="<?php echo $form->id; ?>" />\r<input type="hidden" name="courseid" value="<?php echo $form->courseid; ?>" />\r<input type="hidden" name="format" value="<?php echo $form->format; ?>" />\r<input type="hidden" name="action" value="edit" />\r</p>\r</form>\r
\ No newline at end of file
index 0ffab15a9ee25134f5b780532919a21b388e11bf..a4072ec8aecf04d0d579afad429fd06df3b3c7ea 100644 (file)
@@ -1,44 +1 @@
-<form method="post" action="event.php" name="new">\r
-<table cellpadding=5>\r
-  <tr>\r
-    <td style="vertical-align: top; text-align: right;"><?php print_string('eventname', 'calendar'); ?>:</td>\r
-    <td><input type="text" name="name" size="67" value="<?php p($form->name); ?>" /> <?php if (isset($err['name'])) formerr($err['name']); ?></td>\r
-  </tr>\r
-  <tr>\r
-    <td style="vertical-align: top; text-align: right;"><?php print_string('eventdescription', 'calendar'); ?>:</td>\r
-    <td>\r
-    <?php \r
-        print_textarea($usehtmleditor, 10, 65, 630, 200, "description", $form->description);\r
-        if (isset($err['description'])) formerr($err['description']); \r
-    ?>\r
-    </td>\r
-  </tr>\r
-  <tr>\r
-    <td style="vertical-align: top; text-align: right;"><?php print_string('eventdate', 'calendar'); ?>:</td>\r
-    <td><?php print_date_selector('startday', 'startmon', 'startyr', $form->timestart);?> <?php print_string('eventtime', 'calendar');?> <?php print_time_selector('starthr', 'startmin', $form->timestart) ?>  <?php if (isset($err['timestart'])) formerr($err['timestart']); ?></td>\r
-  </tr>\r
-  <tr>\r
-    <td style="vertical-align: top; text-align: right;"><?php print_string('eventduration', 'calendar'); ?>:</td>\r
-    <td>\r
-      <div><input type="radio" name="duration" value="0" id="duration_none" <?php if($form->duration == 0) echo 'checked="checked"'; ?>/><label for="duration_none"><?php print_string('durationnone', 'calendar'); ?></label></div>\r
-      <div><input type="radio" name="duration" value="1" id="duration_yes" <?php if($form->duration == 1) echo 'checked="checked"'; ?>/><label for="duration_yes"><?php print_string('durationuntil', 'calendar'); ?></label>\r
-        <?php print_date_selector('endday', 'endmon', 'endyr', $form->timestart + $form->timeduration);?> <?php print_string('eventtime', 'calendar');?> <?php print_time_selector('endhr', 'endmin', $form->timestart + $form->timeduration) ?>  <?php if (isset($err['timeduration'])) formerr($err['timeduration']); ?>\r
-      </div>\r
-    </td>\r
-  </tr>\r
-  <tr>\r
-    <td align="center" colspan="2"><p><input type="submit" value="<?php print_string('savechanges') ?>"></p></td>\r
-  </tr>\r
-</table>\r
-<p>\r
-<input type="hidden" name="courseid" value="<?php echo $form->courseid?>" />\r
-<input type="hidden" name="groupid" value="<?php echo $form->groupid?>" />\r
-<input type="hidden" name="userid" value="<?php echo $form->userid?>" />\r
-<input type="hidden" name="modulename" value="<?php echo $form->modulename?>" />\r
-<input type="hidden" name="eventtype" value="<?php echo $form->eventtype?>" />\r
-<input type="hidden" name="instance" value="<?php echo $form->instance?>" />\r
-<input type="hidden" name="format" value="<?php echo $form->format; ?>" />\r
-<input type="hidden" name="action" value="new" />\r
-<input type="hidden" name="type" value="defined" />\r
-</p>\r
-</form>\r
+<form method="post" action="event.php" name="new">\r<table cellpadding=5>\r  <tr>\r    <td style="vertical-align: top; text-align: right;">\r      <?php print_string('eventname', 'calendar'); ?>:\r    </td>\r    <td>\r      <input type="text" name="name" size="67" value="<?php p($form->name); ?>" /> \r      <?php if (isset($err['name'])) formerr($err['name']); ?>\r    </td>\r  </tr>\r  <tr>\r    <td style="vertical-align: top; text-align: right;">\r      <?php print_string('eventdescription', 'calendar'); ?>:\r    </td>\r    <td>\r    <?php \r        print_textarea($usehtmleditor, 10, 65, 630, 200, "description", $form->description);\r        if (isset($err['description'])) formerr($err['description']); \r    ?>\r    </td>\r  </tr>\r  <tr>\r    <td style="vertical-align: top; text-align: right;">\r      <?php print_string('eventdate', 'calendar'); ?>:\r    </td>\r    <td>\r      <?php print_date_selector('startday', 'startmon', 'startyr', $form->timestart);?> \r      <?php print_string('eventtime', 'calendar');?> \r      <?php print_time_selector('starthr', 'startmin', $form->timestart) ?>  \r      <?php if (isset($err['timestart'])) formerr($err['timestart']); ?>\r    </td>\r  </tr>\r  <tr>\r    <td style="vertical-align: top; text-align: right;">\r      <?php print_string('eventduration', 'calendar'); ?>:\r    </td>\r    <td>\r      <div>\r        <input type="radio" name="duration" value="0" id="duration_none" <?php if($form->duration == 0) echo 'checked="checked"'; ?>/>\r        <label for="duration_none"><?php print_string('durationnone', 'calendar'); ?></label>\r      </div>\r      <div>\r        <input type="radio" name="duration" value="1" id="duration_yes" <?php if($form->duration == 1) echo 'checked="checked"'; ?>/>\r        <label for="duration_yes"><?php print_string('durationuntil', 'calendar'); ?></label>\r        <?php print_date_selector('endday', 'endmon', 'endyr', $form->timestart + $form->timeduration);?> \r        <?php print_string('eventtime', 'calendar');?> \r        <?php print_time_selector('endhr', 'endmin', $form->timestart + $form->timeduration) ?>  \r        <?php if (isset($err['timeduration'])) formerr($err['timeduration']); ?>\r      </div>\r      <div>\r        <input type="radio" name="duration" value="2" id="duration_minutes" <?php if($form->duration == 2) echo 'checked="checked"'; ?>/>\r        <label for="duration_minutes"><?php print_string('durationminutes', 'calendar'); ?></label>\r        <input type="text" name="minutes" size="3" value="<?php p($form->minutes); ?>" /> \r        <?php if (isset($err['minutes'])) formerr($err['minutes']); ?>\r      </div>\r    </td>\r  </tr>\r\r  <tr>\r    <td style="vertical-align: top; text-align: right;">\r      <?php print_string('eventrepeat', 'calendar'); ?>:\r    </td>\r    <td>\r      <div>\r        <input type="radio" name="repeat" value="0" id="repeat_none" <?php if($form->repeat == 0) echo 'checked="checked"'; ?>/>\r        <label for="repeat_none">\r          <?php print_string('repeatnone', 'calendar'); ?>\r        </label>\r      </div>\r      <div>\r        <input type="radio" name="repeat" value="1" id="repeat_yes" <?php if($form->repeat == 1) echo 'checked="checked"'; ?>/>\r        <label for="repeat_yes">\r          <?php print_string('repeatweeksl', 'calendar'); ?>\r        </label>\r        <input type="text" name="repeats" size="2" value="<?php p($form->repeats); ?>" /> \r        <?php print_string('repeatweeksr', 'calendar'); ?>\r        <?php if (isset($err['repeats'])) formerr($err['repeats']); ?>\r      </div>\r    </td>\r  </tr>\r\r  <tr>\r    <td align="center" colspan="2"><p><input type="submit" value="<?php print_string('savechanges') ?>"></p></td>\r  </tr>\r</table>\r<p>\r<input type="hidden" name="courseid" value="<?php echo $form->courseid?>" />\r<input type="hidden" name="groupid" value="<?php echo $form->groupid?>" />\r<input type="hidden" name="userid" value="<?php echo $form->userid?>" />\r<input type="hidden" name="modulename" value="<?php echo $form->modulename?>" />\r<input type="hidden" name="eventtype" value="<?php echo $form->eventtype?>" />\r<input type="hidden" name="instance" value="<?php echo $form->instance?>" />\r<input type="hidden" name="format" value="<?php echo $form->format; ?>" />\r<input type="hidden" name="action" value="new" />\r<input type="hidden" name="type" value="defined" />\r</p>\r</form>\r
\ No newline at end of file
index aabcd161fe091efa206004ca5992c5d2c1652087..30afb567eb1f4882aba024d651404ab1fbf63cdd 100644 (file)
@@ -11,11 +11,14 @@ $string['daywithnoevents'] = 'There are no events this day.';
 $string['default'] = 'Default';
 $string['deleteevent'] = 'Delete event';
 $string['detailedmonthview'] = 'Detailed Month View';
+$string['durationminutes'] = 'Duration in minutes:';
 $string['durationnone'] = 'Without duration';
 $string['durationuntil'] = 'Until';
 $string['editevent'] = 'Editing event';
 $string['errorbeforecoursestart'] = 'Cannot set event before course start date';
 $string['errorinvaliddate'] = 'Invalid date';
+$string['errorinvalidminutes'] = 'Specify duration in minutes by giving a number between 1 and 999.';
+$string['errorinvalidrepeats'] = 'Specify the number of events by giving a number between 1 and 99.';
 $string['errornodescription'] = 'Description is required';
 $string['errornoeventname'] = 'Name is required';
 $string['eventdate'] = 'Date';
@@ -25,6 +28,7 @@ $string['eventendtime'] = 'End time';
 $string['eventinstanttime'] = 'Time';
 $string['eventkind'] = 'Type of event';
 $string['eventname'] = 'Name';
+$string['eventrepeat'] = 'Repeats';
 $string['eventsfor'] = '$a events';
 $string['eventstarttime'] = 'Start time';
 $string['eventtime'] = 'Time';
@@ -48,6 +52,9 @@ $string['pref_startwday'] = 'First day of week';
 $string['pref_timeformat'] = 'Time display format';
 $string['preferences'] = 'Preferences';
 $string['preferences_available'] = 'Your personal preferences';
+$string['repeatnone'] = 'No repeats';
+$string['repeatweeksl'] = 'Repeat weekly, creating altogether ';
+$string['repeatweeksr'] = 'events';
 $string['shown'] = 'shown';
 $string['spanningevents'] = 'Events underway';
 $string['timeformat_12'] = '12-hour (am/pm)';