|
Quotes |
" ... I want to tell you that your thyme product is functional and valuable beyond
words. I cannot imagine why any portal would be without it. It is the cornerstone of our new project ..."
" ... Thanks for such a complete project, its making my job much easier. ..."
" ... I have now deployed 4 different calendars and our users love them ... "
" ... Easy to install and use and a great look/design. ..."
" ... This has to be the easiest to use program I think I've had to deal with at all this year. ..."
|
|
| View previous topic :: View next topic |
| Author |
Message |
esoft_ian
Joined: 12 Sep 2005 Posts: 5275
|
Posted: Mon Aug 04, 2008 6:11 pm Post subject: Adding events using Thyme's API |
|
|
The following code will add a simple event.
| Code: |
<?php
require_once("/full/path/to/thyme/include/classes/class.calendar.php");
require_once(_CAL_BASE_PATH_ ."include/classes/class.event.php");
# Used to set calendar
$cal = new calendar();
$cal->set("calendar","Default Calendar"); # title of calendar to add event to
# Create new, blank event
$event = new _cal_event();
# Set calendar for event
$event->calendar = $cal->calendar;
# Set title
$event->title = "My New Event";
# Set start time M/D/YYYY HH:MM
$event->starttime = _ex_strtotime("8/4/2008 14:00");
# Set duration HH:MM:SS
$event->duration = "1:0:0";
# Save event
$event->save();
|
This creates a new event in the calendar called Default Calendar called "My New Event" that starts at 2pm and ends at 3pm on August 4th, 2008.
Here are some common event properties that may also be set:
allday - Set to 1 if the event lasts all day
org_name - Organizer's name
org_email - Organizer's e-mail
url - URL of event
notes - notes or description of the event.
flag - Set to 1 to flag the event
location - Location name
addr_st - Street address line
addr_ci - City / State / Zip line
phone - Phone number
The repeating structure can get a bit complex.
event->freq specifies the frequency of events:
0 = does not repeat
1 = yearly
2 = monthly
3 = weekly
4 = daily
5 = easter yearly
event->finterval specifies the frequency interval
So an event that repeats every 2 weeks would have; freq = 3, finterval = 2
For the more advanced rules you have:
( ** ) byday - specifies the weekday(s) which the event may repeat. These are specified by:
MO = Monday, TU = Tuesday, WE = Wednesday, TH = Thursday, FR = friday etc...
These may be preceded by numbers to specify the 1st, 3rd, last days .. E.g. the last Thursday of the month is: -1TH. The number can be -1 (for last) or 1-5 (1st, 2nd, 3rd, etc..) The 3rd monday of the month is specified by: 3MO. You can add multiple byday rules separated by commas. E.g... the first weekdays of the month:
1FR,1TH,1WE,1TU,1MO
Order does not matter. In the case that an event occurs weekly instead of monthly, do not use numbers. For example, every 3 weeks on Monday and Friday would be:
$event->freq = 3; # weekly
$event->finterval = 3; # every 3 weeks
$event->byday = "MO,FR"; # Monday and Friday
E.x.
| Code: |
| $event->byday = "MO,TU,WE,TH,FR"; # Monday through Friday |
( ** ) bymonthday - specifies the month days to repeat. -30 - 30 (depending on the month).
Just like byday, you can use negative numbers to specify the last day. -1 = the last day of the month, -4 = for days from the last day of the month, 15 = the 15th day of the month. You can add multiples separated by commas just like byday rules as well.
E.x.
| Code: |
| $event->bymonthday = "1,-1"; # First and last days of the month |
( ** ) bymonth - specifies the months that events may repeat on. 1 - 12. Straight forward, no negative numbers, multples can be added separated by commas.
E.x.
| Code: |
| $event->bymonth = "1,2,3"; # Only January - March |
( ** ) starttime - specifies when the event will start
( ** ) endtime - specifies when the repeating event will end.
starttime and endtime must be in unix timestamp format with no timezone adjustments. You can get this by using PHP's gmmktime($second, $minute, $hour, $month, $day, $year);
If an event does not repeat, it's endtime is ignored.
( ** ) end_after - specifies that the event ends after X times.
If an event will repeat for ever, do not set endtime or end_after.
( ** ) duration - The event's duration. in HH:MM:SS format. E.g. event->duration = '6:00:00' .. 6hrs.
( ** ) allday - Set to 1 to specify that the event lasts all day. In which case duration is ignored.
Last edited by esoft_ian on Fri Dec 12, 2008 8:09 pm; edited 1 time in total |
|
| Back to top |
|
 |
esoft_ian
Joined: 12 Sep 2005 Posts: 5275
|
Posted: Thu Aug 07, 2008 4:10 pm Post subject: |
|
|
Note that this:
| Code: |
# Set start time M/D/YYYY HH:MM
$event->starttime = _ex_strtotime("8/4/2008 14:00");
|
could also be in YYYY-MM-DD format:
| Code: |
# Set start time YYYY-MM-DD HH:MM
$event->starttime = _ex_strtotime("2008-8-4 14:00");
|
|
|
| Back to top |
|
 |
haleyjo
Joined: 01 Dec 2008 Posts: 1
|
Posted: Mon Dec 01, 2008 9:48 pm Post subject: Event Confilct Checking w/API |
|
|
Is there anyway to use the Event Conflict checker using a call to the Thyme API?? If so I would love to know how, I have gotten all the other parts of adding a new event using the API except this. Your help would be appreciated.
Haley |
|
| Back to top |
|
 |
cxune
Joined: 25 Jan 2008 Posts: 3
|
Posted: Wed Dec 10, 2008 3:36 pm Post subject: events added via API but pending approval |
|
|
| This is a great feature, but is there a flag that can be set to put the added events on the to-be-approved list, the same as the feature you have for users adding events that pend administrator approval from within Thyme? |
|
| Back to top |
|
 |
esoft_ian
Joined: 12 Sep 2005 Posts: 5275
|
Posted: Wed Dec 10, 2008 7:02 pm Post subject: |
|
|
Hi,
Change this:
| Code: |
| require_once(_CAL_BASE_PATH_ ."include/classes/class.event.php"); |
.. to this :
| Code: |
| require_once(_CAL_BASE_PATH_ ."include/classes/class.request.php"); |
.. and this :
| Code: |
| $event = new _cal_event(); |
... to this:
| Code: |
| $event = new _cal_request(); |
That should do it. Let me know if you have any questions / trouble. |
|
| Back to top |
|
 |
cxune
Joined: 25 Jan 2008 Posts: 3
|
Posted: Fri Dec 12, 2008 4:55 pm Post subject: & repeating events |
|
|
Very nice, and thank you for your help.
But also, how do you specify repeating events?- in my case, I'd like to replicate the 'Weekly' tab under Advanced Repeating on the default Thyme event-add page.
Thanks! |
|
| Back to top |
|
 |
esoft_ian
Joined: 12 Sep 2005 Posts: 5275
|
Posted: Fri Dec 12, 2008 8:09 pm Post subject: |
|
|
Hi,
I've added repeating information to the description. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|