You can now delete a repeating event series all at once.
This commit is contained in:
+21
-6
@@ -230,16 +230,19 @@
|
||||
switch($action) {
|
||||
case 'delete':
|
||||
$confirm = optional_param('confirm', 0, PARAM_INT);
|
||||
$repeats = optional_param('repeats', 0, PARAM_INT);
|
||||
if($confirm) {
|
||||
// Kill it and redirect to day view
|
||||
if(($event = get_record('event', 'id', $eventid)) !== false) {
|
||||
/// Log the event delete.
|
||||
|
||||
delete_records('event', 'id', $eventid);
|
||||
|
||||
// pj - fixed the course id problem, but now we have another one:
|
||||
// what to do with the URL?
|
||||
add_to_log($event->courseid, 'calendar', 'delete', '', $event->name);
|
||||
if($event->repeatid && $repeats) {
|
||||
delete_records('event', 'repeatid', $event->repeatid);
|
||||
add_to_log($event->courseid, 'calendar', 'delete all', '', $event->name);
|
||||
}
|
||||
else {
|
||||
delete_records('event', 'id', $eventid);
|
||||
add_to_log($event->courseid, 'calendar', 'delete', '', $event->name);
|
||||
}
|
||||
}
|
||||
|
||||
redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$_REQUEST['d'].'&cal_m='.$_REQUEST['m'].'&cal_y='.$_REQUEST['y']);
|
||||
@@ -250,9 +253,21 @@
|
||||
$m = $eventtime['mon'];
|
||||
$d = $eventtime['mday'];
|
||||
$y = $eventtime['year'];
|
||||
|
||||
if($event->repeatid) {
|
||||
$fetch = get_record_sql('SELECT 1, COUNT(id) AS repeatcount FROM '.$CFG->prefix.'event WHERE repeatid = '.$event->repeatid);
|
||||
$repeatcount = $fetch->repeatcount;
|
||||
}
|
||||
else {
|
||||
$repeatcount = 0;
|
||||
}
|
||||
|
||||
// Display confirmation form
|
||||
echo '<div class="header">'.get_string('deleteevent', 'calendar').': '.$event->name.'</div>';
|
||||
echo '<h2>'.get_string('confirmeventdelete', 'calendar').'</h2>';
|
||||
if($repeatcount > 1) {
|
||||
echo '<p>'.get_string('youcandeleteallrepeats', 'calendar', $repeatcount).'</p>';
|
||||
}
|
||||
echo '<div class="eventlist">';
|
||||
$event->time = calendar_format_event_time($event, time(), '', false);
|
||||
calendar_print_event($event);
|
||||
|
||||
@@ -4,22 +4,41 @@
|
||||
<form method="get" action="event.php" name="delete">
|
||||
<p>
|
||||
|
||||
<input type="submit" value=" <?php print_string('yes') ?> " />
|
||||
<input type="submit" value=" <?php print_string('delete') ?> " />
|
||||
<input type="hidden" name="id" value="<?php echo $event->id?>" />
|
||||
<input type="hidden" name="action" value="delete" />
|
||||
<input type="hidden" name="m" value="<?php echo $m; ?>" />
|
||||
<input type="hidden" name="d" value="<?php echo $d; ?>" />
|
||||
<input type="hidden" name="y" value="<?php echo $y; ?>" />
|
||||
<input type="hidden" name="confirm" value="1" />
|
||||
<input type="hidden" name="repeats" value="0" />
|
||||
|
||||
</p>
|
||||
</form>
|
||||
</td>
|
||||
<?php if($repeatcount > 1) { ?>
|
||||
<td>
|
||||
<form method="get" action="event.php" name="delete">
|
||||
<p>
|
||||
|
||||
<input type="submit" value=" <?php print_string('deleteall') ?> " />
|
||||
<input type="hidden" name="id" value="<?php echo $event->id?>" />
|
||||
<input type="hidden" name="action" value="delete" />
|
||||
<input type="hidden" name="m" value="<?php echo $m; ?>" />
|
||||
<input type="hidden" name="d" value="<?php echo $d; ?>" />
|
||||
<input type="hidden" name="y" value="<?php echo $y; ?>" />
|
||||
<input type="hidden" name="confirm" value="1" />
|
||||
<input type="hidden" name="repeats" value="1" />
|
||||
|
||||
</p>
|
||||
</form>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td>
|
||||
<form method="get" action="view.php" name="cancel">
|
||||
<p>
|
||||
|
||||
<input type="submit" value=" <?php print_string('no') ?> ">
|
||||
<input type="submit" value=" <?php print_string('cancel') ?> ">
|
||||
<input type="hidden" name="view" value="day" />
|
||||
<input type="hidden" name="cal_m" value="<?php echo $m; ?>" />
|
||||
<input type="hidden" name="cal_d" value="<?php echo $d; ?>" />
|
||||
|
||||
@@ -81,6 +81,7 @@ $string['typeuser'] = 'User event';
|
||||
$string['upcomingevents'] = 'Upcoming Events';
|
||||
$string['userevents'] = 'User events';
|
||||
$string['yesterday'] = 'Yesterday';
|
||||
$string['youcandeleteallrepeats'] = 'This event is part of a repeating event series. You can delete this event only, or all $a events in the series at once.';
|
||||
|
||||
$string['sun'] = 'Sun';
|
||||
$string['mon'] = 'Mon';
|
||||
|
||||
Reference in New Issue
Block a user