From fc4f2848d9274adba2baad5f8a6a54d1c18ec791 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20H=C3=B6=C3=9Fl?= Date: Sun, 8 Jul 2012 17:14:39 +0000 Subject: [PATCH] Heavily refactored, including multiple calendars per user and recurring events. Not in an installable state yet, though --- dav/Changelog.txt | 3 +- .../lib/Sabre/VObject/WindowsTimezoneMap.php | 128 - dav/common/dav_caldav_backend.inc.php | 174 - ...bclass.friendica.calendarobjects.class.php | 28 - .../dbclass.friendica.calendars.class.php | 29 - .../dbclass.friendica.jqcalendar.class.php | 35 - .../dbclass.friendica.notifications.class.php | 40 - .../dbclasses/dbclass_animexx.class.php | 50 - dav/common/virtual_cal_source_backend.inc.php | 63 - dav/common/wdcal_cal_source.inc.php | 138 - dav/common/wdcal_cal_source_private.inc.php | 332 - dav/dav_caldav_backend_friendica.inc.php | 141 - ...arddav_backend_friendica_community.inc.php | 320 - dav/iCalcreator/iCalcreator.class.php | 10181 ---------------- dav/iCalcreator/lgpl.txt | 504 - dav/iCalcreator/releaseNotes-2.12.txt | 88 - dav/iCalcreator/releaseSummary.txt | 31 - dav/iCalcreator/summary.html | 387 - dav/jqueryui/jquery-ui-1.8.20.custom.css | 354 - dav/jqueryui/jquery-ui-1.8.20.custom.min.js | 9 - dav/virtual_cal_source_friendica.inc.php | 169 - dav/wdcal/Changelog.txt | 10 - dav/wdcal_cal_source_friendicaevents.inc.php | 164 - 23 files changed, 2 insertions(+), 13376 deletions(-) delete mode 100644 dav/SabreDAV/lib/Sabre/VObject/WindowsTimezoneMap.php delete mode 100644 dav/common/dav_caldav_backend.inc.php delete mode 100644 dav/common/dbclasses/dbclass.friendica.calendarobjects.class.php delete mode 100644 dav/common/dbclasses/dbclass.friendica.calendars.class.php delete mode 100644 dav/common/dbclasses/dbclass.friendica.jqcalendar.class.php delete mode 100644 dav/common/dbclasses/dbclass.friendica.notifications.class.php delete mode 100644 dav/common/dbclasses/dbclass_animexx.class.php delete mode 100644 dav/common/virtual_cal_source_backend.inc.php delete mode 100644 dav/common/wdcal_cal_source.inc.php delete mode 100644 dav/common/wdcal_cal_source_private.inc.php delete mode 100644 dav/dav_caldav_backend_friendica.inc.php delete mode 100644 dav/dav_carddav_backend_friendica_community.inc.php delete mode 100755 dav/iCalcreator/iCalcreator.class.php delete mode 100755 dav/iCalcreator/lgpl.txt delete mode 100755 dav/iCalcreator/releaseNotes-2.12.txt delete mode 100755 dav/iCalcreator/releaseSummary.txt delete mode 100755 dav/iCalcreator/summary.html delete mode 100644 dav/jqueryui/jquery-ui-1.8.20.custom.css delete mode 100644 dav/jqueryui/jquery-ui-1.8.20.custom.min.js delete mode 100644 dav/virtual_cal_source_friendica.inc.php delete mode 100644 dav/wdcal/Changelog.txt delete mode 100644 dav/wdcal_cal_source_friendicaevents.inc.php diff --git a/dav/Changelog.txt b/dav/Changelog.txt index 4ee89498..a252673e 100644 --- a/dav/Changelog.txt +++ b/dav/Changelog.txt @@ -1,6 +1,7 @@ -v0.2.0 +v0.2.0-pre ====== [FEATURE] Multiple private Calendars can be created. +[FEATURE] Support for recurring events. [COMPATIBILITY] When creating or updating an event using CalDAV, the etag is returned. v0.1.1 diff --git a/dav/SabreDAV/lib/Sabre/VObject/WindowsTimezoneMap.php b/dav/SabreDAV/lib/Sabre/VObject/WindowsTimezoneMap.php deleted file mode 100644 index 5e1cc5d4..00000000 --- a/dav/SabreDAV/lib/Sabre/VObject/WindowsTimezoneMap.php +++ /dev/null @@ -1,128 +0,0 @@ -'Australia/Darwin', - 'AUS Eastern Standard Time'=>'Australia/Sydney', - 'Afghanistan Standard Time'=>'Asia/Kabul', - 'Alaskan Standard Time'=>'America/Anchorage', - 'Arab Standard Time'=>'Asia/Riyadh', - 'Arabian Standard Time'=>'Asia/Dubai', - 'Arabic Standard Time'=>'Asia/Baghdad', - 'Argentina Standard Time'=>'America/Buenos_Aires', - 'Armenian Standard Time'=>'Asia/Yerevan', - 'Atlantic Standard Time'=>'America/Halifax', - 'Azerbaijan Standard Time'=>'Asia/Baku', - 'Azores Standard Time'=>'Atlantic/Azores', - 'Bangladesh Standard Time'=>'Asia/Dhaka', - 'Canada Central Standard Time'=>'America/Regina', - 'Cape Verde Standard Time'=>'Atlantic/Cape_Verde', - 'Caucasus Standard Time'=>'Asia/Yerevan', - 'Cen. Australia Standard Time'=>'Australia/Adelaide', - 'Central America Standard Time'=>'America/Guatemala', - 'Central Asia Standard Time'=>'Asia/Almaty', - 'Central Brazilian Standard Time'=>'America/Cuiaba', - 'Central Europe Standard Time'=>'Europe/Budapest', - 'Central European Standard Time'=>'Europe/Warsaw', - 'Central Pacific Standard Time'=>'Pacific/Guadalcanal', - 'Central Standard Time'=>'America/Chicago', - 'Central Standard Time (Mexico)'=>'America/Mexico_City', - 'China Standard Time'=>'Asia/Shanghai', - 'Dateline Standard Time'=>'Etc/GMT+12', - 'E. Africa Standard Time'=>'Africa/Nairobi', - 'E. Australia Standard Time'=>'Australia/Brisbane', - 'E. Europe Standard Time'=>'Europe/Minsk', - 'E. South America Standard Time'=>'America/Sao_Paulo', - 'Eastern Standard Time'=>'America/New_York', - 'Egypt Standard Time'=>'Africa/Cairo', - 'Ekaterinburg Standard Time'=>'Asia/Yekaterinburg', - 'FLE Standard Time'=>'Europe/Kiev', - 'Fiji Standard Time'=>'Pacific/Fiji', - 'GMT Standard Time'=>'Europe/London', - 'GTB Standard Time'=>'Europe/Istanbul', - 'Georgian Standard Time'=>'Asia/Tbilisi', - 'Greenland Standard Time'=>'America/Godthab', - 'Greenwich Standard Time'=>'Atlantic/Reykjavik', - 'Hawaiian Standard Time'=>'Pacific/Honolulu', - 'India Standard Time'=>'Asia/Calcutta', - 'Iran Standard Time'=>'Asia/Tehran', - 'Israel Standard Time'=>'Asia/Jerusalem', - 'Jordan Standard Time'=>'Asia/Amman', - 'Kamchatka Standard Time'=>'Asia/Kamchatka', - 'Korea Standard Time'=>'Asia/Seoul', - 'Magadan Standard Time'=>'Asia/Magadan', - 'Mauritius Standard Time'=>'Indian/Mauritius', - 'Mexico Standard Time'=>'America/Mexico_City', - 'Mexico Standard Time 2'=>'America/Chihuahua', - 'Mid-Atlantic Standard Time'=>'Etc/GMT+2', - 'Middle East Standard Time'=>'Asia/Beirut', - 'Montevideo Standard Time'=>'America/Montevideo', - 'Morocco Standard Time'=>'Africa/Casablanca', - 'Mountain Standard Time'=>'America/Denver', - 'Mountain Standard Time (Mexico)'=>'America/Chihuahua', - 'Myanmar Standard Time'=>'Asia/Rangoon', - 'N. Central Asia Standard Time'=>'Asia/Novosibirsk', - 'Namibia Standard Time'=>'Africa/Windhoek', - 'Nepal Standard Time'=>'Asia/Katmandu', - 'New Zealand Standard Time'=>'Pacific/Auckland', - 'Newfoundland Standard Time'=>'America/St_Johns', - 'North Asia East Standard Time'=>'Asia/Irkutsk', - 'North Asia Standard Time'=>'Asia/Krasnoyarsk', - 'Pacific SA Standard Time'=>'America/Santiago', - 'Pacific Standard Time'=>'America/Los_Angeles', - 'Pacific Standard Time (Mexico)'=>'America/Santa_Isabel', - 'Pakistan Standard Time'=>'Asia/Karachi', - 'Paraguay Standard Time'=>'America/Asuncion', - 'Romance Standard Time'=>'Europe/Paris', - 'Russian Standard Time'=>'Europe/Moscow', - 'SA Eastern Standard Time'=>'America/Cayenne', - 'SA Pacific Standard Time'=>'America/Bogota', - 'SA Western Standard Time'=>'America/La_Paz', - 'SE Asia Standard Time'=>'Asia/Bangkok', - 'Samoa Standard Time'=>'Pacific/Apia', - 'Singapore Standard Time'=>'Asia/Singapore', - 'South Africa Standard Time'=>'Africa/Johannesburg', - 'Sri Lanka Standard Time'=>'Asia/Colombo', - 'Syria Standard Time'=>'Asia/Damascus', - 'Taipei Standard Time'=>'Asia/Taipei', - 'Tasmania Standard Time'=>'Australia/Hobart', - 'Tokyo Standard Time'=>'Asia/Tokyo', - 'Tonga Standard Time'=>'Pacific/Tongatapu', - 'US Eastern Standard Time'=>'America/Indianapolis', - 'US Mountain Standard Time'=>'America/Phoenix', - 'UTC'=>'Etc/GMT', - 'UTC+12'=>'Etc/GMT-12', - 'UTC-02'=>'Etc/GMT+2', - 'UTC-11'=>'Etc/GMT+11', - 'Ulaanbaatar Standard Time'=>'Asia/Ulaanbaatar', - 'Venezuela Standard Time'=>'America/Caracas', - 'Vladivostok Standard Time'=>'Asia/Vladivostok', - 'W. Australia Standard Time'=>'Australia/Perth', - 'W. Central Africa Standard Time'=>'Africa/Lagos', - 'W. Europe Standard Time'=>'Europe/Berlin', - 'West Asia Standard Time'=>'Asia/Tashkent', - 'West Pacific Standard Time'=>'Pacific/Port_Moresby', - 'Yakutsk Standard Time'=>'Asia/Yakutsk', - ); - - static public function lookup($tzid) { - return isset(self::$map[$tzid]) ? self::$map[$tzid] : null; - } -} diff --git a/dav/common/dav_caldav_backend.inc.php b/dav/common/dav_caldav_backend.inc.php deleted file mode 100644 index c09d48d9..00000000 --- a/dav/common/dav_caldav_backend.inc.php +++ /dev/null @@ -1,174 +0,0 @@ - IntVal($obj["id"]), - "calendardata" => $obj["calendardata"], - "uri" => $obj["uri"], - "lastmodified" => $obj["lastmodified"], - "calendarid" => $calendarId, - "etag" => $obj["etag"], - "size" => IntVal($obj["size"]), - ); - } - return $ret; - } - - /** - * Returns information from a single calendar object, based on it's object - * uri. - * - * The returned array must have the same keys as getCalendarObjects. The - * 'calendardata' object is required here though, while it's not required - * for getCalendarObjects. - * - * @param string $calendarId - * @param string $objectUri - * @throws Sabre_DAV_Exception_FileNotFound - * @return array - */ - function getCalendarObject($calendarId, $objectUri) - { - $x = explode("-", $calendarId); - - $o = q("SELECT * FROM %s%scalendarobjects WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($objectUri)); - if (count($o) > 0) { - $o[0]["calendarid"] = $calendarId; - $o[0]["calendardata"] = str_ireplace("Europe/Belgrade", "Europe/Berlin", $o[0]["calendardata"]); - return $o[0]; - } else throw new Sabre_DAV_Exception_FileNotFound($calendarId . " / " . $objectUri); - } - - /** - * Creates a new calendar object. - * - * @param string $calendarId - * @param string $objectUri - * @param string $calendarData - * @return null|string|void - */ - function createCalendarObject($calendarId, $objectUri, $calendarData) - { - $x = explode("-", $calendarId); - - q("INSERT INTO %s%scalendarobjects (`namespace`, `namespace_id`, `uri`, `calendardata`, `lastmodified`, `etag`, `size`) VALUES (%d, %d, '%s', '%s', NOW(), '%s', %d)", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, - IntVal($x[0]), IntVal($x[1]), dbesc($objectUri), addslashes($calendarData), md5($calendarData), strlen($calendarData) - ); - - $this->increaseCalendarCtag($x[0], $x[1]); - renderCalDavEntry_uri($objectUri); - } - - /** - * Updates an existing calendarobject, based on it's uri. - * - * @param string $calendarId - * @param string $objectUri - * @param string $calendarData - * @return null|string|void - */ - function updateCalendarObject($calendarId, $objectUri, $calendarData) - { - $x = explode("-", $calendarId); - - q("UPDATE %s%scalendarobjects SET `calendardata` = '%s', `lastmodified` = NOW(), `etag` = '%s', `size` = %d WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($calendarData), md5($calendarData), strlen($calendarData), IntVal($x[0]), IntVal($x[1]), dbesc($objectUri)); - - $this->increaseCalendarCtag($x[0], $x[1]); - renderCalDavEntry_uri($objectUri); - } - - /** - * Deletes an existing calendar object. - * - * @param string $calendarId - * @param string $objectUri - * @return void - */ - function deleteCalendarObject($calendarId, $objectUri) - { - $x = explode("-", $calendarId); - - q("DELETE FROM %s%scalendarobjects WHERE `namespace` = %d AND `namespace_id` = %d AND `uri` = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($objectUri) - ); - - $this->increaseCalendarCtag($x[0], $x[1]); - renderCalDavEntry_uri($objectUri); - } -} diff --git a/dav/common/dbclasses/dbclass.friendica.calendarobjects.class.php b/dav/common/dbclasses/dbclass.friendica.calendarobjects.class.php deleted file mode 100644 index 509938b8..00000000 --- a/dav/common/dbclasses/dbclass.friendica.calendarobjects.class.php +++ /dev/null @@ -1,28 +0,0 @@ -PRIMARY_KEY) == 1) { - $dbarray_or_id = q("SELECT * FROM %s%s%s WHERE %s=%d", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->SRC_TABLE, $this->PRIMARY_KEY[0], IntVal($dbarray_or_id) - ); - if (count($dbarray_or_id) == 0) throw new Exception("Not found"); - $dbarray_or_id = $dbarray_or_id[0]; - } - if (is_array($dbarray_or_id)) { - foreach ($this->_string_fields as $field) { - $this->$field = $dbarray_or_id[$field]; - } - foreach ($this->_int_fields as $field) { - $this->$field = IntVal($dbarray_or_id[$field]); - } - foreach ($this->_float_fields as $field) { - $this->$field = FloatVal($dbarray_or_id[$field]); - } - } else throw new Exception("Not found"); - } - - /** - * @return array - */ - function toArray() - { - $arr = array(); - foreach ($this->_string_fields as $field) $arr[$field] = $this->$field; - foreach ($this->_int_fields as $field) $arr[$field] = $this->$field; - foreach ($this->_float_fields as $field) $arr[$field] = $this->$field; - return $arr; - } -} diff --git a/dav/common/virtual_cal_source_backend.inc.php b/dav/common/virtual_cal_source_backend.inc.php deleted file mode 100644 index 5549a6af..00000000 --- a/dav/common/virtual_cal_source_backend.inc.php +++ /dev/null @@ -1,63 +0,0 @@ -namespace_id = IntVal($namespace_id); - $this->user_id = IntVal($user_id); - - $x = q("SELECT * FROM %s%scalendars WHERE `namespace` = %d AND `namespace_id` = %d AND `uid` = %d", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->getNamespace(), $this->namespace_id, $this->user_id - ); - - if (count($x) != 1) throw new Sabre_DAV_Exception_NotFound("Not found"); - - try { - $this->calendarDb = new DBClass_friendica_calendars($x[0]); - } catch (Exception $e) { - throw new Sabre_DAV_Exception_NotFound("Not found"); - } - } - - /** - * @abstract - * @return int - */ - public static abstract function getNamespace(); - - /** - * @abstract - * @param int $user - * @return array - */ - public abstract function getPermissionsCalendar($user); - - /** - * @abstract - * @param int $user - * @param string $item_uri - * @param string $recurrence_uri - * @param array|null $item_arr - * @return array - */ - public abstract function getPermissionsItem($user, $item_uri, $recurrence_uri, $item_arr = null); - - /** - * @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 - */ - public abstract function updateItem($uri, $start, $end, $subject = "", $allday = false, $description = "", $location = "", $color = null, - $timezone = "", $notification = true, $notification_type = null, $notification_value = null); - - - /** - * @abstract - * @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 - */ - public abstract function addItem($start, $end, $subject, $allday = false, $description = "", $location = "", $color = null, - $timezone = "", $notification = true, $notification_type = null, $notification_value = null); - - - /** - * @param string $uri - */ - public abstract function removeItem($uri); - - - /** - * @abstract - * @param string $sd - * @param string $ed - * @param string $base_path - * @return array - */ - public abstract function listItemsByRange($sd, $ed, $base_path); - - - /** - * @abstract - * @param string $uri - * @return array - */ - public abstract function getItemByUri($uri); - - - /** - * @param string $uri - * @return null|string - */ - public function getItemDetailRedirect($uri) { - return null; - } - -} diff --git a/dav/common/wdcal_cal_source_private.inc.php b/dav/common/wdcal_cal_source_private.inc.php deleted file mode 100644 index cb5918e1..00000000 --- a/dav/common/wdcal_cal_source_private.inc.php +++ /dev/null @@ -1,332 +0,0 @@ -calendarDb->uid) return array("read"=> true, "write"=> true); - return array("read"=> false, "write"=> false); - } - - /** - * @param int $user - * @param string $item_uri - * @param string $recurrence_uri - * @param null|array $item_arr - * @return array - */ - public function getPermissionsItem($user, $item_uri, $recurrence_uri, $item_arr = null) - { - $cal_perm = $this->getPermissionsCalendar($user); - if (!$cal_perm["read"]) return array("read"=> false, "write"=> false); - if (!$cal_perm["write"]) array("read"=> true, "write"=> false); - - if ($item_arr === null) { - $x = q("SELECT `permission_edit` FROM %s%sjqcalendar WHERE `namespace` = %d AND `namespace_id` = %d AND `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->getNamespace(), $this->namespace_id, dbesc($item_uri), dbesc($recurrence_uri) - ); - if (!$x || count($x) == 0) return array("read"=> false, "write"=> false); - return array("read"=> true, "write"=> ($x[0]["permission_edit"])); - } else { - return array("read"=> true, "write"=> ($item_arr["permission_edit"])); - } - - } - - /** - * @param string $uri - * @throws Sabre_DAV_Exception_NotFound - */ - public function removeItem($uri){ - $obj_alt = q("SELECT * FROM %s%sjqcalendar WHERE namespace = %d AND namespace_id = %d AND ical_uri = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, $this->getNamespace(), $this->namespace_id, dbesc($uri)); - - if (count($obj_alt) == 0) throw new Sabre_DAV_Exception_NotFound("Not found"); - - $calendarBackend = new Sabre_CalDAV_Backend_Std(); - $calendarBackend->deleteCalendarObject($this->getNamespace() . "-" . $this->namespace_id, $obj_alt[0]["ical_uri"]); - } - - /** - * @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); - } - - /** - * @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"; - } - - private function jqcal2wdcal($row, $usr_id, $base_path) { - $evo = new DBClass_friendica_jqcalendar($row); - $not = q("SELECT COUNT(*) num FROM %s%snotifications WHERE `ical_uri` = '%s' AND `ical_recurr_uri` = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($row["ical_uri"]), $row["ical_recurr_uri"] - ); - $editable = $this->getPermissionsItem($usr_id, $row["ical_uri"], $row["ical_recurr_uri"], $row); - $recurring = (is_null($evo->RecurringRule) || $evo->RecurringRule == "" || $evo->RecurringRule == "NULL" ? 0 : 1); - - $end = wdcal_mySql2PhpTime($evo->EndTime); - if ($evo->IsAllDayEvent) $end -= 1; - - $arr = array( - "uri" => $evo->ical_uri, - "subject" => escape_tags($evo->Subject), - "start" => wdcal_mySql2PhpTime($evo->StartTime), - "end" => $end, - "is_allday" => $evo->IsAllDayEvent, - "is_moredays" => 0, - "is_recurring" => $recurring, - "color" => (is_null($evo->Color) || $evo->Color == "" ? $this->calendarDb->calendarcolor : $evo->Color), - "is_editable" => ($editable ? 1 : 0), - "is_editable_quick" => ($editable && !$recurring ? 1 : 0), - "location" => $evo->Location, - "attendees" => '', - "has_notification" => ($not[0]["num"] > 0 ? 1 : 0), - "url_detail" => $base_path . $evo->ical_uri . "/", - "url_edit" => $base_path . $evo->ical_uri . "/edit/", - "special_type" => "", - ); - return $arr; - } - - /** - * @param string $sd - * @param string $ed - * @param string $base_path - * @return array - */ - public function listItemsByRange($sd, $ed, $base_path) - { - - $usr_id = IntVal($this->calendarDb->uid); - - $von = wdcal_php2MySqlTime($sd); - $bis = wdcal_php2MySqlTime($ed); - - // @TODO Events, die früher angefangen haben, aber noch andauern - $evs = q("SELECT * FROM %s%sjqcalendar WHERE `uid` = %d AND `namespace` = %d AND `namespace_id` = %d AND `starttime` between '%s' and '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, - $usr_id, $this->getNamespace(), $this->namespace_id, dbesc($von), dbesc($bis)); - - $events = array(); - foreach ($evs as $row) $events[] = $this->jqcal2wdcal($row, $usr_id, $base_path); - - return $events; - } - - /** - * @param string $uri - * @throws Sabre_DAV_Exception_NotFound - * @return array - */ - public function getItemByUri($uri) - { - $usr_id = IntVal($this->calendarDb->uid); - $evs = 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($evs) == 0) throw new Sabre_DAV_Exception_NotFound(); - return $this->jqcal2wdcal($evs[0], $usr_id); - } - - - /** - * @param string $uri - * @return string - */ - public function getItemDetailRedirect($uri) { - return "/dav/wdcal/$uri/edit/"; - } -} diff --git a/dav/dav_caldav_backend_friendica.inc.php b/dav/dav_caldav_backend_friendica.inc.php deleted file mode 100644 index 11b27ea6..00000000 --- a/dav/dav_caldav_backend_friendica.inc.php +++ /dev/null @@ -1,141 +0,0 @@ -user["uid"]; - $x = explode("-", $calendarId); - - $ret = array(); - $objs = FriendicaVirtualCalSourceBackend::getItemsByTime($user_id, $x[1]); - foreach ($objs as $obj) { - $ret[] = array( - "id" => IntVal($obj["data_uri"]), - "calendardata" => $obj["ical"], - "uri" => $obj["data_uri"], - "lastmodified" => $obj["date"], - "calendarid" => $calendarId, - "etag" => $obj["ical_etag"], - "size" => IntVal($obj["ical_size"]), - ); - } - - return $ret; - } - - /** - * Returns information from a single calendar object, based on it's object - * uri. - * - * The returned array must have the same keys as getCalendarObjects. The - * 'calendardata' object is required here though, while it's not required - * for getCalendarObjects. - * - * @param string $calendarId - * @param string $objectUri - * @throws Sabre_DAV_Exception_FileNotFound - * @return array - */ - function getCalendarObject($calendarId, $objectUri) - { - $a = get_app(); - $user_id = $a->user["uid"]; - $obj = FriendicaVirtualCalSourceBackend::getItemsByUri($user_id, $objectUri); - - return array( - "id" => IntVal($obj["data_uri"]), - "calendardata" => $obj["ical"], - "uri" => $obj["data_uri"], - "lastmodified" => $obj["date"], - "calendarid" => $calendarId, - "etag" => $obj["ical_etag"], - "size" => IntVal($obj["ical_size"]), - ); - } - - /** - * Creates a new calendar object. - * - * @param string $calendarId - * @param string $objectUri - * @param string $calendarData - * @throws Sabre_DAV_Exception_Forbidden - * @return null|string|void - */ - function createCalendarObject($calendarId, $objectUri, $calendarData) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - /** - * Updates an existing calendarobject, based on it's uri. - * - * @param string $calendarId - * @param string $objectUri - * @param string $calendarData - * @throws Sabre_DAV_Exception_Forbidden - * @return null|string|void - */ - function updateCalendarObject($calendarId, $objectUri, $calendarData) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - /** - * Deletes an existing calendar object. - * - * @param string $calendarId - * @param string $objectUri - * @throws Sabre_DAV_Exception_Forbidden - * @return void - */ - function deleteCalendarObject($calendarId, $objectUri) - { - throw new Sabre_DAV_Exception_Forbidden(); - } -} diff --git a/dav/dav_carddav_backend_friendica_community.inc.php b/dav/dav_carddav_backend_friendica_community.inc.php deleted file mode 100644 index cf8b2ff0..00000000 --- a/dav/dav_carddav_backend_friendica_community.inc.php +++ /dev/null @@ -1,320 +0,0 @@ - CARDDAV_NAMESPACE_COMMUNITYCONTACTS . "-" . $uid, - 'uri' => "friendica", - 'principaluri' => $principalUri, - '{DAV:}displayname' => t("Friendica-Contacts"), - '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description' => t("Your Friendica-Contacts"), - '{http://calendarserver.org/ns/}getctag' => $ctag, - '{' . Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' => - new Sabre_CardDAV_Property_SupportedAddressData(), - ); - - return $addressBooks; - - } - - - /** - * Updates an addressbook's properties - * - * See Sabre_DAV_IProperties for a description of the mutations array, as - * well as the return value. - * - * @param string $addressBookId - * @param array $mutations - * @throws Sabre_DAV_Exception_Forbidden - * @see Sabre_DAV_IProperties::updateProperties - * @return bool|array - */ - public function updateAddressBook($addressBookId, array $mutations) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - /** - * Creates a new address book - * - * @param string $principalUri - * @param string $url Just the 'basename' of the url. - * @param array $properties - * @throws Sabre_DAV_Exception_Forbidden - * @return void - */ - public function createAddressBook($principalUri, $url, array $properties) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - /** - * Deletes an entire addressbook and all its contents - * - * @param int $addressBookId - * @throws Sabre_DAV_Exception_Forbidden - * @return void - */ - public function deleteAddressBook($addressBookId) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - - /** - * @param array $contact - * @return array - */ - private function dav_contactarr2vcardsource($contact) - { - $name = explode(" ", $contact["name"]); - $first_name = $last_name = ""; - $middle_name = array(); - $num = count($name); - for ($i = 0; $i < $num && $first_name == ""; $i++) if ($name[$i] != "") { - $first_name = $name[$i]; - unset($name[$i]); - } - for ($i = $num - 1; $i >= 0 && $last_name == ""; $i--) if (isset($name[$i]) && $name[$i] != "") { - $last_name = $name[$i]; - unset($name[$i]); - } - foreach ($name as $n) if ($n != "") $middle_name[] = $n; - $vcarddata = new vcard_source_data($first_name, implode(" ", $middle_name), $last_name); - $vcarddata->homepages[] = new vcard_source_data_homepage("pref", $contact["url"]); - $vcarddata->last_update = ($contact["last-update"] > 0 ? $contact["last-update"] : $contact["created"]); - - $photo = q("SELECT * FROM photo WHERE `contact-id` = %d ORDER BY scale DESC", $contact["id"]); //prefer size 80x80 - if ($photo && count($photo) > 0) { - $photodata = new vcard_source_data_photo(); - $photodata->width = $photo[0]["width"]; - $photodata->height = $photo[0]["height"]; - $photodata->type = "JPEG"; - $photodata->binarydata = $photo[0]["data"]; - $vcarddata->photo = $photodata; - } - - switch ($contact["network"]) { - case "face": - $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("facebook", $contact["notify"], "http://www.facebook.com/" . $contact["notify"]); - break; - case "dfrn": - $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("dfrn", $contact["nick"], $contact["url"]); - break; - case "twitter": - $vcarddata->socialnetworks[] = new vcard_source_data_socialnetwork("twitter", $contact["nick"], "http://twitter.com/" . $contact["nick"]); // @TODO Stimmt das? - break; - } - - $vcard = vcard_source_compile($vcarddata); - return array( - "id" => $contact["id"], - "carddata" => $vcard, - "uri" => $contact["id"] . ".vcf", - "lastmodified" => wdcal_mySql2PhpTime($vcarddata->last_update), - "etag" => md5($vcard), - "size" => strlen($vcard), - ); - - } - - /** - * @param int $uid - * @param array|int[] $exclude_ids - * @return array - */ - private function dav_getCommunityContactsVCards($uid = 0, $exclude_ids = array()) - { - $notin = (count($exclude_ids) > 0 ? " AND id NOT IN (" . implode(", ", $exclude_ids) . ") " : ""); - $uid = IntVal($uid); - $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 $notin ORDER BY `name` ASC", $uid); - - $retdata = array(); - foreach ($contacts as $contact) { - $x = $this->dav_contactarr2vcardsource($contact); - $x["contact"] = $contact["id"]; - $retdata[] = $x; - } - return $retdata; - } - - - /** - * Returns all cards for a specific addressbook id. - * - * This method should return the following properties for each card: - * * carddata - raw vcard data - * * uri - Some unique url - * * lastmodified - A unix timestamp - * - * It's recommended to also return the following properties: - * * etag - A unique etag. This must change every time the card changes. - * * size - The size of the card in bytes. - * - * If these last two properties are provided, less time will be spent - * calculating them. If they are specified, you can also ommit carddata. - * This may speed up certain requests, especially with large cards. - * - * @param string $addressbookId - * @return array - */ - public function getCards($addressbookId) - { - $add = explode("-", $addressbookId); - - $indb = q('SELECT id, carddata, uri, lastmodified, etag, size, contact, manually_deleted FROM %s%scards WHERE namespace = %d AND namespace_id = %d', - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($add[0]), IntVal($add[1]) - ); - $found_contacts = array(); - $contacts = array(); - foreach ($indb as $x) { - if ($x["manually_deleted"] == 0) $contacts[] = $x; - $found_contacts[] = IntVal($x["contact"]); - } - $new_found = $this->dav_getCommunityContactsVCards($add[1], $found_contacts); - foreach ($new_found as $new) { - q("INSERT INTO %s%scards (namespace, namespace_id, contact, carddata, uri, lastmodified, manually_edited, manually_deleted, etag, size) - VALUES (%d, %d, %d, '%s', '%s', %d, 0, 0, '%s', %d)", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, - IntVal($add[0]), IntVal($add[1]), IntVal($new["contact"]), dbesc($new["carddata"]), dbesc($new["uri"]), time(), md5($new["carddata"]), strlen($new["carddata"]) - ); - } - return array_merge($contacts, $new_found); - } - - /** - * Returns a specfic card. - * - * The same set of properties must be returned as with getCards. The only - * exception is that 'carddata' is absolutely required. - * - * @param mixed $addressBookId - * @param string $cardUri - * @throws Sabre_DAV_Exception_NotFound - * @return array - */ - public function getCard($addressBookId, $cardUri) - { - $x = explode("-", $addressBookId); - $x = q("SELECT id, carddata, uri, lastmodified, etag, size FROM %s%scards WHERE namespace = %d AND namespace_id = %d AND uri = '%s'", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($cardUri)); - if (count($x) == 0) throw new Sabre_DAV_Exception_NotFound(); - return $x[0]; - } - - /** - * Creates a new card. - * - * The addressbook id will be passed as the first argument. This is the - * same id as it is returned from the getAddressbooksForUser method. - * - * The cardUri is a base uri, and doesn't include the full path. The - * cardData argument is the vcard body, and is passed as a string. - * - * It is possible to return an ETag from this method. This ETag is for the - * newly created resource, and must be enclosed with double quotes (that - * is, the string itself must contain the double quotes). - * - * You should only return the ETag if you store the carddata as-is. If a - * subsequent GET request on the same card does not have the same body, - * byte-by-byte and you did return an ETag here, clients tend to get - * confused. - * - * If you don't return an ETag, you can just return null. - * - * @param string $addressBookId - * @param string $cardUri - * @param string $cardData - * @throws Sabre_DAV_Exception_Forbidden - * @return string - */ - public function createCard($addressBookId, $cardUri, $cardData) - { - throw new Sabre_DAV_Exception_Forbidden(); - } - - /** - * Updates a card. - * - * The addressbook id will be passed as the first argument. This is the - * same id as it is returned from the getAddressbooksForUser method. - * - * The cardUri is a base uri, and doesn't include the full path. The - * cardData argument is the vcard body, and is passed as a string. - * - * It is possible to return an ETag from this method. This ETag should - * match that of the updated resource, and must be enclosed with double - * quotes (that is: the string itself must contain the actual quotes). - * - * You should only return the ETag if you store the carddata as-is. If a - * subsequent GET request on the same card does not have the same body, - * byte-by-byte and you did return an ETag here, clients tend to get - * confused. - * - * If you don't return an ETag, you can just return null. - * - * @param string $addressBookId - * @param string $cardUri - * @param string $cardData - * @throws Sabre_DAV_Exception_Forbidden - * @return string|null - */ - public function updateCard($addressBookId, $cardUri, $cardData) - { - $x = explode("-", $addressBookId); - - $etag = md5($cardData); - q("UPDATE %s%scards SET carddata = '%s', lastmodified = %d, etag = '%s', size = %d, manually_edited = 1 WHERE uri = '%s' AND namespace = %d AND namespace_id =%d", - CALDAV_SQL_DB, CALDAV_SQL_PREFIX, dbesc($cardData), time(), $etag, strlen($cardData), dbesc($cardUri), IntVal($x[10]), IntVal($x[1]) - ); - q('UPDATE %s%saddressbooks_community SET ctag = ctag + 1 WHERE uid = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); - - return '"' . $etag . '"'; - } - - /** - * Deletes a card - * - * @param string $addressBookId - * @param string $cardUri - * @throws Sabre_DAV_Exception_Forbidden - * @return bool - */ - public function deleteCard($addressBookId, $cardUri) - { - $x = explode("-", $addressBookId); - - q("UPDATE %s%scards SET manually_deleted = 1 WHERE namespace = %d AND namespace_id = %d AND uri = '%s'", CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[0]), IntVal($x[1]), dbesc($cardUri)); - q('UPDATE %s%saddressbooks_community SET ctag = ctag + 1 WHERE uid = %d', CALDAV_SQL_DB, CALDAV_SQL_PREFIX, IntVal($x[1])); - - return true; - } -} diff --git a/dav/iCalcreator/iCalcreator.class.php b/dav/iCalcreator/iCalcreator.class.php deleted file mode 100755 index d3b84763..00000000 --- a/dav/iCalcreator/iCalcreator.class.php +++ /dev/null @@ -1,10181 +0,0 @@ -= '5.1' ) - // && ( 'UTC' == date_default_timezone_get())) - date_default_timezone_set( 'Europe/Stockholm' ); -/*********************************************************************************/ -/* version, do NOT remove!! */ -define( 'ICALCREATOR_VERSION', 'iCalcreator 2.12' ); -/*********************************************************************************/ -/*********************************************************************************/ -/** - * vcalendar class - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-14 - */ -class vcalendar { - // calendar property variables - var $calscale; - var $method; - var $prodid; - var $version; - var $xprop; - // container for calendar components - var $components; - // component config variables - var $allowEmpty; - var $unique_id; - var $language; - var $directory; - var $filename; - var $url; - var $delimiter; - var $nl; - var $format; - var $dtzid; - // component internal variables - var $attributeDelimiter; - var $valueInit; - // component xCal declaration container - var $xcaldecl; -/** - * constructor for calendar object - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-14 - * @param array $config - * @return void - */ - function vcalendar ( $config = array()) { - $this->_makeVersion(); - $this->calscale = null; - $this->method = null; - $this->_makeUnique_id(); - $this->prodid = null; - $this->xprop = array(); - $this->language = null; - $this->directory = null; - $this->filename = null; - $this->url = null; - $this->dtzid = null; -/** - * language = - */ - if( defined( 'ICAL_LANG' ) && !isset( $config['language'] )) - $config['language'] = ICAL_LANG; - if( !isset( $config['allowEmpty'] )) $config['allowEmpty'] = TRUE; - if( !isset( $config['nl'] )) $config['nl'] = "\r\n"; - if( !isset( $config['format'] )) $config['format'] = 'iCal'; - if( !isset( $config['delimiter'] )) $config['delimiter'] = DIRECTORY_SEPARATOR; - $this->setConfig( $config ); - - $this->xcaldecl = array(); - $this->components = array(); - } -/*********************************************************************************/ -/** - * Property Name: CALSCALE - */ -/** - * creates formatted output for calendar property calscale - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.16 - 2011-10-28 - * @return string - */ - function createCalscale() { - if( empty( $this->calscale )) return FALSE; - switch( $this->format ) { - case 'xcal': - return $this->nl.' calscale="'.$this->calscale.'"'; - break; - default: - return 'CALSCALE:'.$this->calscale.$this->nl; - break; - } - } -/** - * set calendar property calscale - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @param string $value - * @return void - */ - function setCalscale( $value ) { - if( empty( $value )) return FALSE; - $this->calscale = $value; - } -/*********************************************************************************/ -/** - * Property Name: METHOD - */ -/** - * creates formatted output for calendar property method - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.16 - 2011-10-28 - * @return string - */ - function createMethod() { - if( empty( $this->method )) return FALSE; - switch( $this->format ) { - case 'xcal': - return $this->nl.' method="'.$this->method.'"'; - break; - default: - return 'METHOD:'.$this->method.$this->nl; - break; - } - } -/** - * set calendar property method - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-20-23 - * @param string $value - * @return bool - */ - function setMethod( $value ) { - if( empty( $value )) return FALSE; - $this->method = $value; - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: PRODID - * - * The identifier is RECOMMENDED to be the identical syntax to the - * [RFC 822] addr-spec. A good method to assure uniqueness is to put the - * domain name or a domain literal IP address of the host on which.. . - */ -/** - * creates formatted output for calendar property prodid - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.16 - 2011-10-28 - * @return string - */ - function createProdid() { - if( !isset( $this->prodid )) - $this->_makeProdid(); - switch( $this->format ) { - case 'xcal': - return $this->nl.' prodid="'.$this->prodid.'"'; - break; - default: - return 'PRODID:'.$this->prodid.$this->nl; - break; - } - } -/** - * make default value for calendar prodid - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.8 - 2009-12-30 - * @return void - */ - function _makeProdid() { - $this->prodid = '-//'.$this->unique_id.'//NONSGML kigkonsult.se '.ICALCREATOR_VERSION.'//'.strtoupper( $this->language ); - } -/** - * Conformance: The property MUST be specified once in an iCalendar object. - * Description: The vendor of the implementation SHOULD assure that this - * is a globally unique identifier; using some technique such as an FPI - * value, as defined in [ISO 9070]. - */ -/** - * make default unique_id for calendar prodid - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 0.3.0 - 2006-08-10 - * @return void - */ - function _makeUnique_id() { - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; - } -/*********************************************************************************/ -/** - * Property Name: VERSION - * - * Description: A value of "2.0" corresponds to this memo. - */ -/** - * creates formatted output for calendar property version - - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.16 - 2011-10-28 - * @return string - */ - function createVersion() { - if( empty( $this->version )) - $this->_makeVersion(); - switch( $this->format ) { - case 'xcal': - return $this->nl.' version="'.$this->version.'"'; - break; - default: - return 'VERSION:'.$this->version.$this->nl; - break; - } - } -/** - * set default calendar version - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 0.3.0 - 2006-08-10 - * @return void - */ - function _makeVersion() { - $this->version = '2.0'; - } -/** - * set calendar version - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-23 - * @param string $value - * @return void - */ - function setVersion( $value ) { - if( empty( $value )) return FALSE; - $this->version = $value; - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: x-prop - */ -/** - * creates formatted output for calendar property x-prop, iCal format only - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.16 - 2011-11-01 - * @return string - */ - function createXprop() { - if( empty( $this->xprop ) || !is_array( $this->xprop )) return FALSE; - $output = null; - $toolbox = new calendarComponent(); - $toolbox->setConfig( $this->getConfig()); - foreach( $this->xprop as $label => $xpropPart ) { - if( !isset($xpropPart['value']) || ( empty( $xpropPart['value'] ) && !is_numeric( $xpropPart['value'] ))) { - $output .= $toolbox->_createElement( $label ); - continue; - } - $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); - if( is_array( $xpropPart['value'] )) { - foreach( $xpropPart['value'] as $pix => $theXpart ) - $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart ); - $xpropPart['value'] = implode( ',', $xpropPart['value'] ); - } - else - $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] ); - $output .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] ); - if( is_array( $toolbox->xcaldecl ) && ( 0 < count( $toolbox->xcaldecl ))) { - foreach( $toolbox->xcaldecl as $localxcaldecl ) - $this->xcaldecl[] = $localxcaldecl; - } - } - return $output; - } -/** - * set calendar property x-prop - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.9 - 2012-01-16 - * @param string $label - * @param string $value - * @param array $params optional - * @return bool - */ - function setXprop( $label, $value, $params=FALSE ) { - if( empty( $label )) - return FALSE; - if( 'X-' != strtoupper( substr( $label, 0, 2 ))) - return FALSE; - if( empty( $value ) && !is_numeric( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $xprop = array( 'value' => $value ); - $xprop['params'] = iCalUtilityFunctions::_setParams( $params ); - if( !is_array( $this->xprop )) $this->xprop = array(); - $this->xprop[strtoupper( $label )] = $xprop; - return TRUE; - } -/*********************************************************************************/ -/** - * delete calendar property value - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @param mixed $propName, bool FALSE => X-property - * @param int $propix, optional, if specific property is wanted in case of multiply occurences - * @return bool, if successfull delete - */ - function deleteProperty( $propName=FALSE, $propix=FALSE ) { - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; - if( !$propix ) - $propix = ( isset( $this->propdelix[$propName] ) && ( 'X-PROP' != $propName )) ? $this->propdelix[$propName] + 2 : 1; - $this->propdelix[$propName] = --$propix; - $return = FALSE; - switch( $propName ) { - case 'CALSCALE': - if( isset( $this->calscale )) { - $this->calscale = null; - $return = TRUE; - } - break; - case 'METHOD': - if( isset( $this->method )) { - $this->method = null; - $return = TRUE; - } - break; - default: - $reduced = array(); - if( $propName != 'X-PROP' ) { - if( !isset( $this->xprop[$propName] )) { unset( $this->propdelix[$propName] ); return FALSE; } - foreach( $this->xprop as $k => $a ) { - if(( $k != $propName ) && !empty( $a )) - $reduced[$k] = $a; - } - } - else { - if( count( $this->xprop ) <= $propix ) return FALSE; - $xpropno = 0; - foreach( $this->xprop as $xpropkey => $xpropvalue ) { - if( $propix != $xpropno ) - $reduced[$xpropkey] = $xpropvalue; - $xpropno++; - } - } - $this->xprop = $reduced; - if( empty( $this->xprop )) { - unset( $this->propdelix[$propName] ); - return FALSE; - } - return TRUE; - } - return $return; - } -/** - * get calendar property value/params - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-04-16 - * @param string $propName, optional - * @param int $propix, optional, if specific property is wanted in case of multiply occurences - * @param bool $inclParam=FALSE - * @return mixed - */ - function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) { - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; - if( 'X-PROP' == $propName ) { - if( !$propix ) - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; - $this->propix[$propName] = --$propix; - } - switch( $propName ) { - case 'ATTENDEE': - case 'CATEGORIES': - case 'DTSTART': - case 'LOCATION': - case 'ORGANIZER': - case 'PRIORITY': - case 'RESOURCES': - case 'STATUS': - case 'SUMMARY': - case 'RECURRENCE-ID-UID': - case 'R-UID': - case 'UID': - $output = array(); - foreach ( $this->components as $cix => $component) { - if( !in_array( $component->objName, array('vevent', 'vtodo', 'vjournal', 'vfreebusy' ))) - continue; - if(( 'ATTENDEE' == $propName ) || ( 'CATEGORIES' == $propName ) || ( 'RESOURCES' == $propName )) { - $component->_getProperties( $propName, $output ); - continue; - } - elseif(( 3 < strlen( $propName )) && ( 'UID' == substr( $propName, -3 ))) { - if( FALSE !== ( $content = $component->getProperty( 'RECURRENCE-ID' ))) - $content = $component->getProperty( 'UID' ); - } - elseif( FALSE === ( $content = $component->getProperty( $propName ))) - continue; - if( FALSE === $content ) - continue; - elseif( is_array( $content )) { - if( isset( $content['year'] )) { - $key = sprintf( '%04d%02d%02d', $content['year'], $content['month'], $content['day'] ); - if( !isset( $output[$key] )) - $output[$key] = 1; - else - $output[$key] += 1; - } - else { - foreach( $content as $partValue => $partCount ) { - if( !isset( $output[$partValue] )) - $output[$partValue] = $partCount; - else - $output[$partValue] += $partCount; - } - } - } // end elseif( is_array( $content )) { - elseif( !isset( $output[$content] )) - $output[$content] = 1; - else - $output[$content] += 1; - } // end foreach ( $this->components as $cix => $component) - if( !empty( $output )) - ksort( $output ); - return $output; - break; - - case 'CALSCALE': - return ( !empty( $this->calscale )) ? $this->calscale : FALSE; - break; - case 'METHOD': - return ( !empty( $this->method )) ? $this->method : FALSE; - break; - case 'PRODID': - if( empty( $this->prodid )) - $this->_makeProdid(); - return $this->prodid; - break; - case 'VERSION': - return ( !empty( $this->version )) ? $this->version : FALSE; - break; - default: - if( $propName != 'X-PROP' ) { - if( !isset( $this->xprop[$propName] )) return FALSE; - return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) - : array( $propName, $this->xprop[$propName]['value'] ); - } - else { - if( empty( $this->xprop )) return FALSE; - $xpropno = 0; - foreach( $this->xprop as $xpropkey => $xpropvalue ) { - if( $propix == $xpropno ) - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) - : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); - else - $xpropno++; - } - unset( $this->propix[$propName] ); - return FALSE; // not found ?? - } - } - return FALSE; - } -/** - * general vcalendar property setting - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.2.13 - 2007-11-04 - * @param mixed $args variable number of function arguments, - * first argument is ALWAYS component name, - * second ALWAYS component value! - * @return bool - */ - function setProperty () { - $numargs = func_num_args(); - if( 1 > $numargs ) - return FALSE; - $arglist = func_get_args(); - $arglist[0] = strtoupper( $arglist[0] ); - switch( $arglist[0] ) { - case 'CALSCALE': - return $this->setCalscale( $arglist[1] ); - case 'METHOD': - return $this->setMethod( $arglist[1] ); - case 'VERSION': - return $this->setVersion( $arglist[1] ); - default: - if( !isset( $arglist[1] )) $arglist[1] = null; - if( !isset( $arglist[2] )) $arglist[2] = null; - return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); - } - return FALSE; - } -/*********************************************************************************/ -/** - * get vcalendar config values or * calendar components - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.7 - 2012-01-12 - * @param mixed $config - * @return value - */ - function getConfig( $config = FALSE ) { - if( !$config ) { - $return = array(); - $return['ALLOWEMPTY'] = $this->getConfig( 'ALLOWEMPTY' ); - $return['DELIMITER'] = $this->getConfig( 'DELIMITER' ); - $return['DIRECTORY'] = $this->getConfig( 'DIRECTORY' ); - $return['FILENAME'] = $this->getConfig( 'FILENAME' ); - $return['DIRFILE'] = $this->getConfig( 'DIRFILE' ); - $return['FILESIZE'] = $this->getConfig( 'FILESIZE' ); - $return['FORMAT'] = $this->getConfig( 'FORMAT' ); - if( FALSE !== ( $lang = $this->getConfig( 'LANGUAGE' ))) - $return['LANGUAGE'] = $lang; - $return['NEWLINECHAR'] = $this->getConfig( 'NEWLINECHAR' ); - $return['UNIQUE_ID'] = $this->getConfig( 'UNIQUE_ID' ); - if( FALSE !== ( $url = $this->getConfig( 'URL' ))) - $return['URL'] = $url; - $return['TZID'] = $this->getConfig( 'TZID' ); - return $return; - } - switch( strtoupper( $config )) { - case 'ALLOWEMPTY': - return $this->allowEmpty; - break; - case 'COMPSINFO': - unset( $this->compix ); - $info = array(); - foreach( $this->components as $cix => $component ) { - if( empty( $component )) continue; - $info[$cix]['ordno'] = $cix + 1; - $info[$cix]['type'] = $component->objName; - $info[$cix]['uid'] = $component->getProperty( 'uid' ); - $info[$cix]['props'] = $component->getConfig( 'propinfo' ); - $info[$cix]['sub'] = $component->getConfig( 'compsinfo' ); - } - return $info; - break; - case 'DELIMITER': - return $this->delimiter; - break; - case 'DIRECTORY': - if( empty( $this->directory ) && ( '0' != $this->directory )) - $this->directory = '.'; - return $this->directory; - break; - case 'DIRFILE': - return $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$this->getConfig( 'filename' ); - break; - case 'FILEINFO': - return array( $this->getConfig( 'directory' ) - , $this->getConfig( 'filename' ) - , $this->getConfig( 'filesize' )); - break; - case 'FILENAME': - if( empty( $this->filename ) && ( '0' != $this->filename )) { - if( 'xcal' == $this->format ) - $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. . - else - $this->filename = date( 'YmdHis' ).'.ics'; - } - return $this->filename; - break; - case 'FILESIZE': - $size = 0; - if( empty( $this->url )) { - $dirfile = $this->getConfig( 'dirfile' ); - if( !is_file( $dirfile ) || ( FALSE === ( $size = filesize( $dirfile )))) - $size = 0; - clearstatcache(); - } - return $size; - break; - case 'FORMAT': - return ( $this->format == 'xcal' ) ? 'xCal' : 'iCal'; - break; - case 'LANGUAGE': - /* get language for calendar component as defined in [RFC 1766] */ - return $this->language; - break; - case 'NL': - case 'NEWLINECHAR': - return $this->nl; - break; - case 'TZID': - return $this->dtzid; - break; - case 'UNIQUE_ID': - return $this->unique_id; - break; - case 'URL': - if( !empty( $this->url )) - return $this->url; - else - return FALSE; - break; - } - } -/** - * general vcalendar config setting - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.11 - 2011-01-16 - * @param mixed $config - * @param string $value - * @return void - */ - function setConfig( $config, $value = FALSE) { - if( is_array( $config )) { - $ak = array_keys( $config ); - foreach( $ak as $k ) { - if( 'DIRECTORY' == strtoupper( $k )) { - if( FALSE === $this->setConfig( 'DIRECTORY', $config[$k] )) - return FALSE; - unset( $config[$k] ); - } - elseif( 'NEWLINECHAR' == strtoupper( $k )) { - if( FALSE === $this->setConfig( 'NEWLINECHAR', $config[$k] )) - return FALSE; - unset( $config[$k] ); - } - } - foreach( $config as $cKey => $cValue ) { - if( FALSE === $this->setConfig( $cKey, $cValue )) - return FALSE; - } - return TRUE; - } - $res = FALSE; - switch( strtoupper( $config )) { - case 'ALLOWEMPTY': - $this->allowEmpty = $value; - $subcfg = array( 'ALLOWEMPTY' => $value ); - $res = TRUE; - break; - case 'DELIMITER': - $this->delimiter = $value; - return TRUE; - break; - case 'DIRECTORY': - $value = trim( $value ); - $del = $this->getConfig('delimiter'); - if( $del == substr( $value, ( 0 - strlen( $del )))) - $value = substr( $value, 0, ( strlen( $value ) - strlen( $del ))); - if( is_dir( $value )) { - /* local directory */ - clearstatcache(); - $this->directory = $value; - $this->url = null; - return TRUE; - } - else - return FALSE; - break; - case 'FILENAME': - $value = trim( $value ); - if( !empty( $this->url )) { - /* remote directory+file -> URL */ - $this->filename = $value; - return TRUE; - } - $dirfile = $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$value; - if( file_exists( $dirfile )) { - /* local file exists */ - if( is_readable( $dirfile ) || is_writable( $dirfile )) { - clearstatcache(); - $this->filename = $value; - return TRUE; - } - else - return FALSE; - } - elseif( is_readable($this->getConfig( 'directory' ) ) || is_writable( $this->getConfig( 'directory' ) )) { - /* read- or writable directory */ - $this->filename = $value; - return TRUE; - } - else - return FALSE; - break; - case 'FORMAT': - $value = trim( strtolower( $value )); - if( 'xcal' == $value ) { - $this->format = 'xcal'; - $this->attributeDelimiter = $this->nl; - $this->valueInit = null; - } - else { - $this->format = null; - $this->attributeDelimiter = ';'; - $this->valueInit = ':'; - } - $subcfg = array( 'FORMAT' => $value ); - $res = TRUE; - break; - case 'LANGUAGE': - // set language for calendar component as defined in [RFC 1766] - $value = trim( $value ); - $this->language = $value; - $subcfg = array( 'LANGUAGE' => $value ); - $res = TRUE; - break; - case 'NL': - case 'NEWLINECHAR': - $this->nl = $value; - if( 'xcal' == $value ) { - $this->attributeDelimiter = $this->nl; - $this->valueInit = null; - } - else { - $this->attributeDelimiter = ';'; - $this->valueInit = ':'; - } - $subcfg = array( 'NL' => $value ); - $res = TRUE; - break; - case 'TZID': - $this->dtzid = $value; - $subcfg = array( 'TZID' => $value ); - $res = TRUE; - break; - case 'UNIQUE_ID': - $value = trim( $value ); - $this->unique_id = $value; - $this->_makeProdid(); - $subcfg = array( 'UNIQUE_ID' => $value ); - $res = TRUE; - break; - case 'URL': - /* remote file - URL */ - $value = trim( $value ); - $value = str_replace( 'HTTP://', 'http://', $value ); - $value = str_replace( 'WEBCAL://', 'http://', $value ); - $value = str_replace( 'webcal://', 'http://', $value ); - $this->url = $value; - $this->directory = null; - $parts = pathinfo( $value ); - return $this->setConfig( 'filename', $parts['basename'] ); - break; - default: // any unvalid config key.. . - return TRUE; - } - if( !$res ) return FALSE; - if( isset( $subcfg ) && !empty( $this->components )) { - foreach( $subcfg as $cfgkey => $cfgvalue ) { - foreach( $this->components as $cix => $component ) { - $res = $component->setConfig( $cfgkey, $cfgvalue, TRUE ); - if( !$res ) - break 2; - $this->components[$cix] = $component->copy(); // PHP4 compliant - } - } - } - return $res; - } -/*********************************************************************************/ -/** - * add calendar component to container - * - * alias to setComponent - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 1.x.x - 2007-04-24 - * @param object $component calendar component - * @return void - */ - function addComponent( $component ) { - $this->setComponent( $component ); - } -/** - * delete calendar component from container - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @param mixed $arg1 ordno / component type / component uid - * @param mixed $arg2 optional, ordno if arg1 = component type - * @return void - */ - function deleteComponent( $arg1, $arg2=FALSE ) { - $argType = $index = null; - if ( ctype_digit( (string) $arg1 )) { - $argType = 'INDEX'; - $index = (int) $arg1 - 1; - } - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { - $argType = strtolower( $arg1 ); - $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; - } - $cix1dC = 0; - foreach ( $this->components as $cix => $component) { - if( empty( $component )) continue; - if(( 'INDEX' == $argType ) && ( $index == $cix )) { - unset( $this->components[$cix] ); - return TRUE; - } - elseif( $argType == $component->objName ) { - if( $index == $cix1dC ) { - unset( $this->components[$cix] ); - return TRUE; - } - $cix1dC++; - } - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { - unset( $this->components[$cix] ); - return TRUE; - } - } - return FALSE; - } -/** - * get calendar component from container - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.1 - 2011-04-16 - * @param mixed $arg1 optional, ordno/component type/ component uid - * @param mixed $arg2 optional, ordno if arg1 = component type - * @return object - */ - function getComponent( $arg1=FALSE, $arg2=FALSE ) { - $index = $argType = null; - if ( !$arg1 ) { // first or next in component chain - $argType = 'INDEX'; - $index = $this->compix['INDEX'] = ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; - } - elseif ( ctype_digit( (string) $arg1 )) { // specific component in chain - $argType = 'INDEX'; - $index = (int) $arg1; - unset( $this->compix ); - } - elseif( is_array( $arg1 )) { // array( *[propertyName => propertyValue] ) - $arg2 = implode( '-', array_keys( $arg1 )); - $index = $this->compix[$arg2] = ( isset( $this->compix[$arg2] )) ? $this->compix[$arg2] + 1 : 1; - $dateProps = array( 'DTSTART', 'DTEND', 'DUE', 'CREATED', 'COMPLETED', 'DTSTAMP', 'LAST-MODIFIED', 'RECURRENCE-ID' ); - $otherProps = array( 'ATTENDEE', 'CATEGORIES', 'LOCATION', 'ORGANIZER', 'PRIORITY', 'RESOURCES', 'STATUS', 'SUMMARY', 'UID' ); - } - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { // object class name - unset( $this->compix['INDEX'] ); - $argType = strtolower( $arg1 ); - if( !$arg2 ) - $index = $this->compix[$argType] = ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; - elseif( isset( $arg2 ) && ctype_digit( (string) $arg2 )) - $index = (int) $arg2; - } - elseif(( strlen( $arg1 ) > strlen( 'vfreebusy' )) && ( FALSE !== strpos( $arg1, '@' ))) { // UID as 1st argument - if( !$arg2 ) - $index = $this->compix[$arg1] = ( isset( $this->compix[$arg1] )) ? $this->compix[$arg1] + 1 : 1; - elseif( isset( $arg2 ) && ctype_digit( (string) $arg2 )) - $index = (int) $arg2; - } - if( isset( $index )) - $index -= 1; - $ckeys = array_keys( $this->components ); - if( !empty( $index) && ( $index > end( $ckeys ))) - return FALSE; - $cix1gC = 0; - foreach ( $this->components as $cix => $component) { - if( empty( $component )) continue; - if(( 'INDEX' == $argType ) && ( $index == $cix )) - return $component->copy(); - elseif( $argType == $component->objName ) { - if( $index == $cix1gC ) - return $component->copy(); - $cix1gC++; - } - elseif( is_array( $arg1 )) { // array( *[propertyName => propertyValue] ) - $hit = FALSE; - foreach( $arg1 as $pName => $pValue ) { - $pName = strtoupper( $pName ); - if( !in_array( $pName, $dateProps ) && !in_array( $pName, $otherProps )) - continue; - if(( 'ATTENDEE' == $pName ) || ( 'CATEGORIES' == $pName ) || ( 'RESOURCES' == $pName )) { // multiple ocurrence may occur - $propValues = array(); - $component->_getProperties( $pName, $propValues ); - $propValues = array_keys( $propValues ); - $hit = ( in_array( $pValue, $propValues )) ? TRUE : FALSE; - continue; - } // end if(( 'CATEGORIES' == $propName ) || ( 'RESOURCES' == $propName )) { // multiple ocurrence may occur - if( FALSE === ( $value = $component->getProperty( $pName ))) { // single ocurrency - $hit = FALSE; // missing property - continue; - } - if( 'SUMMARY' == $pName ) { // exists within (any case) - $hit = ( FALSE !== stripos( $d, $pValue )) ? TRUE : FALSE; - continue; - } - if( in_array( strtoupper( $pName ), $dateProps )) { - $valuedate = sprintf( '%04d%02d%02d', $value['year'], $value['month'], $value['day'] ); - if( 8 < strlen( $pValue )) { - if( isset( $value['hour'] )) { - if( 'T' == substr( $pValue, 8, 1 )) - $pValue = str_replace( 'T', '', $pValue ); - $valuedate .= sprintf( '%02d%02d%02d', $value['hour'], $value['min'], $value['sec'] ); - } - else - $pValue = substr( $pValue, 0, 8 ); - } - $hit = ( $pValue == $valuedate ) ? TRUE : FALSE; - continue; - } - elseif( !is_array( $value )) - $value = array( $value ); - foreach( $value as $part ) { - $part = ( FALSE !== strpos( $part, ',' )) ? explode( ',', $part ) : array( $part ); - foreach( $part as $subPart ) { - if( $pValue == $subPart ) { - $hit = TRUE; - continue 2; - } - } - } - $hit = FALSE; // no hit in property - } // end foreach( $arg1 as $pName => $pValue ) - if( $hit ) { - if( $index == $cix1gC ) - return $component->copy(); - $cix1gC++; - } - } // end elseif( is_array( $arg1 )) { // array( *[propertyName => propertyValue] ) - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { // UID - if( $index == $cix1gC ) - return $component->copy(); - $cix1gC++; - } - } // end foreach ( $this->components.. . - /* not found.. . */ - unset( $this->compix ); - return FALSE; - } -/** - * create new calendar component, already included within calendar - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.33 - 2011-01-03 - * @param string $compType component type - * @return object (reference) - */ - function & newComponent( $compType ) { - $config = $this->getConfig(); - $keys = array_keys( $this->components ); - $ix = end( $keys) + 1; - switch( strtoupper( $compType )) { - case 'EVENT': - case 'VEVENT': - $this->components[$ix] = new vevent( $config ); - break; - case 'TODO': - case 'VTODO': - $this->components[$ix] = new vtodo( $config ); - break; - case 'JOURNAL': - case 'VJOURNAL': - $this->components[$ix] = new vjournal( $config ); - break; - case 'FREEBUSY': - case 'VFREEBUSY': - $this->components[$ix] = new vfreebusy( $config ); - break; - case 'TIMEZONE': - case 'VTIMEZONE': - array_unshift( $this->components, new vtimezone( $config )); - $ix = 0; - break; - default: - return FALSE; - } - return $this->components[$ix]; - } -/** - * select components from calendar on date or selectOption basis - * - * Ensure DTSTART is set for every component. - * No date controls occurs. - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.22 - 2012-02-13 - * @param mixed $startY optional, start Year, default current Year ALT. array selecOptions ( *[ => ] ) - * @param int $startM optional, start Month, default current Month - * @param int $startD optional, start Day, default current Day - * @param int $endY optional, end Year, default $startY - * @param int $endY optional, end Month, default $startM - * @param int $endY optional, end Day, default $startD - * @param mixed $cType optional, calendar component type(-s), default FALSE=all else string/array type(-s) - * @param bool $flat optional, FALSE (default) => output : array[Year][Month][Day][] - * TRUE => output : array[] (ignores split) - * @param bool $any optional, TRUE (default) - select component(-s) that occurs within period - * FALSE - only component(-s) that starts within period - * @param bool $split optional, TRUE (default) - one component copy every DAY it occurs during the - * period (implies flat=FALSE) - * FALSE - one occurance of component only in output array - * @return array or FALSE - */ - function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) { - /* check if empty calendar */ - if( 0 >= count( $this->components )) return FALSE; - if( is_array( $startY )) - return $this->selectComponents2( $startY ); - /* check default dates */ - if( !$startY ) $startY = date( 'Y' ); - if( !$startM ) $startM = date( 'm' ); - if( !$startD ) $startD = date( 'd' ); - $startDate = mktime( 0, 0, 0, $startM, $startD, $startY ); - if( !$endY ) $endY = $startY; - if( !$endM ) $endM = $startM; - if( !$endD ) $endD = $startD; - $endDate = mktime( 23, 59, 59, $endM, $endD, $endY ); -//echo 'selectComp arg='.date( 'Y-m-d H:i:s', $startDate).' -- '.date( 'Y-m-d H:i:s', $endDate)."
\n"; $tcnt = 0;// test ### - /* check component types */ - $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' ); - if( is_array( $cType )) { - foreach( $cType as $cix => $theType ) { - $cType[$cix] = $theType = strtolower( $theType ); - if( !in_array( $theType, $validTypes )) - $cType[$cix] = 'vevent'; - } - $cType = array_unique( $cType ); - } - elseif( !empty( $cType )) { - $cType = strtolower( $cType ); - if( !in_array( $cType, $validTypes )) - $cType = array( 'vevent' ); - else - $cType = array( $cType ); - } - else - $cType = $validTypes; - if( 0 >= count( $cType )) - $cType = $validTypes; - if(( FALSE === $flat ) && ( FALSE === $any )) // invalid combination - $split = FALSE; - if(( TRUE === $flat ) && ( TRUE === $split )) // invalid combination - $split = FALSE; - /* iterate components */ - $result = array(); - foreach ( $this->components as $cix => $component ) { - if( empty( $component )) continue; - unset( $start ); - /* deselect unvalid type components */ - if( !in_array( $component->objName, $cType )) - continue; - $start = $component->getProperty( 'dtstart' ); - /* select due when dtstart is missing */ - if( empty( $start ) && ( $component->objName == 'vtodo' ) && ( FALSE === ( $start = $component->getProperty( 'due' )))) - continue; - if( empty( $start )) - continue; - $dtendExist = $dueExist = $durationExist = $endAllDayEvent = $recurrid = FALSE; - unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend, $endDateFormat ); // clean up - $startWdate = iCalUtilityFunctions::_date2timestamp( $start ); - $startDateFormat = ( isset( $start['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; - /* get end date from dtend/due/duration properties */ - $end = $component->getProperty( 'dtend' ); - if( !empty( $end )) { - $dtendExist = TRUE; - $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; - } - if( empty( $end ) && ( $component->objName == 'vtodo' )) { - $end = $component->getProperty( 'due' ); - if( !empty( $end )) { - $dueExist = TRUE; - $endDateFormat = ( isset( $end['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; - } - } - if( !empty( $end ) && !isset( $end['hour'] )) { - /* a DTEND without time part regards an event that ends the day before, - for an all-day event DTSTART=20071201 DTEND=20071202 (taking place 20071201!!! */ - $endAllDayEvent = TRUE; - $endWdate = mktime( 23, 59, 59, $end['month'], ($end['day'] - 1), $end['year'] ); - $end['year'] = date( 'Y', $endWdate ); - $end['month'] = date( 'm', $endWdate ); - $end['day'] = date( 'd', $endWdate ); - $end['hour'] = 23; - $end['min'] = $end['sec'] = 59; - } - if( empty( $end )) { - $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format - if( !empty( $end )) - $durationExist = TRUE; - $endDateFormat = ( isset( $start['hour'] )) ? 'Y-m-d H:i:s' : 'Y-m-d'; -// if( !empty($end)) echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."
\n"; // test ### - } - if( empty( $end )) { // assume one day duration if missing end date - $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 ); - } -// if( isset($end)) echo 'selectComp 5 start='.implode('-',$start).' end='.implode('-',$end)."
\n"; // test ### - $endWdate = iCalUtilityFunctions::_date2timestamp( $end ); - if( $endWdate < $startWdate ) { // MUST be after start date!! - $end = array( 'year' => $start['year'], 'month' => $start['month'], 'day' => $start['day'], 'hour' => 23, 'min' => 59, 'sec' => 59 ); - $endWdate = iCalUtilityFunctions::_date2timestamp( $end ); - } - $rdurWsecs = $endWdate - $startWdate; // compute event (component) duration in seconds - /* make a list of optional exclude dates for component occurence from exrule and exdate */ - $exdatelist = array(); - $workstart = iCalUtilityFunctions::_timestamp2date(( $startDate - $rdurWsecs ), 6); - $workend = iCalUtilityFunctions::_timestamp2date(( $endDate + $rdurWsecs ), 6); - while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) // check exrule - iCalUtilityFunctions::_recur2date( $exdatelist, $exrule, $start, $workstart, $workend ); - while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) { // check exdate - foreach( $exdate as $theExdate ) { - $exWdate = iCalUtilityFunctions::_date2timestamp( $theExdate ); - $exWdate = mktime( 0, 0, 0, date( 'm', $exWdate ), date( 'd', $exWdate ), date( 'Y', $exWdate )); // on a day-basis !!! - if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) - $exdatelist[$exWdate] = TRUE; - } // end - foreach( $exdate as $theExdate ) - } // end - check exdate - $compUID = $component->getProperty( 'UID' ); - /* check recurrence-id (with sequence), remove hit with reccurr-id date */ - if(( FALSE !== ( $recurrid = $component->getProperty( 'recurrence-id' ))) && - ( FALSE !== ( $sequence = $component->getProperty( 'sequence' ))) ) { - $recurrid = iCalUtilityFunctions::_date2timestamp( $recurrid ); - $recurrid = mktime( 0, 0, 0, date( 'm', $recurrid ), date( 'd', $recurrid ), date( 'Y', $recurrid )); // on a day-basis !!! - $endD = $recurrid + $rdurWsecs; - do { - if( date( 'Ymd', $startWdate ) != date( 'Ymd', $recurrid )) - $exdatelist[$recurrid] = TRUE; // exclude all other days than startdate - $wd = getdate( $recurrid ); - if( isset( $result[$wd['year']][$wd['mon']][$wd['mday']][$compUID] )) - unset( $result[$wd['year']][$wd['mon']][$wd['mday']][$compUID] ); // remove from output, dtstart etc added below - if( $split && ( $recurrid <= $endD )) - $recurrid = mktime( 0, 0, 0, date( 'm', $recurrid ), date( 'd', $recurrid ) + 1, date( 'Y', $recurrid )); // step one day - else - break; - } while( TRUE ); - } // end recurrence-id test - /* select only components with.. . */ - if(( !$any && ( $startWdate >= $startDate ) && ( $startWdate <= $endDate )) || // (dt)start within the period - ( $any && ( $startWdate < $endDate ) && ( $endWdate >= $startDate ))) { // occurs within the period - /* add the selected component (WITHIN valid dates) to output array */ - if( $flat ) { // any=true/false, ignores split - if( !$recurrid ) - $result[$compUID] = $component->copy(); // copy original to output (but not anyone with recurrence-id) - } - elseif( $split ) { // split the original component - if( $endWdate > $endDate ) - $endWdate = $endDate; // use period end date - $rstart = $startWdate; - if( $rstart < $startDate ) - $rstart = $startDate; // use period start date - $startYMD = date( 'Ymd', $rstart ); - $endYMD = date( 'Ymd', $endWdate ); - $checkDate = mktime( 0, 0, 0, date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart ) ); // on a day-basis !!! - while( date( 'Ymd', $rstart ) <= $endYMD ) { // iterate - $checkDate = mktime( 0, 0, 0, date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart ) ); // on a day-basis !!! - if( isset( $exdatelist[$checkDate] )) { // exclude any recurrence date, found in exdatelist - $rstart = mktime( date( 'H', $rstart ), date( 'i', $rstart ), date( 's', $rstart ), date( 'm', $rstart ), date( 'd', $rstart ) + 1, date( 'Y', $rstart ) ); // step one day - continue; - } - if( date( 'Ymd', $rstart ) > $startYMD ) // date after dtstart - $datestring = date( $startDateFormat, mktime( 0, 0, 0, date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart ))); - else - $datestring = date( $startDateFormat, $rstart ); - if( isset( $start['tz'] )) - $datestring .= ' '.$start['tz']; -// echo "X-CURRENT-DTSTART 3 = $datestring xRecurrence=$xRecurrence tcnt =".++$tcnt."
";$component->setProperty( 'X-CNT', $tcnt ); // test ### - $component->setProperty( 'X-CURRENT-DTSTART', $datestring ); - if( $dtendExist || $dueExist || $durationExist ) { - if( date( 'Ymd', $rstart ) < $endYMD ) // not the last day - $tend = mktime( 23, 59, 59, date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart )); - else - $tend = mktime( date( 'H', $endWdate ), date( 'i', $endWdate ), date( 's', $endWdate ), date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart ) ); // on a day-basis !!! - if( $endAllDayEvent && $dtendExist ) - $tend += ( 24 * 3600 ); // alldaysevents has an end date 'day after' meaning this day - $datestring = date( $endDateFormat, $tend ); - if( isset( $end['tz'] )) - $datestring .= ' '.$end['tz']; - $propName = ( !$dueExist ) ? 'X-CURRENT-DTEND' : 'X-CURRENT-DUE'; - $component->setProperty( $propName, $datestring ); - } // end if( $dtendExist || $dueExist || $durationExist ) - $wd = getdate( $rstart ); - $result[$wd['year']][$wd['mon']][$wd['mday']][$compUID] = $component->copy(); // copy to output - $rstart = mktime( date( 'H', $rstart ), date( 'i', $rstart ), date( 's', $rstart ), date( 'm', $rstart ), date( 'd', $rstart ) + 1, date( 'Y', $rstart ) ); // step one day - } // end while( $rstart <= $endWdate ) - } // end if( $split ) - else use component date - elseif( $recurrid && !$flat && !$any && !$split ) - $continue = TRUE; - else { // !$flat && !$split, i.e. no flat array and DTSTART within period - $checkDate = mktime( 0, 0, 0, date( 'm', $startWdate ), date( 'd', $startWdate ), date( 'Y', $startWdate ) ); // on a day-basis !!! - if( !$any || !isset( $exdatelist[$checkDate] )) { // exclude any recurrence date, found in exdatelist - $wd = getdate( $startWdate ); - $result[$wd['year']][$wd['mon']][$wd['mday']][$compUID] = $component->copy(); // copy to output - } - } - } // end if(( $startWdate >= $startDate ) && ( $startWdate <= $endDate )) - - /* if 'any' components, check components with reccurrence rules, removing all excluding dates */ - if( TRUE === $any ) { - /* make a list of optional repeating dates for component occurence, rrule, rdate */ - $recurlist = array(); - while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) // check rrule - iCalUtilityFunctions::_recur2date( $recurlist, $rrule, $start, $workstart, $workend ); - foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp - $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds - while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) { // check rdate - foreach( $rdate as $theRdate ) { - if( is_array( $theRdate ) && ( 2 == count( $theRdate )) && // all days within PERIOD - array_key_exists( '0', $theRdate ) && array_key_exists( '1', $theRdate )) { - $rstart = iCalUtilityFunctions::_date2timestamp( $theRdate[0] ); - if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) - continue; - if( isset( $theRdate[1]['year'] )) // date-date period - $rend = iCalUtilityFunctions::_date2timestamp( $theRdate[1] ); - else { // date-duration period - $rend = iCalUtilityFunctions::_duration2date( $theRdate[0], $theRdate[1] ); - $rend = iCalUtilityFunctions::_date2timestamp( $rend ); - } - while( $rstart < $rend ) { - $recurlist[$rstart] = $rdurWsecs; // set start date for recurrence instance + rdate duration in seconds - $rstart = mktime( date( 'H', $rstart ), date( 'i', $rstart ), date( 's', $rstart ), date( 'm', $rstart ), date( 'd', $rstart ) + 1, date( 'Y', $rstart ) ); // step one day - } - } // PERIOD end - else { // single date - $theRdate = iCalUtilityFunctions::_date2timestamp( $theRdate ); - if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) - $recurlist[$theRdate] = $rdurWsecs; // set start date for recurrence instance + event duration in seconds - } - } - } // end - check rdate - if( 0 < count( $recurlist )) { - ksort( $recurlist ); - $xRecurrence = 1; - $component2 = $component->copy(); - $compUID = $component2->getProperty( 'UID' ); - foreach( $recurlist as $recurkey => $durvalue ) { -// echo "recurKey=".date( 'Y-m-d H:i:s', $recurkey ).' dur='.iCalUtilityFunctions::offsetSec2His( $durvalue )."
\n"; // test ###; - if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period - continue; - $checkDate = mktime( 0, 0, 0, date( 'm', $recurkey ), date( 'd', $recurkey ), date( 'Y', $recurkey ) ); // on a day-basis !!! - if( isset( $exdatelist[$checkDate] )) // check excluded dates - continue; - if( $startWdate >= $recurkey ) // exclude component start date - continue; - $rstart = $recurkey; - $rend = $recurkey + $durvalue; - /* add repeating components within valid dates to output array, only start date set */ - if( $flat ) { - if( !isset( $result[$compUID] )) // only one comp - $result[$compUID] = $component2->copy(); // copy to output - } - /* add repeating components within valid dates to output array, one each day */ - elseif( $split ) { - if( $rend > $endDate ) - $rend = $endDate; - $startYMD = date( 'Ymd', $rstart ); - $endYMD = date( 'Ymd', $rend ); -// echo "splitStart=".date( 'Y-m-d H:i:s', $rstart ).' end='.date( 'Y-m-d H:i:s', $rend )."
\n"; // test ###; - while( $rstart <= $rend ) { // iterate.. . - $checkDate = mktime( 0, 0, 0, date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart ) ); // on a day-basis !!! - if( isset( $exdatelist[$checkDate] )) // exclude any recurrence START date, found in exdatelist - break; -// echo "checking date after startdate=".date( 'Y-m-d H:i:s', $rstart ).' mot '.date( 'Y-m-d H:i:s', $startDate )."
"; // test ###; - if( $rstart >= $startDate ) { // date after dtstart - if( date( 'Ymd', $rstart ) > $startYMD ) // date after dtstart - $datestring = date( $startDateFormat, $checkDate ); - else - $datestring = date( $startDateFormat, $rstart ); - if( isset( $start['tz'] )) - $datestring .= ' '.$start['tz']; -//echo "X-CURRENT-DTSTART 1 = $datestring xRecurrence=$xRecurrence tcnt =".++$tcnt."
";$component2->setProperty( 'X-CNT', $tcnt ); // test ### - $component2->setProperty( 'X-CURRENT-DTSTART', $datestring ); - if( $dtendExist || $dueExist || $durationExist ) { - if( date( 'Ymd', $rstart ) < $endYMD ) // not the last day - $tend = mktime( 23, 59, 59, date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart )); - else - $tend = mktime( date( 'H', $endWdate ), date( 'i', $endWdate ), date( 's', $endWdate ), date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart ) ); // on a day-basis !!! - if( $endAllDayEvent && $dtendExist ) - $tend += ( 24 * 3600 ); // alldaysevents has an end date 'day after' meaning this day - $datestring = date( $endDateFormat, $tend ); - if( isset( $end['tz'] )) - $datestring .= ' '.$end['tz']; - $propName = ( !$dueExist ) ? 'X-CURRENT-DTEND' : 'X-CURRENT-DUE'; - $component2->setProperty( $propName, $datestring ); - } // end if( $dtendExist || $dueExist || $durationExist ) - $component2->setProperty( 'X-RECURRENCE', $xRecurrence ); - $wd = getdate( $rstart ); - $result[$wd['year']][$wd['mon']][$wd['mday']][$compUID] = $component2->copy(); // copy to output - } // end if( $checkDate > $startYMD ) { // date after dtstart - $rstart = mktime( date( 'H', $rstart ), date( 'i', $rstart ), date( 's', $rstart ), date( 'm', $rstart ), date( 'd', $rstart ) + 1, date( 'Y', $rstart ) ); // step one day - } // end while( $rstart <= $rend ) - $xRecurrence += 1; - } // end elseif( $split ) - elseif( $rstart >= $startDate ) { // date within period //* flat=FALSE && split=FALSE => one comp every recur startdate *// - $checkDate = mktime( 0, 0, 0, date( 'm', $rstart ), date( 'd', $rstart ), date( 'Y', $rstart ) ); // on a day-basis !!! - if( !isset( $exdatelist[$checkDate] )) { // exclude any recurrence START date, found in exdatelist - $xRecurrence += 1; - $datestring = date( $startDateFormat, $rstart ); - if( isset( $start['tz'] )) - $datestring .= ' '.$start['tz']; -//echo "X-CURRENT-DTSTART 2 = $datestring xRecurrence=$xRecurrence tcnt =".++$tcnt."
";$component2->setProperty( 'X-CNT', $tcnt ); // test ### - $component2->setProperty( 'X-CURRENT-DTSTART', $datestring ); - if( $dtendExist || $dueExist || $durationExist ) { - $tend = $rstart + $rdurWsecs; - if( date( 'Ymd', $tend ) < date( 'Ymd', $endWdate )) - $tend = mktime( 23, 59, 59, date( 'm', $tend ), date( 'd', $tend ), date( 'Y', $tend )); - else - $tend = mktime( date( 'H', $endWdate ), date( 'i', $endWdate ), date( 's', $endWdate ), date( 'm', $tend ), date( 'd', $tend ), date( 'Y', $tend ) ); // on a day-basis !!! - if( $endAllDayEvent && $dtendExist ) - $tend += ( 24 * 3600 ); // alldaysevents has an end date 'day after' meaning this day - $datestring = date( $endDateFormat, $tend ); - if( isset( $end['tz'] )) - $datestring .= ' '.$end['tz']; - $propName = ( !$dueExist ) ? 'X-CURRENT-DTEND' : 'X-CURRENT-DUE'; - $component2->setProperty( $propName, $datestring ); - } // end if( $dtendExist || $dueExist || $durationExist ) - $component2->setProperty( 'X-RECURRENCE', $xRecurrence ); - $wd = getdate( $rstart ); - $result[$wd['year']][$wd['mon']][$wd['mday']][$compUID] = $component2->copy(); // copy to output - } // end if( !isset( $exdatelist[$checkDate] )) - } // end elseif( $rstart >= $startDate ) - } // end foreach( $recurlist as $recurkey => $durvalue ) - } // end if( 0 < count( $recurlist )) - /* deselect components with startdate/enddate not within period */ - if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) - continue; - } // end if( TRUE === $any ) - } // end foreach ( $this->components as $cix => $component ) - if( 0 >= count( $result )) return FALSE; - elseif( !$flat ) { - foreach( $result as $y => $yeararr ) { - foreach( $yeararr as $m => $montharr ) { - foreach( $montharr as $d => $dayarr ) { - if( empty( $result[$y][$m][$d] )) - unset( $result[$y][$m][$d] ); - else - $result[$y][$m][$d] = array_values( $dayarr ); // skip tricky UID-index, hoping they are in hour order.. . - } - if( empty( $result[$y][$m] )) - unset( $result[$y][$m] ); - else - ksort( $result[$y][$m] ); - } - if( empty( $result[$y] )) - unset( $result[$y] ); - else - ksort( $result[$y] ); - } - if( empty( $result )) - unset( $result ); - else - ksort( $result ); - } // end elseif( !$flat ) - if( 0 >= count( $result )) - return FALSE; - return $result; - } -/** - * select components from calendar on based on Categories, Location, Resources and/or Summary - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-05-03 - * @param array $selectOptions, (string) key => (mixed) value, (key=propertyName) - * @return array - */ - function selectComponents2( $selectOptions ) { - $output = array(); - $allowedProperties = array( 'ATTENDEE', 'CATEGORIES', 'LOCATION', 'ORGANIZER', 'RESOURCES', 'PRIORITY', 'STATUS', 'SUMMARY', 'UID' ); - foreach( $this->components as $cix => $component3 ) { - if( !in_array( $component3->objName, array('vevent', 'vtodo', 'vjournal', 'vfreebusy' ))) - continue; - $uid = $component3->getProperty( 'UID' ); - foreach( $selectOptions as $propName => $pvalue ) { - $propName = strtoupper( $propName ); - if( !in_array( $propName, $allowedProperties )) - continue; - if( !is_array( $pvalue )) - $pvalue = array( $pvalue ); - if(( 'UID' == $propName ) && in_array( $uid, $pvalue )) { - $output[] = $component3->copy(); - continue; - } - elseif(( 'ATTENDEE' == $propName ) || ( 'CATEGORIES' == $propName ) || ( 'RESOURCES' == $propName )) { - $propValues = array(); - $component3->_getProperties( $propName, $propValues ); - $propValues = array_keys( $propValues ); - foreach( $pvalue as $theValue ) { - if( in_array( $theValue, $propValues ) && !isset( $output[$uid] )) { - $output[$uid] = $component3->copy(); - break; - } - } - continue; - } // end elseif(( 'ATTENDEE' == $propName ) || ( 'CATEGORIES' == $propName ) || ( 'RESOURCES' == $propName )) - elseif( FALSE === ( $d = $component3->getProperty( $propName ))) // single ocurrence - continue; - if( is_array( $d )) { - foreach( $d as $part ) { - if( in_array( $part, $pvalue ) && !isset( $output[$uid] )) - $output[$uid] = $component3->copy(); - } - } - elseif(( 'SUMMARY' == $propName ) && !isset( $output[$uid] )) { - foreach( $pvalue as $pval ) { - if( FALSE !== stripos( $d, $pval )) { - $output[$uid] = $component3->copy(); - break; - } - } - } - elseif( in_array( $d, $pvalue ) && !isset( $output[$uid] )) - $output[$uid] = $component3->copy(); - } // end foreach( $selectOptions as $propName => $pvalue ) { - } // end foreach( $this->components as $cix => $component3 ) { - if( !empty( $output )) { - ksort( $output ); - $output = array_values( $output ); - } - return $output; - } -/** - * add calendar component to container - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @param object $component calendar component - * @param mixed $arg1 optional, ordno/component type/ component uid - * @param mixed $arg2 optional, ordno if arg1 = component type - * @return void - */ - function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { - $component->setConfig( $this->getConfig(), FALSE, TRUE ); - if( !in_array( $component->objName, array( 'valarm', 'vtimezone' ))) { - /* make sure dtstamp and uid is set */ - $dummy1 = $component->getProperty( 'dtstamp' ); - $dummy2 = $component->getProperty( 'uid' ); - } - if( !$arg1 ) { // plain insert, last in chain - $this->components[] = $component->copy(); - return TRUE; - } - $argType = $index = null; - if ( ctype_digit( (string) $arg1 )) { // index insert/replace - $argType = 'INDEX'; - $index = (int) $arg1 - 1; - } - elseif( in_array( strtolower( $arg1 ), array( 'vevent', 'vtodo', 'vjournal', 'vfreebusy', 'valarm', 'vtimezone' ))) { - $argType = strtolower( $arg1 ); - $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; - } - // else if arg1 is set, arg1 must be an UID - $cix1sC = 0; - foreach ( $this->components as $cix => $component2) { - if( empty( $component2 )) continue; - if(( 'INDEX' == $argType ) && ( $index == $cix )) { // index insert/replace - $this->components[$cix] = $component->copy(); - return TRUE; - } - elseif( $argType == $component2->objName ) { // component Type index insert/replace - if( $index == $cix1sC ) { - $this->components[$cix] = $component->copy(); - return TRUE; - } - $cix1sC++; - } - elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { // UID insert/replace - $this->components[$cix] = $component->copy(); - return TRUE; - } - } - /* arg1=index and not found.. . insert at index .. .*/ - if( 'INDEX' == $argType ) { - $this->components[$index] = $component->copy(); - ksort( $this->components, SORT_NUMERIC ); - } - else /* not found.. . insert last in chain anyway .. .*/ - $this->components[] = $component->copy(); - return TRUE; - } -/** - * sort iCal compoments - * - * ascending sort on properties (if exist) x-current-dtstart, dtstart, - * x-current-dtend, dtend, x-current-due, due, duration, created, dtstamp, uid - * if no arguments, otherwise sorting on argument CATEGORIES, LOCATION, SUMMARY or RESOURCES - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.4 - 2011-06-02 - * @param string $sortArg, optional - * @return void - * - */ - function sort( $sortArg=FALSE ) { - if( is_array( $this->components )) { - if( $sortArg ) { - $sortArg = strtoupper( $sortArg ); - if( !in_array( $sortArg, array( 'ATTENDEE', 'CATEGORIES', 'DTSTAMP', 'LOCATION', 'ORGANIZER', 'RESOURCES', 'PRIORITY', 'STATUS', 'SUMMARY' ))) - $sortArg = FALSE; - } - /* set sort parameters for each component */ - foreach( $this->components as $cix => & $c ) { - $c->srtk = array( '0', '0', '0', '0' ); - if( 'vtimezone' == $c->objName ) { - if( FALSE === ( $c->srtk[0] = $c->getProperty( 'tzid' ))) - $c->srtk[0] = 0; - continue; - } - elseif( $sortArg ) { - if(( 'ATTENDEE' == $sortArg ) || ( 'CATEGORIES' == $sortArg ) || ( 'RESOURCES' == $sortArg )) { - $propValues = array(); - $c->_getProperties( $sortArg, $propValues ); - $c->srtk[0] = reset( array_keys( $propValues )); - } - elseif( FALSE !== ( $d = $c->getProperty( $sortArg ))) - $c->srtk[0] = $d; - continue; - } - if( FALSE !== ( $d = $c->getProperty( 'X-CURRENT-DTSTART' ))) { - $c->srtk[0] = iCalUtilityFunctions::_date_time_string( $d[1] ); - unset( $c->srtk[0]['unparsedtext'] ); - } - elseif( FALSE === ( $c->srtk[0] = $c->getProperty( 'dtstart' ))) - $c->srtk[1] = 0; // sortkey 0 : dtstart - if( FALSE !== ( $d = $c->getProperty( 'X-CURRENT-DTEND' ))) { - $c->srtk[1] = iCalUtilityFunctions::_date_time_string( $d[1] ); // sortkey 1 : dtend/due(/dtstart+duration) - unset( $c->srtk[1]['unparsedtext'] ); - } - elseif( FALSE === ( $c->srtk[1] = $c->getProperty( 'dtend' ))) { - if( FALSE !== ( $d = $c->getProperty( 'X-CURRENT-DUE' ))) { - $c->srtk[1] = iCalUtilityFunctions::_date_time_string( $d[1] ); - unset( $c->srtk[1]['unparsedtext'] ); - } - elseif( FALSE === ( $c->srtk[1] = $c->getProperty( 'due' ))) - if( FALSE === ( $c->srtk[1] = $c->getProperty( 'duration', FALSE, FALSE, TRUE ))) - $c->srtk[1] = 0; - } - if( FALSE === ( $c->srtk[2] = $c->getProperty( 'created' ))) // sortkey 2 : created/dtstamp - if( FALSE === ( $c->srtk[2] = $c->getProperty( 'dtstamp' ))) - $c->srtk[2] = 0; - if( FALSE === ( $c->srtk[3] = $c->getProperty( 'uid' ))) // sortkey 3 : uid - $c->srtk[3] = 0; - } // end foreach( $this->components as & $c - /* sort */ - usort( $this->components, array( $this, '_cmpfcn' )); - } - } - function _cmpfcn( $a, $b ) { - if( empty( $a )) return -1; - if( empty( $b )) return 1; - if( 'vtimezone' == $a->objName ) { - if( 'vtimezone' != $b->objName ) return -1; - elseif( $a->srtk[0] <= $b->srtk[0] ) return -1; - else return 1; - } - elseif( 'vtimezone' == $b->objName ) return 1; - $sortkeys = array( 'year', 'month', 'day', 'hour', 'min', 'sec' ); - for( $k = 0; $k < 4 ; $k++ ) { - if( empty( $a->srtk[$k] )) return -1; - elseif( empty( $b->srtk[$k] )) return 1; - if( is_array( $a->srtk[$k] )) { - if( is_array( $b->srtk[$k] )) { - foreach( $sortkeys as $key ) { - if ( empty( $a->srtk[$k][$key] )) return -1; - elseif( empty( $b->srtk[$k][$key] )) return 1; - if ( $a->srtk[$k][$key] == $b->srtk[$k][$key]) - continue; - if (( (int) $a->srtk[$k][$key] ) < ((int) $b->srtk[$k][$key] )) - return -1; - elseif(( (int) $a->srtk[$k][$key] ) > ((int) $b->srtk[$k][$key] )) - return 1; - } - } - else return -1; - } - elseif( is_array( $b->srtk[$k] )) return 1; - elseif( $a->srtk[$k] < $b->srtk[$k] ) return -1; - elseif( $a->srtk[$k] > $b->srtk[$k] ) return 1; - } - return 0; - } -/** - * parse iCal text/file into vcalendar, components, properties and parameters - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.10 - 2012-01-31 - * @param mixed $unparsedtext, optional, strict rfc2445 formatted, single property string or array of property strings - * @return bool FALSE if error occurs during parsing - * - */ - function parse( $unparsedtext=FALSE ) { - $nl = $this->getConfig( 'nl' ); - if(( FALSE === $unparsedtext ) || empty( $unparsedtext )) { - /* directory+filename is set previously via setConfig directory+filename or url */ - if( FALSE === ( $filename = $this->getConfig( 'url' ))) - $filename = $this->getConfig( 'dirfile' ); - /* READ FILE */ - if( FALSE === ( $rows = file_get_contents( $filename ))) - return FALSE; /* err 1 */ - } - elseif( is_array( $unparsedtext )) - $rows = implode( '\n'.$nl, $unparsedtext ); - else - $rows = & $unparsedtext; - /* identify BEGIN:VCALENDAR, MUST be first row */ - if( 'BEGIN:VCALENDAR' != strtoupper( substr( $rows, 0, 15 ))) - return FALSE; /* err 8 */ - /* fix line folding */ - $eolchars = array( "\r\n", "\n\r", "\n", "\r" ); // check all line endings - $EOLmark = FALSE; - foreach( $eolchars as $eolchar ) { - if( !$EOLmark && ( FALSE !== strpos( $rows, $eolchar ))) { - $rows = str_replace( $eolchar." ", '', $rows ); - $rows = str_replace( $eolchar."\t", '', $rows ); - if( $eolchar != $nl ) - $rows = str_replace( $eolchar, $nl, $rows ); - $EOLmark = TRUE; - } - } - $rows = explode( $nl, $rows ); - /* skip trailing empty lines */ - $lix = count( $rows ) - 1; - while( empty( $rows[$lix] ) && ( 0 < $lix )) - $lix -= 1; - /* identify ending END:VCALENDAR row, MUST be last row */ - if( 'END:VCALENDAR' != strtoupper( substr( $rows[$lix], 0, 13 ))) - return FALSE; /* err 9 */ - if( 3 > count( $rows )) - return FALSE; /* err 10 */ - $comp = & $this; - $calsync = 0; - /* identify components and update unparsed data within component */ - $config = $this->getConfig(); - foreach( $rows as $line ) { - if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) { - $calsync++; - continue; - } - elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) { - $calsync--; - break; - } - elseif( 1 != $calsync ) - return FALSE; /* err 20 */ - elseif( in_array( strtoupper( substr( $line, 0, 6 )), array( 'END:VE', 'END:VF', 'END:VJ', 'END:VT' ))) { - $this->components[] = $comp->copy(); - continue; - } - if( 'BEGIN:VEVENT' == strtoupper( substr( $line, 0, 12 ))) - $comp = new vevent( $config ); - elseif( 'BEGIN:VFREEBUSY' == strtoupper( substr( $line, 0, 15 ))) - $comp = new vfreebusy( $config ); - elseif( 'BEGIN:VJOURNAL' == strtoupper( substr( $line, 0, 14 ))) - $comp = new vjournal( $config ); - elseif( 'BEGIN:VTODO' == strtoupper( substr( $line, 0, 11 ))) - $comp = new vtodo( $config ); - elseif( 'BEGIN:VTIMEZONE' == strtoupper( substr( $line, 0, 15 ))) - $comp = new vtimezone( $config ); - else { /* update component with unparsed data */ - $comp->unparsed[] = $line; - } - } // end foreach( $rows as $line ) - unset( $config ); - /* parse data for calendar (this) object */ - if( isset( $this->unparsed ) && is_array( $this->unparsed ) && ( 0 < count( $this->unparsed ))) { - /* concatenate property values spread over several lines */ - $lastix = -1; - $propnames = array( 'calscale','method','prodid','version','x-' ); - $proprows = array(); - foreach( $this->unparsed as $line ) { - $newProp = FALSE; - foreach ( $propnames as $propname ) { - if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) { - $newProp = TRUE; - break; - } - } - if( $newProp ) { - $newProp = FALSE; - $lastix++; - $proprows[$lastix] = $line; - } - else - $proprows[$lastix] .= '!"#¤%&/()=?'.$line; - } - $paramMStz = array( 'utc-', 'utc+', 'gmt-', 'gmt+' ); - $paramProto3 = array( 'fax:', 'cid:', 'sms:', 'tel:', 'urn:' ); - $paramProto4 = array( 'crid:', 'news:', 'pres:' ); - foreach( $proprows as $line ) { - $line = str_replace( '!"#¤%&/()=? ', '', $line ); - $line = str_replace( '!"#¤%&/()=?', '', $line ); - if( '\n' == substr( $line, -2 )) - $line = substr( $line, 0, strlen( $line ) - 2 ); - /* get property name */ - $cix = $propname = null; - for( $cix=0, $clen = strlen( $line ); $cix < $clen; $cix++ ) { - if( in_array( $line[$cix], array( ':', ';' ))) - break; - else - $propname .= $line[$cix]; - } - /* ignore version/prodid properties */ - if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) - continue; - $line = substr( $line, $cix); - /* separate attributes from value */ - $attr = array(); - $attrix = -1; - $strlen = strlen( $line ); - $WithinQuotes = FALSE; - for( $cix=0; $cix < $strlen; $cix++ ) { - if( ( ':' == $line[$cix] ) && - ( substr( $line,$cix, 3 ) != '://' ) && - ( !in_array( strtolower( substr( $line,$cix - 6, 4 )), $paramMStz )) && - ( !in_array( strtolower( substr( $line,$cix - 3, 4 )), $paramProto3 )) && - ( !in_array( strtolower( substr( $line,$cix - 4, 5 )), $paramProto4 )) && - ( strtolower( substr( $line,$cix - 6, 7 )) != 'mailto:' ) && - !$WithinQuotes ) { - $attrEnd = TRUE; - if(( $cix < ( $strlen - 4 )) && - ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr?? - for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) { - if( '://' == substr( $line, $c2ix - 2, 3 )) { - $attrEnd = FALSE; - break; // an URI with a portnr!! - } - } - } - if( $attrEnd) { - $line = substr( $line, ( $cix + 1 )); - break; - } - } - if( '"' == $line[$cix] ) - $WithinQuotes = ( FALSE === $WithinQuotes ) ? TRUE : FALSE; - if( ';' == $line[$cix] ) - $attr[++$attrix] = null; - else - $attr[$attrix] .= $line[$cix]; - } - /* make attributes in array format */ - $propattr = array(); - foreach( $attr as $attribute ) { - $attrsplit = explode( '=', $attribute, 2 ); - if( 1 < count( $attrsplit )) - $propattr[$attrsplit[0]] = $attrsplit[1]; - else - $propattr[] = $attribute; - } - /* update Property */ - if( FALSE !== strpos( $line, ',' )) { - $llen = strlen( $line ); - $content = array( 0 => '' ); - $cix = 0; - for( $lix = 0; $lix < $llen; $lix++ ) { - if(( ',' == $line[$lix] ) && ( "\\" != $line[( $lix - 1 )])) { - $cix++; - $content[$cix] = ''; - } - else - $content[$cix] .= $line[$lix]; - } - if( 1 < count( $content )) { - foreach( $content as $cix => $contentPart ) - $content[$cix] = calendarComponent::_strunrep( $contentPart ); - $this->setProperty( $propname, $content, $propattr ); - continue; - } - else - $line = reset( $content ); - $line = calendarComponent::_strunrep( $line ); - } - $this->setProperty( $propname, rtrim( $line, "\x00..\x1F" ), $propattr ); - } // end - foreach( $this->unparsed.. . - } // end - if( is_array( $this->unparsed.. . - unset( $unparsedtext, $rows, $this->unparsed, $proprows ); - /* parse Components */ - if( is_array( $this->components ) && ( 0 < count( $this->components ))) { - $ckeys = array_keys( $this->components ); - foreach( $ckeys as $ckey ) { - if( !empty( $this->components[$ckey] ) && !empty( $this->components[$ckey]->unparsed )) { - $this->components[$ckey]->parse(); - } - } - } - else - return FALSE; /* err 91 or something.. . */ - return TRUE; - } -/*********************************************************************************/ -/** - * creates formatted output for calendar object instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.16 - 2011-10-28 - * @return string - */ - function createCalendar() { - $calendarInit = $calendarxCaldecl = $calendarStart = $calendar = ''; - switch( $this->format ) { - case 'xcal': - $calendarInit = ''.$this->nl. - 'nl. - '"http://www.ietf.org/internet-drafts/draft-ietf-calsch-many-xcal-01.txt"'; - $calendarStart = '>'.$this->nl.'nl; - break; - } - $calendarStart .= $this->createVersion(); - $calendarStart .= $this->createProdid(); - $calendarStart .= $this->createCalscale(); - $calendarStart .= $this->createMethod(); - if( 'xcal' == $this->format ) - $calendarStart .= '>'.$this->nl; - $calendar .= $this->createXprop(); - - foreach( $this->components as $component ) { - if( empty( $component )) continue; - $component->setConfig( $this->getConfig(), FALSE, TRUE ); - $calendar .= $component->createComponent( $this->xcaldecl ); - } - if(( 'xcal' == $this->format ) && ( 0 < count( $this->xcaldecl ))) { // xCal only - $calendarInit .= ' ['; - $old_xcaldecl = array(); - foreach( $this->xcaldecl as $declix => $declPart ) { - if(( 0 < count( $old_xcaldecl)) && - isset( $declPart['uri'] ) && isset( $declPart['external'] ) && - isset( $old_xcaldecl['uri'] ) && isset( $old_xcaldecl['external'] ) && - ( in_array( $declPart['uri'], $old_xcaldecl['uri'] )) && - ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) - continue; // no duplicate uri and ext. references - if(( 0 < count( $old_xcaldecl)) && - !isset( $declPart['uri'] ) && !isset( $declPart['uri'] ) && - isset( $declPart['ref'] ) && isset( $old_xcaldecl['ref'] ) && - ( in_array( $declPart['ref'], $old_xcaldecl['ref'] ))) - continue; // no duplicate element declarations - $calendarxCaldecl .= $this->nl.' $declValue ) { - switch( $declKey ) { // index - case 'xmldecl': // no 1 - $calendarxCaldecl .= $declValue.' '; - break; - case 'uri': // no 2 - $calendarxCaldecl .= $declValue.' '; - $old_xcaldecl['uri'][] = $declValue; - break; - case 'ref': // no 3 - $calendarxCaldecl .= $declValue.' '; - $old_xcaldecl['ref'][] = $declValue; - break; - case 'external': // no 4 - $calendarxCaldecl .= '"'.$declValue.'" '; - $old_xcaldecl['external'][] = $declValue; - break; - case 'type': // no 5 - $calendarxCaldecl .= $declValue.' '; - break; - case 'type2': // no 6 - $calendarxCaldecl .= $declValue; - break; - } - } - $calendarxCaldecl .= '>'; - } - $calendarxCaldecl .= $this->nl.']'; - } - switch( $this->format ) { - case 'xcal': - $calendar .= ''.$this->nl; - break; - default: - $calendar .= 'END:VCALENDAR'.$this->nl; - break; - } - return $calendarInit.$calendarxCaldecl.$calendarStart.$calendar; - } -/** - * a HTTP redirect header is sent with created, updated and/or parsed calendar - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.24 - 2011-12-23 - * @param bool $utf8Encode - * @param bool $gzip - * @return redirect - */ - function returnCalendar( $utf8Encode=FALSE, $gzip=FALSE ) { - $filename = $this->getConfig( 'filename' ); - $output = $this->createCalendar(); - if( $utf8Encode ) - $output = utf8_encode( $output ); - if( $gzip ) { - $output = gzencode( $output, 9 ); - header( 'Content-Encoding: gzip' ); - header( 'Vary: *' ); - header( 'Content-Length: '.strlen( $output )); - } - if( 'xcal' == $this->format ) - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); - else - header( 'Content-Type: text/calendar; charset=utf-8' ); - header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); - header( 'Cache-Control: max-age=10' ); - die( $output ); - } -/** - * save content in a file - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.2.12 - 2007-12-30 - * @param string $directory optional - * @param string $filename optional - * @param string $delimiter optional - * @return bool - */ - function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) { - if( $directory ) - $this->setConfig( 'directory', $directory ); - if( $filename ) - $this->setConfig( 'filename', $filename ); - if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) - $this->setConfig( 'delimiter', $delimiter ); - if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) - $dirfile = $this->getConfig( 'dirfile' ); - $iCalFile = @fopen( $dirfile, 'w' ); - if( $iCalFile ) { - if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) - return FALSE; - fclose( $iCalFile ); - return TRUE; - } - else - return FALSE; - } -/** - * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent - * else FALSE is returned - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.2.12 - 2007-10-28 - * @param string $directory optional alt. int timeout - * @param string $filename optional - * @param string $delimiter optional - * @param int timeout optional, default 3600 sec - * @return redirect/FALSE - */ - function useCachedCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE, $timeout=3600) { - if ( $directory && ctype_digit( (string) $directory ) && !$filename ) { - $timeout = (int) $directory; - $directory = FALSE; - } - if( $directory ) - $this->setConfig( 'directory', $directory ); - if( $filename ) - $this->setConfig( 'filename', $filename ); - if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) - $this->setConfig( 'delimiter', $delimiter ); - $filesize = $this->getConfig( 'filesize' ); - if( 0 >= $filesize ) - return FALSE; - $dirfile = $this->getConfig( 'dirfile' ); - if( time() - filemtime( $dirfile ) < $timeout) { - clearstatcache(); - $dirfile = $this->getConfig( 'dirfile' ); - $filename = $this->getConfig( 'filename' ); -// if( headers_sent( $filename, $linenum )) -// die( "Headers already sent in $filename on line $linenum\n" ); - if( 'xcal' == $this->format ) - header( 'Content-Type: application/calendar+xml; charset=utf-8' ); - else - header( 'Content-Type: text/calendar; charset=utf-8' ); - header( 'Content-Length: '.$filesize ); - header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); - header( 'Cache-Control: max-age=10' ); - $fp = @fopen( $dirfile, 'r' ); - if( $fp ) { - fpassthru( $fp ); - fclose( $fp ); - } - die(); - } - else - return FALSE; - } -} -/*********************************************************************************/ -/*********************************************************************************/ -/** - * abstract class for calendar components - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-14 - */ -class calendarComponent { - // component property variables - var $uid; - var $dtstamp; - - // component config variables - var $allowEmpty; - var $language; - var $nl; - var $unique_id; - var $format; - var $objName; // created automatically at instance creation - var $dtzid; // default (local) timezone - // component internal variables - var $componentStart1; - var $componentStart2; - var $componentEnd1; - var $componentEnd2; - var $elementStart1; - var $elementStart2; - var $elementEnd1; - var $elementEnd2; - var $intAttrDelimiter; - var $attributeDelimiter; - var $valueInit; - // component xCal declaration container - var $xcaldecl; -/** - * constructor for calendar component object - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-17 - */ - function calendarComponent() { - $this->objName = ( isset( $this->timezonetype )) ? - strtolower( $this->timezonetype ) : get_class ( $this ); - $this->uid = array(); - $this->dtstamp = array(); - - $this->language = null; - $this->nl = null; - $this->unique_id = null; - $this->format = null; - $this->dtzid = null; - $this->allowEmpty = TRUE; - $this->xcaldecl = array(); - - $this->_createFormat(); - $this->_makeDtstamp(); - } -/*********************************************************************************/ -/** - * Property Name: ACTION - */ -/** - * creates formatted output for calendar component property action - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createAction() { - if( empty( $this->action )) return FALSE; - if( empty( $this->action['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE; - $attributes = $this->_createParams( $this->action['params'] ); - return $this->_createElement( 'ACTION', $attributes, $this->action['value'] ); - } -/** - * set calendar component property action - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value "AUDIO" / "DISPLAY" / "EMAIL" / "PROCEDURE" - * @param mixed $params - * @return bool - */ - function setAction( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->action = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: ATTACH - */ -/** - * creates formatted output for calendar component property attach - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.16 - 2012-02-04 - * @return string - */ - function createAttach() { - if( empty( $this->attach )) return FALSE; - $output = null; - foreach( $this->attach as $attachPart ) { - if( !empty( $attachPart['value'] )) { - $attributes = $this->_createParams( $attachPart['params'] ); - if(( 'xcal' != $this->format ) && isset( $attachPart['params']['VALUE'] ) && ( 'BINARY' == $attachPart['params']['VALUE'] )) { - $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); - $str = 'ATTACH'.$attributes.$this->valueInit.$attachPart['value']; - $output = substr( $str, 0, 75 ).$this->nl; - $str = substr( $str, 75 ); - $output .= ' '.chunk_split( $str, 74, $this->nl.' ' ); - if( ' ' == substr( $output, -1 )) - $output = rtrim( $output ); - if( $this->nl != substr( $output, ( 0 - strlen( $this->nl )))) - $output .= $this->nl; - return $output; - } - $output .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] ); - } - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' ); - } - return $output; - } -/** - * set calendar component property attach - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-06 - * @param string $value - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setAttach( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - iCalUtilityFunctions::_setMval( $this->attach, $value, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: ATTENDEE - */ -/** - * creates formatted output for calendar component property attendee - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.12 - 2012-01-31 - * @return string - */ - function createAttendee() { - if( empty( $this->attendee )) return FALSE; - $output = null; - foreach( $this->attendee as $attendeePart ) { // start foreach 1 - if( empty( $attendeePart['value'] )) { - if( $this->getConfig( 'allowEmpty' )) - $output .= $this->_createElement( 'ATTENDEE' ); - continue; - } - $attendee1 = $attendee2 = null; - foreach( $attendeePart as $paramlabel => $paramvalue ) { // start foreach 2 - if( 'value' == $paramlabel ) - $attendee2 .= $paramvalue; - elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif - $mParams = array( 'MEMBER', 'DELEGATED-TO', 'DELEGATED-FROM' ); - foreach( $paramvalue as $pKey => $pValue ) { // fix (opt) quotes - if( is_array( $pValue ) || in_array( $pKey, $mParams )) - continue; - if(( FALSE !== strpos( $pValue, ':' )) || - ( FALSE !== strpos( $pValue, ';' )) || - ( FALSE !== strpos( $pValue, ',' ))) - $paramvalue[$pKey] = '"'.$pValue.'"'; - } - // set attenddee parameters in rfc2445 order - if( isset( $paramvalue['CUTYPE'] )) - $attendee1 .= $this->intAttrDelimiter.'CUTYPE='.$paramvalue['CUTYPE']; - if( isset( $paramvalue['MEMBER'] )) { - $attendee1 .= $this->intAttrDelimiter.'MEMBER='; - foreach( $paramvalue['MEMBER'] as $cix => $opv ) - $attendee1 .= ( $cix ) ? ',"'.$opv.'"' : '"'.$opv.'"' ; - } - if( isset( $paramvalue['ROLE'] )) - $attendee1 .= $this->intAttrDelimiter.'ROLE='.$paramvalue['ROLE']; - if( isset( $paramvalue['PARTSTAT'] )) - $attendee1 .= $this->intAttrDelimiter.'PARTSTAT='.$paramvalue['PARTSTAT']; - if( isset( $paramvalue['RSVP'] )) - $attendee1 .= $this->intAttrDelimiter.'RSVP='.$paramvalue['RSVP']; - if( isset( $paramvalue['DELEGATED-TO'] )) { - $attendee1 .= $this->intAttrDelimiter.'DELEGATED-TO='; - foreach( $paramvalue['DELEGATED-TO'] as $cix => $opv ) - $attendee1 .= ( $cix ) ? ',"'.$opv.'"' : '"'.$opv.'"' ; - } - if( isset( $paramvalue['DELEGATED-FROM'] )) { - $attendee1 .= $this->intAttrDelimiter.'DELEGATED-FROM='; - foreach( $paramvalue['DELEGATED-FROM'] as $cix => $opv ) - $attendee1 .= ( $cix ) ? ',"'.$opv.'"' : '"'.$opv.'"' ; - } - if( isset( $paramvalue['SENT-BY'] )) - $attendee1 .= $this->intAttrDelimiter.'SENT-BY='.$paramvalue['SENT-BY']; - if( isset( $paramvalue['CN'] )) - $attendee1 .= $this->intAttrDelimiter.'CN='.$paramvalue['CN']; - if( isset( $paramvalue['DIR'] )) { - $delim = ( FALSE === strpos( $paramvalue['DIR'], '"' )) ? '"' : ''; - $attendee1 .= $this->intAttrDelimiter.'DIR='.$delim.$paramvalue['DIR'].$delim; - } - if( isset( $paramvalue['LANGUAGE'] )) - $attendee1 .= $this->intAttrDelimiter.'LANGUAGE='.$paramvalue['LANGUAGE']; - $xparams = array(); - foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3 - if( ctype_digit( (string) $optparamlabel )) { - $xparams[] = $optparamvalue; - continue; - } - if( !in_array( $optparamlabel, array( 'CUTYPE', 'MEMBER', 'ROLE', 'PARTSTAT', 'RSVP', 'DELEGATED-TO', 'DELEGATED-FROM', 'SENT-BY', 'CN', 'DIR', 'LANGUAGE' ))) - $xparams[$optparamlabel] = $optparamvalue; - } // end foreach 3 - ksort( $xparams, SORT_STRING ); - foreach( $xparams as $paramKey => $paramValue ) { - if( ctype_digit( (string) $paramKey )) - $attendee1 .= $this->intAttrDelimiter.$paramValue; - else - $attendee1 .= $this->intAttrDelimiter."$paramKey=$paramValue"; - } // end foreach 3 - } // end elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) - } // end foreach 2 - $output .= $this->_createElement( 'ATTENDEE', $attendee1, $attendee2 ); - } // end foreach 1 - return $output; - } -/** - * set calendar component property attach - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.17 - 2012-02-03 - * @param string $value - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setAttendee( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - // ftp://, http://, mailto:, file://, gopher://, news:, nntp://, telnet://, wais://, prospero:// may exist.. . also in params - if( FALSE !== ( $pos = strpos( substr( $value, 0, 9 ), ':' ))) - $value = strtoupper( substr( $value, 0, $pos )).substr( $value, $pos ); - elseif( !empty( $value )) - $value = 'MAILTO:'.$value; - $params2 = array(); - if( is_array($params )) { - $optarrays = array(); - foreach( $params as $optparamlabel => $optparamvalue ) { - $optparamlabel = strtoupper( $optparamlabel ); - switch( $optparamlabel ) { - case 'MEMBER': - case 'DELEGATED-TO': - case 'DELEGATED-FROM': - if( !is_array( $optparamvalue )) - $optparamvalue = array( $optparamvalue ); - foreach( $optparamvalue as $part ) { - $part = trim( $part ); - if(( '"' == substr( $part, 0, 1 )) && - ( '"' == substr( $part, -1 ))) - $part = substr( $part, 1, ( strlen( $part ) - 2 )); - if( 'mailto:' != strtolower( substr( $part, 0, 7 ))) - $part = "MAILTO:$part"; - else - $part = 'MAILTO:'.substr( $part, 7 ); - $optarrays[$optparamlabel][] = $part; - } - break; - default: - if(( '"' == substr( $optparamvalue, 0, 1 )) && - ( '"' == substr( $optparamvalue, -1 ))) - $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 )); - if( 'SENT-BY' == $optparamlabel ) { - if( 'mailto:' != strtolower( substr( $optparamvalue, 0, 7 ))) - $optparamvalue = "MAILTO:$optparamvalue"; - else - $optparamvalue = 'MAILTO:'.substr( $optparamvalue, 7 ); - } - $params2[$optparamlabel] = $optparamvalue; - break; - } // end switch( $optparamlabel.. . - } // end foreach( $optparam.. . - foreach( $optarrays as $optparamlabel => $optparams ) - $params2[$optparamlabel] = $optparams; - } - // remove defaults - iCalUtilityFunctions::_existRem( $params2, 'CUTYPE', 'INDIVIDUAL' ); - iCalUtilityFunctions::_existRem( $params2, 'PARTSTAT', 'NEEDS-ACTION' ); - iCalUtilityFunctions::_existRem( $params2, 'ROLE', 'REQ-PARTICIPANT' ); - iCalUtilityFunctions::_existRem( $params2, 'RSVP', 'FALSE' ); - // check language setting - if( isset( $params2['CN' ] )) { - $lang = $this->getConfig( 'language' ); - if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) - $params2['LANGUAGE' ] = $lang; - } - iCalUtilityFunctions::_setMval( $this->attendee, $value, $params2, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: CATEGORIES - */ -/** - * creates formatted output for calendar component property categories - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createCategories() { - if( empty( $this->categories )) return FALSE; - $output = null; - foreach( $this->categories as $category ) { - if( empty( $category['value'] )) { - if ( $this->getConfig( 'allowEmpty' )) - $output .= $this->_createElement( 'CATEGORIES' ); - continue; - } - $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' )); - if( is_array( $category['value'] )) { - foreach( $category['value'] as $cix => $categoryPart ) - $category['value'][$cix] = $this->_strrep( $categoryPart ); - $content = implode( ',', $category['value'] ); - } - else - $content = $this->_strrep( $category['value'] ); - $output .= $this->_createElement( 'CATEGORIES', $attributes, $content ); - } - return $output; - } -/** - * set calendar component property categories - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-06 - * @param mixed $value - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setCategories( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - iCalUtilityFunctions::_setMval( $this->categories, $value, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: CLASS - */ -/** - * creates formatted output for calendar component property class - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 0.9.7 - 2006-11-20 - * @return string - */ - function createClass() { - if( empty( $this->class )) return FALSE; - if( empty( $this->class['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE; - $attributes = $this->_createParams( $this->class['params'] ); - return $this->_createElement( 'CLASS', $attributes, $this->class['value'] ); - } -/** - * set calendar component property class - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value "PUBLIC" / "PRIVATE" / "CONFIDENTIAL" / iana-token / x-name - * @param array $params optional - * @return bool - */ - function setClass( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->class = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: COMMENT - */ -/** - * creates formatted output for calendar component property comment - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createComment() { - if( empty( $this->comment )) return FALSE; - $output = null; - foreach( $this->comment as $commentPart ) { - if( empty( $commentPart['value'] )) { - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' ); - continue; - } - $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' )); - $content = $this->_strrep( $commentPart['value'] ); - $output .= $this->_createElement( 'COMMENT', $attributes, $content ); - } - return $output; - } -/** - * set calendar component property comment - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-06 - * @param string $value - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setComment( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - iCalUtilityFunctions::_setMval( $this->comment, $value, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: COMPLETED - */ -/** - * creates formatted output for calendar component property completed - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createCompleted( ) { - if( empty( $this->completed )) return FALSE; - if( !isset( $this->completed['value']['year'] ) && - !isset( $this->completed['value']['month'] ) && - !isset( $this->completed['value']['day'] ) && - !isset( $this->completed['value']['hour'] ) && - !isset( $this->completed['value']['min'] ) && - !isset( $this->completed['value']['sec'] )) - if( $this->getConfig( 'allowEmpty' )) - return $this->_createElement( 'COMPLETED' ); - else return FALSE; - $formatted = iCalUtilityFunctions::_format_date_time( $this->completed['value'], 7 ); - $attributes = $this->_createParams( $this->completed['params'] ); - return $this->_createElement( 'COMPLETED', $attributes, $formatted ); - } -/** - * set calendar component property completed - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-23 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param array $params optional - * @return bool - */ - function setCompleted( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { - if( empty( $year )) { - if( $this->getConfig( 'allowEmpty' )) { - $this->completed = array( 'value' => null, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } - else - return FALSE; - } - $this->completed = iCalUtilityFunctions::_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: CONTACT - */ -/** - * creates formatted output for calendar component property contact - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-23 - * @return string - */ - function createContact() { - if( empty( $this->contact )) return FALSE; - $output = null; - foreach( $this->contact as $contact ) { - if( !empty( $contact['value'] )) { - $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' )); - $content = $this->_strrep( $contact['value'] ); - $output .= $this->_createElement( 'CONTACT', $attributes, $content ); - } - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' ); - } - return $output; - } -/** - * set calendar component property contact - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-05 - * @param string $value - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setContact( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - iCalUtilityFunctions::_setMval( $this->contact, $value, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: CREATED - */ -/** - * creates formatted output for calendar component property created - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createCreated() { - if( empty( $this->created )) return FALSE; - $formatted = iCalUtilityFunctions::_format_date_time( $this->created['value'], 7 ); - $attributes = $this->_createParams( $this->created['params'] ); - return $this->_createElement( 'CREATED', $attributes, $formatted ); - } -/** - * set calendar component property created - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-23 - * @param mixed $year optional - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param mixed $params optional - * @return bool - */ - function setCreated( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { - if( !isset( $year )) { - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); - } - $this->created = iCalUtilityFunctions::_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: DESCRIPTION - */ -/** - * creates formatted output for calendar component property description - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createDescription() { - if( empty( $this->description )) return FALSE; - $output = null; - foreach( $this->description as $description ) { - if( !empty( $description['value'] )) { - $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' )); - $content = $this->_strrep( $description['value'] ); - $output .= $this->_createElement( 'DESCRIPTION', $attributes, $content ); - } - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' ); - } - return $output; - } -/** - * set calendar component property description - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.24 - 2010-11-06 - * @param string $value - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setDescription( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; } - if( 'vjournal' != $this->objName ) - $index = 1; - iCalUtilityFunctions::_setMval( $this->description, $value, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: DTEND - */ -/** - * creates formatted output for calendar component property dtend - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-14 - * @return string - */ - function createDtend() { - if( empty( $this->dtend )) return FALSE; - if( !isset( $this->dtend['value']['year'] ) && - !isset( $this->dtend['value']['month'] ) && - !isset( $this->dtend['value']['day'] ) && - !isset( $this->dtend['value']['hour'] ) && - !isset( $this->dtend['value']['min'] ) && - !isset( $this->dtend['value']['sec'] )) - if( $this->getConfig( 'allowEmpty' )) - return $this->_createElement( 'DTEND' ); - else return FALSE; - $formatted = iCalUtilityFunctions::_format_date_time( $this->dtend['value'] ); - if(( FALSE !== ( $tzid = $this->getConfig( 'TZID' ))) && - ( !isset( $this->dtend['params']['VALUE'] ) || ( $this->dtend['params']['VALUE'] != 'DATE' )) && - !isset( $this->dtend['params']['TZID'] )) - $this->dtend['params']['TZID'] = $tzid; - $attributes = $this->_createParams( $this->dtend['params'] ); - return $this->_createElement( 'DTEND', $attributes, $formatted ); - } -/** - * set calendar component property dtend - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-14 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param string $tz optional - * @param array $params optional - * @return bool - */ - function setDtend( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { - if( empty( $year )) { - if( $this->getConfig( 'allowEmpty' )) { - $this->dtend = array( 'value' => null, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } - else - return FALSE; - } - $this->dtend = iCalUtilityFunctions::_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, null, null, $this->getConfig( 'TZID' )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: DTSTAMP - */ -/** - * creates formatted output for calendar component property dtstamp - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.4 - 2008-03-07 - * @return string - */ - function createDtstamp() { - if( !isset( $this->dtstamp['value']['year'] ) && - !isset( $this->dtstamp['value']['month'] ) && - !isset( $this->dtstamp['value']['day'] ) && - !isset( $this->dtstamp['value']['hour'] ) && - !isset( $this->dtstamp['value']['min'] ) && - !isset( $this->dtstamp['value']['sec'] )) - $this->_makeDtstamp(); - $formatted = iCalUtilityFunctions::_format_date_time( $this->dtstamp['value'], 7 ); - $attributes = $this->_createParams( $this->dtstamp['params'] ); - return $this->_createElement( 'DTSTAMP', $attributes, $formatted ); - } -/** - * computes datestamp for calendar component object instance dtstamp - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.9 - 2011-08-10 - * @return void - */ - function _makeDtstamp() { - $d = mktime( date('H'), date('i'), (date('s') - date( 'Z' )), date('m'), date('d'), date('Y')); - $this->dtstamp['value'] = array( 'year' => date( 'Y', $d ) - , 'month' => date( 'm', $d ) - , 'day' => date( 'd', $d ) - , 'hour' => date( 'H', $d ) - , 'min' => date( 'i', $d ) - , 'sec' => date( 's', $d )); - $this->dtstamp['params'] = null; - } -/** - * set calendar component property dtstamp - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-23 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param array $params optional - * @return TRUE - */ - function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { - if( empty( $year )) - $this->_makeDtstamp(); - else - $this->dtstamp = iCalUtilityFunctions::_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: DTSTART - */ -/** - * creates formatted output for calendar component property dtstart - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-15 - * @return string - */ - function createDtstart() { - if( empty( $this->dtstart )) return FALSE; - if( !isset( $this->dtstart['value']['year'] ) && - !isset( $this->dtstart['value']['month'] ) && - !isset( $this->dtstart['value']['day'] ) && - !isset( $this->dtstart['value']['hour'] ) && - !isset( $this->dtstart['value']['min'] ) && - !isset( $this->dtstart['value']['sec'] )) { - if( $this->getConfig( 'allowEmpty' )) - return $this->_createElement( 'DTSTART' ); - else return FALSE; - } - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) - unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] ); - elseif(( FALSE !== ( $tzid = $this->getConfig( 'TZID' ))) && - ( !isset( $this->dtstart['params']['VALUE'] ) || ( $this->dtstart['params']['VALUE'] != 'DATE' )) && - !isset( $this->dtstart['params']['TZID'] )) - $this->dtstart['params']['TZID'] = $tzid; - $formatted = iCalUtilityFunctions::_format_date_time( $this->dtstart['value'] ); - $attributes = $this->_createParams( $this->dtstart['params'] ); - return $this->_createElement( 'DTSTART', $attributes, $formatted ); - } -/** - * set calendar component property dtstart - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.22 - 2010-09-22 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param string $tz optional - * @param array $params optional - * @return bool - */ - function setDtstart( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { - if( empty( $year )) { - if( $this->getConfig( 'allowEmpty' )) { - $this->dtstart = array( 'value' => null, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } - else - return FALSE; - } - $this->dtstart = iCalUtilityFunctions::_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart', $this->objName, $this->getConfig( 'TZID' )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: DUE - */ -/** - * creates formatted output for calendar component property due - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createDue() { - if( empty( $this->due )) return FALSE; - if( !isset( $this->due['value']['year'] ) && - !isset( $this->due['value']['month'] ) && - !isset( $this->due['value']['day'] ) && - !isset( $this->due['value']['hour'] ) && - !isset( $this->due['value']['min'] ) && - !isset( $this->due['value']['sec'] )) { - if( $this->getConfig( 'allowEmpty' )) - return $this->_createElement( 'DUE' ); - else - return FALSE; - } - $formatted = iCalUtilityFunctions::_format_date_time( $this->due['value'] ); - if(( FALSE !== ( $tzid = $this->getConfig( 'TZID' ))) && - ( !isset( $this->due['params']['VALUE'] ) || ( $this->due['params']['VALUE'] != 'DATE' )) && - !isset( $this->due['params']['TZID'] )) - $this->due['params']['TZID'] = $tzid; - $attributes = $this->_createParams( $this->due['params'] ); - return $this->_createElement( 'DUE', $attributes, $formatted ); - } -/** - * set calendar component property due - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param array $params optional - * @return bool - */ - function setDue( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { - if( empty( $year )) { - if( $this->getConfig( 'allowEmpty' )) { - $this->due = array( 'value' => null, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } - else - return FALSE; - } - $this->due = iCalUtilityFunctions::_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, null, null, $this->getConfig( 'TZID' )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: DURATION - */ -/** - * creates formatted output for calendar component property duration - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createDuration() { - if( empty( $this->duration )) return FALSE; - if( !isset( $this->duration['value']['week'] ) && - !isset( $this->duration['value']['day'] ) && - !isset( $this->duration['value']['hour'] ) && - !isset( $this->duration['value']['min'] ) && - !isset( $this->duration['value']['sec'] )) - if( $this->getConfig( 'allowEmpty' )) - return $this->_createElement( 'DURATION', array(), null ); - else return FALSE; - $attributes = $this->_createParams( $this->duration['params'] ); - return $this->_createElement( 'DURATION', $attributes, iCalUtilityFunctions::_format_duration( $this->duration['value'] )); - } -/** - * set calendar component property duration - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param mixed $week - * @param mixed $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param array $params optional - * @return bool - */ - function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { - if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE; - if( is_array( $week ) && ( 1 <= count( $week ))) - $this->duration = array( 'value' => iCalUtilityFunctions::_duration_array( $week ), 'params' => iCalUtilityFunctions::_setParams( $day )); - elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) { - $week = trim( $week ); - if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) - $week = substr( $week, 1 ); - $this->duration = array( 'value' => iCalUtilityFunctions::_duration_string( $week ), 'params' => iCalUtilityFunctions::_setParams( $day )); - } - elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) - return FALSE; - else - $this->duration = array( 'value' => iCalUtilityFunctions::_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: EXDATE - */ -/** - * creates formatted output for calendar component property exdate - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createExdate() { - if( empty( $this->exdate )) return FALSE; - $output = null; - foreach( $this->exdate as $ex => $theExdate ) { - if( empty( $theExdate['value'] )) { - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' ); - continue; - } - $content = $attributes = null; - foreach( $theExdate['value'] as $eix => $exdatePart ) { - $parno = count( $exdatePart ); - $formatted = iCalUtilityFunctions::_format_date_time( $exdatePart, $parno ); - if( isset( $theExdate['params']['TZID'] )) - $formatted = str_replace( 'Z', '', $formatted); - if( 0 < $eix ) { - if( isset( $theExdate['value'][0]['tz'] )) { - if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) || - ( 'Z' == $theExdate['value'][0]['tz'] )) { - if( 'Z' != substr( $formatted, -1 )) - $formatted .= 'Z'; - } - else - $formatted = str_replace( 'Z', '', $formatted ); - } - else - $formatted = str_replace( 'Z', '', $formatted ); - } - $content .= ( 0 < $eix ) ? ','.$formatted : $formatted; - } - $attributes .= $this->_createParams( $theExdate['params'] ); - $output .= $this->_createElement( 'EXDATE', $attributes, $content ); - } - return $output; - } -/** - * set calendar component property exdate - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.8 - 2012-01-19 - * @param array exdates - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setExdate( $exdates, $params=FALSE, $index=FALSE ) { - if( empty( $exdates )) { - if( $this->getConfig( 'allowEmpty' )) { - iCalUtilityFunctions::_setMval( $this->exdate, null, $params, FALSE, $index ); - return TRUE; - } - else - return FALSE; - } - $input = array( 'params' => iCalUtilityFunctions::_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); - $toZ = ( isset( $input['params']['TZID'] ) && in_array( strtoupper( $input['params']['TZID'] ), array( 'GMT', 'UTC', 'Z' ))) ? TRUE : FALSE; - /* ev. check 1:st date and save ev. timezone **/ - iCalUtilityFunctions::_chkdatecfg( reset( $exdates ), $parno, $input['params'] ); - iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter - foreach( $exdates as $eix => $theExdate ) { - iCalUtilityFunctions::_strDate2arr( $theExdate ); - if( iCalUtilityFunctions::_isArrayTimestampDate( $theExdate )) - $exdatea = iCalUtilityFunctions::_timestamp2date( $theExdate, $parno ); - elseif( is_array( $theExdate )) - $exdatea = iCalUtilityFunctions::_date_time_array( $theExdate, $parno ); - elseif( 8 <= strlen( trim( $theExdate ))) { // ex. 2006-08-03 10:12:18 - $exdatea = iCalUtilityFunctions::_date_time_string( $theExdate, $parno ); - unset( $exdatea['unparsedtext'] ); - } - if( 3 == $parno ) - unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] ); - elseif( isset( $exdatea['tz'] )) - $exdatea['tz'] = (string) $exdatea['tz']; - if( isset( $input['params']['TZID'] ) || - ( isset( $exdatea['tz'] ) && !iCalUtilityFunctions::_isOffset( $exdatea['tz'] )) || - ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || - ( isset( $input['value'][0]['tz'] ) && !iCalUtilityFunctions::_isOffset( $input['value'][0]['tz'] ))) - unset( $exdatea['tz'] ); - if( $toZ ) // time zone Z - $exdatea['tz'] = 'Z'; - $input['value'][] = $exdatea; - } - if( 0 >= count( $input['value'] )) - return FALSE; - if( 3 == $parno ) { - $input['params']['VALUE'] = 'DATE'; - unset( $input['params']['TZID'] ); - } - if( $toZ ) // time zone Z - unset( $input['params']['TZID'] ); - iCalUtilityFunctions::_setMval( $this->exdate, $input['value'], $input['params'], FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: EXRULE - */ -/** - * creates formatted output for calendar component property exrule - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createExrule() { - if( empty( $this->exrule )) return FALSE; - return $this->_format_recur( 'EXRULE', $this->exrule ); - } -/** - * set calendar component property exdate - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-05 - * @param array $exruleset - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setExrule( $exruleset, $params=FALSE, $index=FALSE ) { - if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE; - iCalUtilityFunctions::_setMval( $this->exrule, iCalUtilityFunctions::_setRexrule( $exruleset ), $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: FREEBUSY - */ -/** - * creates formatted output for calendar component property freebusy - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.1.23 - 2012-02-16 - * @return string - */ - function createFreebusy() { - if( empty( $this->freebusy )) return FALSE; - $output = null; - foreach( $this->freebusy as $freebusyPart ) { - if( empty( $freebusyPart['value'] ) || (( 1 == count( $freebusyPart['value'] )) && isset( $freebusyPart['value']['fbtype'] ))) { - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' ); - continue; - } - $attributes = $content = null; - if( isset( $freebusyPart['value']['fbtype'] )) { - $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype']; - unset( $freebusyPart['value']['fbtype'] ); - $freebusyPart['value'] = array_values( $freebusyPart['value'] ); - } - else - $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY'; - $attributes .= $this->_createParams( $freebusyPart['params'] ); - $fno = 1; - $cnt = count( $freebusyPart['value']); - foreach( $freebusyPart['value'] as $periodix => $freebusyPeriod ) { - $formatted = iCalUtilityFunctions::_format_date_time( $freebusyPeriod[0] ); - $content .= $formatted; - $content .= '/'; - $cnt2 = count( $freebusyPeriod[1]); - if( array_key_exists( 'year', $freebusyPeriod[1] )) // date-time - $cnt2 = 7; - elseif( array_key_exists( 'week', $freebusyPeriod[1] )) // duration - $cnt2 = 5; - if(( 7 == $cnt2 ) && // period= -> date-time - isset( $freebusyPeriod[1]['year'] ) && - isset( $freebusyPeriod[1]['month'] ) && - isset( $freebusyPeriod[1]['day'] )) { - $content .= iCalUtilityFunctions::_format_date_time( $freebusyPeriod[1] ); - } - else { // period= -> dur-time - $content .= iCalUtilityFunctions::_format_duration( $freebusyPeriod[1] ); - } - if( $fno < $cnt ) - $content .= ','; - $fno++; - } - $output .= $this->_createElement( 'FREEBUSY', $attributes, $content ); - } - return $output; - } -/** - * set calendar component property freebusy - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.30 - 2012-01-16 - * @param string $fbType - * @param array $fbValues - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setFreebusy( $fbType, $fbValues, $params=FALSE, $index=FALSE ) { - if( empty( $fbValues )) { - if( $this->getConfig( 'allowEmpty' )) { - iCalUtilityFunctions::_setMval( $this->freebusy, null, $params, FALSE, $index ); - return TRUE; - } - else - return FALSE; - } - $fbType = strtoupper( $fbType ); - if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) && - ( 'X-' != substr( $fbType, 0, 2 ))) - $fbType = 'BUSY'; - $input = array( 'fbtype' => $fbType ); - foreach( $fbValues as $fbPeriod ) { // periods => period - if( empty( $fbPeriod )) - continue; - $freebusyPeriod = array(); - foreach( $fbPeriod as $fbMember ) { // pairs => singlepart - $freebusyPairMember = array(); - if( is_array( $fbMember )) { - if( iCalUtilityFunctions::_isArrayDate( $fbMember )) { // date-time value - $freebusyPairMember = iCalUtilityFunctions::_date_time_array( $fbMember, 7 ); - $freebusyPairMember['tz'] = 'Z'; - } - elseif( iCalUtilityFunctions::_isArrayTimestampDate( $fbMember )) { // timestamp value - $freebusyPairMember = iCalUtilityFunctions::_timestamp2date( $fbMember['timestamp'], 7 ); - $freebusyPairMember['tz'] = 'Z'; - } - else { // array format duration - $freebusyPairMember = iCalUtilityFunctions::_duration_array( $fbMember ); - } - } - elseif(( 3 <= strlen( trim( $fbMember ))) && // string format duration - ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) { - if( 'P' != $fbMember{0} ) - $fbmember = substr( $fbMember, 1 ); - $freebusyPairMember = iCalUtilityFunctions::_duration_string( $fbMember ); - } - elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18 - $freebusyPairMember = iCalUtilityFunctions::_date_time_string( $fbMember, 7 ); - unset( $freebusyPairMember['unparsedtext'] ); - $freebusyPairMember['tz'] = 'Z'; - } - $freebusyPeriod[] = $freebusyPairMember; - } - $input[] = $freebusyPeriod; - } - iCalUtilityFunctions::_setMval( $this->freebusy, $input, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: GEO - */ -/** - * creates formatted output for calendar component property geo - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createGeo() { - if( empty( $this->geo )) return FALSE; - if( empty( $this->geo['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE; - $attributes = $this->_createParams( $this->geo['params'] ); - $content = null; - $content .= number_format( (float) $this->geo['value']['latitude'], 6, '.', ''); - $content .= ';'; - $content .= number_format( (float) $this->geo['value']['longitude'], 6, '.', ''); - return $this->_createElement( 'GEO', $attributes, $content ); - } -/** - * set calendar component property geo - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param float $latitude - * @param float $longitude - * @param array $params optional - * @return bool - */ - function setGeo( $latitude, $longitude, $params=FALSE ) { - if( !empty( $latitude ) && !empty( $longitude )) { - if( !is_array( $this->geo )) $this->geo = array(); - $this->geo['value']['latitude'] = $latitude; - $this->geo['value']['longitude'] = $longitude; - $this->geo['params'] = iCalUtilityFunctions::_setParams( $params ); - } - elseif( $this->getConfig( 'allowEmpty' )) - $this->geo = array( 'value' => null, 'params' => iCalUtilityFunctions::_setParams( $params ) ); - else - return FALSE; - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: LAST-MODIFIED - */ -/** - * creates formatted output for calendar component property last-modified - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createLastModified() { - if( empty( $this->lastmodified )) return FALSE; - $attributes = $this->_createParams( $this->lastmodified['params'] ); - $formatted = iCalUtilityFunctions::_format_date_time( $this->lastmodified['value'], 7 ); - return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted ); - } -/** - * set calendar component property completed - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-23 - * @param mixed $year optional - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param array $params optional - * @return boll - */ - function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { - if( empty( $year )) - $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' ))); - $this->lastmodified = iCalUtilityFunctions::_setDate2( $year, $month, $day, $hour, $min, $sec, $params ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: LOCATION - */ -/** - * creates formatted output for calendar component property location - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @return string - */ - function createLocation() { - if( empty( $this->location )) return FALSE; - if( empty( $this->location['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE; - $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' )); - $content = $this->_strrep( $this->location['value'] ); - return $this->_createElement( 'LOCATION', $attributes, $content ); - } -/** - * set calendar component property location - ' - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param array params optional - * @return bool - */ - function setLocation( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->location = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: ORGANIZER - */ -/** - * creates formatted output for calendar component property organizer - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.33 - 2010-12-17 - * @return string - */ - function createOrganizer() { - if( empty( $this->organizer )) return FALSE; - if( empty( $this->organizer['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE; - $attributes = $this->_createParams( $this->organizer['params'] - , array( 'CN', 'DIR', 'SENT-BY', 'LANGUAGE' )); - return $this->_createElement( 'ORGANIZER', $attributes, $this->organizer['value'] ); - } -/** - * set calendar component property organizer - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.27 - 2010-11-29 - * @param string $value - * @param array params optional - * @return bool - */ - function setOrganizer( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - if( FALSE === ( $pos = strpos( substr( $value, 0, 9 ), ':' ))) - $value = 'MAILTO:'.$value; - else - $value = strtolower( substr( $value, 0, $pos )).substr( $value, $pos ); - $value = str_replace( 'mailto:', 'MAILTO:', $value ); - $this->organizer = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - if( isset( $this->organizer['params']['SENT-BY'] )){ - if( 'mailto:' !== strtolower( substr( $this->organizer['params']['SENT-BY'], 0, 7 ))) - $this->organizer['params']['SENT-BY'] = 'MAILTO:'.$this->organizer['params']['SENT-BY']; - else - $this->organizer['params']['SENT-BY'] = 'MAILTO:'.substr( $this->organizer['params']['SENT-BY'], 7 ); - } - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: PERCENT-COMPLETE - */ -/** - * creates formatted output for calendar component property percent-complete - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.3 - 2011-05-14 - * @return string - */ - function createPercentComplete() { - if( !isset($this->percentcomplete) || ( empty( $this->percentcomplete ) && !is_numeric( $this->percentcomplete ))) return FALSE; - if( !isset( $this->percentcomplete['value'] ) || ( empty( $this->percentcomplete['value'] ) && !is_numeric( $this->percentcomplete['value'] ))) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE; - $attributes = $this->_createParams( $this->percentcomplete['params'] ); - return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] ); - } -/** - * set calendar component property percent-complete - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.3 - 2011-05-14 - * @param int $value - * @param array $params optional - * @return bool - */ - function setPercentComplete( $value, $params=FALSE ) { - if( empty( $value ) && !is_numeric( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->percentcomplete = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: PRIORITY - */ -/** - * creates formatted output for calendar component property priority - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.3 - 2011-05-14 - * @return string - */ - function createPriority() { - if( !isset($this->priority) || ( empty( $this->priority ) && !is_numeric( $this->priority ))) return FALSE; - if( !isset( $this->priority['value'] ) || ( empty( $this->priority['value'] ) && !is_numeric( $this->priority['value'] ))) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE; - $attributes = $this->_createParams( $this->priority['params'] ); - return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] ); - } -/** - * set calendar component property priority - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.3 - 2011-05-14 - * @param int $value - * @param array $params optional - * @return bool - */ - function setPriority( $value, $params=FALSE ) { - if( empty( $value ) && !is_numeric( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->priority = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: RDATE - */ -/** - * creates formatted output for calendar component property rdate - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.16 - 2008-10-26 - * @return string - */ - function createRdate() { - if( empty( $this->rdate )) return FALSE; - $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; - $output = null; - if( $utctime ) - unset( $this->rdate['params']['TZID'] ); - foreach( $this->rdate as $theRdate ) { - if( empty( $theRdate['value'] )) { - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' ); - continue; - } - if( $utctime ) - unset( $theRdate['params']['TZID'] ); - $attributes = $this->_createParams( $theRdate['params'] ); - $cnt = count( $theRdate['value'] ); - $content = null; - $rno = 1; - foreach( $theRdate['value'] as $rpix => $rdatePart ) { - $contentPart = null; - if( is_array( $rdatePart ) && - isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD - if( $utctime ) - unset( $rdatePart[0]['tz'] ); - $formatted = iCalUtilityFunctions::_format_date_time( $rdatePart[0]); // PERIOD part 1 - if( $utctime || !empty( $theRdate['params']['TZID'] )) - $formatted = str_replace( 'Z', '', $formatted); - if( 0 < $rpix ) { - if( !empty( $rdatePart[0]['tz'] ) && iCalUtilityFunctions::_isOffset( $rdatePart[0]['tz'] )) { - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; - } - else - $formatted = str_replace( 'Z', '', $formatted ); - } - $contentPart .= $formatted; - $contentPart .= '/'; - $cnt2 = count( $rdatePart[1]); - if( array_key_exists( 'year', $rdatePart[1] )) { - if( array_key_exists( 'hour', $rdatePart[1] )) - $cnt2 = 7; // date-time - else - $cnt2 = 3; // date - } - elseif( array_key_exists( 'week', $rdatePart[1] )) // duration - $cnt2 = 5; - if(( 7 == $cnt2 ) && // period= -> date-time - isset( $rdatePart[1]['year'] ) && - isset( $rdatePart[1]['month'] ) && - isset( $rdatePart[1]['day'] )) { - if( $utctime ) - unset( $rdatePart[1]['tz'] ); - $formatted = iCalUtilityFunctions::_format_date_time( $rdatePart[1] ); // PERIOD part 2 - if( $utctime || !empty( $theRdate['params']['TZID'] )) - $formatted = str_replace( 'Z', '', $formatted); - if( !empty( $rdatePart[0]['tz'] ) && iCalUtilityFunctions::_isOffset( $rdatePart[0]['tz'] )) { - if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z'; - } - else - $formatted = str_replace( 'Z', '', $formatted ); - $contentPart .= $formatted; - } - else { // period= -> dur-time - $contentPart .= iCalUtilityFunctions::_format_duration( $rdatePart[1] ); - } - } // PERIOD end - else { // SINGLE date start - if( $utctime ) - unset( $rdatePart['tz'] ); - $formatted = iCalUtilityFunctions::_format_date_time( $rdatePart); - if( $utctime || !empty( $theRdate['params']['TZID'] )) - $formatted = str_replace( 'Z', '', $formatted); - if( !$utctime && ( 0 < $rpix )) { - if( !empty( $theRdate['value'][0]['tz'] ) && iCalUtilityFunctions::_isOffset( $theRdate['value'][0]['tz'] )) { - if( 'Z' != substr( $formatted, -1 )) - $formatted .= 'Z'; - } - else - $formatted = str_replace( 'Z', '', $formatted ); - } - $contentPart .= $formatted; - } - $content .= $contentPart; - if( $rno < $cnt ) - $content .= ','; - $rno++; - } - $output .= $this->_createElement( 'RDATE', $attributes, $content ); - } - return $output; - } -/** - * set calendar component property rdate - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.8 - 2012-01-31 - * @param array $rdates - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setRdate( $rdates, $params=FALSE, $index=FALSE ) { - if( empty( $rdates )) { - if( $this->getConfig( 'allowEmpty' )) { - iCalUtilityFunctions::_setMval( $this->rdate, null, $params, FALSE, $index ); - return TRUE; - } - else - return FALSE; - } - $input = array( 'params' => iCalUtilityFunctions::_setParams( $params, array( 'VALUE' => 'DATE-TIME' ))); - if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) { - unset( $input['params']['TZID'] ); - $input['params']['VALUE'] = 'DATE-TIME'; - } - $zArr = array( 'GMT', 'UTC', 'Z' ); - $toZ = ( isset( $params['TZID'] ) && in_array( strtoupper( $params['TZID'] ), $zArr )) ? TRUE : FALSE; - /* check if PERIOD, if not set */ - if((!isset( $input['params']['VALUE'] ) || !in_array( $input['params']['VALUE'], array( 'DATE', 'PERIOD' ))) && - isset( $rdates[0] ) && is_array( $rdates[0] ) && ( 2 == count( $rdates[0] )) && - isset( $rdates[0][0] ) && isset( $rdates[0][1] ) && !isset( $rdates[0]['timestamp'] ) && - (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) || - iCalUtilityFunctions::_isArrayDate( $rdates[0][0] ))) || - ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] ))))) && - ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) - $input['params']['VALUE'] = 'PERIOD'; - /* check 1:st date, upd. $parno (opt) and save ev. timezone **/ - $date = reset( $rdates ); - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD - $date = reset( $date ); - iCalUtilityFunctions::_chkdatecfg( $date, $parno, $input['params'] ); - iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default - foreach( $rdates as $rpix => $theRdate ) { - $inputa = null; - iCalUtilityFunctions::_strDate2arr( $theRdate ); - if( is_array( $theRdate )) { - if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD - foreach( $theRdate as $rix => $rPeriod ) { - iCalUtilityFunctions::_strDate2arr( $theRdate ); - if( is_array( $rPeriod )) { - if( iCalUtilityFunctions::_isArrayTimestampDate( $rPeriod )) // timestamp - $inputab = ( isset( $rPeriod['tz'] )) ? iCalUtilityFunctions::_timestamp2date( $rPeriod, $parno ) : iCalUtilityFunctions::_timestamp2date( $rPeriod, 6 ); - elseif( iCalUtilityFunctions::_isArrayDate( $rPeriod )) - $inputab = ( 3 < count ( $rPeriod )) ? iCalUtilityFunctions::_date_time_array( $rPeriod, $parno ) : iCalUtilityFunctions::_date_time_array( $rPeriod, 6 ); - elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) { // text-date - $inputab = iCalUtilityFunctions::_date_time_string( reset( $rPeriod ), $parno ); - unset( $inputab['unparsedtext'] ); - } - else // array format duration - $inputab = iCalUtilityFunctions::_duration_array( $rPeriod ); - } - elseif(( 3 <= strlen( trim( $rPeriod ))) && // string format duration - ( in_array( $rPeriod[0], array( 'P', '+', '-' )))) { - if( 'P' != $rPeriod[0] ) - $rPeriod = substr( $rPeriod, 1 ); - $inputab = iCalUtilityFunctions::_duration_string( $rPeriod ); - } - elseif( 8 <= strlen( trim( $rPeriod ))) { // text date ex. 2006-08-03 10:12:18 - $inputab = iCalUtilityFunctions::_date_time_string( $rPeriod, $parno ); - unset( $inputab['unparsedtext'] ); - } - if( isset( $input['params']['TZID'] ) || - ( isset( $inputab['tz'] ) && !iCalUtilityFunctions::_isOffset( $inputab['tz'] )) || - ( isset( $inputa[0] ) && ( !isset( $inputa[0]['tz'] ))) || - ( isset( $inputa[0]['tz'] ) && !iCalUtilityFunctions::_isOffset( $inputa[0]['tz'] ))) - unset( $inputab['tz'] ); - if( $toZ ) - $inputab['tz'] = 'Z'; - $inputa[] = $inputab; - } - } // PERIOD end - elseif ( iCalUtilityFunctions::_isArrayTimestampDate( $theRdate )) { // timestamp - $inputa = iCalUtilityFunctions::_timestamp2date( $theRdate, $parno ); - if( $toZ ) - $inputa['tz'] = 'Z'; - } - else { // date[-time] - $inputa = iCalUtilityFunctions::_date_time_array( $theRdate, $parno ); - $toZ = ( isset( $inputa['tz'] ) && in_array( strtoupper( $inputa['tz'] ), $zArr )) ? TRUE : FALSE; - if( $toZ ) - $inputa['tz'] = 'Z'; - } - } - elseif( 8 <= strlen( trim( $theRdate ))) { // text date ex. 2006-08-03 10:12:18 - $inputa = iCalUtilityFunctions::_date_time_string( $theRdate, $parno ); - unset( $inputa['unparsedtext'] ); - if( $toZ ) - $inputa['tz'] = 'Z'; - } - if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD - if( 3 == $parno ) - unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] ); - elseif( isset( $inputa['tz'] )) - $inputa['tz'] = (string) $inputa['tz']; - if( isset( $input['params']['TZID'] ) || - ( isset( $inputa['tz'] ) && !iCalUtilityFunctions::_isOffset( $inputa['tz'] )) || - ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) || - ( isset( $input['value'][0]['tz'] ) && !iCalUtilityFunctions::_isOffset( $input['value'][0]['tz'] ))) - if( !$toZ ) - unset( $inputa['tz'] ); - } - $input['value'][] = $inputa; - } - if( 3 == $parno ) { - $input['params']['VALUE'] = 'DATE'; - unset( $input['params']['TZID'] ); - } - if( $toZ ) - unset( $input['params']['TZID'] ); - iCalUtilityFunctions::_setMval( $this->rdate, $input['value'], $input['params'], FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: RECURRENCE-ID - */ -/** - * creates formatted output for calendar component property recurrence-id - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-15 - * @return string - */ - function createRecurrenceid() { - if( empty( $this->recurrenceid )) return FALSE; - if( empty( $this->recurrenceid['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE; - $formatted = iCalUtilityFunctions::_format_date_time( $this->recurrenceid['value'] ); - if(( FALSE !== ( $tzid = $this->getConfig( 'TZID' ))) && - ( !isset( $this->recurrenceid['params']['VALUE'] ) || ( $this->recurrenceid['params']['VALUE'] != 'DATE' )) && - !isset( $this->recurrenceid['params']['TZID'] )) - $this->recurrenceid['params']['TZID'] = $tzid; - $attributes = $this->_createParams( $this->recurrenceid['params'] ); - return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted ); - } -/** - * set calendar component property recurrence-id - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-15 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param array $params optional - * @return bool - */ - function setRecurrenceid( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE ) { - if( empty( $year )) { - if( $this->getConfig( 'allowEmpty' )) { - $this->recurrenceid = array( 'value' => null, 'params' => null ); - return TRUE; - } - else - return FALSE; - } - $this->recurrenceid = iCalUtilityFunctions::_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, null, null, $this->getConfig( 'TZID' )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: RELATED-TO - */ -/** - * creates formatted output for calendar component property related-to - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.24 - 2012-02-23 - * @return string - */ - function createRelatedTo() { - if( empty( $this->relatedto )) return FALSE; - $output = null; - foreach( $this->relatedto as $relation ) { - if( !empty( $relation['value'] )) - $output .= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ), $this->_strrep( $relation['value'] ) ); - elseif( $this->getConfig( 'allowEmpty' )) - $output .= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] )); - } - return $output; - } -/** - * set calendar component property related-to - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.24 - 2012-02-23 - * @param float $relid - * @param array $params, optional - * @param index $index, optional - * @return bool - */ - function setRelatedTo( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - iCalUtilityFunctions::_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default - iCalUtilityFunctions::_setMval( $this->relatedto, $value, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: REPEAT - */ -/** - * creates formatted output for calendar component property repeat - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.3 - 2011-05-14 - * @return string - */ - function createRepeat() { - if( !isset( $this->repeat ) || ( empty( $this->repeat ) && !is_numeric( $this->repeat ))) return FALSE; - if( !isset( $this->repeat['value']) || ( empty( $this->repeat['value'] ) && !is_numeric( $this->repeat['value'] ))) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE; - $attributes = $this->_createParams( $this->repeat['params'] ); - return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] ); - } -/** - * set calendar component property repeat - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.3 - 2011-05-14 - * @param string $value - * @param array $params optional - * @return void - */ - function setRepeat( $value, $params=FALSE ) { - if( empty( $value ) && !is_numeric( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->repeat = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: REQUEST-STATUS - */ -/** - * creates formatted output for calendar component property request-status - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-23 - * @return string - */ - function createRequestStatus() { - if( empty( $this->requeststatus )) return FALSE; - $output = null; - foreach( $this->requeststatus as $rstat ) { - if( empty( $rstat['value']['statcode'] )) { - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' ); - continue; - } - $attributes = $this->_createParams( $rstat['params'], array( 'LANGUAGE' )); - $content = number_format( (float) $rstat['value']['statcode'], 2, '.', ''); - $content .= ';'.$this->_strrep( $rstat['value']['text'] ); - if( isset( $rstat['value']['extdata'] )) - $content .= ';'.$this->_strrep( $rstat['value']['extdata'] ); - $output .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content ); - } - return $output; - } -/** - * set calendar component property request-status - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-05 - * @param float $statcode - * @param string $text - * @param string $extdata, optional - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) { - if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE; - $input = array( 'statcode' => $statcode, 'text' => $text ); - if( $extdata ) - $input['extdata'] = $extdata; - iCalUtilityFunctions::_setMval( $this->requeststatus, $input, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: RESOURCES - */ -/** - * creates formatted output for calendar component property resources - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-23 - * @return string - */ - function createResources() { - if( empty( $this->resources )) return FALSE; - $output = null; - foreach( $this->resources as $resource ) { - if( empty( $resource['value'] )) { - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' ); - continue; - } - $attributes = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' )); - if( is_array( $resource['value'] )) { - foreach( $resource['value'] as $rix => $resourcePart ) - $resource['value'][$rix] = $this->_strrep( $resourcePart ); - $content = implode( ',', $resource['value'] ); - } - else - $content = $this->_strrep( $resource['value'] ); - $output .= $this->_createElement( 'RESOURCES', $attributes, $content ); - } - return $output; - } -/** - * set calendar component property recources - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-05 - * @param mixed $value - * @param array $params, optional - * @param integer $index, optional - * @return bool - */ - function setResources( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - iCalUtilityFunctions::_setMval( $this->resources, $value, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: RRULE - */ -/** - * creates formatted output for calendar component property rrule - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createRrule() { - if( empty( $this->rrule )) return FALSE; - return $this->_format_recur( 'RRULE', $this->rrule ); - } -/** - * set calendar component property rrule - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-05 - * @param array $rruleset - * @param array $params, optional - * @param integer $index, optional - * @return void - */ - function setRrule( $rruleset, $params=FALSE, $index=FALSE ) { - if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE; - iCalUtilityFunctions::_setMval( $this->rrule, iCalUtilityFunctions::_setRexrule( $rruleset ), $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: SEQUENCE - */ -/** - * creates formatted output for calendar component property sequence - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.3 - 2011-05-14 - * @return string - */ - function createSequence() { - if( !isset( $this->sequence ) || ( empty( $this->sequence ) && !is_numeric( $this->sequence ))) return FALSE; - if(( !isset($this->sequence['value'] ) || ( empty( $this->sequence['value'] ) && !is_numeric( $this->sequence['value'] ))) && - ( '0' != $this->sequence['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE; - $attributes = $this->_createParams( $this->sequence['params'] ); - return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] ); - } -/** - * set calendar component property sequence - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.8 - 2011-09-19 - * @param int $value optional - * @param array $params optional - * @return bool - */ - function setSequence( $value=FALSE, $params=FALSE ) { - if(( empty( $value ) && !is_numeric( $value )) && ( '0' != $value )) - $value = ( isset( $this->sequence['value'] ) && ( -1 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : '0'; - $this->sequence = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: STATUS - */ -/** - * creates formatted output for calendar component property status - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createStatus() { - if( empty( $this->status )) return FALSE; - if( empty( $this->status['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE; - $attributes = $this->_createParams( $this->status['params'] ); - return $this->_createElement( 'STATUS', $attributes, $this->status['value'] ); - } -/** - * set calendar component property status - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param array $params optional - * @return bool - */ - function setStatus( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->status = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: SUMMARY - */ -/** - * creates formatted output for calendar component property summary - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createSummary() { - if( empty( $this->summary )) return FALSE; - if( empty( $this->summary['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE; - $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' )); - $content = $this->_strrep( $this->summary['value'] ); - return $this->_createElement( 'SUMMARY', $attributes, $content ); - } -/** - * set calendar component property summary - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param string $params optional - * @return bool - */ - function setSummary( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->summary = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: TRANSP - */ -/** - * creates formatted output for calendar component property transp - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createTransp() { - if( empty( $this->transp )) return FALSE; - if( empty( $this->transp['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE; - $attributes = $this->_createParams( $this->transp['params'] ); - return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] ); - } -/** - * set calendar component property transp - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param string $params optional - * @return bool - */ - function setTransp( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->transp = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: TRIGGER - */ -/** - * creates formatted output for calendar component property trigger - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.16 - 2008-10-21 - * @return string - */ - function createTrigger() { - if( empty( $this->trigger )) return FALSE; - if( empty( $this->trigger['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE; - $content = $attributes = null; - if( isset( $this->trigger['value']['year'] ) && - isset( $this->trigger['value']['month'] ) && - isset( $this->trigger['value']['day'] )) - $content .= iCalUtilityFunctions::_format_date_time( $this->trigger['value'] ); - else { - if( TRUE !== $this->trigger['value']['relatedStart'] ) - $attributes .= $this->intAttrDelimiter.'RELATED=END'; - if( $this->trigger['value']['before'] ) - $content .= '-'; - $content .= iCalUtilityFunctions::_format_duration( $this->trigger['value'] ); - } - $attributes .= $this->_createParams( $this->trigger['params'] ); - return $this->_createElement( 'TRIGGER', $attributes, $content ); - } -/** - * set calendar component property trigger - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.30 - 2012-01-16 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $week optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param bool $relatedStart optional - * @param bool $before optional - * @param array $params optional - * @return bool - */ - function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) { - if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) - if( $this->getConfig( 'allowEmpty' )) { - $this->trigger = array( 'value' => null, 'params' => iCalUtilityFunctions::_setParams( $params ) ); - return TRUE; - } - else - return FALSE; - if( iCalUtilityFunctions::_isArrayTimestampDate( $year )) { // timestamp - $params = iCalUtilityFunctions::_setParams( $month ); - $date = iCalUtilityFunctions::_timestamp2date( $year, 7 ); - foreach( $date as $k => $v ) - $$k = $v; - } - elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) { - $params = iCalUtilityFunctions::_setParams( $month ); - if(!(array_key_exists( 'year', $year ) && // exclude date-time - array_key_exists( 'month', $year ) && - array_key_exists( 'day', $year ))) { // when this must be a duration - if( isset( $params['RELATED'] ) && ( 'END' == strtoupper( $params['RELATED'] ))) - $relatedStart = FALSE; - else - $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE; - $before = ( array_key_exists( 'before', $year ) && ( TRUE !== $year['before'] )) ? FALSE : TRUE; - } - $SSYY = ( array_key_exists( 'year', $year )) ? $year['year'] : null; - $month = ( array_key_exists( 'month', $year )) ? $year['month'] : null; - $day = ( array_key_exists( 'day', $year )) ? $year['day'] : null; - $week = ( array_key_exists( 'week', $year )) ? $year['week'] : null; - $hour = ( array_key_exists( 'hour', $year )) ? $year['hour'] : 0; //null; - $min = ( array_key_exists( 'min', $year )) ? $year['min'] : 0; //null; - $sec = ( array_key_exists( 'sec', $year )) ? $year['sec'] : 0; //null; - $year = $SSYY; - } - elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) { // duration or date in a string - $params = iCalUtilityFunctions::_setParams( $month ); - if( in_array( $year[0], array( 'P', '+', '-' ))) { // duration - $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == strtoupper( $params['RELATED'] ))) ? FALSE : TRUE; - $before = ( '-' == $year[0] ) ? TRUE : FALSE; - if( 'P' != $year[0] ) - $year = substr( $year, 1 ); - $date = iCalUtilityFunctions::_duration_string( $year); - } - else // date - $date = iCalUtilityFunctions::_date_time_string( $year, 7 ); - unset( $year, $month, $day, $date['unparsedtext'] ); - if( empty( $date )) - $sec = 0; - else - foreach( $date as $k => $v ) - $$k = $v; - } - else // single values in function input parameters - $params = iCalUtilityFunctions::_setParams( $params ); - if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date - $params['VALUE'] = 'DATE-TIME'; - $hour = ( $hour ) ? $hour : 0; - $min = ( $min ) ? $min : 0; - $sec = ( $sec ) ? $sec : 0; - $this->trigger = array( 'params' => $params ); - $this->trigger['value'] = array( 'year' => $year - , 'month' => $month - , 'day' => $day - , 'hour' => $hour - , 'min' => $min - , 'sec' => $sec - , 'tz' => 'Z' ); - return TRUE; - } - elseif(( empty( $year ) && empty( $month )) && // duration - (( !empty( $week ) || ( 0 == $week )) || - ( !empty( $day ) || ( 0 == $day )) || - ( !empty( $hour ) || ( 0 == $hour )) || - ( !empty( $min ) || ( 0 == $min )) || - ( !empty( $sec ) || ( 0 == $sec )))) { - unset( $params['RELATED'] ); // set at output creation (END only) - unset( $params['VALUE'] ); // 'DURATION' default - $this->trigger = array( 'params' => $params ); - $this->trigger['value'] = array(); - if( !empty( $week )) $this->trigger['value']['week'] = $week; - if( !empty( $day )) $this->trigger['value']['day'] = $day; - if( !empty( $hour )) $this->trigger['value']['hour'] = $hour; - if( !empty( $min )) $this->trigger['value']['min'] = $min; - if( !empty( $sec )) $this->trigger['value']['sec'] = $sec; - if( empty( $this->trigger['value'] )) { - $this->trigger['value']['sec'] = 0; - $before = FALSE; - } - $relatedStart = ( FALSE !== $relatedStart ) ? TRUE : FALSE; - $before = ( FALSE !== $before ) ? TRUE : FALSE; - $this->trigger['value']['relatedStart'] = $relatedStart; - $this->trigger['value']['before'] = $before; - return TRUE; - } - return FALSE; - } -/*********************************************************************************/ -/** - * Property Name: TZID - */ -/** - * creates formatted output for calendar component property tzid - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createTzid() { - if( empty( $this->tzid )) return FALSE; - if( empty( $this->tzid['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE; - $attributes = $this->_createParams( $this->tzid['params'] ); - return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] )); - } -/** - * set calendar component property tzid - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param array $params optional - * @return bool - */ - function setTzid( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->tzid = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * .. . - * Property Name: TZNAME - */ -/** - * creates formatted output for calendar component property tzname - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createTzname() { - if( empty( $this->tzname )) return FALSE; - $output = null; - foreach( $this->tzname as $theName ) { - if( !empty( $theName['value'] )) { - $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' )); - $output .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] )); - } - elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' ); - } - return $output; - } -/** - * set calendar component property tzname - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-05 - * @param string $value - * @param string $params, optional - * @param integer $index, optional - * @return bool - */ - function setTzname( $value, $params=FALSE, $index=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - iCalUtilityFunctions::_setMval( $this->tzname, $value, $params, FALSE, $index ); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: TZOFFSETFROM - */ -/** - * creates formatted output for calendar component property tzoffsetfrom - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createTzoffsetfrom() { - if( empty( $this->tzoffsetfrom )) return FALSE; - if( empty( $this->tzoffsetfrom['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE; - $attributes = $this->_createParams( $this->tzoffsetfrom['params'] ); - return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] ); - } -/** - * set calendar component property tzoffsetfrom - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param string $params optional - * @return bool - */ - function setTzoffsetfrom( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->tzoffsetfrom = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: TZOFFSETTO - */ -/** - * creates formatted output for calendar component property tzoffsetto - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createTzoffsetto() { - if( empty( $this->tzoffsetto )) return FALSE; - if( empty( $this->tzoffsetto['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE; - $attributes = $this->_createParams( $this->tzoffsetto['params'] ); - return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] ); - } -/** - * set calendar component property tzoffsetto - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param string $params optional - * @return bool - */ - function setTzoffsetto( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->tzoffsetto = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: TZURL - */ -/** - * creates formatted output for calendar component property tzurl - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createTzurl() { - if( empty( $this->tzurl )) return FALSE; - if( empty( $this->tzurl['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE; - $attributes = $this->_createParams( $this->tzurl['params'] ); - return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] ); - } -/** - * set calendar component property tzurl - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param string $params optional - * @return boll - */ - function setTzurl( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->tzurl = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: UID - */ -/** - * creates formatted output for calendar component property uid - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 0.9.7 - 2006-11-20 - * @return string - */ - function createUid() { - if( 0 >= count( $this->uid )) - $this->_makeuid(); - $attributes = $this->_createParams( $this->uid['params'] ); - return $this->_createElement( 'UID', $attributes, $this->uid['value'] ); - } -/** - * create an unique id for this calendar component object instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.2.7 - 2007-09-04 - * @return void - */ - function _makeUid() { - $date = date('Ymd\THisT'); - $unique = substr(microtime(), 2, 4); - $base = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVxXuUvVwWzZ1234567890'; - $start = 0; - $end = strlen( $base ) - 1; - $length = 6; - $str = null; - for( $p = 0; $p < $length; $p++ ) - $unique .= $base{mt_rand( $start, $end )}; - $this->uid = array( 'params' => null ); - $this->uid['value'] = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' ); - } -/** - * set calendar component property uid - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param string $params optional - * @return bool - */ - function setUid( $value, $params=FALSE ) { - if( empty( $value )) return FALSE; // no allowEmpty check here !!!! - $this->uid = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: URL - */ -/** - * creates formatted output for calendar component property url - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-21 - * @return string - */ - function createUrl() { - if( empty( $this->url )) return FALSE; - if( empty( $this->url['value'] )) - return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE; - $attributes = $this->_createParams( $this->url['params'] ); - return $this->_createElement( 'URL', $attributes, $this->url['value'] ); - } -/** - * set calendar component property url - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-11-04 - * @param string $value - * @param string $params optional - * @return bool - */ - function setUrl( $value, $params=FALSE ) { - if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $this->url = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params )); - return TRUE; - } -/*********************************************************************************/ -/** - * Property Name: x-prop - */ -/** - * creates formatted output for calendar component property x-prop - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.3 - 2011-05-14 - * @return string - */ - function createXprop() { - if( empty( $this->xprop )) return FALSE; - $output = null; - foreach( $this->xprop as $label => $xpropPart ) { - if( !isset($xpropPart['value']) || ( empty( $xpropPart['value'] ) && !is_numeric( $xpropPart['value'] ))) { - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label ); - continue; - } - $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' )); - if( is_array( $xpropPart['value'] )) { - foreach( $xpropPart['value'] as $pix => $theXpart ) - $xpropPart['value'][$pix] = $this->_strrep( $theXpart ); - $xpropPart['value'] = implode( ',', $xpropPart['value'] ); - } - else - $xpropPart['value'] = $this->_strrep( $xpropPart['value'] ); - $output .= $this->_createElement( $label, $attributes, $xpropPart['value'] ); - } - return $output; - } -/** - * set calendar component property x-prop - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.9 - 2012-01-16 - * @param string $label - * @param mixed $value - * @param array $params optional - * @return bool - */ - function setXprop( $label, $value, $params=FALSE ) { - if( empty( $label )) - return FALSE; - if( 'X-' != strtoupper( substr( $label, 0, 2 ))) - return FALSE; - if( empty( $value ) && !is_numeric( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; - $xprop = array( 'value' => $value ); - $xprop['params'] = iCalUtilityFunctions::_setParams( $params ); - if( !is_array( $this->xprop )) $this->xprop = array(); - $this->xprop[strtoupper( $label )] = $xprop; - return TRUE; - } -/*********************************************************************************/ -/*********************************************************************************/ -/** - * create element format parts - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.0.6 - 2006-06-20 - * @return string - */ - function _createFormat() { - $objectname = null; - switch( $this->format ) { - case 'xcal': - $objectname = ( isset( $this->timezonetype )) ? - strtolower( $this->timezonetype ) : strtolower( $this->objName ); - $this->componentStart1 = $this->elementStart1 = '<'; - $this->componentStart2 = $this->elementStart2 = '>'; - $this->componentEnd1 = $this->elementEnd1 = 'componentEnd2 = $this->elementEnd2 = '>'.$this->nl; - $this->intAttrDelimiter = ''; - $this->attributeDelimiter = $this->nl; - $this->valueInit = null; - break; - default: - $objectname = ( isset( $this->timezonetype )) ? - strtoupper( $this->timezonetype ) : strtoupper( $this->objName ); - $this->componentStart1 = 'BEGIN:'; - $this->componentStart2 = null; - $this->componentEnd1 = 'END:'; - $this->componentEnd2 = $this->nl; - $this->elementStart1 = null; - $this->elementStart2 = null; - $this->elementEnd1 = null; - $this->elementEnd2 = $this->nl; - $this->intAttrDelimiter = ''; - $this->attributeDelimiter = ';'; - $this->valueInit = ':'; - break; - } - return $objectname; - } -/** - * creates formatted output for calendar component property - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.16 - 2011-10-28 - * @param string $label property name - * @param string $attributes property attributes - * @param string $content property content (optional) - * @return string - */ - function _createElement( $label, $attributes=null, $content=FALSE ) { - switch( $this->format ) { - case 'xcal': - $label = strtolower( $label ); - break; - default: - $label = strtoupper( $label ); - break; - } - $output = $this->elementStart1.$label; - $categoriesAttrLang = null; - $attachInlineBinary = FALSE; - $attachfmttype = null; - if (( 'xcal' == $this->format) && ( 'x-' == substr( $label, 0, 2 ))) { - $this->xcaldecl[] = array( 'xmldecl' => 'ELEMENT' - , 'ref' => $label - , 'type2' => '(#PCDATA)' ); - } - if( !empty( $attributes )) { - $attributes = trim( $attributes ); - if ( 'xcal' == $this->format ) { - $attributes2 = explode( $this->intAttrDelimiter, $attributes ); - $attributes = null; - foreach( $attributes2 as $aix => $attribute ) { - $attrKVarr = explode( '=', $attribute ); - if( empty( $attrKVarr[0] )) - continue; - if( !isset( $attrKVarr[1] )) { - $attrValue = $attrKVarr[0]; - $attrKey = $aix; - } - elseif( 2 == count( $attrKVarr)) { - $attrKey = strtolower( $attrKVarr[0] ); - $attrValue = $attrKVarr[1]; - } - else { - $attrKey = strtolower( $attrKVarr[0] ); - unset( $attrKVarr[0] ); - $attrValue = implode( '=', $attrKVarr ); - } - if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) { - $attachInlineBinary = TRUE; - if( 'fmttype' == $attrKey ) - $attachfmttype = $attrKey.'='.$attrValue; - continue; - } - elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) - $categoriesAttrLang = $attrKey.'='.$attrValue; - else { - $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; - $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null; - if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) { - $attrValue = substr( $attrValue, 1, ( strlen( $attrValue ) - 2 )); - $attrValue = str_replace( '"', '', $attrValue ); - } - $attributes .= '"'.htmlspecialchars( $attrValue ).'"'; - } - } - } - else { - $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes ); - } - } - if(( 'xcal' == $this->format) && - ((( 'attach' == $label ) && !$attachInlineBinary ) || ( in_array( $label, array( 'tzurl', 'url' ))))) { - $pos = strrpos($content, "/"); - $docname = ( $pos !== false) ? substr( $content, (1 - strlen( $content ) + $pos )) : $content; - $this->xcaldecl[] = array( 'xmldecl' => 'ENTITY' - , 'uri' => $docname - , 'ref' => 'SYSTEM' - , 'external' => $content - , 'type' => 'NDATA' - , 'type2' => 'BINERY' ); - $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' '; - $attributes .= 'uri="'.$docname.'"'; - $content = null; - if( 'attach' == $label ) { - $attributes = str_replace( $this->attributeDelimiter, $this->intAttrDelimiter, $attributes ); - $content = $this->nl.$this->_createElement( 'extref', $attributes, null ); - $attributes = null; - } - } - elseif(( 'xcal' == $this->format) && ( 'attach' == $label ) && $attachInlineBinary ) { - $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute - } - $output .= $attributes; - if( !$content && ( '0' != $content )) { - switch( $this->format ) { - case 'xcal': - $output .= ' /'; - $output .= $this->elementStart2.$this->nl; - return $output; - break; - default: - $output .= $this->elementStart2.$this->valueInit; - return $this->_size75( $output ); - break; - } - } - $output .= $this->elementStart2; - $output .= $this->valueInit.$content; - switch( $this->format ) { - case 'xcal': - return $output.$this->elementEnd1.$label.$this->elementEnd2; - break; - default: - return $this->_size75( $output ); - break; - } - } -/** - * creates formatted output for calendar component property parameters - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.27 - 2012-01-16 - * @param array $params optional - * @param array $ctrKeys optional - * @return string - */ - function _createParams( $params=array(), $ctrKeys=array() ) { - if( !is_array( $params ) || empty( $params )) - $params = array(); - $attrLANG = $attr1 = $attr2 = $lang = null; - $CNattrKey = ( in_array( 'CN', $ctrKeys )) ? TRUE : FALSE ; - $LANGattrKey = ( in_array( 'LANGUAGE', $ctrKeys )) ? TRUE : FALSE ; - $CNattrExist = $LANGattrExist = FALSE; - $xparams = array(); - foreach( $params as $paramKey => $paramValue ) { - if(( FALSE !== strpos( $paramValue, ':' )) || - ( FALSE !== strpos( $paramValue, ';' )) || - ( FALSE !== strpos( $paramValue, ',' ))) - $paramValue = '"'.$paramValue.'"'; - if( ctype_digit( (string) $paramKey )) { - $xparams[] = $paramValue; - continue; - } - $paramKey = strtoupper( $paramKey ); - if( !in_array( $paramKey, array( 'ALTREP', 'CN', 'DIR', 'ENCODING', 'FMTTYPE', 'LANGUAGE', 'RANGE', 'RELTYPE', 'SENT-BY', 'TZID', 'VALUE' ))) - $xparams[$paramKey] = $paramValue; - else - $params[$paramKey] = $paramValue; - } - ksort( $xparams, SORT_STRING ); - foreach( $xparams as $paramKey => $paramValue ) { - if( ctype_digit( (string) $paramKey )) - $attr2 .= $this->intAttrDelimiter.$paramValue; - else - $attr2 .= $this->intAttrDelimiter."$paramKey=$paramValue"; - } - if( isset( $params['FMTTYPE'] ) && !in_array( 'FMTTYPE', $ctrKeys )) { - $attr1 .= $this->intAttrDelimiter.'FMTTYPE='.$params['FMTTYPE'].$attr2; - $attr2 = null; - } - if( isset( $params['ENCODING'] ) && !in_array( 'ENCODING', $ctrKeys )) { - if( !empty( $attr2 )) { - $attr1 .= $attr2; - $attr2 = null; - } - $attr1 .= $this->intAttrDelimiter.'ENCODING='.$params['ENCODING']; - } - if( isset( $params['VALUE'] ) && !in_array( 'VALUE', $ctrKeys )) - $attr1 .= $this->intAttrDelimiter.'VALUE='.$params['VALUE']; - if( isset( $params['TZID'] ) && !in_array( 'TZID', $ctrKeys )) { - $attr1 .= $this->intAttrDelimiter.'TZID='.$params['TZID']; - } - if( isset( $params['RANGE'] ) && !in_array( 'RANGE', $ctrKeys )) - $attr1 .= $this->intAttrDelimiter.'RANGE='.$params['RANGE']; - if( isset( $params['RELTYPE'] ) && !in_array( 'RELTYPE', $ctrKeys )) - $attr1 .= $this->intAttrDelimiter.'RELTYPE='.$params['RELTYPE']; - if( isset( $params['CN'] ) && $CNattrKey ) { - $attr1 = $this->intAttrDelimiter.'CN='.$params['CN']; - $CNattrExist = TRUE; - } - if( isset( $params['DIR'] ) && in_array( 'DIR', $ctrKeys )) { - $delim = ( FALSE !== strpos( $params['DIR'], '"' )) ? '' : '"'; - $attr1 .= $this->intAttrDelimiter.'DIR='.$delim.$params['DIR'].$delim; - } - if( isset( $params['SENT-BY'] ) && in_array( 'SENT-BY', $ctrKeys )) - $attr1 .= $this->intAttrDelimiter.'SENT-BY='.$params['SENT-BY']; - if( isset( $params['ALTREP'] ) && in_array( 'ALTREP', $ctrKeys )) { - $delim = ( FALSE !== strpos( $params['ALTREP'], '"' )) ? '' : '"'; - $attr1 .= $this->intAttrDelimiter.'ALTREP='.$delim.$params['ALTREP'].$delim; - } - if( isset( $params['LANGUAGE'] ) && $LANGattrKey ) { - $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$params['LANGUAGE']; - $LANGattrExist = TRUE; - } - if( !$LANGattrExist ) { - $lang = $this->getConfig( 'language' ); - if(( $CNattrExist || $LANGattrKey ) && $lang ) - $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang; - } - return $attr1.$attrLANG.$attr2; - } -/** - * creates formatted output for calendar component property data value type recur - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-22 - * @param array $recurlabel - * @param array $recurdata - * @return string - */ - function _format_recur( $recurlabel, $recurdata ) { - $output = null; - foreach( $recurdata as $therule ) { - if( empty( $therule['value'] )) { - if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel ); - continue; - } - $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null; - $content1 = $content2 = null; - foreach( $therule['value'] as $rulelabel => $rulevalue ) { - switch( $rulelabel ) { - case 'FREQ': { - $content1 .= "FREQ=$rulevalue"; - break; - } - case 'UNTIL': { - $content2 .= ";UNTIL="; - $content2 .= iCalUtilityFunctions::_format_date_time( $rulevalue ); - break; - } - case 'COUNT': - case 'INTERVAL': - case 'WKST': { - $content2 .= ";$rulelabel=$rulevalue"; - break; - } - case 'BYSECOND': - case 'BYMINUTE': - case 'BYHOUR': - case 'BYMONTHDAY': - case 'BYYEARDAY': - case 'BYWEEKNO': - case 'BYMONTH': - case 'BYSETPOS': { - $content2 .= ";$rulelabel="; - if( is_array( $rulevalue )) { - foreach( $rulevalue as $vix => $valuePart ) { - $content2 .= ( $vix ) ? ',' : null; - $content2 .= $valuePart; - } - } - else - $content2 .= $rulevalue; - break; - } - case 'BYDAY': { - $content2 .= ";$rulelabel="; - $bydaycnt = 0; - foreach( $rulevalue as $vix => $valuePart ) { - $content21 = $content22 = null; - if( is_array( $valuePart )) { - $content2 .= ( $bydaycnt ) ? ',' : null; - foreach( $valuePart as $vix2 => $valuePart2 ) { - if( 'DAY' != strtoupper( $vix2 )) - $content21 .= $valuePart2; - else - $content22 .= $valuePart2; - } - $content2 .= $content21.$content22; - $bydaycnt++; - } - else { - $content2 .= ( $bydaycnt ) ? ',' : null; - if( 'DAY' != strtoupper( $vix )) - $content21 .= $valuePart; - else { - $content22 .= $valuePart; - $bydaycnt++; - } - $content2 .= $content21.$content22; - } - } - break; - } - default: { - $content2 .= ";$rulelabel=$rulevalue"; - break; - } - } - } - $output .= $this->_createElement( $recurlabel, $attributes, $content1.$content2 ); - } - return $output; - } -/** - * check if property not exists within component - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-15 - * @param string $propName - * @return bool - */ - function _notExistProp( $propName ) { - if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed - $propName = strtolower( $propName ); - if( 'last-modified' == $propName ) { if( !isset( $this->lastmodified )) return TRUE; } - elseif( 'percent-complete' == $propName ) { if( !isset( $this->percentcomplete )) return TRUE; } - elseif( 'recurrence-id' == $propName ) { if( !isset( $this->recurrenceid )) return TRUE; } - elseif( 'related-to' == $propName ) { if( !isset( $this->relatedto )) return TRUE; } - elseif( 'request-status' == $propName ) { if( !isset( $this->requeststatus )) return TRUE; } - elseif(( 'x-' != substr($propName,0,2)) && !isset( $this->$propName )) return TRUE; - return FALSE; - } -/*********************************************************************************/ -/*********************************************************************************/ -/** - * get general component config variables or info about subcomponents - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.6 - 2011-05-14 - * @param mixed $config - * @return value - */ - function getConfig( $config = FALSE) { - if( !$config ) { - $return = array(); - $return['ALLOWEMPTY'] = $this->getConfig( 'ALLOWEMPTY' ); - $return['FORMAT'] = $this->getConfig( 'FORMAT' ); - if( FALSE !== ( $lang = $this->getConfig( 'LANGUAGE' ))) - $return['LANGUAGE'] = $lang; - $return['NEWLINECHAR'] = $this->getConfig( 'NEWLINECHAR' ); - $return['TZTD'] = $this->getConfig( 'TZID' ); - $return['UNIQUE_ID'] = $this->getConfig( 'UNIQUE_ID' ); - return $return; - } - switch( strtoupper( $config )) { - case 'ALLOWEMPTY': - return $this->allowEmpty; - break; - case 'COMPSINFO': - unset( $this->compix ); - $info = array(); - if( isset( $this->components )) { - foreach( $this->components as $cix => $component ) { - if( empty( $component )) continue; - $info[$cix]['ordno'] = $cix + 1; - $info[$cix]['type'] = $component->objName; - $info[$cix]['uid'] = $component->getProperty( 'uid' ); - $info[$cix]['props'] = $component->getConfig( 'propinfo' ); - $info[$cix]['sub'] = $component->getConfig( 'compsinfo' ); - } - } - return $info; - break; - case 'FORMAT': - return $this->format; - break; - case 'LANGUAGE': - // get language for calendar component as defined in [RFC 1766] - return $this->language; - break; - case 'NL': - case 'NEWLINECHAR': - return $this->nl; - break; - case 'PROPINFO': - $output = array(); - if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { - if( empty( $this->uid['value'] )) $this->_makeuid(); - $output['UID'] = 1; - } - if( !empty( $this->dtstamp )) $output['DTSTAMP'] = 1; - if( !empty( $this->summary )) $output['SUMMARY'] = 1; - if( !empty( $this->description )) $output['DESCRIPTION'] = count( $this->description ); - if( !empty( $this->dtstart )) $output['DTSTART'] = 1; - if( !empty( $this->dtend )) $output['DTEND'] = 1; - if( !empty( $this->due )) $output['DUE'] = 1; - if( !empty( $this->duration )) $output['DURATION'] = 1; - if( !empty( $this->rrule )) $output['RRULE'] = count( $this->rrule ); - if( !empty( $this->rdate )) $output['RDATE'] = count( $this->rdate ); - if( !empty( $this->exdate )) $output['EXDATE'] = count( $this->exdate ); - if( !empty( $this->exrule )) $output['EXRULE'] = count( $this->exrule ); - if( !empty( $this->action )) $output['ACTION'] = 1; - if( !empty( $this->attach )) $output['ATTACH'] = count( $this->attach ); - if( !empty( $this->attendee )) $output['ATTENDEE'] = count( $this->attendee ); - if( !empty( $this->categories )) $output['CATEGORIES'] = count( $this->categories ); - if( !empty( $this->class )) $output['CLASS'] = 1; - if( !empty( $this->comment )) $output['COMMENT'] = count( $this->comment ); - if( !empty( $this->completed )) $output['COMPLETED'] = 1; - if( !empty( $this->contact )) $output['CONTACT'] = count( $this->contact ); - if( !empty( $this->created )) $output['CREATED'] = 1; - if( !empty( $this->freebusy )) $output['FREEBUSY'] = count( $this->freebusy ); - if( !empty( $this->geo )) $output['GEO'] = 1; - if( !empty( $this->lastmodified )) $output['LAST-MODIFIED'] = 1; - if( !empty( $this->location )) $output['LOCATION'] = 1; - if( !empty( $this->organizer )) $output['ORGANIZER'] = 1; - if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1; - if( !empty( $this->priority )) $output['PRIORITY'] = 1; - if( !empty( $this->recurrenceid )) $output['RECURRENCE-ID'] = 1; - if( !empty( $this->relatedto )) $output['RELATED-TO'] = count( $this->relatedto ); - if( !empty( $this->repeat )) $output['REPEAT'] = 1; - if( !empty( $this->requeststatus )) $output['REQUEST-STATUS'] = count( $this->requeststatus ); - if( !empty( $this->resources )) $output['RESOURCES'] = count( $this->resources ); - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; - if( !empty( $this->sequence )) $output['SEQUENCE'] = 1; - if( !empty( $this->status )) $output['STATUS'] = 1; - if( !empty( $this->transp )) $output['TRANSP'] = 1; - if( !empty( $this->trigger )) $output['TRIGGER'] = 1; - if( !empty( $this->tzid )) $output['TZID'] = 1; - if( !empty( $this->tzname )) $output['TZNAME'] = count( $this->tzname ); - if( !empty( $this->tzoffsetfrom )) $output['TZOFFSETFROM'] = 1; - if( !empty( $this->tzoffsetto )) $output['TZOFFSETTO'] = 1; - if( !empty( $this->tzurl )) $output['TZURL'] = 1; - if( !empty( $this->url )) $output['URL'] = 1; - if( !empty( $this->xprop )) $output['X-PROP'] = count( $this->xprop ); - return $output; - break; - case 'TZID': - return $this->dtzid; - break; - case 'UNIQUE_ID': - if( empty( $this->unique_id )) - $this->unique_id = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost'; - return $this->unique_id; - break; - } - } -/** - * general component config setting - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.18 - 2011-10-28 - * @param mixed $config - * @param string $value - * @param bool $softUpdate - * @return void - */ - function setConfig( $config, $value = FALSE, $softUpdate = FALSE ) { - if( is_array( $config )) { - $ak = array_keys( $config ); - foreach( $ak as $k ) { - if( 'NEWLINECHAR' == strtoupper( $k )) { - if( FALSE === $this->setConfig( 'NEWLINECHAR', $config[$k] )) - return FALSE; - unset( $config[$k] ); - break; - } - } - foreach( $config as $cKey => $cValue ) { - if( FALSE === $this->setConfig( $cKey, $cValue, $softUpdate )) - return FALSE; - } - return TRUE; - } - $res = FALSE; - switch( strtoupper( $config )) { - case 'ALLOWEMPTY': - $this->allowEmpty = $value; - $subcfg = array( 'ALLOWEMPTY' => $value ); - $res = TRUE; - break; - case 'FORMAT': - $value = trim( strtolower( $value )); - $this->format = $value; - $this->_createFormat(); - $subcfg = array( 'FORMAT' => $value ); - $res = TRUE; - break; - case 'LANGUAGE': - // set language for calendar component as defined in [RFC 1766] - $value = trim( $value ); - if( empty( $this->language ) || !$softUpdate ) - $this->language = $value; - $subcfg = array( 'LANGUAGE' => $value ); - $res = TRUE; - break; - case 'NL': - case 'NEWLINECHAR': - $this->nl = $value; - $this->_createFormat(); - $subcfg = array( 'NL' => $value ); - $res = TRUE; - break; - case 'TZID': - $this->dtzid = $value; - $subcfg = array( 'TZID' => $value ); - $res = TRUE; - break; - case 'UNIQUE_ID': - $value = trim( $value ); - $this->unique_id = $value; - $subcfg = array( 'UNIQUE_ID' => $value ); - $res = TRUE; - break; - default: // any unvalid config key.. . - return TRUE; - } - if( !$res ) return FALSE; - if( isset( $subcfg ) && !empty( $this->components )) { - foreach( $subcfg as $cfgkey => $cfgvalue ) { - foreach( $this->components as $cix => $component ) { - $res = $component->setConfig( $cfgkey, $cfgvalue, $softUpdate ); - if( !$res ) - break 2; - $this->components[$cix] = $component->copy(); // PHP4 compliant - } - } - } - return $res; - } -/*********************************************************************************/ -/** - * delete component property value - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @param mixed $propName, bool FALSE => X-property - * @param int $propix, optional, if specific property is wanted in case of multiply occurences - * @return bool, if successfull delete TRUE - */ - function deleteProperty( $propName=FALSE, $propix=FALSE ) { - if( $this->_notExistProp( $propName )) return FALSE; - $propName = strtoupper( $propName ); - if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', - 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { - if( !$propix ) - $propix = ( isset( $this->propdelix[$propName] ) && ( 'X-PROP' != $propName )) ? $this->propdelix[$propName] + 2 : 1; - $this->propdelix[$propName] = --$propix; - } - $return = FALSE; - switch( $propName ) { - case 'ACTION': - if( !empty( $this->action )) { - $this->action = ''; - $return = TRUE; - } - break; - case 'ATTACH': - return $this->deletePropertyM( $this->attach, $this->propdelix[$propName] ); - break; - case 'ATTENDEE': - return $this->deletePropertyM( $this->attendee, $this->propdelix[$propName] ); - break; - case 'CATEGORIES': - return $this->deletePropertyM( $this->categories, $this->propdelix[$propName] ); - break; - case 'CLASS': - if( !empty( $this->class )) { - $this->class = ''; - $return = TRUE; - } - break; - case 'COMMENT': - return $this->deletePropertyM( $this->comment, $this->propdelix[$propName] ); - break; - case 'COMPLETED': - if( !empty( $this->completed )) { - $this->completed = ''; - $return = TRUE; - } - break; - case 'CONTACT': - return $this->deletePropertyM( $this->contact, $this->propdelix[$propName] ); - break; - case 'CREATED': - if( !empty( $this->created )) { - $this->created = ''; - $return = TRUE; - } - break; - case 'DESCRIPTION': - return $this->deletePropertyM( $this->description, $this->propdelix[$propName] ); - break; - case 'DTEND': - if( !empty( $this->dtend )) { - $this->dtend = ''; - $return = TRUE; - } - break; - case 'DTSTAMP': - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) - return FALSE; - if( !empty( $this->dtstamp )) { - $this->dtstamp = ''; - $return = TRUE; - } - break; - case 'DTSTART': - if( !empty( $this->dtstart )) { - $this->dtstart = ''; - $return = TRUE; - } - break; - case 'DUE': - if( !empty( $this->due )) { - $this->due = ''; - $return = TRUE; - } - break; - case 'DURATION': - if( !empty( $this->duration )) { - $this->duration = ''; - $return = TRUE; - } - break; - case 'EXDATE': - return $this->deletePropertyM( $this->exdate, $this->propdelix[$propName] ); - break; - case 'EXRULE': - return $this->deletePropertyM( $this->exrule, $this->propdelix[$propName] ); - break; - case 'FREEBUSY': - return $this->deletePropertyM( $this->freebusy, $this->propdelix[$propName] ); - break; - case 'GEO': - if( !empty( $this->geo )) { - $this->geo = ''; - $return = TRUE; - } - break; - case 'LAST-MODIFIED': - if( !empty( $this->lastmodified )) { - $this->lastmodified = ''; - $return = TRUE; - } - break; - case 'LOCATION': - if( !empty( $this->location )) { - $this->location = ''; - $return = TRUE; - } - break; - case 'ORGANIZER': - if( !empty( $this->organizer )) { - $this->organizer = ''; - $return = TRUE; - } - break; - case 'PERCENT-COMPLETE': - if( !empty( $this->percentcomplete )) { - $this->percentcomplete = ''; - $return = TRUE; - } - break; - case 'PRIORITY': - if( !empty( $this->priority )) { - $this->priority = ''; - $return = TRUE; - } - break; - case 'RDATE': - return $this->deletePropertyM( $this->rdate, $this->propdelix[$propName] ); - break; - case 'RECURRENCE-ID': - if( !empty( $this->recurrenceid )) { - $this->recurrenceid = ''; - $return = TRUE; - } - break; - case 'RELATED-TO': - return $this->deletePropertyM( $this->relatedto, $this->propdelix[$propName] ); - break; - case 'REPEAT': - if( !empty( $this->repeat )) { - $this->repeat = ''; - $return = TRUE; - } - break; - case 'REQUEST-STATUS': - return $this->deletePropertyM( $this->requeststatus, $this->propdelix[$propName] ); - break; - case 'RESOURCES': - return $this->deletePropertyM( $this->resources, $this->propdelix[$propName] ); - break; - case 'RRULE': - return $this->deletePropertyM( $this->rrule, $this->propdelix[$propName] ); - break; - case 'SEQUENCE': - if( !empty( $this->sequence )) { - $this->sequence = ''; - $return = TRUE; - } - break; - case 'STATUS': - if( !empty( $this->status )) { - $this->status = ''; - $return = TRUE; - } - break; - case 'SUMMARY': - if( !empty( $this->summary )) { - $this->summary = ''; - $return = TRUE; - } - break; - case 'TRANSP': - if( !empty( $this->transp )) { - $this->transp = ''; - $return = TRUE; - } - break; - case 'TRIGGER': - if( !empty( $this->trigger )) { - $this->trigger = ''; - $return = TRUE; - } - break; - case 'TZID': - if( !empty( $this->tzid )) { - $this->tzid = ''; - $return = TRUE; - } - break; - case 'TZNAME': - return $this->deletePropertyM( $this->tzname, $this->propdelix[$propName] ); - break; - case 'TZOFFSETFROM': - if( !empty( $this->tzoffsetfrom )) { - $this->tzoffsetfrom = ''; - $return = TRUE; - } - break; - case 'TZOFFSETTO': - if( !empty( $this->tzoffsetto )) { - $this->tzoffsetto = ''; - $return = TRUE; - } - break; - case 'TZURL': - if( !empty( $this->tzurl )) { - $this->tzurl = ''; - $return = TRUE; - } - break; - case 'UID': - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) - return FALSE; - if( !empty( $this->uid )) { - $this->uid = ''; - $return = TRUE; - } - break; - case 'URL': - if( !empty( $this->url )) { - $this->url = ''; - $return = TRUE; - } - break; - default: - $reduced = ''; - if( $propName != 'X-PROP' ) { - if( !isset( $this->xprop[$propName] )) return FALSE; - foreach( $this->xprop as $k => $a ) { - if(( $k != $propName ) && !empty( $a )) - $reduced[$k] = $a; - } - } - else { - if( count( $this->xprop ) <= $propix ) { unset( $this->propdelix[$propName] ); return FALSE; } - $xpropno = 0; - foreach( $this->xprop as $xpropkey => $xpropvalue ) { - if( $propix != $xpropno ) - $reduced[$xpropkey] = $xpropvalue; - $xpropno++; - } - } - $this->xprop = $reduced; - if( empty( $this->xprop )) { - unset( $this->propdelix[$propName] ); - return FALSE; - } - return TRUE; - } - return $return; - } -/*********************************************************************************/ -/** - * delete component property value, fixing components with multiple occurencies - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @param array $multiprop, reference to a component property - * @param int $propix, reference to removal counter - * @return bool TRUE - */ - function deletePropertyM( & $multiprop, & $propix ) { - if( isset( $multiprop[$propix] )) - unset( $multiprop[$propix] ); - if( empty( $multiprop )) { - $multiprop = ''; - unset( $propix ); - return FALSE; - } - else - return TRUE; - } -/** - * get component property value/params - * - * if property has multiply values, consequtive function calls are needed - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.3 - 2012-01-10 - * @param string $propName, optional - * @param int @propix, optional, if specific property is wanted in case of multiply occurences - * @param bool $inclParam=FALSE - * @param bool $specform=FALSE - * @return mixed - */ - function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) { - if( $this->_notExistProp( $propName )) return FALSE; - $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP'; - if( in_array( $propName, array( 'ATTACH', 'ATTENDEE', 'CATEGORIES', 'COMMENT', 'CONTACT', 'DESCRIPTION', 'EXDATE', 'EXRULE', - 'FREEBUSY', 'RDATE', 'RELATED-TO', 'RESOURCES', 'RRULE', 'REQUEST-STATUS', 'TZNAME', 'X-PROP' ))) { - if( !$propix ) - $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1; - $this->propix[$propName] = --$propix; - } - switch( $propName ) { - case 'ACTION': - if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value']; - break; - case 'ATTACH': - $ak = ( is_array( $this->attach )) ? array_keys( $this->attach ) : array(); - while( is_array( $this->attach ) && !isset( $this->attach[$propix] ) && ( 0 < count( $this->attach )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->attach[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value']; - break; - case 'ATTENDEE': - $ak = ( is_array( $this->attendee )) ? array_keys( $this->attendee ) : array(); - while( is_array( $this->attendee ) && !isset( $this->attendee[$propix] ) && ( 0 < count( $this->attendee )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->attendee[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value']; - break; - case 'CATEGORIES': - $ak = ( is_array( $this->categories )) ? array_keys( $this->categories ) : array(); - while( is_array( $this->categories ) && !isset( $this->categories[$propix] ) && ( 0 < count( $this->categories )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->categories[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value']; - break; - case 'CLASS': - if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value']; - break; - case 'COMMENT': - $ak = ( is_array( $this->comment )) ? array_keys( $this->comment ) : array(); - while( is_array( $this->comment ) && !isset( $this->comment[$propix] ) && ( 0 < count( $this->comment )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->comment[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value']; - break; - case 'COMPLETED': - if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value']; - break; - case 'CONTACT': - $ak = ( is_array( $this->contact )) ? array_keys( $this->contact ) : array(); - while( is_array( $this->contact ) && !isset( $this->contact[$propix] ) && ( 0 < count( $this->contact )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->contact[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value']; - break; - case 'CREATED': - if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value']; - break; - case 'DESCRIPTION': - $ak = ( is_array( $this->description )) ? array_keys( $this->description ) : array(); - while( is_array( $this->description ) && !isset( $this->description[$propix] ) && ( 0 < count( $this->description )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->description[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value']; - break; - case 'DTEND': - if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value']; - break; - case 'DTSTAMP': - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) - return; - if( !isset( $this->dtstamp['value'] )) - $this->_makeDtstamp(); - return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value']; - break; - case 'DTSTART': - if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value']; - break; - case 'DUE': - if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value']; - break; - case 'DURATION': - if( !isset( $this->duration['value'] )) return FALSE; - $value = ( $specform && isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) ? iCalUtilityFunctions::_duration2date( $this->dtstart['value'], $this->duration['value'] ) : $this->duration['value']; - return ( $inclParam ) ? array( 'value' => $value, 'params' => $this->duration['params'] ) : $value; - break; - case 'EXDATE': - $ak = ( is_array( $this->exdate )) ? array_keys( $this->exdate ) : array(); - while( is_array( $this->exdate ) && !isset( $this->exdate[$propix] ) && ( 0 < count( $this->exdate )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->exdate[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value']; - break; - case 'EXRULE': - $ak = ( is_array( $this->exrule )) ? array_keys( $this->exrule ) : array(); - while( is_array( $this->exrule ) && !isset( $this->exrule[$propix] ) && ( 0 < count( $this->exrule )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->exrule[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value']; - break; - case 'FREEBUSY': - $ak = ( is_array( $this->freebusy )) ? array_keys( $this->freebusy ) : array(); - while( is_array( $this->freebusy ) && !isset( $this->freebusy[$propix] ) && ( 0 < count( $this->freebusy )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->freebusy[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value']; - break; - case 'GEO': - if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value']; - break; - case 'LAST-MODIFIED': - if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value']; - break; - case 'LOCATION': - if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value']; - break; - case 'ORGANIZER': - if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value']; - break; - case 'PERCENT-COMPLETE': - if( !empty( $this->percentcomplete['value'] ) || ( isset( $this->percentcomplete['value'] ) && ( '0' == $this->percentcomplete['value'] ))) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value']; - break; - case 'PRIORITY': - if( !empty( $this->priority['value'] ) || ( isset( $this->priority['value'] ) && ('0' == $this->priority['value'] ))) return ( $inclParam ) ? $this->priority : $this->priority['value']; - break; - case 'RDATE': - $ak = ( is_array( $this->rdate )) ? array_keys( $this->rdate ) : array(); - while( is_array( $this->rdate ) && !isset( $this->rdate[$propix] ) && ( 0 < count( $this->rdate )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->rdate[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value']; - break; - case 'RECURRENCE-ID': - if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value']; - break; - case 'RELATED-TO': - $ak = ( is_array( $this->relatedto )) ? array_keys( $this->relatedto ) : array(); - while( is_array( $this->relatedto ) && !isset( $this->relatedto[$propix] ) && ( 0 < count( $this->relatedto )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->relatedto[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value']; - break; - case 'REPEAT': - if( !empty( $this->repeat['value'] ) || ( isset( $this->repeat['value'] ) && ( '0' == $this->repeat['value'] ))) return ( $inclParam ) ? $this->repeat : $this->repeat['value']; - break; - case 'REQUEST-STATUS': - $ak = ( is_array( $this->requeststatus )) ? array_keys( $this->requeststatus ) : array(); - while( is_array( $this->requeststatus ) && !isset( $this->requeststatus[$propix] ) && ( 0 < count( $this->requeststatus )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->requeststatus[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value']; - break; - case 'RESOURCES': - $ak = ( is_array( $this->resources )) ? array_keys( $this->resources ) : array(); - while( is_array( $this->resources ) && !isset( $this->resources[$propix] ) && ( 0 < count( $this->resources )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->resources[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value']; - break; - case 'RRULE': - $ak = ( is_array( $this->rrule )) ? array_keys( $this->rrule ) : array(); - while( is_array( $this->rrule ) && !isset( $this->rrule[$propix] ) && ( 0 < count( $this->rrule )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->rrule[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value']; - break; - case 'SEQUENCE': - if( isset( $this->sequence['value'] ) && ( isset( $this->sequence['value'] ) && ( '0' <= $this->sequence['value'] ))) return ( $inclParam ) ? $this->sequence : $this->sequence['value']; - break; - case 'STATUS': - if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value']; - break; - case 'SUMMARY': - if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value']; - break; - case 'TRANSP': - if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value']; - break; - case 'TRIGGER': - if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value']; - break; - case 'TZID': - if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value']; - break; - case 'TZNAME': - $ak = ( is_array( $this->tzname )) ? array_keys( $this->tzname ) : array(); - while( is_array( $this->tzname ) && !isset( $this->tzname[$propix] ) && ( 0 < count( $this->tzname )) && ( $propix < end( $ak ))) - $propix++; - $this->propix[$propName] = $propix; - if( !isset( $this->tzname[$propix] )) { unset( $this->propix[$propName] ); return FALSE; } - return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value']; - break; - case 'TZOFFSETFROM': - if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value']; - break; - case 'TZOFFSETTO': - if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value']; - break; - case 'TZURL': - if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value']; - break; - case 'UID': - if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) - return FALSE; - if( empty( $this->uid['value'] )) - $this->_makeuid(); - return ( $inclParam ) ? $this->uid : $this->uid['value']; - break; - case 'URL': - if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value']; - break; - default: - if( $propName != 'X-PROP' ) { - if( !isset( $this->xprop[$propName] )) return FALSE; - return ( $inclParam ) ? array( $propName, $this->xprop[$propName] ) - : array( $propName, $this->xprop[$propName]['value'] ); - } - else { - if( empty( $this->xprop )) return FALSE; - $xpropno = 0; - foreach( $this->xprop as $xpropkey => $xpropvalue ) { - if( $propix == $xpropno ) - return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] ) - : array( $xpropkey, $this->xprop[$xpropkey]['value'] ); - else - $xpropno++; - } - return FALSE; // not found ?? - } - } - return FALSE; - } -/** - * returns calendar property unique values for 'CATEGORIES', 'RESOURCES' or 'ATTENDEE' and each number of ocurrence - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-04-13 - * @param string $propName - * @param array $output, incremented result array - */ - function _getProperties( $propName, & $output ) { - if( !in_array( strtoupper( $propName ), array( 'ATTENDEE', 'CATEGORIES', 'RESOURCES' ))) - return output; - while( FALSE !== ( $content = $this->getProperty( $propName ))) { - if( is_array( $content )) { - foreach( $content as $part ) { - if( FALSE !== strpos( $part, ',' )) { - $part = explode( ',', $part ); - foreach( $part as $thePart ) { - $thePart = trim( $thePart ); - if( !empty( $thePart )) { - if( !isset( $output[$thePart] )) - $output[$thePart] = 1; - else - $output[$thePart] += 1; - } - } - } - else { - $part = trim( $part ); - if( !isset( $output[$part] )) - $output[$part] = 1; - else - $output[$part] += 1; - } - } - } - elseif( FALSE !== strpos( $content, ',' )) { - $content = explode( ',', $content ); - foreach( $content as $thePart ) { - $thePart = trim( $thePart ); - if( !empty( $thePart )) { - if( !isset( $output[$thePart] )) - $output[$thePart] = 1; - else - $output[$thePart] += 1; - } - } - } - else { - $content = trim( $content ); - if( !empty( $content )) { - if( !isset( $output[$content] )) - $output[$content] = 1; - else - $output[$content] += 1; - } - } - } - ksort( $output ); - return $output; - } -/** - * general component property setting - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-05 - * @param mixed $args variable number of function arguments, - * first argument is ALWAYS component name, - * second ALWAYS component value! - * @return void - */ - function setProperty() { - $numargs = func_num_args(); - if( 1 > $numargs ) return FALSE; - $arglist = func_get_args(); - if( $this->_notExistProp( $arglist[0] )) return FALSE; - if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) - return FALSE; - $arglist[0] = strtoupper( $arglist[0] ); - for( $argix=$numargs; $argix < 12; $argix++ ) { - if( !isset( $arglist[$argix] )) - $arglist[$argix] = null; - } - switch( $arglist[0] ) { - case 'ACTION': - return $this->setAction( $arglist[1], $arglist[2] ); - case 'ATTACH': - return $this->setAttach( $arglist[1], $arglist[2], $arglist[3] ); - case 'ATTENDEE': - return $this->setAttendee( $arglist[1], $arglist[2], $arglist[3] ); - case 'CATEGORIES': - return $this->setCategories( $arglist[1], $arglist[2], $arglist[3] ); - case 'CLASS': - return $this->setClass( $arglist[1], $arglist[2] ); - case 'COMMENT': - return $this->setComment( $arglist[1], $arglist[2], $arglist[3] ); - case 'COMPLETED': - return $this->setCompleted( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); - case 'CONTACT': - return $this->setContact( $arglist[1], $arglist[2], $arglist[3] ); - case 'CREATED': - return $this->setCreated( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); - case 'DESCRIPTION': - return $this->setDescription( $arglist[1], $arglist[2], $arglist[3] ); - case 'DTEND': - return $this->setDtend( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); - case 'DTSTAMP': - return $this->setDtstamp( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); - case 'DTSTART': - return $this->setDtstart( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); - case 'DUE': - return $this->setDue( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); - case 'DURATION': - return $this->setDuration( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6] ); - case 'EXDATE': - return $this->setExdate( $arglist[1], $arglist[2], $arglist[3] ); - case 'EXRULE': - return $this->setExrule( $arglist[1], $arglist[2], $arglist[3] ); - case 'FREEBUSY': - return $this->setFreebusy( $arglist[1], $arglist[2], $arglist[3], $arglist[4] ); - case 'GEO': - return $this->setGeo( $arglist[1], $arglist[2], $arglist[3] ); - case 'LAST-MODIFIED': - return $this->setLastModified( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7] ); - case 'LOCATION': - return $this->setLocation( $arglist[1], $arglist[2] ); - case 'ORGANIZER': - return $this->setOrganizer( $arglist[1], $arglist[2] ); - case 'PERCENT-COMPLETE': - return $this->setPercentComplete( $arglist[1], $arglist[2] ); - case 'PRIORITY': - return $this->setPriority( $arglist[1], $arglist[2] ); - case 'RDATE': - return $this->setRdate( $arglist[1], $arglist[2], $arglist[3] ); - case 'RECURRENCE-ID': - return $this->setRecurrenceid( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8] ); - case 'RELATED-TO': - return $this->setRelatedTo( $arglist[1], $arglist[2], $arglist[3] ); - case 'REPEAT': - return $this->setRepeat( $arglist[1], $arglist[2] ); - case 'REQUEST-STATUS': - return $this->setRequestStatus( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5] ); - case 'RESOURCES': - return $this->setResources( $arglist[1], $arglist[2], $arglist[3] ); - case 'RRULE': - return $this->setRrule( $arglist[1], $arglist[2], $arglist[3] ); - case 'SEQUENCE': - return $this->setSequence( $arglist[1], $arglist[2] ); - case 'STATUS': - return $this->setStatus( $arglist[1], $arglist[2] ); - case 'SUMMARY': - return $this->setSummary( $arglist[1], $arglist[2] ); - case 'TRANSP': - return $this->setTransp( $arglist[1], $arglist[2] ); - case 'TRIGGER': - return $this->setTrigger( $arglist[1], $arglist[2], $arglist[3], $arglist[4], $arglist[5], $arglist[6], $arglist[7], $arglist[8], $arglist[9], $arglist[10], $arglist[11] ); - case 'TZID': - return $this->setTzid( $arglist[1], $arglist[2] ); - case 'TZNAME': - return $this->setTzname( $arglist[1], $arglist[2], $arglist[3] ); - case 'TZOFFSETFROM': - return $this->setTzoffsetfrom( $arglist[1], $arglist[2] ); - case 'TZOFFSETTO': - return $this->setTzoffsetto( $arglist[1], $arglist[2] ); - case 'TZURL': - return $this->setTzurl( $arglist[1], $arglist[2] ); - case 'UID': - return $this->setUid( $arglist[1], $arglist[2] ); - case 'URL': - return $this->setUrl( $arglist[1], $arglist[2] ); - default: - return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] ); - } - return FALSE; - } -/*********************************************************************************/ -/** - * parse component unparsed data into properties - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.17 - 2012-02-03 - * @param mixed $unparsedtext, optional, strict rfc2445 formatted, single property string or array of strings - * @return bool FALSE if error occurs during parsing - * - */ - function parse( $unparsedtext=null ) { - if( !empty( $unparsedtext )) { - $nl = $this->getConfig( 'nl' ); - if( is_array( $unparsedtext )) - $unparsedtext = implode( '\n'.$nl, $unparsedtext ); - /* fix line folding */ - $eolchars = array( "\r\n", "\n\r", "\n", "\r" ); // check all line endings - $EOLmark = FALSE; - foreach( $eolchars as $eolchar ) { - if( !$EOLmark && ( FALSE !== strpos( $unparsedtext, $eolchar ))) { - $unparsedtext = str_replace( $eolchar." ", '', $unparsedtext ); - $unparsedtext = str_replace( $eolchar."\t", '', $unparsedtext ); - if( $eolchar != $nl ) - $unparsedtext = str_replace( $eolchar, $nl, $unparsedtext ); - $EOLmark = TRUE; - } - } - $tmp = explode( $nl, $unparsedtext ); - $unparsedtext = array(); - foreach( $tmp as $tmpr ) - if( !empty( $tmpr )) - $unparsedtext[] = $tmpr; - } - elseif( !isset( $this->unparsed )) - $unparsedtext = array(); - else - $unparsedtext = $this->unparsed; - $this->unparsed = array(); - $comp = & $this; - $config = $this->getConfig(); - foreach ( $unparsedtext as $line ) { - if( in_array( strtoupper( substr( $line, 0, 6 )), array( 'END:VA', 'END:DA' ))) - $this->components[] = $comp->copy(); - elseif( 'END:ST' == strtoupper( substr( $line, 0, 6 ))) - array_unshift( $this->components, $comp->copy()); - elseif( 'END:' == strtoupper( substr( $line, 0, 4 ))) - break; - elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) - $comp = new valarm( $config); - elseif( 'BEGIN:STANDARD' == strtoupper( substr( $line, 0, 14 ))) - $comp = new vtimezone( 'standard', $config ); - elseif( 'BEGIN:DAYLIGHT' == strtoupper( substr( $line, 0, 14 ))) - $comp = new vtimezone( 'daylight', $config ); - elseif( 'BEGIN:' == strtoupper( substr( $line, 0, 6 ))) - continue; - else - $comp->unparsed[] = $line; - } - unset( $config ); - /* concatenate property values spread over several lines */ - $lastix = -1; - $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed' - , 'contact', 'class', 'created', 'description', 'dtend', 'dtstart' - , 'dtstamp', 'due', 'duration', 'exdate', 'exrule', 'freebusy', 'geo' - , 'last-modified', 'location', 'organizer', 'percent-complete' - , 'priority', 'rdate', 'recurrence-id', 'related-to', 'repeat' - , 'request-status', 'resources', 'rrule', 'sequence', 'status' - , 'summary', 'transp', 'trigger', 'tzid', 'tzname', 'tzoffsetfrom' - , 'tzoffsetto', 'tzurl', 'uid', 'url', 'x-' ); - $proprows = array(); - foreach( $this->unparsed as $line ) { - $newProp = FALSE; - foreach ( $propnames as $propname ) { - if( $propname == strtolower( substr( $line, 0, strlen( $propname )))) { - $newProp = TRUE; - break; - } - } - if( $newProp ) { - $newProp = FALSE; - $lastix++; - $proprows[$lastix] = $line; - } - else - $proprows[$lastix] .= '!"#¤%&/()=?'.$line; - } - /* parse each property 'line' */ - $paramMStz = array( 'utc-', 'utc+', 'gmt-', 'gmt+' ); - $paramProto3 = array( 'fax:', 'cid:', 'sms:', 'tel:', 'urn:' ); - $paramProto4 = array( 'crid:', 'news:', 'pres:' ); - foreach( $proprows as $line ) { - $line = str_replace( '!"#¤%&/()=? ', '', $line ); - $line = str_replace( '!"#¤%&/()=?', '', $line ); - if( '\n' == substr( $line, -2 )) - $line = substr( $line, 0, strlen( $line ) - 2 ); - /* get propname, (problem with x-properties, otherwise in previous loop) */ - $cix = $propname = null; - for( $cix=0, $clen = strlen( $line ); $cix < $clen; $cix++ ) { - if( in_array( $line[$cix], array( ':', ';' ))) - break; - else - $propname .= $line[$cix]; - } - if(( 'x-' == substr( $propname, 0, 2 )) || ( 'X-' == substr( $propname, 0, 2 ))) { - $propname2 = $propname; - $propname = 'X-'; - } - /* rest of the line is opt.params and value */ - $line = substr( $line, $cix ); - /* separate attributes from value */ - $attr = array(); - $attrix = -1; - $clen = strlen( $line ); - $WithinQuotes = FALSE; - for( $cix=0; $cix < $clen; $cix++ ) { - if( ( ':' == $line[$cix] ) && - ( substr( $line,$cix, 3 ) != '://' ) && - ( !in_array( strtolower( substr( $line,$cix - 6, 4 )), $paramMStz )) && - ( !in_array( strtolower( substr( $line,$cix - 3, 4 )), $paramProto3 )) && - ( !in_array( strtolower( substr( $line,$cix - 4, 5 )), $paramProto4 )) && - ( strtolower( substr( $line,$cix - 6, 7 )) != 'mailto:' ) && - !$WithinQuotes ) { - $attrEnd = TRUE; - if(( $cix < ( $clen - 4 )) && - ctype_digit( substr( $line, $cix+1, 4 ))) { // an URI with a (4pos) portnr?? - for( $c2ix = $cix; 3 < $c2ix; $c2ix-- ) { - if( '://' == substr( $line, $c2ix - 2, 3 )) { - $attrEnd = FALSE; - break; // an URI with a portnr!! - } - } - } - if( $attrEnd) { - $line = substr( $line, ( $cix + 1 )); - break; - } - } - if( '"' == $line[$cix] ) - $WithinQuotes = ( FALSE === $WithinQuotes ) ? TRUE : FALSE; - if( ';' == $line[$cix] ) - $attr[++$attrix] = null; - else - $attr[$attrix] .= $line[$cix]; - } - /* make attributes in array format */ - $propattr = array(); - foreach( $attr as $attribute ) { - $attrsplit = explode( '=', $attribute, 2 ); - if( 1 < count( $attrsplit )) - $propattr[$attrsplit[0]] = $attrsplit[1]; - else - $propattr[] = $attribute; - } - /* call setProperty( $propname.. . */ - switch( strtoupper( $propname )) { - case 'ATTENDEE': - foreach( $propattr as $pix => $attr ) { - if( !in_array( strtoupper( $pix ), array( 'MEMBER', 'DELEGATED-TO', 'DELEGATED-FROM' ))) - continue; - $attr2 = explode( ',', $attr ); - if( 1 < count( $attr2 )) - $propattr[$pix] = $attr2; - } - $this->setProperty( $propname, $line, $propattr ); - break; - case 'X-': - $propname = ( isset( $propname2 )) ? $propname2 : $propname; - unset( $propname2 ); - case 'CATEGORIES': - case 'RESOURCES': - if( FALSE !== strpos( $line, ',' )) { - $llen = strlen( $line ); - $content = array( 0 => '' ); - $cix = 0; - for( $lix = 0; $lix < $llen; $lix++ ) { - if(( ',' == $line[$lix] ) && ( "\\" != $line[( $lix - 1 )])) { - $cix++; - $content[$cix] = ''; - } - else - $content[$cix] .= $line[$lix]; - } - if( 1 < count( $content )) { - $content = array_values( $content ); - foreach( $content as $cix => $contentPart ) - $content[$cix] = calendarComponent::_strunrep( $contentPart ); - $this->setProperty( $propname, $content, $propattr ); - break; - } - else - $line = reset( $content ); - } - case 'COMMENT': - case 'CONTACT': - case 'DESCRIPTION': - case 'LOCATION': - case 'SUMMARY': - if( empty( $line )) - $propattr = null; - $this->setProperty( $propname, calendarComponent::_strunrep( $line ), $propattr ); - break; - case 'REQUEST-STATUS': - $values = explode( ';', $line, 3 ); - $values[1] = ( !isset( $values[1] )) ? null : calendarComponent::_strunrep( $values[1] ); - $values[2] = ( !isset( $values[2] )) ? null : calendarComponent::_strunrep( $values[2] ); - $this->setProperty( $propname - , $values[0] // statcode - , $values[1] // statdesc - , $values[2] // extdata - , $propattr ); - break; - case 'FREEBUSY': - $fbtype = ( isset( $propattr['FBTYPE'] )) ? $propattr['FBTYPE'] : ''; // force setting default, if missing - unset( $propattr['FBTYPE'] ); - $values = explode( ',', $line ); - foreach( $values as $vix => $value ) { - $value2 = explode( '/', $value ); - if( 1 < count( $value2 )) - $values[$vix] = $value2; - } - $this->setProperty( $propname, $fbtype, $values, $propattr ); - break; - case 'GEO': - $value = explode( ';', $line, 2 ); - if( 2 > count( $value )) - $value[1] = null; - $this->setProperty( $propname, $value[0], $value[1], $propattr ); - break; - case 'EXDATE': - $values = ( !empty( $line )) ? explode( ',', $line ) : null; - $this->setProperty( $propname, $values, $propattr ); - break; - case 'RDATE': - if( empty( $line )) { - $this->setProperty( $propname, $line, $propattr ); - break; - } - $values = explode( ',', $line ); - foreach( $values as $vix => $value ) { - $value2 = explode( '/', $value ); - if( 1 < count( $value2 )) - $values[$vix] = $value2; - } - $this->setProperty( $propname, $values, $propattr ); - break; - case 'EXRULE': - case 'RRULE': - $values = explode( ';', $line ); - $recur = array(); - foreach( $values as $value2 ) { - if( empty( $value2 )) - continue; // ;-char in ending position ??? - $value3 = explode( '=', $value2, 2 ); - $rulelabel = strtoupper( $value3[0] ); - switch( $rulelabel ) { - case 'BYDAY': { - $value4 = explode( ',', $value3[1] ); - if( 1 < count( $value4 )) { - foreach( $value4 as $v5ix => $value5 ) { - $value6 = array(); - $dayno = $dayname = null; - $value5 = trim( (string) $value5 ); - if(( ctype_alpha( substr( $value5, -1 ))) && - ( ctype_alpha( substr( $value5, -2, 1 )))) { - $dayname = substr( $value5, -2, 2 ); - if( 2 < strlen( $value5 )) - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); - } - if( $dayno ) - $value6[] = $dayno; - if( $dayname ) - $value6['DAY'] = $dayname; - $value4[$v5ix] = $value6; - } - } - else { - $value4 = array(); - $dayno = $dayname = null; - $value5 = trim( (string) $value3[1] ); - if(( ctype_alpha( substr( $value5, -1 ))) && - ( ctype_alpha( substr( $value5, -2, 1 )))) { - $dayname = substr( $value5, -2, 2 ); - if( 2 < strlen( $value5 )) - $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 )); - } - if( $dayno ) - $value4[] = $dayno; - if( $dayname ) - $value4['DAY'] = $dayname; - } - $recur[$rulelabel] = $value4; - break; - } - default: { - $value4 = explode( ',', $value3[1] ); - if( 1 < count( $value4 )) - $value3[1] = $value4; - $recur[$rulelabel] = $value3[1]; - break; - } - } // end - switch $rulelabel - } // end - foreach( $values.. . - $this->setProperty( $propname, $recur, $propattr ); - break; - case 'ACTION': - case 'CLASSIFICATION': - case 'STATUS': - case 'TRANSP': - case 'UID': - case 'TZID': - case 'RELATED-TO': - case 'TZNAME': - $line = calendarComponent::_strunrep( $line ); - default: - $this->setProperty( $propname, $line, $propattr ); - break; - } // end switch( $propname.. . - } // end - foreach( $proprows.. . - unset( $unparsedtext, $this->unparsed, $proprows ); - if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) { - $ckeys = array_keys( $this->components ); - foreach( $ckeys as $ckey ) { - if( !empty( $this->components[$ckey] ) && !empty( $this->components[$ckey]->unparsed )) { - $this->components[$ckey]->parse(); - } - } - } - return TRUE; - } -/*********************************************************************************/ -/*********************************************************************************/ -/** - * return a copy of this component - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @return object - */ - function copy() { - $serialized_contents = serialize( $this ); - $copy = unserialize( $serialized_contents ); - return $copy; - } -/*********************************************************************************/ -/*********************************************************************************/ -/** - * delete calendar subcomponent from component container - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @param mixed $arg1 ordno / component type / component uid - * @param mixed $arg2 optional, ordno if arg1 = component type - * @return void - */ - function deleteComponent( $arg1, $arg2=FALSE ) { - if( !isset( $this->components )) return FALSE; - $argType = $index = null; - if ( ctype_digit( (string) $arg1 )) { - $argType = 'INDEX'; - $index = (int) $arg1 - 1; - } - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { - $argType = strtolower( $arg1 ); - $index = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0; - } - $cix2dC = 0; - foreach ( $this->components as $cix => $component) { - if( empty( $component )) continue; - if(( 'INDEX' == $argType ) && ( $index == $cix )) { - unset( $this->components[$cix] ); - return TRUE; - } - elseif( $argType == $component->objName ) { - if( $index == $cix2dC ) { - unset( $this->components[$cix] ); - return TRUE; - } - $cix2dC++; - } - elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) { - unset( $this->components[$cix] ); - return TRUE; - } - } - return FALSE; - } -/** - * get calendar component subcomponent from component container - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @param mixed $arg1 optional, ordno/component type/ component uid - * @param mixed $arg2 optional, ordno if arg1 = component type - * @return object - */ - function getComponent ( $arg1=FALSE, $arg2=FALSE ) { - if( !isset( $this->components )) return FALSE; - $index = $argType = null; - if ( !$arg1 ) { - $argType = 'INDEX'; - $index = $this->compix['INDEX'] = - ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1; - } - elseif ( ctype_digit( (string) $arg1 )) { - $argType = 'INDEX'; - $index = (int) $arg1; - unset( $this->compix ); - } - elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) { - unset( $this->compix['INDEX'] ); - $argType = strtolower( $arg1 ); - if( !$arg2 ) - $index = $this->compix[$argType] = ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1; - else - $index = (int) $arg2; - } - $index -= 1; - $ckeys = array_keys( $this->components ); - if( !empty( $index) && ( $index > end( $ckeys ))) - return FALSE; - $cix2gC = 0; - foreach( $this->components as $cix => $component ) { - if( empty( $component )) continue; - if(( 'INDEX' == $argType ) && ( $index == $cix )) - return $component->copy(); - elseif( $argType == $component->objName ) { - if( $index == $cix2gC ) - return $component->copy(); - $cix2gC++; - } - elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) - return $component->copy(); - } - /* not found.. . */ - unset( $this->compix ); - return false; - } -/** - * add calendar component as subcomponent to container for subcomponents - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 1.x.x - 2007-04-24 - * @param object $component calendar component - * @return void - */ - function addSubComponent ( $component ) { - $this->setComponent( $component ); - } -/** - * create new calendar component subcomponent, already included within component - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.33 - 2011-01-03 - * @param string $compType subcomponent type - * @return object (reference) - */ - function & newComponent( $compType ) { - $config = $this->getConfig(); - $keys = array_keys( $this->components ); - $ix = end( $keys) + 1; - switch( strtoupper( $compType )) { - case 'ALARM': - case 'VALARM': - $this->components[$ix] = new valarm( $config ); - break; - case 'STANDARD': - array_unshift( $this->components, new vtimezone( 'STANDARD', $config )); - $ix = 0; - break; - case 'DAYLIGHT': - $this->components[$ix] = new vtimezone( 'DAYLIGHT', $config ); - break; - default: - return FALSE; - } - return $this->components[$ix]; - } -/** - * add calendar component as subcomponent to container for subcomponents - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.8 - 2011-03-15 - * @param object $component calendar component - * @param mixed $arg1 optional, ordno/component type/ component uid - * @param mixed $arg2 optional, ordno if arg1 = component type - * @return bool - */ - function setComponent( $component, $arg1=FALSE, $arg2=FALSE ) { - if( !isset( $this->components )) return FALSE; - $component->setConfig( $this->getConfig(), FALSE, TRUE ); - if( !in_array( $component->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) { - /* make sure dtstamp and uid is set */ - $dummy = $component->getProperty( 'dtstamp' ); - $dummy = $component->getProperty( 'uid' ); - } - if( !$arg1 ) { // plain insert, last in chain - $this->components[] = $component->copy(); - return TRUE; - } - $argType = $index = null; - if ( ctype_digit( (string) $arg1 )) { // index insert/replace - $argType = 'INDEX'; - $index = (int) $arg1 - 1; - } - elseif( in_array( strtolower( $arg1 ), array( 'vevent', 'vtodo', 'vjournal', 'vfreebusy', 'valarm', 'vtimezone' ))) { - $argType = strtolower( $arg1 ); - $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0; - } - // else if arg1 is set, arg1 must be an UID - $cix2sC = 0; - foreach ( $this->components as $cix => $component2 ) { - if( empty( $component2 )) continue; - if(( 'INDEX' == $argType ) && ( $index == $cix )) { // index insert/replace - $this->components[$cix] = $component->copy(); - return TRUE; - } - elseif( $argType == $component2->objName ) { // component Type index insert/replace - if( $index == $cix2sC ) { - $this->components[$cix] = $component->copy(); - return TRUE; - } - $cix2sC++; - } - elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) { // UID insert/replace - $this->components[$cix] = $component->copy(); - return TRUE; - } - } - /* arg1=index and not found.. . insert at index .. .*/ - if( 'INDEX' == $argType ) { - $this->components[$index] = $component->copy(); - ksort( $this->components, SORT_NUMERIC ); - } - else /* not found.. . insert last in chain anyway .. .*/ - $this->components[] = $component->copy(); - return TRUE; - } -/** - * creates formatted output for subcomponents - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.20 - 2012-02-06 - * @param array $xcaldecl - * @return string - */ - function createSubComponent() { - $output = null; - if( 'vtimezone' == $this->objName ) { // sort subComponents, first standard, then daylight, in dtstart order - $stdarr = $dlarr = array(); - foreach( $this->components as $component ) { - if( empty( $component )) - continue; - $dt = $component->getProperty( 'dtstart' ); - $key = sprintf( '%04d%02d%02d%02d%02d%02d000', $dt['year'], $dt['month'], $dt['day'], $dt['hour'], $dt['min'], $dt['sec'] ); - if( 'standard' == $component->objName ) { - while( isset( $stdarr[$key] )) - $key += 1; - $stdarr[$key] = $component->copy(); - } - elseif( 'daylight' == $component->objName ) { - while( isset( $dlarr[$key] )) - $key += 1; - $dlarr[$key] = $component->copy(); - } - } // end foreach( $this->components as $component ) - $this->components = array(); - ksort( $stdarr, SORT_NUMERIC ); - foreach( $stdarr as $std ) - $this->components[] = $std->copy(); - unset( $stdarr ); - ksort( $dlarr, SORT_NUMERIC ); - foreach( $dlarr as $dl ) - $this->components[] = $dl->copy(); - unset( $dlarr ); - } // end if( 'vtimezone' == $this->objName ) - foreach( $this->components as $component ) { - $component->setConfig( $this->getConfig(), FALSE, TRUE ); - $output .= $component->createComponent( $this->xcaldecl ); - } - return $output; - } -/********************************************************************************/ -/** - * break lines at pos 75 - * - * Lines of text SHOULD NOT be longer than 75 octets, excluding the line - * break. Long content lines SHOULD be split into a multiple line - * representations using a line "folding" technique. That is, a long - * line can be split between any two characters by inserting a CRLF - * immediately followed by a single linear white space character (i.e., - * SPACE, US-ASCII decimal 32 or HTAB, US-ASCII decimal 9). Any sequence - * of CRLF followed immediately by a single linear white space character - * is ignored (i.e., removed) when processing the content type. - * - * Edited 2007-08-26 by Anders Litzell, anders@litzell.se to fix bug where - * the reserved expression "\n" in the arg $string could be broken up by the - * folding of lines, causing ambiguity in the return string. - * Fix uses var $breakAtChar=75 and breaks the line at $breakAtChar-1 if need be. - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.13 - 2012-02-14 - * @param string $value - * @return string - */ - function _size75( $string ) { - $tmp = $string; - $string = ''; - $eolcharlen = strlen( '\n' ); - /* if PHP is config with mb_string and conf overload.. . */ - if( defined( 'MB_OVERLOAD_STRING' ) && ( 1 < ini_get( 'mbstring.func_overload' ))) { - $strlen = mb_strlen( $tmp ); - while( $strlen > 75 ) { - if( '\n' == mb_substr( $tmp, 75, $eolcharlen )) - $breakAtChar = 74; - else - $breakAtChar = 75; - $string .= mb_substr( $tmp, 0, $breakAtChar ); - if( $this->nl != mb_substr( $string, ( 0 - mb_strlen( $this->nl )))) - $string .= $this->nl; - $tmp = mb_substr( $tmp, $breakAtChar ); - if( !empty( $tmp )) - $tmp = ' '.$tmp; - $strlen = mb_strlen( $tmp ); - } // end while - if( 0 < $strlen ) { - $string .= $tmp; // the rest - if( $this->nl != mb_substr( $string, ( 0 - mb_strlen( $this->nl )))) - $string .= $this->nl; - } - return $string; - } - /* if PHP is not config with mb_string.. . */ - while( TRUE ) { - $bytecnt = strlen( $tmp ); - $charCnt = $ix = 0; - for( $ix = 0; $ix < $bytecnt; $ix++ ) { - if(( 73 < $charCnt ) && ( '\n' == substr( $tmp, $ix, $eolcharlen ))) - break; // break before '\n' - elseif( 74 < $charCnt ) { - if( '\n' == substr( $tmp, $ix, $eolcharlen )) - $ix -= 1; // don't break inside '\n' - break; // always break while-loop here - } - else { - $byte = ord( $tmp[$ix] ); - if ($byte <= 127) { // add a one byte character - $string .= substr( $tmp, $ix, 1 ); - $charCnt += 1; - } - else if ($byte >= 194 && $byte <= 223) { // start byte in two byte character - $string .= substr( $tmp, $ix, 2 ); // add a two bytes character - $charCnt += 1; - } - else if ($byte >= 224 && $byte <= 239) { // start byte in three bytes character - $string .= substr( $tmp, $ix, 3 ); // add a three bytes character - $charCnt += 1; - } - else if ($byte >= 240 && $byte <= 244) { // start byte in four bytes character - $string .= substr( $tmp, $ix, 4 ); // add a four bytes character - $charCnt += 1; - } - } - } // end for - if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) - $string .= $this->nl; - if( FALSE === ( $tmp = substr( $tmp, $ix ))) - break; // while-loop breakes here - else - $tmp = ' '.$tmp; - } // end while - if( '\n'.$this->nl == substr( $string, ( 0 - strlen( '\n'.$this->nl )))) - $string = substr( $string, 0, ( strlen( $string ) - strlen( '\n'.$this->nl ))).$this->nl; - return $string; - } -/** - * special characters management output - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.15 - 2010-09-24 - * @param string $string - * @return string - */ - function _strrep( $string ) { - switch( $this->format ) { - case 'xcal': - $string = str_replace( '\n', $this->nl, $string); - $string = htmlspecialchars( strip_tags( stripslashes( urldecode ( $string )))); - break; - default: - $pos = 0; - $specChars = array( 'n', 'N', 'r', ',', ';' ); - while( $pos <= strlen( $string )) { - $pos = strpos( $string, "\\", $pos ); - if( FALSE === $pos ) - break; - if( !in_array( substr( $string, $pos, 1 ), $specChars )) { - $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 )); - $pos += 1; - } - $pos += 1; - } - if( FALSE !== strpos( $string, '"' )) - $string = str_replace('"', "'", $string); - if( FALSE !== strpos( $string, ',' )) - $string = str_replace(',', '\,', $string); - if( FALSE !== strpos( $string, ';' )) - $string = str_replace(';', '\;', $string); - - if( FALSE !== strpos( $string, "\r\n" )) - $string = str_replace( "\r\n", '\n', $string); - elseif( FALSE !== strpos( $string, "\r" )) - $string = str_replace( "\r", '\n', $string); - - elseif( FALSE !== strpos( $string, "\n" )) - $string = str_replace( "\n", '\n', $string); - - if( FALSE !== strpos( $string, '\N' )) - $string = str_replace( '\N', '\n', $string); -// if( FALSE !== strpos( $string, $this->nl )) - $string = str_replace( $this->nl, '\n', $string); - break; - } - return $string; - } -/** - * special characters management input (from iCal file) - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.22 - 2010-10-17 - * @param string $string - * @return string - */ - static function _strunrep( $string ) { - $string = str_replace( '\\\\', '\\', $string); - $string = str_replace( '\,', ',', $string); - $string = str_replace( '\;', ';', $string); -// $string = str_replace( '\n', $this->nl, $string); // ?? - return $string; - } -} -/*********************************************************************************/ -/*********************************************************************************/ -/** - * class for calendar component VEVENT - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-12 - */ -class vevent extends calendarComponent { - var $attach; - var $attendee; - var $categories; - var $comment; - var $contact; - var $class; - var $created; - var $description; - var $dtend; - var $dtstart; - var $duration; - var $exdate; - var $exrule; - var $geo; - var $lastmodified; - var $location; - var $organizer; - var $priority; - var $rdate; - var $recurrenceid; - var $relatedto; - var $requeststatus; - var $resources; - var $rrule; - var $sequence; - var $status; - var $summary; - var $transp; - var $url; - var $xprop; - // component subcomponents container - var $components; -/** - * constructor for calendar component VEVENT object - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.2 - 2011-05-01 - * @param array $config - * @return void - */ - function vevent( $config = array()) { - $this->calendarComponent(); - - $this->attach = ''; - $this->attendee = ''; - $this->categories = ''; - $this->class = ''; - $this->comment = ''; - $this->contact = ''; - $this->created = ''; - $this->description = ''; - $this->dtstart = ''; - $this->dtend = ''; - $this->duration = ''; - $this->exdate = ''; - $this->exrule = ''; - $this->geo = ''; - $this->lastmodified = ''; - $this->location = ''; - $this->organizer = ''; - $this->priority = ''; - $this->rdate = ''; - $this->recurrenceid = ''; - $this->relatedto = ''; - $this->requeststatus = ''; - $this->resources = ''; - $this->rrule = ''; - $this->sequence = ''; - $this->status = ''; - $this->summary = ''; - $this->transp = ''; - $this->url = ''; - $this->xprop = ''; - - $this->components = array(); - - if( defined( 'ICAL_LANG' ) && !isset( $config['language'] )) - $config['language'] = ICAL_LANG; - if( !isset( $config['allowEmpty'] )) $config['allowEmpty'] = TRUE; - if( !isset( $config['nl'] )) $config['nl'] = "\r\n"; - if( !isset( $config['format'] )) $config['format'] = 'iCal'; - if( !isset( $config['delimiter'] )) $config['delimiter'] = DIRECTORY_SEPARATOR; - $this->setConfig( $config ); - - } -/** - * create formatted output for calendar component VEVENT object instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.16 - 2011-10-28 - * @param array $xcaldecl - * @return string - */ - function createComponent( &$xcaldecl ) { - $objectname = $this->_createFormat(); - $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; - $component .= $this->createUid(); - $component .= $this->createDtstamp(); - $component .= $this->createAttach(); - $component .= $this->createAttendee(); - $component .= $this->createCategories(); - $component .= $this->createComment(); - $component .= $this->createContact(); - $component .= $this->createClass(); - $component .= $this->createCreated(); - $component .= $this->createDescription(); - $component .= $this->createDtstart(); - $component .= $this->createDtend(); - $component .= $this->createDuration(); - $component .= $this->createExdate(); - $component .= $this->createExrule(); - $component .= $this->createGeo(); - $component .= $this->createLastModified(); - $component .= $this->createLocation(); - $component .= $this->createOrganizer(); - $component .= $this->createPriority(); - $component .= $this->createRdate(); - $component .= $this->createRrule(); - $component .= $this->createRelatedTo(); - $component .= $this->createRequestStatus(); - $component .= $this->createRecurrenceid(); - $component .= $this->createResources(); - $component .= $this->createSequence(); - $component .= $this->createStatus(); - $component .= $this->createSummary(); - $component .= $this->createTransp(); - $component .= $this->createUrl(); - $component .= $this->createXprop(); - $component .= $this->createSubComponent(); - $component .= $this->componentEnd1.$objectname.$this->componentEnd2; - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { - foreach( $this->xcaldecl as $localxcaldecl ) - $xcaldecl[] = $localxcaldecl; - } - return $component; - } -} -/*********************************************************************************/ -/*********************************************************************************/ -/** - * class for calendar component VTODO - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-12 - */ -class vtodo extends calendarComponent { - var $attach; - var $attendee; - var $categories; - var $comment; - var $completed; - var $contact; - var $class; - var $created; - var $description; - var $dtstart; - var $due; - var $duration; - var $exdate; - var $exrule; - var $geo; - var $lastmodified; - var $location; - var $organizer; - var $percentcomplete; - var $priority; - var $rdate; - var $recurrenceid; - var $relatedto; - var $requeststatus; - var $resources; - var $rrule; - var $sequence; - var $status; - var $summary; - var $url; - var $xprop; - // component subcomponents container - var $components; -/** - * constructor for calendar component VTODO object - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.2 - 2011-05-01 - * @param array $config - * @return void - */ - function vtodo( $config = array()) { - $this->calendarComponent(); - - $this->attach = ''; - $this->attendee = ''; - $this->categories = ''; - $this->class = ''; - $this->comment = ''; - $this->completed = ''; - $this->contact = ''; - $this->created = ''; - $this->description = ''; - $this->dtstart = ''; - $this->due = ''; - $this->duration = ''; - $this->exdate = ''; - $this->exrule = ''; - $this->geo = ''; - $this->lastmodified = ''; - $this->location = ''; - $this->organizer = ''; - $this->percentcomplete = ''; - $this->priority = ''; - $this->rdate = ''; - $this->recurrenceid = ''; - $this->relatedto = ''; - $this->requeststatus = ''; - $this->resources = ''; - $this->rrule = ''; - $this->sequence = ''; - $this->status = ''; - $this->summary = ''; - $this->url = ''; - $this->xprop = ''; - - $this->components = array(); - - if( defined( 'ICAL_LANG' ) && !isset( $config['language'] )) - $config['language'] = ICAL_LANG; - if( !isset( $config['allowEmpty'] )) $config['allowEmpty'] = TRUE; - if( !isset( $config['nl'] )) $config['nl'] = "\r\n"; - if( !isset( $config['format'] )) $config['format'] = 'iCal'; - if( !isset( $config['delimiter'] )) $config['delimiter'] = DIRECTORY_SEPARATOR; - $this->setConfig( $config ); - - } -/** - * create formatted output for calendar component VTODO object instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-11-07 - * @param array $xcaldecl - * @return string - */ - function createComponent( &$xcaldecl ) { - $objectname = $this->_createFormat(); - $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; - $component .= $this->createUid(); - $component .= $this->createDtstamp(); - $component .= $this->createAttach(); - $component .= $this->createAttendee(); - $component .= $this->createCategories(); - $component .= $this->createClass(); - $component .= $this->createComment(); - $component .= $this->createCompleted(); - $component .= $this->createContact(); - $component .= $this->createCreated(); - $component .= $this->createDescription(); - $component .= $this->createDtstart(); - $component .= $this->createDue(); - $component .= $this->createDuration(); - $component .= $this->createExdate(); - $component .= $this->createExrule(); - $component .= $this->createGeo(); - $component .= $this->createLastModified(); - $component .= $this->createLocation(); - $component .= $this->createOrganizer(); - $component .= $this->createPercentComplete(); - $component .= $this->createPriority(); - $component .= $this->createRdate(); - $component .= $this->createRelatedTo(); - $component .= $this->createRequestStatus(); - $component .= $this->createRecurrenceid(); - $component .= $this->createResources(); - $component .= $this->createRrule(); - $component .= $this->createSequence(); - $component .= $this->createStatus(); - $component .= $this->createSummary(); - $component .= $this->createUrl(); - $component .= $this->createXprop(); - $component .= $this->createSubComponent(); - $component .= $this->componentEnd1.$objectname.$this->componentEnd2; - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { - foreach( $this->xcaldecl as $localxcaldecl ) - $xcaldecl[] = $localxcaldecl; - } - return $component; - } -} -/*********************************************************************************/ -/*********************************************************************************/ -/** - * class for calendar component VJOURNAL - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-12 - */ -class vjournal extends calendarComponent { - var $attach; - var $attendee; - var $categories; - var $comment; - var $contact; - var $class; - var $created; - var $description; - var $dtstart; - var $exdate; - var $exrule; - var $lastmodified; - var $organizer; - var $rdate; - var $recurrenceid; - var $relatedto; - var $requeststatus; - var $rrule; - var $sequence; - var $status; - var $summary; - var $url; - var $xprop; -/** - * constructor for calendar component VJOURNAL object - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.2 - 2011-05-01 - * @param array $config - * @return void - */ - function vjournal( $config = array()) { - $this->calendarComponent(); - - $this->attach = ''; - $this->attendee = ''; - $this->categories = ''; - $this->class = ''; - $this->comment = ''; - $this->contact = ''; - $this->created = ''; - $this->description = ''; - $this->dtstart = ''; - $this->exdate = ''; - $this->exrule = ''; - $this->lastmodified = ''; - $this->organizer = ''; - $this->rdate = ''; - $this->recurrenceid = ''; - $this->relatedto = ''; - $this->requeststatus = ''; - $this->rrule = ''; - $this->sequence = ''; - $this->status = ''; - $this->summary = ''; - $this->url = ''; - $this->xprop = ''; - - if( defined( 'ICAL_LANG' ) && !isset( $config['language'] )) - $config['language'] = ICAL_LANG; - if( !isset( $config['allowEmpty'] )) $config['allowEmpty'] = TRUE; - if( !isset( $config['nl'] )) $config['nl'] = "\r\n"; - if( !isset( $config['format'] )) $config['format'] = 'iCal'; - if( !isset( $config['delimiter'] )) $config['delimiter'] = DIRECTORY_SEPARATOR; - $this->setConfig( $config ); - - } -/** - * create formatted output for calendar component VJOURNAL object instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-12 - * @param array $xcaldecl - * @return string - */ - function createComponent( &$xcaldecl ) { - $objectname = $this->_createFormat(); - $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; - $component .= $this->createUid(); - $component .= $this->createDtstamp(); - $component .= $this->createAttach(); - $component .= $this->createAttendee(); - $component .= $this->createCategories(); - $component .= $this->createClass(); - $component .= $this->createComment(); - $component .= $this->createContact(); - $component .= $this->createCreated(); - $component .= $this->createDescription(); - $component .= $this->createDtstart(); - $component .= $this->createExdate(); - $component .= $this->createExrule(); - $component .= $this->createLastModified(); - $component .= $this->createOrganizer(); - $component .= $this->createRdate(); - $component .= $this->createRequestStatus(); - $component .= $this->createRecurrenceid(); - $component .= $this->createRelatedTo(); - $component .= $this->createRrule(); - $component .= $this->createSequence(); - $component .= $this->createStatus(); - $component .= $this->createSummary(); - $component .= $this->createUrl(); - $component .= $this->createXprop(); - $component .= $this->componentEnd1.$objectname.$this->componentEnd2; - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { - foreach( $this->xcaldecl as $localxcaldecl ) - $xcaldecl[] = $localxcaldecl; - } - return $component; - } -} -/*********************************************************************************/ -/*********************************************************************************/ -/** - * class for calendar component VFREEBUSY - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-12 - */ -class vfreebusy extends calendarComponent { - var $attendee; - var $comment; - var $contact; - var $dtend; - var $dtstart; - var $duration; - var $freebusy; - var $organizer; - var $requeststatus; - var $url; - var $xprop; - // component subcomponents container - var $components; -/** - * constructor for calendar component VFREEBUSY object - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.2 - 2011-05-01 - * @param array $config - * @return void - */ - function vfreebusy( $config = array()) { - $this->calendarComponent(); - - $this->attendee = ''; - $this->comment = ''; - $this->contact = ''; - $this->dtend = ''; - $this->dtstart = ''; - $this->duration = ''; - $this->freebusy = ''; - $this->organizer = ''; - $this->requeststatus = ''; - $this->url = ''; - $this->xprop = ''; - - if( defined( 'ICAL_LANG' ) && !isset( $config['language'] )) - $config['language'] = ICAL_LANG; - if( !isset( $config['allowEmpty'] )) $config['allowEmpty'] = TRUE; - if( !isset( $config['nl'] )) $config['nl'] = "\r\n"; - if( !isset( $config['format'] )) $config['format'] = 'iCal'; - if( !isset( $config['delimiter'] )) $config['delimiter'] = DIRECTORY_SEPARATOR; - $this->setConfig( $config ); - - } -/** - * create formatted output for calendar component VFREEBUSY object instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.3.1 - 2007-11-19 - * @param array $xcaldecl - * @return string - */ - function createComponent( &$xcaldecl ) { - $objectname = $this->_createFormat(); - $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; - $component .= $this->createUid(); - $component .= $this->createDtstamp(); - $component .= $this->createAttendee(); - $component .= $this->createComment(); - $component .= $this->createContact(); - $component .= $this->createDtstart(); - $component .= $this->createDtend(); - $component .= $this->createDuration(); - $component .= $this->createFreebusy(); - $component .= $this->createOrganizer(); - $component .= $this->createRequestStatus(); - $component .= $this->createUrl(); - $component .= $this->createXprop(); - $component .= $this->componentEnd1.$objectname.$this->componentEnd2; - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { - foreach( $this->xcaldecl as $localxcaldecl ) - $xcaldecl[] = $localxcaldecl; - } - return $component; - } -} -/*********************************************************************************/ -/*********************************************************************************/ -/** - * class for calendar component VALARM - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-12 - */ -class valarm extends calendarComponent { - var $action; - var $attach; - var $attendee; - var $description; - var $duration; - var $repeat; - var $summary; - var $trigger; - var $xprop; -/** - * constructor for calendar component VALARM object - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.2 - 2011-05-01 - * @param array $config - * @return void - */ - function valarm( $config = array()) { - $this->calendarComponent(); - - $this->action = ''; - $this->attach = ''; - $this->attendee = ''; - $this->description = ''; - $this->duration = ''; - $this->repeat = ''; - $this->summary = ''; - $this->trigger = ''; - $this->xprop = ''; - - if( defined( 'ICAL_LANG' ) && !isset( $config['language'] )) - $config['language'] = ICAL_LANG; - if( !isset( $config['allowEmpty'] )) $config['allowEmpty'] = TRUE; - if( !isset( $config['nl'] )) $config['nl'] = "\r\n"; - if( !isset( $config['format'] )) $config['format'] = 'iCal'; - if( !isset( $config['delimiter'] )) $config['delimiter'] = DIRECTORY_SEPARATOR; - $this->setConfig( $config ); - - } -/** - * create formatted output for calendar component VALARM object instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-22 - * @param array $xcaldecl - * @return string - */ - function createComponent( &$xcaldecl ) { - $objectname = $this->_createFormat(); - $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; - $component .= $this->createAction(); - $component .= $this->createAttach(); - $component .= $this->createAttendee(); - $component .= $this->createDescription(); - $component .= $this->createDuration(); - $component .= $this->createRepeat(); - $component .= $this->createSummary(); - $component .= $this->createTrigger(); - $component .= $this->createXprop(); - $component .= $this->componentEnd1.$objectname.$this->componentEnd2; - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { - foreach( $this->xcaldecl as $localxcaldecl ) - $xcaldecl[] = $localxcaldecl; - } - return $component; - } -} -/********************************************************************************** -/*********************************************************************************/ -/** - * class for calendar component VTIMEZONE - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-12 - */ -class vtimezone extends calendarComponent { - var $timezonetype; - - var $comment; - var $dtstart; - var $lastmodified; - var $rdate; - var $rrule; - var $tzid; - var $tzname; - var $tzoffsetfrom; - var $tzoffsetto; - var $tzurl; - var $xprop; - // component subcomponents container - var $components; -/** - * constructor for calendar component VTIMEZONE object - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.2 - 2011-05-01 - * @param mixed $timezonetype optional, default FALSE ( STANDARD / DAYLIGHT ) - * @param array $config - * @return void - */ - function vtimezone( $timezonetype=FALSE, $config = array()) { - if( is_array( $timezonetype )) { - $config = $timezonetype; - $timezonetype = FALSE; - } - if( !$timezonetype ) - $this->timezonetype = 'VTIMEZONE'; - else - $this->timezonetype = strtoupper( $timezonetype ); - $this->calendarComponent(); - - $this->comment = ''; - $this->dtstart = ''; - $this->lastmodified = ''; - $this->rdate = ''; - $this->rrule = ''; - $this->tzid = ''; - $this->tzname = ''; - $this->tzoffsetfrom = ''; - $this->tzoffsetto = ''; - $this->tzurl = ''; - $this->xprop = ''; - - $this->components = array(); - - if( defined( 'ICAL_LANG' ) && !isset( $config['language'] )) - $config['language'] = ICAL_LANG; - if( !isset( $config['allowEmpty'] )) $config['allowEmpty'] = TRUE; - if( !isset( $config['nl'] )) $config['nl'] = "\r\n"; - if( !isset( $config['format'] )) $config['format'] = 'iCal'; - if( !isset( $config['delimiter'] )) $config['delimiter'] = DIRECTORY_SEPARATOR; - $this->setConfig( $config ); - - } -/** - * create formatted output for calendar component VTIMEZONE object instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.5.1 - 2008-10-25 - * @param array $xcaldecl - * @return string - */ - function createComponent( &$xcaldecl ) { - $objectname = $this->_createFormat(); - $component = $this->componentStart1.$objectname.$this->componentStart2.$this->nl; - $component .= $this->createTzid(); - $component .= $this->createLastModified(); - $component .= $this->createTzurl(); - $component .= $this->createDtstart(); - $component .= $this->createTzoffsetfrom(); - $component .= $this->createTzoffsetto(); - $component .= $this->createComment(); - $component .= $this->createRdate(); - $component .= $this->createRrule(); - $component .= $this->createTzname(); - $component .= $this->createXprop(); - $component .= $this->createSubComponent(); - $component .= $this->componentEnd1.$objectname.$this->componentEnd2; - if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) { - foreach( $this->xcaldecl as $localxcaldecl ) - $xcaldecl[] = $localxcaldecl; - } - return $component; - } -} -/*********************************************************************************/ -/*********************************************************************************/ -/** - * moving all utility (static) functions to a utility class - * 20111223 - move iCalUtilityFunctions class to the end of the iCalcreator class file - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.1 - 2011-07-16 - * - */ -class iCalUtilityFunctions { - // Store the single instance of iCalUtilityFunctions - private static $m_pInstance; - - // Private constructor to limit object instantiation to within the class - private function __construct() { - $m_pInstance = FALSE; - } - - // Getter method for creating/returning the single instance of this class - public static function getInstance() { - if (!self::$m_pInstance) - self::$m_pInstance = new iCalUtilityFunctions(); - - return self::$m_pInstance; - } -/** - * check a date(-time) for an opt. timezone and if it is a DATE-TIME or DATE - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.30 - 2012-01-16 - * @param array $date, date to check - * @param int $parno, no of date parts (i.e. year, month.. .) - * @return array $params, property parameters - */ - public static function _chkdatecfg( $theDate, & $parno, & $params ) { - if( isset( $params['TZID'] )) - $parno = 6; - elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) - $parno = 3; - else { - if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) - $parno = 7; - if( is_array( $theDate )) { - if( isset( $theDate['timestamp'] )) - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null; - else - $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null; - if( !empty( $tzid )) { - $parno = 7; - if( !iCalUtilityFunctions::_isOffset( $tzid )) - $params['TZID'] = $tzid; // save only timezone - } - elseif( !$parno && ( 3 == count( $theDate )) && - ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) - $parno = 3; - else - $parno = 6; - } - else { // string - $date = trim( $theDate ); - if( 'Z' == substr( $date, -1 )) - $parno = 7; // UTC DATE-TIME - elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) && - ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) - $parno = 3; // DATE - $date = iCalUtilityFunctions::_date_time_string( $date, $parno ); - unset( $date['unparsedtext'] ); - if( !empty( $date['tz'] )) { - $parno = 7; - if( !iCalUtilityFunctions::_isOffset( $date['tz'] )) - $params['TZID'] = $date['tz']; // save only timezone - } - elseif( empty( $parno )) - $parno = 6; - } - if( isset( $params['TZID'] )) - $parno = 6; - } - } -/** - * create timezone and standard/daylight components - * - * Result when 'Europe/Stockholm' and no from/to arguments is used as timezone: - * - * BEGIN:VTIMEZONE - * TZID:Europe/Stockholm - * BEGIN:STANDARD - * DTSTART:20101031T020000 - * TZOFFSETFROM:+0200 - * TZOFFSETTO:+0100 - * TZNAME:CET - * END:STANDARD - * BEGIN:DAYLIGHT - * DTSTART:20100328T030000 - * TZOFFSETFROM:+0100 - * TZOFFSETTO:+0200 - * TZNAME:CEST - * END:DAYLIGHT - * END:VTIMEZONE - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.8 - 2012-02-06 - * Generates components for all transitions in a date range, based on contribution by Yitzchok Lavi - * @param object $calendar, reference to an iCalcreator calendar instance - * @param string $timezone, a PHP5 (DateTimeZone) valid timezone - * @param array $xProp, *[x-propName => x-propValue], optional - * @param int $from an unix timestamp - * @param int $to an unix timestamp - * @return bool - */ - public static function createTimezone( & $calendar, $timezone, $xProp=array(), $from=null, $to=null ) { - if( !class_exists( 'DateTimeZone' )) - return FALSE; - if( empty( $timezone )) - return FALSE; - try { - $dtz = new DateTimeZone( $timezone ); - $transitions = $dtz->getTransitions(); - unset( $dtz ); - $utcTz = new DateTimeZone( 'UTC' ); - } - catch( Exception $e ) { - return FALSE; - } - if( empty( $to )) - $dates = array_keys( $calendar->getProperty( 'dtstart' )); - $transCnt = 2; // number of transitions in output if empty input $from/$to and an empty dates-array - $dateFrom = new DateTime( 'now' ); - $dateTo = new DateTime( 'now' ); - if( !empty( $from )) - $dateFrom->setTimestamp( $from ); - else { - if( !empty( $dates )) - $dateFrom = new DateTime( reset( $dates )); // set lowest date to the lowest dtstart date - $dateFrom->modify( '-1 month' ); // set $dateFrom to one month before the lowest date - } - $dateFrom->setTimezone( $utcTz ); // convert local date to UTC - if( !empty( $to )) - $dateTo->setTimestamp( $to ); - else { - if( !empty( $dates )) { - $dateTo = new DateTime( end( $dates )); // set highest date to the highest dtstart date - $to = $dateTo->getTimestamp(); // set mark that a highest date is found - } - $dateTo->modify( '+1 year' ); // set $dateTo to one year after the highest date - } - $dateTo->setTimezone( $utcTz ); // convert local date to UTC - $transTemp = array(); - $prevOffsetfrom = $stdCnt = $dlghtCnt = 0; - $stdIx = $dlghtIx = null; - $date = new DateTime( 'now', $utcTz ); - foreach( $transitions as $tix => $trans ) { // all transitions in date-time order!! - $date->setTimestamp( $trans['ts'] ); // set transition date (UTC) - if ( $date < $dateFrom ) { - $prevOffsetfrom = $trans['offset']; // previous trans offset will be 'next' trans offsetFrom - continue; - } - if( $date > $dateTo ) - break; // loop always (?) breaks here - if( !empty( $prevOffsetfrom ) || ( 0 == $prevOffsetfrom )) { - $trans['offsetfrom'] = $prevOffsetfrom; // i.e. set previous offsetto as offsetFrom - $date->modify( $trans['offsetfrom'].'seconds' ); // convert utc date to local date - $trans['time'] = array( 'year' => $date->format( 'Y' ) // set dtstart to array to ease up dtstart and (opt) rdate setting - , 'month' => $date->format( 'n' ) - , 'day' => $date->format( 'j' ) - , 'hour' => $date->format( 'G' ) - , 'min' => $date->format( 'i' ) - , 'sec' => $date->format( 's' )); - } - $prevOffsetfrom = $trans['offset']; - $trans['prevYear'] = $trans['time']['year']; - if( TRUE !== $trans['isdst'] ) { // standard timezone - if( !empty( $stdIx ) && isset( $transTemp[$stdIx]['offsetfrom'] ) && // check for any rdate's (in strict year order) - ( $transTemp[$stdIx]['abbr'] == $trans['abbr'] ) && - ( $transTemp[$stdIx]['offsetfrom'] == $trans['offsetfrom'] ) && - ( $transTemp[$stdIx]['offset'] == $trans['offset'] ) && - (($transTemp[$stdIx]['prevYear'] + 1) == $trans['time']['year'] )) { - $transTemp[$stdIx]['prevYear'] = $trans['time']['year']; - $transTemp[$stdIx]['rdate'][] = $trans['time']; - continue; - } - $stdIx = $tix; - $stdCnt += 1; - } // end standard timezone - else { // daylight timezone - if( !empty( $dlghtIx ) && isset( $transTemp[$dlghtIx]['offsetfrom'] ) && // check for any rdate's (in strict year order) - ( $transTemp[$dlghtIx]['abbr'] == $trans['abbr'] ) && - ( $transTemp[$dlghtIx]['offsetfrom'] == $trans['offsetfrom'] ) && - ( $transTemp[$dlghtIx]['offset'] == $trans['offset'] ) && - (($transTemp[$dlghtIx]['prevYear'] + 1) == $trans['time']['year'] )) { - $transTemp[$dlghtIx]['prevYear'] = $trans['time']['year']; - $transTemp[$dlghtIx]['rdate'][] = $trans['time']; - continue; - } - $dlghtIx = $tix; - $dlghtCnt += 1; - } // end daylight timezone - if( empty( $to ) && ( $transCnt == count( $transTemp ))) { // store only $transCnt transitions - if( TRUE !== $transTemp[0]['isdst'] ) - $stdCnt -= 1; - else - $dlghtCnt -= 1; - array_shift( $transTemp ); - } // end if( empty( $to ) && ( $transCnt == count( $transTemp ))) - $transTemp[$tix] = $trans; - } // end foreach( $transitions as $tix => $trans ) - unset( $transitions ); - if( empty( $transTemp )) - return FALSE; - $tz = & $calendar->newComponent( 'vtimezone' ); - $tz->setproperty( 'tzid', $timezone ); - if( !empty( $xProp )) { - foreach( $xProp as $xPropName => $xPropValue ) - if( 'x-' == strtolower( substr( $xPropName, 0, 2 ))) - $tz->setproperty( $xPropName, $xPropValue ); - } - foreach( $transTemp as $trans ) { - $type = ( TRUE !== $trans['isdst'] ) ? 'standard' : 'daylight'; - $scomp = & $tz->newComponent( $type ); - $scomp->setProperty( 'dtstart', $trans['time'] ); -// $scomp->setProperty( 'x-utc-timestamp', $trans['ts'] ); // test ### - if( !empty( $trans['abbr'] )) - $scomp->setProperty( 'tzname', $trans['abbr'] ); - $scomp->setProperty( 'tzoffsetfrom', iCalUtilityFunctions::offsetSec2His( $trans['offsetfrom'] )); - $scomp->setProperty( 'tzoffsetto', iCalUtilityFunctions::offsetSec2His( $trans['offset'] )); - if( isset( $trans['rdate'] )) - $scomp->setProperty( 'RDATE', $trans['rdate'] ); - } - return TRUE; - } -/** - * convert a date/datetime (array) to timestamp - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.8 - 2008-10-30 - * @param array $datetime datetime/(date) - * @param string $tz timezone - * @return timestamp - */ - public static function _date2timestamp( $datetime, $tz=null ) { - $output = null; - if( !isset( $datetime['hour'] )) $datetime['hour'] = '0'; - if( !isset( $datetime['min'] )) $datetime['min'] = '0'; - if( !isset( $datetime['sec'] )) $datetime['sec'] = '0'; - foreach( $datetime as $dkey => $dvalue ) { - if( 'tz' != $dkey ) - $datetime[$dkey] = (integer) $dvalue; - } - if( $tz ) - $datetime['tz'] = $tz; - $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? iCalUtilityFunctions::_tz2offset( $datetime['tz'] ) : 0; - $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] ); - return $output; - } -/** - * ensures internal date-time/date format for input date-time/date in array format - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.4 - 2012-03-18 - * @param array $datetime - * @param int $parno optional, default FALSE - * @return array - */ - public static function _date_time_array( $datetime, $parno=FALSE ) { - $output = array(); - foreach( $datetime as $dateKey => $datePart ) { - switch ( $dateKey ) { - case '0': case 'year': $output['year'] = $datePart; break; - case '1': case 'month': $output['month'] = $datePart; break; - case '2': case 'day': $output['day'] = $datePart; break; - } - if( 3 != $parno ) { - switch ( $dateKey ) { - case '0': - case '1': - case '2': break; - case '3': case 'hour': $output['hour'] = $datePart; break; - case '4': case 'min' : $output['min'] = $datePart; break; - case '5': case 'sec' : $output['sec'] = $datePart; break; - case '6': case 'tz' : $output['tz'] = $datePart; break; - } - } - } - if( 3 != $parno ) { - if( !isset( $output['hour'] )) - $output['hour'] = 0; - if( !isset( $output['min'] )) - $output['min'] = 0; - if( !isset( $output['sec'] )) - $output['sec'] = 0; - if( isset( $output['tz'] ) && ( 'Z' != $output['tz'] ) && - (( '+0000' == $output['tz'] ) || ( '-0000' == $output['tz'] ) || ( '+000000' == $output['tz'] ) || ( '-000000' == $output['tz'] ))) - $output['tz'] = 'Z'; - } - return $output; - } -/** - * ensures internal date-time/date format for input date-time/date in string fromat - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.30 - 2012-01-06 - * Modified to also return original string value by Yitzchok Lavi - * @param array $datetime - * @param int $parno optional, default FALSE - * @return array - */ - public static function _date_time_string( $datetime, $parno=FALSE ) { - // save original input string to return it later - $unparseddatetime = $datetime; - $datetime = (string) trim( $datetime ); - $tz = null; - $len = strlen( $datetime ) - 1; - if( 'Z' == substr( $datetime, -1 )) { - $tz = 'Z'; - $datetime = trim( substr( $datetime, 0, $len )); - } - elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date - ( '-' == substr( $datetime, -3, 1 )) || - ( ':' == substr( $datetime, -3, 1 )) || - ( '.' == substr( $datetime, -3, 1 ))) { - $continue = TRUE; - } - elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset - ( ' +' == substr( $datetime, -6, 2 )) || - ( ' -' == substr( $datetime, -6, 2 ))) { - $tz = substr( $datetime, -5, 5 ); - $datetime = substr( $datetime, 0, ($len - 5)); - } - elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset - ( ' +' == substr( $datetime, -8, 2 )) || - ( ' -' == substr( $datetime, -8, 2 ))) { - $tz = substr( $datetime, -7, 7 ); - $datetime = substr( $datetime, 0, ($len - 7)); - } - elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) { - $continue = TRUE; - } - elseif( 'T' == substr( $datetime, -7, 1 )) { - $continue = TRUE; - } - else { - $cx = $tx = 0; // 19970415T133000 US-Eastern - for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) { - $char = substr( $datetime, $cx, 1 ); - if(( ' ' == $char) || ctype_digit( $char)) - break; // if exists, tz ends here.. . ? - else - $tx--; // tz length counter - } - if( 0 > $tx ) { - $tz = substr( $datetime, $tx ); - $datetime = trim( substr( $datetime, 0, $len + $tx + 1 )); - } - } - if( 0 < substr_count( $datetime, '-' )) { - $datetime = str_replace( '-', '/', $datetime ); - } - elseif( ctype_digit( substr( $datetime, 0, 8 )) && - ( 'T' == substr( $datetime, 8, 1 )) && - ctype_digit( substr( $datetime, 9, 6 ))) { - } - $datestring = date( 'Y-m-d H:i:s', strtotime( $datetime )); - $tz = trim( $tz ); - $output = array(); - $output['year'] = substr( $datestring, 0, 4 ); - $output['month'] = substr( $datestring, 5, 2 ); - $output['day'] = substr( $datestring, 8, 2 ); - if(( 6 == $parno ) || ( 7 == $parno ) || ( !$parno && ( 'Z' == $tz ))) { - $output['hour'] = substr( $datestring, 11, 2 ); - $output['min'] = substr( $datestring, 14, 2 ); - $output['sec'] = substr( $datestring, 17, 2 ); - if( !empty( $tz )) - $output['tz'] = $tz; - } - elseif( 3 != $parno ) { - if(( '00' < substr( $datestring, 11, 2 )) || - ( '00' < substr( $datestring, 14, 2 )) || - ( '00' < substr( $datestring, 17, 2 ))) { - $output['hour'] = substr( $datestring, 11, 2 ); - $output['min'] = substr( $datestring, 14, 2 ); - $output['sec'] = substr( $datestring, 17, 2 ); - } - if( !empty( $tz )) - $output['tz'] = $tz; - } - // return original string in the array in case strtotime failed to make sense of it - $output['unparsedtext'] = $unparseddatetime; - return $output; - } -/** - * convert local startdate/enddate (Ymd[His]) to duration array - * - * uses this component dates if missing input dates - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.11 - 2010-10-21 - * @param array $startdate - * @param array $duration - * @return array duration - */ - public static function _date2duration( $startdate, $enddate ) { - $startWdate = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] ); - $endWdate = mktime( 0, 0, 0, $enddate['month'], $enddate['day'], $enddate['year'] ); - $wduration = $endWdate - $startWdate; - $dur = array(); - $dur['week'] = (int) floor( $wduration / ( 7 * 24 * 60 * 60 )); - $wduration = $wduration % ( 7 * 24 * 60 * 60 ); - $dur['day'] = (int) floor( $wduration / ( 24 * 60 * 60 )); - $wduration = $wduration % ( 24 * 60 * 60 ); - $dur['hour'] = (int) floor( $wduration / ( 60 * 60 )); - $wduration = $wduration % ( 60 * 60 ); - $dur['min'] = (int) floor( $wduration / ( 60 )); - $dur['sec'] = (int) $wduration % ( 60 ); - return $dur; - } -/** - * ensures internal duration format for input in array format - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.1.1 - 2007-06-24 - * @param array $duration - * @return array - */ - public static function _duration_array( $duration ) { - $output = array(); - if( is_array( $duration ) && - ( 1 == count( $duration )) && - isset( $duration['sec'] ) && - ( 60 < $duration['sec'] )) { - $durseconds = $duration['sec']; - $output['week'] = floor( $durseconds / ( 60 * 60 * 24 * 7 )); - $durseconds = $durseconds % ( 60 * 60 * 24 * 7 ); - $output['day'] = floor( $durseconds / ( 60 * 60 * 24 )); - $durseconds = $durseconds % ( 60 * 60 * 24 ); - $output['hour'] = floor( $durseconds / ( 60 * 60 )); - $durseconds = $durseconds % ( 60 * 60 ); - $output['min'] = floor( $durseconds / ( 60 )); - $output['sec'] = ( $durseconds % ( 60 )); - } - else { - foreach( $duration as $durKey => $durValue ) { - if( empty( $durValue )) continue; - switch ( $durKey ) { - case '0': case 'week': $output['week'] = $durValue; break; - case '1': case 'day': $output['day'] = $durValue; break; - case '2': case 'hour': $output['hour'] = $durValue; break; - case '3': case 'min': $output['min'] = $durValue; break; - case '4': case 'sec': $output['sec'] = $durValue; break; - } - } - } - if( isset( $output['week'] ) && ( 0 < $output['week'] )) { - unset( $output['day'], $output['hour'], $output['min'], $output['sec'] ); - return $output; - } - unset( $output['week'] ); - if( empty( $output['day'] )) - unset( $output['day'] ); - if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) { - if( !isset( $output['hour'] )) $output['hour'] = 0; - if( !isset( $output['min'] )) $output['min'] = 0; - if( !isset( $output['sec'] )) $output['sec'] = 0; - if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) - unset( $output['hour'], $output['min'], $output['sec'] ); - } - return $output; - } -/** - * ensures internal duration format for input in string format - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.0.5 - 2007-03-14 - * @param string $duration - * @return array - */ - public static function _duration_string( $duration ) { - $duration = (string) trim( $duration ); - while( 'P' != strtoupper( substr( $duration, 0, 1 ))) { - if( 0 < strlen( $duration )) - $duration = substr( $duration, 1 ); - else - return false; // no leading P !?!? - } - $duration = substr( $duration, 1 ); // skip P - $duration = str_replace ( 't', 'T', $duration ); - $duration = str_replace ( 'T', '', $duration ); - $output = array(); - $val = null; - for( $ix=0; $ix < strlen( $duration ); $ix++ ) { - switch( strtoupper( substr( $duration, $ix, 1 ))) { - case 'W': - $output['week'] = $val; - $val = null; - break; - case 'D': - $output['day'] = $val; - $val = null; - break; - case 'H': - $output['hour'] = $val; - $val = null; - break; - case 'M': - $output['min'] = $val; - $val = null; - break; - case 'S': - $output['sec'] = $val; - $val = null; - break; - default: - if( !ctype_digit( substr( $duration, $ix, 1 ))) - return false; // unknown duration control character !?!? - else - $val .= substr( $duration, $ix, 1 ); - } - } - return iCalUtilityFunctions::_duration_array( $output ); - } -/** - * convert duration to date in array format - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.8.7 - 2011-03-03 - * @param array $startdate - * @param array $duration - * @return array, date format - */ - public static function _duration2date( $startdate=null, $duration=null ) { - if( empty( $startdate )) return FALSE; - if( empty( $duration )) return FALSE; - $dateOnly = ( isset( $startdate['hour'] ) || isset( $startdate['min'] ) || isset( $startdate['sec'] )) ? FALSE : TRUE; - $startdate['hour'] = ( isset( $startdate['hour'] )) ? $startdate['hour'] : 0; - $startdate['min'] = ( isset( $startdate['min'] )) ? $startdate['min'] : 0; - $startdate['sec'] = ( isset( $startdate['sec'] )) ? $startdate['sec'] : 0; - $dtend = 0; - if( isset( $duration['week'] )) - $dtend += ( $duration['week'] * 7 * 24 * 60 * 60 ); - if( isset( $duration['day'] )) - $dtend += ( $duration['day'] * 24 * 60 * 60 ); - if( isset( $duration['hour'] )) - $dtend += ( $duration['hour'] * 60 *60 ); - if( isset( $duration['min'] )) - $dtend += ( $duration['min'] * 60 ); - if( isset( $duration['sec'] )) - $dtend += $duration['sec']; - $dtend = mktime( $startdate['hour'], $startdate['min'], ( $startdate['sec'] + $dtend ), $startdate['month'], $startdate['day'], $startdate['year'] ); - $dtend2 = array(); - $dtend2['year'] = date('Y', $dtend ); - $dtend2['month'] = date('m', $dtend ); - $dtend2['day'] = date('d', $dtend ); - $dtend2['hour'] = date('H', $dtend ); - $dtend2['min'] = date('i', $dtend ); - $dtend2['sec'] = date('s', $dtend ); - if( isset( $startdate['tz'] )) - $dtend2['tz'] = $startdate['tz']; - if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) - unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] ); - return $dtend2; - } -/** - * if not preSet, if exist, remove key with expected value from array and return hit value else return elseValue - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.16 - 2008-11-08 - * @param array $array - * @param string $expkey, expected key - * @param string $expval, expected value - * @param int $hitVal optional, return value if found - * @param int $elseVal optional, return value if not found - * @param int $preSet optional, return value if already preset - * @return int - */ - public static function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) { - if( $preSet ) - return $preSet; - if( !is_array( $array ) || ( 0 == count( $array ))) - return $elseVal; - foreach( $array as $key => $value ) { - if( strtoupper( $expkey ) == strtoupper( $key )) { - if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) { - unset( $array[$key] ); - return $hitVal; - } - } - } - return $elseVal; - } -/** - * creates formatted output for calendar component property data value type date/date-time - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.8 - 2012-03-17 - * @param array $datetime - * @param int $parno, optional, default 6 - * @return string - */ - public static function _format_date_time( $datetime, $parno=6 ) { - if( !isset( $datetime['year'] ) && - !isset( $datetime['month'] ) && - !isset( $datetime['day'] ) && - !isset( $datetime['hour'] ) && - !isset( $datetime['min'] ) && - !isset( $datetime['sec'] )) - return ; - $output = null; - foreach( $datetime as $dkey => & $dvalue ) - if( 'tz' != $dkey ) $dvalue = (integer) $dvalue; - $output = sprintf( '%04d%02d%02d', $datetime['year'], $datetime['month'], $datetime['day'] ); - if( isset( $datetime['hour'] ) || - isset( $datetime['min'] ) || - isset( $datetime['sec'] ) || - isset( $datetime['tz'] )) { - if( isset( $datetime['tz'] ) && - !isset( $datetime['hour'] )) - $datetime['hour'] = 0; - if( isset( $datetime['hour'] ) && - !isset( $datetime['min'] )) - $datetime['min'] = 0; - if( isset( $datetime['hour'] ) && - isset( $datetime['min'] ) && - !isset( $datetime['sec'] )) - $datetime['sec'] = 0; - $output .= sprintf( 'T%02d%02d%02d', $datetime['hour'], $datetime['min'], $datetime['sec'] ); - if( isset( $datetime['tz'] ) && ( '' < trim( $datetime['tz'] ))) { - $datetime['tz'] = trim( $datetime['tz'] ); - if( 'Z' == $datetime['tz'] ) - $output .= 'Z'; - $offset = iCalUtilityFunctions::_tz2offset( $datetime['tz'] ); - if( 0 != $offset ) { - $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] - $offset), $datetime['month'], $datetime['day'], $datetime['year']); - $output = date( 'Ymd\THis\Z', $date ); - } - } - elseif( 7 == $parno ) - $output .= 'Z'; - } - return $output; - } -/** - * creates formatted output for calendar component property data value type duration - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.9.9 - 2011-06-17 - * @param array $duration ( week, day, hour, min, sec ) - * @return string - */ - public static function _format_duration( $duration ) { - if( isset( $duration['week'] ) || - isset( $duration['day'] ) || - isset( $duration['hour'] ) || - isset( $duration['min'] ) || - isset( $duration['sec'] )) - $ok = TRUE; - else - return; - if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) - return 'P'.$duration['week'].'W'; - $output = 'P'; - if( isset($duration['day'] ) && ( 0 < $duration['day'] )) - $output .= $duration['day'].'D'; - if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) || - ( isset( $duration['min']) && ( 0 < $duration['min'] )) || - ( isset( $duration['sec']) && ( 0 < $duration['sec'] ))) - $output .= 'T'; - $output .= ( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ? $duration['hour'].'H' : ''; - $output .= ( isset( $duration['min']) && ( 0 < $duration['min'] )) ? $duration['min']. 'M' : ''; - $output .= ( isset( $duration['sec']) && ( 0 < $duration['sec'] )) ? $duration['sec']. 'S' : ''; - if( 'P' == $output ) - $output = 'PT0S'; - return $output; - } -/** - * checks if input array contains a date - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.8 - 2012-01-20 - * @param array $input - * @return bool - */ - public static function _isArrayDate( $input ) { - if( !is_array( $input )) - return FALSE; - if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) - return FALSE; - if( 7 == count( $input )) - return TRUE; - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); - if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) - return FALSE; - if( in_array( 0, $input )) - return FALSE; - if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) - return FALSE; - if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) && - checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) - return TRUE; - $input = iCalUtilityFunctions::_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); // m - d - Y - if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) - return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] ); - return FALSE; - } -/** - * checks if input array contains a timestamp date - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.16 - 2008-10-18 - * @param array $input - * @return bool - */ - public static function _isArrayTimestampDate( $input ) { - return ( is_array( $input ) && isset( $input['timestamp'] )) ? TRUE : FALSE ; - } -/** - * controll if input string contains trailing UTC offset - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.16 - 2008-10-19 - * @param string $input - * @return bool - */ - public static function _isOffset( $input ) { - $input = trim( (string) $input ); - if( 'Z' == substr( $input, -1 )) - return TRUE; - elseif(( 5 <= strlen( $input )) && - ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) && - ( '0000' < substr( $input, -4 )) && ( '9999' >= substr( $input, -4 ))) - return TRUE; - elseif(( 7 <= strlen( $input )) && - ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) - return TRUE; - return FALSE; - } -/** - * (very simple) conversion of a MS timezone to a PHP5 valid (Date-)timezone - * matching (MS) UCT offset and time zone descriptors - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.29 - 2012-01-11 - * @param string $timezone, input/output variable reference - * @return bool - */ - public static function ms2phpTZ( & $timezone ) { - if( !class_exists( 'DateTimeZone' )) - return FALSE; - if( empty( $timezone )) - return FALSE; - $search = str_replace( '"', '', $timezone ); - $search = str_replace( array('GMT', 'gmt', 'utc' ), 'UTC', $search ); - if( '(UTC' != substr( $search, 0, 4 )) - return FALSE; - if( FALSE === ( $pos = strpos( $search, ')' ))) - return FALSE; - $pos = strpos( $search, ')' ); - $searchOffset = substr( $search, 4, ( $pos - 4 )); - $searchOffset = iCalUtilityFunctions::_tz2offset( str_replace( ':', '', $searchOffset )); - while( ' ' ==substr( $search, ( $pos + 1 ))) - $pos += 1; - $searchText = trim( str_replace( array( '(', ')', '&', ',', ' ' ), ' ', substr( $search, ( $pos + 1 )) )); - $searchWords = explode( ' ', $searchText ); - $timezone_abbreviations = DateTimeZone::listAbbreviations(); - $hits = array(); - foreach( $timezone_abbreviations as $name => $transitions ) { - foreach( $transitions as $cnt => $transition ) { - if( empty( $transition['offset'] ) || - empty( $transition['timezone_id'] ) || - ( $transition['offset'] != $searchOffset )) - continue; - $cWords = explode( '/', $transition['timezone_id'] ); - $cPrio = $hitCnt = $rank = 0; - foreach( $cWords as $cWord ) { - if( empty( $cWord )) - continue; - $cPrio += 1; - $sPrio = 0; - foreach( $searchWords as $sWord ) { - if( empty( $sWord ) || ( 'time' == strtolower( $sWord ))) - continue; - $sPrio += 1; - if( strtolower( $cWord ) == strtolower( $sWord )) { - $hitCnt += 1; - $rank += ( $cPrio + $sPrio ); - } - else - $rank += 10; - } - } - if( 0 < $hitCnt ) { - $hits[$rank][] = $transition['timezone_id']; - } - } - } - unset( $timezone_abbreviations ); - if( empty( $hits )) - return FALSE; - ksort( $hits ); - foreach( $hits as $rank => $tzs ) { - if( !empty( $tzs )) { - $timezone = reset( $tzs ); - return TRUE; - } - } - return FALSE; - } -/** - * transform offset in seconds to [-/+]hhmm[ss] - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2011-05-02 - * @param string $seconds - * @return string - */ - public static function offsetSec2His( $seconds ) { - if( '-' == substr( $seconds, 0, 1 )) { - $prefix = '-'; - $seconds = substr( $seconds, 1 ); - } - elseif( '+' == substr( $seconds, 0, 1 )) { - $prefix = '+'; - $seconds = substr( $seconds, 1 ); - } - else - $prefix = '+'; - $output = ''; - $hour = (int) floor( $seconds / 3600 ); - if( 10 > $hour ) - $hour = '0'.$hour; - $seconds = $seconds % 3600; - $min = (int) floor( $seconds / 60 ); - if( 10 > $min ) - $min = '0'.$min; - $output = $hour.$min; - $seconds = $seconds % 60; - if( 0 < $seconds) { - if( 9 < $seconds) - $output .= $seconds; - else - $output .= '0'.$seconds; - } - return $prefix.$output; - } -/** - * remakes a recur pattern to an array of dates - * - * if missing, UNTIL is set 1 year from startdate (emergency break) - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.10.19 - 2011-10-31 - * @param array $result, array to update, array([timestamp] => timestamp) - * @param array $recur, pattern for recurrency (only value part, params ignored) - * @param array $wdate, component start date - * @param array $startdate, start date - * @param array $enddate, optional - * @return array of recurrence (start-)dates as index - * @todo BYHOUR, BYMINUTE, BYSECOND, WEEKLY at year end/start - */ - public static function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) { - foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v; - $wdateStart = $wdate; - $wdatets = iCalUtilityFunctions::_date2timestamp( $wdate ); - $startdatets = iCalUtilityFunctions::_date2timestamp( $startdate ); - if( !$enddate ) { - $enddate = $startdate; - $enddate['year'] += 1; - } -// echo "recur __in_ comp start ".implode('-',$wdate)." period start ".implode('-',$startdate)." period end ".implode('-',$enddate)."
\n";print_r($recur);echo "
\n";//test### - $endDatets = iCalUtilityFunctions::_date2timestamp( $enddate ); // fix break - if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) - $recur['UNTIL'] = $enddate; // create break - if( isset( $recur['UNTIL'] )) { - $tdatets = iCalUtilityFunctions::_date2timestamp( $recur['UNTIL'] ); - if( $endDatets > $tdatets ) { - $endDatets = $tdatets; // emergency break - $enddate = iCalUtilityFunctions::_timestamp2date( $endDatets, 6 ); - } - else - $recur['UNTIL'] = iCalUtilityFunctions::_timestamp2date( $endDatets, 6 ); - } - if( $wdatets > $endDatets ) { -// echo "recur out of date ".date('Y-m-d H:i:s',$wdatets)."
\n";//test - return array(); // nothing to do.. . - } - if( !isset( $recur['FREQ'] )) // "MUST be specified.. ." - $recur['FREQ'] = 'DAILY'; // ?? - $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ?? - $weekStart = (int) date( 'W', ( $wdatets + $wkst )); - if( !isset( $recur['INTERVAL'] )) - $recur['INTERVAL'] = 1; - $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence - /* find out how to step up dates and set index for interval count */ - $step = array(); - if( 'YEARLY' == $recur['FREQ'] ) - $step['year'] = 1; - elseif( 'MONTHLY' == $recur['FREQ'] ) - $step['month'] = 1; - elseif( 'WEEKLY' == $recur['FREQ'] ) - $step['day'] = 7; - else - $step['day'] = 1; - if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) - $step = array( 'month' => 1 ); - if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ?? - $step = array( 'day' => 7 ); - if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) - $step = array( 'day' => 1 ); - $intervalarr = array(); - if( 1 < $recur['INTERVAL'] ) { - $intervalix = iCalUtilityFunctions::_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); - $intervalarr = array( $intervalix => 0 ); - } - if( isset( $recur['BYSETPOS'] )) { // save start date + weekno - $bysetposymd1 = $bysetposymd2 = $bysetposw1 = $bysetposw2 = array(); -// echo "bysetposXold_start=$bysetposYold $bysetposMold $bysetposDold
\n"; // test ### - if( is_array( $recur['BYSETPOS'] )) { - foreach( $recur['BYSETPOS'] as $bix => $bval ) - $recur['BYSETPOS'][$bix] = (int) $bval; - } - else - $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] ); - if( 'YEARLY' == $recur['FREQ'] ) { - $wdate['month'] = $wdate['day'] = 1; // start from beginning of year - $wdatets = iCalUtilityFunctions::_date2timestamp( $wdate ); - iCalUtilityFunctions::_stepdate( $enddate, $endDatets, array( 'year' => 1 )); // make sure to count whole last year - } - elseif( 'MONTHLY' == $recur['FREQ'] ) { - $wdate['day'] = 1; // start from beginning of month - $wdatets = iCalUtilityFunctions::_date2timestamp( $wdate ); - iCalUtilityFunctions::_stepdate( $enddate, $endDatets, array( 'month' => 1 )); // make sure to count whole last month - } - else - iCalUtilityFunctions::_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period -// echo "BYSETPOS endDat++ =".implode('-',$enddate).' step='.var_export($step,TRUE)."
\n";//test### - $bysetposWold = (int) date( 'W', ( $wdatets + $wkst )); - $bysetposYold = $wdate['year']; - $bysetposMold = $wdate['month']; - $bysetposDold = $wdate['day']; - } - else - iCalUtilityFunctions::_stepdate( $wdate, $wdatets, $step); - $year_old = null; - $daynames = array( 'SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA' ); - /* MAIN LOOP */ -// echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."
\n";//test - while( TRUE ) { - if( isset( $endDatets ) && ( $wdatets > $endDatets )) - break; - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) - break; - if( $year_old != $wdate['year'] ) { - $year_old = $wdate['year']; - $daycnts = array(); - $yeardays = $weekno = 0; - $yeardaycnt = array(); - foreach( $daynames as $dn ) - $yeardaycnt[$dn] = 0; - for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters - $daycnts[$m] = array(); - $weekdaycnt = array(); - foreach( $daynames as $dn ) - $weekdaycnt[$dn] = 0; - $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); - for( $d = 1; $d <= $mcnt; $d++ ) { - $daycnts[$m][$d] = array(); - if( isset( $recur['BYYEARDAY'] )) { - $yeardays++; - $daycnts[$m][$d]['yearcnt_up'] = $yeardays; - } - if( isset( $recur['BYDAY'] )) { - $day = date( 'w', mktime( 0, 0, 0, $m, $d, $wdate['year'] )); - $day = $daynames[$day]; - $daycnts[$m][$d]['DAY'] = $day; - $weekdaycnt[$day]++; - $daycnts[$m][$d]['monthdayno_up'] = $weekdaycnt[$day]; - $yeardaycnt[$day]++; - $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day]; - } - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) - $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year'])); - } - } - $daycnt = 0; - $yeardaycnt = array(); - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) { - $weekno = null; - for( $d=31; $d > 25; $d-- ) { // get last weekno for year - if( !$weekno ) - $weekno = $daycnts[12][$d]['weekno_up']; - elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) { - $weekno = $daycnts[12][$d]['weekno_up']; - break; - } - } - } - for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters - $weekdaycnt = array(); - foreach( $daynames as $dn ) - $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0; - $monthcnt = 0; - $mcnt = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] )); - for( $d = $mcnt; $d > 0; $d-- ) { - if( isset( $recur['BYYEARDAY'] )) { - $daycnt -= 1; - $daycnts[$m][$d]['yearcnt_down'] = $daycnt; - } - if( isset( $recur['BYMONTHDAY'] )) { - $monthcnt -= 1; - $daycnts[$m][$d]['monthcnt_down'] = $monthcnt; - } - if( isset( $recur['BYDAY'] )) { - $day = $daycnts[$m][$d]['DAY']; - $weekdaycnt[$day] -= 1; - $daycnts[$m][$d]['monthdayno_down'] = $weekdaycnt[$day]; - $yeardaycnt[$day] -= 1; - $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day]; - } - if( isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) - $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1); - } - } - } - /* check interval */ - if( 1 < $recur['INTERVAL'] ) { - /* create interval index */ - $intervalix = iCalUtilityFunctions::_recurIntervalIx( $recur['FREQ'], $wdate, $wkst ); - /* check interval */ - $currentKey = array_keys( $intervalarr ); - $currentKey = end( $currentKey ); // get last index - if( $currentKey != $intervalix ) - $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 )); - if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) && - ( 0 != $intervalarr[$intervalix] )) { - /* step up date */ -// echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."
\n";//test - iCalUtilityFunctions::_stepdate( $wdate, $wdatets, $step); - continue; - } - else // continue within the selected interval - $intervalarr[$intervalix] = 0; -// echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."
\n";//test - } - $updateOK = TRUE; - if( $updateOK && isset( $recur['BYMONTH'] )) - $updateOK = iCalUtilityFunctions::_recurBYcntcheck( $recur['BYMONTH'] - , $wdate['month'] - ,($wdate['month'] - 13)); - if( $updateOK && isset( $recur['BYWEEKNO'] )) - $updateOK = iCalUtilityFunctions::_recurBYcntcheck( $recur['BYWEEKNO'] - , $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] - , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] ); - if( $updateOK && isset( $recur['BYYEARDAY'] )) - $updateOK = iCalUtilityFunctions::_recurBYcntcheck( $recur['BYYEARDAY'] - , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up'] - , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] ); - if( $updateOK && isset( $recur['BYMONTHDAY'] )) - $updateOK = iCalUtilityFunctions::_recurBYcntcheck( $recur['BYMONTHDAY'] - , $wdate['day'] - , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] ); -// echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "
\n";//test### - if( $updateOK && isset( $recur['BYDAY'] )) { - $updateOK = FALSE; - $m = $wdate['month']; - $d = $wdate['day']; - if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no - $daynoexists = $daynosw = $daynamesw = FALSE; - if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) - $daynamesw = TRUE; - if( isset( $recur['BYDAY'][0] )) { - $daynoexists = TRUE; - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) - $daynosw = iCalUtilityFunctions::_recurBYcntcheck( $recur['BYDAY'][0] - , $daycnts[$m][$d]['monthdayno_up'] - , $daycnts[$m][$d]['monthdayno_down'] ); - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) - $daynosw = iCalUtilityFunctions::_recurBYcntcheck( $recur['BYDAY'][0] - , $daycnts[$m][$d]['yeardayno_up'] - , $daycnts[$m][$d]['yeardayno_down'] ); - } - if(( $daynoexists && $daynosw && $daynamesw ) || - ( !$daynoexists && !$daynosw && $daynamesw )) { - $updateOK = TRUE; -// echo "m=$m d=$d day=".$daycnts[$m][$d]['DAY']." yeardayno_up=".$daycnts[$m][$d]['yeardayno_up']." daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw updateOK:$updateOK
\n"; // test ### - } -//echo "m=$m d=$d day=".$daycnts[$m][$d]['DAY']." yeardayno_up=".$daycnts[$m][$d]['yeardayno_up']." daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw updateOK:$updateOK
\n"; // test ### - } - else { - foreach( $recur['BYDAY'] as $bydayvalue ) { - $daynoexists = $daynosw = $daynamesw = FALSE; - if( isset( $bydayvalue['DAY'] ) && - ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) - $daynamesw = TRUE; - if( isset( $bydayvalue[0] )) { - $daynoexists = TRUE; - if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || - isset( $recur['BYMONTH'] )) - $daynosw = iCalUtilityFunctions::_recurBYcntcheck( $bydayvalue['0'] - , $daycnts[$m][$d]['monthdayno_up'] - , $daycnts[$m][$d]['monthdayno_down'] ); - elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) - $daynosw = iCalUtilityFunctions::_recurBYcntcheck( $bydayvalue['0'] - , $daycnts[$m][$d]['yeardayno_up'] - , $daycnts[$m][$d]['yeardayno_down'] ); - } -// echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw
\n"; // test ### - if(( $daynoexists && $daynosw && $daynamesw ) || - ( !$daynoexists && !$daynosw && $daynamesw )) { - $updateOK = TRUE; - break; - } - } - } - } -// echo "efter BYDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "
\n"; // test ### - /* check BYSETPOS */ - if( $updateOK ) { - if( isset( $recur['BYSETPOS'] ) && - ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) { - if( isset( $recur['WEEKLY'] )) { - if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) - $bysetposw1[] = $wdatets; - else - $bysetposw2[] = $wdatets; - } - else { - if(( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && - ( $bysetposYold == $wdate['year'] )) || - ( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] ) && - (( $bysetposYold == $wdate['year'] ) && - ( $bysetposMold == $wdate['month'] ))) || - ( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && - (( $bysetposYold == $wdate['year'] ) && - ( $bysetposMold == $wdate['month']) && - ( $bysetposDold == $wdate['day'] )))) { -// echo "bysetposymd1[]=".date('Y-m-d H:i:s',$wdatets)."
\n";//test - $bysetposymd1[] = $wdatets; - } - else { -// echo "bysetposymd2[]=".date('Y-m-d H:i:s',$wdatets)."
\n";//test - $bysetposymd2[] = $wdatets; - } - } - } - else { - /* update result array if BYSETPOS is set */ - $countcnt++; - if( $startdatets <= $wdatets ) { // only output within period - $result[$wdatets] = TRUE; -// echo "recur ".date('Y-m-d H:i:s',$wdatets)."
\n";//test - } -// echo "recur undate ".date('Y-m-d H:i:s',$wdatets)." okdatstart ".date('Y-m-d H:i:s',$startdatets)."
\n";//test - $updateOK = FALSE; - } - } - /* step up date */ - iCalUtilityFunctions::_stepdate( $wdate, $wdatets, $step); - /* check if BYSETPOS is set for updating result array */ - if( $updateOK && isset( $recur['BYSETPOS'] )) { - $bysetpos = FALSE; - if( isset( $recur['FREQ'] ) && ( 'YEARLY' == $recur['FREQ'] ) && - ( $bysetposYold != $wdate['year'] )) { - $bysetpos = TRUE; - $bysetposYold = $wdate['year']; - } - elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] && - (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) { - $bysetpos = TRUE; - $bysetposYold = $wdate['year']; - $bysetposMold = $wdate['month']; - } - elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY' == $recur['FREQ'] )) { - $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year'])); - if( $bysetposWold != $weekno ) { - $bysetposWold = $weekno; - $bysetpos = TRUE; - } - } - elseif( isset( $recur['FREQ'] ) && ( 'DAILY' == $recur['FREQ'] ) && - (( $bysetposYold != $wdate['year'] ) || - ( $bysetposMold != $wdate['month'] ) || - ( $bysetposDold != $wdate['day'] ))) { - $bysetpos = TRUE; - $bysetposYold = $wdate['year']; - $bysetposMold = $wdate['month']; - $bysetposDold = $wdate['day']; - } - if( $bysetpos ) { - if( isset( $recur['BYWEEKNO'] )) { - $bysetposarr1 = & $bysetposw1; - $bysetposarr2 = & $bysetposw2; - } - else { - $bysetposarr1 = & $bysetposymd1; - $bysetposarr2 = & $bysetposymd2; - } -// echo 'test före out startYMD (weekno)='.$wdateStart['year'].':'.$wdateStart['month'].':'.$wdateStart['day']." ($weekStart) "; // test ### - foreach( $recur['BYSETPOS'] as $ix ) { - if( 0 > $ix ) // both positive and negative BYSETPOS allowed - $ix = ( count( $bysetposarr1 ) + $ix + 1); - $ix--; - if( isset( $bysetposarr1[$ix] )) { - if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period -// $testdate = iCalUtilityFunctions::_timestamp2date( $bysetposarr1[$ix], 6 ); // test ### -// $testweekno = (int) date( 'W', mktime( 0, 0, $wkst, $testdate['month'], $testdate['day'], $testdate['year'] )); // test ### -// echo " testYMD (weekno)=".$testdate['year'].':'.$testdate['month'].':'.$testdate['day']." ($testweekno)"; // test ### - $result[$bysetposarr1[$ix]] = TRUE; -// echo " recur ".date('Y-m-d H:i:s',$bysetposarr1[$ix]); // test ### - } - $countcnt++; - } - if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) - break; - } -// echo "
\n"; // test ### - $bysetposarr1 = $bysetposarr2; - $bysetposarr2 = array(); - } - } - } - } - public static function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) { - if( is_array( $BYvalue ) && - ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) - return TRUE; - elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) - return TRUE; - else - return FALSE; - } - public static function _recurIntervalIx( $freq, $date, $wkst ) { - /* create interval index */ - switch( $freq ) { - case 'YEARLY': - $intervalix = $date['year']; - break; - case 'MONTHLY': - $intervalix = $date['year'].'-'.$date['month']; - break; - case 'WEEKLY': - $wdatets = iCalUtilityFunctions::_date2timestamp( $date ); - $intervalix = (int) date( 'W', ( $wdatets + $wkst )); - break; - case 'DAILY': - default: - $intervalix = $date['year'].'-'.$date['month'].'-'.$date['day']; - break; - } - return $intervalix; - } -/** - * convert input format for exrule and rrule to internal format - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.15 - 2012-01-31 - * @param array $rexrule - * @return array - */ - public static function _setRexrule( $rexrule ) { - $input = array(); - if( empty( $rexrule )) - return $input; - foreach( $rexrule as $rexrulelabel => $rexrulevalue ) { - $rexrulelabel = strtoupper( $rexrulelabel ); - if( 'UNTIL' != $rexrulelabel ) - $input[$rexrulelabel] = $rexrulevalue; - else { - iCalUtilityFunctions::_strDate2arr( $rexrulevalue ); - if( iCalUtilityFunctions::_isArrayTimestampDate( $rexrulevalue )) // timestamp, always date-time - $input[$rexrulelabel] = iCalUtilityFunctions::_timestamp2date( $rexrulevalue, 6 ); - elseif( iCalUtilityFunctions::_isArrayDate( $rexrulevalue )) { // date or date-time - $parno = ( isset( $rexrulevalue['hour'] ) || isset( $rexrulevalue[4] )) ? 6 : 3; - $input[$rexrulelabel] = iCalUtilityFunctions::_date_time_array( $rexrulevalue, $parno ); - } - elseif( 8 <= strlen( trim( $rexrulevalue ))) { // ex. textual datetime/date 2006-08-03 10:12:18 - $input[$rexrulelabel] = iCalUtilityFunctions::_date_time_string( $rexrulevalue ); - unset( $input['$rexrulelabel']['unparsedtext'] ); - } - if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) - $input[$rexrulelabel]['tz'] = 'Z'; - } - } - /* set recurrence rule specification in rfc2445 order */ - $input2 = array(); - if( isset( $input['FREQ'] )) - $input2['FREQ'] = $input['FREQ']; - if( isset( $input['UNTIL'] )) - $input2['UNTIL'] = $input['UNTIL']; - elseif( isset( $input['COUNT'] )) - $input2['COUNT'] = $input['COUNT']; - if( isset( $input['INTERVAL'] )) - $input2['INTERVAL'] = $input['INTERVAL']; - if( isset( $input['BYSECOND'] )) - $input2['BYSECOND'] = $input['BYSECOND']; - if( isset( $input['BYMINUTE'] )) - $input2['BYMINUTE'] = $input['BYMINUTE']; - if( isset( $input['BYHOUR'] )) - $input2['BYHOUR'] = $input['BYHOUR']; - if( isset( $input['BYDAY'] )) { - if( !is_array( $input['BYDAY'] )) // ensure upper case.. . - $input2['BYDAY'] = strtoupper( $input['BYDAY'] ); - else { - foreach( $input['BYDAY'] as $BYDAYx => $BYDAYv ) { - if( 'DAY' == strtoupper( $BYDAYx )) - $input2['BYDAY']['DAY'] = strtoupper( $BYDAYv ); - elseif( !is_array( $BYDAYv )) { - $input2['BYDAY'][$BYDAYx] = $BYDAYv; - } - else { - foreach( $BYDAYv as $BYDAYx2 => $BYDAYv2 ) { - if( 'DAY' == strtoupper( $BYDAYx2 )) - $input2['BYDAY'][$BYDAYx]['DAY'] = strtoupper( $BYDAYv2 ); - else - $input2['BYDAY'][$BYDAYx][$BYDAYx2] = $BYDAYv2; - } - } - } - } - } - if( isset( $input['BYMONTHDAY'] )) - $input2['BYMONTHDAY'] = $input['BYMONTHDAY']; - if( isset( $input['BYYEARDAY'] )) - $input2['BYYEARDAY'] = $input['BYYEARDAY']; - if( isset( $input['BYWEEKNO'] )) - $input2['BYWEEKNO'] = $input['BYWEEKNO']; - if( isset( $input['BYMONTH'] )) - $input2['BYMONTH'] = $input['BYMONTH']; - if( isset( $input['BYSETPOS'] )) - $input2['BYSETPOS'] = $input['BYSETPOS']; - if( isset( $input['WKST'] )) - $input2['WKST'] = $input['WKST']; - return $input2; - } -/** - * convert format for input date to internal date with parameters - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.8 - 2012-03-18 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param string $tz optional - * @param array $params optional - * @param string $caller optional - * @param string $objName optional - * @param string $tzid optional - * @return array - */ - public static function _setDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $params=FALSE, $caller=null, $objName=null, $tzid=FALSE ) { - $input = $parno = null; - $localtime = (( 'dtstart' == $caller ) && in_array( $objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE; - iCalUtilityFunctions::_strDate2arr( $year ); - if( iCalUtilityFunctions::_isArrayDate( $year )) { - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); - $input['params'] = iCalUtilityFunctions::_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); - if( isset( $input['params']['TZID'] )) { - $input['params']['VALUE'] = 'DATE-TIME'; - unset( $year['tz'] ); - } - $hitval = ( isset( $year['tz'] ) || isset( $year[6] )) ? 7 : 6; - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval ); - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno ); - $input['value'] = iCalUtilityFunctions::_date_time_array( $year, $parno ); - } - elseif( iCalUtilityFunctions::_isArrayTimestampDate( $year )) { - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); - $input['params'] = iCalUtilityFunctions::_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); - if( isset( $input['params']['TZID'] )) { - $input['params']['VALUE'] = 'DATE-TIME'; - unset( $year['tz'] ); - } - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE', 3 ); - $hitval = ( isset( $year['tz'] )) ? 7 : 6; - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno ); - $input['value'] = iCalUtilityFunctions::_timestamp2date( $year, $parno ); - } - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 - if( $localtime ) unset ( $month['VALUE'], $month['TZID'] ); - $input['params'] = iCalUtilityFunctions::_setParams( $month, array( 'VALUE' => 'DATE-TIME' )); - if( isset( $input['params']['TZID'] )) { - $input['params']['VALUE'] = 'DATE-TIME'; - $parno = 6; - } - elseif( $tzid && iCalUtilityFunctions::_isOffset( substr( $year, -7 ))) { - if(( in_array( substr( $year, -5, 1 ), array( '+', '-' ))) && - ( '0000' < substr( $year, -4 )) && ( '9999' >= substr( $year, -4 ))) - $year = substr( $year, 0, ( strlen( $year ) - 5 )); - elseif(( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) && - ( '000000' < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) - $year = substr( $year, 0, ( strlen( $year ) - 7 )); - $parno = 6; - } - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno ); - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno ); - $input['value'] = iCalUtilityFunctions::_date_time_string( $year, $parno ); - unset( $input['value']['unparsedtext'] ); - } - else { - if( is_array( $params )) { - if( $localtime ) unset ( $params['VALUE'], $params['TZID'] ); - $input['params'] = iCalUtilityFunctions::_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); - } - elseif( is_array( $tz )) { - $input['params'] = iCalUtilityFunctions::_setParams( $tz, array( 'VALUE' => 'DATE-TIME' )); - $tz = FALSE; - } - elseif( is_array( $hour )) { - $input['params'] = iCalUtilityFunctions::_setParams( $hour, array( 'VALUE' => 'DATE-TIME' )); - $hour = $min = $sec = $tz = FALSE; - } - if( isset( $input['params']['TZID'] )) { - $tz = null; - $input['params']['VALUE'] = 'DATE-TIME'; - } - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE', 3 ); - $hitval = ( !empty( $tz )) ? 7 : 6; - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno, $parno ); - $input['value'] = array( 'year' => $year, 'month' => $month, 'day' => $day ); - if( 3 != $parno ) { - $input['value']['hour'] = ( $hour ) ? $hour : '0'; - $input['value']['min'] = ( $min ) ? $min : '0'; - $input['value']['sec'] = ( $sec ) ? $sec : '0'; - if( !empty( $tz )) - $input['value']['tz'] = $tz; - } - } - if( 3 == $parno ) { - $input['params']['VALUE'] = 'DATE'; - unset( $input['value']['tz'] ); - unset( $input['params']['TZID'] ); - } - elseif( isset( $input['params']['TZID'] )) - unset( $input['value']['tz'] ); - if( $localtime ) - unset( $input['value']['tz'], $input['params']['TZID'] ); - elseif(( !isset( $input['params']['VALUE'] ) || ( $input['params']['VALUE'] != 'DATE' )) && !isset( $input['params']['TZID'] ) && $tzid ) - $input['params']['TZID'] = $tzid; - if( isset( $input['value']['tz'] )) - $input['value']['tz'] = (string) $input['value']['tz']; - if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) && // real time zone in tz to TZID - ( !iCalUtilityFunctions::_isOffset( $input['value']['tz'] ))) { - $input['params']['TZID'] = $input['value']['tz']; - unset( $input['value']['tz'] ); - } - if( isset( $input['params']['TZID'] ) && !empty( $input['params']['TZID'] )) { - if(( 'Z' != $input['params']['TZID'] ) && iCalUtilityFunctions::_isOffset( $input['params']['TZID'] )) { // utc offset in TZID to tz - $input['value']['tz'] = $input['params']['TZID']; - unset( $input['params']['TZID'] ); - } - elseif( in_array( strtoupper( $input['params']['TZID'] ), array( 'GMT', 'UTC', 'Z' ))) { // time zone Z - $input['value']['tz'] = 'Z'; - unset( $input['params']['TZID'] ); - } - } - return $input; - } -/** - * convert format for input date (UTC) to internal date with parameters - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.8 - 2012-01-19 - * @param mixed $year - * @param mixed $month optional - * @param int $day optional - * @param int $hour optional - * @param int $min optional - * @param int $sec optional - * @param array $params optional - * @return array - */ - public static function _setDate2( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) { - $input = null; - iCalUtilityFunctions::_strDate2arr( $year ); - if( iCalUtilityFunctions::_isArrayDate( $year )) { - $input['value'] = iCalUtilityFunctions::_date_time_array( $year, 7 ); - $input['params'] = iCalUtilityFunctions::_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); - } - elseif( iCalUtilityFunctions::_isArrayTimestampDate( $year )) { - $input['value'] = iCalUtilityFunctions::_timestamp2date( $year, 7 ); - $input['params'] = iCalUtilityFunctions::_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); - } - elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18 - $input['value'] = iCalUtilityFunctions::_date_time_string( $year, 7 ); - unset( $input['value']['unparsedtext'] ); - $input['params'] = iCalUtilityFunctions::_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) ); - } - else { - $input['value'] = array( 'year' => $year - , 'month' => $month - , 'day' => $day - , 'hour' => $hour - , 'min' => $min - , 'sec' => $sec ); - $input['params'] = iCalUtilityFunctions::_setParams( $params, array( 'VALUE' => 'DATE-TIME' )); - } - $parno = iCalUtilityFunctions::_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default - if( !isset( $input['value']['hour'] )) - $input['value']['hour'] = 0; - if( !isset( $input['value']['min'] )) - $input['value']['min'] = 0; - if( !isset( $input['value']['sec'] )) - $input['value']['sec'] = 0; - if( isset( $input['params']['TZID'] ) && !empty( $input['params']['TZID'] )) { - if(( 'Z' != $input['params']['TZID'] ) && iCalUtilityFunctions::_isOffset( $input['params']['TZID'] )) { // utc offset in TZID to tz - $input['value']['tz'] = $input['params']['TZID']; - unset( $input['params']['TZID'] ); - } - elseif( in_array( strtoupper( $input['params']['TZID'] ), array( 'GMT', 'UTC', 'Z' ))) { // time zone Z - $input['value']['tz'] = 'Z'; - unset( $input['params']['TZID'] ); - } - } - if( !isset( $input['value']['tz'] ) || !iCalUtilityFunctions::_isOffset( $input['value']['tz'] )) - $input['value']['tz'] = 'Z'; - return $input; - } -/** - * check index and set (an indexed) content in multiple value array - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.12 - 2011-01-03 - * @param array $valArr - * @param mixed $value - * @param array $params - * @param array $defaults - * @param int $index - * @return void - */ - public static function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) { - if( !is_array( $valArr )) $valArr = array(); - if( $index ) - $index = $index - 1; - elseif( 0 < count( $valArr )) { - $keys = array_keys( $valArr ); - $index = end( $keys ) + 1; - } - else - $index = 0; - $valArr[$index] = array( 'value' => $value, 'params' => iCalUtilityFunctions::_setParams( $params, $defaults )); - ksort( $valArr ); - } -/** - * set input (formatted) parameters- component property attributes - * - * default parameters can be set, if missing - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 1.x.x - 2007-05-01 - * @param array $params - * @param array $defaults - * @return array - */ - public static function _setParams( $params, $defaults=FALSE ) { - if( !is_array( $params)) - $params = array(); - $input = array(); - foreach( $params as $paramKey => $paramValue ) { - if( is_array( $paramValue )) { - foreach( $paramValue as $pkey => $pValue ) { - if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) - $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 )); - } - } - elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) - $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 )); - if( 'VALUE' == strtoupper( $paramKey )) - $input['VALUE'] = strtoupper( $paramValue ); - else - $input[strtoupper( $paramKey )] = $paramValue; - } - if( is_array( $defaults )) { - foreach( $defaults as $paramKey => $paramValue ) { - if( !isset( $input[$paramKey] )) - $input[$paramKey] = $paramValue; - } - } - return (0 < count( $input )) ? $input : null; - } -/** - * step date, return updated date, array and timpstamp - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.16 - 2008-10-18 - * @param array $date, date to step - * @param int $timestamp - * @param array $step, default array( 'day' => 1 ) - * @return void - */ - public static function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) { - foreach( $step as $stepix => $stepvalue ) - $date[$stepix] += $stepvalue; - $timestamp = iCalUtilityFunctions::_date2timestamp( $date ); - $date = iCalUtilityFunctions::_timestamp2date( $timestamp, 6 ); - foreach( $date as $k => $v ) { - if( ctype_digit( $v )) - $date[$k] = (int) $v; - } - } -/** - * convert a date from specific string to array format - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.8 - 2012-01-27 - * @param mixed $input - * @return bool, TRUE on success - */ - public static function _strDate2arr( & $input ) { - if( is_array( $input )) - return FALSE; - if( 5 > strlen( (string) $input )) - return FALSE; - $work = $input; - if( 2 == substr_count( $work, '-' )) - $work = str_replace( '-', '', $work ); - if( 2 == substr_count( $work, '/' )) - $work = str_replace( '/', '', $work ); - if( !ctype_digit( substr( $work, 0, 8 ))) - return FALSE; - if( !checkdate( (int) substr( $work, 4, 2 ), (int) substr( $work, 6, 2 ), (int) substr( $work, 0, 4 ))) - return FALSE; - $temp = array( 'year' => substr( $work, 0, 4 ) - , 'month' => substr( $work, 4, 2 ) - , 'day' => substr( $work, 6, 2 )); - if( 8 == strlen( $work )) { - $input = $temp; - return TRUE; - } - if(( ' ' == substr( $work, 8, 1 )) || ( 'T' == substr( $work, 8, 1 )) || ( 't' == substr( $work, 8, 1 ))) - $work = substr( $work, 9 ); - elseif( ctype_digit( substr( $work, 8, 1 ))) - $work = substr( $work, 8 ); - else - return FALSE; - if( 2 == substr_count( $work, ':' )) - $work = str_replace( ':', '', $work ); - if( !ctype_digit( substr( $work, 0, 4 ))) - return FALSE; - $temp['hour'] = substr( $work, 0, 2 ); - $temp['min'] = substr( $work, 2, 2 ); - if((( 0 > $temp['hour'] ) || ( $temp['hour'] > 23 )) || - (( 0 > $temp['min'] ) || ( $temp['min'] > 59 ))) - return FALSE; - if( ctype_digit( substr( $work, 4, 2 ))) { - $temp['sec'] = substr( $work, 4, 2 ); - if(( 0 > $temp['sec'] ) || ( $temp['sec'] > 59 )) - return FALSE; - $len = 6; - } - else { - $temp['sec'] = 0; - $len = 4; - } - if( $len < strlen( $work)) - $temp['tz'] = trim( substr( $work, 6 )); - $input = $temp; - return TRUE; - } -/** - * convert timestamp to date array - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.4.16 - 2008-11-01 - * @param mixed $timestamp - * @param int $parno - * @return array - */ - public static function _timestamp2date( $timestamp, $parno=6 ) { - if( is_array( $timestamp )) { - if(( 7 == $parno ) && !empty( $timestamp['tz'] )) - $tz = $timestamp['tz']; - $timestamp = $timestamp['timestamp']; - } - $output = array( 'year' => date( 'Y', $timestamp ) - , 'month' => date( 'm', $timestamp ) - , 'day' => date( 'd', $timestamp )); - if( 3 != $parno ) { - $output['hour'] = date( 'H', $timestamp ); - $output['min'] = date( 'i', $timestamp ); - $output['sec'] = date( 's', $timestamp ); - if( isset( $tz )) - $output['tz'] = $tz; - } - return $output; - } -/** - * convert timestamp to duration in array format - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.6.23 - 2010-10-23 - * @param int $timestamp - * @return array, duration format - */ - public static function _timestamp2duration( $timestamp ) { - $dur = array(); - $dur['week'] = (int) floor( $timestamp / ( 7 * 24 * 60 * 60 )); - $timestamp = $timestamp % ( 7 * 24 * 60 * 60 ); - $dur['day'] = (int) floor( $timestamp / ( 24 * 60 * 60 )); - $timestamp = $timestamp % ( 24 * 60 * 60 ); - $dur['hour'] = (int) floor( $timestamp / ( 60 * 60 )); - $timestamp = $timestamp % ( 60 * 60 ); - $dur['min'] = (int) floor( $timestamp / ( 60 )); - $dur['sec'] = (int) $timestamp % ( 60 ); - return $dur; - } -/** - * transforms a dateTime from a timezone to another using PHP DateTime and DateTimeZone class (PHP >= PHP 5.2.0) - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.14 - 2012-01-24 - * @param mixed $date, date to alter - * @param string $tzFrom, PHP valid old timezone - * @param string $tzTo, PHP valid new timezone, default 'UTC' - * @param string $format, date output format, default 'Ymd\THis' - * @return bool - */ - public static function transformDateTime( & $date, $tzFrom, $tzTo='UTC', $format = 'Ymd\THis' ) { - if( !class_exists( 'DateTime' ) || !class_exists( 'DateTimeZone' )) - return FALSE; - if( is_array( $date ) && isset( $date['timestamp'] )) - $timestamp = $date['timestamp']; - elseif( iCalUtilityFunctions::_isArrayDate( $date )) { - if(isset( $date['tz'] )) - unset( $date['tz'] ); - $date = iCalUtilityFunctions::_format_date_time( iCalUtilityFunctions::_date_time_array( $date )); - if( 'Z' == substr( $date, -1 )) - $date = substr( $date, 0, ( strlen( $date ) - 2 )); - if( FALSE === ( $timestamp = strtotime( $date ))) - return FALSE; - } - elseif( FALSE === ( $timestamp = @strtotime( $date ))) - return FALSE; - try { - $d = new DateTime( date( 'Y-m-d H:i:s', $timestamp ), new DateTimeZone( $tzFrom )); - $d->setTimezone( new DateTimeZone( $tzTo )); - } - catch (Exception $e) { - return FALSE; - } - $date = $d->format( $format ); - return TRUE; - } -/** - * convert (numeric) local time offset, ("+" / "-")HHmm[ss], to seconds correcting localtime to GMT - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.4 - 2012-01-11 - * @param string $offset - * @return integer - */ - public static function _tz2offset( $tz ) { - $tz = trim( (string) $tz ); - $offset = 0; - if((( 5 != strlen( $tz )) && ( 7 != strlen( $tz ))) || - (( '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) || - (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) || - (( 7 == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) - return $offset; - $hours2sec = (int) substr( $tz, 1, 2 ) * 3600; - $min2sec = (int) substr( $tz, 3, 2 ) * 60; - $sec = ( 7 == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00'; - $offset = $hours2sec + $min2sec + $sec; - $offset = ('-' == substr( $tz, 0, 1 )) ? $offset * -1 : $offset; - return $offset; - } -} -/*********************************************************************************/ -/* iCalcreator XML (rfc6321) helper functions */ -/*********************************************************************************/ -/** - * format iCal XML output, rfc6321, using PHP SimpleXMLElement - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.1 - 2012-02-22 - * @param object $calendar, iCalcreator vcalendar instance reference - * @return string - */ -function iCal2XML( & $calendar ) { - /** fix an SimpleXMLElement instance and create root element */ - $xmlstr = ''; - $xmlstr .= ''; - $xmlstr .= ''; - $xml = new SimpleXMLElement( $xmlstr ); - $vcalendar = $xml->addChild( 'vcalendar' ); - /** fix calendar properties */ - $properties = $vcalendar->addChild( 'properties' ); - $calProps = array( 'prodid', 'version', 'calscale', 'method' ); - foreach( $calProps as $calProp ) { - if( FALSE !== ( $content = $calendar->getProperty( $calProp ))) - _addXMLchild( $properties, $calProp, 'text', $content ); - } - while( FALSE !== ( $content = $calendar->getProperty( FALSE, FALSE, TRUE ))) - _addXMLchild( $properties, $content[0], 'unknown', $content[1]['value'], $content[1]['params'] ); - $langCal = $calendar->getConfig( 'language' ); - /** prepare to fix components with properties */ - $components = $vcalendar->addChild( 'components' ); - $comps = array( 'vtimezone', 'vevent', 'vtodo', 'vjournal', 'vfreebusy' ); - $eventProps = array( 'dtstamp', 'dtstart', 'uid', - 'class', 'created', 'description', 'geo', 'last-modified', 'location', 'organizer', 'priority', - 'sequence', 'status', 'summary', 'transp', 'url', 'recurrence-id', 'rrule', 'dtend', 'duration', - 'attach', 'attendee', 'categories', 'comment', 'contact', 'exdate', 'request-status', 'related-to', 'resources', 'rdate', - 'x-prop' ); - $todoProps = array( 'dtstamp', 'uid', - 'class', 'completed', 'created', 'description', 'geo', 'last-modified', 'location', 'organizer', 'percent-complete', 'priority', - 'recurrence-id', 'sequence', 'status', 'summary', 'url', 'rrule', 'dtstart', 'due', 'duration', - 'attach', 'attendee', 'categories', 'comment', 'contact', 'exdate', 'request-status', 'related-to', 'resources', 'rdate', - 'x-prop' ); - $journalProps = array( 'dtstamp', 'uid', - 'class', 'created', 'dtstart', 'last-modified', 'organizer', 'recurrence-id', 'sequence', 'status', 'summary', 'url', 'rrule', - 'attach', 'attendee', 'categories', 'comment', 'contact', - 'description', - 'exdate', 'related-to', 'rdate', 'request-status', - 'x-prop' ); - $freebusyProps = array( 'dtstamp', 'uid', - 'contact', 'dtstart', 'dtend', 'duration', 'organizer', 'url', - 'attendee', 'comment', 'freebusy', 'request-status', - 'x-prop' ); - $timezoneProps = array( 'tzid', - 'last-modified', 'tzurl', - 'x-prop' ); - $alarmProps = array( 'action', 'description', 'trigger', 'summary', - 'attendee', - 'duration', 'repeat', 'attach', - 'x-prop' ); - $stddghtProps = array( 'dtstart', 'tzoffsetto', 'tzoffsetfrom', - 'rrule', - 'comment', 'rdate', 'tzname', - 'x-prop' ); - foreach( $comps as $compName ) { - switch( $compName ) { - case 'vevent': - $props = & $eventProps; - $subComps = array( 'valarm' ); - $subCompProps = & $alarmProps; - break; - case 'vtodo': - $props = & $todoProps; - $subComps = array( 'valarm' ); - $subCompProps = & $alarmProps; - break; - case 'vjournal': - $props = & $journalProps; - $subComps = array(); - $subCompProps = array(); - break; - case 'vfreebusy': - $props = & $freebusyProps; - $subComps = array(); - $subCompProps = array(); - break; - case 'vtimezone': - $props = & $timezoneProps; - $subComps = array( 'standard', 'daylight' ); - $subCompProps = & $stddghtProps; - break; - } // end switch( $compName ) - /** fix component properties */ - while( FALSE !== ( $component = $calendar->getComponent( $compName ))) { - $child = $components->addChild( $compName ); - $properties = $child->addChild( 'properties' ); - $langComp = $component->getConfig( 'language' ); - foreach( $props as $prop ) { - switch( $prop ) { - case 'attach': // may occur multiple times, below - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - $type = ( isset( $content['params']['VALUE'] ) && ( 'BINARY' == $content['params']['VALUE'] )) ? 'binary' : 'uri'; - unset( $content['params']['VALUE'] ); - _addXMLchild( $properties, $prop, $type, $content['value'], $content['params'] ); - } - break; - case 'attendee': - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - if( isset( $content['params']['CN'] ) && !isset( $content['params']['LANGUAGE'] )) { - if( $langComp ) - $content['params']['LANGUAGE'] = $langComp; - elseif( $langCal ) - $content['params']['LANGUAGE'] = $langCal; - } - _addXMLchild( $properties, $prop, 'cal-address', $content['value'], $content['params'] ); - } - break; - case 'exdate': - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - $type = ( isset( $content['params']['VALUE'] ) && ( 'DATE' == $content['params']['VALUE'] )) ? 'date' : 'date-time'; - unset( $content['params']['VALUE'] ); - foreach( $content['value'] as & $exDate ) { - if( ( isset( $exDate['tz'] ) && // fix UTC-date if offset set - iCalUtilityFunctions::_isOffset( $exDate['tz'] ) && - ( 'Z' != $exDate['tz'] )) - || ( isset( $content['params']['TZID'] ) && - iCalUtilityFunctions::_isOffset( $content['params']['TZID'] ) && - ( 'Z' != $content['params']['TZID'] ))) { - $offset = isset( $exDate['tz'] ) ? $exDate['tz'] : $content['params']['TZID']; - $date = mktime( (int) $exDate['hour'], - (int) $exDate['min'], - (int) ($exDate['sec'] + iCalUtilityFunctions::_tz2offset( $offset )), - (int) $exDate['month'], - (int) $exDate['day'], - (int) $exDate['year'] ); - unset( $exDate['tz'] ); - $exDate = iCalUtilityFunctions::_date_time_string( date( 'YmdTHis\Z', $date ), 6 ); - unset( $exDate['unparsedtext'] ); - } - } - _addXMLchild( $properties, $prop, $type, $content['value'], $content['params'] ); - } - break; - case 'freebusy': - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'period', $content['value'], $content['params'] ); - break; - case 'request-status': - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - if( !isset( $content['params']['LANGUAGE'] )) { - if( $langComp ) - $content['params']['LANGUAGE'] = $langComp; - elseif( $langCal ) - $content['params']['LANGUAGE'] = $langCal; - } - _addXMLchild( $properties, $prop, 'rstatus', $content['value'], $content['params'] ); - } - break; - case 'rdate': - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - $type = 'date-time'; - if( isset( $content['params']['VALUE'] )) { - if( 'DATE' == $content['params']['VALUE'] ) - $type = 'date'; - elseif( 'PERIOD' == $content['params']['VALUE'] ) - $type = 'period'; - } - if( 'period' == $type ) { - foreach( $content['value'] as & $rDates ) { - if( ( isset( $rDates[0]['tz'] ) && // fix UTC-date if offset set - iCalUtilityFunctions::_isOffset( $rDates[0]['tz'] ) && - ( 'Z' != $rDates[0]['tz'] )) - || ( isset( $content['params']['TZID'] ) && - iCalUtilityFunctions::_isOffset( $content['params']['TZID'] ) && - ( 'Z' != $content['params']['TZID'] ))) { - $offset = isset( $rDates[0]['tz'] ) ? $rDates[0]['tz'] : $content['params']['TZID']; - $date = mktime( (int) $rDates[0]['hour'], - (int) $rDates[0]['min'], - (int) ($rDates[0]['sec'] + iCalUtilityFunctions::_tz2offset( $offset )), - (int) $rDates[0]['month'], - (int) $rDates[0]['day'], - (int) $rDates[0]['year'] ); - unset( $rDates[0]['tz'] ); - $rDates[0] = iCalUtilityFunctions::_date_time_string( date( 'YmdTHis\Z', $date ), 6 ); - unset( $rDates[0]['unparsedtext'] ); - } - if( isset( $rDates[1]['year'] )) { - if( ( isset( $rDates[1]['tz'] ) && // fix UTC-date if offset set - iCalUtilityFunctions::_isOffset( $rDates[1]['tz'] ) && - ( 'Z' != $rDates[1]['tz'] )) - || ( isset( $content['params']['TZID'] ) && - iCalUtilityFunctions::_isOffset( $content['params']['TZID'] ) && - ( 'Z' != $content['params']['TZID'] ))) { - $offset = isset( $rDates[1]['tz'] ) ? $rDates[1]['tz'] : $content['params']['TZID']; - $date = mktime( (int) $rDates[1]['hour'], - (int) $rDates[1]['min'], - (int) ($rDates[1]['sec'] + iCalUtilityFunctions::_tz2offset( $offset )), - (int) $rDates[1]['month'], - (int) $rDates[1]['day'], - (int) $rDates[1]['year'] ); - unset( $rDates[1]['tz'] ); - $rDates[1] = iCalUtilityFunctions::_date_time_string( date( 'YmdTHis\Z', $date ), 6 ); - unset( $rDates[1]['unparsedtext'] ); - } - } - } - } - elseif( 'date-time' == $type ) { - foreach( $content['value'] as & $rDate ) { - if( ( isset( $rDate['tz'] ) && // fix UTC-date if offset set - iCalUtilityFunctions::_isOffset( $rDate['tz'] ) && - ( 'Z' != $rDate['tz'] )) - || ( isset( $content['params']['TZID'] ) && - iCalUtilityFunctions::_isOffset( $content['params']['TZID'] ) && - ( 'Z' != $content['params']['TZID'] ))) { - $offset = isset( $rDate['tz'] ) ? $rDate['tz'] : $content['params']['TZID']; - $date = mktime( (int) $rDate['hour'], - (int) $rDate['min'], - (int) ($rDate['sec'] + iCalUtilityFunctions::_tz2offset( $offset )), - (int) $rDate['month'], - (int) $rDate['day'], - (int) $rDate['year'] ); - unset( $rDate['tz'] ); - $rDate = iCalUtilityFunctions::_date_time_string( date( 'YmdTHis\Z', $date ), 6 ); - unset( $rDate['unparsedtext'] ); - } - } - } - unset( $content['params']['VALUE'] ); - _addXMLchild( $properties, $prop, $type, $content['value'], $content['params'] ); - } - break; - case 'categories': - case 'comment': - case 'contact': - case 'description': - case 'related-to': - case 'resources': - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - if(( 'related-to' != $prop ) && !isset( $content['params']['LANGUAGE'] )) { - if( $langComp ) - $content['params']['LANGUAGE'] = $langComp; - elseif( $langCal ) - $content['params']['LANGUAGE'] = $langCal; - } - _addXMLchild( $properties, $prop, 'text', $content['value'], $content['params'] ); - } - break; - case 'x-prop': - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $content[0], 'unknown', $content[1]['value'], $content[1]['params'] ); - break; - case 'created': // single occurence below, if set - case 'completed': - case 'dtstamp': - case 'last-modified': - $utcDate = TRUE; - case 'dtstart': - case 'dtend': - case 'due': - case 'recurrence-id': - if( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - if( isset( $content['params']['VALUE'] ) && ( 'DATE' == $content['params']['VALUE'] )) { - $type = 'date'; - unset( $content['value']['hour'], $content['value']['min'], $content['value']['sec'] ); - } - else { - $type = 'date-time'; - if( isset( $utcDate ) && !isset( $content['value']['tz'] )) - $content['value']['tz'] = 'Z'; - if( ( isset( $content['value']['tz'] ) && // fix UTC-date if offset set - iCalUtilityFunctions::_isOffset( $content['value']['tz'] ) && - ( 'Z' != $content['value']['tz'] )) - || ( isset( $content['params']['TZID'] ) && - iCalUtilityFunctions::_isOffset( $content['params']['TZID'] ) && - ( 'Z' != $content['params']['TZID'] ))) { - $offset = isset( $content['value']['tz'] ) ? $content['value']['tz'] : $content['params']['TZID']; - $date = mktime( (int) $content['value']['hour'], - (int) $content['value']['min'], - (int) ($content['value']['sec'] + iCalUtilityFunctions::_tz2offset( $offset )), - (int) $content['value']['month'], - (int) $content['value']['day'], - (int) $content['value']['year'] ); - unset( $content['value']['tz'], $content['params']['TZID'] ); - $content['value'] = iCalUtilityFunctions::_date_time_string( date( 'YmdTHis\Z', $date ), 6 ); - unset( $content['value']['unparsedtext'] ); - } - elseif( isset( $content['value']['tz'] ) && !empty( $content['value']['tz'] ) && - ( 'Z' != $content['value']['tz'] ) && !isset( $content['params']['TZID'] )) { - $content['params']['TZID'] = $content['value']['tz']; - unset( $content['value']['tz'] ); - } - } - unset( $content['params']['VALUE'] ); - if(( isset( $content['params']['TZID'] ) && empty( $content['params']['TZID'] )) || @is_null( $content['params']['TZID'] )) - unset( $content['params']['TZID'] ); - _addXMLchild( $properties, $prop, $type, $content['value'], $content['params'] ); - } - unset( $utcDate ); - break; - case 'duration': - if( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'duration', $content['value'], $content['params'] ); - break; - case 'rrule': - while( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'recur', $content['value'], $content['params'] ); - break; - case 'class': - case 'location': - case 'status': - case 'summary': - case 'transp': - case 'tzid': - case 'uid': - if( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - if((( 'location' == $prop ) || ( 'summary' == $prop )) && !isset( $content['params']['LANGUAGE'] )) { - if( $langComp ) - $content['params']['LANGUAGE'] = $langComp; - elseif( $langCal ) - $content['params']['LANGUAGE'] = $langCal; - } - _addXMLchild( $properties, $prop, 'text', $content['value'], $content['params'] ); - } - break; - case 'geo': - if( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'geo', $content['value'], $content['params'] ); - break; - case 'organizer': - if( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) { - if( isset( $content['params']['CN'] ) && !isset( $content['params']['LANGUAGE'] )) { - if( $langComp ) - $content['params']['LANGUAGE'] = $langComp; - elseif( $langCal ) - $content['params']['LANGUAGE'] = $langCal; - } - _addXMLchild( $properties, $prop, 'cal-address', $content['value'], $content['params'] ); - } - break; - case 'percent-complete': - case 'priority': - case 'sequence': - if( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'integer', $content['value'], $content['params'] ); - break; - case 'tzurl': - case 'url': - if( FALSE !== ( $content = $component->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'uri', $content['value'], $content['params'] ); - break; - } // end switch( $prop ) - } // end foreach( $props as $prop ) - /** fix subComponent properties, if any */ - foreach( $subComps as $subCompName ) { - while( FALSE !== ( $subcomp = $component->getComponent( $subCompName ))) { - $child2 = $child->addChild( $subCompName ); - $properties = $child2->addChild( 'properties' ); - $langComp = $subcomp->getConfig( 'language' ); - foreach( $subCompProps as $prop ) { - switch( $prop ) { - case 'attach': // may occur multiple times, below - while( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) { - $type = ( isset( $content['params']['VALUE'] ) && ( 'BINARY' == $content['params']['VALUE'] )) ? 'binary' : 'uri'; - unset( $content['params']['VALUE'] ); - _addXMLchild( $properties, $prop, $type, $content['value'], $content['params'] ); - } - break; - case 'attendee': - while( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) { - if( isset( $content['params']['CN'] ) && !isset( $content['params']['LANGUAGE'] )) { - if( $langComp ) - $content['params']['LANGUAGE'] = $langComp; - elseif( $langCal ) - $content['params']['LANGUAGE'] = $langCal; - } - _addXMLchild( $properties, $prop, 'cal-address', $content['value'], $content['params'] ); - } - break; - case 'comment': - case 'tzname': - while( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) { - if( !isset( $content['params']['LANGUAGE'] )) { - if( $langComp ) - $content['params']['LANGUAGE'] = $langComp; - elseif( $langCal ) - $content['params']['LANGUAGE'] = $langCal; - } - _addXMLchild( $properties, $prop, 'text', $content['value'], $content['params'] ); - } - break; - case 'rdate': - while( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) { - $type = 'date-time'; - if( isset( $content['params']['VALUE'] )) { - if( 'DATE' == $content['params']['VALUE'] ) - $type = 'date'; - elseif( 'PERIOD' == $content['params']['VALUE'] ) - $type = 'period'; - } - if( 'period' == $type ) { - foreach( $content['value'] as & $rDates ) { - if( ( isset( $rDates[0]['tz'] ) && // fix UTC-date if offset set - iCalUtilityFunctions::_isOffset( $rDates[0]['tz'] ) && - ( 'Z' != $rDates[0]['tz'] )) - || ( isset( $content['params']['TZID'] ) && - iCalUtilityFunctions::_isOffset( $content['params']['TZID'] ) && - ( 'Z' != $content['params']['TZID'] ))) { - $offset = isset( $rDates[0]['tz'] ) ? $rDates[0]['tz'] : $content['params']['TZID']; - $date = mktime( (int) $rDates[0]['hour'], - (int) $rDates[0]['min'], - (int) ($rDates[0]['sec'] + iCalUtilityFunctions::_tz2offset( $offset )), - (int) $rDates[0]['month'], - (int) $rDates[0]['day'], - (int) $rDates[0]['year'] ); - unset( $rDates[0]['tz'] ); - $rDates[0] = iCalUtilityFunctions::_date_time_string( date( 'YmdTHis\Z', $date ), 6 ); - unset( $rDates[0]['unparsedtext'] ); - } - if( isset( $rDates[1]['year'] )) { - if( ( isset( $rDates[1]['tz'] ) && // fix UTC-date if offset set - iCalUtilityFunctions::_isOffset( $rDates[1]['tz'] ) && - ( 'Z' != $rDates[1]['tz'] )) - || ( isset( $content['params']['TZID'] ) && - iCalUtilityFunctions::_isOffset( $content['params']['TZID'] ) && - ( 'Z' != $content['params']['TZID'] ))) { - $offset = isset( $rDates[1]['tz'] ) ? $rDates[1]['tz'] : $content['params']['TZID']; - $date = mktime( (int) $rDates[1]['hour'], - (int) $rDates[1]['min'], - (int) ($rDates[1]['sec'] + iCalUtilityFunctions::_tz2offset( $offset )), - (int) $rDates[1]['month'], - (int) $rDates[1]['day'], - (int) $rDates[1]['year'] ); - unset( $rDates[1]['tz'] ); - $rDates[1] = iCalUtilityFunctions::_date_time_string( date( 'YmdTHis\Z', $date ), 6 ); - unset( $rDates[1]['unparsedtext'] ); - } - } - } - } - elseif( 'date-time' == $type ) { - foreach( $content['value'] as & $rDate ) { - if( ( isset( $rDate['tz'] ) && // fix UTC-date if offset set - iCalUtilityFunctions::_isOffset( $rDate['tz'] ) && - ( 'Z' != $rDate['tz'] )) - || ( isset( $content['params']['TZID'] ) && - iCalUtilityFunctions::_isOffset( $content['params']['TZID'] ) && - ( 'Z' != $content['params']['TZID'] ))) { - $offset = isset( $rDate['tz'] ) ? $rDate['tz'] : $content['params']['TZID']; - $date = mktime( (int) $rDate['hour'], - (int) $rDate['min'], - (int) ($rDate['sec'] + iCalUtilityFunctions::_tz2offset( $offset )), - (int) $rDate['month'], - (int) $rDate['day'], - (int) $rDate['year'] ); - unset( $rDate['tz'] ); - $rDate = iCalUtilityFunctions::_date_time_string( date( 'YmdTHis\Z', $date ), 6 ); - unset( $rDate['unparsedtext'] ); - } - } - } - unset( $content['params']['VALUE'] ); - _addXMLchild( $properties, $prop, $type, $content['value'], $content['params'] ); - } - break; - case 'x-prop': - while( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $content[0], 'unknown', $content[1]['value'], $content[1]['params'] ); - break; - case 'action': // single occurence below, if set - case 'description': - case 'summary': - if( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) { - if(( 'action' != $prop ) && !isset( $content['params']['LANGUAGE'] )) { - if( $langComp ) - $content['params']['LANGUAGE'] = $langComp; - elseif( $langCal ) - $content['params']['LANGUAGE'] = $langCal; - } - _addXMLchild( $properties, $prop, 'text', $content['value'], $content['params'] ); - } - break; - case 'dtstart': - if( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) { - unset( $content['value']['tz'], $content['params']['VALUE'] ); // always local time - _addXMLchild( $properties, $prop, 'date-time', $content['value'], $content['params'] ); - } - break; - case 'duration': - if( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'duration', $content['value'], $content['params'] ); - break; - case 'repeat': - if( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'integer', $content['value'], $content['params'] ); - break; - case 'trigger': - if( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) { - if( isset( $content['value']['year'] ) && - isset( $content['value']['month'] ) && - isset( $content['value']['day'] )) - $type = 'date-time'; - else - $type = 'duration'; - _addXMLchild( $properties, $prop, $type, $content['value'], $content['params'] ); - } - break; - case 'tzoffsetto': - case 'tzoffsetfrom': - if( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'utc-offset', $content['value'], $content['params'] ); - break; - case 'rrule': - while( FALSE !== ( $content = $subcomp->getProperty( $prop, FALSE, TRUE ))) - _addXMLchild( $properties, $prop, 'recur', $content['value'], $content['params'] ); - break; - } // switch( $prop ) - } // end foreach( $subCompProps as $prop ) - } // end while( FALSE !== ( $subcomp = $component->getComponent( subCompName ))) - } // end foreach( $subCombs as $subCompName ) - } // end while( FALSE !== ( $component = $calendar->getComponent( $compName ))) - } // end foreach( $comps as $compName) - return $xml->asXML(); -} -/** - * Add children to a SimpleXMLelement - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.1 - 2012-01-16 - * @param object $parent, reference to a SimpleXMLelement node - * @param string $name, new element node name - * @param string $type, content type, subelement(-s) name - * @param string $content, new subelement content - * @param array $params, new element 'attributes' - * @return void - */ -function _addXMLchild( & $parent, $name, $type, $content, $params=array()) { - /** create new child node */ - $child = $parent->addChild( strtolower( $name )); - /** fix attributes */ - if( is_array( $content ) && isset( $content['fbtype'] )) { - $params['FBTYPE'] = $content['fbtype']; - unset( $content['fbtype'] ); - } - if( isset( $params['VALUE'] )) - unset( $params['VALUE'] ); - if(( 'trigger' == $name ) && ( 'duration' == $type ) && ( TRUE !== $content['relatedStart'] )) - $params['RELATED'] = 'END'; - if( !empty( $params )) { - $parameters = $child->addChild( 'parameters' ); - foreach( $params as $param => $parVal ) { - $param = strtolower( $param ); - if( 'x-' == substr( $param, 0, 2 )) { - $p1 = $parameters->addChild( $param ); - $p2 = $p1->addChild( 'unknown', htmlspecialchars( $parVal )); - } - else { - $p1 = $parameters->addChild( $param ); - switch( $param ) { - case 'altrep': - case 'dir': $ptype = 'uri'; break; - case 'delegated-from': - case 'delegated-to': - case 'member': - case 'sent-by': $ptype = 'cal-address'; break; - case 'rsvp': $ptype = 'boolean'; break ; - default: $ptype = 'text'; break; - } - if( is_array( $parVal )) { - foreach( $parVal as $pV ) - $p2 = $p1->addChild( $ptype, htmlspecialchars( $pV )); - } - else - $p2 = $p1->addChild( $ptype, htmlspecialchars( $parVal )); - } - } - } - if( empty( $content ) && ( '0' != $content )) - return; - /** store content */ - switch( $type ) { - case 'binary': - $v = $child->addChild( $type, $content ); - break; - case 'boolean': - break; - case 'cal-address': - $v = $child->addChild( $type, $content ); - break; - case 'date': - if( array_key_exists( 'year', $content )) - $content = array( $content ); - foreach( $content as $date ) { - $str = sprintf( '%04d-%02d-%02d', $date['year'], $date['month'], $date['day'] ); - $v = $child->addChild( $type, $str ); - } - break; - case 'date-time': - if( array_key_exists( 'year', $content )) - $content = array( $content ); - foreach( $content as $dt ) { - if( !isset( $dt['hour'] )) $dt['hour'] = 0; - if( !isset( $dt['min'] )) $dt['min'] = 0; - if( !isset( $dt['sec'] )) $dt['sec'] = 0; - $str = sprintf( '%04d-%02d-%02dT%02d:%02d:%02d', $dt['year'], $dt['month'], $dt['day'], $dt['hour'], $dt['min'], $dt['sec'] ); - if( isset( $dt['tz'] ) && ( 'Z' == $dt['tz'] )) - $str .= 'Z'; - $v = $child->addChild( $type, $str ); - } - break; - case 'duration': - $output = (( 'trigger' == $name ) && ( FALSE !== $content['before'] )) ? '-' : ''; - $v = $child->addChild( $type, $output.iCalUtilityFunctions::_format_duration( $content ) ); - break; - case 'geo': - $v1 = $child->addChild( 'latitude', number_format( (float) $content['latitude'], 6, '.', '' )); - $v1 = $child->addChild( 'longitude', number_format( (float) $content['longitude'], 6, '.', '' )); - break; - case 'integer': - $v = $child->addChild( $type, $content ); - break; - case 'period': - if( !is_array( $content )) - break; - foreach( $content as $period ) { - $v1 = $child->addChild( $type ); - $str = sprintf( '%04d-%02d-%02dT%02d:%02d:%02d', $period[0]['year'], $period[0]['month'], $period[0]['day'], $period[0]['hour'], $period[0]['min'], $period[0]['sec'] ); - if( isset( $period[0]['tz'] ) && ( 'Z' == $period[0]['tz'] )) - $str .= 'Z'; - $v2 = $v1->addChild( 'start', $str ); - if( array_key_exists( 'year', $period[1] )) { - $str = sprintf( '%04d-%02d-%02dT%02d:%02d:%02d', $period[1]['year'], $period[1]['month'], $period[1]['day'], $period[1]['hour'], $period[1]['min'], $period[1]['sec'] ); - if( isset($period[1]['tz'] ) && ( 'Z' == $period[1]['tz'] )) - $str .= 'Z'; - $v2 = $v1->addChild( 'end', $str ); - } - else - $v2 = $v1->addChild( 'duration', iCalUtilityFunctions::_format_duration( $period[1] )); - } - break; - case 'recur': - foreach( $content as $rulelabel => $rulevalue ) { - $rulelabel = strtolower( $rulelabel ); - switch( $rulelabel ) { - case 'until': - if( isset( $rulevalue['hour'] )) - $str = sprintf( '%04d-%02d-%02dT%02d:%02d:%02dZ', $rulevalue['year'], $rulevalue['month'], $rulevalue['day'], $rulevalue['hour'], $rulevalue['min'], $rulevalue['sec'] ); - else - $str = sprintf( '%04d-%02d-%02d', $rulevalue['year'], $rulevalue['month'], $rulevalue['day'] ); - $v = $child->addChild( $rulelabel, $str ); - break; - case 'bysecond': - case 'byminute': - case 'byhour': - case 'bymonthday': - case 'byyearday': - case 'byweekno': - case 'bymonth': - case 'bysetpos': { - if( is_array( $rulevalue )) { - foreach( $rulevalue as $vix => $valuePart ) - $v = $child->addChild( $rulelabel, $valuePart ); - } - else - $v = $child->addChild( $rulelabel, $rulevalue ); - break; - } - case 'byday': { - if( isset( $rulevalue['DAY'] )) { - $str = ( isset( $rulevalue[0] )) ? $rulevalue[0] : ''; - $str .= $rulevalue['DAY']; - $p = $child->addChild( $rulelabel, $str ); - } - else { - foreach( $rulevalue as $valuePart ) { - if( isset( $valuePart['DAY'] )) { - $str = ( isset( $valuePart[0] )) ? $valuePart[0] : ''; - $str .= $valuePart['DAY']; - $p = $child->addChild( $rulelabel, $str ); - } - else - $p = $child->addChild( $rulelabel, $valuePart ); - } - } - break; - } - case 'freq': - case 'count': - case 'interval': - case 'wkst': - default: - $p = $child->addChild( $rulelabel, $rulevalue ); - break; - } // end switch( $rulelabel ) - } // end foreach( $content as $rulelabel => $rulevalue ) - break; - case 'rstatus': - $v = $child->addChild( 'code', number_format( (float) $content['statcode'], 2, '.', '')); - $v = $child->addChild( 'description', htmlspecialchars( $content['text'] )); - if( isset( $content['extdata'] )) - $v = $child->addChild( 'data', htmlspecialchars( $content['extdata'] )); - break; - case 'text': - if( !is_array( $content )) - $content = array( $content ); - foreach( $content as $part ) - $v = $child->addChild( $type, htmlspecialchars( $part )); - break; - case 'time': - break; - case 'uri': - $v = $child->addChild( $type, $content ); - break; - case 'utc-offset': - if( in_array( substr( $content, 0, 1 ), array( '-', '+' ))) { - $str = substr( $content, 0, 1 ); - $content = substr( $content, 1 ); - } - else - $str = '+'; - $str .= substr( $content, 0, 2 ).':'.substr( $content, 2, 2 ); - if( 4 < strlen( $content )) - $str .= ':'.substr( $content, 4 ); - $v = $child->addChild( $type, $str ); - break; - case 'unknown': - default: - if( is_array( $content )) - $content = implode( '', $content ); - $v = $child->addChild( 'unknown', htmlspecialchars( $content )); - break; - } -} -/** - * parse xml string into iCalcreator instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.2 - 2012-01-31 - * @param string $xmlstr - * @param array $iCalcfg iCalcreator config array (opt) - * @return mixed iCalcreator instance or FALSE on error - */ -function & XMLstr2iCal( $xmlstr, $iCalcfg=array()) { - libxml_use_internal_errors( TRUE ); - $xml = simplexml_load_string( $xmlstr ); - if( !$xml ) { - $str = ''; - $return = FALSE; - foreach( libxml_get_errors() as $error ) { - switch ( $error->level ) { - case LIBXML_ERR_FATAL: $str .= ' FATAL '; break; - case LIBXML_ERR_ERROR: $str .= ' ERROR '; break; - case LIBXML_ERR_WARNING: - default: $str .= ' WARNING '; break; - } - $str .= PHP_EOL.'Error when loading XML'; - if( !empty( $error->file )) - $str .= ', file:'.$error->file.', '; - $str .= ', line:'.$error->line; - $str .= ', ('.$error->code.') '.$error->message; - } - error_log( $str ); - if( LIBXML_ERR_WARNING != $error->level ) - return $return; - libxml_clear_errors(); - } - return xml2iCal( $xml, $iCalcfg ); -} -/** - * parse xml file into iCalcreator instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.2 - 2012-01-20 - * @param string $xmlfile - * @param array$iCalcfg iCalcreator config array (opt) - * @return mixediCalcreator instance or FALSE on error - */ -function & XMLfile2iCal( $xmlfile, $iCalcfg=array()) { - libxml_use_internal_errors( TRUE ); - $xml = simplexml_load_file( $xmlfile ); - if( !$xml ) { - $str = ''; - foreach( libxml_get_errors() as $error ) { - switch ( $error->level ) { - case LIBXML_ERR_FATAL: $str .= 'FATAL '; break; - case LIBXML_ERR_ERROR: $str .= 'ERROR '; break; - case LIBXML_ERR_WARNING: - default: $str .= 'WARNING '; break; - } - $str .= 'Failed loading XML'.PHP_EOL; - if( !empty( $error->file )) - $str .= ' file:'.$error->file.', '; - $str .= 'line:'.$error->line.PHP_EOL; - $str .= '('.$error->code.') '.$error->message.PHP_EOL; - } - error_log( $str ); - if( LIBXML_ERR_WARNING != $error->level ) - return FALSE; - libxml_clear_errors(); - } - return xml2iCal( $xml, $iCalcfg ); -} -/** - * parse SimpleXMLElement xCal into iCalcreator instance - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.2 - 2012-01-27 - * @param object $xmlobj SimpleXMLElement - * @param array $iCalcfg iCalcreator config array (opt) - * @return mixed iCalcreator instance or FALSE on error - */ -function & XML2iCal( $xmlobj, $iCalcfg=array()) { - $iCal = new vcalendar( $iCalcfg ); - foreach( $xmlobj->children() as $icalendar ) { // vcalendar - foreach( $icalendar->children() as $calPart ) { // calendar properties and components - if( 'components' == $calPart->getName()) { - foreach( $calPart->children() as $component ) { // single components - if( 0 < $component->count()) - _getXMLComponents( $iCal, $component ); - } - } - elseif(( 'properties' == $calPart->getName()) && ( 0 < $calPart->count())) { - foreach( $calPart->children() as $calProp ) { // calendar properties - $propName = $calProp->getName(); - if(( 'calscale' != $propName ) && ( 'method' != $propName ) && ( 'x-' != substr( $propName,0,2 ))) - continue; - $params = array(); - foreach( $calProp->children() as $calPropElem ) { // single calendar property - if( 'parameters' == $calPropElem->getName()) - $params = _getXMLParams( $calPropElem ); - else - $iCal->setProperty( $propName, reset( $calPropElem ), $params ); - } // end foreach( $calProp->children() as $calPropElem ) - } // end foreach( $calPart->properties->children() as $calProp ) - } // end if( 0 < $calPart->properties->count()) - } // end foreach( $icalendar->children() as $calPart ) - } // end foreach( $xmlobj->children() as $icalendar ) - return $iCal; -} -/** - * parse SimpleXMLElement xCal property parameters and return iCalcreator property parameter array - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.2 - 2012-01-15 - * @param object $parameters SimpleXMLElement - * @return array iCalcreator property parameter array - */ -function _getXMLParams( & $parameters ) { - if( 1 > $parameters->count()) - return array(); - $params = array(); - foreach( $parameters->children() as $parameter ) { // single parameter key - $key = strtoupper( $parameter->getName()); - $value = array(); - foreach( $parameter->children() as $paramValue ) // skip parameter value type - $value[] = reset( $paramValue ); - if( 2 > count( $value )) - $params[$key] = html_entity_decode( reset( $value )); - else - $params[$key] = $value; - } - return $params; -} -/** - * parse SimpleXMLElement xCal components, create iCalcreator component and update - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.2 - 2012-01-15 - * @param array $iCal iCalcreator calendar instance - * @param object $component SimpleXMLElement - * @return void - */ -function _getXMLComponents( & $iCal, & $component ) { - $compName = $component->getName(); - $comp = & $iCal->newComponent( $compName ); - $subComponents = array( 'valarm', 'standard', 'daylight' ); - foreach( $component->children() as $compPart ) { // properties and (opt) subComponents - if( 1 > $compPart->count()) - continue; - if( in_array( $compPart->getName(), $subComponents )) - _getXMLComponents( $comp, $compPart ); - elseif( 'properties' == $compPart->getName()) { - foreach( $compPart->children() as $property ) // properties as single property - _getXMLProperties( $comp, $property ); - } - } // end foreach( $component->children() as $compPart ) -} -/** - * parse SimpleXMLElement xCal property, create iCalcreator component property - * - * @author Kjell-Inge Gustafsson, kigkonsult - * @since 2.11.2 - 2012-01-27 - * @param array $iCal iCalcreator calendar instance - * @param object $component SimpleXMLElement - * @return void - */ -function _getXMLProperties( & $iCal, & $property ) { - $propName = $property->getName(); - $value = $params = array(); - $valueType = ''; - foreach( $property->children() as $propPart ) { // calendar property parameters (opt) and value(-s) - $valueType = $propPart->getName(); - if( 'parameters' == $valueType) { - $params = _getXMLParams( $propPart ); - continue; - } - switch( $valueType ) { - case 'binary': - $value = reset( $propPart ); - break; - case 'boolean': - break; - case 'cal-address': - $value = reset( $propPart ); - break; - case 'date': - $params['VALUE'] = 'DATE'; - case 'date-time': - if(( 'exdate' == $propName ) || ( 'rdate' == $propName )) - $value[] = reset( $propPart ); - else - $value = reset( $propPart ); - break; - case 'duration': - $value = reset( $propPart ); - break; -// case 'geo': - case 'latitude': - case 'longitude': - $value[$valueType] = reset( $propPart ); - break; - case 'integer': - $value = reset( $propPart ); - break; - case 'period': - if( 'rdate' == $propName ) - $params['VALUE'] = 'PERIOD'; - $pData = array(); - foreach( $propPart->children() as $periodPart ) - $pData[] = reset( $periodPart ); - if( !empty( $pData )) - $value[] = $pData; - break; -// case 'rrule': - case 'freq': - case 'count': - case 'until': - case 'interval': - case 'wkst': - $value[$valueType] = reset( $propPart ); - break; - case 'bysecond': - case 'byminute': - case 'byhour': - case 'bymonthday': - case 'byyearday': - case 'byweekno': - case 'bymonth': - case 'bysetpos': - $value[$valueType][] = reset( $propPart ); - break; - case 'byday': - $byday = reset( $propPart ); - if( 2 == strlen( $byday )) - $value[$valueType][] = array( 'DAY' => $byday ); - else { - $day = substr( $byday, -2 ); - $key = substr( $byday, 0, ( strlen( $byday ) - 2 )); - $value[$valueType][] = array( $key, 'DAY' => $day ); - } - break; -// case 'rstatus': - case 'code': - $value[0] = reset( $propPart ); - break; - case 'description': - $value[1] = reset( $propPart ); - break; - case 'data': - $value[2] = reset( $propPart ); - break; - case 'text': - $text = str_replace( array( "\r\n", "\n\r", "\r", "\n"), '\n', reset( $propPart )); - $value['text'][] = html_entity_decode( $text ); - break; - case 'time': - break; - case 'uri': - $value = reset( $propPart ); - break; - case 'utc-offset': - $value = str_replace( ':', '', reset( $propPart )); - break; - case 'unknown': - default: - $value = html_entity_decode( reset( $propPart )); - break; - } // end switch( $valueType ) - } // end foreach( $property->children() as $propPart ) - if( 'freebusy' == $propName ) { - $fbtype = $params['FBTYPE']; - unset( $params['FBTYPE'] ); - $iCal->setProperty( $propName, $fbtype, $value, $params ); - } - elseif( 'geo' == $propName ) - $iCal->setProperty( $propName, $value['latitude'], $value['longitude'], $params ); - elseif( 'request-status' == $propName ) { - if( !isset( $value[2] )) - $value[2] = FALSE; - $iCal->setProperty( $propName, $value[0], $value[1], $value[2], $params ); - } - else { - if( isset( $value['text'] ) && is_array( $value['text'] )) { - if(( 'categories' == $propName ) || ( 'resources' == $propName )) - $value = $value['text']; - else - $value = reset( $value['text'] ); - } - $iCal->setProperty( $propName, $value, $params ); - } -} -/** - * Additional functions to use with vtimezone components - * For use with - * iCalcreator (kigkonsult.se/iCalcreator/index.php) - * copyright (c) 2011 Yitzchok Lavi - * icalcreator@onebigsystem.com - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -/** - * Additional functions to use with vtimezone components - * - * Before calling the functions, set time zone 'GMT' ('date_default_timezone_set')! - * - * @author Yitzchok Lavi - * adjusted for iCalcreator Kjell-Inge Gustafsson, kigkonsult - * @version 1.0.2 - 2011-02-24 - * - */ -/** - * Returns array with the offset information from UTC for a (UTC) datetime/timestamp in the - * timezone, according to the VTIMEZONE information in the input array. - * - * $param array $timezonesarray, output from function getTimezonesAsDateArrays (below) - * $param string $tzid, time zone identifier - * $param mixed $timestamp, timestamp or a UTC datetime (in array format) - * @return array, time zone data with keys for 'offsetHis', 'offsetSec' and 'tzname' - * - */ -function getTzOffsetForDate($timezonesarray, $tzid, $timestamp) { - if( is_array( $timestamp )) { -//$disp = sprintf( '%04d%02d%02d %02d%02d%02d', $timestamp['year'], $timestamp['month'], $timestamp['day'], $timestamp['hour'], $timestamp['min'], $timestamp['sec'] ); - $timestamp = gmmktime( - $timestamp['hour'], - $timestamp['min'], - $timestamp['sec'], - $timestamp['month'], - $timestamp['day'], - $timestamp['year'] - ) ; -//echo ' '."\n".' '.$timestamp.''.$disp.' '."\n".' '; // test ### - } - $tzoffset = array(); - // something to return if all goes wrong (such as if $tzid doesn't find us an array of dates) - $tzoffset['offsetHis'] = '+0000'; - $tzoffset['offsetSec'] = 0; - $tzoffset['tzname'] = '?'; - if( !isset( $timezonesarray[$tzid] )) - return $tzoffset; - $tzdatearray = $timezonesarray[$tzid]; - if ( is_array($tzdatearray) ) { - sort($tzdatearray); // just in case - if ( $timestamp < $tzdatearray[0]['timestamp'] ) { - // our date is before the first change - $tzoffset['offsetHis'] = $tzdatearray[0]['tzbefore']['offsetHis'] ; - $tzoffset['offsetSec'] = $tzdatearray[0]['tzbefore']['offsetSec'] ; - $tzoffset['tzname'] = $tzdatearray[0]['tzbefore']['offsetHis'] ; // we don't know the tzname in this case - } elseif ( $timestamp >= $tzdatearray[count($tzdatearray)-1]['timestamp'] ) { - // our date is after the last change (we do this so our scan can stop at the last record but one) - $tzoffset['offsetHis'] = $tzdatearray[count($tzdatearray)-1]['tzafter']['offsetHis'] ; - $tzoffset['offsetSec'] = $tzdatearray[count($tzdatearray)-1]['tzafter']['offsetSec'] ; - $tzoffset['tzname'] = $tzdatearray[count($tzdatearray)-1]['tzafter']['tzname'] ; - } else { - // our date somewhere in between - // loop through the list of dates and stop at the one where the timestamp is before our date and the next one is after it - // we don't include the last date in our loop as there isn't one after it to check - for ( $i = 0 ; $i <= count($tzdatearray)-2 ; $i++ ) { - if(( $timestamp >= $tzdatearray[$i]['timestamp'] ) && ( $timestamp < $tzdatearray[$i+1]['timestamp'] )) { - $tzoffset['offsetHis'] = $tzdatearray[$i]['tzafter']['offsetHis'] ; - $tzoffset['offsetSec'] = $tzdatearray[$i]['tzafter']['offsetSec'] ; - $tzoffset['tzname'] = $tzdatearray[$i]['tzafter']['tzname'] ; - break; - } - } - } - } - return $tzoffset; -} -/** - * Returns an array containing all the timezone data in the vcalendar object - * - * @param object $vcalendar, iCalcreator calendar instance - * @return array, time zone transition timestamp, array before(offsetHis, offsetSec), array after(offsetHis, offsetSec, tzname) - * based on the timezone data in the vcalendar object - * - */ -function getTimezonesAsDateArrays($vcalendar) { - $timezonedata = array(); - while( $vtz = $vcalendar->getComponent( 'vtimezone' )) { - $tzid = $vtz->getProperty('tzid'); - $alltzdates = array(); - while ( $vtzc = $vtz->getComponent( 'standard' )) { - $newtzdates = expandTimezoneDates($vtzc); - $alltzdates = array_merge($alltzdates, $newtzdates); - } - while ( $vtzc = $vtz->getComponent( 'daylight' )) { - $newtzdates = expandTimezoneDates($vtzc); - $alltzdates = array_merge($alltzdates, $newtzdates); - } - sort($alltzdates); - $timezonedata[$tzid] = $alltzdates; - } - return $timezonedata; -} -/** - * Returns an array containing time zone data from vtimezone standard/daylight instances - * - * @param object $vtzc, an iCalcreator calendar standard/daylight instance - * @return array, time zone data; array before(offsetHis, offsetSec), array after(offsetHis, offsetSec, tzname) - * - */ -function expandTimezoneDates($vtzc) { - $tzdates = array(); - // prepare time zone "description" to attach to each change - $tzbefore = array(); - $tzbefore['offsetHis'] = $vtzc->getProperty('tzoffsetfrom') ; - $tzbefore['offsetSec'] = iCalUtilityFunctions::_tz2offset($tzbefore['offsetHis']); - if(( '-' != substr( (string) $tzbefore['offsetSec'], 0, 1 )) && ( '+' != substr( (string) $tzbefore['offsetSec'], 0, 1 ))) - $tzbefore['offsetSec'] = '+'.$tzbefore['offsetSec']; - $tzafter = array(); - $tzafter['offsetHis'] = $vtzc->getProperty('tzoffsetto') ; - $tzafter['offsetSec'] = iCalUtilityFunctions::_tz2offset($tzafter['offsetHis']); - if(( '-' != substr( (string) $tzafter['offsetSec'], 0, 1 )) && ( '+' != substr( (string) $tzafter['offsetSec'], 0, 1 ))) - $tzafter['offsetSec'] = '+'.$tzafter['offsetSec']; - if( FALSE === ( $tzafter['tzname'] = $vtzc->getProperty('tzname'))) - $tzafter['tzname'] = $tzafter['offsetHis']; - // find out where to start from - $dtstart = $vtzc->getProperty('dtstart'); - $dtstarttimestamp = mktime( - $dtstart['hour'], - $dtstart['min'], - $dtstart['sec'], - $dtstart['month'], - $dtstart['day'], - $dtstart['year'] - ) ; - if( !isset( $dtstart['unparsedtext'] )) // ?? - $dtstart['unparsedtext'] = sprintf( '%04d%02d%02dT%02d%02d%02d', $dtstart['year'], $dtstart['month'], $dtstart['day'], $dtstart['hour'], $dtstart['min'], $dtstart['sec'] ); - if ( $dtstarttimestamp == 0 ) { - // it seems that the dtstart string may not have parsed correctly - // let's set a timestamp starting from 1902, using the time part of the original string - // so that the time will change at the right time of day - // at worst we'll get midnight again - $origdtstartsplit = explode('T',$dtstart['unparsedtext']) ; - $dtstarttimestamp = strtotime("19020101",0); - $dtstarttimestamp = strtotime($origdtstartsplit[1],$dtstarttimestamp); - } - // the date (in dtstart and opt RDATE/RRULE) is ALWAYS LOCAL (not utc!!), adjust from 'utc' to 'local' timestamp - $diff = -1 * $tzbefore['offsetSec']; - $dtstarttimestamp += $diff; - // add this (start) change to the array of changes - $tzdates[] = array( - 'timestamp' => $dtstarttimestamp, - 'tzbefore' => $tzbefore, - 'tzafter' => $tzafter - ); - $datearray = getdate($dtstarttimestamp); - // save original array to use time parts, because strtotime (used below) apparently loses the time - $changetime = $datearray ; - // generate dates according to an RRULE line - $rrule = $vtzc->getProperty('rrule') ; - if ( is_array($rrule) ) { - if ( $rrule['FREQ'] == 'YEARLY' ) { - // calculate transition dates starting from DTSTART - $offsetchangetimestamp = $dtstarttimestamp; - // calculate transition dates until 10 years in the future - $stoptimestamp = strtotime("+10 year",time()); - // if UNTIL is set, calculate until then (however far ahead) - if ( isset( $rrule['UNTIL'] ) && ( $rrule['UNTIL'] != '' )) { - $stoptimestamp = mktime( - $rrule['UNTIL']['hour'], - $rrule['UNTIL']['min'], - $rrule['UNTIL']['sec'], - $rrule['UNTIL']['month'], - $rrule['UNTIL']['day'], - $rrule['UNTIL']['year'] - ) ; - } - $count = 0 ; - $stopcount = isset( $rrule['COUNT'] ) ? $rrule['COUNT'] : 0 ; - $daynames = array( - 'SU' => 'Sunday', - 'MO' => 'Monday', - 'TU' => 'Tuesday', - 'WE' => 'Wednesday', - 'TH' => 'Thursday', - 'FR' => 'Friday', - 'SA' => 'Saturday' - ); - // repeat so long as we're between DTSTART and UNTIL, or we haven't prepared COUNT dates - while ( $offsetchangetimestamp < $stoptimestamp && ( $stopcount == 0 || $count < $stopcount ) ) { - // break up the timestamp into its parts - $datearray = getdate($offsetchangetimestamp); - if ( isset( $rrule['BYMONTH'] ) && ( $rrule['BYMONTH'] != 0 )) { - // set the month - $datearray['mon'] = $rrule['BYMONTH'] ; - } - if ( isset( $rrule['BYMONTHDAY'] ) && ( $rrule['BYMONTHDAY'] != 0 )) { - // set specific day of month - $datearray['mday'] = $rrule['BYMONTHDAY']; - } elseif ( is_array($rrule['BYDAY']) ) { - // find the Xth WKDAY in the month - // the starting point for this process is the first of the month set above - $datearray['mday'] = 1 ; - // turn $datearray as it is now back into a timestamp - $offsetchangetimestamp = mktime( - $datearray['hours'], - $datearray['minutes'], - $datearray['seconds'], - $datearray['mon'], - $datearray['mday'], - $datearray['year'] - ); - if ($rrule['BYDAY'][0] > 0) { - // to find Xth WKDAY in month, we find last WKDAY in month before - // we do that by finding first WKDAY in this month and going back one week - // then we add X weeks (below) - $offsetchangetimestamp = strtotime($daynames[$rrule['BYDAY']['DAY']],$offsetchangetimestamp); - $offsetchangetimestamp = strtotime("-1 week",$offsetchangetimestamp); - } else { - // to find Xth WKDAY before the end of the month, we find the first WKDAY in the following month - // we do that by going forward one month and going to WKDAY there - // then we subtract X weeks (below) - $offsetchangetimestamp = strtotime("+1 month",$offsetchangetimestamp); - $offsetchangetimestamp = strtotime($daynames[$rrule['BYDAY']['DAY']],$offsetchangetimestamp); - } - // now move forward or back the appropriate number of weeks, into the month we want - $offsetchangetimestamp = strtotime($rrule['BYDAY'][0] . " week",$offsetchangetimestamp); - $datearray = getdate($offsetchangetimestamp); - } - // convert the date parts back into a timestamp, setting the time parts according to the - // original time data which we stored - $offsetchangetimestamp = mktime( - $changetime['hours'], - $changetime['minutes'], - $changetime['seconds'] + $diff, - $datearray['mon'], - $datearray['mday'], - $datearray['year'] - ); - // add this change to the array of changes - $tzdates[] = array( - 'timestamp' => $offsetchangetimestamp, - 'tzbefore' => $tzbefore, - 'tzafter' => $tzafter - ); - // update counters (timestamp and count) - $offsetchangetimestamp = strtotime("+" . (( isset( $rrule['INTERVAL'] ) && ( $rrule['INTERVAL'] != 0 )) ? $rrule['INTERVAL'] : 1 ) . " year",$offsetchangetimestamp); - $count += 1 ; - } - } - } - // generate dates according to RDATE lines - while ($rdates = $vtzc->getProperty('rdate')) { - if ( is_array($rdates) ) { - - foreach ( $rdates as $rdate ) { - // convert the explicit change date to a timestamp - $offsetchangetimestamp = mktime( - $rdate['hour'], - $rdate['min'], - $rdate['sec'] + $diff, - $rdate['month'], - $rdate['day'], - $rdate['year'] - ) ; - // add this change to the array of changes - $tzdates[] = array( - 'timestamp' => $offsetchangetimestamp, - 'tzbefore' => $tzbefore, - 'tzafter' => $tzafter - ); - } - } - } - return $tzdates; -} -?> \ No newline at end of file diff --git a/dav/iCalcreator/lgpl.txt b/dav/iCalcreator/lgpl.txt deleted file mode 100755 index 5ab7695a..00000000 --- a/dav/iCalcreator/lgpl.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/dav/iCalcreator/releaseNotes-2.12.txt b/dav/iCalcreator/releaseNotes-2.12.txt deleted file mode 100755 index 2a145dd3..00000000 --- a/dav/iCalcreator/releaseNotes-2.12.txt +++ /dev/null @@ -1,88 +0,0 @@ -2.10.24 ###################### -upd returnCalendar, only create header 'content-length' when gziping output - -2.10.26 ###################### -Concatenate iCalcreator, utilityFunction and helper functions in iCalcreator.class.php file - -2.10.27 ###################### -parsing dates with extended (MS outlook) time zones - -2.10.28 ###################### -bug in function selectComponents, (continue if) missing dtstart - -2.10.29 ###################### -new function ms2phpTZ, (very) simple mapping of MS outlook time zones to PHP - -2.10.30 ###################### thanks Yitzchok -external (iCalUtilityFunctions) time zone helper contributions:getTimezonesAsDateArrays (expandTimezoneDates) and getTzOffsetForDate functions - -2.11.1 ###################### -creation of rfc6321 XML output, input iCalcreator instance -new (helper) function iCal2XML ('inner' _addXMLchild), - -2.11.2 ###################### -parse of rfc6321 XML input (string/file), output iCalcreator instance -new (helper) functions: XMLstr2iCal, XMLfile2iCal, XML2iCal -('inner' functions:_getXMLParams, _getXMLComponents, _getXMLProperties) - -2.11.3 ###################### -bug in getProperty, management of properties with multiple ocurrences - -2.11.4 ###################### -bug in _tz2offset, plus/minus error - -2.11.5 ###################### -updated _setDate _setDate2, setExdate, setRdate, utc offset management, Z-suffix - -2.11.7 ###################### -bug in function getConfig, 'directory' or 'filename' couldn't accept '0' (zero) - -2.11.8 ###################### -upd createTimezone (_setTZrrule), fixing from/to UTC offset and rdate(-s) -upd functions: _format_date_time, _setDate, _setDate2, setRdate, setExdate, - _setRexrule, _isArrayDate -new function: _strDate2arr - -2.11.9 ###################### -check x-props names, start with 'x-'/'X-' - -2.11.10 ###################### -function parse, management of list content in TEXT properties - -2.11.11 ###################### -always update PRODID when (re-)setting 'unique_id' - -2.11.12 ###################### -update management of (Attendee) parameter value lists -update rfc5545 parameters with 'DQUOTE' settings -function createAttendee and _createParams - -2.11.13 ###################### -upd _size75, correct line break when property content ends with '0' at pos 76 - -2.11.14 ###################### -upd function transformDateTime, now accepting input date in array format - -2.11.15 ###################### -bug in function _setRexrule, UNTIL in DATE format - -2.11.16 ###################### -property ATTACH and large file attachments - -2.11.17 ###################### -bug in ATTENDEE, parsing error - -2.11.19 ###################### -upd using.html - -2.11.20 ###################### -upd createComponent, sorting standard/daylight subComponents - -2.11.21 ###################### -bug in selectComponents: long 'event' starting before period - -2.11.23 ###################### -bug: create FREEBUSY, empty property - -2.11.24 ###################### -bug: set/create RELATED-TO mgnt diff --git a/dav/iCalcreator/releaseSummary.txt b/dav/iCalcreator/releaseSummary.txt deleted file mode 100755 index c78b1939..00000000 --- a/dav/iCalcreator/releaseSummary.txt +++ /dev/null @@ -1,31 +0,0 @@ -A major subrelease: -- Concatenate iCalcreator, utilityFunction and helper functions in iCalcreator.class.php file -- new functionality: --- external time zone helper contributions:getTimezonesAsDateArrays - (expandTimezoneDates) and getTzOffsetForDate functions --- create and parse of rfc6321 XML --- ms2phpTZ, mapping of MS outlook time zones to PHP --- createComponent, sorting standard/daylight subComponents -- uppdates: --- parsing dates with extended (MS outlook) time zones --- returnCalendar, only create header 'content-length' when gziping output --- _setDate _setDate2, setExdate, setRdate, utc offset management, Z-suffix --- createTimezone (_setTZrrule), fixing from/to UTC offset and rdate(-s) --- checking x-props names, start with 'x-'/'X-' --- parse, management of list content in TEXT properties --- all rfc5545 parameters with 'DQUOTE' settings --- transformDateTime, accepting input date in array format --- property ATTACH and large file attachments -- fixed bugs: --- selectComponents, (continue if) missing dtstart --- selectComponents: long 'event' starting before period --- getProperty, management of properties with multiple ocurrences --- _tz2offset, plus/minus error --- getConfig, 'directory' or 'filename' couldn't accept '0' (zero) --- _size75, correct line break when property content ends with '0' at pos 76-- --- _setRexrule, UNTIL in DATE format --- ATTENDEE, parsing error --- setFREEBUSY, empty property --- set/create RELATED-TO mgnt --- update of PRODID when (re-)setting 'unique_id' -- updated using manual diff --git a/dav/iCalcreator/summary.html b/dav/iCalcreator/summary.html deleted file mode 100755 index 40e5f6c5..00000000 --- a/dav/iCalcreator/summary.html +++ /dev/null @@ -1,387 +0,0 @@ - - - -iCalcreator 2.12 summary - - - - - - - - -

iCalcreator v2.12

-iCalcreator v2.12
-copyright (c) 2007-2012 Kjell-Inge Gustafsson, kigkonsult
-kigkonsult.se iCalcreator
-kigkonsult.se contact
-
-iCalcreator is a PHP class package managing iCal files, supporting (non-)calendar -systems and applications to process and communicate calendar information like -events, agendas, tasks, reports, totos and journaling information. -

-This is a short summary how to use iCalcreator; create, parse, edit, select and output functionality. -

-The iCalcreator package, built of a calendar class with support of a function class and helper functions, are calendar -component property oriented. Development environment is PHP version 5.x but coding is done -to meet 4.x backward compatibility and may work. Some functions requires PHP >= 5.2.0. -

-The iCalcreator main class, utility class and helper functions are included in the "iCalcreator.class.php" file. -

-More iCalcreator supplementary and "howto" information will be found at -kigkonsult.se iCalcreator implement examples and test pages. -A strong recommendation is to have the document user's manual -open in parallell when exploiting the link. - -

iCal

-A short iCal description is found at Wikipedia. If You are not familiar with iCal, read this first!
-Knowledge of calendar protocol rfc5545/rfc5546 is to recommend;
-rfc5545 - - Internet Calendaring and Scheduling Core Object Specification (iCalendar)
-rfc5546 - - iCalendar Transport-Independent Interoperability Protocol (iTIP) Scheduling Events, BusyTime, To-dos and Journal Entries
-rfc5545 and -rfc5546 -obsoletes, respectively, -rfc2445 and -rfc2446. -
- -

xCal

-iCalcreator also supports xCal (iCal xml)
-rfc6321 - - "xCal: The XML Format for iCalendar" -
- -

SUPPORT

-The main support channel is using iCalcreator -Sourceforge forum. -
-
-kigkonsult offer services for software support, design and development of customizations and adaptations of PHP/MySQL solutions -with a special focus on software long term utility and reliability, -supported through our agile acquire/design/transition process model. -
- -

DONATE

-You can show your appreciation for our free software, -and can support future development by making a donation to the kigkonsult GPL/LGPL projects. -
-
-Make a donation of any size by clicking here. -Thanks in advance! -
- -

Contact

-Use the contact page -for queries, improvement/development issues or professional support and development. -Please note that paid support or consulting service has the highest priority. -
- -

Downloads and usage examples

-On kigkonsult.se can you download the -complete manual -and review -coding and test examples. -
- -

INSTALL

-Unpack to any folder
-- add this folder to your include-path
-- or unpack to your application-(include)-folder
-Add "require_once '[folder/]iCalcreator.class.php';" to your php-script. -
-
-If using PHP version 5.1 or higher, the default timezone need to be set/altered, now "Europe/Stockholm", -line 50 in the iCalcreator.class.php file. -
-When creating a new calendar/component instance, review config settings. -
-
-To really boost performance, visit kigkonsult.se contact page for information. -
-
- - -

CREATE

- -

require_once( "iCalcreator.class.php" ); -$config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id -$v = new vcalendar( $config ); // create a new calendar instance -$tz = "Europe/Stockholm"; // define time zone - -$v->setProperty( "method", "PUBLISH" ); // required of some calendar software -$v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software -$v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software -$v->setProperty( "X-WR-TIMEZONE", $tz ); // required of some calendar software -.. . -$xprops = array( "X-LIC-LOCATION" => $tz ); // required of some calendar software -iCalUtilityFunctions::createTimezone( $v, $tz, $xprops ); // create timezone component(-s) opt. 1 -.. . // based on present date -.. . -$vevent = & $v->newComponent( "vevent" ); // create an event calendar component -$vevent->setProperty( "dtstart", array( "year"=>2007, "month"=>4, "day"=>1, "hour"=>19, "min"=>0, "sec"=>0 )); -$vevent->setProperty( "dtend", array( "year"=>2007, "month"=>4, "day"=>1, "hour"=>22, "min"=>30, "sec"=>0 )); -$vevent->setProperty( "LOCATION", "Central Placa" ); // property name - case independent -$vevent->setProperty( "summary", "PHP summit" ); -$vevent->setProperty( "description", "This is a description" ); -$vevent->setProperty( "comment", "This is a comment" ); -$vevent->setProperty( "attendee", "attendee1@icaldomain.net" ); -.. . -$valarm = & $vevent->newComponent( "valarm" ); // create an event alarm -$valarm->setProperty("action", "DISPLAY" ); -$valarm->setProperty("description", $vevent->getProperty( "description" ); -.. . // reuse the event description -.. . -$d = sprintf( '%04d%02d%02d %02d%02d%02d', 2007, 3, 31, 15, 0, 0 ); -iCalUtilityFunctions::transformDateTime( $d, $tz, "UTC", "Ymd\THis\Z"); -$valarm->setProperty( "trigger", $d ); // create alarm trigger (in UTC datetime) -.. . -$vevent = & $v->newComponent( "vevent" ); // create next event calendar component -$vevent->setProperty( "dtstart", "20070401", array("VALUE" => "DATE"));// alt. date format, now for an all-day event -$vevent->setProperty( "organizer" , "boss@icaldomain.com" ); -$vevent->setProperty( "summary", "ALL-DAY event" ); -$vevent->setProperty( "description", "This is a description for an all-day event" ); -$vevent->setProperty( "resources", "COMPUTER PROJECTOR" ); -$vevent->setProperty( "rrule", array( "FREQ" => "WEEKLY", "count" => 4));// weekly, four occasions -$vevent->parse( "LOCATION:1CP Conference Room 4350" ); // supporting parse of strict rfc5545 formatted text -.. . -.. .// all calendar components are described in rfc5545 -.. .// a complete iCalcreator function list (ex. setProperty) in iCalcreator manual -.. . -iCalUtilityFunctions::createTimezone( $v, $tz, $xprops); // create timezone component(-s) opt. 2 -.. . // based on all start dates in events (i.e. dtstart) -.. . -.. . -

-
-
- -

PARSE

-

iCal, rfc5545 / rfc2445

-

require_once( "iCalcreator.class.php" ); -$config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id, required if any component UID is missing -$v = new vcalendar( $config ); // create a new calendar instance - - /* start parse of local iCal file */ -$config = array( "directory" => "calendar", "filename" => "file.ics" ); -$v->setConfig( $config ); // set directory and file name -$v->parse(); - - /* start parse of remote iCal file */ -$v->setConfig( "url", "http://www.aDomain.net/file.ics" ); // iCalcreator also support parse of remote files -$v->parse(); - -$v->setProperty( "method", "PUBLISH" ); // required of some calendar software -$v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software -$v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software -$v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); // required of some calendar software - -.. . -$v->sort(); // ensure start date order -.. . -.. . // continue process (edit, parse,select) the iCalcreator instance -.. . -

- -

xCal, rfc6321 (XML)

-

require_once( "iCalcreator.class.php" ); -$config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id, required if any component UID is missing -.. . -$filename = 'xmlfile.xml'; // use a local xCal file -// $filename = 'http://kigkonsult.se/xcal.php?a=1&b=2&c=3';// or a remote xCal resource -if( FALSE === ( $v = XMLfile2iCal( $filename, $config ))) // convert the XML resource to an iCalcreator instance - exit( "Error when parsing $filename" ); -.. . -.. . // continue process (edit, parse,select) the iCalcreator instance -.. . -

-
- -

EDIT

-

require_once( "iCalcreator.class.php" ); -$config = array( "unique_id" => "kigkonsult.se", "directory" => "calendar", "filename" => "file.ics" ); - // set the (site) unique id, the import directory and file name -$v = new vcalendar( $config ); // create a new calendar instance - -$v->parse(); - -$v->setProperty( "method", "PUBLISH" ); // required of some calendar software -$v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software -$v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software -$v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); // required of some calendar software - -while( $vevent = $v->getComponent( "vevent" )) { // read events, one by one - $uid = $vevent->getProperty( "uid" ); // uid required, one occurrence (unique id/key for component) - .. . - $dtstart = $vevent->getProperty( "dtstart" ); // dtstart required, one occurrence - .. . - if( $description = $vevent->getProperty( "description", 1 )) { // description optional, first occurrence - .. . // edit the description - $vevent->setProperty( "description", $description, FALSE, 1 ); // update/replace the description - } - while( $comment = $vevent->getProperty( "comment" )) { // comment optional, may occur more than once - .. . // manage comments - } - .. . - while( $vevent->deleteProperty( "attendee" )) - continue; // remove all ATTENDEE properties .. . - .. . - $v->setComponent ( $vevent, $uid ); // update/replace event in calendar with UID as key -} -.. . -.. .// a complete iCalcreator function list (ex. getProperty, deleteProperty) in iCalcreator manual -.. . -

-
-
- -

SELECT

-

require_once( "iCalcreator.class.php" ); -$config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id -$v = new vcalendar( $config ); // create a new calendar instance - -$v->setConfig( "url", "http://www.aDomain.net/file.ics" ); // iCalcreator also support remote files -$v->parse(); -$v->sort(); // ensure start date order - -$v->setProperty( "method", "PUBLISH" ); // required of some calendar software -$v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software -$v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software -$v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); // required of some calendar software -

-

Select components based on specific date period

-

$eventArray = $v->selectComponents(); // select components occurring today - // (including components with recurrence pattern) -foreach( $eventArray as $year => $yearArray) { - foreach( $yearArray as $month => $monthArray ) { - foreach( $monthArray as $day => $dailyEventsArray ) { - foreach( $dailyEventsArray as $vevent ) { - $currddate = $event->getProperty( "x-current-dtstart" ); - // if member of a recurrence set (2nd occurrence etc) - // returns array( "x-current-dtstart" - // , <(string) date("Y-m-d [H:i:s][timezone/UTC offset]")>) - $dtstart = $vevent->getProperty( "dtstart" ); // dtstart required, one occurrence, (orig. start date) - $summary = $vevent->getProperty( "summary" ); - $description = $vevent->getProperty( "description" ); - .. . - .. . - } - } - } -} -

-

Select specific property values

-

$valueOccur = $v->getProperty( "RESOURCES" ); // fetch specific property (unique) values and occurrences - // ATTENDEE, CATEGORIES, DTSTART, LOCATION, - // ORGANIZER, PRIORITY, RESOURCES, STATUS, - // SUMMARY, UID -foreach( $valueOccur as $uniqueValue => $occurCnt ) { - echo "The RESOURCES value <b>$uniqueValue</b> occurs <b>$occurCnt</b> times<br />"; - .. . -} -

-

Select components based on specific property value

-

$selectSpec = array( "CATEGORIES" => "course1" ); -$specComps = $v->selectComponents( $selectSpec ); // selects components based on specific property value(-s) - // ATTENDEE, CATEGORIES, LOCATION, ORGANIZER, - // PRIORITY, RESOURCES, STATUS, SUMMARY, UID -foreach( $specComps as $comp ) { - .. . -} -

-
-
- -

OUTPUT

-

require_once( "iCalcreator.class.php" ); -$config = array( "unique_id" => "kigkonsult.se" ); // set a (site) unique id -$v = new vcalendar( $config ); // create a new calendar instance - -$v->setProperty( "method", "PUBLISH" ); // required of some calendar software -$v->setProperty( "x-wr-calname", "Calendar Sample" ); // required of some calendar software -$v->setProperty( "X-WR-CALDESC", "Calendar Description" ); // required of some calendar software -$v->setProperty( "X-WR-TIMEZONE", "Europe/Stockholm" ); // required of some calendar software -.. . -.. . // continue process (edit, parse,select) the iCalcreator instance -.. . -

-

opt 1

-

.. . -$v->returnCalendar(); // redirect calendar file to browser -

- -

opt 2

-

.. . -$config = array( "directory" => "depot", "filename" => "calendar.ics" ); -$v->setConfig( $config ); // set output directory and file name -$v->saveCalendar(); // save calendar to (local) file -.. . -

- -

opt 3, xCal

-

.. . -$xmlstr = iCal2XML( $v ); // create well-formed XML, rfc6321 -... -

-
-
- - -

COPYRIGHT AND LICENSE

- -

Copyright

-iCalcreator v2.12
-copyright (c) 2007-2012 Kjell-Inge Gustafsson, kigkonsult
-kigkonsult.se iCalcreator
-kigkonsult.se contact
-
- -

License

- -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. -

-This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. -

-You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -or download it here. - - \ No newline at end of file diff --git a/dav/jqueryui/jquery-ui-1.8.20.custom.css b/dav/jqueryui/jquery-ui-1.8.20.custom.css deleted file mode 100644 index 089d68e1..00000000 --- a/dav/jqueryui/jquery-ui-1.8.20.custom.css +++ /dev/null @@ -1,354 +0,0 @@ -/*! - * jQuery UI CSS Framework 1.8.20 - * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; } -.ui-helper-clearfix:after { clear: both; } -.ui-helper-clearfix { zoom: 1; } -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/*! - * jQuery UI CSS Framework 1.8.20 - * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS,%20Tahoma,%20Verdana,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=03_highlight_soft.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=08_diagonals_thick.png&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=01_flat.png&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1.1em; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; color: #333333; } -.ui-widget-content a { color: #333333; } -.ui-widget-header { border: 1px solid #e78f08; background: #f6a828 url(images/ui-bg_gloss-wave_35_f6a828_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1c94c4; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #fbcb09; background: #fdf5ce url(images/ui-bg_glass_100_fdf5ce_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #c77405; } -.ui-state-hover a, .ui-state-hover a:hover { color: #c77405; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #fbd850; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eb8f00; } -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #eb8f00; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fed22f; background: #ffe45c url(images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; color: #363636; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat; color: #ffffff; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #ffffff; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #ffffff; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); } -.ui-state-default .ui-icon { background-image: url(images/ui-icons_ef8c08_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); } -.ui-state-active .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_228ef1_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_ffd27a_256x240.png); } - -/* positioning */ -.ui-icon-carat-1-n { background-position: 0 0; } -.ui-icon-carat-1-ne { background-position: -16px 0; } -.ui-icon-carat-1-e { background-position: -32px 0; } -.ui-icon-carat-1-se { background-position: -48px 0; } -.ui-icon-carat-1-s { background-position: -64px 0; } -.ui-icon-carat-1-sw { background-position: -80px 0; } -.ui-icon-carat-1-w { background-position: -96px 0; } -.ui-icon-carat-1-nw { background-position: -112px 0; } -.ui-icon-carat-2-n-s { background-position: -128px 0; } -.ui-icon-carat-2-e-w { background-position: -144px 0; } -.ui-icon-triangle-1-n { background-position: 0 -16px; } -.ui-icon-triangle-1-ne { background-position: -16px -16px; } -.ui-icon-triangle-1-e { background-position: -32px -16px; } -.ui-icon-triangle-1-se { background-position: -48px -16px; } -.ui-icon-triangle-1-s { background-position: -64px -16px; } -.ui-icon-triangle-1-sw { background-position: -80px -16px; } -.ui-icon-triangle-1-w { background-position: -96px -16px; } -.ui-icon-triangle-1-nw { background-position: -112px -16px; } -.ui-icon-triangle-2-n-s { background-position: -128px -16px; } -.ui-icon-triangle-2-e-w { background-position: -144px -16px; } -.ui-icon-arrow-1-n { background-position: 0 -32px; } -.ui-icon-arrow-1-ne { background-position: -16px -32px; } -.ui-icon-arrow-1-e { background-position: -32px -32px; } -.ui-icon-arrow-1-se { background-position: -48px -32px; } -.ui-icon-arrow-1-s { background-position: -64px -32px; } -.ui-icon-arrow-1-sw { background-position: -80px -32px; } -.ui-icon-arrow-1-w { background-position: -96px -32px; } -.ui-icon-arrow-1-nw { background-position: -112px -32px; } -.ui-icon-arrow-2-n-s { background-position: -128px -32px; } -.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } -.ui-icon-arrow-2-e-w { background-position: -160px -32px; } -.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } -.ui-icon-arrowstop-1-n { background-position: -192px -32px; } -.ui-icon-arrowstop-1-e { background-position: -208px -32px; } -.ui-icon-arrowstop-1-s { background-position: -224px -32px; } -.ui-icon-arrowstop-1-w { background-position: -240px -32px; } -.ui-icon-arrowthick-1-n { background-position: 0 -48px; } -.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } -.ui-icon-arrowthick-1-e { background-position: -32px -48px; } -.ui-icon-arrowthick-1-se { background-position: -48px -48px; } -.ui-icon-arrowthick-1-s { background-position: -64px -48px; } -.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } -.ui-icon-arrowthick-1-w { background-position: -96px -48px; } -.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } -.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } -.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } -.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } -.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } -.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } -.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } -.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } -.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } -.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } -.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } -.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } -.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } -.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } -.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } -.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } -.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } -.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } -.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } -.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } -.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } -.ui-icon-arrow-4 { background-position: 0 -80px; } -.ui-icon-arrow-4-diag { background-position: -16px -80px; } -.ui-icon-extlink { background-position: -32px -80px; } -.ui-icon-newwin { background-position: -48px -80px; } -.ui-icon-refresh { background-position: -64px -80px; } -.ui-icon-shuffle { background-position: -80px -80px; } -.ui-icon-transfer-e-w { background-position: -96px -80px; } -.ui-icon-transferthick-e-w { background-position: -112px -80px; } -.ui-icon-folder-collapsed { background-position: 0 -96px; } -.ui-icon-folder-open { background-position: -16px -96px; } -.ui-icon-document { background-position: -32px -96px; } -.ui-icon-document-b { background-position: -48px -96px; } -.ui-icon-note { background-position: -64px -96px; } -.ui-icon-mail-closed { background-position: -80px -96px; } -.ui-icon-mail-open { background-position: -96px -96px; } -.ui-icon-suitcase { background-position: -112px -96px; } -.ui-icon-comment { background-position: -128px -96px; } -.ui-icon-person { background-position: -144px -96px; } -.ui-icon-print { background-position: -160px -96px; } -.ui-icon-trash { background-position: -176px -96px; } -.ui-icon-locked { background-position: -192px -96px; } -.ui-icon-unlocked { background-position: -208px -96px; } -.ui-icon-bookmark { background-position: -224px -96px; } -.ui-icon-tag { background-position: -240px -96px; } -.ui-icon-home { background-position: 0 -112px; } -.ui-icon-flag { background-position: -16px -112px; } -.ui-icon-calendar { background-position: -32px -112px; } -.ui-icon-cart { background-position: -48px -112px; } -.ui-icon-pencil { background-position: -64px -112px; } -.ui-icon-clock { background-position: -80px -112px; } -.ui-icon-disk { background-position: -96px -112px; } -.ui-icon-calculator { background-position: -112px -112px; } -.ui-icon-zoomin { background-position: -128px -112px; } -.ui-icon-zoomout { background-position: -144px -112px; } -.ui-icon-search { background-position: -160px -112px; } -.ui-icon-wrench { background-position: -176px -112px; } -.ui-icon-gear { background-position: -192px -112px; } -.ui-icon-heart { background-position: -208px -112px; } -.ui-icon-star { background-position: -224px -112px; } -.ui-icon-link { background-position: -240px -112px; } -.ui-icon-cancel { background-position: 0 -128px; } -.ui-icon-plus { background-position: -16px -128px; } -.ui-icon-plusthick { background-position: -32px -128px; } -.ui-icon-minus { background-position: -48px -128px; } -.ui-icon-minusthick { background-position: -64px -128px; } -.ui-icon-close { background-position: -80px -128px; } -.ui-icon-closethick { background-position: -96px -128px; } -.ui-icon-key { background-position: -112px -128px; } -.ui-icon-lightbulb { background-position: -128px -128px; } -.ui-icon-scissors { background-position: -144px -128px; } -.ui-icon-clipboard { background-position: -160px -128px; } -.ui-icon-copy { background-position: -176px -128px; } -.ui-icon-contact { background-position: -192px -128px; } -.ui-icon-image { background-position: -208px -128px; } -.ui-icon-video { background-position: -224px -128px; } -.ui-icon-script { background-position: -240px -128px; } -.ui-icon-alert { background-position: 0 -144px; } -.ui-icon-info { background-position: -16px -144px; } -.ui-icon-notice { background-position: -32px -144px; } -.ui-icon-help { background-position: -48px -144px; } -.ui-icon-check { background-position: -64px -144px; } -.ui-icon-bullet { background-position: -80px -144px; } -.ui-icon-radio-off { background-position: -96px -144px; } -.ui-icon-radio-on { background-position: -112px -144px; } -.ui-icon-pin-w { background-position: -128px -144px; } -.ui-icon-pin-s { background-position: -144px -144px; } -.ui-icon-play { background-position: 0 -160px; } -.ui-icon-pause { background-position: -16px -160px; } -.ui-icon-seek-next { background-position: -32px -160px; } -.ui-icon-seek-prev { background-position: -48px -160px; } -.ui-icon-seek-end { background-position: -64px -160px; } -.ui-icon-seek-start { background-position: -80px -160px; } -/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ -.ui-icon-seek-first { background-position: -80px -160px; } -.ui-icon-stop { background-position: -96px -160px; } -.ui-icon-eject { background-position: -112px -160px; } -.ui-icon-volume-off { background-position: -128px -160px; } -.ui-icon-volume-on { background-position: -144px -160px; } -.ui-icon-power { background-position: 0 -176px; } -.ui-icon-signal-diag { background-position: -16px -176px; } -.ui-icon-signal { background-position: -32px -176px; } -.ui-icon-battery-0 { background-position: -48px -176px; } -.ui-icon-battery-1 { background-position: -64px -176px; } -.ui-icon-battery-2 { background-position: -80px -176px; } -.ui-icon-battery-3 { background-position: -96px -176px; } -.ui-icon-circle-plus { background-position: 0 -192px; } -.ui-icon-circle-minus { background-position: -16px -192px; } -.ui-icon-circle-close { background-position: -32px -192px; } -.ui-icon-circle-triangle-e { background-position: -48px -192px; } -.ui-icon-circle-triangle-s { background-position: -64px -192px; } -.ui-icon-circle-triangle-w { background-position: -80px -192px; } -.ui-icon-circle-triangle-n { background-position: -96px -192px; } -.ui-icon-circle-arrow-e { background-position: -112px -192px; } -.ui-icon-circle-arrow-s { background-position: -128px -192px; } -.ui-icon-circle-arrow-w { background-position: -144px -192px; } -.ui-icon-circle-arrow-n { background-position: -160px -192px; } -.ui-icon-circle-zoomin { background-position: -176px -192px; } -.ui-icon-circle-zoomout { background-position: -192px -192px; } -.ui-icon-circle-check { background-position: -208px -192px; } -.ui-icon-circlesmall-plus { background-position: 0 -208px; } -.ui-icon-circlesmall-minus { background-position: -16px -208px; } -.ui-icon-circlesmall-close { background-position: -32px -208px; } -.ui-icon-squaresmall-plus { background-position: -48px -208px; } -.ui-icon-squaresmall-minus { background-position: -64px -208px; } -.ui-icon-squaresmall-close { background-position: -80px -208px; } -.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } -.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } -.ui-icon-grip-solid-vertical { background-position: -32px -224px; } -.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } -.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } -.ui-icon-grip-diagonal-se { background-position: -80px -224px; } - - -/* Misc visuals -----------------------------------*/ - -/* Corner radius */ -.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; } -.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; } -.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; } -.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; } - -/* Overlays */ -.ui-widget-overlay { background: #666666 url(images/ui-bg_diagonals-thick_20_666666_40x40.png) 50% 50% repeat; opacity: .50;filter:Alpha(Opacity=50); } -.ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .20;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }/*! - * jQuery UI Datepicker 1.8.20 - * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Datepicker#theming - */ -.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; } -.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } -.ui-datepicker .ui-datepicker-prev { left:2px; } -.ui-datepicker .ui-datepicker-next { right:2px; } -.ui-datepicker .ui-datepicker-prev-hover { left:1px; } -.ui-datepicker .ui-datepicker-next-hover { right:1px; } -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } -.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } -.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } -.ui-datepicker select.ui-datepicker-month-year {width: 100%;} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { width: 49%;} -.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } -.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } -.ui-datepicker td { border: 0; padding: 1px; } -.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } -.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } -.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } - -/* with multiple calendars */ -.ui-datepicker.ui-datepicker-multi { width:auto; } -.ui-datepicker-multi .ui-datepicker-group { float:left; } -.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } -.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } -.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } -.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } -.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } -.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } -.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; } - -/* RTL support */ -.ui-datepicker-rtl { direction: rtl; } -.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } -.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } -.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } -.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } -.ui-datepicker-rtl .ui-datepicker-group { float:right; } -.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } -.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } - -/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ -.ui-datepicker-cover { - display: none; /*sorry for IE5*/ - display/**/: block; /*sorry for IE5*/ - position: absolute; /*must have*/ - z-index: -1; /*must have*/ - filter: mask(); /*must have*/ - top: -4px; /*must have*/ - left: -4px; /*must have*/ - width: 200px; /*must have*/ - height: 200px; /*must have*/ -} \ No newline at end of file diff --git a/dav/jqueryui/jquery-ui-1.8.20.custom.min.js b/dav/jqueryui/jquery-ui-1.8.20.custom.min.js deleted file mode 100644 index bb6ed07d..00000000 --- a/dav/jqueryui/jquery-ui-1.8.20.custom.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! jQuery UI - v1.8.20 - 2012-04-30 -* https://github.com/jquery/jquery-ui -* Includes: jquery.ui.core.js -* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */ -(function(a,b){function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;return!b.href||!g||f.nodeName.toLowerCase()!=="map"?!1:(h=a("img[usemap=#"+g+"]")[0],!!h&&d(h))}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};if(a.ui.version)return;a.extend(a.ui,{version:"1.8.20",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;return a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(c,d){function h(b,c,d,f){return a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)}),c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return c===b?g["inner"+d].call(this):this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return typeof b!="number"?g["outer"+d].call(this,b):this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!d||!a.element[0].parentNode)return;for(var e=0;e0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)},isOverAxis:function(a,b,c){return a>b&&a'))}function bindHover(a){var b="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return a.bind("mouseout",function(a){var c=$(a.target).closest(b);if(!c.length)return;c.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(c){var d=$(c.target).closest(b);if($.datepicker._isDisabledDatepicker(instActive.inline?a.parent()[0]:instActive.input[0])||!d.length)return;d.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),d.addClass("ui-state-hover"),d.hasClass("ui-datepicker-prev")&&d.addClass("ui-datepicker-prev-hover"),d.hasClass("ui-datepicker-next")&&d.addClass("ui-datepicker-next-hover")})}function extendRemove(a,b){$.extend(a,b);for(var c in b)if(b[c]==null||b[c]==undefined)a[c]=b[c];return a}function isArray(a){return a&&($.browser.safari&&typeof a=="object"&&a.length||a.constructor&&a.constructor.toString().match(/\Array\(\)/))}$.extend($.ui,{datepicker:{version:"1.8.20"}});var PROP_NAME="datepicker",dpuuid=(new Date).getTime(),instActive;$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){return extendRemove(this._defaults,a||{}),this},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase(),inline=nodeName=="div"||nodeName=="span";target.id||(this.uuid+=1,target.id="dp"+this.uuid);var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{}),nodeName=="input"?this._connectDatepicker(target,inst):inline&&this._inlineDatepicker(target,inst)},_newInst:function(a,b){var c=a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1");return{id:c,input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:b?bindHover($('
')):this.dpDiv}},_connectDatepicker:function(a,b){var c=$(a);b.append=$([]),b.trigger=$([]);if(c.hasClass(this.markerClassName))return;this._attachments(c,b),c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(a,c,d){b.settings[c]=d}).bind("getData.datepicker",function(a,c){return this._get(b,c)}),this._autoSize(b),$.data(a,PROP_NAME,b),b.settings.disabled&&this._disableDatepicker(a)},_attachments:function(a,b){var c=this._get(b,"appendText"),d=this._get(b,"isRTL");b.append&&b.append.remove(),c&&(b.append=$(''+c+""),a[d?"before":"after"](b.append)),a.unbind("focus",this._showDatepicker),b.trigger&&b.trigger.remove();var e=this._get(b,"showOn");(e=="focus"||e=="both")&&a.focus(this._showDatepicker);if(e=="button"||e=="both"){var f=this._get(b,"buttonText"),g=this._get(b,"buttonImage");b.trigger=$(this._get(b,"buttonImageOnly")?$("").addClass(this._triggerClass).attr({src:g,alt:f,title:f}):$('').addClass(this._triggerClass).html(g==""?f:$("").attr({src:g,alt:f,title:f}))),a[d?"before":"after"](b.trigger),b.trigger.click(function(){return $.datepicker._datepickerShowing&&$.datepicker._lastInput==a[0]?$.datepicker._hideDatepicker():$.datepicker._datepickerShowing&&$.datepicker._lastInput!=a[0]?($.datepicker._hideDatepicker(),$.datepicker._showDatepicker(a[0])):$.datepicker._showDatepicker(a[0]),!1})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var d=function(a){var b=0,c=0;for(var d=0;db&&(b=a[d].length,c=d);return c};b.setMonth(d(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort"))),b.setDate(d(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,b){var c=$(a);if(c.hasClass(this.markerClassName))return;c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(a,c,d){b.settings[c]=d}).bind("getData.datepicker",function(a,c){return this._get(b,c)}),$.data(a,PROP_NAME,b),this._setDate(b,this._getDefaultDate(b),!0),this._updateDatepicker(b),this._updateAlternate(b),b.settings.disabled&&this._disableDatepicker(a),b.dpDiv.css("display","block")},_dialogDatepicker:function(a,b,c,d,e){var f=this._dialogInst;if(!f){this.uuid+=1;var g="dp"+this.uuid;this._dialogInput=$(''),this._dialogInput.keydown(this._doKeyDown),$("body").append(this._dialogInput),f=this._dialogInst=this._newInst(this._dialogInput,!1),f.settings={},$.data(this._dialogInput[0],PROP_NAME,f)}extendRemove(f.settings,d||{}),b=b&&b.constructor==Date?this._formatDate(f,b):b,this._dialogInput.val(b),this._pos=e?e.length?e:[e.pageX,e.pageY]:null;if(!this._pos){var h=document.documentElement.clientWidth,i=document.documentElement.clientHeight,j=document.documentElement.scrollLeft||document.body.scrollLeft,k=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[h/2-100+j,i/2-150+k]}return this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),f.settings.onSelect=c,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),$.blockUI&&$.blockUI(this.dpDiv),$.data(this._dialogInput[0],PROP_NAME,f),this},_destroyDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();$.removeData(a,PROP_NAME),d=="input"?(c.append.remove(),c.trigger.remove(),b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):(d=="div"||d=="span")&&b.removeClass(this.markerClassName).empty()},_enableDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();if(d=="input")a.disabled=!1,c.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""});else if(d=="div"||d=="span"){var e=b.children("."+this._inlineClass);e.children().removeClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}this._disabledInputs=$.map(this._disabledInputs,function(b){return b==a?null:b})},_disableDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();if(d=="input")a.disabled=!0,c.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if(d=="div"||d=="span"){var e=b.children("."+this._inlineClass);e.children().addClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}this._disabledInputs=$.map(this._disabledInputs,function(b){return b==a?null:b}),this._disabledInputs[this._disabledInputs.length]=a},_isDisabledDatepicker:function(a){if(!a)return!1;for(var b=0;b-1}},_doKeyUp:function(a){var b=$.datepicker._getInst(a.target);if(b.input.val()!=b.lastVal)try{var c=$.datepicker.parseDate($.datepicker._get(b,"dateFormat"),b.input?b.input.val():null,$.datepicker._getFormatConfig(b));c&&($.datepicker._setDateFromField(b),$.datepicker._updateAlternate(b),$.datepicker._updateDatepicker(b))}catch(d){$.datepicker.log(d)}return!0},_showDatepicker:function(a){a=a.target||a,a.nodeName.toLowerCase()!="input"&&(a=$("input",a.parentNode)[0]);if($.datepicker._isDisabledDatepicker(a)||$.datepicker._lastInput==a)return;var b=$.datepicker._getInst(a);$.datepicker._curInst&&$.datepicker._curInst!=b&&($.datepicker._curInst.dpDiv.stop(!0,!0),b&&$.datepicker._datepickerShowing&&$.datepicker._hideDatepicker($.datepicker._curInst.input[0]));var c=$.datepicker._get(b,"beforeShow"),d=c?c.apply(a,[a,b]):{};if(d===!1)return;extendRemove(b.settings,d),b.lastVal=null,$.datepicker._lastInput=a,$.datepicker._setDateFromField(b),$.datepicker._inDialog&&(a.value=""),$.datepicker._pos||($.datepicker._pos=$.datepicker._findPos(a),$.datepicker._pos[1]+=a.offsetHeight);var e=!1;$(a).parents().each(function(){return e|=$(this).css("position")=="fixed",!e}),e&&$.browser.opera&&($.datepicker._pos[0]-=document.documentElement.scrollLeft,$.datepicker._pos[1]-=document.documentElement.scrollTop);var f={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null,b.dpDiv.empty(),b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),$.datepicker._updateDatepicker(b),f=$.datepicker._checkOffset(b,f,e),b.dpDiv.css({position:$.datepicker._inDialog&&$.blockUI?"static":e?"fixed":"absolute",display:"none",left:f.left+"px",top:f.top+"px"});if(!b.inline){var g=$.datepicker._get(b,"showAnim"),h=$.datepicker._get(b,"duration"),i=function(){var a=b.dpDiv.find("iframe.ui-datepicker-cover");if(!!a.length){var c=$.datepicker._getBorders(b.dpDiv);a.css({left:-c[0],top:-c[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex($(a).zIndex()+1),$.datepicker._datepickerShowing=!0,$.effects&&$.effects[g]?b.dpDiv.show(g,$.datepicker._get(b,"showOptions"),h,i):b.dpDiv[g||"show"](g?h:null,i),(!g||!h)&&i(),b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus(),$.datepicker._curInst=b}},_updateDatepicker:function(a){var b=this;b.maxRows=4;var c=$.datepicker._getBorders(a.dpDiv);instActive=a,a.dpDiv.empty().append(this._generateHTML(a));var d=a.dpDiv.find("iframe.ui-datepicker-cover");!d.length||d.css({left:-c[0],top:-c[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()}),a.dpDiv.find("."+this._dayOverClass+" a").mouseover();var e=this._getNumberOfMonths(a),f=e[1],g=17;a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),f>1&&a.dpDiv.addClass("ui-datepicker-multi-"+f).css("width",g*f+"em"),a.dpDiv[(e[0]!=1||e[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi"),a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),a==$.datepicker._curInst&&$.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var h=a.yearshtml;setTimeout(function(){h===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml),h=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(a){return{thin:1,medium:2,thick:3}[a]||a};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var d=a.dpDiv.outerWidth(),e=a.dpDiv.outerHeight(),f=a.input?a.input.outerWidth():0,g=a.input?a.input.outerHeight():0,h=document.documentElement.clientWidth+$(document).scrollLeft(),i=document.documentElement.clientHeight+$(document).scrollTop();return b.left-=this._get(a,"isRTL")?d-f:0,b.left-=c&&b.left==a.input.offset().left?$(document).scrollLeft():0,b.top-=c&&b.top==a.input.offset().top+g?$(document).scrollTop():0,b.left-=Math.min(b.left,b.left+d>h&&h>d?Math.abs(b.left+d-h):0),b.top-=Math.min(b.top,b.top+e>i&&i>e?Math.abs(e+g):0),b},_findPos:function(a){var b=this._getInst(a),c=this._get(b,"isRTL");while(a&&(a.type=="hidden"||a.nodeType!=1||$.expr.filters.hidden(a)))a=a[c?"previousSibling":"nextSibling"];var d=$(a).offset();return[d.left,d.top]},_hideDatepicker:function(a){var b=this._curInst;if(!b||a&&b!=$.data(a,PROP_NAME))return;if(this._datepickerShowing){var c=this._get(b,"showAnim"),d=this._get(b,"duration"),e=function(){$.datepicker._tidyDialog(b)};$.effects&&$.effects[c]?b.dpDiv.hide(c,$.datepicker._get(b,"showOptions"),d,e):b.dpDiv[c=="slideDown"?"slideUp":c=="fadeIn"?"fadeOut":"hide"](c?d:null,e),c||e(),this._datepickerShowing=!1;var f=this._get(b,"onClose");f&&f.apply(b.input?b.input[0]:null,[b.input?b.input.val():"",b]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),$.blockUI&&($.unblockUI(),$("body").append(this.dpDiv))),this._inDialog=!1}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(!$.datepicker._curInst)return;var b=$(a.target),c=$.datepicker._getInst(b[0]);(b[0].id!=$.datepicker._mainDivId&&b.parents("#"+$.datepicker._mainDivId).length==0&&!b.hasClass($.datepicker.markerClassName)&&!b.closest("."+$.datepicker._triggerClass).length&&$.datepicker._datepickerShowing&&(!$.datepicker._inDialog||!$.blockUI)||b.hasClass($.datepicker.markerClassName)&&$.datepicker._curInst!=c)&&$.datepicker._hideDatepicker()},_adjustDate:function(a,b,c){var d=$(a),e=this._getInst(d[0]);if(this._isDisabledDatepicker(d[0]))return;this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):0),c),this._updateDatepicker(e)},_gotoToday:function(a){var b=$(a),c=this._getInst(b[0]);if(this._get(c,"gotoCurrent")&&c.currentDay)c.selectedDay=c.currentDay,c.drawMonth=c.selectedMonth=c.currentMonth,c.drawYear=c.selectedYear=c.currentYear;else{var d=new Date;c.selectedDay=d.getDate(),c.drawMonth=c.selectedMonth=d.getMonth(),c.drawYear=c.selectedYear=d.getFullYear()}this._notifyChange(c),this._adjustDate(b)},_selectMonthYear:function(a,b,c){var d=$(a),e=this._getInst(d[0]);e["selected"+(c=="M"?"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10),this._notifyChange(e),this._adjustDate(d)},_selectDay:function(a,b,c,d){var e=$(a);if($(d).hasClass(this._unselectableClass)||this._isDisabledDatepicker(e[0]))return;var f=this._getInst(e[0]);f.selectedDay=f.currentDay=$("a",d).html(),f.selectedMonth=f.currentMonth=b,f.selectedYear=f.currentYear=c,this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))},_clearDate:function(a){var b=$(a),c=this._getInst(b[0]);this._selectDate(b,"")},_selectDate:function(a,b){var c=$(a),d=this._getInst(c[0]);b=b!=null?b:this._formatDate(d),d.input&&d.input.val(b),this._updateAlternate(d);var e=this._get(d,"onSelect");e?e.apply(d.input?d.input[0]:null,[b,d]):d.input&&d.input.trigger("change"),d.inline?this._updateDatepicker(d):(this._hideDatepicker(),this._lastInput=d.input[0],typeof d.input[0]!="object"&&d.input.focus(),this._lastInput=null)},_updateAlternate:function(a){var b=this._get(a,"altField");if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),d=this._getDate(a),e=this.formatDate(c,d,this._getFormatConfig(a));$(b).each(function(){$(this).val(e)})}},noWeekends:function(a){var b=a.getDay();return[b>0&&b<6,""]},iso8601Week:function(a){var b=new Date(a.getTime());b.setDate(b.getDate()+4-(b.getDay()||7));var c=b.getTime();return b.setMonth(0),b.setDate(1),Math.floor(Math.round((c-b)/864e5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"?b.toString():b+"";if(b=="")return null;var d=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;d=typeof d!="string"?d:(new Date).getFullYear()%100+parseInt(d,10);var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,g=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,h=(c?c.monthNames:null)||this._defaults.monthNames,i=-1,j=-1,k=-1,l=-1,m=!1,n=function(b){var c=s+1-1){j=1,k=l;do{var u=this._getDaysInMonth(i,j-1);if(k<=u)break;j++,k-=u}while(!0)}var t=this._daylightSavingAdjust(new Date(i,j-1,k));if(t.getFullYear()!=i||t.getMonth()+1!=j||t.getDate()!=k)throw"Invalid date";return t},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1e7,formatDate:function(a,b,c){if(!b)return"";var d=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,e=(c?c.dayNames:null)||this._defaults.dayNames,f=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,h=function(b){var c=m+112?a.getHours()+2:0),a):null},_setDate:function(a,b,c){var d=!b,e=a.selectedMonth,f=a.selectedYear,g=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=g.getDate(),a.drawMonth=a.selectedMonth=a.currentMonth=g.getMonth(),a.drawYear=a.selectedYear=a.currentYear=g.getFullYear(),(e!=a.selectedMonth||f!=a.selectedYear)&&!c&&this._notifyChange(a),this._adjustInstDate(a),a.input&&a.input.val(d?"":this._formatDate(a))},_getDate:function(a){var b=!a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return b},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),d=this._get(a,"showButtonPanel"),e=this._get(a,"hideIfNoPrevNext"),f=this._get(a,"navigationAsDateFormat"),g=this._getNumberOfMonths(a),h=this._get(a,"showCurrentAtPos"),i=this._get(a,"stepMonths"),j=g[0]!=1||g[1]!=1,k=this._daylightSavingAdjust(a.currentDay?new Date(a.currentYear,a.currentMonth,a.currentDay):new Date(9999,9,9)),l=this._getMinMaxDate(a,"min"),m=this._getMinMaxDate(a,"max"),n=a.drawMonth-h,o=a.drawYear;n<0&&(n+=12,o--);if(m){var p=this._daylightSavingAdjust(new Date(m.getFullYear(),m.getMonth()-g[0]*g[1]+1,m.getDate()));p=l&&pp)n--,n<0&&(n=11,o--)}a.drawMonth=n,a.drawYear=o;var q=this._get(a,"prevText");q=f?this.formatDate(q,this._daylightSavingAdjust(new Date(o,n-i,1)),this._getFormatConfig(a)):q;var r=this._canAdjustMonth(a,-1,o,n)?''+q+"":e?"":''+q+"",s=this._get(a,"nextText");s=f?this.formatDate(s,this._daylightSavingAdjust(new Date(o,n+i,1)),this._getFormatConfig(a)):s;var t=this._canAdjustMonth(a,1,o,n)?''+s+"":e?"":''+s+"",u=this._get(a,"currentText"),v=this._get(a,"gotoCurrent")&&a.currentDay?k:b;u=f?this.formatDate(u,v,this._getFormatConfig(a)):u;var w=a.inline?"":'",x=d?'
'+(c?w:"")+(this._isInRange(a,v)?'":"")+(c?"":w)+"
":"",y=parseInt(this._get(a,"firstDay"),10);y=isNaN(y)?0:y;var z=this._get(a,"showWeek"),A=this._get(a,"dayNames"),B=this._get(a,"dayNamesShort"),C=this._get(a,"dayNamesMin"),D=this._get(a,"monthNames"),E=this._get(a,"monthNamesShort"),F=this._get(a,"beforeShowDay"),G=this._get(a,"showOtherMonths"),H=this._get(a,"selectOtherMonths"),I=this._get(a,"calculateWeek")||this.iso8601Week,J=this._getDefaultDate(a),K="";for(var L=0;L1)switch(N){case 0:Q+=" ui-datepicker-group-first",P=" ui-corner-"+(c?"right":"left");break;case g[1]-1:Q+=" ui-datepicker-group-last",P=" ui-corner-"+(c?"left":"right");break;default:Q+=" ui-datepicker-group-middle",P=""}Q+='">'}Q+='
'+(/all|left/.test(P)&&L==0?c?t:r:"")+(/all|right/.test(P)&&L==0?c?r:t:"")+this._generateMonthYearHeader(a,n,o,l,m,L>0||N>0,D,E)+'
'+"";var R=z?'":"";for(var S=0;S<7;S++){var T=(S+y)%7;R+="=5?' class="ui-datepicker-week-end"':"")+">"+''+C[T]+""}Q+=R+"";var U=this._getDaysInMonth(o,n);o==a.selectedYear&&n==a.selectedMonth&&(a.selectedDay=Math.min(a.selectedDay,U));var V=(this._getFirstDayOfMonth(o,n)-y+7)%7,W=Math.ceil((V+U)/7),X=j?this.maxRows>W?this.maxRows:W:W;this.maxRows=X;var Y=this._daylightSavingAdjust(new Date(o,n,1-V));for(var Z=0;Z";var _=z?'":"";for(var S=0;S<7;S++){var ba=F?F.apply(a.input?a.input[0]:null,[Y]):[!0,""],bb=Y.getMonth()!=n,bc=bb&&!H||!ba[0]||l&&Ym;_+='",Y.setDate(Y.getDate()+1),Y=this._daylightSavingAdjust(Y)}Q+=_+""}n++,n>11&&(n=0,o++),Q+="
'+this._get(a,"weekHeader")+"
'+this._get(a,"calculateWeek")(Y)+""+(bb&&!G?" ":bc?''+Y.getDate()+"":''+Y.getDate()+"")+"
"+(j?""+(g[0]>0&&N==g[1]-1?'
':""):""),M+=Q}K+=M}return K+=x+($.browser.msie&&parseInt($.browser.version,10)<7&&!a.inline?'':""),a._keyEvent=!1,K},_generateMonthYearHeader:function(a,b,c,d,e,f,g,h){var i=this._get(a,"changeMonth"),j=this._get(a,"changeYear"),k=this._get(a,"showMonthAfterYear"),l='
',m="";if(f||!i)m+=''+g[b]+"";else{var n=d&&d.getFullYear()==c,o=e&&e.getFullYear()==c;m+='"}k||(l+=m+(f||!i||!j?" ":""));if(!a.yearshtml){a.yearshtml="";if(f||!j)l+=''+c+"";else{var q=this._get(a,"yearRange").split(":"),r=(new Date).getFullYear(),s=function(a){var b=a.match(/c[+-].*/)?c+parseInt(a.substring(1),10):a.match(/[+-].*/)?r+parseInt(a,10):parseInt(a,10);return isNaN(b)?r:b},t=s(q[0]),u=Math.max(t,s(q[1]||""));t=d?Math.max(t,d.getFullYear()):t,u=e?Math.min(u,e.getFullYear()):u,a.yearshtml+='",l+=a.yearshtml,a.yearshtml=null}}return l+=this._get(a,"yearSuffix"),k&&(l+=(f||!i||!j?" ":"")+m),l+="
",l},_adjustInstDate:function(a,b,c){var d=a.drawYear+(c=="Y"?b:0),e=a.drawMonth+(c=="M"?b:0),f=Math.min(a.selectedDay,this._getDaysInMonth(d,e))+(c=="D"?b:0),g=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(d,e,f)));a.selectedDay=g.getDate(),a.drawMonth=a.selectedMonth=g.getMonth(),a.drawYear=a.selectedYear=g.getFullYear(),(c=="M"||c=="Y")&&this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max"),e=c&&bd?d:e,e},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");b&&b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){var b=this._get(a,"numberOfMonths");return b==null?[1,1]:typeof b=="number"?[1,b]:b},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,d){var e=this._getNumberOfMonths(a),f=this._daylightSavingAdjust(new Date(c,d+(b<0?b:e[0]*e[1]),1));return b<0&&f.setDate(this._getDaysInMonth(f.getFullYear(),f.getMonth())),this._isInRange(a,f)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!d||b.getTime()<=d.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");return b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10),{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,d){b||(a.currentDay=a.selectedDay,a.currentMonth=a.selectedMonth,a.currentYear=a.selectedYear);var e=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(d,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),e,this._getFormatConfig(a))}}),$.fn.datepicker=function(a){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find("body").append($.datepicker.dpDiv),$.datepicker.initialized=!0);var b=Array.prototype.slice.call(arguments,1);return typeof a!="string"||a!="isDisabled"&&a!="getDate"&&a!="widget"?a=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b)):this.each(function(){typeof a=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this].concat(b)):$.datepicker._attachDatepicker(this,a)}):$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.8.20",window["DP_jQuery_"+dpuuid]=$})(jQuery);; \ No newline at end of file diff --git a/dav/virtual_cal_source_friendica.inc.php b/dav/virtual_cal_source_friendica.inc.php deleted file mode 100644 index 7434fbbc..00000000 --- a/dav/virtual_cal_source_friendica.inc.php +++ /dev/null @@ -1,169 +0,0 @@ -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); - } - */ - - // 2012-06-29 - change to Friendica new event behaviour where summary is present and required, - // but use desc for older events where summary wasn't present or required (but desc was) - - $subject = (($row["summary"]) ? $row["summary"] : substr(preg_replace("/\[[^\]]*\]/", "", $row["desc"]), 0, 100)); - $description = (($row["desc"]) ? preg_replace("/\[[^\]]*\]/", "", $row["desc"]) : $row["summary"]); - - $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), - ); - - } - - /** - * @static - * @param int $uid - * @param int $namespace_id - * @param string|int $date_from - * @param string|int $date_to - * @throws Sabre_DAV_Exception_NotFound - * @return array - */ - static public function getItemsByTime($uid = 0, $namespace_id = 0, $date_from = "", $date_to = "") - { - $uid = IntVal($uid); - $namespace_id = IntVal($namespace_id); - - switch ($namespace_id) { - case CALDAV_FRIENDICA_MINE: - $sql_where = " AND cid = 0"; - break; - case CALDAV_FRIENDICA_CONTACTS: - $sql_where = " AND cid > 0"; - break; - default: - throw new Sabre_DAV_Exception_NotFound(); - } - - if ($date_from != "") { - if (is_numeric($date_from)) $sql_where .= " AND `finish` >= '" . date("Y-m-d H:i:s", $date_from) . "'"; - else $sql_where .= " AND `finish` >= '" . dbesc($date_from) . "'"; - } - if ($date_to != "") { - if (is_numeric($date_to)) $sql_where .= " AND `start` <= '" . date("Y-m-d H:i:s", $date_to) . "'"; - else $sql_where .= " AND `start` <= '" . dbesc($date_to) . "'"; - } - - $ret = array(); - $a = get_app(); - $host = $a->get_hostname(); - - - $r = q("SELECT * FROM `event` WHERE `uid` = %d " . $sql_where . " ORDER BY `start`", $uid); - foreach ($r as $row) $ret[] =self::row2array($row, $a->timezone, $host, $uid, $namespace_id); - - return $ret; - } - - - /** - * @static - * @param int $uid - * @param string $uri - * @throws Sabre_DAV_Exception_NotFound - * @return array - */ - static public function getItemsByUri($uid = 0, $uri) - { - $x = explode("-", $uri); - if ($x[0] != "friendica") throw new Sabre_DAV_Exception_NotFound(); - - $namespace_id = IntVal($x[1]); - switch ($namespace_id) { - case CALDAV_FRIENDICA_MINE: - $sql_where = " AND cid = 0"; - break; - case CALDAV_FRIENDICA_CONTACTS: - $sql_where = " AND cid > 0"; - break; - default: - throw new Sabre_DAV_Exception_NotFound(); - } - - $a = get_app(); - $host = $a->get_hostname(); - - $r = q("SELECT * FROM `event` WHERE `uid` = %d AND id = %d " . $sql_where, $uid, IntVal($x[2])); - if (count($r) != 1) throw new Sabre_DAV_Exception_NotFound(); - $ret =self::row2array($r[0], $a->timezone, $host, $uid, $namespace_id); - - return $ret; - } - - -} \ No newline at end of file diff --git a/dav/wdcal/Changelog.txt b/dav/wdcal/Changelog.txt deleted file mode 100644 index 9cc23a4a..00000000 --- a/dav/wdcal/Changelog.txt +++ /dev/null @@ -1,10 +0,0 @@ -v0.1.1 -====== -[FEATURE] A "New Event" Button in the navigation bar of the calendar is added. -[FEATURE] When creating an event by dragging in the calendar, the "Edit Details"-Link leads to a page where the details can be added before actually creating the event. -[BUGFIX] When editing a event, the start time cannot be set befor the end time anymore. -[BUGFIX] Fixed some problems with Magic Quotes - -v0.1 -====== -Initial Release \ No newline at end of file diff --git a/dav/wdcal_cal_source_friendicaevents.inc.php b/dav/wdcal_cal_source_friendicaevents.inc.php deleted file mode 100644 index ed44bf96..00000000 --- a/dav/wdcal_cal_source_friendicaevents.inc.php +++ /dev/null @@ -1,164 +0,0 @@ -calendarDb->uid) return array("read"=> true, "write"=> false); - return array("read"=> false, "write"=> false); - } - - /** - * @param int $user - * @param string $item_uri - * @param string $recurrence_uri - * @param null|array $item_arr - * @return array - */ - public function getPermissionsItem($user, $item_uri, $recurrence_uri, $item_arr = null) - { - $cal_perm = $this->getPermissionsCalendar($user); - if (!$cal_perm["read"]) return array("read"=> false, "write"=> false); - return array("read"=> true, "write"=> false); - } - - - /** - * @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_MethodNotAllowed - */ - public function updateItem($uri, $start, $end, $subject = "", $allday = false, $description = "", $location = "", $color = null, $timezone = "", $notification = true, $notification_type = null, $notification_value = null) - { - throw new Sabre_DAV_Exception_MethodNotAllowed(); - } - - /** - * @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_MethodNotAllowed - * @return array|string - */ - public function addItem($start, $end, $subject, $allday = false, $description = "", $location = "", $color = null, - $timezone = "", $notification = true, $notification_type = null, $notification_value = null) - { - throw new Sabre_DAV_Exception_MethodNotAllowed(); - } - - /** - * @param array $row - * @return array - */ - private function virtualData2wdcal($row) { - $end = wdcal_mySql2PhpTime($row["data_end"]); - if ($row["data_allday"]) $end--; - $start = wdcal_mySql2PhpTime($row["data_start"]); - $a = get_app(); - $arr = array( - "uri" => $row["data_uri"], - "subject" => escape_tags($row["data_subject"]), - "start" => $start, - "end" => $end, - "is_allday" => ($row["data_allday"] == 1), - "is_moredays" => (date("Ymd", $start) != date("Ymd", $end)), - "is_recurring" => ($row["data_type"] == "birthday"), - "color" => "#ff0000", - "is_editable" => false, - "is_editable_quick" => false, - "location" => $row["data_location"], - "attendees" => '', - "has_notification" => false, - "url_detail" => $a->get_baseurl() . "/dav/wdcal/" . $row["data_uri"] . "/", - "url_edit" => "", - "special_type" => ($row["data_type"] == "birthday" ? "birthday" : ""), - ); - return $arr; - } - - /** - * @param string $sd - * @param string $ed - * @param string $base_path - * @return array - */ - public function listItemsByRange($sd, $ed, $base_path) - { - $usr_id = IntVal($this->calendarDb->uid); - - $evs = FriendicaVirtualCalSourceBackend::getItemsByTime($usr_id, $this->namespace_id, $sd, $ed); - $events = array(); - foreach ($evs as $row) $events[] = $this->virtualData2wdcal($row); - - return $events; - } - - /** - * @param string $uri - * @throws Sabre_DAV_Exception_MethodNotAllowed - * @return void - */ - public function removeItem($uri) { - throw new Sabre_DAV_Exception_MethodNotAllowed(); - } - - /** - * @param string $uri - * @return array - */ - public function getItemByUri($uri) - { - $usr_id = IntVal($this->calendarDb->uid); - $row = FriendicaVirtualCalSourceBackend::getItemsByUri($usr_id, $uri); - return $this->virtualData2wdcal($row); - } - - /** - * @param string $uri - * @return string - */ - public function getItemDetailRedirect($uri) { - $x = explode("@", $uri); - $y = explode("-", $x[0]); - $a = get_app(); - if (count($y) != 3) { - goaway($a->get_baseurl() . "/dav/wdcal/"); - killme(); - } - $a = get_app(); - $item = q("SELECT `id` FROM `item` WHERE `event-id` = %d AND `uid` = %d AND deleted = 0", IntVal($y[2]), $a->user["uid"]); - if (count($item) == 0) return "/events/"; - return "/display/" . $a->user["nickname"] . "/" . IntVal($item[0]["id"]); - } -} -- 2.39.5