本文整理汇总了PHP中vcalendar::setComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP vcalendar::setComponent方法的具体用法?PHP vcalendar::setComponent怎么用?PHP vcalendar::setComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcalendar
的用法示例。
在下文中一共展示了vcalendar::setComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: row2array
private static function row2array($row, $timezone, $hostname, $uid, $namespace_id)
{
$v = new vcalendar();
$v->setConfig('unique_id', $hostname);
$v->setProperty('method', 'PUBLISH');
$v->setProperty("x-wr-calname", "AnimexxCal");
$v->setProperty("X-WR-CALDESC", "Animexx Calendar");
$v->setProperty("X-WR-TIMEZONE", $timezone);
if ($row["adjust"]) {
$start = datetime_convert('UTC', date_default_timezone_get(), $row["start"]);
$finish = datetime_convert('UTC', date_default_timezone_get(), $row["finish"]);
} else {
$start = $row["start"];
$finish = $row["finish"];
}
$allday = strpos($start, "00:00:00") !== false && strpos($finish, "00:00:00") !== false;
/*
if ($allday) {
$dat = Datetime::createFromFormat("Y-m-d H:i:s", $finish_tmp);
$dat->sub(new DateInterval("P1D"));
$finish = datetime_convert("UTC", date_default_timezone_get(), $dat->format("Y-m-d H:i:s"));
var_dump($finish);
}
*/
$subject = substr(preg_replace("/\\[[^\\]]*\\]/", "", $row["desc"]), 0, 100);
$description = preg_replace("/\\[[^\\]]*\\]/", "", $row["desc"]);
$vevent = dav_create_vevent(wdcal_mySql2icalTime($row["start"]), wdcal_mySql2icalTime($row["finish"]), false);
$vevent->setLocation(icalendar_sanitize_string($row["location"]));
$vevent->setSummary(icalendar_sanitize_string($subject));
$vevent->setDescription(icalendar_sanitize_string($description));
$v->setComponent($vevent);
$ical = $v->createCalendar();
return array("uid" => $uid, "namespace" => CALDAV_NAMESPACE_FRIENDICA_NATIVE, "namespace_id" => $namespace_id, "date" => $row["edited"], "data_uri" => "friendica-" . $namespace_id . "-" . $row["id"] . "@" . $hostname, "data_subject" => $subject, "data_location" => $row["location"], "data_description" => $description, "data_start" => $start, "data_end" => $finish, "data_allday" => $allday, "data_type" => $row["type"], "ical" => $ical, "ical_size" => strlen($ical), "ical_etag" => md5($ical));
}
示例2: ical
public function ical($params)
{
$this->setView('ical.php');
$official = isset($params['official']);
$group_name = isset($params['group']) ? $params['group'] : null;
$event_model = new Event_Model();
$events = $event_model->getUpcoming($group_name, $official, false);
// Creation of the iCal content
$cache_entry = 'ical-' . (isset($group_name) ? $group_name : '') . '-' . ($official ? 'official' : 'non-official');
$content = Cache::read($cache_entry);
if (!$content) {
require_once APP_DIR . 'classes/class.iCalcreator.php';
$cal = new vcalendar();
$cal->setConfig('unique_id', $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
$cal->setProperty('method', 'PUBLISH');
$cal->setProperty('x-wr-calname', $official ? __('EVENTS_TITLE_OFFICIAL') : __('EVENTS_TITLE_NONOFFICIAL'));
$cal->setProperty('X-WR-CALDESC', '');
$cal->setProperty('X-WR-TIMEZONE', date('e'));
foreach ($events as $event) {
$vevent = new vevent();
$vevent->setProperty('dtstart', array('year' => (int) date('Y', $event['date_start']), 'month' => (int) date('n', $event['date_start']), 'day' => (int) date('j', $event['date_start']), 'hour' => (int) date('G', $event['date_start']), 'min' => (int) date('i', $event['date_start']), 'sec' => (int) date('s', $event['date_start'])));
$vevent->setProperty('dtend', array('year' => (int) date('Y', $event['date_end']), 'month' => (int) date('n', $event['date_end']), 'day' => (int) date('j', $event['date_end']), 'hour' => (int) date('G', $event['date_end']), 'min' => (int) date('i', $event['date_end']), 'sec' => (int) date('s', $event['date_end'])));
$vevent->setProperty('summary', $event['title']);
$vevent->setProperty('description', $event['message']);
$cal->setComponent($vevent);
}
$content = $cal->createCalendar();
Cache::write($cache_entry, $content, 2 * 3600);
}
$this->set('content', $content);
}
示例3: array
$e->setProperty('rrule', array('FREQ' => 'YEARLY'));
$c->setComponent($e);
$str = $c->createCalendar();
echo $str;
echo "<br />\n\n";
/*
* BEGIN:VTODO
* UID:19970901T130000Z-123404@host.com
* DTSTAMP:19970901T1300Z
* DTSTART:19970415T133000Z
* DUE:19970416T045959Z
* SUMMARY:1996 Income Tax Preparation
* CLASS:CONFIDENTIAL
* CATEGORIES:FAMILY,FINANCE
* PRIORITY:1
* STATUS:NEEDS-ACTION
* END:VTODO
*/
$c = new vcalendar();
$t = new vtodo();
$t->setProperty('dtstart', '19970415T133000 GMT');
$t->setProperty('due', '19970416T045959 GMT');
$t->setProperty('summary', '1996 Income Tax Preparation');
$t->setProperty('class', 'CONFIDENTIAL');
$t->setProperty('categories', 'FAMILY');
$t->setProperty('categories', 'FINANCE');
$t->setProperty('priority', 1);
$t->setProperty('status', 'NEEDS-ACTION');
$c->setComponent($t);
$str = $c->createCalendar();
echo $str;
示例4: toICS
/**
* toICS()
*
* Outputs group schedules in ICS format
*/
function toICS()
{
require_once BPSP_PLUGIN_DIR . '/schedules/iCalcreator.class.php';
global $bp;
define('ICAL_LANG', get_bloginfo('language'));
$cal = new vcalendar();
$cal->setConfig('unique_id', str_replace('http://', '', get_bloginfo('siteurl')));
$cal->setConfig('filename', $bp->groups->current_group->slug);
$cal->setProperty('X-WR-CALNAME', __('Calendar for: ', 'bpsp') . $bp->groups->current_group->name);
$cal->setProperty('X-WR-CALDESC', $bp->groups->current_group->description);
$cal->setProperty('X-WR-TIMEZONE', get_option('timezone_string'));
$schedules = $this->has_schedules();
$assignments = BPSP_Assignments::has_assignments();
$entries = array_merge($assignments, $schedules);
foreach ($entries as $entry) {
setup_postdata($entry);
$e = new vevent();
if ($entry->post_type == "schedule") {
$date = getdate(strtotime($entry->start_date));
} elseif ($entry->post_type == "assignment") {
$date = getdate(strtotime($entry->post_date));
}
$dtstart['year'] = $date['year'];
$dtstart['month'] = $date['mon'];
$dtstart['day'] = $date['mday'];
$dtstart['hour'] = $date['hours'];
$dtstart['min'] = $date['minutes'];
$dtstart['sec'] = $date['seconds'];
$e->setProperty('dtstart', $dtstart);
$e->setProperty('description', get_the_content() . "\n\n" . $entry->permalink);
if (!empty($entry->location)) {
$e->setProperty('location', $entry->location);
}
if ($entry->post_type == "assignment") {
$entry->end_date = $entry->due_date;
}
// make assignments compatible with schedule parser
if (!empty($entry->end_date)) {
$date = getdate(strtotime($entry->end_date));
$dtend['year'] = $date['year'];
$dtend['month'] = $date['mon'];
$dtend['day'] = $date['mday'];
$dtend['hour'] = $date['hours'];
$dtend['min'] = $date['minutes'];
$dtend['sec'] = $date['seconds'];
$e->setProperty('dtend', $dtend);
} else {
$e->setProperty('duration', 0, 1, 0);
}
// Assume it's an one day event
$e->setProperty('summary', get_the_title($entry->ID));
$e->setProperty('status', 'CONFIRMED');
$cal->setComponent($e);
}
header("HTTP/1.1 200 OK");
die($cal->returnCalendar());
}
示例5: addItem
/**
* @param array $start
* @param array $end
* @param string $subject
* @param bool $allday
* @param string $description
* @param string $location
* @param null $color
* @param string $timezone
* @param bool $notification
* @param null $notification_type
* @param null $notification_value
* @return array|string
*/
public function addItem($start, $end, $subject, $allday = false, $description = "", $location = "", $color = null, $timezone = "", $notification = true, $notification_type = null, $notification_value = null)
{
$a = get_app();
$v = new vcalendar();
$v->setConfig('unique_id', $a->get_hostname());
$v->setProperty('method', 'PUBLISH');
$v->setProperty("x-wr-calname", "AnimexxCal");
$v->setProperty("X-WR-CALDESC", "Animexx Calendar");
$v->setProperty("X-WR-TIMEZONE", $a->timezone);
$vevent = dav_create_vevent($start, $end, $allday);
$vevent->setLocation(icalendar_sanitize_string($location));
$vevent->setSummary(icalendar_sanitize_string($subject));
$vevent->setDescription(icalendar_sanitize_string($description));
if (!is_null($color) && $color >= 0) {
$vevent->setProperty("X-ANIMEXX-COLOR", $color);
}
if ($notification && $notification_type == null) {
if ($allday) {
$notification_type = "hour";
$notification_value = 24;
} else {
$notification_type = "minute";
$notification_value = 60;
}
}
if ($notification) {
$valarm = new valarm();
$valarm->setTrigger($notification_type == "year" ? $notification_value : 0, $notification_type == "month" ? $notification_value : 0, $notification_type == "day" ? $notification_value : 0, $notification_type == "week" ? $notification_value : 0, $notification_type == "hour" ? $notification_value : 0, $notification_type == "minute" ? $notification_value : 0, $notification_type == "second" ? $notification_value : 0, true, $notification_value > 0);
$valarm->setAction("DISPLAY");
$valarm->setDescription($subject);
$vevent->setComponent($valarm);
}
$v->setComponent($vevent);
$ical = $v->createCalendar();
$obj_id = trim($vevent->getProperty("UID"));
$calendarBackend = new Sabre_CalDAV_Backend_Std();
$calendarBackend->createCalendarObject($this->getNamespace() . "-" . $this->namespace_id, $obj_id . ".ics", $ical);
return $obj_id . ".ics";
}
示例6: icalendar
//.........这里部分代码省略.........
// Set the timezone for this calendar based on the first event's info
// -------------------------------------
if ($key == 0) {
// -------------------------------------
// Convert calendar_name to calendar_id
// -------------------------------------
if ($this->P->value('calendar_id') == '' and $this->P->value('calendar_name') != '') {
$ids = $this->data->get_calendar_id_from_name($this->P->value('calendar_name'), NULL, $this->P->params['calendar_name']['details']['not']);
$this->P->set('calendar_id', implode('|', $ids));
}
//--------------------------------------------
// lets try to get the timezone from the
// passed calendar ID if there is one
//--------------------------------------------
$cal_timezone = FALSE;
$cal_tz_offset = FALSE;
if ($this->P->value('calendar_id') != '') {
$sql = "SELECT \ttz_offset, timezone\n\t\t\t\t\t\t\tFROM\texp_calendar_calendars\n\t\t\t\t\t\t\tWHERE \tcalendar_id\n\t\t\t\t\t\t\tIN \t\t(" . ee()->db->escape_str(implode(',', explode('|', $this->P->value('calendar_id')))) . ")\n\t\t\t\t\t\t\tLIMIT\t1";
$cal_tz_query = ee()->db->query($sql);
if ($cal_tz_query->num_rows() > 0) {
$cal_timezone = $cal_tz_query->row('timezone');
$cal_tz_offset = $cal_tz_query->row('tz_offset');
}
}
//last resort, we get it from the current event
$T = new vtimezone();
$T->setProperty('tzid', $cal_timezone ? $cal_timezone : $timezone);
$T->setProperty('tzoffsetfrom', '+0000');
$tzoffsetto = $cal_tz_offset ? $cal_tz_offset : $tz_offset;
if ($tzoffsetto === '0000') {
$tzoffsetto = '+0000';
}
$T->setProperty('tzoffsetto', $tzoffsetto);
$ICAL->setComponent($T);
}
$title = strip_tags($title);
$description = strip_tags(trim($summary));
$location = strip_tags(trim($location));
// -------------------------------------
// Occurrences?
// -------------------------------------
$occurrences = explode('|', rtrim($occurrences, '|'));
$odata = array();
foreach ($occurrences as $k => $occ) {
$occ = trim($occ);
if ($occ == '') {
continue;
}
$occ = explode($r, $occ);
$odata[$k][] = $occ[0];
$odata[$k][] = $occ[1];
}
// -------------------------------------
// Exceptions?
// -------------------------------------
$exceptions = explode('|', rtrim($exceptions, '|'));
$exdata = array();
foreach ($exceptions as $k => $exc) {
$exc = trim($exc);
if ($exc == '') {
continue;
}
$exdata[] = $exc;
}
// -------------------------------------
// Rules?
示例7: send_iCal
function send_iCal($entry_id)
{
global $login;
// ## Getting entry
$entry = getEntry($entry_id);
if (!count($entry)) {
return FALSE;
}
$description = template_ical($entry);
// ## Making iCal-element
$c = new vcalendar();
$e = new vevent();
$e->setProperty('dtstart', date('Y', $entry['time_start']), date('m', $entry['time_start']), date('d', $entry['time_start']), date('H', $entry['time_start']), date('i', $entry['time_start']), date('s', $entry['time_start']));
$e->setProperty('dtend', date('Y', $entry['time_end']), date('m', $entry['time_end']), date('d', $entry['time_end']), date('H', $entry['time_end']), date('i', $entry['time_end']), date('s', $entry['time_end']));
$e->setProperty('summary', $entry['entry_name']);
$e->setProperty('class', 'PUBLIC');
$e->setProperty('description', $description);
$e->setProperty('UID', 'entry' . $entry['entry_id'] . '@booking.jaermuseet.no');
$c->setProperty('method', 'REQUEST');
$c->setComponent($e);
$ical = str_replace('DTSTART', 'X-GWITEM-TYPE:APPOINTMENT' . chr(10) . 'DTSTART', $c->createCalendar());
// ## Sending mail
// Need to find who we are sending it to
$users = array();
foreach ($entry['user_assigned'] as $user_id) {
$user = getUser($user_id);
if (count($user)) {
$users[$user_id] = $user['user_email'];
}
}
// Sending to the users
foreach ($users as $user_mail) {
$rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$rand}x";
$subject = 'Stadfesting av bestilling - ' . date('d-m-Y', $entry['time_start']) . ': ' . $entry['entry_name'];
if (isset($login['user_email']) && $login['user_email'] != '') {
$headers = 'From: ' . $login['user_email'];
} else {
$headers = 'From: ' . constant('EMAIL_FROM');
}
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . "{$description}\n\n";
// iCal
$message .= "--{$mime_boundary}\n" . "Content-class: urn:content-classes:calendarmessage\n" . "Content-type: text/calendar; method=REQUEST; name=meeting.ics; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n";
$message .= $ical;
$message .= "\n--{$mime_boundary}--";
$ok = mail($user_mail, $subject, $message, $headers);
$ok = true;
if (!$ok) {
// TODO: Error handling for mail not sent
echo 'Faild sending mail. Please contact somebody!!';
exit;
} else {
// It's okey...
}
}
// ## Loging iCal sending
// TODO: Log iCal sending
return TRUE;
}
示例8: list
$M2 = $M2 - 60;
$h2 += 1;
}
} else {
list($y2, $m2, $d2, $h2, $M2, $s2) = preg_split('/[\\s:-]/', $event['end_date']);
}
$vevent->setProperty('dtend', array('year' => $y2, 'month' => $m2, 'day' => $d2, 'hour' => $h2, 'min' => $M2, 'sec' => $s2));
//$vevent->setProperty( 'LOCATION', get_lang('Unknown') ); // property name - case independent
$vevent->setProperty('description', api_convert_encoding($event['description'], 'UTF-8', $charset));
//$vevent->setProperty( 'comment', 'This is a comment' );
//$user = api_get_user_info($event['user']);
//$vevent->setProperty('organizer',$user['mail']);
//$vevent->setProperty('attendee',$user['mail']);
//$vevent->setProperty( 'rrule', array( 'FREQ' => 'WEEKLY', 'count' => 4));// occurs also four next weeks
$ical->setConfig('filename', $y . $m . $d . $h . $M . $s . '-' . rand(1, 1000) . '.ics');
$ical->setComponent($vevent);
// add event to calendar
$ical->returnCalendar();
break;
case 'course':
$vevent->setProperty('summary', api_convert_encoding($event['title'], 'UTF-8', $charset));
if (empty($event['start_date'])) {
header('location:' . Security::remove_XSS($_SERVER['HTTP_REFERER']));
}
list($y, $m, $d, $h, $M, $s) = preg_split('/[\\s:-]/', $event['start_date']);
$vevent->setProperty('dtstart', array('year' => $y, 'month' => $m, 'day' => $d, 'hour' => $h, 'min' => $M, 'sec' => $s));
if (empty($event['end_date'])) {
$y2 = $y;
$m2 = $m;
$d2 = $d;
$h2 = $h;
示例9: generateIcal
/**
* Generate ical file content
*
* @param $who user ID
* @param $who_group group ID
*
* @return icalendar string
**/
static function generateIcal($who, $who_group)
{
global $CFG_GLPI, $LANG;
if ($who == 0 && $who_group == 0) {
return false;
}
include_once GLPI_ROOT . "/lib/icalcreator/iCalcreator.class.php";
$v = new vcalendar();
if (!empty($CFG_GLPI["version"])) {
$v->setConfig('unique_id', "GLPI-Planning-" . trim($CFG_GLPI["version"]));
} else {
$v->setConfig('unique_id', "GLPI-Planning-UnknownVersion");
}
$v->setConfig('filename', "glpi.ics");
$v->setProperty("method", "PUBLISH");
$v->setProperty("version", "2.0");
$v->setProperty("x-wr-calname", "GLPI-" . $who . "-" . $who_group);
$v->setProperty("calscale", "GREGORIAN");
$interv = array();
$begin = time() - MONTH_TIMESTAMP * 12;
$end = time() + MONTH_TIMESTAMP * 12;
$begin = date("Y-m-d H:i:s", $begin);
$end = date("Y-m-d H:i:s", $end);
// ---------------Tracking
$interv = TicketPlanning::populatePlanning(array('who' => $who, 'who_group' => $who_group, 'begin' => $begin, 'end' => $end));
// ---------------Reminder
$data = Reminder::populatePlanning(array('who' => $who, 'who_group' => $who_group, 'begin' => $begin, 'end' => $end));
$interv = array_merge($interv, $data);
// ---------------Plugin
$data = doHookFunction("planning_populate", array("begin" => $begin, "end" => $end, "who" => $who, "who_group" => $who_group));
if (isset($data["items"]) && count($data["items"])) {
$interv = array_merge($data["items"], $interv);
}
if (count($interv) > 0) {
foreach ($interv as $key => $val) {
$vevent = new vevent();
//initiate EVENT
if (isset($val["tickettasks_id"])) {
$vevent->setProperty("uid", "Job#" . $val["tickettasks_id"]);
} else {
if (isset($val["reminders_id"])) {
$vevent->setProperty("uid", "Event#" . $val["reminders_id"]);
} else {
if (isset($val['planningID'])) {
// Specify the ID (for plugins)
$vevent->setProperty("uid", "Plugin#" . $val['planningID']);
} else {
$vevent->setProperty("uid", "Plugin#" . $key);
}
}
}
$vevent->setProperty("dstamp", $val["begin"]);
$vevent->setProperty("dtstart", $val["begin"]);
$vevent->setProperty("dtend", $val["end"]);
if (isset($val["tickets_id"])) {
$vevent->setProperty("summary", $LANG['planning'][8] . " # " . $val["tickets_id"] . " " . $LANG['document'][14] . " # " . $val["device"]);
} else {
if (isset($val["name"])) {
$vevent->setProperty("summary", $val["name"]);
}
}
if (isset($val["content"])) {
$vevent->setProperty("description", html_clean($val["content"]));
} else {
if (isset($val["name"])) {
$vevent->setProperty("description", $val["name"]);
}
}
if (isset($val["tickets_id"])) {
$vevent->setProperty("url", $CFG_GLPI["url_base"] . "/index.php?redirect=tracking_" . $val["tickets_id"]);
}
$v->setComponent($vevent);
}
}
$v->sort();
//$v->parse();
return $v->returnCalendar();
}
示例10: display
function display($tpl = null)
{
// Get a reference of the page instance in joomla
$document = JFactory::getDocument();
$model = $this->getModel();
$project = $model->getProject();
//$config = $model->getTemplateConfig($this->getName());
if (isset($project)) {
$this->project = $project;
}
$this->overallconfig = $model->getOverallConfig();
$this->config = $this->overallconfig;
$this->matches = $model->getMatches();
$this->teams = $model->getTeamsFromMatches($this->matches);
// load a class that handles ical formats.
require_once JLG_PATH_SITE . DS . 'helpers' . DS . 'iCalcreator.class.php';
// create a new calendar instance
$v = new vcalendar();
foreach ($this->matches as $match) {
$hometeam = $this->teams[$match->team1];
$home = sprintf('%s', $hometeam->name);
$guestteam = $this->teams[$match->team2];
$guest = sprintf('%s', $guestteam->name);
$summary = $match->project_name . ': ' . $home . ' - ' . $guest;
// check if match gots a date, if not it will not be included in ical
if ($match->match_date) {
$totalMatchTime = isset($project) ? $project->halftime * ($project->game_parts - 1) + $project->game_regular_time : 90;
$start = JoomleagueHelper::getMatchStartTimestamp($match, 'Y-m-d H:i:s');
$end = JoomleagueHelper::getMatchEndTimestamp($match, $totalMatchTime, 'Y-m-d H:i:s');
// check if exist a playground in match or team or club
$stringlocation = '';
$stringname = '';
if (!empty($match->playground_id)) {
$stringlocation = $match->playground_address . ", " . $match->playground_zipcode . " " . $match->playground_city;
$stringname = $match->playground_name;
} elseif (!empty($match->team_playground_id)) {
$stringlocation = $match->team_playground_address . ", " . $match->team_playground_zipcode . " " . $match->team_playground_city;
$stringname = $match->team_playground_name;
} elseif (!empty($match->club_playground_id)) {
$stringlocation = $match->club_playground_address . ", " . $match->club_playground_zipcode . " " . $match->club_playground_city;
$stringname = $match->club_playground_name;
}
$location = $stringlocation;
//if someone want to insert more in description here is the place
$description = $stringname;
// create an event and insert it in calendar
$vevent = new vevent();
$timezone = JoomleagueHelper::getMatchTimezone($match);
$vevent->setProperty("dtstart", $start, array("TZID" => $timezone));
$vevent->setProperty("dtend", $end, array("TZID" => $timezone));
$vevent->setProperty('LOCATION', $location);
$vevent->setProperty('summary', $summary);
$vevent->setProperty('description', $description);
$v->setComponent($vevent);
}
}
$v->setProperty("X-WR-TIMEZONE", $timezone);
$xprops = array("X-LIC-LOCATION" => $timezone);
iCalUtilityFunctions::createTimezone($v, $timezone, $xprops);
$v->returnCalendar();
//$debugstr = $v->createCalendar();
//echo "<pre>";
//echo $debugstr;
// exit before display
// parent::display( $tpl );
}
示例11: answerInvitation
/**
* @param string $iCal
* @param string $myEmail
* @param int $answer possible values: accept: 1, maybe: 2, decline: 3
*/
public static function answerInvitation(string $iCal, string $myEmail, int $answer)
{
if ($answer == "1") {
$text = "akzeptiert";
}
if ($answer == "2") {
$text = "vorläufig akzeptiert";
}
if ($answer == "3") {
$text = "abgelehnt";
}
$VC = new vcalendar();
$VC->parse($iCal);
$event = $VC->getComponent("vevent");
$targetAttendee = "MAILTO:" . $myEmail;
$i = 1;
while ($valueOccur = $event->getProperty("ATTENDEE", $i, true)) {
if (stripos($valueOccur["value"], $targetAttendee) === false) {
$i++;
continue;
}
$params = $valueOccur["params"];
if ($answer == "1") {
$params["PARTSTAT"] = "ACCEPTED";
}
if ($answer == "2") {
$params["PARTSTAT"] = "TENTATIVE";
}
if ($answer == "3") {
$params["PARTSTAT"] = "DECLINED";
}
if (isset($params["RSVP"])) {
unset($params["RSVP"]);
}
$event->setAttendee($targetAttendee, $params, $i);
$i++;
}
$i = 1;
while ($valueOccur = $event->getProperty("ATTENDEE", $i, true)) {
if (stripos($valueOccur["value"], $targetAttendee) === false) {
$i++;
$event->deleteProperty("ATTENDEE");
continue;
}
$i++;
}
$event->setProperty("DTSTAMP", gmdate("Ymd") . "T" . gmdate("His") . "Z");
$event->setProperty("LAST-MODIFIED", gmdate("Ymd") . "T" . gmdate("His") . "Z");
$VC->deleteComponent("vevent");
$VC->setComponent($event);
$VC->setMethod("REPLY");
$ics = $VC->createCalendar();
$fromName = Session::currentUser()->A("name");
$from = Session::currentUser()->A("UserEmail");
$mail = new htmlMimeMail5();
$mail->setFrom(utf8_decode($fromName . " <" . $from . ">"));
if (!ini_get('safe_mode')) {
$mail->setReturnPath($from);
}
$mail->setSubject(utf8_decode("Antwort Termineinladung (" . ucfirst($text) . "): " . $event->getProperty("SUMMARY")));
$mail->addAttachment(new stringAttachment($ics, "invite.ics", 'application/ics'));
$mail->setCalendar($ics, "REPLY");
$mail->setCalendarCharset("UTF-8");
$mail->setTextCharset("UTF-8");
$mail->setText("{$fromName} hat diesen Termin {$text}");
$organizer = str_replace("MAILTO:", "", $event->getProperty("ORGANIZER"));
return $mail->send(array($organizer));
}
示例12: vcalendar
<?php
/**
* Create a ical for the upcoming recordings
*
* @license GPL
*
* @package MythWeb
* @subpackage TV
*
**/
$calendar = new vcalendar();
$calendar->setConfig($_SERVER['SERVER_SIGNATURE'], $_SERVER['HTTP_HOST']);
$calendar->setProperty('method', 'PUBLISH');
foreach ($all_shows as $show) {
$event = new vevent();
$event->setProperty('dtstart', array('year' => date('Y', $show->starttime), 'month' => date('m', $show->starttime), 'day' => date('d', $show->starttime), 'hour' => date('H', $show->starttime), 'min' => date('i', $show->starttime), 'sec' => date('s', $show->starttime)));
$event->setProperty('dtend', array('year' => date('Y', $show->endtime), 'month' => date('m', $show->endtime), 'day' => date('d', $show->endtime), 'hour' => date('H', $show->endtime), 'min' => date('i', $show->endtime), 'sec' => date('s', $show->endtime)));
$event->setProperty('summary', $show->title . ($show->subtitle ? ' - ' . $show->subtitle : ''));
$event->setProperty('description', $show->description . "\n\n" . preg_replace('/([A-Z]+)/', ' $1', $show->recstatus));
$event->setProperty('location', $show->channel->callsign);
$calendar->setComponent($event);
}
$calendar->returnCalendar();
示例13: createTestFile
function createTestFile()
{
$dirFile = CALDIR . DIRECTORY_SEPARATOR . TESTFILE;
$calendar = new vcalendar();
$calendar->setConfig('unique_id', UNIQUE);
if (!$calendar->setConfig('directory', CALDIR)) {
addLogEntry(1, ' ERROR (11) when setting directory \'' . CALDIR . '\', check directory/file permissions!!');
return FALSE;
} elseif (!$calendar->setConfig('filename', TESTFILE)) {
addLogEntry(1, " ERROR (12) when setting directory/file '{$dirFile}', check directory/file permissions!!");
return FALSE;
}
$calendar->setProperty('METHOD', METHOD);
$calendar->setProperty('X-WR-CALNAME', CALNAME);
$calendar->setProperty('X-WR-CALDESC', CALDESC);
$calendar->setProperty('X-WR-TIMEZONE', TIMEZONE);
$date = mktime(0, 0, 0, (int) substr(THISDATE, 4, 2), (int) substr(THISDATE, 6, 2), (int) substr(THISDATE, 0, 4));
$stopDate = $date + 7 * 24 * 3600;
$eventCount = 1;
// random priority, 1 to 9. HIGH (1-4), MEDIUM (5), LOW (6-9)
// reversed prio; HIGH: weight 1, MEDIUM weight 4, LOW: weight 8
$prioArr = array();
for ($r = 1; $r <= 9; $r++) {
$weight = 5 < $r ? 1 : 5 > $r ? 8 : 4;
for ($r1 = 1; $r1 <= $weight; $r1++) {
$prioArr[] = $r;
}
}
mt_srand();
shuffle($prioArr);
// array to randomly select a summary from
$summaries = array('Duis ac dui sit amet ante auctor euismod.', 'Suspendisse_pellentesque_velit_in_tortor.', 'Mauris vulputate.', 'Nulla sapien pede, dapibus sed.', 'Maecenas tristique, pede_id_sollicitudin_posuere, enim nibh mollis odio.', 'Lorem ipsum dolor sit amet, consectetuerAdipiscingElit.');
while ($date <= $stopDate) {
$dayCount = 1;
while ($dayCount < 4) {
$event = new vevent();
$eventdate = $date + mt_rand(7, 18) * 3600;
// random start hour, 7 to 18
$event->setProperty('DTSTART', array('timestamp' => $eventdate));
// random duration, 1-4 hours or 2 days
if (9 > mt_rand(1, 9)) {
$event->setProperty('DURATION', 0, 0, mt_rand(1, 4));
} else {
$event->setProperty('DURATION', 0, 2);
}
// 2 days duration
$event->setProperty('SUMMARY', "Event #{$eventCount}. " . $summaries[mt_rand(0, 5)]);
$event->setProperty('CATEGORIES', "Category #{$eventCount}");
$event->setProperty('LOCATION', "Location #{$eventCount}");
$event->setProperty('RESOURCES', "Resource #{$eventCount}");
$event->setProperty('ORGANIZER', "chair.{$eventCount}@" . UNIQUE);
$event->setProperty('CONTACT', "contact.{$eventCount}@" . UNIQUE);
$event->setProperty('DESCRIPTION', 'Lorem ipsum dolor sit amet, ' . 'consectetuer adipiscing elit. ' . 'Mauris vulputate. Suspendisse ' . 'pellentesque velit in tortor. ' . 'Nulla sapien pede, dapibus sed.');
// random priority, 1 to 9. HIGH (1-4), MEDIUM (5), LOW (6-9)
$event->setProperty('PRIORITY', $prioArr[mt_rand(0, count($prioArr) - 1)]);
// two attendees every event
$event->setProperty('ATTENDEE', 'attendee.' . $eventCount . '.1@' . UNIQUE);
$event->setProperty('ATTENDEE', 'attendee.' . $eventCount . '.2@' . UNIQUE);
// two comments every event
$event->setProperty('COMMENT', 'Duis ac dui sit amet ante auctor euismod. Sed vulputate.');
$event->setProperty('COMMENT', 'Maecenas tristique, pede id sollicitudin posuere, enim nibh mollis odio.');
$event->setProperty('CREATED', array('timestamp' => $eventdate - 2 * 24 * 3600));
// fake two days before event startdate
$event->setProperty('LAST-MODIFIED', array('timestamp' => $eventdate - 23 * 3600));
// fake 25 hours before event startdate
if (5 > $eventCount) {
$event->setProperty('RRULE', array('FREQ' => 'DAILY', 'COUNT' => 4, 'INTERVAL' => 3));
$event->setProperty('EXRULE', array('FREQ' => 'DAILY', 'COUNT' => 2, 'INTERVAL' => 6));
}
$event->setProperty('URL', 'http://www.kigkonsult.se/tinycal/index.php');
if (FALSE === $calendar->setComponent($event)) {
error_log('setComponent error');
}
$eventCount++;
$dayCount++;
}
$date += 24 * 3600;
}
$calendar->sort();
if (FALSE === $calendar->saveCalendar()) {
addLogEntry(1, " ERROR (13) saving calendar file '{$dirFile}'");
}
}
示例14: foreach
//Get events
$q = $dbh->prepare("SELECT * FROM `cm_events_responsibles`,`cm_events`\n\t\tWHERE cm_events_responsibles.username = ?\n\t\tAND cm_events_responsibles.event_id = cm_events.id\n\t\tORDER by cm_events.start DESC");
$q->bindParam(1, $user);
$q->execute();
$events = $q->fetchAll(PDO::FETCH_ASSOC);
foreach ($events as $event) {
$case_name = case_id_to_casename($dbh, $event['case_id']);
$e = new vevent();
// initiate EVENT
if ($event['all_day'] == '1') {
$start = explode(' ', $event['start']);
//all-day events are date only
$e->setProperty('dtstart', $start[0]);
if ($event['end'] == null) {
$e->setProperty('dtend', $start[0]);
//make end same as event
} else {
$end = explode(' ', $event['end']);
$e->setProperty('dtend', $end[0]);
}
} else {
$e->setProperty('dtstart', $event['start']);
$e->setProperty('dtend', $event['end']);
}
$e->setProperty('summary', $case_name . ": " . $event['task']);
$e->setProperty('description', $event['notes']);
$v->setComponent($e);
}
$cal = $v->createCalendar();
echo $cal;
}
示例15: getICalData
private function getICalData($event)
{
// set Your unique id
$config = array('unique_id' => 'ravebuild.com');
$caldesc_string = "RaveBuild-Calendar Events";
// create a new calendar instance
$v_calendar = new vcalendar($config);
// set download file name
$v_calendar->filename = md5($event->getId()) . '.ics';
// required of some calendar software
$v_calendar->setProperty('method', 'PUBLISH');
$v_calendar->setProperty('X-WR-CALNAME;VALUE=TEXT', $caldesc_string);
$v_calendar->setProperty("X-WR-CALDESC", "This is " . $caldesc_string);
$v_calendar->setProperty("X-WR-TIMEZONE", "Pacific/Auckland");
$start_time = strtotime($event->getStartTime());
$end_time = strtotime($event->getStartTime());
$end_hour = date('H', strtotime($event->getEndTime()));
// star time
$start = array('year' => date('Y', $start_time), 'month' => date('m', $start_time), 'day' => date('d', $start_time), 'hour' => date('H', $start_time), 'min' => 0, 'sec' => 0);
// end time
$end = array('year' => date('Y', $end_time), 'month' => date('m', $end_time), 'day' => date('d', $end_time), 'hour' => $end_hour, 'min' => 0, 'sec' => 0);
$v_event = new vevent();
// create an event calendar component
$v_event->setProperty('uid', md5($event->getId()));
//$v_event->setProperty("recurrence-id", $start);
$v_event->setProperty('created', $event->getCreatedAt());
$v_event->setProperty('last-modified', $event->getUpdatedAt());
$v_event->setProperty('dtstart', $start);
$v_event->setProperty('dtend', $end);
$v_event->setProperty('summary', $event->getSubject());
$v_event->setProperty('description', $event->getBody());
$v_calendar->setComponent($v_event);
return $v_calendar;
}