/**
  * Function that create the exported file
  * @param Vtiger_Request $request
  * @param <Array> $result
  * @param Vtiger_Module_Model $moduleModel
  */
 public function output($request, $result, $moduleModel)
 {
     $fileName = $request->get('filename');
     $exportType = $this->getExportContentType($request);
     // Send the right content type and filename
     header("Content-type: {$exportType}");
     header("Content-Disposition: attachment; filename={$fileName}.ics");
     $timeZone = new iCalendar_timezone();
     $timeZoneId = split('/', date_default_timezone_get());
     if (!empty($timeZoneId[1])) {
         $zoneId = $timeZoneId[1];
     } else {
         $zoneId = $timeZoneId[0];
     }
     $timeZone->add_property('TZID', $zoneId);
     $timeZone->add_property('TZOFFSETTO', date('O'));
     if (date('I') == 1) {
         $timeZone->add_property('DAYLIGHTC', date('I'));
     } else {
         $timeZone->add_property('STANDARDC', date('I'));
     }
     $myiCal = new iCalendar();
     $myiCal->add_component($timeZone);
     while (!$result->EOF) {
         $eventFields = $result->fields;
         $id = $eventFields['activityid'];
         $type = $eventFields['activitytype'];
         if ($type != 'Task') {
             $temp = $moduleModel->get('eventFields');
             foreach ($temp as $fieldName => $access) {
                 $temp[$fieldName] = $eventFields[$fieldName];
             }
             $temp['id'] = $id;
             $iCalTask = new iCalendar_event();
             $iCalTask->assign_values($temp);
             $iCalAlarm = new iCalendar_alarm();
             $iCalAlarm->assign_values($temp);
             $iCalTask->add_component($iCalAlarm);
         } else {
             $temp = $moduleModel->get('todoFields');
             foreach ($temp as $fieldName => $access) {
                 $temp[$fieldName] = $eventFields[$fieldName];
             }
             $iCalTask = new iCalendar_todo();
             $iCalTask->assign_values($temp);
         }
         $myiCal->add_component($iCalTask);
         $result->MoveNext();
     }
     echo $myiCal->serialize();
 }
Example #2
0
 /**
  * Function that create the exported file
  * @param Vtiger_Request $request
  * @param <Array> $result
  * @param Vtiger_Module_Model $moduleModel
  */
 public function output($request, $result, $moduleModel)
 {
     $fileName = $request->get('filename');
     $exportType = $this->getExportContentType($request);
     // Send the right content type and filename
     header("Content-type: {$exportType}");
     header("Content-Disposition: attachment; filename={$fileName}.ics");
     $timeZone = new iCalendar_timezone();
     $timeZoneId = split('/', date_default_timezone_get());
     if (!empty($timeZoneId[1])) {
         $zoneId = $timeZoneId[1];
     } else {
         $zoneId = $timeZoneId[0];
     }
     $timeZone->add_property('TZID', $zoneId);
     $timeZone->add_property('TZOFFSETTO', date('O'));
     if (date('I') == 1) {
         $timeZone->add_property('DAYLIGHTC', date('I'));
     } else {
         $timeZone->add_property('STANDARDC', date('I'));
     }
     $myiCal = new iCalendar();
     $myiCal->add_component($timeZone);
     while (!$result->EOF) {
         $eventFields = $result->fields;
         $id = $eventFields['activityid'];
         $type = $eventFields['activitytype'];
         if ($type != 'Task') {
             $temp = $moduleModel->get('eventFields');
             foreach ($temp as $fieldName => $access) {
                 /* Priority property of ical is Integer
                  * http://kigkonsult.se/iCalcreator/docs/using.html#PRIORITY
                  */
                 if ($fieldName == 'priority') {
                     $priorityMap = array('High' => '1', 'Medium' => '2', 'Low' => '3');
                     $priorityval = $eventFields[$fieldName];
                     $icalZeroPriority = 0;
                     if (array_key_exists($priorityval, $priorityMap)) {
                         $temp[$fieldName] = $priorityMap[$priorityval];
                     } else {
                         $temp[$fieldName] = $icalZeroPriority;
                     }
                 } else {
                     $temp[$fieldName] = $eventFields[$fieldName];
                 }
             }
             $temp['id'] = $id;
             $iCalTask = new iCalendar_event();
             $iCalTask->assign_values($temp);
             $iCalAlarm = new iCalendar_alarm();
             $iCalAlarm->assign_values($temp);
             $iCalTask->add_component($iCalAlarm);
         } else {
             $temp = $moduleModel->get('todoFields');
             foreach ($temp as $fieldName => $access) {
                 if ($fieldName == 'priority') {
                     $priorityMap = array('High' => '1', 'Medium' => '2', 'Low' => '3');
                     $priorityval = $eventFields[$fieldName];
                     $icalZeroPriority = 0;
                     if (array_key_exists($priorityval, $priorityMap)) {
                         $temp[$fieldName] = $priorityMap[$priorityval];
                     } else {
                         $temp[$fieldName] = $icalZeroPriority;
                     }
                 } else {
                     $temp[$fieldName] = $eventFields[$fieldName];
                 }
             }
             $iCalTask = new iCalendar_todo();
             $iCalTask->assign_values($temp);
         }
         $myiCal->add_component($iCalTask);
         $result->MoveNext();
     }
     echo $myiCal->serialize();
 }
Example #3
0
        break;
    }
    $xml = new SimpleXMLElement($xmlstr);
    foreach ($xml->Episode as $episode) {
        $episodenr = $episode->EpisodeNumber;
        $episodenr = leading_zeros((int) $episodenr, 2);
        $id = $episode->id;
        $season = $episode->Combined_season;
        $season = leading_zeros((int) $season, 2);
        $naam = $episode->EpisodeName;
        $datum = $episode->FirstAired;
        $formatdatum = strtotime($datum);
        $datum = str_replace("-", "", $datum);
        $uitleg = $episode->Overview;
        if ($formatdatum >= time() - 604800) {
            if ($datum != "") {
                $ev = new iCalendar_event();
                $ev->add_property('uid', $id);
                $ev->add_property('summary', $xml->Series->SeriesName . " | " . $naam . " (S" . $season . "E" . $episodenr . ")");
                if ($uitleg != "") {
                    $ev->add_property('description', "{$uitleg}");
                }
                $ev->add_property('dtstart', $datum, array('value' => 'DATE'));
                $ev->add_property('dtend', $datum, array('value' => 'DATE'));
                $ev->add_property('dtstamp', $datum . 'T120000Z');
                $a->add_component($ev);
            }
        }
    }
}
echo $a->serialize();
Example #4
0
        die;
    }
}
$whereclause = calendar_sql_where($timestart, $timeend, $users, $groups, array_keys($courses), false);
if ($whereclause === false) {
    $events = array();
} else {
    $events = get_records_select('event', $whereclause, 'timestart');
}
if ($events === false) {
    $events = array();
}
$ical = new iCalendar();
$ical->add_property('method', 'PUBLISH');
foreach ($events as $event) {
    $ev = new iCalendar_event();
    $ev->add_property('summary', $event->name);
    $ev->add_property('description', $event->description);
    $ev->add_property('class', 'PUBLIC');
    // PUBLIC / PRIVATE / CONFIDENTIAL
    $ev->add_property('last-modified', Bennu::timestamp_to_datetime($event->timemodified));
    $ev->add_property('dtstamp', Bennu::timestamp_to_datetime());
    // now
    $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart));
    // when event starts
    if ($event->timeduration > 0) {
        //dtend is better than duration, because it works in Microsoft Outlook and works better in Korganizer
        $ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration));
    }
    if ($event->courseid != 0) {
        $ev->add_property('categories', $courses[$event->courseid]->shortname);
Example #5
0
} else {
    $tz->add_property('STANDARDC', date('I'));
}
$myical = new iCalendar();
$myical->add_component($tz);
while ($row = $adb->fetch_array($calendar_results)) {
    $this_event = $row;
    $id = $this_event['activityid'];
    $type = $this_event['activitytype'];
    if ($type != 'Task') {
        $temp = $event;
        foreach ($temp as $key => $val) {
            $temp[$key] = $this_event[$key];
        }
        $temp['id'] = $id;
        $ev = new iCalendar_event();
        $ev->assign_values($temp);
        $al = new iCalendar_alarm();
        $al->assign_values($temp);
        $ev->add_component($al);
    } else {
        $temp = $todo;
        foreach ($temp as $key => $val) {
            $temp[$key] = $this_event[$key];
        }
        $ev = new iCalendar_todo();
        $ev->assign_values($temp);
    }
    $myical->add_component($ev);
    $calendar_results->MoveNext();
}
Example #6
0
        die;
    }
}
$events = calendar_get_events($timestart, $timeend, $users, $groups, array_keys($courses), false);
$ical = new iCalendar();
$ical->add_property('method', 'PUBLISH');
foreach ($events as $event) {
    if (!empty($event->modulename)) {
        $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
        if (!groups_course_module_visible($cm)) {
            continue;
        }
    }
    $hostaddress = str_replace('http://', '', $CFG->wwwroot);
    $hostaddress = str_replace('https://', '', $hostaddress);
    $ev = new iCalendar_event();
    $ev->add_property('uid', $event->id . '@' . $hostaddress);
    $ev->add_property('summary', $event->name);
    $ev->add_property('description', $event->description);
    $ev->add_property('class', 'PUBLIC');
    // PUBLIC / PRIVATE / CONFIDENTIAL
    $ev->add_property('last-modified', Bennu::timestamp_to_datetime($event->timemodified));
    $ev->add_property('dtstamp', Bennu::timestamp_to_datetime());
    // now
    $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart));
    // when event starts
    if ($event->timeduration > 0) {
        //dtend is better than duration, because it works in Microsoft Outlook and works better in Korganizer
        $ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration));
    }
    if ($event->courseid != 0) {
Example #7
0
/* example for one entry, key in array is always id
 [1] => stdClass Object
 (
 [id] => 1
 [termin] => 1442697000
 [time] => 5400
 [creation] => 1442610703
 [moun] => Admin Nutzer
 [note] => Ma / KA / G
 [rname] => fh115
 [uname] => leh
 )
 [uname] => leh
 */
foreach ($entries as $key => $event) {
    $ev = new iCalendar_event();
    $ev->add_property('uid', $event->id . '@' . $hostaddress);
    $ev->add_property('summary', $event->rname . '/' . $event->uname);
    $ev->add_property('description', clean_param($event->note, PARAM_NOTAGS));
    $ev->add_property('class', 'PUBLIC');
    // PUBLIC / PRIVATE / CONFIDENTIAL
    $ev->add_property('created', Bennu::timestamp_to_datetime($event->creation));
    //$ev->add_property('last-modified', Bennu::timestamp_to_datetime($event->creation));
    $ev->add_property('dtstamp', Bennu::timestamp_to_datetime());
    // now
    $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->termin));
    // when event starts
    if ($event->time > 0) {
        //dtend is better than duration, because it works in Microsoft Outlook and works better in Korganizer
        $ev->add_property('dtend', Bennu::timestamp_to_datetime($event->termin + $event->time));
    }
Example #8
0
<?php

error_reporting(E_ALL);
include '../lib/bennu.inc.php';
echo '<pre>';
echo "\n";
$a = new iCalendar();
$ev = new iCalendar_event();
// Convenience: if you don't specify this, one will be auto-generated
//$ev->add_property('uid', '4306f93e-e379-11d9-bd57-ff0e7e0d5d50');
// Attachments: an application and a URL
//$ev->add_property('attach', base64_encode('Application-Data-Octets'), array('fmttype' => 'application/octet-stream', 'encoding' => 'BASe64', 'value' => 'binARY'));
//$ev->add_property('attach', 'http://www.moodle.org/');
// Summary and description; also resources
$ev->add_property('summary', 'Blablabla');
$ev->add_property('description', 'These are: some "notes" for this event');
//$ev->add_property('resources', array('one of this', 'one of that'));
// Start-end date
//$ev->add_property('class', 'PRIVATE');
$ev->add_property('dtstart', '20050623', array('value' => 'DATE'));
$ev->add_property('dtend', '20050624', array('value' => 'DATE'));
$ev->add_property('dtstamp', '20050622T235601Z');
//$ev->add_property('attendee', 'mailto:pj@uom.gr', array('cn' => 'John Papaioannou', 'delegated-from' => array('mailto:bla@some.net', 'mailto:bla@some.net')));
//$ev->add_property('exdate', array('20050622T235601Z', '20060622T235601Z'));
//$ev->add_property('exrule', 'FREQ=WEEKLY;COUNT=4;INTERVAL=2;BYDAY=TU,TH');
//$ev->add_property('request-status', '2.3.1;Some explanation for the request status code');
//$ev->add_property('recurrence-id', '20050622T235601Z', array('value' => 'DATE-TIME', 'range' => 'thisANDFUTURE'));
//$ev->add_property('rdate', array('19960403T020000Z/19960403T040000Z','19960404T010000Z/PT3H'), array('value' => 'PERIOD'));
//$ev->add_property('rdate', array(19970101,19970120,19970217,19970421,19970526,19970704,19970901,19971014,19971128,19971129,19971225), array('value' => 'DATE'));
//$ev->add_property('geo', array(37.386013,-122.082932));
//$ev->add_property('organizer', 'MAILTO:jsmith@host1.com', array('cn' => 'John C. Smith', 'dir' => 'ldap://host.com:6666/o=3DDC%20Associates,c=3DUS??(cn=3DJohn%20Smith)'));
Example #9
0
}
$events = calendar_get_events($timestart, $timeend, $users, $groups, array_keys($courses), false);

$ical = new iCalendar;
$ical->add_property('method', 'PUBLISH');
foreach($events as $event) {
   if (!empty($event->modulename)) {
        $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
        if (!groups_course_module_visible($cm)) {
            continue;
        }
    }
    $hostaddress = str_replace('http://', '', $CFG->wwwroot);
    $hostaddress = str_replace('https://', '', $hostaddress);

    $ev = new iCalendar_event;
    $ev->add_property('uid', $event->id.'@'.$hostaddress);
    $ev->add_property('summary', $event->name);
    $ev->add_property('description', $event->description);
    $ev->add_property('class', 'PUBLIC'); // PUBLIC / PRIVATE / CONFIDENTIAL
    $ev->add_property('last-modified', Bennu::timestamp_to_datetime($event->timemodified));
    $ev->add_property('dtstamp', Bennu::timestamp_to_datetime()); // now
    $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart)); // when event starts
    if ($event->timeduration > 0) {
        //dtend is better than duration, because it works in Microsoft Outlook and works better in Korganizer
        $ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration));
    }
    if ($event->courseid != 0) {
        $ev->add_property('categories', $courses[$event->courseid]->shortname);
    }
    $ical->add_component($ev);