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.
This commit is contained in:
+21
-2
@@ -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);
|
||||
|
||||
@@ -1,39 +1 @@
|
||||
<form method="post" action="event.php" name="edit">
|
||||
<table cellpadding=5>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventname', 'calendar'); ?>:</td>
|
||||
<td><input type="text" name="name" size="67" value="<?php p($form->name); ?>" /> <?php if (isset($err['name'])) formerr($err['name']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventdescription', 'calendar'); ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
print_textarea($usehtmleditor, 25, 65, 630, 400, "description", $form->description);
|
||||
if (isset($err['description'])) formerr($err['description']);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventdate', 'calendar'); ?>:</td>
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventduration', 'calendar'); ?>:</td>
|
||||
<td>
|
||||
<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>
|
||||
<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>
|
||||
<?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']); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan="2"><p><input type="submit" value="<?php print_string('savechanges') ?>"></p></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
<input type="hidden" name="id" value="<?php echo $form->id; ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php echo $form->courseid; ?>" />
|
||||
<input type="hidden" name="format" value="<?php echo $form->format; ?>" />
|
||||
<input type="hidden" name="action" value="edit" />
|
||||
</p>
|
||||
</form>
|
||||
<form method="post" action="event.php" name="edit">
|
||||
+1
-44
@@ -1,44 +1 @@
|
||||
<form method="post" action="event.php" name="new">
|
||||
<table cellpadding=5>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventname', 'calendar'); ?>:</td>
|
||||
<td><input type="text" name="name" size="67" value="<?php p($form->name); ?>" /> <?php if (isset($err['name'])) formerr($err['name']); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventdescription', 'calendar'); ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
print_textarea($usehtmleditor, 10, 65, 630, 200, "description", $form->description);
|
||||
if (isset($err['description'])) formerr($err['description']);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventdate', 'calendar'); ?>:</td>
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventduration', 'calendar'); ?>:</td>
|
||||
<td>
|
||||
<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>
|
||||
<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>
|
||||
<?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']); ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan="2"><p><input type="submit" value="<?php print_string('savechanges') ?>"></p></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
<input type="hidden" name="courseid" value="<?php echo $form->courseid?>" />
|
||||
<input type="hidden" name="groupid" value="<?php echo $form->groupid?>" />
|
||||
<input type="hidden" name="userid" value="<?php echo $form->userid?>" />
|
||||
<input type="hidden" name="modulename" value="<?php echo $form->modulename?>" />
|
||||
<input type="hidden" name="eventtype" value="<?php echo $form->eventtype?>" />
|
||||
<input type="hidden" name="instance" value="<?php echo $form->instance?>" />
|
||||
<input type="hidden" name="format" value="<?php echo $form->format; ?>" />
|
||||
<input type="hidden" name="action" value="new" />
|
||||
<input type="hidden" name="type" value="defined" />
|
||||
</p>
|
||||
</form>
|
||||
<form method="post" action="event.php" name="new">
|
||||
@@ -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)';
|
||||
|
||||
Reference in New Issue
Block a user