MCAL functionsMCAL
MCAL stands for Modular Calendar Access Library.
Libmcal is a C library for accessing calendars. It's written to be
very modular, with pluggable drivers. MCAL is the calendar
equivalent of the IMAP module for mailboxes.
With mcal support, a calendar stream can be opened much like the
mailbox stream with the IMAP support. Calendars can be local file
stores, remote ICAP servers, or other formats that are supported
by the mcal library.
Calendar events can be pulled up, queried, and stored. There is
also support for calendar triggers (alarms) and recurring events.
With libmcal, central calendar servers can be accessed,
removing the need for any specific database or local file
programming.
To get these functions to work, you have to compile PHP with
. That requires the
mcal library to be installed. Grab the latest version from
&url.mcal; and compile and install
it.
The following constants are defined when using the MCAL module.
For weekdays :
MCAL_SUNDAY
MCAL_MONDAY
MCAL_TUESDAY
MCAL_WEDNESDAY
MCAL_THURSDAY
MCAL_FRIDAY
MCAL_SATURDAY
For recurrence :
MCAL_RECUR_NONE
MCAL_RECUR_DAILY
MCAL_RECUR_WEEKLY
MCAL_RECUR_MONTHLY_MDAY
MCAL_RECUR_MONTHLY_WDAY
MCAL_RECUR_YEARLY
For months :
MCAL_JANUARY
MCAL_FEBRUARY
MCAL_MARCH
MCAL_APRIL
MCAL_MAY
MCAL_JUNE
MCAL_JULY
MCAL_AUGUST
MCAL_SEPTEMBER
MCAL_OCTOBER
MCAL_NOVEMBER
MCAL_DECEMBER
Most of the functions use an internal event structure that is
unique for each stream. This alleviates the need to pass around
large objects between functions. There are convenience functions
for setting, initializing, and retrieving the event structure
values.
mcal_openOpens up an MCAL connectionDescriptionintmcal_openstringcalendarstringusernamestringpasswordintoptions
Returns an MCAL stream on success, &false; on error.
mcal_open opens up an MCAL connection to the
specified calendar store. If the optional
options is specified, passes the
options to that mailbox also. The streams
internal event structure is also initialized upon connection.
mcal_popenOpens up a persistent MCAL connectionDescriptionintmcal_popenstringcalendarstringusernamestringpasswordintoptions
Returns an MCAL stream on success, &false; on error.
mcal_popen opens up an MCAL connection to the
specified calendar store. If the optional
options is specified, passes the
options to that mailbox also. The streams
internal event structure is also initialized upon connection.
mcal_reopenReopens an MCAL connectionDescriptionintmcal_reopenstringcalendarintoptions
Reopens an MCAL stream to a new calendar.
mcal_reopen reopens an MCAL connection to the
specified calendar store. If the optional
options is specified, passes the
options to that mailbox also.
mcal_closeClose an MCAL streamDescriptionintmcal_closeintmcal_streamintflags
Closes the given mcal stream.
mcal_create_calendarCreate a new MCAL calendar Descriptionstringmcal_create_calendarintstreamstringcalendar
Creates a new calendar named calendar.
mcal_rename_calendarRename an MCAL calendar Descriptionstringmcal_rename_calendarintstreamstringold_namestringnew_name
Renames the calendar old_name to
new_name.
mcal_delete_calendarDelete an MCAL calendar Descriptionstringmcal_delete_calendarintstreamstringcalendar
Deletes the calendar named calendar.
mcal_fetch_event
Fetches an event from the calendar stream
Descriptionobjectmcal_fetch_eventintmcal_streamintevent_idintoptionsmcal_fetch_event fetches an event from the
calendar stream specified by id.
Returns an event object consisting of:
int id - ID of that event.
int public - &true; if the event if public, &false; if it is
private.
string category - Category string of the event.
string title - Title string of the event.
string description - Description string of the event.
int alarm - number of minutes before the event to send an
alarm/reminder.
object start - Object containing a datetime entry.
object end - Object containing a datetime entry.
int recur_type - recurrence type
int recur_interval - recurrence interval
datetime recur_enddate - recurrence end date
int recur_data - recurrence data
All datetime entries consist of an object that contains:
int year - year
int month - month
int mday - day of month
int hour - hour
int min - minutes
int sec - seconds
int alarm - minutes before event to send an alarm
The possible values for recur_type are:
0 - Indicates that this event does not recur
1 - This event recurs daily
2 - This event recurs on a weekly basis
3 - This event recurs monthly on a specific day of the month (e.g. the 10th of the month)
4 - This event recurs monthly on a sequenced day of the week (e.g. the 3rd Saturday)
5 - This event recurs on an annual basismcal_list_events
Return a list of IDs for a date or a range of dates.
Descriptionarraymcal_list_eventsintmcal_streamobjectbegin_dateobjectend_date
Returns an array of ID's that are between the start and end
dates, or if just a stream is given, uses the start and end dates
in the global event structure.
mcal_list_events function takes in an
beginning date and an optional end date for a calendar stream. An
array of event id's that are between the given dates or the
internal event dates are returned.
mcal_append_eventStore a new event into an MCAL calendarDescriptionintmcal_append_eventintmcal_streammcal_append_event Stores the global event
into an MCAL calendar for the given stream.
Returns the id of the newly inserted event.
mcal_store_eventModify an existing event in an MCAL calendarDescriptionintmcal_store_eventintmcal_streammcal_store_event Stores the modifications
to the current global event for the given stream.
Returns the event id of the modified event on success and &false; on error.
mcal_delete_eventDelete an event from an MCAL calendarDescriptionintmcal_delete_eventintmcal_streamintevent_idmcal_delete_event deletes the calendar event
specified by the event_id.
Returns &true;.
mcal_snoozeTurn off an alarm for an eventDescriptionintmcal_snoozeintidmcal_snooze turns off an alarm for a
calendar event specified by the id.
Returns &true;.
mcal_list_alarms
Return a list of events that has an alarm triggered at the given
datetime
Descriptionarraymcal_list_alarmsintmcal_streamintbegin_yearintbegin_monthintbegin_dayintend_yearintend_monthintend_day
Returns an array of event ID's that has an alarm going off
between the start and end dates, or if just a stream is given,
uses the start and end dates in the global event structure.
mcal_list_events function takes in an
optional beginning date and an end date for a calendar stream. An
array of event id's that are between the given dates or the
internal event dates are returned.
mcal_event_init
Initializes a streams global event structure
Descriptionintmcal_event_initintstreammcal_event_init initializes a streams global
event structure. this effectively sets all elements of the
structure to 0, or the default settings.
Returns &true;.
mcal_event_set_category
Sets the category of the streams global event structure
Descriptionintmcal_event_set_categoryintstreamstringcategorymcal_event_set_category sets the streams
global event structure's category to the given string.
Returns &true;.
mcal_event_set_title
Sets the title of the streams global event structure
Descriptionintmcal_event_set_titleintstreamstringtitlemcal_event_set_title sets the streams global
event structure's title to the given string.
Returns &true;.
mcal_event_set_description
Sets the description of the streams global event structure
Descriptionintmcal_event_set_descriptionintstreamstringdescriptionmcal_event_set_description sets the streams
global event structure's description to the given string.
Returns &true;.
mcal_event_set_start
Sets the start date and time of the streams global event
structure
Descriptionintmcal_event_set_startintstreamintyearintmonthint
day
int
hour
int
minint
sec
mcal_event_set_start sets the streams global
event structure's start date and time to the given values.
Returns &true;.
mcal_event_set_end
Sets the end date and time of the streams global event structure
Descriptionintmcal_event_set_endintstreamintyearintmonthint
day
int
hour
int
min
int
sec
mcal_event_set_end sets the streams global
event structure's end date and time to the given values.
Returns &true;.
mcal_event_set_alarm
Sets the alarm of the streams global event structure
Descriptionintmcal_event_set_alarmintstreamintalarmmcal_event_set_alarm sets the streams global
event structure's alarm to the given minutes before the event.
Returns &true;.
mcal_event_set_class
Sets the class of the streams global event structure
Descriptionintmcal_event_set_classintstreamintclassmcal_event_set_class sets the streams global
event structure's class to the given value. The class is either 1
for public, or 0 for private.
Returns &true;.
mcal_is_leap_year
Returns if the given year is a leap year or not
Descriptionintmcal_is_leap_yearintyearmcal_is_leap_year returns 1 if the given
year is a leap year, 0 if not.
mcal_days_in_month
Returns the number of days in the given month
Descriptionintmcal_days_in_monthintmonthintleap yearmcal_days_in_month Returns the number of
days in the given month, taking into account if the given year is
a leap year or not.
mcal_date_valid
Returns &true; if the given year, month, day is a valid date
Descriptionintmcal_date_validintyearintmonthintdaymcal_date_valid Returns &true; if the given
year, month and day is a valid date, &false; if not.
mcal_time_valid
Returns &true; if the given year, month, day is a valid time
Descriptionintmcal_time_validinthourintminutesintsecondsmcal_time_valid Returns &true; if the given
hour, minutes and seconds is a valid time, &false; if not.
mcal_day_of_week
Returns the day of the week of the given date
Descriptionintmcal_day_of_weekintyearintmonthintdaymcal_day_of_week returns the day of the week
of the given date.
Possible return values range from 0 for Sunday through 6 for Saturday.
mcal_day_of_year
Returns the day of the year of the given date
Descriptionintmcal_intyearintmonthintdaymcal_day_of_year returns the day of the year
of the given date.
mcal_date_compareCompares two datesDescriptionintmcal_date_compareinta_yearinta_monthinta_dayintb_yearintb_monthintb_daymcal_date_compare Compares the two given
dates, returns <0, 0, >0 if a<b, a==b, a>b respectively.
mcal_next_recurrenceReturns the next recurrence of the eventDescriptionintmcal_next_recurrenceintstreamintweekstartarraynextmcal_next_recurrence returns an object
filled with the next date the event occurs, on or after the
supplied date. Returns empty date field if event does not occur
or something is invalid. Uses weekstart to determine what day is
considered the beginning of the week.
mcal_event_set_recur_none
Sets the recurrence of the streams global event structure
Descriptionintmcal_event_set_recur_noneintstreammcal_event_set_recur_none sets the streams
global event structure to not recur (event->recur_type is set to
MCAL_RECUR_NONE).
mcal_event_set_recur_daily
Sets the recurrence of the streams global event structure
Descriptionintmcal_event_set_recur_dailyintstreamintyearintmonthintdayintintervalmcal_event_set_recur_daily sets the streams
global event structure's recurrence to the given value to be
reoccuring on a daily basis, ending at the given date.
mcal_event_set_recur_weekly
Sets the recurrence of the streams global event structure
Descriptionintmcal_event_set_recur_weeklyintstreamintyearintmonthintdayintintervalintweekdaysmcal_event_set_recur_weekly sets the streams
global event structure's recurrence to the given value to be
reoccuring on a weekly basis, ending at the given date.
mcal_event_set_recur_monthly_mday
Sets the recurrence of the streams global event structure
Descriptionintmcal_event_set_recur_monthly_mdayintstreamintyearintmonthintdayintintervalmcal_event_set_recur_monthly_mday sets the
streams global event structure's recurrence to the given value to
be reoccuring on a monthly by month day basis, ending at the
given date.
mcal_event_set_recur_monthly_wday
Sets the recurrence of the streams global event structure
Descriptionintmcal_event_set_recur_monthly_wdayintstreamintyearintmonthintdayintintervalmcal_event_set_recur_monthly_wday sets the
streams global event structure's recurrence to the given value to
be reoccuring on a monthly by week basis, ending at the given
date.
mcal_event_set_recur_yearly
Sets the recurrence of the streams global event structure
Descriptionintmcal_event_set_recur_yearlyintstreamintyearintmonthintdayintintervalmcal_event_set_recur_yearly sets the streams
global event structure's recurrence to the given value to be
reoccuring on a yearly basis,ending at the given date.
mcal_fetch_current_stream_event
Returns an object containing the current streams event structure
Descriptionobjectmcal_fetch_current_stream_eventintstreammcal_fetch_current_stream_event
returns the current stream's event structure as an object
containing:
int id - ID of that event.
int public - &true; if the event if public, &false; if it is
private.
string category - Category string of the event.
string title - Title string of the event.
string description - Description string of the event.
int alarm - number of minutes before the event to send an
alarm/reminder.
object start - Object containing a datetime entry.
object end - Object containing a datetime entry.
int recur_type - recurrence type
int recur_interval - recurrence interval
datetime recur_enddate - recurrence end date
int recur_data - recurrence data
All datetime entries consist of an object that contains:
int year - year
int month - month
int mday - day of month
int hour - hour
int min - minutes
int sec - seconds
int alarm - minutes before event to send an alarmmcal_event_add_attribute
Adds an attribute and a value to the streams global event structure
Descriptionvoidmcal_event_add_attributeintstreamstringattributestringvaluemcal_event_add_attribute adds an attribute
to the stream's global event structure with the value given by
"value".
mcal_expunge
Deletes all events marked for being expunged.
Descriptionintmcal_expungeintstreammcal_expunge Deletes all events which have
been previously marked for deletion.
mcal_week_of_year
Returns the week number of the given date
Descriptionintmcal_week_of_yearintdayintmonthintyear
&warn.undocumented.func;