From: gustav_delius Date: Thu, 6 May 2004 16:30:12 +0000 (+0000) Subject: It is possible to create weekly repeating events but it is not yet possible to edit... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f86aaab21c9f0d3fd19f1ea4b7efa44a1248b2be;p=moodle.git It is possible to create weekly repeating events but it is not yet possible to edit or delete them together. Also it is now possible to specify the duration in minutes as an alternative to specifying the end time and date. --- diff --git a/calendar/event.php b/calendar/event.php index 83d98df884..eabd3dfe70 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -145,6 +145,9 @@ $form->timeduration = 0; } } + else if ($form->duration == 2) { + $form->timeduration = $form->minutes * 60; + } else { $form->timeduration = 0; } @@ -160,7 +163,17 @@ /// Log the event entry. add_to_log($form->courseid, 'calendar', 'add', 'event.php?action=edit&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&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); diff --git a/calendar/event_edit.html b/calendar/event_edit.html index d5e41bc302..35bc369c25 100644 --- a/calendar/event_edit.html +++ b/calendar/event_edit.html @@ -1,39 +1 @@ -
- - - - - - - - - - - - - - - - - - - - -
:
: - description); - if (isset($err['description'])) formerr($err['description']); - ?> -
:timestart);?> timestart) ?>
: -
duration == 0) echo 'checked="checked"'; ?>/>
-
duration == 1) echo 'checked="checked"'; ?>/> - timestart + $form->timeduration);?> timestart + $form->timeduration) ?> -
-

-

- - - - -

-
+
:
: description); if (isset($err['description'])) formerr($err['description']); ?>
: timestart);?> timestart) ?>
:
duration == 0) echo 'checked="checked"'; ?>/>
duration == 1) echo 'checked="checked"'; ?>/> timestart + $form->timeduration);?> timestart + $form->timeduration) ?>
duration == 2) echo 'checked="checked"'; ?>/>

\ No newline at end of file diff --git a/calendar/event_new.html b/calendar/event_new.html index 0ffab15a9e..a4072ec8ae 100644 --- a/calendar/event_new.html +++ b/calendar/event_new.html @@ -1,44 +1 @@ -
- - - - - - - - - - - - - - - - - - - - -
:
: - description); - if (isset($err['description'])) formerr($err['description']); - ?> -
:timestart);?> timestart) ?>
: -
duration == 0) echo 'checked="checked"'; ?>/>
-
duration == 1) echo 'checked="checked"'; ?>/> - timestart + $form->timeduration);?> timestart + $form->timeduration) ?> -
-

-

- - - - - - - - - -

-
+
:
: description); if (isset($err['description'])) formerr($err['description']); ?>
: timestart);?> timestart) ?>
:
duration == 0) echo 'checked="checked"'; ?>/>
duration == 1) echo 'checked="checked"'; ?>/> timestart + $form->timeduration);?> timestart + $form->timeduration) ?>
duration == 2) echo 'checked="checked"'; ?>/>
:
repeat == 0) echo 'checked="checked"'; ?>/>
repeat == 1) echo 'checked="checked"'; ?>/>

\ No newline at end of file diff --git a/lang/en/calendar.php b/lang/en/calendar.php index aabcd161fe..30afb567eb 100644 --- a/lang/en/calendar.php +++ b/lang/en/calendar.php @@ -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)';