Ejemplo n.º 1
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) {
                 $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();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 3
0
}
$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();
}
// Print the actual calendar
echo $myical->serialize();