An online calendar for Winning Side

Well, the smarty project went great.  It’s been done for a while now, but I’ve been too busy/lazy to post recently.  I’ve been grinding pretty hard on my latest project, an online calendar for Winning Side Ministries.

In the ministry, there are several of us preachers involved and we take turns preaching at different events.  There are only two of us that attend every event, and the others come to the events that their personal schedules allow.  This situation creates a bit of confusion and complication when it comes to scheduling.  For the moment we have it all written down on paper, but that’s difficult to keep up with.  It’s also difficult to figure out who’s going to be doing what on a day in the future so you know if you need to make arrangements before you miss an event.

This led me to start the creation of an online calendar system that would run on the website.  Each event would have it’s own schedule, and could be calculated based on a certain date each month, a certain day every week, or a certain numbered week-day of the month (eg, the 3rd Friday of every month).  In addition, “exceptions” can be made to alter a specific occurrence of an event, or to create a one-time special event at any time.

I guess the project’s going OK, but slow.  I have this (unfortunate) hatred for spending large amounts of time designing classes and API’s and such, so I end up doing a lot of flying by the seat of my pants then re-doing things that I’ve done the wrong way.  I have especially been doing this a lot with the messaging system.  Since this will be an interactive part of the website, I need not only to have logging capabilities but also a way of getting errors/warnings to the user.  What I ended up with is a standard message dispatcher type system where any class that wants to receive message simply subscribes as a listener, and the messages are broadcast as soon as they are received.

The way I decided to get messages to the user was to store them in the $_SESSION superglobal.  I chose this because the messages needed to be attached to the session, and what better way to do it?  I couldn’t really justify writing a custom session handler to do something that PHP/HTTP could do natively.  The class that handles this keeps an ID that is passed to the constructor to keep messages from different systems separate, and it stores messages using this ID.  For instance, my calendar’s ID is “calender”, so messages are stored in an array that lives in $_SESSION[‘messageArray’][‘calendar’].

I had a funny quirk when designing this…I originally used $_SESSION[‘messages”], but that exhibited strange behavior.  For one thing, it was constantly getting cleared.  I don’t know if it was due to another random bug in my code or what, but the problems went away when I changed “messages” to “messageArray”.  I searched google to see if that was some special HTTP thing, but the only hits I got were from drupal.

I don’t know, but it works now.  😉

I’ve got some cleaning up to do in the code now that I’ve got the design nailed down (I think) and then it’s off to designing the front-end.  Hurray!

Also, thanks to Balsamiq for a free NPO license for Mockups.  It’s a real help!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: