/** * Description: A "VEVENT" calendar component is a grouping of component * properties, and possibly including "VALARM" calendar components, that * represents a scheduled amount of time on a calendar. For example, it * can be an activity; such as a one-hour long, department meeting from * 8:00 AM to 9:00 AM, tomorrow. Generally, an event will take up time * on an individual calendar. Hence, the event will appear as an opaque * interval in a search for busy time. Alternately, the event can have * its Time Transparency set to "TRANSPARENT" in order to prevent * blocking of the event in searches for busy time. * * Example: The following is an example of the "VEVENT" calendar * component used to represent a meeting that will also be opaque to * searches for busy time: * * BEGIN:VEVENT * UID:19970901T130000Z-123401@host.com * DTSTAMP:19970901T1300Z * DTSTART:19970903T163000Z * DTEND:19970903T190000Z * SUMMARY:Annual Employee Review * CLASS:PRIVATE * CATEGORIES:BUSINESS,HUMAN RESOURCES * END:VEVENT * * The following is an example of the "VEVENT" calendar component used * to represent a reminder that will not be opaque, but rather * transparent, to searches for busy time: * * BEGIN:VEVENT * UID:19970901T130000Z-123402@host.com * DTSTAMP:19970901T1300Z * DTSTART:19970401T163000Z * DTEND:19970402T010000Z * SUMMARY:Laurel is in sensitivity awareness class. * CLASS:PUBLIC * CATEGORIES:BUSINESS,HUMAN RESOURCES * TRANSP:TRANSPARENT * END:VEVENT * * The following is an example of the "VEVENT" calendar component used * to represent an anniversary that will occur annually. Since it takes * up no time, it will not appear as opaque in a search for busy time; * no matter what the value of the "TRANSP" property indicates: * * BEGIN:VEVENT * UID:19970901T130000Z-123403@host.com * DTSTAMP:19970901T1300Z * DTSTART:19971102 * SUMMARY:Our Blissful Anniversary * CLASS:CONFIDENTIAL * CATEGORIES:ANNIVERSARY,PERSONAL,SPECIAL OCCASION * RRULE:FREQ=YEARLY * END:VEVENT * */ public function zzztestMeetingThatWillBeOpaqueToSearchesForBusyTime() { $event = new qCal_Component_Vevent(array('uid' => '*****@*****.**', 'dtstamp' => '19970901T1300Z', 'dtstart' => '19970903T163000Z', 'dtend' => '19970903T190000Z', 'summary' => 'Annual Employee Review', 'class' => 'PRIVATE', 'categories' => array('BUSINESS', 'HUMAN RESOURCES', 'SOMETHING, COOL'))); $cal = new qCal(); $cal->attach($event); $freebusytime = $cal->getFreeBusyTime(); }
/** * Test that binary data can be encoded as text and then decoded to be put back together. */ public function testBinaryData() { $cal = new qCal(); $journal = new qCal_Component_Vjournal(array('description' => 'This is a really long line that will of course need to be folded. I mean, we can\'t just have long lines laying around in an icalendar file. That would be like not ok. So, let\'s find out if this folded properly!', 'summary' => 'This is a short summary, which I think is like a title', 'dtstamp' => '2008-04-23 1:00am', new qCal_Property_Attach(file_get_contents('./files/me.jpg'), array('encoding' => 'base64', 'fmtype' => 'image/basic', 'value' => 'binary')))); $cal->attach($journal); $attach = $journal->getProperty('attach'); $jpg = base64_decode($attach[0]->getValue()); file_put_contents('./files/me2.jpg', $jpg); $this->assertEqual(file_get_contents('./files/me2.jpg'), file_get_contents('./files/me.jpg')); }
/** * Component constructor should accept an array of properties */ public function testConstructorAcceptsInitializingArray() { $cal = new qCal(array('version' => '2.0', 'prodid' => '-//foo/bar//NONFOO v1.0//EN')); $properties = array_keys($cal->getProperties()); $this->assertEqual($properties, array('VERSION', 'PRODID')); }
/** * Generate icalendar data output. * * @return String */ function generate() { $properties = array(); $properties['prodid'] = '-//vtiger/Mobile/NONSGML 1.0//EN'; $ical = new qCal($properties); // TODO Configure timezone information. $fieldnames = array('activityid', 'subject', 'description', 'activitytype', 'location', 'reminder_time', 'date_start', 'time_start', 'due_date', 'time_end', 'modifiedtime'); $query = "SELECT " . implode(',', $fieldnames) . " FROM vtiger_activity\n\t\t\tINNER JOIN vtiger_crmentity ON\n\t\t\t(vtiger_activity.activityid=vtiger_crmentity.crmid \tAND vtiger_crmentity.deleted = 0 AND vtiger_crmentity.smownerid = ?)\n\t\t\tLEFT JOIN vtiger_activity_reminder ON vtiger_activity_reminder.activity_id=vtiger_activity.activityid\n\t\t\tWHERE vtiger_activity.activitytype != 'Emails'"; $result = $this->db->pquery($query, array($this->userfocus->id)); while ($resultrow = $this->db->fetch_array($result)) { $properties = array(); $properties['uid'] = $resultrow['activityid']; $properties['summary'] = $this->formatValue(decode_html($resultrow['subject'])); $properties['description'] = $this->formatValue(decode_html($resultrow['description'])); $properties['class'] = 'PRIVATE'; $properties['dtstart'] = $this->formatDateTime($resultrow['date_start'], $resultrow['time_start']); $properties['dtend'] = $this->formatDateTime($resultrow['due_date'], $resultrow['time_end']); $properties['dtstamp'] = $this->formatDateTimestamp($resultrow['modifiedtime']); $properties['location'] = $this->formatValue($resultrow['location']); if ($resultrow['activitytype'] == 'Task') { // Tranform the parameter $properties['due'] = $properties['dtend']; unset($properties['dtend']); $icalComponent = new qCal_Component_Vtodo($properties); } else { $icalComponent = new qCal_Component_Vevent($properties); if (!empty($resultrow['reminder_time'])) { $alarmProperties = array(); $alarmProperties['trigger'] = $resultrow['reminder_time'] * 60; $icalComponent->attach(new qCal_Component_Valarm($alarmProperties)); } } $ical->attach($icalComponent); } return $ical->render(); }
<?php set_include_path(realpath("../lib") . PATH_SEPARATOR . get_include_path()); require_once "../tests/convenience.php"; /** * Parse an iCalendar file */ $filepath = realpath('../tests/files'); $parser = new qCal_Parser(array('searchpath' => $filepath)); // parse a file $ical = $parser->parseFile('simple.ics'); // parse raw data // $rawdata = file_get_contents($filepath . '/simple.ics'); // $ical->parse($rawdata); /** * Render an iCal object as an icalendar file */ $iCalData = $ical->render(); // eventually we can use other renderers as well... // $xCal = $ical->render(new qCal_Renderer_xCal()); // xCal is an implementation of icalendar in xml // $hCal = $ical->render(new qCal_Renderer_hCal()); // hCal is a microformat (html version of icalendar format) /** * Build an iCal object from scratch */ $calendar = new qCal(array('prodid' => '-//Some Calendar Company//Calendar Program v0.1//EN')); $todo = new qCal_Component_Vtodo(array('class' => 'private', 'dtstart' => '20090909', 'description' => 'Eat some bacon!!', 'summary' => 'Eat bacon', 'priority' => 1)); $todo->attach(new qCal_Component_Valarm(array('action' => 'audio', 'trigger' => '20090423', 'attach' => 'http://www.example.com/foo.wav'))); $calendar->attach($todo); // now you can render the calendar if you want, or just echo it out