Hello,
First off, CMSMS is the best CMS I've every used--keep up the great work!
I'm using CMS as the backend for a sort of community website for which I'm using the awesome calendar module. It's missing just one thing--repeating events (e.g., the even happens ever week, every month, every 2 weeks, 2nd and 4th week of the month, etc). Does anyone have suggestions on the proper way to implement this?
I worked out in my head an idea that might allow this to be done fairly sanely. The issue is not the creation of the repeating events, it's the editing.
So now that I have a plan, I just need to find time to implement...
I worked out in my head an idea that might allow this to be done fairly sanely. The issue is not the creation of the repeating events, it's the editing.
Yeah, I couldn't figure that out either :S... Do you have time to do this, or would you mind elaborating on how you were planning to do this so that I could try my hand at it too.
I know we are repeating information unncessessarily at this point... it might be worth factoring out to a seperate table. Not sure yet.
adding a repeating event results in multiple event records with the same repeating_group_id. I'd use a random md5 hash for the id number.
When editing the first event in a repeating group, offer the user the option of changing just this one, or all events.
When editing the last event in a repeating group, offer the user the option of changing just this one, or all events.
When editing any other event in a repeating group, offer the user the option of changing just this one, this one and all future events, or all events.
The edit form needs a checkbox for creation of a repeating event and a "interval" text box and a "units of interval" radio group containing "days", "weeks", "months". These new edit fields should only exist when creating a new event.
The edit form requires a "what to change" radio group containing "all", "just this one", "this one and future ones". This should only be available when editing and should default to none selected. There must be validation to ensure that a selection is made.
When editing more than one event, only change field data in the other events that are the same as the data in the field for this event (before you do the update). i.e. if changing the title, from "X" to "Y", for all events, then you only change the title for events that are currently "X". You do not change events where the title is "Z". Note that this is done per field so that it's easy to change blocks of titles (for instance) using multiple edits without overwriting previous block changes.
If a date is changed, then only change the dates which have the same interval from this one. i.e. we can change all future events one day forward, but if another future event is not on the interval, then leave it alone.
One thing I would say, is that what happens if you just want the event to repeat every week, (ie there's no end date), it makes it impossible to generate a finite set of events, so you can't store them as indivdual events.
best solution I can come up with is set a maximum limit, say generate events for 6 weeks, 6 months or something (I have however solved this in a slightly less portable project with a cron job)
Second suggestion, factor out the repeat representing data to a different table, this will mean that a facility can be more easily built into the admin to administrate intervals, eg: options form at the top to specify repeating interval details, with a list below it of each of the generated intervals (allows easy link to edit that individual entry). This would then also lend itself quite nicely to allowing users to delete specifc instances (say you're event was cancelled one week, it could be removed).
In terms of the conceptual issues about how to implement repeating events, I know that Moodle has an events module that allows repeating events by simply specifying the number of times an event is to repeat. (e.g.: repeats every _[number of]__ (week, month) for [number of] times.)