You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -337,6 +336,10 @@ Now you have a basic scheduler that stores its events in the mysql database.
337
336
338
337
## Recurring events
339
338
339
+
:::note
340
+
The implementation below applies to Scheduler v7.1 and newer, which uses the `rrule` based recurring events format. If you are still using the legacy recurring events (`rec_type`, `event_pid`, `event_length`) shipped before v7.1, the previous approach with those columns continues to work for that data.
341
+
:::
342
+
340
343
In order to enable recurrence (e.g. "repeat event daily") you'll need to add an appropriate extension to the scheduler page:
341
344
342
345
~~~html
@@ -347,7 +350,7 @@ In order to enable recurrence (e.g. "repeat event daily") you'll need to add an
// delete a single occurrence from recurring series
435
-
if ($body["rec_type"] ==="none") {
436
-
$result["action"] ="deleted";/*!*/
443
+
if ($body["deleted"]) {/*!*/
444
+
$result["action"] ="deleted";/*!*/
437
445
}
438
446
} elseif($action=="updated") {
439
447
update($db, $body, $id);
440
448
} elseif($action=="deleted") {
441
449
delete($db, $id);
442
450
}
443
451
break;
444
-
default:
445
-
thrownewException("Unexpected Method");
452
+
default:
453
+
thrownewException("Unexpected Method");
446
454
break;
447
455
}
448
456
~~~
449
457
450
458
The update handler requires the same changes in the SQL query. Additionally, you need to handle a different special case there: when a recurring series is modified, you need to delete all modified occurrences of that series:
$subQueryText ="DELETE FROM `events` WHERE `recurring_event_id`=? ;"; /*!*/
488
+
$subQuery = $db->prepare($subQueryText);
489
+
$subQuery->execute([$id]);
490
+
}
478
491
$query = $db->prepare($queryText);
479
492
$query->execute($queryParams);
480
493
}
481
494
~~~
482
495
483
496
And finally, the `DELETE` action. Here we have to check two special cases:
484
-
485
-
- if the event you are going to delete has a non-empty `event_pid`, it means a user deletes a modified instance of the recurring series. Instead of deleting such a record from the database, you need to give it `rec_type='none'`, in order for scheduler to skip this occurrence.
486
-
497
+
498
+
- if the event you are going to delete is a modified instance of the recurring series. Instead of deleting, update the record to mark `deleted`.
499
+
487
500
- if a user deletes a whole recurring series, you also need to delete all the modified instances of that series.
488
501
489
502
~~~js title="data/api.php"
503
+
// delete an event
490
504
functiondelete($db, $id){
491
505
// some logic specific to recurring events support
0 commit comments