本文整理汇总了PHP中vcalendar::deleteComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP vcalendar::deleteComponent方法的具体用法?PHP vcalendar::deleteComponent怎么用?PHP vcalendar::deleteComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vcalendar
的用法示例。
在下文中一共展示了vcalendar::deleteComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateItem
/**
* @param string $uri
* @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
* @throws Sabre_DAV_Exception_NotFound
* @throws Sabre_DAV_Exception_Conflict
*/
public function updateItem($uri, $start, $end, $subject = "", $allday = false, $description = "", $location = "", $color = null, $timezone = "", $notification = true, $notification_type = null, $notification_value = null)
{
$a = get_app();
$usr_id = IntVal($this->calendarDb->uid);
$old = q("SELECT * FROM %s%sjqcalendar WHERE `uid` = %d AND `namespace` = %d AND `namespace_id` = %d AND `ical_uri` = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $usr_id, $this->getNamespace(), $this->namespace_id, dbesc($uri));
if (count($old) == 0) {
throw new Sabre_DAV_Exception_NotFound("Not Found 1");
}
$old_obj = new DBClass_friendica_jqcalendar($old[0]);
$calendarBackend = new Sabre_CalDAV_Backend_Std();
$obj = $calendarBackend->getCalendarObject($this->getNamespace() . "-" . $this->namespace_id, $old_obj->ical_uri);
if (!$obj) {
throw new Sabre_DAV_Exception_NotFound("Not Found 2");
}
$v = new vcalendar();
$v->setConfig('unique_id', $a->get_hostname());
$v->setMethod('PUBLISH');
$v->setProperty("x-wr-calname", "AnimexxCal");
$v->setProperty("X-WR-CALDESC", "Animexx Calendar");
$v->setProperty("X-WR-TIMEZONE", $a->timezone);
$obj["calendardata"] = icalendar_sanitize_string($obj["calendardata"]);
$v->parse($obj["calendardata"]);
/** @var $vevent vevent */
$vevent = $v->getComponent('vevent');
if (trim($vevent->getProperty('uid')) . ".ics" != $old_obj->ical_uri) {
throw new Sabre_DAV_Exception_Conflict("URI != URI: " . $old_obj->ical_uri . " vs. " . trim($vevent->getProperty("uid")));
}
if ($end["year"] < $start["year"] || $end["year"] == $start["year"] && $end["month"] < $start["month"] || $end["year"] == $start["year"] && $end["month"] == $start["month"] && $end["day"] < $start["day"] || $end["year"] == $start["year"] && $end["month"] == $start["month"] && $end["day"] == $start["day"] && $end["hour"] < $start["hour"] || $end["year"] == $start["year"] && $end["month"] == $start["month"] && $end["day"] == $start["day"] && $end["hour"] == $start["hour"] && $end["minute"] < $start["minute"] || $end["year"] == $start["year"] && $end["month"] == $start["month"] && $end["day"] == $start["day"] && $end["hour"] == $start["hour"] && $end["minute"] == $start["minute"] && $end["second"] < $start["second"]) {
$end = $start;
if ($end["hour"] < 23) {
$end["hour"]++;
}
}
// DTEND muss <= DTSTART
if ($start["hour"] == 0 && $start["minute"] == 0 && $end["hour"] == 23 && $end["minute"] == 59) {
$allday = true;
}
if ($allday) {
$vevent->setDtstart($start["year"], $start["month"], $start["day"], FALSE, FALSE, FALSE, FALSE, array("VALUE" => "DATE"));
$end = mktime(0, 0, 0, $end["month"], $end["day"], $end["year"]) + 3600 * 24;
// If a DST change occurs on the current day
$end += date("Z", $end - 3600 * 24) - date("Z", $end);
$vevent->setDtend(date("Y", $end), date("m", $end), date("d", $end), FALSE, FALSE, FALSE, FALSE, array("VALUE" => "DATE"));
} else {
$vevent->setDtstart($start["year"], $start["month"], $start["day"], $start["hour"], $start["minute"], $start["second"], FALSE, array("VALUE" => "DATE-TIME"));
$vevent->setDtend($end["year"], $end["month"], $end["day"], $end["hour"], $end["minute"], $end["second"], FALSE, array("VALUE" => "DATE-TIME"));
}
if ($subject != "") {
$vevent->setProperty('LOCATION', $location);
$vevent->setProperty('summary', $subject);
$vevent->setProperty('description', $description);
}
if (!is_null($color) && $color >= 0) {
$vevent->setProperty("X-ANIMEXX-COLOR", $color);
}
if (!$notification || $notification_type != null) {
$vevent->deleteComponent("VALARM");
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 == "minute" ? $notification_value : 0, true, $notification_value > 0);
$valarm->setProperty("ACTION", "DISPLAY");
$valarm->setProperty("DESCRIPTION", $subject);
$vevent->setComponent($valarm);
}
}
$v->deleteComponent("vevent");
$v->setComponent($vevent, trim($vevent->getProperty("uid")));
$ical = $v->createCalendar();
$calendarBackend->updateCalendarObject($this->getNamespace() . "-" . $this->namespace_id, $old_obj->ical_uri, $ical);
}
示例2: 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));
}