public function getUserMonthYear($time = NULL) { if (is_null($time)) { $time = Saf_Time::time(); } return date('F Y', $time); }
protected function _renderItem($type, $id, $data) { $out = ''; $outType = strtolower(substr($type, 1)); $outProp = ''; $dateStamp = gmdate(self::OUTPUT_DATESTAMP, Saf_Time::time()); $version = $this->getVersion($data); $atProps = 'CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE'; //or just ROLE=REQ-PARTICIPANT; $uid = "{$outType}{$id}@{$this->_hostId}"; //#TODO #2.0.0 see what more advanced attendee properties we can suppor... foreach (self::$_itemProps[$type] as $prop => $card) { $value = NULL; $propKey = array_key_exists($prop, $data) ? $prop : $this->_resolvePropKey($prop, $data); $outProp = "{$prop}:"; switch ($prop) { case 'ORGANIZER': case 'ATTENDEE': $attendeeMail = $propKey && array_key_exists($propKey, $data) ? $data[$propKey] : NULL; $cnSource = array_key_exists('USER:CN', $data) ? $data['USER:CN'] : (array_key_exists('userFullname', $data) ? $data['userFullname'] : NULL); if (is_array($attendeeMail)) { foreach ($attendeeMail as $email) { $outProp = array(); if (is_array($cnSource) && array_key_exists($email, $cnSource)) { $cn = ";CN={$cnSource[$email]}"; } else { $cn = ''; } $outProp = 'ATTENDEE;'; $value[] = "{$atProps}{$cn}:MAILTO:{$email}"; } } else { if (!is_null($attendeeMail)) { $attendeeCn = is_array($cnSource) ? '' : ";CN={$cnSource}"; $outProp = 'ATTENDEE;'; $value = "{$atProps}{$attendeeCn}:MAILTO:{$attendeeMail}"; } } break; case 'DTSTAMP': case 'DTSTART': case 'DTEND': case 'LAST-MODIFIED': $value = $propKey && array_key_exists($propKey, $data) ? $data[$propKey] : NULL; if (!is_null($value)) { if (Saf_Time::isTimeStamp($value)) { $value = gmdate(self::OUTPUT_DATESTAMP, $value); } else { //if { //#TODO #1.1.0 detect non-GMT and convert } } else { if ($prop == 'DTSTAMP') { $value = gmdate(self::OUTPUT_DATESTAMP, Saf_Time::time()); } } break; case 'UID': $value = $uid; break; case 'SEQUENCE': if ($propKey && array_key_exists($propKey, $data) && $data[$propKey] == '*') { $value = Saf_Time::time() - $this->_baseTime; } else { if ($propKey && array_key_exists($propKey, $data)) { $value = (int) $data[$propKey]; } } break; case 'STATUS': switch (strtoupper($this->_method)) { case 'CANCEL': $value = $propKey && array_key_exists($propKey, $data) ? strtoupper($data[$propKey]) : NULL; break; case 'PUBLISH': case 'REQUEST': default: $value = $propKey && array_key_exists($propKey, $data) ? strtoupper($data[$propKey]) : 'CONFIRMED'; } break; default: if ($propKey && array_key_exists($propKey, $data)) { $value = self::escapeText($data[$propKey]); } } if ($card === '+' || $card === 1) { if (is_null($value)) { throw new Exception("Required value {$prop} missing to generate iCal for {$uid}"); } } else { if ($card === '?' || $card === 1) { if (is_array($value)) { throw new Exception("Too many values provided for {$prop} to generate iCal for {$uid}"); } } } if (is_array($value) && count($value) > 0) { foreach ($value as $subValue) { $out .= "{$outProp}{$subValue}\n"; } } else { if (!is_array($value) && !is_null($value)) { $out .= "{$outProp}{$value}\n"; } } } return $out; }