/**
  * @todo Remove the binary attach stuff from here and put it in the test below.
  */
 public function testLongLinesFolded()
 {
     $cal = new qCal();
     $todo = new qCal_Component_Vtodo(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', 'dtstart' => '2008-04-23 1:00am'));
     $cal->attach($todo);
     $lines = explode("\r\n", $cal->render());
     $long = false;
     foreach ($lines as $line) {
         if (strlen($line) > 76) {
             $long = true;
         }
     }
     $this->assertFalse($long);
 }
Beispiel #2
0
 /**
  * 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();
 }