';
+
+ /**
+ * https://www.kanzaki.com/docs/ical/summary.html
+ *
+ * @var string
+ */
+ public $summary;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/dtstart.html
+ *
+ * @var string
+ */
+ public $dtstart;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/dtend.html
+ *
+ * @var string
+ */
+ public $dtend;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/duration.html
+ *
+ * @var string|null
+ */
+ public $duration;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/dtstamp.html
+ *
+ * @var string
+ */
+ public $dtstamp;
+
+ /**
+ * When the event starts, represented as a timezone-adjusted string
+ *
+ * @var string
+ */
+ public $dtstart_tz;
+
+ /**
+ * When the event ends, represented as a timezone-adjusted string
+ *
+ * @var string
+ */
+ public $dtend_tz;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/uid.html
+ *
+ * @var string
+ */
+ public $uid;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/created.html
+ *
+ * @var string
+ */
+ public $created;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/lastModified.html
+ *
+ * @var string
+ */
+ public $last_modified;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/description.html
+ *
+ * @var string|null
+ */
+ public $description;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/location.html
+ *
+ * @var string|null
+ */
+ public $location;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/sequence.html
+ *
+ * @var string
+ */
+ public $sequence;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/status.html
+ *
+ * @var string
+ */
+ public $status;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/transp.html
+ *
+ * @var string
+ */
+ public $transp;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/organizer.html
+ *
+ * @var string
+ */
+ public $organizer;
+
+ /**
+ * https://www.kanzaki.com/docs/ical/attendee.html
+ *
+ * @var string
+ */
+ public $attendee;
+
+ /**
+ * Manage additional properties
+ *
+ * @var array
+ */
+ public $additionalProperties = array();
+
+ /**
+ * Creates the Event object
+ *
+ * @param array $data
+ * @return void
+ */
+ public function __construct(array $data = array())
+ {
+ foreach ($data as $key => $value) {
+ $variable = self::snakeCase($key);
+ if (property_exists($this, $variable)) {
+ $this->{$variable} = $this->prepareData($value);
+ } else {
+ $this->additionalProperties[$variable] = $this->prepareData($value);
+ }
+ }
+ }
+
+ /**
+ * Magic getter method
+ *
+ * @param string $additionalPropertyName
+ * @return mixed
+ */
+ public function __get($additionalPropertyName)
+ {
+ if (array_key_exists($additionalPropertyName, $this->additionalProperties)) {
+ return $this->additionalProperties[$additionalPropertyName];
+ }
+
+ return null;
+ }
+
+ /**
+ * Magic isset method
+ *
+ * @param string $name
+ * @return boolean
+ */
+ public function __isset($name)
+ {
+ return is_null($this->$name) === false;
+ }
+
+ /**
+ * Prepares the data for output
+ *
+ * @param mixed $value
+ * @return mixed
+ */
+ protected function prepareData($value)
+ {
+ if (is_string($value)) {
+ return stripslashes(trim(str_replace('\n', "\n", $value)));
+ }
+
+ if (is_array($value)) {
+ return array_map(function ($value) {
+ return $this->prepareData($value);
+ }, $value);
+ }
+
+ return $value;
+ }
+
+ /**
+ * Returns Event data excluding anything blank
+ * within an HTML template
+ *
+ * @param string $html HTML template to use
+ * @return string
+ */
+ public function printData($html = self::HTML_TEMPLATE)
+ {
+ $data = array(
+ 'SUMMARY' => $this->summary,
+ 'DTSTART' => $this->dtstart,
+ 'DTEND' => $this->dtend,
+ 'DTSTART_TZ' => $this->dtstart_tz,
+ 'DTEND_TZ' => $this->dtend_tz,
+ 'DURATION' => $this->duration,
+ 'DTSTAMP' => $this->dtstamp,
+ 'UID' => $this->uid,
+ 'CREATED' => $this->created,
+ 'LAST-MODIFIED' => $this->last_modified,
+ 'DESCRIPTION' => $this->description,
+ 'LOCATION' => $this->location,
+ 'SEQUENCE' => $this->sequence,
+ 'STATUS' => $this->status,
+ 'TRANSP' => $this->transp,
+ 'ORGANISER' => $this->organizer,
+ 'ATTENDEE(S)' => $this->attendee,
+ );
+
+ // Remove any blank values
+ $data = array_filter($data);
+
+ $output = '';
+
+ foreach ($data as $key => $value) {
+ $output .= sprintf($html, $key, $value);
+ }
+
+ return $output;
+ }
+
+ /**
+ * Converts the given input to snake_case
+ *
+ * @param string $input
+ * @param string $glue
+ * @param string $separator
+ * @return string
+ */
+ protected static function snakeCase($input, $glue = '_', $separator = '-')
+ {
+ $inputSplit = preg_split('/(?<=[a-z])(?=[A-Z])/x', $input);
+
+ if ($inputSplit === false) {
+ return $input;
+ }
+
+ $inputSplit = implode($glue, $inputSplit);
+ $inputSplit = str_replace($separator, $glue, $inputSplit);
+
+ return strtolower($inputSplit);
+ }
+}
diff --git a/lib/composer/vendor/johngrogg/ics-parser/src/ICal/ICal.php b/lib/composer/vendor/johngrogg/ics-parser/src/ICal/ICal.php
new file mode 100644
index 0000000..f4aab16
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/src/ICal/ICal.php
@@ -0,0 +1,2731 @@
+
+ * @license https://opensource.org/licenses/mit-license.php MIT License
+ * @version 3.2.0
+ */
+
+namespace ICal;
+
+class ICal
+{
+ // phpcs:disable Generic.Arrays.DisallowLongArraySyntax
+
+ const DATE_TIME_FORMAT = 'Ymd\THis';
+ const DATE_TIME_FORMAT_PRETTY = 'F Y H:i:s';
+ const ICAL_DATE_TIME_TEMPLATE = 'TZID=%s:';
+ const ISO_8601_WEEK_START = 'MO';
+ const RECURRENCE_EVENT = 'Generated recurrence event';
+ const SECONDS_IN_A_WEEK = 604800;
+ const TIME_FORMAT = 'His';
+ const TIME_ZONE_UTC = 'UTC';
+ const UNIX_FORMAT = 'U';
+ const UNIX_MIN_YEAR = 1970;
+
+ /**
+ * Tracks the number of alarms in the current iCal feed
+ *
+ * @var integer
+ */
+ public $alarmCount = 0;
+
+ /**
+ * Tracks the number of events in the current iCal feed
+ *
+ * @var integer
+ */
+ public $eventCount = 0;
+
+ /**
+ * Tracks the free/busy count in the current iCal feed
+ *
+ * @var integer
+ */
+ public $freeBusyCount = 0;
+
+ /**
+ * Tracks the number of todos in the current iCal feed
+ *
+ * @var integer
+ */
+ public $todoCount = 0;
+
+ /**
+ * The value in years to use for indefinite, recurring events
+ *
+ * @var integer
+ */
+ public $defaultSpan = 2;
+
+ /**
+ * Enables customisation of the default time zone
+ *
+ * @var string|null
+ */
+ public $defaultTimeZone;
+
+ /**
+ * The two letter representation of the first day of the week
+ *
+ * @var string
+ */
+ public $defaultWeekStart = self::ISO_8601_WEEK_START;
+
+ /**
+ * Toggles whether to skip the parsing of recurrence rules
+ *
+ * @var boolean
+ */
+ public $skipRecurrence = false;
+
+ /**
+ * Toggles whether to disable all character replacement.
+ *
+ * @var boolean
+ */
+ public $disableCharacterReplacement = false;
+
+ /**
+ * If this value is an integer, the parser will ignore all events more than roughly this many days before now.
+ * If this value is a date, the parser will ignore all events occurring before this date.
+ *
+ * @var \DateTimeInterface|integer|null
+ */
+ public $filterDaysBefore;
+
+ /**
+ * If this value is an integer, the parser will ignore all events more than roughly this many days after now.
+ * If this value is a date, the parser will ignore all events occurring after this date.
+ *
+ * @var \DateTimeInterface|integer|null
+ */
+ public $filterDaysAfter;
+
+ /**
+ * The parsed calendar
+ *
+ * @var array
+ */
+ public $cal = array();
+
+ /**
+ * Tracks the VFREEBUSY component
+ *
+ * @var integer
+ */
+ protected $freeBusyIndex = 0;
+
+ /**
+ * Variable to track the previous keyword
+ *
+ * @var string
+ */
+ protected $lastKeyword;
+
+ /**
+ * Cache valid IANA time zone IDs to avoid unnecessary lookups
+ *
+ * @var array
+ */
+ protected $validIanaTimeZones = array();
+
+ /**
+ * Event recurrence instances that have been altered
+ *
+ * @var array
+ */
+ protected $alteredRecurrenceInstances = array();
+
+ /**
+ * An associative array containing weekday conversion data
+ *
+ * The order of the days in the array follow the ISO-8601 specification of a week.
+ *
+ * @var array
+ */
+ protected $weekdays = array(
+ 'MO' => 'monday',
+ 'TU' => 'tuesday',
+ 'WE' => 'wednesday',
+ 'TH' => 'thursday',
+ 'FR' => 'friday',
+ 'SA' => 'saturday',
+ 'SU' => 'sunday',
+ );
+
+ /**
+ * An associative array containing frequency conversion terms
+ *
+ * @var array
+ */
+ protected $frequencyConversion = array(
+ 'DAILY' => 'day',
+ 'WEEKLY' => 'week',
+ 'MONTHLY' => 'month',
+ 'YEARLY' => 'year',
+ );
+
+ /**
+ * Holds the username and password for HTTP basic authentication
+ *
+ * @var array
+ */
+ protected $httpBasicAuth = array();
+
+ /**
+ * Holds the custom User Agent string header
+ *
+ * @var string
+ */
+ protected $httpUserAgent;
+
+ /**
+ * Holds the custom Accept Language string header
+ *
+ * @var string
+ */
+ protected $httpAcceptLanguage;
+
+ /**
+ * Holds the custom HTTP Protocol version
+ *
+ * @var string
+ */
+ protected $httpProtocolVersion;
+
+ /**
+ * Define which variables can be configured
+ *
+ * @var array
+ */
+ private static $configurableOptions = array(
+ 'defaultSpan',
+ 'defaultTimeZone',
+ 'defaultWeekStart',
+ 'disableCharacterReplacement',
+ 'filterDaysAfter',
+ 'filterDaysBefore',
+ 'httpUserAgent',
+ 'skipRecurrence',
+ );
+
+ /**
+ * CLDR time zones mapped to IANA time zones.
+ *
+ * @var array
+ */
+ private static $cldrTimeZonesMap = array(
+ '(UTC-12:00) International Date Line West' => 'Etc/GMT+12',
+ '(UTC-11:00) Coordinated Universal Time-11' => 'Etc/GMT+11',
+ '(UTC-10:00) Hawaii' => 'Pacific/Honolulu',
+ '(UTC-09:00) Alaska' => 'America/Anchorage',
+ '(UTC-08:00) Pacific Time (US & Canada)' => 'America/Los_Angeles',
+ '(UTC-07:00) Arizona' => 'America/Phoenix',
+ '(UTC-07:00) Chihuahua, La Paz, Mazatlan' => 'America/Chihuahua',
+ '(UTC-07:00) Mountain Time (US & Canada)' => 'America/Denver',
+ '(UTC-06:00) Central America' => 'America/Guatemala',
+ '(UTC-06:00) Central Time (US & Canada)' => 'America/Chicago',
+ '(UTC-06:00) Guadalajara, Mexico City, Monterrey' => 'America/Mexico_City',
+ '(UTC-06:00) Saskatchewan' => 'America/Regina',
+ '(UTC-05:00) Bogota, Lima, Quito, Rio Branco' => 'America/Bogota',
+ '(UTC-05:00) Chetumal' => 'America/Cancun',
+ '(UTC-05:00) Eastern Time (US & Canada)' => 'America/New_York',
+ '(UTC-05:00) Indiana (East)' => 'America/Indianapolis',
+ '(UTC-04:00) Asuncion' => 'America/Asuncion',
+ '(UTC-04:00) Atlantic Time (Canada)' => 'America/Halifax',
+ '(UTC-04:00) Caracas' => 'America/Caracas',
+ '(UTC-04:00) Cuiaba' => 'America/Cuiaba',
+ '(UTC-04:00) Georgetown, La Paz, Manaus, San Juan' => 'America/La_Paz',
+ '(UTC-04:00) Santiago' => 'America/Santiago',
+ '(UTC-03:30) Newfoundland' => 'America/St_Johns',
+ '(UTC-03:00) Brasilia' => 'America/Sao_Paulo',
+ '(UTC-03:00) Cayenne, Fortaleza' => 'America/Cayenne',
+ '(UTC-03:00) City of Buenos Aires' => 'America/Buenos_Aires',
+ '(UTC-03:00) Greenland' => 'America/Godthab',
+ '(UTC-03:00) Montevideo' => 'America/Montevideo',
+ '(UTC-03:00) Salvador' => 'America/Bahia',
+ '(UTC-02:00) Coordinated Universal Time-02' => 'Etc/GMT+2',
+ '(UTC-01:00) Azores' => 'Atlantic/Azores',
+ '(UTC-01:00) Cabo Verde Is.' => 'Atlantic/Cape_Verde',
+ '(UTC) Coordinated Universal Time' => 'Etc/GMT',
+ '(UTC+00:00) Casablanca' => 'Africa/Casablanca',
+ '(UTC+00:00) Dublin, Edinburgh, Lisbon, London' => 'Europe/London',
+ '(UTC+00:00) Monrovia, Reykjavik' => 'Atlantic/Reykjavik',
+ '(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna' => 'Europe/Berlin',
+ '(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague' => 'Europe/Budapest',
+ '(UTC+01:00) Brussels, Copenhagen, Madrid, Paris' => 'Europe/Paris',
+ '(UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb' => 'Europe/Warsaw',
+ '(UTC+01:00) West Central Africa' => 'Africa/Lagos',
+ '(UTC+02:00) Amman' => 'Asia/Amman',
+ '(UTC+02:00) Athens, Bucharest' => 'Europe/Bucharest',
+ '(UTC+02:00) Beirut' => 'Asia/Beirut',
+ '(UTC+02:00) Cairo' => 'Africa/Cairo',
+ '(UTC+02:00) Chisinau' => 'Europe/Chisinau',
+ '(UTC+02:00) Damascus' => 'Asia/Damascus',
+ '(UTC+02:00) Harare, Pretoria' => 'Africa/Johannesburg',
+ '(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius' => 'Europe/Kiev',
+ '(UTC+02:00) Jerusalem' => 'Asia/Jerusalem',
+ '(UTC+02:00) Kaliningrad' => 'Europe/Kaliningrad',
+ '(UTC+02:00) Tripoli' => 'Africa/Tripoli',
+ '(UTC+02:00) Windhoek' => 'Africa/Windhoek',
+ '(UTC+03:00) Baghdad' => 'Asia/Baghdad',
+ '(UTC+03:00) Istanbul' => 'Europe/Istanbul',
+ '(UTC+03:00) Kuwait, Riyadh' => 'Asia/Riyadh',
+ '(UTC+03:00) Minsk' => 'Europe/Minsk',
+ '(UTC+03:00) Moscow, St. Petersburg, Volgograd' => 'Europe/Moscow',
+ '(UTC+03:00) Nairobi' => 'Africa/Nairobi',
+ '(UTC+03:30) Tehran' => 'Asia/Tehran',
+ '(UTC+04:00) Abu Dhabi, Muscat' => 'Asia/Dubai',
+ '(UTC+04:00) Baku' => 'Asia/Baku',
+ '(UTC+04:00) Izhevsk, Samara' => 'Europe/Samara',
+ '(UTC+04:00) Port Louis' => 'Indian/Mauritius',
+ '(UTC+04:00) Tbilisi' => 'Asia/Tbilisi',
+ '(UTC+04:00) Yerevan' => 'Asia/Yerevan',
+ '(UTC+04:30) Kabul' => 'Asia/Kabul',
+ '(UTC+05:00) Ashgabat, Tashkent' => 'Asia/Tashkent',
+ '(UTC+05:00) Ekaterinburg' => 'Asia/Yekaterinburg',
+ '(UTC+05:00) Islamabad, Karachi' => 'Asia/Karachi',
+ '(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi' => 'Asia/Calcutta',
+ '(UTC+05:30) Sri Jayawardenepura' => 'Asia/Colombo',
+ '(UTC+05:45) Kathmandu' => 'Asia/Katmandu',
+ '(UTC+06:00) Astana' => 'Asia/Almaty',
+ '(UTC+06:00) Dhaka' => 'Asia/Dhaka',
+ '(UTC+06:30) Yangon (Rangoon)' => 'Asia/Rangoon',
+ '(UTC+07:00) Bangkok, Hanoi, Jakarta' => 'Asia/Bangkok',
+ '(UTC+07:00) Krasnoyarsk' => 'Asia/Krasnoyarsk',
+ '(UTC+07:00) Novosibirsk' => 'Asia/Novosibirsk',
+ '(UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi' => 'Asia/Shanghai',
+ '(UTC+08:00) Irkutsk' => 'Asia/Irkutsk',
+ '(UTC+08:00) Kuala Lumpur, Singapore' => 'Asia/Singapore',
+ '(UTC+08:00) Perth' => 'Australia/Perth',
+ '(UTC+08:00) Taipei' => 'Asia/Taipei',
+ '(UTC+08:00) Ulaanbaatar' => 'Asia/Ulaanbaatar',
+ '(UTC+09:00) Osaka, Sapporo, Tokyo' => 'Asia/Tokyo',
+ '(UTC+09:00) Pyongyang' => 'Asia/Pyongyang',
+ '(UTC+09:00) Seoul' => 'Asia/Seoul',
+ '(UTC+09:00) Yakutsk' => 'Asia/Yakutsk',
+ '(UTC+09:30) Adelaide' => 'Australia/Adelaide',
+ '(UTC+09:30) Darwin' => 'Australia/Darwin',
+ '(UTC+10:00) Brisbane' => 'Australia/Brisbane',
+ '(UTC+10:00) Canberra, Melbourne, Sydney' => 'Australia/Sydney',
+ '(UTC+10:00) Guam, Port Moresby' => 'Pacific/Port_Moresby',
+ '(UTC+10:00) Hobart' => 'Australia/Hobart',
+ '(UTC+10:00) Vladivostok' => 'Asia/Vladivostok',
+ '(UTC+11:00) Chokurdakh' => 'Asia/Srednekolymsk',
+ '(UTC+11:00) Magadan' => 'Asia/Magadan',
+ '(UTC+11:00) Solomon Is., New Caledonia' => 'Pacific/Guadalcanal',
+ '(UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky' => 'Asia/Kamchatka',
+ '(UTC+12:00) Auckland, Wellington' => 'Pacific/Auckland',
+ '(UTC+12:00) Coordinated Universal Time+12' => 'Etc/GMT-12',
+ '(UTC+12:00) Fiji' => 'Pacific/Fiji',
+ "(UTC+13:00) Nuku'alofa" => 'Pacific/Tongatapu',
+ '(UTC+13:00) Samoa' => 'Pacific/Apia',
+ '(UTC+14:00) Kiritimati Island' => 'Pacific/Kiritimati',
+ );
+
+ /**
+ * Maps Windows (non-CLDR) time zone ID to IANA ID. This is pragmatic but not 100% precise as one Windows zone ID
+ * maps to multiple IANA IDs (one for each territory). For all practical purposes this should be good enough, though.
+ *
+ * Source: http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml
+ *
+ * @var array
+ */
+ private static $windowsTimeZonesMap = array(
+ 'AUS Central Standard Time' => 'Australia/Darwin',
+ 'AUS Eastern Standard Time' => 'Australia/Sydney',
+ 'Afghanistan Standard Time' => 'Asia/Kabul',
+ 'Alaskan Standard Time' => 'America/Anchorage',
+ 'Aleutian Standard Time' => 'America/Adak',
+ 'Altai Standard Time' => 'Asia/Barnaul',
+ 'Arab Standard Time' => 'Asia/Riyadh',
+ 'Arabian Standard Time' => 'Asia/Dubai',
+ 'Arabic Standard Time' => 'Asia/Baghdad',
+ 'Argentina Standard Time' => 'America/Buenos_Aires',
+ 'Astrakhan Standard Time' => 'Europe/Astrakhan',
+ 'Atlantic Standard Time' => 'America/Halifax',
+ 'Aus Central W. Standard Time' => 'Australia/Eucla',
+ 'Azerbaijan Standard Time' => 'Asia/Baku',
+ 'Azores Standard Time' => 'Atlantic/Azores',
+ 'Bahia Standard Time' => 'America/Bahia',
+ 'Bangladesh Standard Time' => 'Asia/Dhaka',
+ 'Belarus Standard Time' => 'Europe/Minsk',
+ 'Bougainville Standard Time' => 'Pacific/Bougainville',
+ '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 (Mexico)' => 'America/Mexico_City',
+ 'Central Standard Time' => 'America/Chicago',
+ 'Chatham Islands Standard Time' => 'Pacific/Chatham',
+ 'China Standard Time' => 'Asia/Shanghai',
+ 'Cuba Standard Time' => 'America/Havana',
+ 'Dateline Standard Time' => 'Etc/GMT+12',
+ 'E. Africa Standard Time' => 'Africa/Nairobi',
+ 'E. Australia Standard Time' => 'Australia/Brisbane',
+ 'E. Europe Standard Time' => 'Europe/Chisinau',
+ 'E. South America Standard Time' => 'America/Sao_Paulo',
+ 'Easter Island Standard Time' => 'Pacific/Easter',
+ 'Eastern Standard Time (Mexico)' => 'America/Cancun',
+ '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/Bucharest',
+ 'Georgian Standard Time' => 'Asia/Tbilisi',
+ 'Greenland Standard Time' => 'America/Godthab',
+ 'Greenwich Standard Time' => 'Atlantic/Reykjavik',
+ 'Haiti Standard Time' => 'America/Port-au-Prince',
+ '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',
+ 'Kaliningrad Standard Time' => 'Europe/Kaliningrad',
+ 'Korea Standard Time' => 'Asia/Seoul',
+ 'Libya Standard Time' => 'Africa/Tripoli',
+ 'Line Islands Standard Time' => 'Pacific/Kiritimati',
+ 'Lord Howe Standard Time' => 'Australia/Lord_Howe',
+ 'Magadan Standard Time' => 'Asia/Magadan',
+ 'Magallanes Standard Time' => 'America/Punta_Arenas',
+ 'Marquesas Standard Time' => 'Pacific/Marquesas',
+ 'Mauritius Standard Time' => 'Indian/Mauritius',
+ 'Middle East Standard Time' => 'Asia/Beirut',
+ 'Montevideo Standard Time' => 'America/Montevideo',
+ 'Morocco Standard Time' => 'Africa/Casablanca',
+ 'Mountain Standard Time (Mexico)' => 'America/Chihuahua',
+ 'Mountain Standard Time' => 'America/Denver',
+ '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',
+ 'Norfolk Standard Time' => 'Pacific/Norfolk',
+ 'North Asia East Standard Time' => 'Asia/Irkutsk',
+ 'North Asia Standard Time' => 'Asia/Krasnoyarsk',
+ 'North Korea Standard Time' => 'Asia/Pyongyang',
+ 'Omsk Standard Time' => 'Asia/Omsk',
+ 'Pacific SA Standard Time' => 'America/Santiago',
+ 'Pacific Standard Time (Mexico)' => 'America/Tijuana',
+ 'Pacific Standard Time' => 'America/Los_Angeles',
+ 'Pakistan Standard Time' => 'Asia/Karachi',
+ 'Paraguay Standard Time' => 'America/Asuncion',
+ 'Romance Standard Time' => 'Europe/Paris',
+ 'Russia Time Zone 10' => 'Asia/Srednekolymsk',
+ 'Russia Time Zone 11' => 'Asia/Kamchatka',
+ 'Russia Time Zone 3' => 'Europe/Samara',
+ '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',
+ 'Saint Pierre Standard Time' => 'America/Miquelon',
+ 'Sakhalin Standard Time' => 'Asia/Sakhalin',
+ 'Samoa Standard Time' => 'Pacific/Apia',
+ 'Sao Tome Standard Time' => 'Africa/Sao_Tome',
+ 'Saratov Standard Time' => 'Europe/Saratov',
+ 'Singapore Standard Time' => 'Asia/Singapore',
+ 'South Africa Standard Time' => 'Africa/Johannesburg',
+ 'Sri Lanka Standard Time' => 'Asia/Colombo',
+ 'Sudan Standard Time' => 'Africa/Tripoli',
+ 'Syria Standard Time' => 'Asia/Damascus',
+ 'Taipei Standard Time' => 'Asia/Taipei',
+ 'Tasmania Standard Time' => 'Australia/Hobart',
+ 'Tocantins Standard Time' => 'America/Araguaina',
+ 'Tokyo Standard Time' => 'Asia/Tokyo',
+ 'Tomsk Standard Time' => 'Asia/Tomsk',
+ 'Tonga Standard Time' => 'Pacific/Tongatapu',
+ 'Transbaikal Standard Time' => 'Asia/Chita',
+ 'Turkey Standard Time' => 'Europe/Istanbul',
+ 'Turks And Caicos Standard Time' => 'America/Grand_Turk',
+ 'US Eastern Standard Time' => 'America/Indianapolis',
+ 'US Mountain Standard Time' => 'America/Phoenix',
+ 'UTC' => 'Etc/GMT',
+ 'UTC+12' => 'Etc/GMT-12',
+ 'UTC+13' => 'Etc/GMT-13',
+ 'UTC-02' => 'Etc/GMT+2',
+ 'UTC-08' => 'Etc/GMT+8',
+ 'UTC-09' => 'Etc/GMT+9',
+ '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',
+ 'W. Mongolia Standard Time' => 'Asia/Hovd',
+ 'West Asia Standard Time' => 'Asia/Tashkent',
+ 'West Bank Standard Time' => 'Asia/Hebron',
+ 'West Pacific Standard Time' => 'Pacific/Port_Moresby',
+ 'Yakutsk Standard Time' => 'Asia/Yakutsk',
+ );
+
+ /**
+ * If `$filterDaysBefore` or `$filterDaysAfter` are set then the events are filtered according to the window defined
+ * by this field and `$windowMaxTimestamp`.
+ *
+ * @var integer
+ */
+ private $windowMinTimestamp;
+
+ /**
+ * If `$filterDaysBefore` or `$filterDaysAfter` are set then the events are filtered according to the window defined
+ * by this field and `$windowMinTimestamp`.
+ *
+ * @var integer
+ */
+ private $windowMaxTimestamp;
+
+ /**
+ * `true` if either `$filterDaysBefore` or `$filterDaysAfter` are set.
+ *
+ * @var boolean
+ */
+ private $shouldFilterByWindow = false;
+
+ /**
+ * Creates the ICal object
+ *
+ * @param mixed $files
+ * @param array $options
+ * @return void
+ */
+ public function __construct($files = false, array $options = array())
+ {
+ if (\PHP_VERSION_ID < 80100) {
+ ini_set('auto_detect_line_endings', '1');
+ }
+
+ foreach ($options as $option => $value) {
+ if (in_array($option, self::$configurableOptions)) {
+ $this->{$option} = $value;
+ }
+ }
+
+ // Fallback to use the system default time zone
+ if (!isset($this->defaultTimeZone) || !$this->isValidTimeZoneId($this->defaultTimeZone)) {
+ $this->defaultTimeZone = $this->getDefaultTimeZone(true);
+ }
+
+ // Ideally you would use `PHP_INT_MIN` from PHP 7
+ $php_int_min = -2147483648;
+
+ $this->windowMinTimestamp = $php_int_min;
+
+ if (!is_null($this->filterDaysBefore)) {
+ if (is_int($this->filterDaysBefore)) {
+ $this->windowMinTimestamp = (new \DateTime('now'))
+ ->sub(new \DateInterval('P' . $this->filterDaysBefore . 'D'))
+ ->getTimestamp();
+ }
+
+ if ($this->filterDaysBefore instanceof \DateTimeInterface) {
+ $this->windowMinTimestamp = $this->filterDaysBefore->getTimestamp();
+ }
+ }
+
+ $this->windowMaxTimestamp = PHP_INT_MAX;
+
+ if (!is_null($this->filterDaysAfter)) {
+ if (is_int($this->filterDaysAfter)) {
+ $this->windowMaxTimestamp = (new \DateTime('now'))
+ ->add(new \DateInterval('P' . $this->filterDaysAfter . 'D'))
+ ->getTimestamp();
+ }
+
+ if ($this->filterDaysAfter instanceof \DateTimeInterface) {
+ $this->windowMaxTimestamp = $this->filterDaysAfter->getTimestamp();
+ }
+ }
+
+ $this->shouldFilterByWindow = !is_null($this->filterDaysBefore) || !is_null($this->filterDaysAfter);
+
+ if ($files !== false) {
+ $files = is_array($files) ? $files : array($files);
+
+ foreach ($files as $file) {
+ if (!is_array($file) && $this->isFileOrUrl($file)) {
+ $lines = $this->fileOrUrl($file);
+ } else {
+ $lines = is_array($file) ? $file : array($file);
+ }
+
+ $this->initLines($lines);
+ }
+ }
+ }
+
+ /**
+ * Initialises lines from a string
+ *
+ * @param string $string
+ * @return ICal
+ */
+ public function initString($string)
+ {
+ $string = str_replace(array("\r\n", "\n\r", "\r"), "\n", $string);
+
+ if ($this->cal === array()) {
+ $lines = explode("\n", $string);
+
+ $this->initLines($lines);
+ } else {
+ trigger_error('ICal::initString: Calendar already initialised in constructor', E_USER_NOTICE);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Initialises lines from a file
+ *
+ * @param string $file
+ * @return ICal
+ */
+ public function initFile($file)
+ {
+ if ($this->cal === array()) {
+ $lines = $this->fileOrUrl($file);
+
+ $this->initLines($lines);
+ } else {
+ trigger_error('ICal::initFile: Calendar already initialised in constructor', E_USER_NOTICE);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Initialises lines from a URL
+ *
+ * @param string $url
+ * @param string $username
+ * @param string $password
+ * @param string $userAgent
+ * @param string $acceptLanguage
+ * @param string $httpProtocolVersion
+ * @return ICal
+ */
+ public function initUrl($url, $username = null, $password = null, $userAgent = null, $acceptLanguage = null, $httpProtocolVersion = null)
+ {
+ if (!is_null($username) && !is_null($password)) {
+ $this->httpBasicAuth['username'] = $username;
+ $this->httpBasicAuth['password'] = $password;
+ }
+
+ if (!is_null($userAgent)) {
+ $this->httpUserAgent = $userAgent;
+ }
+
+ if (!is_null($acceptLanguage)) {
+ $this->httpAcceptLanguage = $acceptLanguage;
+ }
+
+ if (!is_null($httpProtocolVersion)) {
+ $this->httpProtocolVersion = $httpProtocolVersion;
+ }
+
+ $this->initFile($url);
+
+ return $this;
+ }
+
+ /**
+ * Initialises the parser using an array
+ * containing each line of iCal content
+ *
+ * @param array $lines
+ * @return void
+ */
+ protected function initLines(array $lines)
+ {
+ $lines = $this->unfold($lines);
+
+ if (stristr($lines[0], 'BEGIN:VCALENDAR') !== false) {
+ $component = '';
+ foreach ($lines as $line) {
+ $line = rtrim($line); // Trim trailing whitespace
+ $line = $this->removeUnprintableChars($line);
+
+ if (empty($line)) {
+ continue;
+ }
+
+ if (!$this->disableCharacterReplacement) {
+ $line = str_replace(array(
+ ' ',
+ "\t",
+ "\xc2\xa0", // Non-breaking space
+ ), ' ', $line);
+
+ $line = $this->cleanCharacters($line);
+ }
+
+ $add = $this->keyValueFromString($line);
+ $keyword = $add[0];
+ $values = $add[1]; // May be an array containing multiple values
+
+ if (!is_array($values)) {
+ if (!empty($values)) {
+ $values = array($values); // Make an array as not one already
+ $blankArray = array(); // Empty placeholder array
+ $values[] = $blankArray;
+ } else {
+ $values = array(); // Use blank array to ignore this line
+ }
+ } elseif (empty($values[0])) {
+ $values = array(); // Use blank array to ignore this line
+ }
+
+ // Reverse so that our array of properties is processed first
+ $values = array_reverse($values);
+
+ foreach ($values as $value) {
+ switch ($line) {
+ // https://www.kanzaki.com/docs/ical/vtodo.html
+ case 'BEGIN:VTODO':
+ if (!is_array($value)) {
+ $this->todoCount++;
+ }
+
+ $component = 'VTODO';
+
+ break;
+
+ case 'BEGIN:VEVENT':
+ // https://www.kanzaki.com/docs/ical/vevent.html
+ if (!is_array($value)) {
+ $this->eventCount++;
+ }
+
+ $component = 'VEVENT';
+
+ break;
+
+ case 'BEGIN:VFREEBUSY':
+ // https://www.kanzaki.com/docs/ical/vfreebusy.html
+ if (!is_array($value)) {
+ $this->freeBusyIndex++;
+ }
+
+ $component = 'VFREEBUSY';
+
+ break;
+
+ case 'BEGIN:VALARM':
+ if (!is_array($value)) {
+ $this->alarmCount++;
+ }
+
+ $component = 'VALARM';
+
+ break;
+
+ case 'END:VALARM':
+ $component = 'VEVENT';
+
+ break;
+
+ case 'BEGIN:DAYLIGHT':
+ case 'BEGIN:STANDARD':
+ case 'BEGIN:VCALENDAR':
+ case 'BEGIN:VTIMEZONE':
+ $component = $value;
+
+ break;
+
+ case 'END:DAYLIGHT':
+ case 'END:STANDARD':
+ case 'END:VCALENDAR':
+ case 'END:VFREEBUSY':
+ case 'END:VTIMEZONE':
+ case 'END:VTODO':
+ $component = 'VCALENDAR';
+
+ break;
+
+ case 'END:VEVENT':
+ if ($this->shouldFilterByWindow) {
+ $this->removeLastEventIfOutsideWindowAndNonRecurring();
+ }
+
+ $component = 'VCALENDAR';
+
+ break;
+
+ default:
+ $this->addCalendarComponentWithKeyAndValue($component, $keyword, $value);
+
+ break;
+ }
+ }
+ }
+
+ $this->processEvents();
+
+ if (!$this->skipRecurrence) {
+ $this->processRecurrences();
+
+ // Apply changes to altered recurrence instances
+ if ($this->alteredRecurrenceInstances !== array()) {
+ $events = $this->cal['VEVENT'];
+
+ foreach ($this->alteredRecurrenceInstances as $alteredRecurrenceInstance) {
+ if (isset($alteredRecurrenceInstance['altered-event'])) {
+ $alteredEvent = $alteredRecurrenceInstance['altered-event'];
+ $key = key($alteredEvent);
+ $events[$key] = $alteredEvent[$key];
+ }
+ }
+
+ $this->cal['VEVENT'] = $events;
+ }
+ }
+
+ if ($this->shouldFilterByWindow) {
+ $this->reduceEventsToMinMaxRange();
+ }
+
+ $this->processDateConversions();
+ }
+ }
+
+ /**
+ * Removes the last event (i.e. most recently parsed) if its start date is outside the window spanned by
+ * `$windowMinTimestamp` / `$windowMaxTimestamp`.
+ *
+ * @return void
+ */
+ protected function removeLastEventIfOutsideWindowAndNonRecurring()
+ {
+ $events = $this->cal['VEVENT'];
+
+ if ($events !== array()) {
+ $lastIndex = count($events) - 1;
+ $lastEvent = $events[$lastIndex];
+
+ if ((!isset($lastEvent['RRULE']) || $lastEvent['RRULE'] === '') && $this->doesEventStartOutsideWindow($lastEvent)) {
+ $this->eventCount--;
+
+ unset($events[$lastIndex]);
+ }
+
+ $this->cal['VEVENT'] = $events;
+ }
+ }
+
+ /**
+ * Reduces the number of events to the defined minimum and maximum range
+ *
+ * @return void
+ */
+ protected function reduceEventsToMinMaxRange()
+ {
+ $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array();
+
+ if ($events !== array()) {
+ foreach ($events as $key => $anEvent) {
+ if ($anEvent === null) {
+ unset($events[$key]);
+
+ continue;
+ }
+
+ if ($this->doesEventStartOutsideWindow($anEvent)) {
+ $this->eventCount--;
+
+ unset($events[$key]);
+
+ continue;
+ }
+ }
+
+ $this->cal['VEVENT'] = $events;
+ }
+ }
+
+ /**
+ * Determines whether the event start date is outside `$windowMinTimestamp` / `$windowMaxTimestamp`.
+ * Returns `true` for invalid dates.
+ *
+ * @param array $event
+ * @return boolean
+ */
+ protected function doesEventStartOutsideWindow(array $event)
+ {
+ return !$this->isValidDate($event['DTSTART']) || $this->isOutOfRange($event['DTSTART'], $this->windowMinTimestamp, $this->windowMaxTimestamp);
+ }
+
+ /**
+ * Determines whether a valid iCalendar date is within a given range
+ *
+ * @param string $calendarDate
+ * @param integer $minTimestamp
+ * @param integer $maxTimestamp
+ * @return boolean
+ */
+ protected function isOutOfRange($calendarDate, $minTimestamp, $maxTimestamp)
+ {
+ $timestamp = strtotime(explode('T', $calendarDate)[0]);
+
+ return $timestamp < $minTimestamp || $timestamp > $maxTimestamp;
+ }
+
+ /**
+ * Unfolds an iCal file in preparation for parsing
+ * (https://icalendar.org/iCalendar-RFC-5545/3-1-content-lines.html)
+ *
+ * @param array $lines
+ * @return array
+ */
+ protected function unfold(array $lines)
+ {
+ $string = implode(PHP_EOL, $lines);
+ $string = str_ireplace(' ', ' ', $string);
+
+ $cleanedString = preg_replace('/' . PHP_EOL . '[ \t]/', '', $string);
+
+ $lines = explode(PHP_EOL, $cleanedString ?: $string);
+
+ return $lines;
+ }
+
+ /**
+ * Add one key and value pair to the `$this->cal` array
+ *
+ * @param string $component
+ * @param string|boolean $keyword
+ * @param string|array $value
+ * @return void
+ */
+ protected function addCalendarComponentWithKeyAndValue($component, $keyword, $value)
+ {
+ if ($keyword === false) {
+ $keyword = $this->lastKeyword;
+ }
+
+ switch ($component) {
+ case 'VALARM':
+ $key1 = 'VEVENT';
+ $key2 = ($this->eventCount - 1);
+ $key3 = $component;
+
+ if (!isset($this->cal[$key1][$key2][$key3]["{$keyword}_array"])) {
+ $this->cal[$key1][$key2][$key3]["{$keyword}_array"] = array();
+ }
+
+ if (is_array($value)) {
+ // Add array of properties to the end
+ $this->cal[$key1][$key2][$key3]["{$keyword}_array"][] = $value;
+ } else {
+ if (!isset($this->cal[$key1][$key2][$key3][$keyword])) {
+ $this->cal[$key1][$key2][$key3][$keyword] = $value;
+ }
+
+ if ($this->cal[$key1][$key2][$key3][$keyword] !== $value) {
+ $this->cal[$key1][$key2][$key3][$keyword] .= ',' . $value;
+ }
+ }
+ break;
+
+ case 'VEVENT':
+ $key1 = $component;
+ $key2 = ($this->eventCount - 1);
+
+ if (!isset($this->cal[$key1][$key2]["{$keyword}_array"])) {
+ $this->cal[$key1][$key2]["{$keyword}_array"] = array();
+ }
+
+ if (is_array($value)) {
+ // Add array of properties to the end
+ $this->cal[$key1][$key2]["{$keyword}_array"][] = $value;
+ } else {
+ if (!isset($this->cal[$key1][$key2][$keyword])) {
+ $this->cal[$key1][$key2][$keyword] = $value;
+ }
+
+ if ($keyword === 'EXDATE') {
+ if (trim($value) === $value) {
+ $array = array_filter(explode(',', $value));
+ $this->cal[$key1][$key2]["{$keyword}_array"][] = $array;
+ } else {
+ $value = explode(',', implode(',', $this->cal[$key1][$key2]["{$keyword}_array"][1]) . trim($value));
+ $this->cal[$key1][$key2]["{$keyword}_array"][1] = $value;
+ }
+ } else {
+ $this->cal[$key1][$key2]["{$keyword}_array"][] = $value;
+
+ if ($keyword === 'DURATION') {
+ $duration = new \DateInterval($value);
+ $this->cal[$key1][$key2]["{$keyword}_array"][] = $duration;
+ }
+ }
+
+ if (!is_array($value) && $this->cal[$key1][$key2][$keyword] !== $value) {
+ $this->cal[$key1][$key2][$keyword] .= ',' . $value;
+ }
+ }
+ break;
+
+ case 'VFREEBUSY':
+ $key1 = $component;
+ $key2 = ($this->freeBusyIndex - 1);
+ $key3 = $keyword;
+
+ if ($keyword === 'FREEBUSY') {
+ if (is_array($value)) {
+ $this->cal[$key1][$key2][$key3][][] = $value;
+ } else {
+ $this->freeBusyCount++;
+
+ end($this->cal[$key1][$key2][$key3]);
+ $key = key($this->cal[$key1][$key2][$key3]);
+
+ $value = explode('/', $value);
+ $this->cal[$key1][$key2][$key3][$key][] = $value;
+ }
+ } else {
+ $this->cal[$key1][$key2][$key3][] = $value;
+ }
+ break;
+
+ case 'VTODO':
+ $this->cal[$component][$this->todoCount - 1][$keyword] = $value;
+
+ break;
+
+ default:
+ $this->cal[$component][$keyword] = $value;
+
+ break;
+ }
+
+ if (is_string($keyword)) {
+ $this->lastKeyword = $keyword;
+ }
+ }
+
+ /**
+ * Gets the key value pair from an iCal string
+ *
+ * @param string $text
+ * @return array
+ */
+ public function keyValueFromString($text)
+ {
+ $splitLine = $this->parseLine($text);
+ $object = array();
+ $paramObj = array();
+ $valueObj = '';
+ $i = 0;
+
+ while ($i < count($splitLine)) {
+ // The first token corresponds to the property name
+ if ($i === 0) {
+ $object[0] = $splitLine[$i];
+ $i++;
+
+ continue;
+ }
+
+ // After each semicolon define the property parameters
+ if ($splitLine[$i] == ';') {
+ $i++;
+ $paramName = $splitLine[$i];
+ $i += 2;
+ $paramValue = array();
+ $multiValue = false;
+ // A parameter can have multiple values separated by a comma
+ while ($i + 1 < count($splitLine) && $splitLine[$i + 1] === ',') {
+ $paramValue[] = $splitLine[$i];
+ $i += 2;
+ $multiValue = true;
+ }
+
+ if ($multiValue) {
+ $paramValue[] = $splitLine[$i];
+ } else {
+ $paramValue = $splitLine[$i];
+ }
+
+ // Create object with paramName => paramValue
+ $paramObj[$paramName] = $paramValue;
+ }
+
+ // After a colon all tokens are concatenated (non-standard behaviour because the property can have multiple values
+ // according to RFC5545)
+ if ($splitLine[$i] === ':') {
+ $i++;
+ while ($i < count($splitLine)) {
+ $valueObj .= $splitLine[$i];
+ $i++;
+ }
+ }
+
+ $i++;
+ }
+
+ // Object construction
+ if ($paramObj !== array()) {
+ $object[1][0] = $valueObj;
+ $object[1][1] = $paramObj;
+ } else {
+ $object[1] = $valueObj;
+ }
+
+ return $object;
+ }
+
+ /**
+ * Parses a line from an iCal file into an array of tokens
+ *
+ * @param string $line
+ * @return array
+ */
+ protected function parseLine($line)
+ {
+ $words = array();
+ $word = '';
+ // The use of str_split is not a problem here even if the character set is in utf8
+ // Indeed we only compare the characters , ; : = " which are on a single byte
+ $arrayOfChar = str_split($line);
+ $inDoubleQuotes = false;
+
+ foreach ($arrayOfChar as $char) {
+ // Don't stop the word on ; , : = if it is enclosed in double quotes
+ if ($char === '"') {
+ if ($word !== '') {
+ $words[] = $word;
+ }
+
+ $word = '';
+ $inDoubleQuotes = !$inDoubleQuotes;
+ } elseif (!in_array($char, array(';', ':', ',', '=')) || $inDoubleQuotes) {
+ $word .= $char;
+ } else {
+ if ($word !== '') {
+ $words[] = $word;
+ }
+
+ $words[] = $char;
+ $word = '';
+ }
+ }
+
+ $words[] = $word;
+
+ return $words;
+ }
+
+ /**
+ * Returns the default time zone if set.
+ * Falls back to the system default if not set.
+ *
+ * @param boolean $forceReturnSystemDefault
+ * @return string
+ */
+ private function getDefaultTimeZone($forceReturnSystemDefault = false)
+ {
+ $systemDefault = date_default_timezone_get();
+
+ if ($forceReturnSystemDefault) {
+ return $systemDefault;
+ }
+
+ return $this->defaultTimeZone ?: $systemDefault;
+ }
+
+ /**
+ * Returns a `DateTime` object from an iCal date time format
+ *
+ * @param string $icalDate
+ * @return \DateTime|false
+ * @throws \Exception
+ */
+ public function iCalDateToDateTime($icalDate)
+ {
+ /**
+ * iCal times may be in 3 formats, (https://www.kanzaki.com/docs/ical/dateTime.html)
+ *
+ * UTC: Has a trailing 'Z'
+ * Floating: No time zone reference specified, no trailing 'Z', use local time
+ * TZID: Set time zone as specified
+ *
+ * Use DateTime class objects to get around limitations with `mktime` and `gmmktime`.
+ * Must have a local time zone set to process floating times.
+ */
+ $pattern = '/^(?:TZID=)?([^:]*|".*")'; // [1]: Time zone
+ $pattern .= ':?'; // Time zone delimiter
+ $pattern .= '(\d{8})'; // [2]: YYYYMMDD
+ $pattern .= 'T?'; // Time delimiter
+ $pattern .= '(?(?<=T)(\d{6}))'; // [3]: HHMMSS (filled if delimiter present)
+ $pattern .= '(Z?)/'; // [4]: UTC flag
+
+ preg_match($pattern, $icalDate, $date);
+
+ if ($date === array()) {
+ throw new \Exception('Invalid iCal date format.');
+ }
+
+ // A Unix timestamp usually cannot represent a date prior to 1 Jan 1970.
+ // PHP, on the other hand, uses negative numbers for that. Thus we don't
+ // need to special case them.
+
+ if ($date[4] === 'Z') {
+ $dateTimeZone = new \DateTimeZone(self::TIME_ZONE_UTC);
+ } elseif (isset($date[1]) && $date[1] !== '') {
+ $dateTimeZone = $this->timeZoneStringToDateTimeZone($date[1]);
+ } else {
+ $dateTimeZone = new \DateTimeZone($this->getDefaultTimeZone());
+ }
+
+ // The exclamation mark at the start of the format string indicates that if a
+ // time portion is not included, the time in the returned DateTime should be
+ // set to 00:00:00. Without it, the time would be set to the current system time.
+ $dateFormat = '!Ymd';
+ $dateBasic = $date[2];
+ if (isset($date[3]) && $date[3] !== '') {
+ $dateBasic .= "T{$date[3]}";
+ $dateFormat .= '\THis';
+ }
+
+ return \DateTime::createFromFormat($dateFormat, $dateBasic, $dateTimeZone);
+ }
+
+ /**
+ * Returns a Unix timestamp from an iCal date time format
+ *
+ * @param string $icalDate
+ * @return integer
+ */
+ public function iCalDateToUnixTimestamp($icalDate)
+ {
+ $iCalDateToDateTime = $this->iCalDateToDateTime($icalDate);
+
+ if ($iCalDateToDateTime === false) {
+ trigger_error("ICal::iCalDateToUnixTimestamp: Invalid date passed ({$icalDate})", E_USER_NOTICE);
+
+ return 0;
+ }
+
+ return $iCalDateToDateTime->getTimestamp();
+ }
+
+ /**
+ * Returns a date adapted to the calendar time zone depending on the event `TZID`
+ *
+ * @param array $event
+ * @param string $key
+ * @param string|null $format
+ * @return string|integer|boolean|\DateTime
+ */
+ public function iCalDateWithTimeZone(array $event, $key, $format = self::DATE_TIME_FORMAT)
+ {
+ if (!isset($event["{$key}_array"]) || !isset($event[$key])) {
+ return false;
+ }
+
+ $dateArray = $event["{$key}_array"];
+
+ if ($key === 'DURATION') {
+ $dateTime = $this->parseDuration($event['DTSTART'], $dateArray[2]);
+
+ if ($dateTime instanceof \DateTime === false) {
+ trigger_error("ICal::iCalDateWithTimeZone: Invalid date passed ({$event['DTSTART']})", E_USER_NOTICE);
+
+ return false;
+ }
+ } else {
+ // When constructing from a Unix Timestamp, no time zone needs passing.
+ $dateTime = new \DateTime("@{$dateArray[2]}");
+ }
+
+ $calendarTimeZone = $this->calendarTimeZone();
+
+ if (!is_null($calendarTimeZone)) {
+ // Set the time zone we wish to use when running `$dateTime->format`.
+ $dateTime->setTimezone(new \DateTimeZone($calendarTimeZone));
+ }
+
+ if (is_null($format)) {
+ return $dateTime;
+ }
+
+ return $dateTime->format($format);
+ }
+
+ /**
+ * Performs admin tasks on all events as read from the iCal file.
+ * Adds a Unix timestamp to all `{DTSTART|DTEND|RECURRENCE-ID}_array` arrays
+ * Tracks modified recurrence instances
+ *
+ * @return void
+ */
+ protected function processEvents()
+ {
+ $checks = null;
+ $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array();
+
+ if ($events !== array()) {
+ foreach ($events as $key => $anEvent) {
+ foreach (array('DTSTART', 'DTEND', 'RECURRENCE-ID') as $type) {
+ if (isset($anEvent[$type])) {
+ $date = $anEvent["{$type}_array"][1];
+
+ if (isset($anEvent["{$type}_array"][0]['TZID'])) {
+ $timeZone = $this->escapeParamText($anEvent["{$type}_array"][0]['TZID']);
+ $date = sprintf(self::ICAL_DATE_TIME_TEMPLATE, $timeZone) . $date;
+ }
+
+ $anEvent["{$type}_array"][2] = $this->iCalDateToUnixTimestamp($date);
+ $anEvent["{$type}_array"][3] = $date;
+ }
+ }
+
+ if (isset($anEvent['RECURRENCE-ID'])) {
+ $uid = $anEvent['UID'];
+
+ if (!isset($this->alteredRecurrenceInstances[$uid])) {
+ $this->alteredRecurrenceInstances[$uid] = array();
+ }
+
+ $recurrenceDateUtc = $this->iCalDateToUnixTimestamp($anEvent['RECURRENCE-ID_array'][3]);
+ $this->alteredRecurrenceInstances[$uid][$key] = $recurrenceDateUtc;
+ }
+
+ $events[$key] = $anEvent;
+ }
+
+ $eventKeysToRemove = array();
+
+ foreach ($events as $key => $event) {
+ $checks[] = !isset($event['RECURRENCE-ID']);
+ $checks[] = isset($event['UID']);
+ $checks[] = isset($event['UID']) && isset($this->alteredRecurrenceInstances[$event['UID']]);
+
+ if ((bool) array_product($checks)) {
+ $eventDtstartUnix = $this->iCalDateToUnixTimestamp($event['DTSTART_array'][3]);
+
+ // phpcs:ignore CustomPHPCS.ControlStructures.AssignmentInCondition
+ if (($alteredEventKey = array_search($eventDtstartUnix, $this->alteredRecurrenceInstances[$event['UID']], true)) !== false) {
+ $eventKeysToRemove[] = $alteredEventKey;
+
+ $alteredEvent = array_replace_recursive($events[$key], $events[$alteredEventKey]);
+ $this->alteredRecurrenceInstances[$event['UID']]['altered-event'] = array($key => $alteredEvent);
+ }
+ }
+
+ unset($checks);
+ }
+
+ foreach ($eventKeysToRemove as $eventKeyToRemove) {
+ $events[$eventKeyToRemove] = null;
+ }
+
+ $this->cal['VEVENT'] = $events;
+ }
+ }
+
+ /**
+ * Processes recurrence rules
+ *
+ * @return void
+ */
+ protected function processRecurrences()
+ {
+ $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array();
+
+ // If there are no events, then we have nothing to process.
+ if ($events === array()) {
+ return;
+ }
+
+ $allEventRecurrences = array();
+ $eventKeysToRemove = array();
+
+ foreach ($events as $key => $anEvent) {
+ if (!isset($anEvent['RRULE']) || $anEvent['RRULE'] === '') {
+ continue;
+ }
+
+ // Tag as generated by a recurrence rule
+ $anEvent['RRULE_array'][2] = self::RECURRENCE_EVENT;
+
+ // Create new initial starting point.
+ $initialEventDate = $this->icalDateToDateTime($anEvent['DTSTART_array'][3]);
+
+ if ($initialEventDate === false) {
+ trigger_error("ICal::processRecurrences: Invalid date passed ({$anEvent['DTSTART_array'][3]})", E_USER_NOTICE);
+
+ continue;
+ }
+
+ // Separate the RRULE stanzas, and explode the values that are lists.
+ $rrules = array();
+ foreach (array_filter(explode(';', $anEvent['RRULE'])) as $s) {
+ list($k, $v) = explode('=', $s);
+ if (in_array($k, array('BYSETPOS', 'BYDAY', 'BYMONTHDAY', 'BYMONTH', 'BYYEARDAY', 'BYWEEKNO'))) {
+ $rrules[$k] = explode(',', $v);
+ } else {
+ $rrules[$k] = $v;
+ }
+ }
+
+ $frequency = $rrules['FREQ'];
+
+ if (!is_string($frequency)) {
+ trigger_error('ICal::processRecurrences: Invalid frequency passed', E_USER_NOTICE);
+
+ continue;
+ }
+
+ // Reject RRULE if BYDAY stanza is invalid:
+ // > The BYDAY rule part MUST NOT be specified with a numeric value
+ // > when the FREQ rule part is not set to MONTHLY or YEARLY.
+ // > Furthermore, the BYDAY rule part MUST NOT be specified with a
+ // > numeric value with the FREQ rule part set to YEARLY when the
+ // > BYWEEKNO rule part is specified.
+ if (isset($rrules['BYDAY'])) {
+ $checkByDays = function ($carry, $weekday) {
+ return $carry && substr($weekday, -2) === $weekday;
+ };
+ if (!in_array($frequency, array('MONTHLY', 'YEARLY'))) {
+ if (is_array($rrules['BYDAY']) && !array_reduce($rrules['BYDAY'], $checkByDays, true)) {
+ trigger_error("ICal::processRecurrences: A {$frequency} RRULE may not contain BYDAY values with numeric prefixes", E_USER_NOTICE);
+
+ continue;
+ }
+ } elseif ($frequency === 'YEARLY' && (isset($rrules['BYWEEKNO']) && ($rrules['BYWEEKNO'] !== '' && $rrules['BYWEEKNO'] !== array()))) {
+ if (is_array($rrules['BYDAY']) && !array_reduce($rrules['BYDAY'], $checkByDays, true)) {
+ trigger_error('ICal::processRecurrences: A YEARLY RRULE with a BYWEEKNO part may not contain BYDAY values with numeric prefixes', E_USER_NOTICE);
+
+ continue;
+ }
+ }
+ }
+
+ $interval = (empty($rrules['INTERVAL'])) ? 1 : (int) $rrules['INTERVAL'];
+
+ // Throw an error if this isn't an integer.
+ if (!is_int($this->defaultSpan)) {
+ trigger_error('ICal::defaultSpan: User defined value is not an integer', E_USER_NOTICE);
+ }
+
+ // Compute EXDATEs
+ $exdates = $this->parseExdates($anEvent);
+
+ // Determine if the initial date is also an EXDATE
+ $initialDateIsExdate = array_reduce($exdates, function ($carry, $exdate) use ($initialEventDate) {
+ return $carry || $exdate->getTimestamp() === $initialEventDate->getTimestamp();
+ }, false);
+
+ if ($initialDateIsExdate) {
+ $eventKeysToRemove[] = $key;
+ }
+
+ /**
+ * Determine at what point we should stop calculating recurrences
+ * by looking at the UNTIL or COUNT rrule stanza, or, if neither
+ * if set, using a fallback.
+ *
+ * If the initial date is also an EXDATE, it shouldn't be included
+ * in the count.
+ *
+ * Syntax:
+ * UNTIL={enddate}
+ * COUNT=
+ *
+ * Where:
+ * enddate = ||
+ */
+ $count = 1;
+ $countLimit = (isset($rrules['COUNT'])) ? intval($rrules['COUNT']) : PHP_INT_MAX;
+ $now = date_create();
+
+ $until = $now === false
+ ? 0
+ : $now->modify("{$this->defaultSpan} years")->setTime(23, 59, 59)->getTimestamp();
+
+ $untilWhile = $until;
+
+ if (isset($rrules['UNTIL']) && is_string($rrules['UNTIL'])) {
+ $untilDT = $this->iCalDateToDateTime($rrules['UNTIL']);
+ $until = min($until, ($untilDT === false) ? $until : $untilDT->getTimestamp());
+
+ // There are certain edge cases where we need to go a little beyond the UNTIL to
+ // ensure we get all events. Consider:
+ //
+ // DTSTART:20200103
+ // RRULE:FREQ=MONTHLY;BYDAY=-5FR;UNTIL=20200502
+ //
+ // In this case the last occurrence should be 1st May, however when we transition
+ // from April to May:
+ //
+ // $until ~= 2nd May
+ // $frequencyRecurringDateTime ~= 3rd May
+ //
+ // And as the latter comes after the former, the while loop ends before any dates
+ // in May have the chance to be considered.
+ $untilWhile = min($untilWhile, ($untilDT === false) ? $untilWhile : $untilDT->modify("+1 {$this->frequencyConversion[$frequency]}")->getTimestamp());
+ }
+
+ $eventRecurrences = array();
+
+ $frequencyRecurringDateTime = clone $initialEventDate;
+ while ($frequencyRecurringDateTime->getTimestamp() <= $untilWhile && $count < $countLimit) {
+ $candidateDateTimes = array();
+
+ // phpcs:ignore Squiz.ControlStructures.SwitchDeclaration.MissingDefault
+ switch ($frequency) {
+ case 'DAILY':
+ if (isset($rrules['BYMONTHDAY']) && (is_array($rrules['BYMONTHDAY']) && $rrules['BYMONTHDAY'] !== array())) {
+ if (!isset($monthDays)) {
+ // This variable is unset when we change months (see below)
+ $monthDays = $this->getDaysOfMonthMatchingByMonthDayRRule($rrules['BYMONTHDAY'], $frequencyRecurringDateTime);
+ }
+
+ if (!in_array($frequencyRecurringDateTime->format('j'), $monthDays)) {
+ break;
+ }
+ }
+
+ $candidateDateTimes[] = clone $frequencyRecurringDateTime;
+
+ break;
+
+ case 'WEEKLY':
+ $initialDayOfWeek = $frequencyRecurringDateTime->format('N');
+ $matchingDays = array($initialDayOfWeek);
+
+ if (isset($rrules['BYDAY']) && (is_array($rrules['BYDAY']) && $rrules['BYDAY'] !== array())) {
+ // setISODate() below uses the ISO-8601 specification of weeks: start on
+ // a Monday, end on a Sunday. However, RRULEs (or the caller of the
+ // parser) may state an alternate WeeKSTart.
+ $wkstTransition = 7;
+
+ if (empty($rrules['WKST'])) {
+ if ($this->defaultWeekStart !== self::ISO_8601_WEEK_START) {
+ $wkstTransition = array_search($this->defaultWeekStart, array_keys($this->weekdays), true);
+ }
+ } elseif ($rrules['WKST'] !== self::ISO_8601_WEEK_START) {
+ $wkstTransition = array_search($rrules['WKST'], array_keys($this->weekdays), true);
+ }
+
+ $matchingDays = array_map(
+ function ($weekday) use ($initialDayOfWeek, $wkstTransition, $interval) {
+ $day = array_search($weekday, array_keys($this->weekdays), true);
+
+ if ($day < $initialDayOfWeek) {
+ $day += 7;
+ }
+
+ if ($day >= $wkstTransition) {
+ $day += 7 * ($interval - 1);
+ }
+
+ // Ignoring alternate week starts, $day at this point will have a
+ // value between 0 and 6. But setISODate() expects a value of 1 to 7.
+ // Even with alternate week starts, we still need to +1 to set the
+ // correct weekday.
+ $day++;
+
+ return $day;
+ },
+ $rrules['BYDAY']
+ );
+ }
+
+ sort($matchingDays);
+
+ foreach ($matchingDays as $day) {
+ $clonedDateTime = clone $frequencyRecurringDateTime;
+ $candidateDateTimes[] = $clonedDateTime->setISODate(
+ (int) $frequencyRecurringDateTime->format('o'),
+ (int) $frequencyRecurringDateTime->format('W'),
+ (int) $day
+ );
+ }
+ break;
+
+ case 'MONTHLY':
+ $matchingDays = array();
+
+ if (isset($rrules['BYMONTHDAY']) && (is_array($rrules['BYMONTHDAY']) && $rrules['BYMONTHDAY'] !== array())) {
+ $matchingDays = $this->getDaysOfMonthMatchingByMonthDayRRule($rrules['BYMONTHDAY'], $frequencyRecurringDateTime);
+ if (isset($rrules['BYDAY']) && (is_array($rrules['BYDAY']) && $rrules['BYDAY'] !== array())) {
+ $matchingDays = array_filter(
+ $this->getDaysOfMonthMatchingByDayRRule($rrules['BYDAY'], $frequencyRecurringDateTime),
+ function ($monthDay) use ($matchingDays) {
+ return in_array($monthDay, $matchingDays);
+ }
+ );
+ }
+ } elseif (isset($rrules['BYDAY']) && (is_array($rrules['BYDAY']) && $rrules['BYDAY'] !== array())) {
+ $matchingDays = $this->getDaysOfMonthMatchingByDayRRule($rrules['BYDAY'], $frequencyRecurringDateTime);
+ } else {
+ $matchingDays[] = $frequencyRecurringDateTime->format('d');
+ }
+
+ if (isset($rrules['BYSETPOS']) && (is_array($rrules['BYSETPOS']) && $rrules['BYSETPOS'] !== array())) {
+ $matchingDays = $this->filterValuesUsingBySetPosRRule($rrules['BYSETPOS'], $matchingDays);
+ }
+
+ foreach ($matchingDays as $day) {
+ // Skip invalid dates (e.g. 30th February)
+ if ($day > $frequencyRecurringDateTime->format('t')) {
+ continue;
+ }
+
+ $clonedDateTime = clone $frequencyRecurringDateTime;
+ $candidateDateTimes[] = $clonedDateTime->setDate(
+ (int) $frequencyRecurringDateTime->format('Y'),
+ (int) $frequencyRecurringDateTime->format('m'),
+ $day
+ );
+ }
+ break;
+
+ case 'YEARLY':
+ $matchingDays = array();
+
+ if (isset($rrules['BYMONTH']) && (is_array($rrules['BYMONTH']) && $rrules['BYMONTH'] !== array())) {
+ $bymonthRecurringDatetime = clone $frequencyRecurringDateTime;
+ foreach ($rrules['BYMONTH'] as $byMonth) {
+ $bymonthRecurringDatetime->setDate(
+ (int) $frequencyRecurringDateTime->format('Y'),
+ (int) $byMonth,
+ (int) $frequencyRecurringDateTime->format('d')
+ );
+
+ // Determine the days of the month affected
+ // (The interaction between BYMONTHDAY and BYDAY is resolved later.)
+ $monthDays = array();
+ if (isset($rrules['BYMONTHDAY']) && (is_array($rrules['BYMONTHDAY']) && $rrules['BYMONTHDAY'] !== array())) {
+ $monthDays = $this->getDaysOfMonthMatchingByMonthDayRRule($rrules['BYMONTHDAY'], $bymonthRecurringDatetime);
+ } elseif (isset($rrules['BYDAY']) && (is_array($rrules['BYDAY']) && $rrules['BYDAY'] !== array())) {
+ $monthDays = $this->getDaysOfMonthMatchingByDayRRule($rrules['BYDAY'], $bymonthRecurringDatetime);
+ } else {
+ $monthDays[] = $bymonthRecurringDatetime->format('d');
+ }
+
+ // And add each of them to the list of recurrences
+ foreach ($monthDays as $day) {
+ $matchingDays[] = $bymonthRecurringDatetime->setDate(
+ (int) $frequencyRecurringDateTime->format('Y'),
+ (int) $bymonthRecurringDatetime->format('m'),
+ $day
+ )->format('z') + 1;
+ }
+ }
+ } elseif (isset($rrules['BYWEEKNO']) && (is_array($rrules['BYWEEKNO']) && $rrules['BYWEEKNO'] !== array())) {
+ $matchingDays = $this->getDaysOfYearMatchingByWeekNoRRule($rrules['BYWEEKNO'], $frequencyRecurringDateTime);
+ } elseif (isset($rrules['BYYEARDAY']) && (is_array($rrules['BYYEARDAY']) && $rrules['BYYEARDAY'] !== array())) {
+ $matchingDays = $this->getDaysOfYearMatchingByYearDayRRule($rrules['BYYEARDAY'], $frequencyRecurringDateTime);
+ } elseif (isset($rrules['BYMONTHDAY']) && (is_array($rrules['BYMONTHDAY']) && $rrules['BYMONTHDAY'] !== array())) {
+ $matchingDays = $this->getDaysOfYearMatchingByMonthDayRRule($rrules['BYMONTHDAY'], $frequencyRecurringDateTime);
+ }
+
+ if (isset($rrules['BYDAY']) && (is_array($rrules['BYDAY']) && $rrules['BYDAY'] !== array())) {
+ if (isset($rrules['BYYEARDAY']) && ($rrules['BYYEARDAY'] !== '' && $rrules['BYYEARDAY'] !== array()) || isset($rrules['BYMONTHDAY']) && ($rrules['BYMONTHDAY'] !== '' && $rrules['BYMONTHDAY'] !== array()) || isset($rrules['BYWEEKNO']) && ($rrules['BYWEEKNO'] !== '' && $rrules['BYWEEKNO'] !== array())) {
+ $matchingDays = array_filter(
+ $this->getDaysOfYearMatchingByDayRRule($rrules['BYDAY'], $frequencyRecurringDateTime),
+ function ($yearDay) use ($matchingDays) {
+ return in_array($yearDay, $matchingDays);
+ }
+ );
+ } elseif ($matchingDays === array()) {
+ $matchingDays = $this->getDaysOfYearMatchingByDayRRule($rrules['BYDAY'], $frequencyRecurringDateTime);
+ }
+ }
+
+ if ($matchingDays === array()) {
+ $matchingDays = array($frequencyRecurringDateTime->format('z') + 1);
+ } else {
+ sort($matchingDays);
+ }
+
+ if (isset($rrules['BYSETPOS']) && (is_array($rrules['BYSETPOS']) && $rrules['BYSETPOS'] !== array())) {
+ $matchingDays = $this->filterValuesUsingBySetPosRRule($rrules['BYSETPOS'], $matchingDays);
+ }
+
+ foreach ($matchingDays as $day) {
+ $clonedDateTime = clone $frequencyRecurringDateTime;
+ $candidateDateTimes[] = $clonedDateTime->setDate(
+ (int) $frequencyRecurringDateTime->format('Y'),
+ 1,
+ $day
+ );
+ }
+ break;
+ }
+
+ foreach ($candidateDateTimes as $candidate) {
+ $timestamp = $candidate->getTimestamp();
+ if ($timestamp <= $initialEventDate->getTimestamp()) {
+ continue;
+ }
+
+ if ($timestamp > $until) {
+ break;
+ }
+
+ // Exclusions
+ $isExcluded = array_filter($exdates, function ($exdate) use ($timestamp) {
+ return $exdate->getTimestamp() === $timestamp;
+ });
+
+ if (isset($this->alteredRecurrenceInstances[$anEvent['UID']])) {
+ if (in_array($timestamp, $this->alteredRecurrenceInstances[$anEvent['UID']])) {
+ $isExcluded = true;
+ }
+ }
+
+ if (!$isExcluded) {
+ $eventRecurrences[] = $candidate;
+ $this->eventCount++;
+ }
+
+ // Count all evaluated candidates including excluded ones,
+ // and if RRULE[COUNT] (if set) is reached then break.
+ $count++;
+ if ($count >= $countLimit) {
+ break 2;
+ }
+ }
+
+ // Move forwards $interval $frequency.
+ $monthPreMove = $frequencyRecurringDateTime->format('m');
+ $frequencyRecurringDateTime->modify("{$interval} {$this->frequencyConversion[$frequency]}");
+
+ // As noted in Example #2 on https://www.php.net/manual/en/datetime.modify.php,
+ // there are some occasions where adding months doesn't give the month you might
+ // expect. For instance: January 31st + 1 month == March 3rd (March 2nd on a leap
+ // year.) The following code crudely rectifies this.
+ if ($frequency === 'MONTHLY') {
+ $monthDiff = $frequencyRecurringDateTime->format('m') - $monthPreMove;
+
+ if (($monthDiff > 0 && $monthDiff > $interval) || ($monthDiff < 0 && $monthDiff > $interval - 12)) {
+ $frequencyRecurringDateTime->modify('-1 month');
+ }
+ }
+
+ // $monthDays is set in the DAILY frequency if the BYMONTHDAY stanza is present in
+ // the RRULE. The variable only needs to be updated when we change months, so we
+ // unset it here, prompting a recreation next iteration.
+ if (isset($monthDays) && $frequencyRecurringDateTime->format('m') !== $monthPreMove) {
+ unset($monthDays);
+ }
+ }
+
+ unset($monthDays); // Unset it here as well, so it doesn't bleed into the calculation of the next recurring event.
+
+ // Determine event length
+ $eventLength = 0;
+ if (isset($anEvent['DURATION'])) {
+ $clonedDateTime = clone $initialEventDate;
+ $endDate = $clonedDateTime->add($anEvent['DURATION_array'][2]);
+ $eventLength = $endDate->getTimestamp() - $anEvent['DTSTART_array'][2];
+ } elseif (isset($anEvent['DTEND_array'])) {
+ $eventLength = $anEvent['DTEND_array'][2] - $anEvent['DTSTART_array'][2];
+ }
+
+ // Whether or not the initial date was UTC
+ $initialDateWasUTC = substr($anEvent['DTSTART'], -1) === 'Z';
+
+ // Build the param array
+ $dateParamArray = array();
+ if (
+ !$initialDateWasUTC
+ && isset($anEvent['DTSTART_array'][0]['TZID'])
+ && $this->isValidTimeZoneId($anEvent['DTSTART_array'][0]['TZID'])
+ ) {
+ $dateParamArray['TZID'] = $anEvent['DTSTART_array'][0]['TZID'];
+ }
+
+ // Populate the `DT{START|END}[_array]`s
+ $eventRecurrences = array_map(
+ function ($recurringDatetime) use ($anEvent, $eventLength, $initialDateWasUTC, $dateParamArray) {
+ $tzidPrefix = (isset($dateParamArray['TZID'])) ? 'TZID=' . $this->escapeParamText($dateParamArray['TZID']) . ':' : '';
+
+ foreach (array('DTSTART', 'DTEND') as $dtkey) {
+ $anEvent[$dtkey] = $recurringDatetime->format(self::DATE_TIME_FORMAT) . (($initialDateWasUTC) ? 'Z' : '');
+
+ $anEvent["{$dtkey}_array"] = array(
+ $dateParamArray, // [0] Array of params (incl. TZID)
+ $anEvent[$dtkey], // [1] ICalDateTime string w/o TZID
+ $recurringDatetime->getTimestamp(), // [2] Unix Timestamp
+ "{$tzidPrefix}{$anEvent[$dtkey]}", // [3] Full ICalDateTime string
+ );
+
+ if ($dtkey !== 'DTEND') {
+ $recurringDatetime->modify("{$eventLength} seconds");
+ }
+ }
+
+ return $anEvent;
+ },
+ $eventRecurrences
+ );
+
+ $allEventRecurrences = array_merge($allEventRecurrences, $eventRecurrences);
+ }
+
+ // Nullify the initial events that are also EXDATEs
+ foreach ($eventKeysToRemove as $eventKeyToRemove) {
+ $events[$eventKeyToRemove] = null;
+ }
+
+ $events = array_merge($events, $allEventRecurrences);
+
+ $this->cal['VEVENT'] = $events;
+ }
+
+ /**
+ * Resolves values from indices of the range 1 -> $limit.
+ *
+ * For instance, if passed [1, 4, -16] and 28, this will return [1, 4, 13].
+ *
+ * @param array $indexes
+ * @param integer $limit
+ * @return array
+ */
+ protected function resolveIndicesOfRange(array $indexes, $limit)
+ {
+ $matching = array();
+ foreach ($indexes as $index) {
+ if ($index > 0 && $index <= $limit) {
+ $matching[] = $index;
+ } elseif ($index < 0 && -$index <= $limit) {
+ $matching[] = $index + $limit + 1;
+ }
+ }
+
+ sort($matching);
+
+ return $matching;
+ }
+
+ /**
+ * Find all days of a month that match the BYDAY stanza of an RRULE.
+ *
+ * With no {ordwk}, then return the day number of every {weekday}
+ * within the month.
+ *
+ * With a +ve {ordwk}, then return the {ordwk} {weekday} within the
+ * month.
+ *
+ * With a -ve {ordwk}, then return the {ordwk}-to-last {weekday}
+ * within the month.
+ *
+ * RRule Syntax:
+ * BYDAY={bywdaylist}
+ *
+ * Where:
+ * bywdaylist = {weekdaynum}[,{weekdaynum}...]
+ * weekdaynum = [[+]{ordwk} || -{ordwk}]{weekday}
+ * ordwk = 1 to 53
+ * weekday = SU || MO || TU || WE || TH || FR || SA
+ *
+ * @param array $byDays
+ * @param \DateTime $initialDateTime
+ * @return array
+ */
+ protected function getDaysOfMonthMatchingByDayRRule(array $byDays, $initialDateTime)
+ {
+ $matchingDays = array();
+ $currentMonth = $initialDateTime->format('n');
+
+ foreach ($byDays as $weekday) {
+ $bydayDateTime = clone $initialDateTime;
+
+ $ordwk = intval(substr($weekday, 0, -2));
+
+ // Quantise the date to the first instance of the requested day in a month
+ // (Or last if we have a -ve {ordwk})
+ $bydayDateTime->modify(
+ (($ordwk < 0) ? 'Last' : 'First') .
+ ' ' .
+ $this->weekdays[substr($weekday, -2)] . // e.g. "Monday"
+ ' of ' .
+ $initialDateTime->format('F') // e.g. "June"
+ );
+
+ if ($ordwk < 0) { // -ve {ordwk}
+ $bydayDateTime->modify((++$ordwk) . ' week');
+ if ($bydayDateTime->format('n') === $currentMonth) {
+ $matchingDays[] = $bydayDateTime->format('j');
+ }
+ } elseif ($ordwk > 0) { // +ve {ordwk}
+ $bydayDateTime->modify((--$ordwk) . ' week');
+ if ($bydayDateTime->format('n') === $currentMonth) {
+ $matchingDays[] = $bydayDateTime->format('j');
+ }
+ } else { // No {ordwk}
+ while ($bydayDateTime->format('n') === $initialDateTime->format('n')) {
+ $matchingDays[] = $bydayDateTime->format('j');
+ $bydayDateTime->modify('+1 week');
+ }
+ }
+ }
+
+ // Sort into ascending order
+ sort($matchingDays);
+
+ return $matchingDays;
+ }
+
+ /**
+ * Find all days of a month that match the BYMONTHDAY stanza of an RRULE.
+ *
+ * RRUle Syntax:
+ * BYMONTHDAY={bymodaylist}
+ *
+ * Where:
+ * bymodaylist = {monthdaynum}[,{monthdaynum}...]
+ * monthdaynum = ([+] || -) {ordmoday}
+ * ordmoday = 1 to 31
+ *
+ * @param array $byMonthDays
+ * @param \DateTime $initialDateTime
+ * @return array
+ */
+ protected function getDaysOfMonthMatchingByMonthDayRRule(array $byMonthDays, $initialDateTime)
+ {
+ return $this->resolveIndicesOfRange($byMonthDays, (int) $initialDateTime->format('t'));
+ }
+
+ /**
+ * Find all days of a year that match the BYDAY stanza of an RRULE.
+ *
+ * With no {ordwk}, then return the day number of every {weekday}
+ * within the year.
+ *
+ * With a +ve {ordwk}, then return the {ordwk} {weekday} within the
+ * year.
+ *
+ * With a -ve {ordwk}, then return the {ordwk}-to-last {weekday}
+ * within the year.
+ *
+ * RRule Syntax:
+ * BYDAY={bywdaylist}
+ *
+ * Where:
+ * bywdaylist = {weekdaynum}[,{weekdaynum}...]
+ * weekdaynum = [[+]{ordwk} || -{ordwk}]{weekday}
+ * ordwk = 1 to 53
+ * weekday = SU || MO || TU || WE || TH || FR || SA
+ *
+ * @param array $byDays
+ * @param \DateTime $initialDateTime
+ * @return array
+ */
+ protected function getDaysOfYearMatchingByDayRRule(array $byDays, $initialDateTime)
+ {
+ $matchingDays = array();
+
+ foreach ($byDays as $weekday) {
+ $bydayDateTime = clone $initialDateTime;
+
+ $ordwk = intval(substr($weekday, 0, -2));
+
+ // Quantise the date to the first instance of the requested day in a year
+ // (Or last if we have a -ve {ordwk})
+ $bydayDateTime->modify(
+ (($ordwk < 0) ? 'Last' : 'First') .
+ ' ' .
+ $this->weekdays[substr($weekday, -2)] . // e.g. "Monday"
+ ' of ' . (($ordwk < 0) ? 'December' : 'January') .
+ ' ' . $initialDateTime->format('Y') // e.g. "2018"
+ );
+
+ if ($ordwk < 0) { // -ve {ordwk}
+ $bydayDateTime->modify((++$ordwk) . ' week');
+ $matchingDays[] = $bydayDateTime->format('z') + 1;
+ } elseif ($ordwk > 0) { // +ve {ordwk}
+ $bydayDateTime->modify((--$ordwk) . ' week');
+ $matchingDays[] = $bydayDateTime->format('z') + 1;
+ } else { // No {ordwk}
+ while ($bydayDateTime->format('Y') === $initialDateTime->format('Y')) {
+ $matchingDays[] = $bydayDateTime->format('z') + 1;
+ $bydayDateTime->modify('+1 week');
+ }
+ }
+ }
+
+ // Sort into ascending order
+ sort($matchingDays);
+
+ return $matchingDays;
+ }
+
+ /**
+ * Find all days of a year that match the BYYEARDAY stanza of an RRULE.
+ *
+ * RRUle Syntax:
+ * BYYEARDAY={byyrdaylist}
+ *
+ * Where:
+ * byyrdaylist = {yeardaynum}[,{yeardaynum}...]
+ * yeardaynum = ([+] || -) {ordyrday}
+ * ordyrday = 1 to 366
+ *
+ * @param array $byYearDays
+ * @param \DateTime $initialDateTime
+ * @return array
+ */
+ protected function getDaysOfYearMatchingByYearDayRRule(array $byYearDays, $initialDateTime)
+ {
+ // `\DateTime::format('L')` returns 1 if leap year, 0 if not.
+ $daysInThisYear = $initialDateTime->format('L') ? 366 : 365;
+
+ return $this->resolveIndicesOfRange($byYearDays, $daysInThisYear);
+ }
+
+ /**
+ * Find all days of a year that match the BYWEEKNO stanza of an RRULE.
+ *
+ * Unfortunately, the RFC5545 specification does not specify exactly
+ * how BYWEEKNO should expand on the initial DTSTART when provided
+ * without any other stanzas.
+ *
+ * A comparison of expansions used by other ics parsers may be found
+ * at https://github.com/s0600204/ics-parser-1/wiki/byweekno
+ *
+ * This method uses the same expansion as the python-dateutil module.
+ *
+ * RRUle Syntax:
+ * BYWEEKNO={bywknolist}
+ *
+ * Where:
+ * bywknolist = {weeknum}[,{weeknum}...]
+ * weeknum = ([+] || -) {ordwk}
+ * ordwk = 1 to 53
+ *
+ * @param array $byWeekNums
+ * @param \DateTime $initialDateTime
+ * @return array
+ */
+ protected function getDaysOfYearMatchingByWeekNoRRule(array $byWeekNums, $initialDateTime)
+ {
+ // `\DateTime::format('L')` returns 1 if leap year, 0 if not.
+ $isLeapYear = $initialDateTime->format('L');
+ $initialYear = date_create("first day of January {$initialDateTime->format('Y')}");
+ $firstDayOfTheYear = ($initialYear === false) ? null : $initialYear->format('D');
+ $weeksInThisYear = ($firstDayOfTheYear === 'Thu' || $isLeapYear && $firstDayOfTheYear === 'Wed') ? 53 : 52;
+
+ $matchingWeeks = $this->resolveIndicesOfRange($byWeekNums, $weeksInThisYear);
+ $matchingDays = array();
+ $byweekDateTime = clone $initialDateTime;
+ foreach ($matchingWeeks as $weekNum) {
+ $dayNum = $byweekDateTime->setISODate(
+ (int) $initialDateTime->format('Y'),
+ $weekNum,
+ 1
+ )->format('z') + 1;
+ for ($x = 0; $x < 7; ++$x) {
+ $matchingDays[] = $x + $dayNum;
+ }
+ }
+
+ sort($matchingDays);
+
+ return $matchingDays;
+ }
+
+ /**
+ * Find all days of a year that match the BYMONTHDAY stanza of an RRULE.
+ *
+ * RRule Syntax:
+ * BYMONTHDAY={bymodaylist}
+ *
+ * Where:
+ * bymodaylist = {monthdaynum}[,{monthdaynum}...]
+ * monthdaynum = ([+] || -) {ordmoday}
+ * ordmoday = 1 to 31
+ *
+ * @param array $byMonthDays
+ * @param \DateTime $initialDateTime
+ * @return array
+ */
+ protected function getDaysOfYearMatchingByMonthDayRRule(array $byMonthDays, $initialDateTime)
+ {
+ $matchingDays = array();
+ $monthDateTime = clone $initialDateTime;
+ for ($month = 1; $month < 13; $month++) {
+ $monthDateTime->setDate(
+ (int) $initialDateTime->format('Y'),
+ $month,
+ 1
+ );
+
+ $monthDays = $this->getDaysOfMonthMatchingByMonthDayRRule($byMonthDays, $monthDateTime);
+ foreach ($monthDays as $day) {
+ $matchingDays[] = $monthDateTime->setDate(
+ (int) $initialDateTime->format('Y'),
+ (int) $monthDateTime->format('m'),
+ $day
+ )->format('z') + 1;
+ }
+ }
+
+ return $matchingDays;
+ }
+
+ /**
+ * Filters a provided values-list by applying a BYSETPOS RRule.
+ *
+ * Where a +ve {daynum} is provided, the {ordday} position'd value as
+ * measured from the start of the list of values should be retained.
+ *
+ * Where a -ve {daynum} is provided, the {ordday} position'd value as
+ * measured from the end of the list of values should be retained.
+ *
+ * RRule Syntax:
+ * BYSETPOS={bysplist}
+ *
+ * Where:
+ * bysplist = {setposday}[,{setposday}...]
+ * setposday = {daynum}
+ * daynum = [+ || -] {ordday}
+ * ordday = 1 to 366
+ *
+ * @param array $bySetPos
+ * @param array $valuesList
+ * @return array
+ */
+ protected function filterValuesUsingBySetPosRRule(array $bySetPos, array $valuesList)
+ {
+ $filteredMatches = array();
+
+ foreach ($bySetPos as $setPosition) {
+ if ($setPosition < 0) {
+ $setPosition = count($valuesList) + ++$setPosition;
+ }
+
+ // Positioning starts at 1, array indexes start at 0
+ if (isset($valuesList[$setPosition - 1])) {
+ $filteredMatches[] = $valuesList[$setPosition - 1];
+ }
+ }
+
+ return $filteredMatches;
+ }
+
+ /**
+ * Processes date conversions using the time zone
+ *
+ * Add keys `DTSTART_tz` and `DTEND_tz` to each Event
+ * These keys contain dates adapted to the calendar
+ * time zone depending on the event `TZID`.
+ *
+ * @return void
+ * @throws \Exception
+ */
+ protected function processDateConversions()
+ {
+ $events = (isset($this->cal['VEVENT'])) ? $this->cal['VEVENT'] : array();
+
+ if ($events !== array()) {
+ foreach ($events as $key => $anEvent) {
+ if (is_null($anEvent) || !$this->isValidDate($anEvent['DTSTART'])) {
+ unset($events[$key]);
+ $this->eventCount--;
+
+ continue;
+ }
+
+ $events[$key]['DTSTART_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DTSTART');
+
+ if ($this->iCalDateWithTimeZone($anEvent, 'DTEND')) {
+ $events[$key]['DTEND_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DTEND');
+ } elseif ($this->iCalDateWithTimeZone($anEvent, 'DURATION')) {
+ $events[$key]['DTEND_tz'] = $this->iCalDateWithTimeZone($anEvent, 'DURATION');
+ } else {
+ $events[$key]['DTEND_tz'] = $events[$key]['DTSTART_tz'];
+ }
+ }
+
+ $this->cal['VEVENT'] = $events;
+ }
+ }
+
+ /**
+ * Returns an array of Events.
+ * Every event is a class with the event
+ * details being properties within it.
+ *
+ * @return array
+ */
+ public function events()
+ {
+ $array = $this->cal;
+ $array = isset($array['VEVENT']) ? $array['VEVENT'] : array();
+
+ $events = array();
+
+ foreach ($array as $event) {
+ $events[] = new Event($event);
+ }
+
+ return $events;
+ }
+
+ /**
+ * Returns the calendar name
+ *
+ * @return string
+ */
+ public function calendarName()
+ {
+ return isset($this->cal['VCALENDAR']['X-WR-CALNAME']) ? $this->cal['VCALENDAR']['X-WR-CALNAME'] : '';
+ }
+
+ /**
+ * Returns the calendar description
+ *
+ * @return string
+ */
+ public function calendarDescription()
+ {
+ return isset($this->cal['VCALENDAR']['X-WR-CALDESC']) ? $this->cal['VCALENDAR']['X-WR-CALDESC'] : '';
+ }
+
+ /**
+ * Returns the calendar time zone
+ *
+ * @param boolean $ignoreUtc
+ * @return string|null
+ */
+ public function calendarTimeZone($ignoreUtc = false)
+ {
+ if (isset($this->cal['VCALENDAR']['X-WR-TIMEZONE'])) {
+ $timeZone = $this->cal['VCALENDAR']['X-WR-TIMEZONE'];
+ } elseif (isset($this->cal['VTIMEZONE']['TZID'])) {
+ $timeZone = $this->cal['VTIMEZONE']['TZID'];
+ } else {
+ $timeZone = $this->defaultTimeZone;
+ }
+
+ // Validate the time zone, falling back to the time zone set in the PHP environment.
+ $timeZone = $this->timeZoneStringToDateTimeZone($timeZone)->getName();
+
+ if ($ignoreUtc && strtoupper($timeZone) === self::TIME_ZONE_UTC) {
+ return null;
+ }
+
+ return $timeZone;
+ }
+
+ /**
+ * Returns an array of arrays with all free/busy events.
+ * Every event is an associative array and each property
+ * is an element it.
+ *
+ * @return array
+ */
+ public function freeBusyEvents()
+ {
+ $array = $this->cal;
+
+ return isset($array['VFREEBUSY']) ? $array['VFREEBUSY'] : array();
+ }
+
+ /**
+ * Returns a boolean value whether the
+ * current calendar has events or not
+ *
+ * @return boolean
+ */
+ public function hasEvents()
+ {
+ return ($this->events() !== array()) ?: false;
+ }
+
+ /**
+ * Returns a sorted array of the events in a given range,
+ * or an empty array if no events exist in the range.
+ *
+ * Events will be returned if the start or end date is contained within the
+ * range (inclusive), or if the event starts before and end after the range.
+ *
+ * If a start date is not specified or of a valid format, then the start
+ * of the range will default to the current time and date of the server.
+ *
+ * If an end date is not specified or of a valid format, then the end of
+ * the range will default to the current time and date of the server,
+ * plus 20 years.
+ *
+ * Note that this function makes use of Unix timestamps. This might be a
+ * problem for events on, during, or after 29 Jan 2038.
+ * See https://en.wikipedia.org/wiki/Unix_time#Representing_the_number
+ *
+ * @param string|null $rangeStart
+ * @param string|null $rangeEnd
+ * @return array
+ * @throws \Exception
+ */
+ public function eventsFromRange($rangeStart = null, $rangeEnd = null)
+ {
+ // Sort events before processing range
+ $events = $this->sortEventsWithOrder($this->events());
+
+ if ($events === array()) {
+ return array();
+ }
+
+ $extendedEvents = array();
+
+ if (!is_null($rangeStart)) {
+ try {
+ $rangeStart = new \DateTime($rangeStart, new \DateTimeZone($this->getDefaultTimeZone()));
+ } catch (\Exception $exception) {
+ error_log("ICal::eventsFromRange: Invalid date passed ({$rangeStart})");
+ $rangeStart = false;
+ }
+ } else {
+ $rangeStart = new \DateTime('now', new \DateTimeZone($this->getDefaultTimeZone()));
+ }
+
+ if (!is_null($rangeEnd)) {
+ try {
+ $rangeEnd = new \DateTime($rangeEnd, new \DateTimeZone($this->getDefaultTimeZone()));
+ } catch (\Exception $exception) {
+ error_log("ICal::eventsFromRange: Invalid date passed ({$rangeEnd})");
+ $rangeEnd = false;
+ }
+ } else {
+ $rangeEnd = new \DateTime('now', new \DateTimeZone($this->getDefaultTimeZone()));
+ $rangeEnd->modify('+20 years');
+ }
+
+ if ($rangeEnd !== false && $rangeStart !== false) {
+ // If start and end are identical and are dates with no times...
+ if ($rangeEnd->format('His') == 0 && $rangeStart->getTimestamp() === $rangeEnd->getTimestamp()) {
+ $rangeEnd->modify('+1 day');
+ }
+
+ $rangeStart = $rangeStart->getTimestamp();
+ $rangeEnd = $rangeEnd->getTimestamp();
+ }
+
+ foreach ($events as $anEvent) {
+ $eventStart = $anEvent->dtstart_array[2];
+ $eventEnd = (isset($anEvent->dtend_array[2])) ? $anEvent->dtend_array[2] : null;
+
+ if (
+ ($eventStart >= $rangeStart && $eventStart < $rangeEnd) // Event start date contained in the range
+ || (
+ $eventEnd !== null
+ && (
+ ($eventEnd > $rangeStart && $eventEnd <= $rangeEnd) // Event end date contained in the range
+ || ($eventStart < $rangeStart && $eventEnd > $rangeEnd) // Event starts before and finishes after range
+ )
+ )
+ ) {
+ $extendedEvents[] = $anEvent;
+ }
+ }
+
+ return $extendedEvents;
+ }
+
+ /**
+ * Returns a sorted array of the events following a given string
+ *
+ * @param string $interval
+ * @return array
+ */
+ public function eventsFromInterval($interval)
+ {
+ $timeZone = $this->getDefaultTimeZone();
+ $rangeStart = new \DateTime('now', new \DateTimeZone($timeZone));
+ $rangeEnd = new \DateTime('now', new \DateTimeZone($timeZone));
+
+ $dateInterval = \DateInterval::createFromDateString($interval);
+
+ if ($dateInterval instanceof \DateInterval) {
+ $rangeEnd->add($dateInterval);
+ }
+
+ return $this->eventsFromRange($rangeStart->format('Y-m-d'), $rangeEnd->format('Y-m-d'));
+ }
+
+ /**
+ * Sorts events based on a given sort order
+ *
+ * @param array $events
+ * @param integer $sortOrder Either SORT_ASC, SORT_DESC, SORT_REGULAR, SORT_NUMERIC, SORT_STRING
+ * @return array
+ */
+ public function sortEventsWithOrder(array $events, $sortOrder = SORT_ASC)
+ {
+ $extendedEvents = array();
+ $timestamp = array();
+
+ foreach ($events as $key => $anEvent) {
+ $extendedEvents[] = $anEvent;
+ $timestamp[$key] = $anEvent->dtstart_array[2];
+ }
+
+ array_multisort($timestamp, $sortOrder, $extendedEvents);
+
+ return $extendedEvents;
+ }
+
+ /**
+ * Checks if a time zone is valid (IANA, CLDR, or Windows)
+ *
+ * @param string $timeZone
+ * @return boolean
+ */
+ protected function isValidTimeZoneId($timeZone)
+ {
+ return $this->isValidIanaTimeZoneId($timeZone) !== false
+ || $this->isValidCldrTimeZoneId($timeZone) !== false
+ || $this->isValidWindowsTimeZoneId($timeZone) !== false;
+ }
+
+ /**
+ * Checks if a time zone is a valid IANA time zone
+ *
+ * @param string $timeZone
+ * @return boolean
+ */
+ protected function isValidIanaTimeZoneId($timeZone)
+ {
+ if (in_array($timeZone, $this->validIanaTimeZones)) {
+ return true;
+ }
+
+ $valid = array();
+ $tza = timezone_abbreviations_list();
+
+ foreach ($tza as $zone) {
+ foreach ($zone as $item) {
+ $valid[$item['timezone_id']] = true;
+ }
+ }
+
+ unset($valid['']);
+
+ if (isset($valid[$timeZone]) || in_array($timeZone, timezone_identifiers_list(\DateTimeZone::ALL_WITH_BC))) {
+ $this->validIanaTimeZones[] = $timeZone;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks if a time zone is a valid CLDR time zone
+ *
+ * @param string $timeZone
+ * @return boolean
+ */
+ public function isValidCldrTimeZoneId($timeZone)
+ {
+ return array_key_exists(html_entity_decode($timeZone), self::$cldrTimeZonesMap);
+ }
+
+ /**
+ * Checks if a time zone is a recognised Windows (non-CLDR) time zone
+ *
+ * @param string $timeZone
+ * @return boolean
+ */
+ public function isValidWindowsTimeZoneId($timeZone)
+ {
+ return array_key_exists(html_entity_decode($timeZone), self::$windowsTimeZonesMap);
+ }
+
+ /**
+ * Parses a duration and applies it to a date
+ *
+ * @param string $date
+ * @param \DateInterval $duration
+ * @return \DateTime|false
+ */
+ protected function parseDuration($date, $duration)
+ {
+ $dateTime = date_create($date);
+
+ if ($dateTime === false) {
+ return false;
+ }
+
+ $dateTime->modify("{$duration->y} year");
+ $dateTime->modify("{$duration->m} month");
+ $dateTime->modify("{$duration->d} day");
+ $dateTime->modify("{$duration->h} hour");
+ $dateTime->modify("{$duration->i} minute");
+ $dateTime->modify("{$duration->s} second");
+
+ return $dateTime;
+ }
+
+ /**
+ * Removes unprintable ASCII and UTF-8 characters
+ *
+ * @param string $data
+ * @return string|null
+ */
+ protected function removeUnprintableChars($data)
+ {
+ return preg_replace('/[\x00-\x1F\x7F]/u', '', $data);
+ }
+
+ /**
+ * Provides a polyfill for PHP 7.2's `mb_chr()`, which is a multibyte safe version of `chr()`.
+ * Multibyte safe.
+ *
+ * @param integer $code
+ * @return string
+ */
+ protected function mb_chr($code) // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
+ {
+ if (function_exists('mb_chr')) {
+ return mb_chr($code);
+ } else {
+ if (($code %= 0x200000) < 0x80) {
+ $s = chr($code);
+ } elseif ($code < 0x800) {
+ $s = chr(0xc0 | $code >> 6) . chr(0x80 | $code & 0x3f);
+ } elseif ($code < 0x10000) {
+ $s = chr(0xe0 | $code >> 12) . chr(0x80 | $code >> 6 & 0x3f) . chr(0x80 | $code & 0x3f);
+ } else {
+ $s = chr(0xf0 | $code >> 18) . chr(0x80 | $code >> 12 & 0x3f) . chr(0x80 | $code >> 6 & 0x3f) . chr(0x80 | $code & 0x3f);
+ }
+
+ return $s;
+ }
+ }
+
+ /**
+ * Places double-quotes around texts that have characters not permitted
+ * in parameter-texts, but are permitted in quoted-texts.
+ *
+ * @param string $candidateText
+ * @return string
+ */
+ protected function escapeParamText($candidateText)
+ {
+ if (strpbrk($candidateText, ':;,') !== false) {
+ return '"' . $candidateText . '"';
+ }
+
+ return $candidateText;
+ }
+
+ /**
+ * Replace curly quotes and other special characters with their standard equivalents
+ * @see https://utf8-chartable.de/unicode-utf8-table.pl?start=8211&utf8=string-literal
+ *
+ * @param string $input
+ * @return string
+ */
+ protected function cleanCharacters($input)
+ {
+ return strtr(
+ $input,
+ array(
+ "\xe2\x80\x98" => "'", // ‘
+ "\xe2\x80\x99" => "'", // ’
+ "\xe2\x80\x9a" => "'", // ‚
+ "\xe2\x80\x9b" => "'", // ‛
+ "\xe2\x80\x9c" => '"', // “
+ "\xe2\x80\x9d" => '"', // ”
+ "\xe2\x80\x9e" => '"', // „
+ "\xe2\x80\x9f" => '"', // ‟
+ "\xe2\x80\x93" => '-', // –
+ "\xe2\x80\x94" => '--', // —
+ "\xe2\x80\xa6" => '...', // …
+ $this->mb_chr(145) => "'", // ‘
+ $this->mb_chr(146) => "'", // ’
+ $this->mb_chr(147) => '"', // “
+ $this->mb_chr(148) => '"', // ”
+ $this->mb_chr(150) => '-', // –
+ $this->mb_chr(151) => '--', // —
+ $this->mb_chr(133) => '...', // …
+ )
+ );
+ }
+
+ /**
+ * Parses a list of excluded dates
+ * to be applied to an Event
+ *
+ * @param array $event
+ * @return array
+ */
+ public function parseExdates(array $event)
+ {
+ if (empty($event['EXDATE_array'])) {
+ return array();
+ } else {
+ $exdates = $event['EXDATE_array'];
+ }
+
+ $output = array();
+ $currentTimeZone = new \DateTimeZone($this->getDefaultTimeZone());
+
+ foreach ($exdates as $subArray) {
+ end($subArray);
+ $finalKey = key($subArray);
+
+ foreach (array_keys($subArray) as $key) {
+ if ($key === 'TZID') {
+ $currentTimeZone = $this->timeZoneStringToDateTimeZone($subArray[$key]);
+ } elseif (is_numeric($key)) {
+ $icalDate = $subArray[$key];
+
+ if (substr($icalDate, -1) === 'Z') {
+ $currentTimeZone = new \DateTimeZone(self::TIME_ZONE_UTC);
+ }
+
+ $output[] = new \DateTime($icalDate, $currentTimeZone);
+
+ if ($key === $finalKey) {
+ // Reset to default
+ $currentTimeZone = new \DateTimeZone($this->getDefaultTimeZone());
+ }
+ }
+ }
+ }
+
+ return $output;
+ }
+
+ /**
+ * Checks if a date string is a valid date
+ *
+ * @param string $value
+ * @return boolean
+ * @throws \Exception
+ */
+ public function isValidDate($value)
+ {
+ if (!$value) {
+ return false;
+ }
+
+ try {
+ new \DateTime($value);
+
+ return true;
+ } catch (\Exception $exception) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if a filename exists as a file or URL
+ *
+ * @param string $filename
+ * @return boolean
+ */
+ protected function isFileOrUrl($filename)
+ {
+ return (file_exists($filename) || filter_var($filename, FILTER_VALIDATE_URL)) ?: false;
+ }
+
+ /**
+ * Reads an entire file or URL into an array
+ *
+ * @param string $filename
+ * @return array
+ * @throws \Exception
+ */
+ protected function fileOrUrl($filename)
+ {
+ $options = array();
+ $options['http'] = array();
+ $options['http']['header'] = array();
+
+ if ($this->httpBasicAuth !== array() || !empty($this->httpUserAgent) || !empty($this->httpAcceptLanguage)) {
+ if ($this->httpBasicAuth !== array()) {
+ $username = $this->httpBasicAuth['username'];
+ $password = $this->httpBasicAuth['password'];
+ $basicAuth = base64_encode("{$username}:{$password}");
+
+ $options['http']['header'][] = "Authorization: Basic {$basicAuth}";
+ }
+
+ if (!empty($this->httpUserAgent)) {
+ $options['http']['header'][] = "User-Agent: {$this->httpUserAgent}";
+ }
+
+ if (!empty($this->httpAcceptLanguage)) {
+ $options['http']['header'][] = "Accept-language: {$this->httpAcceptLanguage}";
+ }
+ }
+
+ if (empty($this->httpUserAgent)) {
+ if (mb_stripos($filename, 'outlook.office365.com') !== false) {
+ $options['http']['header'][] = 'User-Agent: A User Agent';
+ }
+ }
+
+ if (!empty($this->httpProtocolVersion)) {
+ $options['http']['protocol_version'] = $this->httpProtocolVersion;
+ } else {
+ $options['http']['protocol_version'] = '1.1';
+ }
+
+ $options['http']['header'][] = 'Connection: close';
+
+ $context = stream_context_create($options);
+
+ // phpcs:ignore CustomPHPCS.ControlStructures.AssignmentInCondition
+ if (($lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES, $context)) === false) {
+ throw new \Exception("The file path or URL '{$filename}' does not exist.");
+ }
+
+ return $lines;
+ }
+
+ /**
+ * Returns a `DateTimeZone` object based on a string containing a time zone name.
+ * Falls back to the default time zone if string passed not a recognised time zone.
+ *
+ * @param string $timeZoneString
+ * @return \DateTimeZone
+ */
+ public function timeZoneStringToDateTimeZone($timeZoneString)
+ {
+ // Some time zones contain characters that are not permitted in param-texts,
+ // but are within quoted texts. We need to remove the quotes as they're not
+ // actually part of the time zone.
+ $timeZoneString = trim($timeZoneString, '"');
+ $timeZoneString = html_entity_decode($timeZoneString);
+
+ if ($this->isValidIanaTimeZoneId($timeZoneString)) {
+ return new \DateTimeZone($timeZoneString);
+ }
+
+ if ($this->isValidCldrTimeZoneId($timeZoneString)) {
+ return new \DateTimeZone(self::$cldrTimeZonesMap[$timeZoneString]);
+ }
+
+ if ($this->isValidWindowsTimeZoneId($timeZoneString)) {
+ return new \DateTimeZone(self::$windowsTimeZonesMap[$timeZoneString]);
+ }
+
+ return new \DateTimeZone($this->getDefaultTimeZone());
+ }
+}
diff --git a/lib/composer/vendor/johngrogg/ics-parser/tests/CleanCharacterTest.php b/lib/composer/vendor/johngrogg/ics-parser/tests/CleanCharacterTest.php
new file mode 100644
index 0000000..31ee582
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/tests/CleanCharacterTest.php
@@ -0,0 +1,53 @@
+getMethod($name);
+
+ // < PHP 8.1.0
+ $method->setAccessible(true);
+
+ return $method;
+ }
+
+ public function testCleanCharactersWithUnicodeCharacters()
+ {
+ $ical = new ICal();
+
+ self::assertSame(
+ '...',
+ self::getMethod('cleanCharacters')->invokeArgs($ical, array("\xe2\x80\xa6"))
+ );
+ }
+
+ public function testCleanCharactersWithEmojis()
+ {
+ $ical = new ICal();
+ $input = 'Test with emoji 🔴👍🏻';
+
+ self::assertSame(
+ $input,
+ self::getMethod('cleanCharacters')->invokeArgs($ical, array($input))
+ );
+ }
+
+ public function testCleanCharactersWithWindowsCharacters()
+ {
+ $ical = new ICal();
+ $input = self::getMethod('mb_chr')->invokeArgs($ical, array(133));
+
+ self::assertSame(
+ '...',
+ self::getMethod('cleanCharacters')->invokeArgs($ical, array($input))
+ );
+ }
+}
diff --git a/lib/composer/vendor/johngrogg/ics-parser/tests/DynamicPropertiesTest.php b/lib/composer/vendor/johngrogg/ics-parser/tests/DynamicPropertiesTest.php
new file mode 100644
index 0000000..c683642
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/tests/DynamicPropertiesTest.php
@@ -0,0 +1,24 @@
+events() as $event) {
+ $this->assertTrue(isset($event->dtstart_array));
+ $this->assertTrue(isset($event->dtend_array));
+ $this->assertTrue(isset($event->dtstamp_array));
+ $this->assertTrue(isset($event->uid_array));
+ $this->assertTrue(isset($event->created_array));
+ $this->assertTrue(isset($event->last_modified_array));
+ $this->assertTrue(isset($event->summary_array));
+ }
+ }
+}
diff --git a/lib/composer/vendor/johngrogg/ics-parser/tests/KeyValueTest.php b/lib/composer/vendor/johngrogg/ics-parser/tests/KeyValueTest.php
new file mode 100644
index 0000000..6bbbe6e
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/tests/KeyValueTest.php
@@ -0,0 +1,86 @@
+ 'ATTENDEE',
+ 1 => array(
+ 0 => 'mailto:julien@ag.com',
+ 1 => array(
+ 'PARTSTAT' => 'TENTATIVE',
+ 'CN' => 'ju: @ag.com = Ju ; ',
+ ),
+ ),
+ );
+
+ $this->assertLines(
+ 'ATTENDEE;PARTSTAT=TENTATIVE;CN="ju: @ag.com = Ju ; ":mailto:julien@ag.com',
+ $checks
+ );
+ }
+
+ public function testUtf8Characters()
+ {
+ $checks = array(
+ 0 => 'ATTENDEE',
+ 1 => array(
+ 0 => 'mailto:juëǯ@ag.com',
+ 1 => array(
+ 'PARTSTAT' => 'TENTATIVE',
+ 'CN' => 'juëǯĻ',
+ ),
+ ),
+ );
+
+ $this->assertLines(
+ 'ATTENDEE;PARTSTAT=TENTATIVE;CN=juëǯĻ:mailto:juëǯ@ag.com',
+ $checks
+ );
+
+ $checks = array(
+ 0 => 'SUMMARY',
+ 1 => ' I love emojis 😀😁😁 ë, ǯ, Ļ',
+ );
+
+ $this->assertLines(
+ 'SUMMARY: I love emojis 😀😁😁 ë, ǯ, Ļ',
+ $checks
+ );
+ }
+
+ public function testParametersOfKeysWithMultipleValues()
+ {
+ $checks = array(
+ 0 => 'ATTENDEE',
+ 1 => array(
+ 0 => 'mailto:jsmith@example.com',
+ 1 => array(
+ 'DELEGATED-TO' => array(
+ 0 => 'mailto:jdoe@example.com',
+ 1 => 'mailto:jqpublic@example.com',
+ ),
+ ),
+ ),
+ );
+
+ $this->assertLines(
+ 'ATTENDEE;DELEGATED-TO="mailto:jdoe@example.com","mailto:jqpublic@example.com":mailto:jsmith@example.com',
+ $checks
+ );
+ }
+
+ private function assertLines($lines, array $checks)
+ {
+ $ical = new ICal();
+
+ self::assertSame($ical->keyValueFromString($lines), $checks);
+ }
+}
diff --git a/lib/composer/vendor/johngrogg/ics-parser/tests/RecurrencesTest.php b/lib/composer/vendor/johngrogg/ics-parser/tests/RecurrencesTest.php
new file mode 100644
index 0000000..add13eb
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/tests/RecurrencesTest.php
@@ -0,0 +1,580 @@
+originalTimeZone = date_default_timezone_get();
+ }
+
+ /**
+ * @after
+ */
+ public function tearDownFixtures()
+ {
+ date_default_timezone_set($this->originalTimeZone);
+ }
+
+ public function testYearlyFullDayTimeZoneBerlin()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20000301', 'message' => '1st event, CET: '),
+ array('index' => 1, 'dateString' => '20010301T000000', 'message' => '2nd event, CET: '),
+ array('index' => 2, 'dateString' => '20020301T000000', 'message' => '3rd event, CET: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART;VALUE=DATE:20000301',
+ 'DTEND;VALUE=DATE:20000302',
+ 'RRULE:FREQ=YEARLY;WKST=SU;COUNT=3',
+ ),
+ 3,
+ $checks
+ );
+ }
+
+ public function testMonthlyFullDayTimeZoneBerlin()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20000301', 'message' => '1st event, CET: '),
+ array('index' => 1, 'dateString' => '20000401T000000', 'message' => '2nd event, CEST: '),
+ array('index' => 2, 'dateString' => '20000501T000000', 'message' => '3rd event, CEST: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART;VALUE=DATE:20000301',
+ 'DTEND;VALUE=DATE:20000302',
+ 'RRULE:FREQ=MONTHLY;BYMONTHDAY=1;WKST=SU;COUNT=3',
+ ),
+ 3,
+ $checks
+ );
+ }
+
+ public function testMonthlyFullDayTimeZoneBerlinSummerTime()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20180701', 'message' => '1st event, CEST: '),
+ array('index' => 1, 'dateString' => '20180801T000000', 'message' => '2nd event, CEST: '),
+ array('index' => 2, 'dateString' => '20180901T000000', 'message' => '3rd event, CEST: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART;VALUE=DATE:20180701',
+ 'DTEND;VALUE=DATE:20180702',
+ 'RRULE:FREQ=MONTHLY;WKST=SU;COUNT=3',
+ ),
+ 3,
+ $checks
+ );
+ }
+
+ public function testMonthlyFullDayTimeZoneBerlinFromFile()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20180701', 'message' => '1st event, CEST: '),
+ array('index' => 1, 'dateString' => '20180801T000000', 'message' => '2nd event, CEST: '),
+ array('index' => 2, 'dateString' => '20180901T000000', 'message' => '3rd event, CEST: '),
+ );
+ $this->assertEventFile(
+ 'Europe/Berlin',
+ './tests/ical/ical-monthly.ics',
+ 25,
+ $checks
+ );
+ }
+
+ public function testIssue196FromFile()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20191105T190000', 'timezone' => 'Europe/Berlin', 'message' => '1st event, CEST: '),
+ array('index' => 1, 'dateString' => '20191106T190000', 'timezone' => 'Europe/Berlin', 'message' => '2nd event, CEST: '),
+ array('index' => 2, 'dateString' => '20191107T190000', 'timezone' => 'Europe/Berlin', 'message' => '3rd event, CEST: '),
+ array('index' => 3, 'dateString' => '20191108T190000', 'timezone' => 'Europe/Berlin', 'message' => '4th event, CEST: '),
+ array('index' => 4, 'dateString' => '20191109T170000', 'timezone' => 'Europe/Berlin', 'message' => '5th event, CEST: '),
+ array('index' => 5, 'dateString' => '20191110T180000', 'timezone' => 'Europe/Berlin', 'message' => '6th event, CEST: '),
+ );
+ $this->assertEventFile(
+ 'UTC',
+ './tests/ical/issue-196.ics',
+ 7,
+ $checks
+ );
+ }
+
+ public function testWeeklyFullDayTimeZoneBerlin()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20000301', 'message' => '1st event, CET: '),
+ array('index' => 1, 'dateString' => '20000308T000000', 'message' => '2nd event, CET: '),
+ array('index' => 2, 'dateString' => '20000315T000000', 'message' => '3rd event, CET: '),
+ array('index' => 3, 'dateString' => '20000322T000000', 'message' => '4th event, CET: '),
+ array('index' => 4, 'dateString' => '20000329T000000', 'message' => '5th event, CEST: '),
+ array('index' => 5, 'dateString' => '20000405T000000', 'message' => '6th event, CEST: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART;VALUE=DATE:20000301',
+ 'DTEND;VALUE=DATE:20000302',
+ 'RRULE:FREQ=WEEKLY;WKST=SU;COUNT=6',
+ ),
+ 6,
+ $checks
+ );
+ }
+
+ public function testDailyFullDayTimeZoneBerlin()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20000301', 'message' => '1st event, CET: '),
+ array('index' => 1, 'dateString' => '20000302T000000', 'message' => '2nd event, CET: '),
+ array('index' => 30, 'dateString' => '20000331T000000', 'message' => '31st event, CEST: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART;VALUE=DATE:20000301',
+ 'DTEND;VALUE=DATE:20000302',
+ 'RRULE:FREQ=DAILY;WKST=SU;COUNT=31',
+ ),
+ 31,
+ $checks
+ );
+ }
+
+ public function testWeeklyFullDayTimeZoneBerlinLocal()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20000301T000000', 'message' => '1st event, CET: '),
+ array('index' => 1, 'dateString' => '20000308T000000', 'message' => '2nd event, CET: '),
+ array('index' => 2, 'dateString' => '20000315T000000', 'message' => '3rd event, CET: '),
+ array('index' => 3, 'dateString' => '20000322T000000', 'message' => '4th event, CET: '),
+ array('index' => 4, 'dateString' => '20000329T000000', 'message' => '5th event, CEST: '),
+ array('index' => 5, 'dateString' => '20000405T000000', 'message' => '6th event, CEST: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART;TZID=Europe/Berlin:20000301T000000',
+ 'DTEND;TZID=Europe/Berlin:20000302T000000',
+ 'RRULE:FREQ=WEEKLY;WKST=SU;COUNT=6',
+ ),
+ 6,
+ $checks
+ );
+ }
+
+ public function testRFCDaily10NewYork()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'timezone' => 'America/New_York', 'message' => '1st event, EDT: '),
+ array('index' => 1, 'dateString' => '19970903T090000', 'timezone' => 'America/New_York', 'message' => '2nd event, EDT: '),
+ array('index' => 9, 'dateString' => '19970911T090000', 'timezone' => 'America/New_York', 'message' => '10th event, EDT: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=DAILY;COUNT=10',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ public function testRFCDaily10Berlin()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'timezone' => 'Europe/Berlin', 'message' => '1st event, CEST: '),
+ array('index' => 1, 'dateString' => '19970903T090000', 'timezone' => 'Europe/Berlin', 'message' => '2nd event, CEST: '),
+ array('index' => 9, 'dateString' => '19970911T090000', 'timezone' => 'Europe/Berlin', 'message' => '10th event, CEST: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART;TZID=Europe/Berlin:19970902T090000',
+ 'RRULE:FREQ=DAILY;COUNT=10',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ public function testStartDateIsExdateUsingUntil()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20190918T095000', 'timezone' => 'Europe/London', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20191002T095000', 'timezone' => 'Europe/London', 'message' => '2nd event: '),
+ array('index' => 2, 'dateString' => '20191016T095000', 'timezone' => 'Europe/London', 'message' => '3rd event: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/London',
+ array(
+ 'DTSTART;TZID=Europe/London:20190911T095000',
+ 'RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20191027T235959Z;BYDAY=WE',
+ 'EXDATE;TZID=Europe/London:20191023T095000',
+ 'EXDATE;TZID=Europe/London:20191009T095000',
+ 'EXDATE;TZID=Europe/London:20190925T095000',
+ 'EXDATE;TZID=Europe/London:20190911T095000',
+ ),
+ 3,
+ $checks
+ );
+ }
+
+ public function testStartDateIsExdateUsingCount()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20190918T095000', 'timezone' => 'Europe/London', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20191002T095000', 'timezone' => 'Europe/London', 'message' => '2nd event: '),
+ array('index' => 2, 'dateString' => '20191016T095000', 'timezone' => 'Europe/London', 'message' => '3rd event: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/London',
+ array(
+ 'DTSTART;TZID=Europe/London:20190911T095000',
+ 'RRULE:FREQ=WEEKLY;WKST=SU;COUNT=7;BYDAY=WE',
+ 'EXDATE;TZID=Europe/London:20191023T095000',
+ 'EXDATE;TZID=Europe/London:20191009T095000',
+ 'EXDATE;TZID=Europe/London:20190925T095000',
+ 'EXDATE;TZID=Europe/London:20190911T095000',
+ ),
+ 3,
+ $checks
+ );
+ }
+
+ public function testCountWithExdate()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20200323T050000', 'timezone' => 'Europe/Paris', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20200324T050000', 'timezone' => 'Europe/Paris', 'message' => '2nd event: '),
+ array('index' => 2, 'dateString' => '20200327T050000', 'timezone' => 'Europe/Paris', 'message' => '3rd event: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/London',
+ array(
+ 'DTSTART;TZID=Europe/Paris:20200323T050000',
+ 'DTEND;TZID=Europe/Paris:20200323T070000',
+ 'RRULE:FREQ=DAILY;COUNT=5',
+ 'EXDATE;TZID=Europe/Paris:20200326T050000',
+ 'EXDATE;TZID=Europe/Paris:20200325T050000',
+ 'DTSTAMP:20200318T141057Z',
+ ),
+ 3,
+ $checks
+ );
+ }
+
+ public function testRFCDaily10BerlinFromNewYork()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'timezone' => 'Europe/Berlin', 'message' => '1st event, CEST: '),
+ array('index' => 1, 'dateString' => '19970903T090000', 'timezone' => 'Europe/Berlin', 'message' => '2nd event, CEST: '),
+ array('index' => 9, 'dateString' => '19970911T090000', 'timezone' => 'Europe/Berlin', 'message' => '10th event, CEST: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=Europe/Berlin:19970902T090000',
+ 'RRULE:FREQ=DAILY;COUNT=10',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ public function testExdatesInDifferentTimezone()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20170503T190000', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20170510T190000', 'message' => '2nd event: '),
+ array('index' => 9, 'dateString' => '20170712T190000', 'message' => '10th event: '),
+ array('index' => 19, 'dateString' => '20171004T190000', 'message' => '20th event: '),
+ );
+ $this->assertVEVENT(
+ 'America/Chicago',
+ array(
+ 'DTSTART;TZID=America/Chicago:20170503T190000',
+ 'RRULE:FREQ=WEEKLY;BYDAY=WE;WKST=SU;UNTIL=20180101',
+ 'EXDATE:20170601T000000Z',
+ 'EXDATE:20170803T000000Z',
+ 'EXDATE:20170824T000000Z',
+ 'EXDATE:20171026T000000Z',
+ 'EXDATE:20171102T000000Z',
+ 'EXDATE:20171123T010000Z',
+ 'EXDATE:20171221T010000Z',
+ ),
+ 28,
+ $checks
+ );
+ }
+
+ public function testYearlyWithBySetPos()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970306T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970313T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970325T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19980305T090000', 'message' => '4th occurrence: '),
+ array('index' => 4, 'dateString' => '19980312T090000', 'message' => '5th occurrence: '),
+ array('index' => 5, 'dateString' => '19980326T090000', 'message' => '6th occurrence: '),
+ array('index' => 9, 'dateString' => '20000307T090000', 'message' => '10th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970306T090000',
+ 'RRULE:FREQ=YEARLY;COUNT=10;BYMONTH=3;BYDAY=TU,TH;BYSETPOS=2,4,-2',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ public function testDailyWithByMonthDay()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20000206T120000', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20000211T120000', 'message' => '2nd event: '),
+ array('index' => 2, 'dateString' => '20000216T120000', 'message' => '3rd event: '),
+ array('index' => 4, 'dateString' => '20000226T120000', 'message' => '5th event, transition from February to March: '),
+ array('index' => 5, 'dateString' => '20000301T120000', 'message' => '6th event, transition to March from February: '),
+ array('index' => 11, 'dateString' => '20000331T120000', 'message' => '12th event, transition from March to April: '),
+ array('index' => 12, 'dateString' => '20000401T120000', 'message' => '13th event, transition to April from March: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART:20000206T120000',
+ 'DTEND:20000206T130000',
+ 'RRULE:FREQ=DAILY;BYMONTHDAY=1,6,11,16,21,26,31;COUNT=16',
+ ),
+ 16,
+ $checks
+ );
+ }
+
+ public function testYearlyWithByMonthDay()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20001214T120000', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20001221T120000', 'message' => '2nd event: '),
+ array('index' => 2, 'dateString' => '20010107T120000', 'message' => '3rd event: '),
+ array('index' => 3, 'dateString' => '20010114T120000', 'message' => '4th event: '),
+ array('index' => 6, 'dateString' => '20010214T120000', 'message' => '7th event: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART:20001214T120000',
+ 'DTEND:20001214T130000',
+ 'RRULE:FREQ=YEARLY;BYMONTHDAY=7,14,21;COUNT=8',
+ ),
+ 8,
+ $checks
+ );
+ }
+
+ public function testYearlyWithByMonthDayAndByDay()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20001214T120000', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20001221T120000', 'message' => '2nd event: '),
+ array('index' => 2, 'dateString' => '20010607T120000', 'message' => '3rd event: '),
+ array('index' => 3, 'dateString' => '20010614T120000', 'message' => '4th event: '),
+ array('index' => 6, 'dateString' => '20020214T120000', 'message' => '7th event: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART:20001214T120000',
+ 'DTEND:20001214T130000',
+ 'RRULE:FREQ=YEARLY;BYMONTHDAY=7,14,21;BYDAY=TH;COUNT=8',
+ ),
+ 8,
+ $checks
+ );
+ }
+
+ public function testYearlyWithByMonthAndByMonthDay()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20001214T120000', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20001221T120000', 'message' => '2nd event: '),
+ array('index' => 2, 'dateString' => '20010607T120000', 'message' => '3rd event: '),
+ array('index' => 3, 'dateString' => '20010614T120000', 'message' => '4th event: '),
+ array('index' => 6, 'dateString' => '20011214T120000', 'message' => '7th event: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ array(
+ 'DTSTART:20001214T120000',
+ 'DTEND:20001214T130000',
+ 'RRULE:FREQ=YEARLY;BYMONTH=12,6;BYMONTHDAY=7,14,21;COUNT=8',
+ ),
+ 8,
+ $checks
+ );
+ }
+
+ public function testCountIsOne()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20211201T090000', 'message' => '1st and only expected event: '),
+ );
+ $this->assertVEVENT(
+ 'UTC',
+ array(
+ 'DTSTART:20211201T090000',
+ 'DTEND:20211201T100000',
+ 'RRULE:FREQ=DAILY;COUNT=1',
+ ),
+ 1,
+ $checks
+ );
+ }
+
+ public function test5thByDayOfMonth()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20200103T090000', 'message' => '1st event: '),
+ array('index' => 1, 'dateString' => '20200129T090000', 'message' => '2nd event: '),
+ array('index' => 2, 'dateString' => '20200429T090000', 'message' => '3rd event: '),
+ array('index' => 3, 'dateString' => '20200501T090000', 'message' => '4th event: '),
+ array('index' => 4, 'dateString' => '20200703T090000', 'message' => '5th event: '),
+ array('index' => 5, 'dateString' => '20200729T090000', 'message' => '6th event: '),
+ array('index' => 6, 'dateString' => '20200930T090000', 'message' => '7th event: '),
+ array('index' => 7, 'dateString' => '20201002T090000', 'message' => '8th event: '),
+ array('index' => 8, 'dateString' => '20201230T090000', 'message' => '9th event: '),
+ array('index' => 9, 'dateString' => '20210101T090000', 'message' => '10th and last event: '),
+ );
+ $this->assertVEVENT(
+ 'UTC',
+ array(
+ 'DTSTART:20200103T090000',
+ 'DTEND:20200103T100000',
+ 'RRULE:FREQ=MONTHLY;BYDAY=5WE,-5FR;UNTIL=20210102T090000',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ public function assertVEVENT($defaultTimezone, $veventParts, $count, $checks)
+ {
+ $options = $this->getOptions($defaultTimezone);
+
+ $testIcal = implode(PHP_EOL, $this->getIcalHeader());
+ $testIcal .= PHP_EOL;
+ $testIcal .= implode(PHP_EOL, $this->formatIcalEvent($veventParts));
+ $testIcal .= PHP_EOL;
+ $testIcal .= implode(PHP_EOL, $this->getIcalFooter());
+
+ $ical = new ICal(false, $options);
+ $ical->initString($testIcal);
+
+ $events = $ical->events();
+
+ $this->assertCount($count, $events);
+
+ foreach ($checks as $check) {
+ $this->assertEvent($events[$check['index']], $check['dateString'], $check['message'], isset($check['timezone']) ? $check['timezone'] : $defaultTimezone);
+ }
+ }
+
+ public function assertEventFile($defaultTimezone, $file, $count, $checks)
+ {
+ $options = $this->getOptions($defaultTimezone);
+
+ $ical = new ICal($file, $options);
+
+ $events = $ical->events();
+
+ $this->assertCount($count, $events);
+
+ $events = $ical->sortEventsWithOrder($events);
+
+ foreach ($checks as $check) {
+ $this->assertEvent($events[$check['index']], $check['dateString'], $check['message'], isset($check['timezone']) ? $check['timezone'] : $defaultTimezone);
+ }
+ }
+
+ public function assertEvent($event, $expectedDateString, $message, $timeZone = null)
+ {
+ if (!is_null($timeZone)) {
+ date_default_timezone_set($timeZone);
+ }
+
+ $expectedTimeStamp = strtotime($expectedDateString);
+
+ $this->assertSame($expectedTimeStamp, $event->dtstart_array[2], $message . 'timestamp mismatch (expected ' . $expectedDateString . ' vs actual ' . $event->dtstart . ')');
+ $this->assertSame($expectedDateString, $event->dtstart, $message . 'dtstart mismatch (timestamp is okay)');
+ }
+
+ public function getOptions($defaultTimezone)
+ {
+ $options = array(
+ 'defaultSpan' => 2, // Default value
+ 'defaultTimeZone' => $defaultTimezone, // Default value: UTC
+ 'defaultWeekStart' => 'MO', // Default value
+ 'disableCharacterReplacement' => false, // Default value
+ 'filterDaysAfter' => null, // Default value
+ 'filterDaysBefore' => null, // Default value
+ 'httpUserAgent' => null, // Default value
+ 'skipRecurrence' => false, // Default value
+ );
+
+ return $options;
+ }
+
+ public function formatIcalEvent($veventParts)
+ {
+ return array_merge(
+ array(
+ 'BEGIN:VEVENT',
+ 'CREATED:' . gmdate('Ymd\THis\Z'),
+ 'UID:M2CD-1-1-5FB000FB-BBE4-4F3F-9E7E-217F1FF97209',
+ ),
+ $veventParts,
+ array(
+ 'SUMMARY:test',
+ 'LAST-MODIFIED:' . gmdate('Ymd\THis\Z', filemtime(__FILE__)),
+ 'END:VEVENT',
+ )
+ );
+ }
+
+ public function getIcalHeader()
+ {
+ return array(
+ 'BEGIN:VCALENDAR',
+ 'VERSION:2.0',
+ 'PRODID:-//Google Inc//Google Calendar 70.9054//EN',
+ 'X-WR-CALNAME:Private',
+ 'X-APPLE-CALENDAR-COLOR:#FF2968',
+ 'X-WR-CALDESC:',
+ );
+ }
+
+ public function getIcalFooter()
+ {
+ return array('END:VCALENDAR');
+ }
+}
diff --git a/lib/composer/vendor/johngrogg/ics-parser/tests/Rfc5545RecurrenceTest.php b/lib/composer/vendor/johngrogg/ics-parser/tests/Rfc5545RecurrenceTest.php
new file mode 100644
index 0000000..a617445
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/tests/Rfc5545RecurrenceTest.php
@@ -0,0 +1,1059 @@
+originalTimeZone = date_default_timezone_get();
+ }
+
+ /**
+ * @after
+ */
+ public function tearDownFixtures()
+ {
+ date_default_timezone_set($this->originalTimeZone);
+ }
+
+ // Page 123, Test 1 :: Daily, 10 Occurrences
+ public function test_page123_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970903T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970904T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=DAILY;COUNT=10',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 123, Test 2 :: Daily, until December 24th
+ public function test_page123_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970903T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970904T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=DAILY;UNTIL=19971224T000000Z',
+ ),
+ 113,
+ $checks
+ );
+ }
+
+ // Page 123, Test 3 :: Daily, until December 24th, with trailing semicolon
+ public function test_page123_test3()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970903T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970904T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=DAILY;UNTIL=19971224T000000Z;',
+ ),
+ 113,
+ $checks
+ );
+ }
+
+ // Page 124, Test 1 :: Daily, every other day, Forever
+ //
+ // UNTIL rule does not exist in original example
+ public function test_page124_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970904T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970906T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=DAILY;INTERVAL=2;UNTIL=19971201Z',
+ ),
+ 45,
+ $checks
+ );
+ }
+
+ // Page 124, Test 2 :: Daily, 10-day intervals, 5 occurrences
+ public function test_page124_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970912T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970922T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5',
+ ),
+ 5,
+ $checks
+ );
+ }
+
+ // Page 124, Test 3a :: Every January day, for 3 years (Variant A)
+ public function test_page124_test3a()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19980101T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19980102T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19980103T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19980101T090000',
+ 'RRULE:FREQ=YEARLY;UNTIL=20000131T140000Z;BYMONTH=1;BYDAY=SU,MO,TU,WE,TH,FR,SA',
+ ),
+ 93,
+ $checks
+ );
+ }
+
+ /* Requires support for BYMONTH under DAILY [No ticket]
+ *
+ // Page 124, Test 3b :: Every January day, for 3 years (Variant B)
+ public function test_page124_test3b()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19980101T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19980102T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19980103T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19980101T090000',
+ 'RRULE:FREQ=DAILY;UNTIL=20000131T140000Z;BYMONTH=1',
+ ),
+ 93,
+ $checks
+ );
+ }
+ */
+
+ // Page 124, Test 4 :: Weekly, 10 occurrences
+ public function test_page124_test4()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970909T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970916T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=WEEKLY;COUNT=10',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 125, Test 1 :: Weekly, until December 24th
+ public function test_page125_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970909T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970916T090000', 'message' => '3rd occurrence: '),
+ array('index' => 16, 'dateString' => '19971223T090000', 'message' => 'last occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=WEEKLY;UNTIL=19971224T000000Z',
+ ),
+ 17,
+ $checks
+ );
+ }
+
+ // Page 125, Test 2 :: Every other week, forever
+ //
+ // UNTIL rule does not exist in original example
+ public function test_page125_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970916T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970930T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19971014T090000', 'message' => '4th occurrence: '),
+ array('index' => 4, 'dateString' => '19971028T090000', 'message' => '5th occurrence: '),
+ array('index' => 5, 'dateString' => '19971111T090000', 'message' => '6th occurrence: '),
+ array('index' => 6, 'dateString' => '19971125T090000', 'message' => '7th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=WEEKLY;INTERVAL=2;WKST=SU;UNTIL=19971201Z',
+ ),
+ 7,
+ $checks
+ );
+ }
+
+ // Page 125, Test 3a :: Tuesday & Thursday every week, for five weeks (Variant A)
+ public function test_page125_test3a()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970904T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970909T090000', 'message' => '3rd occurrence: '),
+ array('index' => 9, 'dateString' => '19971002T090000', 'message' => 'final occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=WEEKLY;UNTIL=19971007T000000Z;WKST=SU;BYDAY=TU,TH',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 125, Test 3b :: Tuesday & Thursday every week, for five weeks (Variant B)
+ public function test_page125_test3b()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970904T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970909T090000', 'message' => '3rd occurrence: '),
+ array('index' => 9, 'dateString' => '19971002T090000', 'message' => 'final occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 125, Test 4 :: Monday, Wednesday & Friday of every other week until December 24th
+ public function test_page125_test4()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970901T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970903T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970905T090000', 'message' => '3rd occurrence: '),
+ array('index' => 24, 'dateString' => '19971222T090000', 'message' => 'final occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970901T090000',
+ 'RRULE:FREQ=WEEKLY;INTERVAL=2;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR',
+ ),
+ 25,
+ $checks
+ );
+ }
+
+ // Page 126, Test 1 :: Tuesday & Thursday, every other week, for 8 occurrences
+ public function test_page126_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970904T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970916T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=8;WKST=SU;BYDAY=TU,TH',
+ ),
+ 8,
+ $checks
+ );
+ }
+
+ // Page 126, Test 2 :: First Friday of the Month, for 10 occurrences
+ public function test_page126_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970905T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19971003T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971107T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970905T090000',
+ 'RRULE:FREQ=MONTHLY;COUNT=10;BYDAY=1FR',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 126, Test 3 :: First Friday of the Month, until 24th December
+ public function test_page126_test3()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970905T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19971003T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971107T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970905T090000',
+ 'RRULE:FREQ=MONTHLY;UNTIL=19971224T000000Z;BYDAY=1FR',
+ ),
+ 4,
+ $checks
+ );
+ }
+
+ // Page 126, Test 4 :: First and last Sunday, every other Month, for 10 occurrences
+ public function test_page126_test4()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970907T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970928T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971102T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19971130T090000', 'message' => '4th occurrence: '),
+ array('index' => 4, 'dateString' => '19980104T090000', 'message' => '5th occurrence: '),
+ array('index' => 5, 'dateString' => '19980125T090000', 'message' => '6th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970907T090000',
+ 'RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=10;BYDAY=1SU,-1SU',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 126, Test 5 :: Second-to-last Monday of the Month, for six months
+ public function test_page126_test5()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970922T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19971020T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971117T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970922T090000',
+ 'RRULE:FREQ=MONTHLY;COUNT=6;BYDAY=-2MO',
+ ),
+ 6,
+ $checks
+ );
+ }
+
+ // Page 127, Test 1 :: Third-to-last day of the month, forever
+ //
+ // UNTIL rule does not exist in original example.
+ public function test_page127_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970928T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19971029T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971128T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19971229T090000', 'message' => '4th occurrence: '),
+ array('index' => 4, 'dateString' => '19980129T090000', 'message' => '5th occurrence: '),
+ array('index' => 5, 'dateString' => '19980226T090000', 'message' => '6th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970928T090000',
+ 'RRULE:FREQ=MONTHLY;BYMONTHDAY=-3;UNTIL=19980401',
+ ),
+ 7,
+ $checks
+ );
+ }
+
+ // Page 127, Test 2 :: 2nd and 15th of each Month, for 10 occurrences
+ public function test_page127_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970915T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971002T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19971015T090000', 'message' => '4th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=MONTHLY;COUNT=10;BYMONTHDAY=2,15',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 127, Test 3 :: First and last day of the month, for 10 occurrences
+ public function test_page127_test3()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970930T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19971001T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971031T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19971101T090000', 'message' => '4th occurrence: '),
+ array('index' => 4, 'dateString' => '19971130T090000', 'message' => '5th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970930T090000',
+ 'RRULE:FREQ=MONTHLY;COUNT=10;BYMONTHDAY=1,-1',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 127, Test 4 :: 10th through 15th, every 18 months, for 10 occurrences
+ public function test_page127_test4()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970910T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970911T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970912T090000', 'message' => '3rd occurrence: '),
+ array('index' => 6, 'dateString' => '19990310T090000', 'message' => '7th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970910T090000',
+ 'RRULE:FREQ=MONTHLY;INTERVAL=18;COUNT=10;BYMONTHDAY=10,11,12,13,14,15',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 127, Test 5 :: Every Tuesday, every other Month, forever
+ //
+ // UNTIL rule does not exist in original example.
+ public function test_page127_test5()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970909T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970916T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=MONTHLY;INTERVAL=2;BYDAY=TU;UNTIL=19980101',
+ ),
+ 9,
+ $checks
+ );
+ }
+
+ // Page 128, Test 1 :: June & July of each Year, for 10 occurrences
+ public function test_page128_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970610T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970710T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19980610T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970610T090000',
+ 'RRULE:FREQ=YEARLY;COUNT=10;BYMONTH=6,7',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 128, Test 2 :: January, February, & March, every other Year, for 10 occurrences
+ public function test_page128_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970310T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19990110T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19990210T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970310T090000',
+ 'RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=10;BYMONTH=1,2,3',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 128, Test 3 :: Every third Year on the 1st, 100th, & 200th day for 10 occurrences
+ public function test_page128_test3()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970101T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970410T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970719T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970101T090000',
+ 'RRULE:FREQ=YEARLY;INTERVAL=3;COUNT=10;BYYEARDAY=1,100,200',
+ ),
+ 10,
+ $checks
+ );
+ }
+
+ // Page 128, Test 4 :: 20th Monday of a Year, forever
+ //
+ // COUNT rule does not exist in original example.
+ public function test_page128_test4()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970519T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19980518T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19990517T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970519T090000',
+ 'RRULE:FREQ=YEARLY;BYDAY=20MO;COUNT=4',
+ ),
+ 4,
+ $checks
+ );
+ }
+
+ // Page 129, Test 1 :: Monday of Week 20, where the default start of the week is Monday, forever
+ //
+ // COUNT rule does not exist in original example.
+ public function test_page129_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970512T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19980511T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19990517T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970512T090000',
+ 'RRULE:FREQ=YEARLY;BYWEEKNO=20;BYDAY=MO;COUNT=4',
+ ),
+ 4,
+ $checks
+ );
+ }
+
+ // Page 129, Test 2 :: Every Thursday in March, forever
+ //
+ // UNTIL rule does not exist in original example.
+ public function test_page129_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970313T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970320T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970327T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970313T090000',
+ 'RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=TH;UNTIL=19990401Z',
+ ),
+ 11,
+ $checks
+ );
+ }
+
+ // Page 129, Test 3 :: Every Thursday in June, July, & August, forever
+ //
+ // UNTIL rule does not exist in original example.
+ public function test_page129_test3()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970605T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970612T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970619T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970605T090000',
+ 'RRULE:FREQ=YEARLY;BYDAY=TH;BYMONTH=6,7,8;UNTIL=19970901Z',
+ ),
+ 13,
+ $checks
+ );
+ }
+
+ /* Requires support for BYMONTHDAY and BYDAY in the same MONTHLY RRULE [No ticket]
+ *
+ // Page 129, Test 4 :: Every Friday 13th, forever
+ //
+ // COUNT rule does not exist in original example.
+ public function test_page129_test4()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19980213T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19980313T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19981113T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19990813T090000', 'message' => '4th occurrence: '),
+ array('index' => 4, 'dateString' => '20001013T090000', 'message' => '5th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'EXDATE;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13;COUNT=5',
+ ),
+ 5,
+ $checks
+ );
+ }
+ */
+
+ // Page 130, Test 1 :: The first Saturday that follows the first Sunday of the month, forever:
+ //
+ // COUNT rule does not exist in original example.
+ public function test_page130_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970913T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19971011T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971108T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970913T090000',
+ 'RRULE:FREQ=MONTHLY;BYDAY=SA;BYMONTHDAY=7,8,9,10,11,12,13;COUNT=7',
+ ),
+ 7,
+ $checks
+ );
+ }
+
+ // Page 130, Test 2 :: The first Tuesday after a Monday in November, every 4 Years (U.S. Presidential Election Day), forever
+ //
+ // COUNT rule does not exist in original example.
+ public function test_page130_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19961105T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '20001107T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '20041102T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19961105T090000',
+ 'RRULE:FREQ=YEARLY;INTERVAL=4;BYMONTH=11;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8;COUNT=4',
+ ),
+ 4,
+ $checks
+ );
+ }
+
+ // Page 130, Test 3 :: Third instance of either a Tuesday, Wednesday, or Thursday of a Month, for 3 months.
+ public function test_page130_test3()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970904T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19971007T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971106T090000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970904T090000',
+ 'RRULE:FREQ=MONTHLY;COUNT=3;BYDAY=TU,WE,TH;BYSETPOS=3',
+ ),
+ 3,
+ $checks
+ );
+ }
+
+ // Page 130, Test 4 :: Second-to-last weekday of the month, indefinitely
+ //
+ // UNTIL rule does not exist in original example.
+ public function test_page130_test4()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970929T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19971030T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19971127T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19971230T090000', 'message' => '4th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970929T090000',
+ 'RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2;UNTIL=19980101',
+ ),
+ 4,
+ $checks
+ );
+ }
+
+ /* Requires support of HOURLY frequency [#101]
+ *
+ // Page 131, Test 1 :: Every 3 hours from 09:00 to 17:00 on a specific day
+ public function test_page131_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970902T120000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970902T150000', 'message' => '3rd occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'FREQ=HOURLY;INTERVAL=3;UNTIL=19970902T170000Z',
+ ),
+ 3,
+ $checks
+ );
+ }
+ */
+
+ /* Requires support of MINUTELY frequency [#101]
+ *
+ // Page 131, Test 2 :: Every 15 minutes for 6 occurrences
+ public function test_page131_test2()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970902T091500', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970902T093000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19970902T094500', 'message' => '4th occurrence: '),
+ array('index' => 4, 'dateString' => '19970902T100000', 'message' => '5th occurrence: '),
+ array('index' => 5, 'dateString' => '19970902T101500', 'message' => '6th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=MINUTELY;INTERVAL=15;COUNT=6',
+ ),
+ 6,
+ $checks
+ );
+ }
+ */
+
+ /* Requires support of MINUTELY frequency [#101]
+ *
+ // Page 131, Test 3 :: Every hour and a half for 4 occurrences
+ public function test_page131_test3()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970902T103000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970902T120000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19970902T133000', 'message' => '4th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=MINUTELY;INTERVAL=90;COUNT=4',
+ ),
+ 4,
+ $checks
+ );
+ }
+ */
+
+ /* Requires support of BYHOUR and BYMINUTE under DAILY [#11]
+ *
+ // Page 131, Test 4a :: Every 20 minutes from 9:00 to 16:40 every day, using DAILY
+ //
+ // UNTIL rule does not exist in original example
+ public function test_page131_test4a()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence, Day 1: '),
+ array('index' => 1, 'dateString' => '19970902T092000', 'message' => '2nd occurrence, Day 1: '),
+ array('index' => 2, 'dateString' => '19970902T094000', 'message' => '3rd occurrence, Day 1: '),
+ array('index' => 3, 'dateString' => '19970902T100000', 'message' => '4th occurrence, Day 1: '),
+ array('index' => 20, 'dateString' => '19970902T164000', 'message' => 'Last occurrence, Day 1: '),
+ array('index' => 21, 'dateString' => '19970903T090000', 'message' => '1st occurrence, Day 2: '),
+ array('index' => 41, 'dateString' => '19970903T164000', 'message' => 'Last occurrence, Day 2: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=DAILY;BYHOUR=9,10,11,12,13,14,15,16;BYMINUTE=0,20,40;UNTIL=19970904T000000Z',
+ ),
+ 42,
+ $checks
+ );
+ }
+ */
+
+ /* Requires support of MINUTELY frequency [#101]
+ *
+ // Page 131, Test 4b :: Every 20 minutes from 9:00 to 16:40 every day, using MINUTELY
+ //
+ // UNTIL rule does not exist in original example
+ public function test_page131_test4b()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970902T090000', 'message' => '1st occurrence, Day 1: '),
+ array('index' => 1, 'dateString' => '19970902T092000', 'message' => '2nd occurrence, Day 1: '),
+ array('index' => 2, 'dateString' => '19970902T094000', 'message' => '3rd occurrence, Day 1: '),
+ array('index' => 3, 'dateString' => '19970902T100000', 'message' => '4th occurrence, Day 1: '),
+ array('index' => 20, 'dateString' => '19970902T164000', 'message' => 'Last occurrence, Day 1: '),
+ array('index' => 21, 'dateString' => '19970903T090000', 'message' => '1st occurrence, Day 2: '),
+ array('index' => 41, 'dateString' => '19970903T164000', 'message' => 'Last occurrence, Day 2: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970902T090000',
+ 'RRULE:FREQ=MINUTELY;INTERVAL=20;BYHOUR=9,10,11,12,13,14,15,16;UNTIL=19970904T000000Z',
+ ),
+ 42,
+ $checks
+ );
+ }
+ */
+
+ // Page 131, Test 5a :: Changing the passed WKST rule, before...
+ public function test_page131_test5a()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970805T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970810T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970819T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19970824T090000', 'message' => '4th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970805T090000',
+ 'RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=MO',
+ ),
+ 4,
+ $checks
+ );
+ }
+
+ // Page 131, Test 5b :: ...and after
+ public function test_page131_test5b()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '19970805T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '19970817T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '19970819T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '19970831T090000', 'message' => '4th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:19970805T090000',
+ 'RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU',
+ ),
+ 4,
+ $checks
+ );
+ }
+
+ // Page 132, Test 1 :: Automatically ignoring an invalid date (30 February)
+ public function test_page132_test1()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20070115T090000', 'message' => '1st occurrence: '),
+ array('index' => 1, 'dateString' => '20070130T090000', 'message' => '2nd occurrence: '),
+ array('index' => 2, 'dateString' => '20070215T090000', 'message' => '3rd occurrence: '),
+ array('index' => 3, 'dateString' => '20070315T090000', 'message' => '4th occurrence: '),
+ array('index' => 4, 'dateString' => '20070330T090000', 'message' => '5th occurrence: '),
+ );
+ $this->assertVEVENT(
+ 'America/New_York',
+ array(
+ 'DTSTART;TZID=America/New_York:20070115T090000',
+ 'RRULE:FREQ=MONTHLY;BYMONTHDAY=15,30;COUNT=5',
+ ),
+ 5,
+ $checks
+ );
+ }
+
+ public function assertVEVENT($defaultTimezone, $veventParts, $count, $checks)
+ {
+ $options = $this->getOptions($defaultTimezone);
+
+ $testIcal = implode(PHP_EOL, $this->getIcalHeader());
+ $testIcal .= PHP_EOL;
+ $testIcal .= implode(PHP_EOL, $this->formatIcalEvent($veventParts));
+ $testIcal .= PHP_EOL;
+ $testIcal .= implode(PHP_EOL, $this->getIcalFooter());
+
+ $ical = new ICal(false, $options);
+ $ical->initString($testIcal);
+
+ $events = $ical->events();
+
+ $this->assertCount($count, $events);
+
+ foreach ($checks as $check) {
+ $this->assertEvent($events[$check['index']], $check['dateString'], $check['message'], isset($check['timezone']) ? $check['timezone'] : $defaultTimezone);
+ }
+ }
+
+ public function assertEvent($event, $expectedDateString, $message, $timeZone = null)
+ {
+ if (!is_null($timeZone)) {
+ date_default_timezone_set($timeZone);
+ }
+
+ $expectedTimeStamp = strtotime($expectedDateString);
+
+ $this->assertSame($expectedTimeStamp, $event->dtstart_array[2], $message . 'timestamp mismatch (expected ' . $expectedDateString . ' vs actual ' . $event->dtstart . ')');
+ $this->assertSame($expectedDateString, $event->dtstart, $message . 'dtstart mismatch (timestamp is okay)');
+ }
+
+ public function getOptions($defaultTimezone)
+ {
+ $options = array(
+ 'defaultSpan' => 2, // Default value: 2
+ 'defaultTimeZone' => $defaultTimezone, // Default value: UTC
+ 'defaultWeekStart' => 'MO', // Default value
+ 'disableCharacterReplacement' => false, // Default value
+ 'filterDaysAfter' => null, // Default value
+ 'filterDaysBefore' => null, // Default value
+ 'httpUserAgent' => null, // Default value
+ 'skipRecurrence' => false, // Default value
+ );
+
+ return $options;
+ }
+
+ public function formatIcalEvent($veventParts)
+ {
+ return array_merge(
+ array(
+ 'BEGIN:VEVENT',
+ 'CREATED:' . gmdate('Ymd\THis\Z'),
+ 'UID:RFC5545-examples-test',
+ ),
+ $veventParts,
+ array(
+ 'SUMMARY:test',
+ 'LAST-MODIFIED:' . gmdate('Ymd\THis\Z', filemtime(__FILE__)),
+ 'END:VEVENT',
+ )
+ );
+ }
+
+ public function getIcalHeader()
+ {
+ return array(
+ 'BEGIN:VCALENDAR',
+ 'VERSION:2.0',
+ 'PRODID:-//Google Inc//Google Calendar 70.9054//EN',
+ 'X-WR-CALNAME:Private',
+ 'X-APPLE-CALENDAR-COLOR:#FF2968',
+ 'X-WR-CALDESC:',
+ );
+ }
+
+ public function getIcalFooter()
+ {
+ return array('END:VCALENDAR');
+ }
+}
diff --git a/lib/composer/vendor/johngrogg/ics-parser/tests/SingleEventsTest.php b/lib/composer/vendor/johngrogg/ics-parser/tests/SingleEventsTest.php
new file mode 100644
index 0000000..fc89c67
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/tests/SingleEventsTest.php
@@ -0,0 +1,509 @@
+originalTimeZone = date_default_timezone_get();
+ }
+
+ /**
+ * @after
+ */
+ public function tearDownFixtures()
+ {
+ date_default_timezone_set($this->originalTimeZone);
+ }
+
+ public function testFullDayTimeZoneBerlin()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20000301', 'message' => '1st event, CET: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ 'DTSTART;VALUE=DATE:20000301',
+ 'DTEND;VALUE=DATE:20000302',
+ 1,
+ $checks
+ );
+ }
+
+ public function testSeveralFullDaysTimeZoneBerlin()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20000301', 'message' => '1st event, CET: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ 'DTSTART;VALUE=DATE:20000301',
+ 'DTEND;VALUE=DATE:20000304',
+ 1,
+ $checks
+ );
+ }
+
+ public function testEventTimeZoneUTC()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20180626T070000Z', 'message' => '1st event, UTC: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ 'DTSTART:20180626T070000Z',
+ 'DTEND:20180626T110000Z',
+ 1,
+ $checks
+ );
+ }
+
+ public function testEventTimeZoneBerlin()
+ {
+ $checks = array(
+ array('index' => 0, 'dateString' => '20180626T070000', 'message' => '1st event, CEST: '),
+ );
+ $this->assertVEVENT(
+ 'Europe/Berlin',
+ 'DTSTART:20180626T070000',
+ 'DTEND:20180626T110000',
+ 1,
+ $checks
+ );
+ }
+
+ public function assertVEVENT($defaultTimezone, $dtstart, $dtend, $count, $checks)
+ {
+ $options = $this->getOptions($defaultTimezone);
+
+ $testIcal = implode(PHP_EOL, $this->getIcalHeader());
+ $testIcal .= PHP_EOL;
+ $testIcal .= implode(PHP_EOL, $this->formatIcalEvent($dtstart, $dtend));
+ $testIcal .= PHP_EOL;
+ $testIcal .= implode(PHP_EOL, $this->getIcalTimezones());
+ $testIcal .= PHP_EOL;
+ $testIcal .= implode(PHP_EOL, $this->getIcalFooter());
+
+ date_default_timezone_set('UTC');
+
+ $ical = new ICal(false, $options);
+ $ical->initString($testIcal);
+
+ $events = $ical->events();
+
+ $this->assertCount($count, $events);
+
+ foreach ($checks as $check) {
+ $this->assertEvent(
+ $events[$check['index']],
+ $check['dateString'],
+ $check['message'],
+ isset($check['timezone']) ? $check['timezone'] : $defaultTimezone
+ );
+ }
+ }
+
+ public function getOptions($defaultTimezone)
+ {
+ $options = array(
+ 'defaultSpan' => 2, // Default value
+ 'defaultTimeZone' => $defaultTimezone, // Default value: UTC
+ 'defaultWeekStart' => 'MO', // Default value
+ 'disableCharacterReplacement' => false, // Default value
+ 'filterDaysAfter' => null, // Default value
+ 'filterDaysBefore' => null, // Default value
+ 'httpUserAgent' => null, // Default value
+ 'skipRecurrence' => false, // Default value
+ );
+
+ return $options;
+ }
+
+ public function getIcalHeader()
+ {
+ return array(
+ 'BEGIN:VCALENDAR',
+ 'VERSION:2.0',
+ 'PRODID:-//Google Inc//Google Calendar 70.9054//EN',
+ 'X-WR-CALNAME:Private',
+ 'X-APPLE-CALENDAR-COLOR:#FF2968',
+ 'X-WR-CALDESC:',
+ );
+ }
+
+ public function formatIcalEvent($dtstart, $dtend)
+ {
+ return array(
+ 'BEGIN:VEVENT',
+ 'CREATED:20090213T195947Z',
+ 'UID:M2CD-1-1-5FB000FB-BBE4-4F3F-9E7E-217F1FF97209',
+ $dtstart,
+ $dtend,
+ 'SUMMARY:test',
+ 'DESCRIPTION;LANGUAGE=en-gb:This is a short description\nwith a new line. Some "special" \'s',
+ ' igns\' may be interesting\, too.',
+ ' And a non-breaking space.',
+ 'LAST-MODIFIED:20110429T222101Z',
+ 'DTSTAMP:20170630T105724Z',
+ 'SEQUENCE:0',
+ 'END:VEVENT',
+ );
+ }
+
+ public function getIcalTimezones()
+ {
+ return array(
+ 'BEGIN:VTIMEZONE',
+ 'TZID:Europe/Berlin',
+ 'X-LIC-LOCATION:Europe/Berlin',
+ 'BEGIN:STANDARD',
+ 'DTSTART:18930401T000000',
+ 'RDATE:18930401T000000',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+005328',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19160430T230000',
+ 'RDATE:19160430T230000',
+ 'RDATE:19400401T020000',
+ 'RDATE:19430329T020000',
+ 'RDATE:19460414T020000',
+ 'RDATE:19470406T030000',
+ 'RDATE:19480418T020000',
+ 'RDATE:19490410T020000',
+ 'RDATE:19800406T020000',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19161001T010000',
+ 'RDATE:19161001T010000',
+ 'RDATE:19421102T030000',
+ 'RDATE:19431004T030000',
+ 'RDATE:19441002T030000',
+ 'RDATE:19451118T030000',
+ 'RDATE:19461007T030000',
+ 'TZNAME:CET',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19170416T020000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19180415T010000Z;BYMONTH=4;BYDAY=3MO',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19170917T030000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19180916T010000Z;BYMONTH=9;BYDAY=3MO',
+ 'TZNAME:CET',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19440403T020000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19450402T010000Z;BYMONTH=4;BYDAY=1MO',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19450524T020000',
+ 'RDATE:19450524T020000',
+ 'RDATE:19470511T030000',
+ 'TZNAME:CEMT',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0300',
+ 'END:DAYLIGHT',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19450924T030000',
+ 'RDATE:19450924T030000',
+ 'RDATE:19470629T030000',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0300',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19460101T000000',
+ 'RDATE:19460101T000000',
+ 'RDATE:19800101T000000',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19471005T030000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19491002T010000Z;BYMONTH=10;BYDAY=1SU',
+ 'TZNAME:CET',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19800928T030000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19950924T010000Z;BYMONTH=9;BYDAY=-1SU',
+ 'TZNAME:CET',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19810329T020000',
+ 'RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19961027T030000',
+ 'RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU',
+ 'TZNAME:CET',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'END:VTIMEZONE',
+ 'BEGIN:VTIMEZONE',
+ 'TZID:Europe/Paris',
+ 'X-LIC-LOCATION:Europe/Paris',
+ 'BEGIN:STANDARD',
+ 'DTSTART:18910315T000100',
+ 'RDATE:18910315T000100',
+ 'TZNAME:PMT',
+ 'TZOFFSETFROM:+000921',
+ 'TZOFFSETTO:+000921',
+ 'END:STANDARD',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19110311T000100',
+ 'RDATE:19110311T000100',
+ 'TZNAME:WEST',
+ 'TZOFFSETFROM:+000921',
+ 'TZOFFSETTO:+0000',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19160614T230000',
+ 'RDATE:19160614T230000',
+ 'RDATE:19170324T230000',
+ 'RDATE:19180309T230000',
+ 'RDATE:19190301T230000',
+ 'RDATE:19200214T230000',
+ 'RDATE:19210314T230000',
+ 'RDATE:19220325T230000',
+ 'RDATE:19230526T230000',
+ 'RDATE:19240329T230000',
+ 'RDATE:19250404T230000',
+ 'RDATE:19260417T230000',
+ 'RDATE:19270409T230000',
+ 'RDATE:19280414T230000',
+ 'RDATE:19290420T230000',
+ 'RDATE:19300412T230000',
+ 'RDATE:19310418T230000',
+ 'RDATE:19320402T230000',
+ 'RDATE:19330325T230000',
+ 'RDATE:19340407T230000',
+ 'RDATE:19350330T230000',
+ 'RDATE:19360418T230000',
+ 'RDATE:19370403T230000',
+ 'RDATE:19380326T230000',
+ 'RDATE:19390415T230000',
+ 'RDATE:19400225T020000',
+ 'TZNAME:WEST',
+ 'TZOFFSETFROM:+0000',
+ 'TZOFFSETTO:+0100',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19161002T000000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19191005T230000Z;BYMONTH=10;BYMONTHDAY=2,3,4,5,6,',
+ ' 7,8;BYDAY=MO',
+ 'TZNAME:WET',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0000',
+ 'END:STANDARD',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19201024T000000',
+ 'RDATE:19201024T000000',
+ 'RDATE:19211026T000000',
+ 'RDATE:19391119T000000',
+ 'TZNAME:WET',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0000',
+ 'END:STANDARD',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19221008T000000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19381001T230000Z;BYMONTH=10;BYMONTHDAY=2,3,4,5,6,',
+ ' 7,8;BYDAY=SU',
+ 'TZNAME:WET',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0000',
+ 'END:STANDARD',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19400614T230000',
+ 'RDATE:19400614T230000',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:STANDARD',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19421102T030000',
+ 'RDATE:19421102T030000',
+ 'RDATE:19431004T030000',
+ 'RDATE:19760926T010000',
+ 'RDATE:19770925T030000',
+ 'RDATE:19781001T030000',
+ 'TZNAME:CET',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19430329T020000',
+ 'RDATE:19430329T020000',
+ 'RDATE:19440403T020000',
+ 'RDATE:19760328T010000',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19440825T000000',
+ 'RDATE:19440825T000000',
+ 'TZNAME:WEST',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0200',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19441008T010000',
+ 'RDATE:19441008T010000',
+ 'TZNAME:WEST',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:DAYLIGHT',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19450402T020000',
+ 'RDATE:19450402T020000',
+ 'TZNAME:WEMT',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19450916T030000',
+ 'RDATE:19450916T030000',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19770101T000000',
+ 'RDATE:19770101T000000',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19770403T020000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19800406T010000Z;BYMONTH=4;BYDAY=1SU',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19790930T030000',
+ 'RRULE:FREQ=YEARLY;UNTIL=19950924T010000Z;BYMONTH=9;BYDAY=-1SU',
+ 'TZNAME:CET',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19810329T020000',
+ 'RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU',
+ 'TZNAME:CEST',
+ 'TZOFFSETFROM:+0100',
+ 'TZOFFSETTO:+0200',
+ 'END:DAYLIGHT',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19961027T030000',
+ 'RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU',
+ 'TZNAME:CET',
+ 'TZOFFSETFROM:+0200',
+ 'TZOFFSETTO:+0100',
+ 'END:STANDARD',
+ 'END:VTIMEZONE',
+ 'BEGIN:VTIMEZONE',
+ 'TZID:US-Eastern',
+ 'LAST-MODIFIED:19870101T000000Z',
+ 'TZURL:http://zones.stds_r_us.net/tz/US-Eastern',
+ 'BEGIN:STANDARD',
+ 'DTSTART:19671029T020000',
+ 'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10',
+ 'TZOFFSETFROM:-0400',
+ 'TZOFFSETTO:-0500',
+ 'TZNAME:EST',
+ 'END:STANDARD',
+ 'BEGIN:DAYLIGHT',
+ 'DTSTART:19870405T020000',
+ 'RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4',
+ 'TZOFFSETFROM:-0500',
+ 'TZOFFSETTO:-0400',
+ 'TZNAME:EDT',
+ 'END:DAYLIGHT',
+ 'END:VTIMEZONE',
+ );
+ }
+
+ public function getIcalFooter()
+ {
+ return array('END:VCALENDAR');
+ }
+
+ public function assertEvent($event, $expectedDateString, $message, $timezone = null)
+ {
+ if ($timezone !== null) {
+ date_default_timezone_set($timezone);
+ }
+
+ $expectedTimeStamp = strtotime($expectedDateString);
+
+ $this->assertSame(
+ $expectedTimeStamp,
+ $event->dtstart_array[2],
+ $message . 'timestamp mismatch (expected ' . $expectedDateString . ' vs actual ' . $event->dtstart . ')'
+ );
+ $this->assertSame(
+ $expectedDateString,
+ $event->dtstart,
+ $message . 'dtstart mismatch (timestamp is okay)'
+ );
+ }
+
+ public function assertEventFile($defaultTimezone, $file, $count, $checks)
+ {
+ $options = $this->getOptions($defaultTimezone);
+
+ date_default_timezone_set('UTC');
+
+ $ical = new ICal($file, $options);
+
+ $events = $ical->events();
+
+ $this->assertCount($count, $events);
+
+ foreach ($checks as $check) {
+ $this->assertEvent(
+ $events[$check['index']],
+ $check['dateString'],
+ $check['message'],
+ isset($check['timezone']) ? $check['timezone'] : $defaultTimezone
+ );
+ }
+ }
+}
diff --git a/lib/composer/vendor/johngrogg/ics-parser/tests/ical/ical-monthly.ics b/lib/composer/vendor/johngrogg/ics-parser/tests/ical/ical-monthly.ics
new file mode 100644
index 0000000..d80e221
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/tests/ical/ical-monthly.ics
@@ -0,0 +1,18 @@
+BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+X-WR-CALNAME:Private
+X-APPLE-CALENDAR-COLOR:#FF2968
+X-WR-CALDESC:
+BEGIN:VEVENT
+CREATED:20090213T195947Z
+UID:M2CD-1-1-5FB000FB-BBE4-4F3F-9E7E-217F1FF97208
+RRULE:FREQ=MONTHLY;BYMONTHDAY=1;WKST=SU;COUNT=25
+DTSTART;VALUE=DATE:20180701
+DTEND;VALUE=DATE:20180702
+SUMMARY:Monthly
+LAST-MODIFIED:20110429T222101Z
+DTSTAMP:20170630T105724Z
+SEQUENCE:0
+END:VEVENT
+END:VCALENDAR
diff --git a/lib/composer/vendor/johngrogg/ics-parser/tests/ical/issue-196.ics b/lib/composer/vendor/johngrogg/ics-parser/tests/ical/issue-196.ics
new file mode 100644
index 0000000..3ffcb18
--- /dev/null
+++ b/lib/composer/vendor/johngrogg/ics-parser/tests/ical/issue-196.ics
@@ -0,0 +1,64 @@
+BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+X-WR-CALNAME:Test-Calendar
+X-WR-TIMEZONE:Europe/Berlin
+BEGIN:VTIMEZONE
+TZID:Europe/Berlin
+BEGIN:DAYLIGHT
+TZOFFSETFROM:+0100
+TZOFFSETTO:+0200
+TZNAME:CEST
+DTSTART:19700329T020000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:+0200
+TZOFFSETTO:+0100
+TZNAME:CET
+DTSTART:19701025T030000
+RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+CREATED:20180101T152047Z
+LAST-MODIFIED:20181202T202056Z
+DTSTAMP:20181202T202056Z
+UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5
+SUMMARY:test
+RRULE:FREQ=DAILY;UNTIL=20191111T180000Z
+DTSTART;TZID=Europe/Berlin:20191105T190000
+DTEND;TZID=Europe/Berlin:20191105T220000
+TRANSP:OPAQUE
+SEQUENCE:24
+X-MOZ-GENERATION:37
+END:VEVENT
+BEGIN:VEVENT
+CREATED:20181202T202042Z
+LAST-MODIFIED:20181202T202053Z
+DTSTAMP:20181202T202053Z
+UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5
+SUMMARY:test
+RECURRENCE-ID;TZID=Europe/Berlin:20191109T190000
+DTSTART;TZID=Europe/Berlin:20191109T170000
+DTEND;TZID=Europe/Berlin:20191109T220000
+TRANSP:OPAQUE
+SEQUENCE:25
+X-MOZ-GENERATION:37
+DURATION:PT0S
+END:VEVENT
+BEGIN:VEVENT
+CREATED:20181202T202053Z
+LAST-MODIFIED:20181202T202056Z
+DTSTAMP:20181202T202056Z
+UID:529b1ea3-8de8-484d-b878-c20c7fb72bf5
+SUMMARY:test
+RECURRENCE-ID;TZID=Europe/Berlin:20191110T190000
+DTSTART;TZID=Europe/Berlin:20191110T180000
+DTEND;TZID=Europe/Berlin:20191110T220000
+TRANSP:OPAQUE
+SEQUENCE:25
+X-MOZ-GENERATION:37
+DURATION:PT0S
+END:VEVENT
+END:VCALENDAR
diff --git a/lib/composer/vendor/psr/log/LICENSE b/lib/composer/vendor/psr/log/LICENSE
new file mode 100644
index 0000000..474c952
--- /dev/null
+++ b/lib/composer/vendor/psr/log/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2012 PHP Framework Interoperability Group
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/lib/composer/vendor/psr/log/README.md b/lib/composer/vendor/psr/log/README.md
new file mode 100644
index 0000000..a9f20c4
--- /dev/null
+++ b/lib/composer/vendor/psr/log/README.md
@@ -0,0 +1,58 @@
+PSR Log
+=======
+
+This repository holds all interfaces/classes/traits related to
+[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).
+
+Note that this is not a logger of its own. It is merely an interface that
+describes a logger. See the specification for more details.
+
+Installation
+------------
+
+```bash
+composer require psr/log
+```
+
+Usage
+-----
+
+If you need a logger, you can use the interface like this:
+
+```php
+logger = $logger;
+ }
+
+ public function doSomething()
+ {
+ if ($this->logger) {
+ $this->logger->info('Doing work');
+ }
+
+ try {
+ $this->doSomethingElse();
+ } catch (Exception $exception) {
+ $this->logger->error('Oh no!', array('exception' => $exception));
+ }
+
+ // do something useful
+ }
+}
+```
+
+You can then pick one of the implementations of the interface to get a logger.
+
+If you want to implement the interface, you can require this package and
+implement `Psr\Log\LoggerInterface` in your code. Please read the
+[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
+for details.
diff --git a/lib/composer/vendor/psr/log/composer.json b/lib/composer/vendor/psr/log/composer.json
new file mode 100644
index 0000000..879fc6f
--- /dev/null
+++ b/lib/composer/vendor/psr/log/composer.json
@@ -0,0 +1,26 @@
+{
+ "name": "psr/log",
+ "description": "Common interface for logging libraries",
+ "keywords": ["psr", "psr-3", "log"],
+ "homepage": "https://github.com/php-fig/log",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "require": {
+ "php": ">=8.0.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Log\\": "src"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ }
+}
diff --git a/lib/composer/vendor/psr/log/src/AbstractLogger.php b/lib/composer/vendor/psr/log/src/AbstractLogger.php
new file mode 100644
index 0000000..d60a091
--- /dev/null
+++ b/lib/composer/vendor/psr/log/src/AbstractLogger.php
@@ -0,0 +1,15 @@
+logger = $logger;
+ }
+}
diff --git a/lib/composer/vendor/psr/log/src/LoggerInterface.php b/lib/composer/vendor/psr/log/src/LoggerInterface.php
new file mode 100644
index 0000000..cb4cf64
--- /dev/null
+++ b/lib/composer/vendor/psr/log/src/LoggerInterface.php
@@ -0,0 +1,98 @@
+log(LogLevel::EMERGENCY, $message, $context);
+ }
+
+ /**
+ * Action must be taken immediately.
+ *
+ * Example: Entire website down, database unavailable, etc. This should
+ * trigger the SMS alerts and wake you up.
+ */
+ public function alert(string|\Stringable $message, array $context = []): void
+ {
+ $this->log(LogLevel::ALERT, $message, $context);
+ }
+
+ /**
+ * Critical conditions.
+ *
+ * Example: Application component unavailable, unexpected exception.
+ */
+ public function critical(string|\Stringable $message, array $context = []): void
+ {
+ $this->log(LogLevel::CRITICAL, $message, $context);
+ }
+
+ /**
+ * Runtime errors that do not require immediate action but should typically
+ * be logged and monitored.
+ */
+ public function error(string|\Stringable $message, array $context = []): void
+ {
+ $this->log(LogLevel::ERROR, $message, $context);
+ }
+
+ /**
+ * Exceptional occurrences that are not errors.
+ *
+ * Example: Use of deprecated APIs, poor use of an API, undesirable things
+ * that are not necessarily wrong.
+ */
+ public function warning(string|\Stringable $message, array $context = []): void
+ {
+ $this->log(LogLevel::WARNING, $message, $context);
+ }
+
+ /**
+ * Normal but significant events.
+ */
+ public function notice(string|\Stringable $message, array $context = []): void
+ {
+ $this->log(LogLevel::NOTICE, $message, $context);
+ }
+
+ /**
+ * Interesting events.
+ *
+ * Example: User logs in, SQL logs.
+ */
+ public function info(string|\Stringable $message, array $context = []): void
+ {
+ $this->log(LogLevel::INFO, $message, $context);
+ }
+
+ /**
+ * Detailed debug information.
+ */
+ public function debug(string|\Stringable $message, array $context = []): void
+ {
+ $this->log(LogLevel::DEBUG, $message, $context);
+ }
+
+ /**
+ * Logs with an arbitrary level.
+ *
+ * @param mixed $level
+ *
+ * @throws \Psr\Log\InvalidArgumentException
+ */
+ abstract public function log($level, string|\Stringable $message, array $context = []): void;
+}
diff --git a/lib/composer/vendor/psr/log/src/NullLogger.php b/lib/composer/vendor/psr/log/src/NullLogger.php
new file mode 100644
index 0000000..de0561e
--- /dev/null
+++ b/lib/composer/vendor/psr/log/src/NullLogger.php
@@ -0,0 +1,26 @@
+logger) { }`
+ * blocks.
+ */
+class NullLogger extends AbstractLogger
+{
+ /**
+ * Logs with an arbitrary level.
+ *
+ * @param mixed[] $context
+ *
+ * @throws \Psr\Log\InvalidArgumentException
+ */
+ public function log($level, string|\Stringable $message, array $context = []): void
+ {
+ // noop
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/LICENSE b/lib/composer/vendor/sabre/dav/LICENSE
new file mode 100644
index 0000000..fd3539e
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/LICENSE
@@ -0,0 +1,27 @@
+Copyright (C) 2007-2016 fruux GmbH (https://fruux.com/).
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of SabreDAV nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
diff --git a/lib/composer/vendor/sabre/dav/README.md b/lib/composer/vendor/sabre/dav/README.md
new file mode 100644
index 0000000..32ca1c3
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/README.md
@@ -0,0 +1,39 @@
+ sabre/dav
+=======================================================
+
+Introduction
+------------
+
+sabre/dav is the most popular WebDAV framework for PHP. Use it to create WebDAV, CalDAV and CardDAV servers.
+
+Full documentation can be found on the website:
+
+http://sabre.io/
+
+
+Build status
+------------
+
+| branch | status | PHP version |
+|------------|---------------------------------------------------------------------------|--------------------|
+| master 4.* |  | PHP 7.1 up, 8.0 up |
+| 3.2 | unmaintained | PHP 5.5 to 7.1 |
+| 3.1 | unmaintained | PHP 5.5 |
+| 3.0 | unmaintained | PHP 5.4 |
+| 2.1 | unmaintained | PHP 5.4 |
+| 2.0 | unmaintained | PHP 5.4 |
+| 1.8 | unmaintained | PHP 5.3 |
+| 1.7 | unmaintained | PHP 5.3 |
+| 1.6 | unmaintained | PHP 5.3 |
+
+Documentation
+-------------
+
+* [Introduction](http://sabre.io/dav/).
+* [Installation](http://sabre.io/dav/install/).
+
+
+Made at fruux
+-------------
+
+SabreDAV is being developed by [fruux](https://fruux.com/). Drop us a line for commercial services or enterprise support.
diff --git a/lib/composer/vendor/sabre/dav/bin/build.php b/lib/composer/vendor/sabre/dav/bin/build.php
new file mode 100755
index 0000000..4dd25d9
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/bin/build.php
@@ -0,0 +1,169 @@
+#!/usr/bin/env php
+ [
+ 'init', 'test', 'clean',
+ ],
+ 'markrelease' => [
+ 'init', 'test', 'clean',
+ ],
+ 'clean' => [],
+ 'test' => [
+ 'composerupdate',
+ ],
+ 'init' => [],
+ 'composerupdate' => [],
+ ];
+
+$default = 'buildzip';
+
+$baseDir = __DIR__.'/../';
+chdir($baseDir);
+
+$currentTask = $default;
+if ($argc > 1) {
+ $currentTask = $argv[1];
+}
+$version = null;
+if ($argc > 2) {
+ $version = $argv[2];
+}
+
+if (!isset($tasks[$currentTask])) {
+ echo 'Task not found: ', $currentTask, "\n";
+ exit(1);
+}
+
+// Creating the dependency graph
+$newTaskList = [];
+$oldTaskList = [$currentTask => true];
+
+while (count($oldTaskList) > 0) {
+ foreach ($oldTaskList as $task => $foo) {
+ if (!isset($tasks[$task])) {
+ echo 'Dependency not found: '.$task, "\n";
+ exit(1);
+ }
+ $dependencies = $tasks[$task];
+
+ $fullFilled = true;
+ foreach ($dependencies as $dependency) {
+ if (isset($newTaskList[$dependency])) {
+ // Already in the fulfilled task list.
+ continue;
+ } else {
+ $oldTaskList[$dependency] = true;
+ $fullFilled = false;
+ }
+ }
+ if ($fullFilled) {
+ unset($oldTaskList[$task]);
+ $newTaskList[$task] = 1;
+ }
+ }
+}
+
+foreach (array_keys($newTaskList) as $task) {
+ echo 'task: '.$task, "\n";
+ call_user_func($task);
+ echo "\n";
+}
+
+function init()
+{
+ global $version;
+ if (!$version) {
+ include __DIR__.'/../vendor/autoload.php';
+ $version = Sabre\DAV\Version::VERSION;
+ }
+
+ echo ' Building sabre/dav '.$version, "\n";
+}
+
+function clean()
+{
+ global $baseDir;
+ echo " Removing build files\n";
+ $outputDir = $baseDir.'/build/SabreDAV';
+ if (is_dir($outputDir)) {
+ system('rm -r '.$baseDir.'/build/SabreDAV');
+ }
+}
+
+function composerupdate()
+{
+ global $baseDir;
+ echo " Updating composer packages to latest version\n\n";
+ system('cd '.$baseDir.'; composer update');
+}
+
+function test()
+{
+ global $baseDir;
+
+ echo " Running all unittests.\n";
+ echo " This may take a while.\n\n";
+ system(__DIR__.'/phpunit --configuration '.$baseDir.'/tests/phpunit.xml.dist --stop-on-failure', $code);
+ if (0 != $code) {
+ echo "PHPUnit reported error code $code\n";
+ exit(1);
+ }
+}
+
+function buildzip()
+{
+ global $baseDir, $version;
+ echo " Generating composer.json\n";
+
+ $input = json_decode(file_get_contents(__DIR__.'/../composer.json'), true);
+ $newComposer = [
+ 'require' => $input['require'],
+ 'config' => [
+ 'bin-dir' => './bin',
+ ],
+ 'prefer-stable' => true,
+ 'minimum-stability' => 'alpha',
+ ];
+ unset(
+ $newComposer['require']['sabre/vobject'],
+ $newComposer['require']['sabre/http'],
+ $newComposer['require']['sabre/uri'],
+ $newComposer['require']['sabre/event']
+ );
+ $newComposer['require']['sabre/dav'] = $version;
+ mkdir('build/SabreDAV');
+ file_put_contents('build/SabreDAV/composer.json', json_encode($newComposer, JSON_PRETTY_PRINT));
+
+ echo " Downloading dependencies\n";
+ system('cd build/SabreDAV; composer install -n', $code);
+ if (0 !== $code) {
+ echo "Composer reported error code $code\n";
+ exit(1);
+ }
+
+ echo " Removing pointless files\n";
+ unlink('build/SabreDAV/composer.json');
+ unlink('build/SabreDAV/composer.lock');
+
+ echo " Moving important files to the root of the project\n";
+
+ $fileNames = [
+ 'CHANGELOG.md',
+ 'LICENSE',
+ 'README.md',
+ 'examples',
+ ];
+ foreach ($fileNames as $fileName) {
+ echo " $fileName\n";
+ rename('build/SabreDAV/vendor/sabre/dav/'.$fileName, 'build/SabreDAV/'.$fileName);
+ }
+
+ //
+
+ echo "\n";
+ echo "Zipping the sabredav distribution\n\n";
+ system('cd build; zip -qr sabredav-'.$version.'.zip SabreDAV');
+
+ echo 'Done.';
+}
diff --git a/lib/composer/vendor/sabre/dav/bin/migrateto20.php b/lib/composer/vendor/sabre/dav/bin/migrateto20.php
new file mode 100755
index 0000000..fb24fe5
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/bin/migrateto20.php
@@ -0,0 +1,414 @@
+#!/usr/bin/env php
+setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
+
+$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
+
+switch ($driver) {
+ case 'mysql':
+ echo "Detected MySQL.\n";
+ break;
+ case 'sqlite':
+ echo "Detected SQLite.\n";
+ break;
+ default:
+ echo 'Error: unsupported driver: '.$driver."\n";
+ exit(-1);
+}
+
+foreach (['calendar', 'addressbook'] as $itemType) {
+ $tableName = $itemType.'s';
+ $tableNameOld = $tableName.'_old';
+ $changesTable = $itemType.'changes';
+
+ echo "Upgrading '$tableName'\n";
+
+ // The only cross-db way to do this, is to just fetch a single record.
+ $row = $pdo->query("SELECT * FROM $tableName LIMIT 1")->fetch();
+
+ if (!$row) {
+ echo "No records were found in the '$tableName' table.\n";
+ echo "\n";
+ echo "We're going to rename the old table to $tableNameOld (just in case).\n";
+ echo "and re-create the new table.\n";
+
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec("RENAME TABLE $tableName TO $tableNameOld");
+ switch ($itemType) {
+ case 'calendar':
+ $pdo->exec("
+ CREATE TABLE calendars (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ principaluri VARCHAR(100),
+ displayname VARCHAR(100),
+ uri VARCHAR(200),
+ synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1',
+ description TEXT,
+ calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ calendarcolor VARCHAR(10),
+ timezone TEXT,
+ components VARCHAR(20),
+ transparent TINYINT(1) NOT NULL DEFAULT '0',
+ UNIQUE(principaluri, uri)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ ");
+ break;
+ case 'addressbook':
+ $pdo->exec("
+ CREATE TABLE addressbooks (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ principaluri VARCHAR(255),
+ displayname VARCHAR(255),
+ uri VARCHAR(200),
+ description TEXT,
+ synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1',
+ UNIQUE(principaluri, uri)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ ");
+ break;
+ }
+ break;
+
+ case 'sqlite':
+ $pdo->exec("ALTER TABLE $tableName RENAME TO $tableNameOld");
+
+ switch ($itemType) {
+ case 'calendar':
+ $pdo->exec('
+ CREATE TABLE calendars (
+ id integer primary key asc,
+ principaluri text,
+ displayname text,
+ uri text,
+ synctoken integer,
+ description text,
+ calendarorder integer,
+ calendarcolor text,
+ timezone text,
+ components text,
+ transparent bool
+ );
+ ');
+ break;
+ case 'addressbook':
+ $pdo->exec('
+ CREATE TABLE addressbooks (
+ id integer primary key asc,
+ principaluri text,
+ displayname text,
+ uri text,
+ description text,
+ synctoken integer
+ );
+ ');
+
+ break;
+ }
+ break;
+ }
+ echo "Creation of 2.0 $tableName table is complete\n";
+ } else {
+ // Checking if there's a synctoken field already.
+ if (array_key_exists('synctoken', $row)) {
+ echo "The 'synctoken' field already exists in the $tableName table.\n";
+ echo "It's likely you already upgraded, so we're simply leaving\n";
+ echo "the $tableName table alone\n";
+ } else {
+ echo "1.8 table schema detected\n";
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec("ALTER TABLE $tableName ADD synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1'");
+ $pdo->exec("ALTER TABLE $tableName DROP ctag");
+ $pdo->exec("UPDATE $tableName SET synctoken = '1'");
+ break;
+ case 'sqlite':
+ $pdo->exec("ALTER TABLE $tableName ADD synctoken integer");
+ $pdo->exec("UPDATE $tableName SET synctoken = '1'");
+ echo "Note: there's no easy way to remove fields in sqlite.\n";
+ echo "The ctag field is no longer used, but it's kept in place\n";
+ break;
+ }
+
+ echo "Upgraded '$tableName' to 2.0 schema.\n";
+ }
+ }
+
+ try {
+ $pdo->query("SELECT * FROM $changesTable LIMIT 1");
+
+ echo "'$changesTable' already exists. Assuming that this part of the\n";
+ echo "upgrade was already completed.\n";
+ } catch (Exception $e) {
+ echo "Creating '$changesTable' table.\n";
+
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec("
+ CREATE TABLE $changesTable (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ uri VARCHAR(200) NOT NULL,
+ synctoken INT(11) UNSIGNED NOT NULL,
+ {$itemType}id INT(11) UNSIGNED NOT NULL,
+ operation TINYINT(1) NOT NULL,
+ INDEX {$itemType}id_synctoken ({$itemType}id, synctoken)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+ ");
+ break;
+ case 'sqlite':
+ $pdo->exec("
+
+ CREATE TABLE $changesTable (
+ id integer primary key asc,
+ uri text,
+ synctoken integer,
+ {$itemType}id integer,
+ operation bool
+ );
+
+ ");
+ $pdo->exec("CREATE INDEX {$itemType}id_synctoken ON $changesTable ({$itemType}id, synctoken);");
+ break;
+ }
+ }
+}
+
+try {
+ $pdo->query('SELECT * FROM calendarsubscriptions LIMIT 1');
+
+ echo "'calendarsubscriptions' already exists. Assuming that this part of the\n";
+ echo "upgrade was already completed.\n";
+} catch (Exception $e) {
+ echo "Creating calendarsubscriptions table.\n";
+
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec("
+CREATE TABLE calendarsubscriptions (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ uri VARCHAR(200) NOT NULL,
+ principaluri VARCHAR(100) NOT NULL,
+ source TEXT,
+ displayname VARCHAR(100),
+ refreshrate VARCHAR(10),
+ calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ calendarcolor VARCHAR(10),
+ striptodos TINYINT(1) NULL,
+ stripalarms TINYINT(1) NULL,
+ stripattachments TINYINT(1) NULL,
+ lastmodified INT(11) UNSIGNED,
+ UNIQUE(principaluri, uri)
+);
+ ");
+ break;
+ case 'sqlite':
+ $pdo->exec('
+
+CREATE TABLE calendarsubscriptions (
+ id integer primary key asc,
+ uri text,
+ principaluri text,
+ source text,
+ displayname text,
+ refreshrate text,
+ calendarorder integer,
+ calendarcolor text,
+ striptodos bool,
+ stripalarms bool,
+ stripattachments bool,
+ lastmodified int
+);
+ ');
+
+ $pdo->exec('CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri);');
+ break;
+ }
+}
+
+try {
+ $pdo->query('SELECT * FROM propertystorage LIMIT 1');
+
+ echo "'propertystorage' already exists. Assuming that this part of the\n";
+ echo "upgrade was already completed.\n";
+} catch (Exception $e) {
+ echo "Creating propertystorage table.\n";
+
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec('
+CREATE TABLE propertystorage (
+ id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ path VARBINARY(1024) NOT NULL,
+ name VARBINARY(100) NOT NULL,
+ value MEDIUMBLOB
+);
+ ');
+ $pdo->exec('
+CREATE UNIQUE INDEX path_property ON propertystorage (path(600), name(100));
+ ');
+ break;
+ case 'sqlite':
+ $pdo->exec('
+CREATE TABLE propertystorage (
+ id integer primary key asc,
+ path TEXT,
+ name TEXT,
+ value TEXT
+);
+ ');
+ $pdo->exec('
+CREATE UNIQUE INDEX path_property ON propertystorage (path, name);
+ ');
+
+ break;
+ }
+}
+
+echo "Upgrading cards table to 2.0 schema\n";
+
+try {
+ $create = false;
+ $row = $pdo->query('SELECT * FROM cards LIMIT 1')->fetch();
+ if (!$row) {
+ $random = mt_rand(1000, 9999);
+ echo "There was no data in the cards table, so we're re-creating it\n";
+ echo "The old table will be renamed to cards_old$random, just in case.\n";
+
+ $create = true;
+
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec("RENAME TABLE cards TO cards_old$random");
+ break;
+ case 'sqlite':
+ $pdo->exec("ALTER TABLE cards RENAME TO cards_old$random");
+ break;
+ }
+ }
+} catch (Exception $e) {
+ echo "Exception while checking cards table. Assuming that the table does not yet exist.\n";
+ echo 'Debug: ', $e->getMessage(), "\n";
+ $create = true;
+}
+
+if ($create) {
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec('
+CREATE TABLE cards (
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ addressbookid INT(11) UNSIGNED NOT NULL,
+ carddata MEDIUMBLOB,
+ uri VARCHAR(200),
+ lastmodified INT(11) UNSIGNED,
+ etag VARBINARY(32),
+ size INT(11) UNSIGNED NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+ ');
+ break;
+
+ case 'sqlite':
+ $pdo->exec('
+CREATE TABLE cards (
+ id integer primary key asc,
+ addressbookid integer,
+ carddata blob,
+ uri text,
+ lastmodified integer,
+ etag text,
+ size integer
+);
+ ');
+ break;
+ }
+} else {
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec('
+ ALTER TABLE cards
+ ADD etag VARBINARY(32),
+ ADD size INT(11) UNSIGNED NOT NULL;
+ ');
+ break;
+
+ case 'sqlite':
+ $pdo->exec('
+ ALTER TABLE cards ADD etag text;
+ ALTER TABLE cards ADD size integer;
+ ');
+ break;
+ }
+ echo "Reading all old vcards and populating etag and size fields.\n";
+ $result = $pdo->query('SELECT id, carddata FROM cards');
+ $stmt = $pdo->prepare('UPDATE cards SET etag = ?, size = ? WHERE id = ?');
+ while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
+ $stmt->execute([
+ md5($row['carddata']),
+ strlen($row['carddata']),
+ $row['id'],
+ ]);
+ }
+}
+
+echo "Upgrade to 2.0 schema completed.\n";
diff --git a/lib/composer/vendor/sabre/dav/bin/migrateto21.php b/lib/composer/vendor/sabre/dav/bin/migrateto21.php
new file mode 100755
index 0000000..2c15b0a
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/bin/migrateto21.php
@@ -0,0 +1,166 @@
+#!/usr/bin/env php
+setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
+
+$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
+
+switch ($driver) {
+ case 'mysql':
+ echo "Detected MySQL.\n";
+ break;
+ case 'sqlite':
+ echo "Detected SQLite.\n";
+ break;
+ default:
+ echo 'Error: unsupported driver: '.$driver."\n";
+ exit(-1);
+}
+
+echo "Upgrading 'calendarobjects'\n";
+$addUid = false;
+try {
+ $result = $pdo->query('SELECT * FROM calendarobjects LIMIT 1');
+ $row = $result->fetch(\PDO::FETCH_ASSOC);
+
+ if (!$row) {
+ echo "No data in table. Going to try to add the uid field anyway.\n";
+ $addUid = true;
+ } elseif (array_key_exists('uid', $row)) {
+ echo "uid field exists. Assuming that this part of the migration has\n";
+ echo "Already been completed.\n";
+ } else {
+ echo "2.0 schema detected.\n";
+ $addUid = true;
+ }
+} catch (Exception $e) {
+ echo "Could not find a calendarobjects table. Skipping this part of the\n";
+ echo "upgrade.\n";
+}
+
+if ($addUid) {
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec('ALTER TABLE calendarobjects ADD uid VARCHAR(200)');
+ break;
+ case 'sqlite':
+ $pdo->exec('ALTER TABLE calendarobjects ADD uid TEXT');
+ break;
+ }
+
+ $result = $pdo->query('SELECT id, calendardata FROM calendarobjects');
+ $stmt = $pdo->prepare('UPDATE calendarobjects SET uid = ? WHERE id = ?');
+ $counter = 0;
+
+ while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
+ try {
+ $vobj = \Sabre\VObject\Reader::read($row['calendardata']);
+ } catch (\Exception $e) {
+ echo "Warning! Item with id $row[id] could not be parsed!\n";
+ continue;
+ }
+ $uid = null;
+ $item = $vobj->getBaseComponent();
+ if (!isset($item->UID)) {
+ echo "Warning! Item with id $item[id] does NOT have a UID property and this is required.\n";
+ continue;
+ }
+ $uid = (string) $item->UID;
+ $stmt->execute([$uid, $row['id']]);
+ ++$counter;
+ }
+}
+
+echo "Creating 'schedulingobjects'\n";
+
+switch ($driver) {
+ case 'mysql':
+ $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects
+(
+ id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ principaluri VARCHAR(255),
+ calendardata MEDIUMBLOB,
+ uri VARCHAR(200),
+ lastmodified INT(11) UNSIGNED,
+ etag VARCHAR(32),
+ size INT(11) UNSIGNED NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ ');
+ break;
+
+ case 'sqlite':
+ $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects (
+ id integer primary key asc,
+ principaluri text,
+ calendardata blob,
+ uri text,
+ lastmodified integer,
+ etag text,
+ size integer
+)
+');
+ break;
+}
+
+echo "Done.\n";
+
+echo "Upgrade to 2.1 schema completed.\n";
diff --git a/lib/composer/vendor/sabre/dav/bin/migrateto30.php b/lib/composer/vendor/sabre/dav/bin/migrateto30.php
new file mode 100755
index 0000000..9798cad
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/bin/migrateto30.php
@@ -0,0 +1,161 @@
+#!/usr/bin/env php
+setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
+
+$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
+
+switch ($driver) {
+ case 'mysql':
+ echo "Detected MySQL.\n";
+ break;
+ case 'sqlite':
+ echo "Detected SQLite.\n";
+ break;
+ default:
+ echo 'Error: unsupported driver: '.$driver."\n";
+ exit(-1);
+}
+
+echo "Upgrading 'propertystorage'\n";
+$addValueType = false;
+try {
+ $result = $pdo->query('SELECT * FROM propertystorage LIMIT 1');
+ $row = $result->fetch(\PDO::FETCH_ASSOC);
+
+ if (!$row) {
+ echo "No data in table. Going to re-create the table.\n";
+ $random = mt_rand(1000, 9999);
+ echo "Renaming propertystorage -> propertystorage_old$random and creating new table.\n";
+
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec('RENAME TABLE propertystorage TO propertystorage_old'.$random);
+ $pdo->exec('
+ CREATE TABLE propertystorage (
+ id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ path VARBINARY(1024) NOT NULL,
+ name VARBINARY(100) NOT NULL,
+ valuetype INT UNSIGNED,
+ value MEDIUMBLOB
+ );
+ ');
+ $pdo->exec('CREATE UNIQUE INDEX path_property_'.$random.' ON propertystorage (path(600), name(100));');
+ break;
+ case 'sqlite':
+ $pdo->exec('ALTER TABLE propertystorage RENAME TO propertystorage_old'.$random);
+ $pdo->exec('
+CREATE TABLE propertystorage (
+ id integer primary key asc,
+ path text,
+ name text,
+ valuetype integer,
+ value blob
+);');
+
+ $pdo->exec('CREATE UNIQUE INDEX path_property_'.$random.' ON propertystorage (path, name);');
+ break;
+ }
+ } elseif (array_key_exists('valuetype', $row)) {
+ echo "valuetype field exists. Assuming that this part of the migration has\n";
+ echo "Already been completed.\n";
+ } else {
+ echo "2.1 schema detected. Going to perform upgrade.\n";
+ $addValueType = true;
+ }
+} catch (Exception $e) {
+ echo "Could not find a propertystorage table. Skipping this part of the\n";
+ echo "upgrade.\n";
+ echo $e->getMessage(), "\n";
+}
+
+if ($addValueType) {
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec('ALTER TABLE propertystorage ADD valuetype INT UNSIGNED');
+ break;
+ case 'sqlite':
+ $pdo->exec('ALTER TABLE propertystorage ADD valuetype INT');
+
+ break;
+ }
+
+ $pdo->exec('UPDATE propertystorage SET valuetype = 1 WHERE valuetype IS NULL ');
+}
+
+echo "Migrating vcardurl\n";
+
+$result = $pdo->query('SELECT id, uri, vcardurl FROM principals WHERE vcardurl IS NOT NULL');
+$stmt1 = $pdo->prepare('INSERT INTO propertystorage (path, name, valuetype, value) VALUES (?, ?, 3, ?)');
+
+while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
+ // Inserting the new record
+ $stmt1->execute([
+ 'addressbooks/'.basename($row['uri']),
+ '{http://calendarserver.org/ns/}me-card',
+ serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])),
+ ]);
+
+ echo serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl']));
+}
+
+echo "Done.\n";
+echo "Upgrade to 3.0 schema completed.\n";
diff --git a/lib/composer/vendor/sabre/dav/bin/migrateto32.php b/lib/composer/vendor/sabre/dav/bin/migrateto32.php
new file mode 100755
index 0000000..09ac55d
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/bin/migrateto32.php
@@ -0,0 +1,258 @@
+#!/usr/bin/env php
+setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
+
+$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
+
+switch ($driver) {
+ case 'mysql':
+ echo "Detected MySQL.\n";
+ break;
+ case 'sqlite':
+ echo "Detected SQLite.\n";
+ break;
+ default:
+ echo 'Error: unsupported driver: '.$driver."\n";
+ exit(-1);
+}
+
+echo "Creating 'calendarinstances'\n";
+$addValueType = false;
+try {
+ $result = $pdo->query('SELECT * FROM calendarinstances LIMIT 1');
+ $result->fetch(\PDO::FETCH_ASSOC);
+ echo "calendarinstances exists. Assuming this part of the migration has already been done.\n";
+} catch (Exception $e) {
+ echo "calendarinstances does not yet exist. Creating table and migrating data.\n";
+
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec(<<exec('
+INSERT INTO calendarinstances
+ (
+ calendarid,
+ principaluri,
+ access,
+ displayname,
+ uri,
+ description,
+ calendarorder,
+ calendarcolor,
+ transparent
+ )
+SELECT
+ id,
+ principaluri,
+ 1,
+ displayname,
+ uri,
+ description,
+ calendarorder,
+ calendarcolor,
+ transparent
+FROM calendars
+');
+ break;
+ case 'sqlite':
+ $pdo->exec(<<exec('
+INSERT INTO calendarinstances
+ (
+ calendarid,
+ principaluri,
+ access,
+ displayname,
+ uri,
+ description,
+ calendarorder,
+ calendarcolor,
+ transparent
+ )
+SELECT
+ id,
+ principaluri,
+ 1,
+ displayname,
+ uri,
+ description,
+ calendarorder,
+ calendarcolor,
+ transparent
+FROM calendars
+');
+ break;
+ }
+}
+try {
+ $result = $pdo->query('SELECT * FROM calendars LIMIT 1');
+ $row = $result->fetch(\PDO::FETCH_ASSOC);
+
+ if (!$row) {
+ echo "Source table is empty.\n";
+ $migrateCalendars = true;
+ }
+
+ $columnCount = count($row);
+ if (3 === $columnCount) {
+ echo "The calendars table has 3 columns already. Assuming this part of the migration was already done.\n";
+ $migrateCalendars = false;
+ } else {
+ echo 'The calendars table has '.$columnCount." columns.\n";
+ $migrateCalendars = true;
+ }
+} catch (Exception $e) {
+ echo "calendars table does not exist. This is a major problem. Exiting.\n";
+ exit(-1);
+}
+
+if ($migrateCalendars) {
+ $calendarBackup = 'calendars_3_1_'.$backupPostfix;
+ echo "Backing up 'calendars' to '", $calendarBackup, "'\n";
+
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec('RENAME TABLE calendars TO '.$calendarBackup);
+ break;
+ case 'sqlite':
+ $pdo->exec('ALTER TABLE calendars RENAME TO '.$calendarBackup);
+ break;
+ }
+
+ echo "Creating new calendars table.\n";
+ switch ($driver) {
+ case 'mysql':
+ $pdo->exec(<<exec(<<exec(<<0):
+ print "Bytes to go before we hit threshold:", bytes
+ else:
+ print "Threshold exceeded with:", -bytes, "bytes"
+ dir = os.listdir(cacheDir)
+ dir2 = []
+ for file in dir:
+ path = cacheDir + '/' + file
+ dir2.append({
+ "path" : path,
+ "atime": os.stat(path).st_atime,
+ "size" : os.stat(path).st_size
+ })
+
+ dir2.sort(lambda x,y: int(x["atime"]-y["atime"]))
+
+ filesunlinked = 0
+ gainedspace = 0
+
+ # Left is the amount of bytes that need to be freed up
+ # The default is the 'min_erase setting'
+ left = min_erase
+
+ # If the min_erase setting is lower than the amount of bytes over
+ # the threshold, we use that number instead.
+ if left < -bytes :
+ left = -bytes
+
+ print "Need to delete at least:", left;
+
+ for file in dir2:
+
+ # Only deleting files if we're not simulating
+ if not simulate: os.unlink(file["path"])
+ left = int(left - file["size"])
+ gainedspace = gainedspace + file["size"]
+ filesunlinked = filesunlinked + 1
+
+ if(left<0):
+ break
+
+ print "%d files deleted (%d bytes)" % (filesunlinked, gainedspace)
+
+
+ time.sleep(sleep)
+
+
+
+def main():
+ parser = OptionParser(
+ version="naturalselection v0.3",
+ description="Cache directory manager. Deletes cache entries based on accesstime and free space thresholds.\n" +
+ "This utility is distributed alongside SabreDAV.",
+ usage="usage: %prog [options] cacheDirectory",
+ )
+ parser.add_option(
+ '-s',
+ dest="simulate",
+ action="store_true",
+ help="Don't actually make changes, but just simulate the behaviour",
+ )
+ parser.add_option(
+ '-r','--runs',
+ help="How many times to check before exiting. -1 is infinite, which is the default",
+ type="int",
+ dest="runs",
+ default=-1
+ )
+ parser.add_option(
+ '-n','--interval',
+ help="Sleep time in seconds (default = 5)",
+ type="int",
+ dest="sleep",
+ default=5
+ )
+ parser.add_option(
+ '-l','--threshold',
+ help="Threshold in bytes (default = 10737418240, which is 10GB)",
+ type="int",
+ dest="threshold",
+ default=10737418240
+ )
+ parser.add_option(
+ '-m', '--min-erase',
+ help="Minimum number of bytes to erase when the threshold is reached. " +
+ "Setting this option higher will reduce the number of times the cache directory will need to be scanned. " +
+ "(the default is 1073741824, which is 1GB.)",
+ type="int",
+ dest="min_erase",
+ default=1073741824
+ )
+
+ options,args = parser.parse_args()
+ if len(args)<1:
+ parser.error("This utility requires at least 1 argument")
+ cacheDir = args[0]
+
+ print "Natural Selection"
+ print "Cache directory:", cacheDir
+ free = getfreespace(cacheDir);
+ print "Current free disk space:", free
+
+ runs = options.runs;
+ while runs!=0 :
+ run(
+ cacheDir,
+ sleep=options.sleep,
+ simulate=options.simulate,
+ threshold=options.threshold,
+ min_erase=options.min_erase
+ )
+ if runs>0:
+ runs = runs - 1
+
+if __name__ == '__main__' :
+ main()
diff --git a/lib/composer/vendor/sabre/dav/bin/sabredav b/lib/composer/vendor/sabre/dav/bin/sabredav
new file mode 100755
index 0000000..032371b
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/bin/sabredav
@@ -0,0 +1,2 @@
+#!/bin/sh
+php -S 0.0.0.0:8080 `dirname $0`/sabredav.php
diff --git a/lib/composer/vendor/sabre/dav/bin/sabredav.php b/lib/composer/vendor/sabre/dav/bin/sabredav.php
new file mode 100755
index 0000000..71047b8
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/bin/sabredav.php
@@ -0,0 +1,51 @@
+stream = fopen('php://stdout', 'w');
+ }
+
+ public function log($msg)
+ {
+ fwrite($this->stream, $msg."\n");
+ }
+}
+
+$log = new CliLog();
+
+if ('cli-server' !== php_sapi_name()) {
+ exit('This script is intended to run on the built-in php webserver');
+}
+
+// Finding composer
+
+$paths = [
+ __DIR__.'/../vendor/autoload.php',
+ __DIR__.'/../../../autoload.php',
+];
+
+foreach ($paths as $path) {
+ if (file_exists($path)) {
+ include $path;
+ break;
+ }
+}
+
+use Sabre\DAV;
+
+// Root
+$root = new DAV\FS\Directory(getcwd());
+
+// Setting up server.
+$server = new DAV\Server($root);
+
+// Browser plugin
+$server->addPlugin(new DAV\Browser\Plugin());
+
+$server->exec();
diff --git a/lib/composer/vendor/sabre/dav/composer.json b/lib/composer/vendor/sabre/dav/composer.json
new file mode 100644
index 0000000..3154173
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/composer.json
@@ -0,0 +1,81 @@
+{
+ "name": "sabre/dav",
+ "type": "library",
+ "description": "WebDAV Framework for PHP",
+ "keywords": ["Framework", "WebDAV", "CalDAV", "CardDAV", "iCalendar"],
+ "homepage": "http://sabre.io/",
+ "license" : "BSD-3-Clause",
+ "authors": [
+ {
+ "name": "Evert Pot",
+ "email": "me@evertpot.com",
+ "homepage" : "http://evertpot.com/",
+ "role" : "Developer"
+ }
+ ],
+ "require": {
+ "php": "^7.1.0 || ^8.0",
+ "sabre/vobject": "^4.2.1",
+ "sabre/event" : "^5.0",
+ "sabre/xml" : "^2.0.1",
+ "sabre/http" : "^5.0.5",
+ "sabre/uri" : "^2.0",
+ "ext-dom": "*",
+ "ext-pcre": "*",
+ "ext-spl": "*",
+ "ext-simplexml": "*",
+ "ext-mbstring" : "*",
+ "ext-ctype" : "*",
+ "ext-date" : "*",
+ "ext-iconv" : "*",
+ "lib-libxml" : ">=2.7.0",
+ "psr/log": "^1.0 || ^2.0 || ^3.0",
+ "ext-json": "*"
+ },
+ "require-dev" : {
+ "friendsofphp/php-cs-fixer": "^2.19",
+ "monolog/monolog": "^1.27 || ^2.0",
+ "phpstan/phpstan": "^0.12 || ^1.0",
+ "phpstan/phpstan-phpunit": "^1.0",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6"
+ },
+ "suggest" : {
+ "ext-curl" : "*",
+ "ext-pdo" : "*",
+ "ext-imap": "*"
+ },
+ "autoload": {
+ "psr-4" : {
+ "Sabre\\" : "lib/"
+ }
+ },
+ "autoload-dev" : {
+ "psr-4" : {
+ "Sabre\\" : "tests/Sabre/"
+ }
+ },
+ "support" : {
+ "forum" : "https://groups.google.com/group/sabredav-discuss",
+ "source" : "https://github.com/fruux/sabre-dav"
+ },
+ "bin" : [
+ "bin/sabredav",
+ "bin/naturalselection"
+ ],
+ "scripts": {
+ "phpstan": [
+ "phpstan analyse lib tests"
+ ],
+ "cs-fixer": [
+ "php-cs-fixer fix"
+ ],
+ "phpunit": [
+ "phpunit --configuration tests/phpunit.xml"
+ ],
+ "test": [
+ "composer phpstan",
+ "composer cs-fixer",
+ "composer phpunit"
+ ]
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php
new file mode 100644
index 0000000..c761bff
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/AbstractBackend.php
@@ -0,0 +1,216 @@
+getCalendarObject($calendarId, $uri);
+ }, $uris);
+ }
+
+ /**
+ * Performs a calendar-query on the contents of this calendar.
+ *
+ * The calendar-query is defined in RFC4791 : CalDAV. Using the
+ * calendar-query it is possible for a client to request a specific set of
+ * object, based on contents of iCalendar properties, date-ranges and
+ * iCalendar component types (VTODO, VEVENT).
+ *
+ * This method should just return a list of (relative) urls that match this
+ * query.
+ *
+ * The list of filters are specified as an array. The exact array is
+ * documented by \Sabre\CalDAV\CalendarQueryParser.
+ *
+ * Note that it is extremely likely that getCalendarObject for every path
+ * returned from this method will be called almost immediately after. You
+ * may want to anticipate this to speed up these requests.
+ *
+ * This method provides a default implementation, which parses *all* the
+ * iCalendar objects in the specified calendar.
+ *
+ * This default may well be good enough for personal use, and calendars
+ * that aren't very large. But if you anticipate high usage, big calendars
+ * or high loads, you are strongly advised to optimize certain paths.
+ *
+ * The best way to do so is override this method and to optimize
+ * specifically for 'common filters'.
+ *
+ * Requests that are extremely common are:
+ * * requests for just VEVENTS
+ * * requests for just VTODO
+ * * requests with a time-range-filter on either VEVENT or VTODO.
+ *
+ * ..and combinations of these requests. It may not be worth it to try to
+ * handle every possible situation and just rely on the (relatively
+ * easy to use) CalendarQueryValidator to handle the rest.
+ *
+ * Note that especially time-range-filters may be difficult to parse. A
+ * time-range filter specified on a VEVENT must for instance also handle
+ * recurrence rules correctly.
+ * A good example of how to interpret all these filters can also simply
+ * be found in \Sabre\CalDAV\CalendarQueryFilter. This class is as correct
+ * as possible, so it gives you a good idea on what type of stuff you need
+ * to think of.
+ *
+ * @param mixed $calendarId
+ *
+ * @return array
+ */
+ public function calendarQuery($calendarId, array $filters)
+ {
+ $result = [];
+ $objects = $this->getCalendarObjects($calendarId);
+
+ foreach ($objects as $object) {
+ if ($this->validateFilterForObject($object, $filters)) {
+ $result[] = $object['uri'];
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * This method validates if a filter (as passed to calendarQuery) matches
+ * the given object.
+ *
+ * @return bool
+ */
+ protected function validateFilterForObject(array $object, array $filters)
+ {
+ // Unfortunately, setting the 'calendardata' here is optional. If
+ // it was excluded, we actually need another call to get this as
+ // well.
+ if (!isset($object['calendardata'])) {
+ $object = $this->getCalendarObject($object['calendarid'], $object['uri']);
+ }
+
+ $vObject = VObject\Reader::read($object['calendardata']);
+
+ $validator = new CalDAV\CalendarQueryValidator();
+ $result = $validator->validate($vObject, $filters);
+
+ // Destroy circular references so PHP will GC the object.
+ $vObject->destroy();
+
+ return $result;
+ }
+
+ /**
+ * Searches through all of a users calendars and calendar objects to find
+ * an object with a specific UID.
+ *
+ * This method should return the path to this object, relative to the
+ * calendar home, so this path usually only contains two parts:
+ *
+ * calendarpath/objectpath.ics
+ *
+ * If the uid is not found, return null.
+ *
+ * This method should only consider * objects that the principal owns, so
+ * any calendars owned by other principals that also appear in this
+ * collection should be ignored.
+ *
+ * @param string $principalUri
+ * @param string $uid
+ *
+ * @return string|null
+ */
+ public function getCalendarObjectByUID($principalUri, $uid)
+ {
+ // Note: this is a super slow naive implementation of this method. You
+ // are highly recommended to optimize it, if your backend allows it.
+ foreach ($this->getCalendarsForUser($principalUri) as $calendar) {
+ // We must ignore calendars owned by other principals.
+ if ($calendar['principaluri'] !== $principalUri) {
+ continue;
+ }
+
+ // Ignore calendars that are shared.
+ if (isset($calendar['{http://sabredav.org/ns}owner-principal']) && $calendar['{http://sabredav.org/ns}owner-principal'] !== $principalUri) {
+ continue;
+ }
+
+ $results = $this->calendarQuery(
+ $calendar['id'],
+ [
+ 'name' => 'VCALENDAR',
+ 'prop-filters' => [],
+ 'comp-filters' => [
+ [
+ 'name' => 'VEVENT',
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ 'comp-filters' => [],
+ 'prop-filters' => [
+ [
+ 'name' => 'UID',
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ 'text-match' => [
+ 'value' => $uid,
+ 'negate-condition' => false,
+ 'collation' => 'i;octet',
+ ],
+ 'param-filters' => [],
+ ],
+ ],
+ ],
+ ],
+ ]
+ );
+ if ($results) {
+ // We have a match
+ return $calendar['uri'].'/'.$results[0];
+ }
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php
new file mode 100644
index 0000000..ccaa251
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/BackendInterface.php
@@ -0,0 +1,273 @@
+ 'displayname',
+ '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'description',
+ '{urn:ietf:params:xml:ns:caldav}calendar-timezone' => 'timezone',
+ '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder',
+ '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor',
+ ];
+
+ /**
+ * List of subscription properties, and how they map to database fieldnames.
+ *
+ * @var array
+ */
+ public $subscriptionPropertyMap = [
+ '{DAV:}displayname' => 'displayname',
+ '{http://apple.com/ns/ical/}refreshrate' => 'refreshrate',
+ '{http://apple.com/ns/ical/}calendar-order' => 'calendarorder',
+ '{http://apple.com/ns/ical/}calendar-color' => 'calendarcolor',
+ '{http://calendarserver.org/ns/}subscribed-strip-todos' => 'striptodos',
+ '{http://calendarserver.org/ns/}subscribed-strip-alarms' => 'stripalarms',
+ '{http://calendarserver.org/ns/}subscribed-strip-attachments' => 'stripattachments',
+ ];
+
+ /**
+ * Creates the backend.
+ */
+ public function __construct(\PDO $pdo)
+ {
+ $this->pdo = $pdo;
+ }
+
+ /**
+ * Returns a list of calendars for a principal.
+ *
+ * Every project is an array with the following keys:
+ * * id, a unique id that will be used by other functions to modify the
+ * calendar. This can be the same as the uri or a database key.
+ * * uri. This is just the 'base uri' or 'filename' of the calendar.
+ * * principaluri. The owner of the calendar. Almost always the same as
+ * principalUri passed to this method.
+ *
+ * Furthermore it can contain webdav properties in clark notation. A very
+ * common one is '{DAV:}displayname'.
+ *
+ * Many clients also require:
+ * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set
+ * For this property, you can just return an instance of
+ * Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet.
+ *
+ * If you return {http://sabredav.org/ns}read-only and set the value to 1,
+ * ACL will automatically be put in read-only mode.
+ *
+ * @param string $principalUri
+ *
+ * @return array
+ */
+ public function getCalendarsForUser($principalUri)
+ {
+ $fields = array_values($this->propertyMap);
+ $fields[] = 'calendarid';
+ $fields[] = 'uri';
+ $fields[] = 'synctoken';
+ $fields[] = 'components';
+ $fields[] = 'principaluri';
+ $fields[] = 'transparent';
+ $fields[] = 'access';
+
+ // Making fields a comma-delimited list
+ $fields = implode(', ', $fields);
+ $stmt = $this->pdo->prepare(<<calendarInstancesTableName}.id as id, $fields FROM {$this->calendarInstancesTableName}
+ LEFT JOIN {$this->calendarTableName} ON
+ {$this->calendarInstancesTableName}.calendarid = {$this->calendarTableName}.id
+WHERE principaluri = ? ORDER BY calendarorder ASC
+SQL
+ );
+ $stmt->execute([$principalUri]);
+
+ $calendars = [];
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $components = [];
+ if ($row['components']) {
+ $components = explode(',', $row['components']);
+ }
+
+ $calendar = [
+ 'id' => [(int) $row['calendarid'], (int) $row['id']],
+ 'uri' => $row['uri'],
+ 'principaluri' => $row['principaluri'],
+ '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}getctag' => 'http://sabre.io/ns/sync/'.($row['synctoken'] ? $row['synctoken'] : '0'),
+ '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
+ '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet($components),
+ '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp' => new CalDAV\Xml\Property\ScheduleCalendarTransp($row['transparent'] ? 'transparent' : 'opaque'),
+ 'share-resource-uri' => '/ns/share/'.$row['calendarid'],
+ ];
+
+ $calendar['share-access'] = (int) $row['access'];
+ // 1 = owner, 2 = readonly, 3 = readwrite
+ if ($row['access'] > 1) {
+ // We need to find more information about the original owner.
+ //$stmt2 = $this->pdo->prepare('SELECT principaluri FROM ' . $this->calendarInstancesTableName . ' WHERE access = 1 AND id = ?');
+ //$stmt2->execute([$row['id']]);
+
+ // read-only is for backwards compatibility. Might go away in
+ // the future.
+ $calendar['read-only'] = \Sabre\DAV\Sharing\Plugin::ACCESS_READ === (int) $row['access'];
+ }
+
+ foreach ($this->propertyMap as $xmlName => $dbName) {
+ $calendar[$xmlName] = $row[$dbName];
+ }
+
+ $calendars[] = $calendar;
+ }
+
+ return $calendars;
+ }
+
+ /**
+ * Creates a new calendar for a principal.
+ *
+ * If the creation was a success, an id must be returned that can be used
+ * to reference this calendar in other methods, such as updateCalendar.
+ *
+ * @param string $principalUri
+ * @param string $calendarUri
+ *
+ * @return string
+ */
+ public function createCalendar($principalUri, $calendarUri, array $properties)
+ {
+ $fieldNames = [
+ 'principaluri',
+ 'uri',
+ 'transparent',
+ 'calendarid',
+ ];
+ $values = [
+ ':principaluri' => $principalUri,
+ ':uri' => $calendarUri,
+ ':transparent' => 0,
+ ];
+
+ $sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
+ if (!isset($properties[$sccs])) {
+ // Default value
+ $components = 'VEVENT,VTODO';
+ } else {
+ if (!($properties[$sccs] instanceof CalDAV\Xml\Property\SupportedCalendarComponentSet)) {
+ throw new DAV\Exception('The '.$sccs.' property must be of type: \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet');
+ }
+ $components = implode(',', $properties[$sccs]->getValue());
+ }
+ $transp = '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp';
+ if (isset($properties[$transp])) {
+ $values[':transparent'] = 'transparent' === $properties[$transp]->getValue() ? 1 : 0;
+ }
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarTableName.' (synctoken, components) VALUES (1, ?)');
+ $stmt->execute([$components]);
+
+ $calendarId = $this->pdo->lastInsertId(
+ $this->calendarTableName.'_id_seq'
+ );
+
+ $values[':calendarid'] = $calendarId;
+
+ foreach ($this->propertyMap as $xmlName => $dbName) {
+ if (isset($properties[$xmlName])) {
+ $values[':'.$dbName] = $properties[$xmlName];
+ $fieldNames[] = $dbName;
+ }
+ }
+
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarInstancesTableName.' ('.implode(', ', $fieldNames).') VALUES ('.implode(', ', array_keys($values)).')');
+
+ $stmt->execute($values);
+
+ return [
+ $calendarId,
+ $this->pdo->lastInsertId($this->calendarInstancesTableName.'_id_seq'),
+ ];
+ }
+
+ /**
+ * Updates properties for a calendar.
+ *
+ * The list of mutations is stored in a Sabre\DAV\PropPatch object.
+ * To do the actual updates, you must tell this object which properties
+ * you're going to process with the handle() method.
+ *
+ * Calling the handle method is like telling the PropPatch object "I
+ * promise I can handle updating this property".
+ *
+ * Read the PropPatch documentation for more info and examples.
+ *
+ * @param mixed $calendarId
+ */
+ public function updateCalendar($calendarId, PropPatch $propPatch)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $supportedProperties = array_keys($this->propertyMap);
+ $supportedProperties[] = '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp';
+
+ $propPatch->handle($supportedProperties, function ($mutations) use ($calendarId, $instanceId) {
+ $newValues = [];
+ foreach ($mutations as $propertyName => $propertyValue) {
+ switch ($propertyName) {
+ case '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-calendar-transp':
+ $fieldName = 'transparent';
+ $newValues[$fieldName] = 'transparent' === $propertyValue->getValue();
+ break;
+ default:
+ $fieldName = $this->propertyMap[$propertyName];
+ $newValues[$fieldName] = $propertyValue;
+ break;
+ }
+ }
+ $valuesSql = [];
+ foreach ($newValues as $fieldName => $value) {
+ $valuesSql[] = $fieldName.' = ?';
+ }
+
+ $stmt = $this->pdo->prepare('UPDATE '.$this->calendarInstancesTableName.' SET '.implode(', ', $valuesSql).' WHERE id = ?');
+ $newValues['id'] = $instanceId;
+ $stmt->execute(array_values($newValues));
+
+ $this->addChange($calendarId, '', 2);
+
+ return true;
+ });
+ }
+
+ /**
+ * Delete a calendar and all it's objects.
+ *
+ * @param mixed $calendarId
+ */
+ public function deleteCalendar($calendarId)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $stmt = $this->pdo->prepare('SELECT access FROM '.$this->calendarInstancesTableName.' where id = ?');
+ $stmt->execute([$instanceId]);
+ $access = (int) $stmt->fetchColumn();
+
+ if (\Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $access) {
+ /**
+ * If the user is the owner of the calendar, we delete all data and all
+ * instances.
+ **/
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?');
+ $stmt->execute([$calendarId]);
+
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarChangesTableName.' WHERE calendarid = ?');
+ $stmt->execute([$calendarId]);
+
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE calendarid = ?');
+ $stmt->execute([$calendarId]);
+
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarTableName.' WHERE id = ?');
+ $stmt->execute([$calendarId]);
+ } else {
+ /**
+ * If it was an instance of a shared calendar, we only delete that
+ * instance.
+ */
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE id = ?');
+ $stmt->execute([$instanceId]);
+ }
+ }
+
+ /**
+ * Returns all calendar objects within a calendar.
+ *
+ * Every item contains an array with the following keys:
+ * * calendardata - The iCalendar-compatible calendar data
+ * * uri - a unique key which will be used to construct the uri. This can
+ * be any arbitrary string, but making sure it ends with '.ics' is a
+ * good idea. This is only the basename, or filename, not the full
+ * path.
+ * * lastmodified - a timestamp of the last modification time
+ * * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
+ * ' "abcdef"')
+ * * size - The size of the calendar objects, in bytes.
+ * * component - optional, a string containing the type of object, such
+ * as 'vevent' or 'vtodo'. If specified, this will be used to populate
+ * the Content-Type header.
+ *
+ * Note that the etag is optional, but it's highly encouraged to return for
+ * speed reasons.
+ *
+ * The calendardata is also optional. If it's not returned
+ * 'getCalendarObject' will be called later, which *is* expected to return
+ * calendardata.
+ *
+ * If neither etag or size are specified, the calendardata will be
+ * used/fetched to determine these numbers. If both are specified the
+ * amount of times this is needed is reduced by a great degree.
+ *
+ * @param mixed $calendarId
+ *
+ * @return array
+ */
+ public function getCalendarObjects($calendarId)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?');
+ $stmt->execute([$calendarId]);
+
+ $result = [];
+ foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
+ $result[] = [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'lastmodified' => (int) $row['lastmodified'],
+ 'etag' => '"'.$row['etag'].'"',
+ 'size' => (int) $row['size'],
+ 'component' => strtolower($row['componenttype']),
+ ];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns information from a single calendar object, based on it's object
+ * uri.
+ *
+ * The object uri is only the basename, or filename and not a full path.
+ *
+ * The returned array must have the same keys as getCalendarObjects. The
+ * 'calendardata' object is required here though, while it's not required
+ * for getCalendarObjects.
+ *
+ * This method must return null if the object did not exist.
+ *
+ * @param mixed $calendarId
+ * @param string $objectUri
+ *
+ * @return array|null
+ */
+ public function getCalendarObject($calendarId, $objectUri)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?');
+ $stmt->execute([$calendarId, $objectUri]);
+ $row = $stmt->fetch(\PDO::FETCH_ASSOC);
+
+ if (!$row) {
+ return null;
+ }
+
+ return [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'lastmodified' => (int) $row['lastmodified'],
+ 'etag' => '"'.$row['etag'].'"',
+ 'size' => (int) $row['size'],
+ 'calendardata' => $row['calendardata'],
+ 'component' => strtolower($row['componenttype']),
+ ];
+ }
+
+ /**
+ * Returns a list of calendar objects.
+ *
+ * This method should work identical to getCalendarObject, but instead
+ * return all the calendar objects in the list as an array.
+ *
+ * If the backend supports this, it may allow for some speed-ups.
+ *
+ * @param mixed $calendarId
+ *
+ * @return array
+ */
+ public function getMultipleCalendarObjects($calendarId, array $uris)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $result = [];
+ foreach (array_chunk($uris, 900) as $chunk) {
+ $query = 'SELECT id, uri, lastmodified, etag, calendarid, size, calendardata, componenttype FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri IN (';
+ // Inserting a whole bunch of question marks
+ $query .= implode(',', array_fill(0, count($chunk), '?'));
+ $query .= ')';
+
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute(array_merge([$calendarId], $chunk));
+
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $result[] = [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'lastmodified' => (int) $row['lastmodified'],
+ 'etag' => '"'.$row['etag'].'"',
+ 'size' => (int) $row['size'],
+ 'calendardata' => $row['calendardata'],
+ 'component' => strtolower($row['componenttype']),
+ ];
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Creates a new calendar object.
+ *
+ * The object uri is only the basename, or filename and not a full path.
+ *
+ * It is possible return an etag from this function, which will be used in
+ * the response to this PUT request. Note that the ETag must be surrounded
+ * by double-quotes.
+ *
+ * However, you should only really return this ETag if you don't mangle the
+ * calendar-data. If the result of a subsequent GET to this object is not
+ * the exact same as this request body, you should omit the ETag.
+ *
+ * @param mixed $calendarId
+ * @param string $objectUri
+ * @param string $calendarData
+ *
+ * @return string|null
+ */
+ public function createCalendarObject($calendarId, $objectUri, $calendarData)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $extraData = $this->getDenormalizedData($calendarData);
+
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarObjectTableName.' (calendarid, uri, calendardata, lastmodified, etag, size, componenttype, firstoccurence, lastoccurence, uid) VALUES (?,?,?,?,?,?,?,?,?,?)');
+ $stmt->execute([
+ $calendarId,
+ $objectUri,
+ $calendarData,
+ time(),
+ $extraData['etag'],
+ $extraData['size'],
+ $extraData['componentType'],
+ $extraData['firstOccurence'],
+ $extraData['lastOccurence'],
+ $extraData['uid'],
+ ]);
+ $this->addChange($calendarId, $objectUri, 1);
+
+ return '"'.$extraData['etag'].'"';
+ }
+
+ /**
+ * Updates an existing calendarobject, based on it's uri.
+ *
+ * The object uri is only the basename, or filename and not a full path.
+ *
+ * It is possible return an etag from this function, which will be used in
+ * the response to this PUT request. Note that the ETag must be surrounded
+ * by double-quotes.
+ *
+ * However, you should only really return this ETag if you don't mangle the
+ * calendar-data. If the result of a subsequent GET to this object is not
+ * the exact same as this request body, you should omit the ETag.
+ *
+ * @param mixed $calendarId
+ * @param string $objectUri
+ * @param string $calendarData
+ *
+ * @return string|null
+ */
+ public function updateCalendarObject($calendarId, $objectUri, $calendarData)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $extraData = $this->getDenormalizedData($calendarData);
+
+ $stmt = $this->pdo->prepare('UPDATE '.$this->calendarObjectTableName.' SET calendardata = ?, lastmodified = ?, etag = ?, size = ?, componenttype = ?, firstoccurence = ?, lastoccurence = ?, uid = ? WHERE calendarid = ? AND uri = ?');
+ $stmt->execute([$calendarData, time(), $extraData['etag'], $extraData['size'], $extraData['componentType'], $extraData['firstOccurence'], $extraData['lastOccurence'], $extraData['uid'], $calendarId, $objectUri]);
+
+ $this->addChange($calendarId, $objectUri, 2);
+
+ return '"'.$extraData['etag'].'"';
+ }
+
+ /**
+ * Parses some information from calendar objects, used for optimized
+ * calendar-queries.
+ *
+ * Returns an array with the following keys:
+ * * etag - An md5 checksum of the object without the quotes.
+ * * size - Size of the object in bytes
+ * * componentType - VEVENT, VTODO or VJOURNAL
+ * * firstOccurence
+ * * lastOccurence
+ * * uid - value of the UID property
+ *
+ * @param string $calendarData
+ *
+ * @return array
+ */
+ protected function getDenormalizedData($calendarData)
+ {
+ $vObject = VObject\Reader::read($calendarData);
+ $componentType = null;
+ $component = null;
+ $firstOccurence = null;
+ $lastOccurence = null;
+ $uid = null;
+ foreach ($vObject->getComponents() as $component) {
+ if ('VTIMEZONE' !== $component->name) {
+ $componentType = $component->name;
+ $uid = (string) $component->UID;
+ break;
+ }
+ }
+ if (!$componentType) {
+ throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component');
+ }
+ if ('VEVENT' === $componentType) {
+ $firstOccurence = $component->DTSTART->getDateTime()->getTimeStamp();
+ // Finding the last occurence is a bit harder
+ if (!isset($component->RRULE)) {
+ if (isset($component->DTEND)) {
+ $lastOccurence = $component->DTEND->getDateTime()->getTimeStamp();
+ } elseif (isset($component->DURATION)) {
+ $endDate = clone $component->DTSTART->getDateTime();
+ $endDate = $endDate->add(VObject\DateTimeParser::parse($component->DURATION->getValue()));
+ $lastOccurence = $endDate->getTimeStamp();
+ } elseif (!$component->DTSTART->hasTime()) {
+ $endDate = clone $component->DTSTART->getDateTime();
+ $endDate = $endDate->modify('+1 day');
+ $lastOccurence = $endDate->getTimeStamp();
+ } else {
+ $lastOccurence = $firstOccurence;
+ }
+ } else {
+ $it = new VObject\Recur\EventIterator($vObject, (string) $component->UID);
+ $maxDate = new \DateTime(self::MAX_DATE);
+ if ($it->isInfinite()) {
+ $lastOccurence = $maxDate->getTimeStamp();
+ } else {
+ $end = $it->getDtEnd();
+ while ($it->valid() && $end < $maxDate) {
+ $end = $it->getDtEnd();
+ $it->next();
+ }
+ $lastOccurence = $end->getTimeStamp();
+ }
+ }
+
+ // Ensure Occurence values are positive
+ if ($firstOccurence < 0) {
+ $firstOccurence = 0;
+ }
+ if ($lastOccurence < 0) {
+ $lastOccurence = 0;
+ }
+ }
+
+ // Destroy circular references to PHP will GC the object.
+ $vObject->destroy();
+
+ return [
+ 'etag' => md5($calendarData),
+ 'size' => strlen($calendarData),
+ 'componentType' => $componentType,
+ 'firstOccurence' => $firstOccurence,
+ 'lastOccurence' => $lastOccurence,
+ 'uid' => $uid,
+ ];
+ }
+
+ /**
+ * Deletes an existing calendar object.
+ *
+ * The object uri is only the basename, or filename and not a full path.
+ *
+ * @param mixed $calendarId
+ * @param string $objectUri
+ */
+ public function deleteCalendarObject($calendarId, $objectUri)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarObjectTableName.' WHERE calendarid = ? AND uri = ?');
+ $stmt->execute([$calendarId, $objectUri]);
+
+ $this->addChange($calendarId, $objectUri, 3);
+ }
+
+ /**
+ * Performs a calendar-query on the contents of this calendar.
+ *
+ * The calendar-query is defined in RFC4791 : CalDAV. Using the
+ * calendar-query it is possible for a client to request a specific set of
+ * object, based on contents of iCalendar properties, date-ranges and
+ * iCalendar component types (VTODO, VEVENT).
+ *
+ * This method should just return a list of (relative) urls that match this
+ * query.
+ *
+ * The list of filters are specified as an array. The exact array is
+ * documented by \Sabre\CalDAV\CalendarQueryParser.
+ *
+ * Note that it is extremely likely that getCalendarObject for every path
+ * returned from this method will be called almost immediately after. You
+ * may want to anticipate this to speed up these requests.
+ *
+ * This method provides a default implementation, which parses *all* the
+ * iCalendar objects in the specified calendar.
+ *
+ * This default may well be good enough for personal use, and calendars
+ * that aren't very large. But if you anticipate high usage, big calendars
+ * or high loads, you are strongly advised to optimize certain paths.
+ *
+ * The best way to do so is override this method and to optimize
+ * specifically for 'common filters'.
+ *
+ * Requests that are extremely common are:
+ * * requests for just VEVENTS
+ * * requests for just VTODO
+ * * requests with a time-range-filter on a VEVENT.
+ *
+ * ..and combinations of these requests. It may not be worth it to try to
+ * handle every possible situation and just rely on the (relatively
+ * easy to use) CalendarQueryValidator to handle the rest.
+ *
+ * Note that especially time-range-filters may be difficult to parse. A
+ * time-range filter specified on a VEVENT must for instance also handle
+ * recurrence rules correctly.
+ * A good example of how to interpret all these filters can also simply
+ * be found in \Sabre\CalDAV\CalendarQueryFilter. This class is as correct
+ * as possible, so it gives you a good idea on what type of stuff you need
+ * to think of.
+ *
+ * This specific implementation (for the PDO) backend optimizes filters on
+ * specific components, and VEVENT time-ranges.
+ *
+ * @param mixed $calendarId
+ *
+ * @return array
+ */
+ public function calendarQuery($calendarId, array $filters)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $componentType = null;
+ $requirePostFilter = true;
+ $timeRange = null;
+
+ // if no filters were specified, we don't need to filter after a query
+ if (!$filters['prop-filters'] && !$filters['comp-filters']) {
+ $requirePostFilter = false;
+ }
+
+ // Figuring out if there's a component filter
+ if (count($filters['comp-filters']) > 0 && !$filters['comp-filters'][0]['is-not-defined']) {
+ $componentType = $filters['comp-filters'][0]['name'];
+
+ // Checking if we need post-filters
+ $has_time_range = array_key_exists('time-range', $filters['comp-filters'][0]) && $filters['comp-filters'][0]['time-range'];
+ if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$has_time_range && !$filters['comp-filters'][0]['prop-filters']) {
+ $requirePostFilter = false;
+ }
+ // There was a time-range filter
+ if ('VEVENT' == $componentType && $has_time_range) {
+ $timeRange = $filters['comp-filters'][0]['time-range'];
+
+ // If start time OR the end time is not specified, we can do a
+ // 100% accurate mysql query.
+ if (!$filters['prop-filters'] && !$filters['comp-filters'][0]['comp-filters'] && !$filters['comp-filters'][0]['prop-filters'] && $timeRange) {
+ if ((array_key_exists('start', $timeRange) && !$timeRange['start']) || (array_key_exists('end', $timeRange) && !$timeRange['end'])) {
+ $requirePostFilter = false;
+ }
+ }
+ }
+ }
+
+ if ($requirePostFilter) {
+ $query = 'SELECT uri, calendardata FROM '.$this->calendarObjectTableName.' WHERE calendarid = :calendarid';
+ } else {
+ $query = 'SELECT uri FROM '.$this->calendarObjectTableName.' WHERE calendarid = :calendarid';
+ }
+
+ $values = [
+ 'calendarid' => $calendarId,
+ ];
+
+ if ($componentType) {
+ $query .= ' AND componenttype = :componenttype';
+ $values['componenttype'] = $componentType;
+ }
+
+ if ($timeRange && array_key_exists('start', $timeRange) && $timeRange['start']) {
+ $query .= ' AND lastoccurence > :startdate';
+ $values['startdate'] = $timeRange['start']->getTimeStamp();
+ }
+ if ($timeRange && array_key_exists('end', $timeRange) && $timeRange['end']) {
+ $query .= ' AND firstoccurence < :enddate';
+ $values['enddate'] = $timeRange['end']->getTimeStamp();
+ }
+
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute($values);
+
+ $result = [];
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ if ($requirePostFilter) {
+ if (!$this->validateFilterForObject($row, $filters)) {
+ continue;
+ }
+ }
+ $result[] = $row['uri'];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Searches through all of a users calendars and calendar objects to find
+ * an object with a specific UID.
+ *
+ * This method should return the path to this object, relative to the
+ * calendar home, so this path usually only contains two parts:
+ *
+ * calendarpath/objectpath.ics
+ *
+ * If the uid is not found, return null.
+ *
+ * This method should only consider * objects that the principal owns, so
+ * any calendars owned by other principals that also appear in this
+ * collection should be ignored.
+ *
+ * @param string $principalUri
+ * @param string $uid
+ *
+ * @return string|null
+ */
+ public function getCalendarObjectByUID($principalUri, $uid)
+ {
+ $query = <<calendarObjectTableName AS calendarobjects
+LEFT JOIN
+ $this->calendarInstancesTableName AS calendar_instances
+ ON calendarobjects.calendarid = calendar_instances.calendarid
+WHERE
+ calendar_instances.principaluri = ?
+ AND
+ calendarobjects.uid = ?
+ AND
+ calendar_instances.access = 1
+SQL;
+
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute([$principalUri, $uid]);
+
+ if ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ return $row['calendaruri'].'/'.$row['objecturi'];
+ }
+ }
+
+ /**
+ * The getChanges method returns all the changes that have happened, since
+ * the specified syncToken in the specified calendar.
+ *
+ * This function should return an array, such as the following:
+ *
+ * [
+ * 'syncToken' => 'The current synctoken',
+ * 'added' => [
+ * 'new.txt',
+ * ],
+ * 'modified' => [
+ * 'modified.txt',
+ * ],
+ * 'deleted' => [
+ * 'foo.php.bak',
+ * 'old.txt'
+ * ]
+ * ];
+ *
+ * The returned syncToken property should reflect the *current* syncToken
+ * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
+ * property this is needed here too, to ensure the operation is atomic.
+ *
+ * If the $syncToken argument is specified as null, this is an initial
+ * sync, and all members should be reported.
+ *
+ * The modified property is an array of nodenames that have changed since
+ * the last token.
+ *
+ * The deleted property is an array with nodenames, that have been deleted
+ * from collection.
+ *
+ * The $syncLevel argument is basically the 'depth' of the report. If it's
+ * 1, you only have to report changes that happened only directly in
+ * immediate descendants. If it's 2, it should also include changes from
+ * the nodes below the child collections. (grandchildren)
+ *
+ * The $limit argument allows a client to specify how many results should
+ * be returned at most. If the limit is not specified, it should be treated
+ * as infinite.
+ *
+ * If the limit (infinite or not) is higher than you're willing to return,
+ * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
+ *
+ * If the syncToken is expired (due to data cleanup) or unknown, you must
+ * return null.
+ *
+ * The limit is 'suggestive'. You are free to ignore it.
+ *
+ * @param mixed $calendarId
+ * @param string $syncToken
+ * @param int $syncLevel
+ * @param int $limit
+ *
+ * @return array|null
+ */
+ public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $result = [
+ 'added' => [],
+ 'modified' => [],
+ 'deleted' => [],
+ ];
+
+ if ($syncToken) {
+ $query = 'SELECT uri, operation, synctoken FROM '.$this->calendarChangesTableName.' WHERE synctoken >= ? AND calendarid = ? ORDER BY synctoken';
+ if ($limit > 0) {
+ // Fetch one more raw to detect result truncation
+ $query .= ' LIMIT '.((int) $limit + 1);
+ }
+
+ // Fetching all changes
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute([$syncToken, $calendarId]);
+
+ $changes = [];
+
+ // This loop ensures that any duplicates are overwritten, only the
+ // last change on a node is relevant.
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $changes[$row['uri']] = $row;
+ }
+ $currentToken = null;
+
+ $result_count = 0;
+ foreach ($changes as $uri => $operation) {
+ if (!is_null($limit) && $result_count >= $limit) {
+ $result['result_truncated'] = true;
+ break;
+ }
+
+ if (null === $currentToken || $currentToken < $operation['synctoken'] + 1) {
+ // SyncToken in CalDAV perspective is consistently the next number of the last synced change event in this class.
+ $currentToken = $operation['synctoken'] + 1;
+ }
+
+ ++$result_count;
+ switch ($operation['operation']) {
+ case 1:
+ $result['added'][] = $uri;
+ break;
+ case 2:
+ $result['modified'][] = $uri;
+ break;
+ case 3:
+ $result['deleted'][] = $uri;
+ break;
+ }
+ }
+
+ if (!is_null($currentToken)) {
+ $result['syncToken'] = $currentToken;
+ } else {
+ // This means returned value is equivalent to syncToken
+ $result['syncToken'] = $syncToken;
+ }
+ } else {
+ // Current synctoken
+ $stmt = $this->pdo->prepare('SELECT synctoken FROM '.$this->calendarTableName.' WHERE id = ?');
+ $stmt->execute([$calendarId]);
+ $currentToken = $stmt->fetchColumn(0);
+
+ if (is_null($currentToken)) {
+ return null;
+ }
+ $result['syncToken'] = $currentToken;
+
+ // No synctoken supplied, this is the initial sync.
+ $query = 'SELECT uri FROM '.$this->calendarObjectTableName.' WHERE calendarid = ?';
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute([$calendarId]);
+
+ $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Adds a change record to the calendarchanges table.
+ *
+ * @param mixed $calendarId
+ * @param string $objectUri
+ * @param int $operation 1 = add, 2 = modify, 3 = delete
+ */
+ protected function addChange($calendarId, $objectUri, $operation)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarChangesTableName.' (uri, synctoken, calendarid, operation) SELECT ?, synctoken, ?, ? FROM '.$this->calendarTableName.' WHERE id = ?');
+ $stmt->execute([
+ $objectUri,
+ $calendarId,
+ $operation,
+ $calendarId,
+ ]);
+ $stmt = $this->pdo->prepare('UPDATE '.$this->calendarTableName.' SET synctoken = synctoken + 1 WHERE id = ?');
+ $stmt->execute([
+ $calendarId,
+ ]);
+ }
+
+ /**
+ * Returns a list of subscriptions for a principal.
+ *
+ * Every subscription is an array with the following keys:
+ * * id, a unique id that will be used by other functions to modify the
+ * subscription. This can be the same as the uri or a database key.
+ * * uri. This is just the 'base uri' or 'filename' of the subscription.
+ * * principaluri. The owner of the subscription. Almost always the same as
+ * principalUri passed to this method.
+ * * source. Url to the actual feed
+ *
+ * Furthermore, all the subscription info must be returned too:
+ *
+ * 1. {DAV:}displayname
+ * 2. {http://apple.com/ns/ical/}refreshrate
+ * 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos
+ * should not be stripped).
+ * 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms
+ * should not be stripped).
+ * 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if
+ * attachments should not be stripped).
+ * 7. {http://apple.com/ns/ical/}calendar-color
+ * 8. {http://apple.com/ns/ical/}calendar-order
+ * 9. {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set
+ * (should just be an instance of
+ * Sabre\CalDAV\Property\SupportedCalendarComponentSet, with a bunch of
+ * default components).
+ *
+ * @param string $principalUri
+ *
+ * @return array
+ */
+ public function getSubscriptionsForUser($principalUri)
+ {
+ $fields = array_values($this->subscriptionPropertyMap);
+ $fields[] = 'id';
+ $fields[] = 'uri';
+ $fields[] = 'source';
+ $fields[] = 'principaluri';
+ $fields[] = 'lastmodified';
+
+ // Making fields a comma-delimited list
+ $fields = implode(', ', $fields);
+ $stmt = $this->pdo->prepare('SELECT '.$fields.' FROM '.$this->calendarSubscriptionsTableName.' WHERE principaluri = ? ORDER BY calendarorder ASC');
+ $stmt->execute([$principalUri]);
+
+ $subscriptions = [];
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $subscription = [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'principaluri' => $row['principaluri'],
+ 'source' => $row['source'],
+ 'lastmodified' => $row['lastmodified'],
+
+ '{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VEVENT']),
+ ];
+
+ foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) {
+ if (!is_null($row[$dbName])) {
+ $subscription[$xmlName] = $row[$dbName];
+ }
+ }
+
+ $subscriptions[] = $subscription;
+ }
+
+ return $subscriptions;
+ }
+
+ /**
+ * Creates a new subscription for a principal.
+ *
+ * If the creation was a success, an id must be returned that can be used to reference
+ * this subscription in other methods, such as updateSubscription.
+ *
+ * @param string $principalUri
+ * @param string $uri
+ *
+ * @return mixed
+ */
+ public function createSubscription($principalUri, $uri, array $properties)
+ {
+ $fieldNames = [
+ 'principaluri',
+ 'uri',
+ 'source',
+ 'lastmodified',
+ ];
+
+ if (!isset($properties['{http://calendarserver.org/ns/}source'])) {
+ throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions');
+ }
+
+ $values = [
+ ':principaluri' => $principalUri,
+ ':uri' => $uri,
+ ':source' => $properties['{http://calendarserver.org/ns/}source']->getHref(),
+ ':lastmodified' => time(),
+ ];
+
+ foreach ($this->subscriptionPropertyMap as $xmlName => $dbName) {
+ if (isset($properties[$xmlName])) {
+ $values[':'.$dbName] = $properties[$xmlName];
+ $fieldNames[] = $dbName;
+ }
+ }
+
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->calendarSubscriptionsTableName.' ('.implode(', ', $fieldNames).') VALUES ('.implode(', ', array_keys($values)).')');
+ $stmt->execute($values);
+
+ return $this->pdo->lastInsertId(
+ $this->calendarSubscriptionsTableName.'_id_seq'
+ );
+ }
+
+ /**
+ * Updates a subscription.
+ *
+ * The list of mutations is stored in a Sabre\DAV\PropPatch object.
+ * To do the actual updates, you must tell this object which properties
+ * you're going to process with the handle() method.
+ *
+ * Calling the handle method is like telling the PropPatch object "I
+ * promise I can handle updating this property".
+ *
+ * Read the PropPatch documentation for more info and examples.
+ *
+ * @param mixed $subscriptionId
+ */
+ public function updateSubscription($subscriptionId, PropPatch $propPatch)
+ {
+ $supportedProperties = array_keys($this->subscriptionPropertyMap);
+ $supportedProperties[] = '{http://calendarserver.org/ns/}source';
+
+ $propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {
+ $newValues = [];
+
+ foreach ($mutations as $propertyName => $propertyValue) {
+ if ('{http://calendarserver.org/ns/}source' === $propertyName) {
+ $newValues['source'] = $propertyValue->getHref();
+ } else {
+ $fieldName = $this->subscriptionPropertyMap[$propertyName];
+ $newValues[$fieldName] = $propertyValue;
+ }
+ }
+
+ // Now we're generating the sql query.
+ $valuesSql = [];
+ foreach ($newValues as $fieldName => $value) {
+ $valuesSql[] = $fieldName.' = ?';
+ }
+
+ $stmt = $this->pdo->prepare('UPDATE '.$this->calendarSubscriptionsTableName.' SET '.implode(', ', $valuesSql).', lastmodified = ? WHERE id = ?');
+ $newValues['lastmodified'] = time();
+ $newValues['id'] = $subscriptionId;
+ $stmt->execute(array_values($newValues));
+
+ return true;
+ });
+ }
+
+ /**
+ * Deletes a subscription.
+ *
+ * @param mixed $subscriptionId
+ */
+ public function deleteSubscription($subscriptionId)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->calendarSubscriptionsTableName.' WHERE id = ?');
+ $stmt->execute([$subscriptionId]);
+ }
+
+ /**
+ * Returns a single scheduling object.
+ *
+ * The returned array should contain the following elements:
+ * * uri - A unique basename for the object. This will be used to
+ * construct a full uri.
+ * * calendardata - The iCalendar object
+ * * lastmodified - The last modification date. Can be an int for a unix
+ * timestamp, or a PHP DateTime object.
+ * * etag - A unique token that must change if the object changed.
+ * * size - The size of the object, in bytes.
+ *
+ * @param string $principalUri
+ * @param string $objectUri
+ *
+ * @return array
+ */
+ public function getSchedulingObject($principalUri, $objectUri)
+ {
+ $stmt = $this->pdo->prepare('SELECT uri, calendardata, lastmodified, etag, size FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ? AND uri = ?');
+ $stmt->execute([$principalUri, $objectUri]);
+ $row = $stmt->fetch(\PDO::FETCH_ASSOC);
+
+ if (!$row) {
+ return null;
+ }
+
+ return [
+ 'uri' => $row['uri'],
+ 'calendardata' => $row['calendardata'],
+ 'lastmodified' => $row['lastmodified'],
+ 'etag' => '"'.$row['etag'].'"',
+ 'size' => (int) $row['size'],
+ ];
+ }
+
+ /**
+ * Returns all scheduling objects for the inbox collection.
+ *
+ * These objects should be returned as an array. Every item in the array
+ * should follow the same structure as returned from getSchedulingObject.
+ *
+ * The main difference is that 'calendardata' is optional.
+ *
+ * @param string $principalUri
+ *
+ * @return array
+ */
+ public function getSchedulingObjects($principalUri)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, calendardata, uri, lastmodified, etag, size FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ?');
+ $stmt->execute([$principalUri]);
+
+ $result = [];
+ foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
+ $result[] = [
+ 'calendardata' => $row['calendardata'],
+ 'uri' => $row['uri'],
+ 'lastmodified' => $row['lastmodified'],
+ 'etag' => '"'.$row['etag'].'"',
+ 'size' => (int) $row['size'],
+ ];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Deletes a scheduling object.
+ *
+ * @param string $principalUri
+ * @param string $objectUri
+ */
+ public function deleteSchedulingObject($principalUri, $objectUri)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->schedulingObjectTableName.' WHERE principaluri = ? AND uri = ?');
+ $stmt->execute([$principalUri, $objectUri]);
+ }
+
+ /**
+ * Creates a new scheduling object. This should land in a users' inbox.
+ *
+ * @param string $principalUri
+ * @param string $objectUri
+ * @param string|resource $objectData
+ */
+ public function createSchedulingObject($principalUri, $objectUri, $objectData)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->schedulingObjectTableName.' (principaluri, calendardata, uri, lastmodified, etag, size) VALUES (?, ?, ?, ?, ?, ?)');
+
+ if (is_resource($objectData)) {
+ $objectData = stream_get_contents($objectData);
+ }
+
+ $stmt->execute([$principalUri, $objectData, $objectUri, time(), md5($objectData), strlen($objectData)]);
+ }
+
+ /**
+ * Updates the list of shares.
+ *
+ * @param mixed $calendarId
+ * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees
+ */
+ public function updateInvites($calendarId, array $sharees)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to $calendarId is expected to be an array with a calendarId and an instanceId');
+ }
+ $currentInvites = $this->getInvites($calendarId);
+ list($calendarId, $instanceId) = $calendarId;
+
+ $removeStmt = $this->pdo->prepare('DELETE FROM '.$this->calendarInstancesTableName.' WHERE calendarid = ? AND share_href = ? AND access IN (2,3)');
+ $updateStmt = $this->pdo->prepare('UPDATE '.$this->calendarInstancesTableName.' SET access = ?, share_displayname = ?, share_invitestatus = ? WHERE calendarid = ? AND share_href = ?');
+
+ $insertStmt = $this->pdo->prepare('
+INSERT INTO '.$this->calendarInstancesTableName.'
+ (
+ calendarid,
+ principaluri,
+ access,
+ displayname,
+ uri,
+ description,
+ calendarorder,
+ calendarcolor,
+ timezone,
+ transparent,
+ share_href,
+ share_displayname,
+ share_invitestatus
+ )
+ SELECT
+ ?,
+ ?,
+ ?,
+ displayname,
+ ?,
+ description,
+ calendarorder,
+ calendarcolor,
+ timezone,
+ 1,
+ ?,
+ ?,
+ ?
+ FROM '.$this->calendarInstancesTableName.' WHERE id = ?');
+
+ foreach ($sharees as $sharee) {
+ if (\Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS === $sharee->access) {
+ // if access was set no NOACCESS, it means access for an
+ // existing sharee was removed.
+ $removeStmt->execute([$calendarId, $sharee->href]);
+ continue;
+ }
+
+ if (is_null($sharee->principal)) {
+ // If the server could not determine the principal automatically,
+ // we will mark the invite status as invalid.
+ $sharee->inviteStatus = \Sabre\DAV\Sharing\Plugin::INVITE_INVALID;
+ } else {
+ // Because sabre/dav does not yet have an invitation system,
+ // every invite is automatically accepted for now.
+ $sharee->inviteStatus = \Sabre\DAV\Sharing\Plugin::INVITE_ACCEPTED;
+ }
+
+ foreach ($currentInvites as $oldSharee) {
+ if ($oldSharee->href === $sharee->href) {
+ // This is an update
+ $sharee->properties = array_merge(
+ $oldSharee->properties,
+ $sharee->properties
+ );
+ $updateStmt->execute([
+ $sharee->access,
+ isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null,
+ $sharee->inviteStatus ?: $oldSharee->inviteStatus,
+ $calendarId,
+ $sharee->href,
+ ]);
+ continue 2;
+ }
+ }
+ // If we got here, it means it was a new sharee
+ $insertStmt->execute([
+ $calendarId,
+ $sharee->principal,
+ $sharee->access,
+ \Sabre\DAV\UUIDUtil::getUUID(),
+ $sharee->href,
+ isset($sharee->properties['{DAV:}displayname']) ? $sharee->properties['{DAV:}displayname'] : null,
+ $sharee->inviteStatus ?: \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE,
+ $instanceId,
+ ]);
+ }
+ }
+
+ /**
+ * Returns the list of people whom a calendar is shared with.
+ *
+ * Every item in the returned list must be a Sharee object with at
+ * least the following properties set:
+ * $href
+ * $shareAccess
+ * $inviteStatus
+ *
+ * and optionally:
+ * $properties
+ *
+ * @param mixed $calendarId
+ *
+ * @return \Sabre\DAV\Xml\Element\Sharee[]
+ */
+ public function getInvites($calendarId)
+ {
+ if (!is_array($calendarId)) {
+ throw new \InvalidArgumentException('The value passed to getInvites() is expected to be an array with a calendarId and an instanceId');
+ }
+ list($calendarId, $instanceId) = $calendarId;
+
+ $query = <<calendarInstancesTableName}
+WHERE
+ calendarid = ?
+SQL;
+
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute([$calendarId]);
+
+ $result = [];
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $result[] = new Sharee([
+ 'href' => isset($row['share_href']) ? $row['share_href'] : \Sabre\HTTP\encodePath($row['principaluri']),
+ 'access' => (int) $row['access'],
+ /// Everyone is always immediately accepted, for now.
+ 'inviteStatus' => (int) $row['share_invitestatus'],
+ 'properties' => !empty($row['share_displayname'])
+ ? ['{DAV:}displayname' => $row['share_displayname']]
+ : [],
+ 'principal' => $row['principaluri'],
+ ]);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Publishes a calendar.
+ *
+ * @param mixed $calendarId
+ * @param bool $value
+ */
+ public function setPublishStatus($calendarId, $value)
+ {
+ throw new DAV\Exception\NotImplemented('Not implemented');
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php
new file mode 100644
index 0000000..69467e5
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/SchedulingSupport.php
@@ -0,0 +1,66 @@
+pdo = $pdo;
+ }
+
+ /**
+ * Returns a list of calendars for a principal.
+ *
+ * Every project is an array with the following keys:
+ * * id, a unique id that will be used by other functions to modify the
+ * calendar. This can be the same as the uri or a database key.
+ * * uri. This is just the 'base uri' or 'filename' of the calendar.
+ * * principaluri. The owner of the calendar. Almost always the same as
+ * principalUri passed to this method.
+ *
+ * Furthermore it can contain webdav properties in clark notation. A very
+ * common one is '{DAV:}displayname'.
+ *
+ * Many clients also require:
+ * {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set
+ * For this property, you can just return an instance of
+ * Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet.
+ *
+ * If you return {http://sabredav.org/ns}read-only and set the value to 1,
+ * ACL will automatically be put in read-only mode.
+ *
+ * @param string $principalUri
+ *
+ * @return array
+ */
+ public function getCalendarsForUser($principalUri)
+ {
+ // Making fields a comma-delimited list
+ $stmt = $this->pdo->prepare('SELECT id, uri FROM simple_calendars WHERE principaluri = ? ORDER BY id ASC');
+ $stmt->execute([$principalUri]);
+
+ $calendars = [];
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $calendars[] = [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'principaluri' => $principalUri,
+ ];
+ }
+
+ return $calendars;
+ }
+
+ /**
+ * Creates a new calendar for a principal.
+ *
+ * If the creation was a success, an id must be returned that can be used
+ * to reference this calendar in other methods, such as updateCalendar.
+ *
+ * @param string $principalUri
+ * @param string $calendarUri
+ *
+ * @return string
+ */
+ public function createCalendar($principalUri, $calendarUri, array $properties)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO simple_calendars (principaluri, uri) VALUES (?, ?)');
+ $stmt->execute([$principalUri, $calendarUri]);
+
+ return $this->pdo->lastInsertId();
+ }
+
+ /**
+ * Delete a calendar and all it's objects.
+ *
+ * @param string $calendarId
+ */
+ public function deleteCalendar($calendarId)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM simple_calendarobjects WHERE calendarid = ?');
+ $stmt->execute([$calendarId]);
+
+ $stmt = $this->pdo->prepare('DELETE FROM simple_calendars WHERE id = ?');
+ $stmt->execute([$calendarId]);
+ }
+
+ /**
+ * Returns all calendar objects within a calendar.
+ *
+ * Every item contains an array with the following keys:
+ * * calendardata - The iCalendar-compatible calendar data
+ * * uri - a unique key which will be used to construct the uri. This can
+ * be any arbitrary string, but making sure it ends with '.ics' is a
+ * good idea. This is only the basename, or filename, not the full
+ * path.
+ * * lastmodified - a timestamp of the last modification time
+ * * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
+ * ' "abcdef"')
+ * * size - The size of the calendar objects, in bytes.
+ * * component - optional, a string containing the type of object, such
+ * as 'vevent' or 'vtodo'. If specified, this will be used to populate
+ * the Content-Type header.
+ *
+ * Note that the etag is optional, but it's highly encouraged to return for
+ * speed reasons.
+ *
+ * The calendardata is also optional. If it's not returned
+ * 'getCalendarObject' will be called later, which *is* expected to return
+ * calendardata.
+ *
+ * If neither etag or size are specified, the calendardata will be
+ * used/fetched to determine these numbers. If both are specified the
+ * amount of times this is needed is reduced by a great degree.
+ *
+ * @param string $calendarId
+ *
+ * @return array
+ */
+ public function getCalendarObjects($calendarId)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, uri, calendardata FROM simple_calendarobjects WHERE calendarid = ?');
+ $stmt->execute([$calendarId]);
+
+ $result = [];
+ foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
+ $result[] = [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'etag' => '"'.md5($row['calendardata']).'"',
+ 'calendarid' => $calendarId,
+ 'size' => strlen($row['calendardata']),
+ 'calendardata' => $row['calendardata'],
+ ];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns information from a single calendar object, based on it's object
+ * uri.
+ *
+ * The object uri is only the basename, or filename and not a full path.
+ *
+ * The returned array must have the same keys as getCalendarObjects. The
+ * 'calendardata' object is required here though, while it's not required
+ * for getCalendarObjects.
+ *
+ * This method must return null if the object did not exist.
+ *
+ * @param string $calendarId
+ * @param string $objectUri
+ *
+ * @return array|null
+ */
+ public function getCalendarObject($calendarId, $objectUri)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, uri, calendardata FROM simple_calendarobjects WHERE calendarid = ? AND uri = ?');
+ $stmt->execute([$calendarId, $objectUri]);
+ $row = $stmt->fetch(\PDO::FETCH_ASSOC);
+
+ if (!$row) {
+ return null;
+ }
+
+ return [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'etag' => '"'.md5($row['calendardata']).'"',
+ 'calendarid' => $calendarId,
+ 'size' => strlen($row['calendardata']),
+ 'calendardata' => $row['calendardata'],
+ ];
+ }
+
+ /**
+ * Creates a new calendar object.
+ *
+ * The object uri is only the basename, or filename and not a full path.
+ *
+ * It is possible return an etag from this function, which will be used in
+ * the response to this PUT request. Note that the ETag must be surrounded
+ * by double-quotes.
+ *
+ * However, you should only really return this ETag if you don't mangle the
+ * calendar-data. If the result of a subsequent GET to this object is not
+ * the exact same as this request body, you should omit the ETag.
+ *
+ * @param mixed $calendarId
+ * @param string $objectUri
+ * @param string $calendarData
+ *
+ * @return string|null
+ */
+ public function createCalendarObject($calendarId, $objectUri, $calendarData)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO simple_calendarobjects (calendarid, uri, calendardata) VALUES (?,?,?)');
+ $stmt->execute([
+ $calendarId,
+ $objectUri,
+ $calendarData,
+ ]);
+
+ return '"'.md5($calendarData).'"';
+ }
+
+ /**
+ * Updates an existing calendarobject, based on it's uri.
+ *
+ * The object uri is only the basename, or filename and not a full path.
+ *
+ * It is possible return an etag from this function, which will be used in
+ * the response to this PUT request. Note that the ETag must be surrounded
+ * by double-quotes.
+ *
+ * However, you should only really return this ETag if you don't mangle the
+ * calendar-data. If the result of a subsequent GET to this object is not
+ * the exact same as this request body, you should omit the ETag.
+ *
+ * @param mixed $calendarId
+ * @param string $objectUri
+ * @param string $calendarData
+ *
+ * @return string|null
+ */
+ public function updateCalendarObject($calendarId, $objectUri, $calendarData)
+ {
+ $stmt = $this->pdo->prepare('UPDATE simple_calendarobjects SET calendardata = ? WHERE calendarid = ? AND uri = ?');
+ $stmt->execute([$calendarData, $calendarId, $objectUri]);
+
+ return '"'.md5($calendarData).'"';
+ }
+
+ /**
+ * Deletes an existing calendar object.
+ *
+ * The object uri is only the basename, or filename and not a full path.
+ *
+ * @param string $calendarId
+ * @param string $objectUri
+ */
+ public function deleteCalendarObject($calendarId, $objectUri)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM simple_calendarobjects WHERE calendarid = ? AND uri = ?');
+ $stmt->execute([$calendarId, $objectUri]);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php
new file mode 100644
index 0000000..7655c2e
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Backend/SubscriptionSupport.php
@@ -0,0 +1,89 @@
+ 'The current synctoken',
+ * 'added' => [
+ * 'new.txt',
+ * ],
+ * 'modified' => [
+ * 'modified.txt',
+ * ],
+ * 'deleted' => [
+ * 'foo.php.bak',
+ * 'old.txt'
+ * ]
+ * );
+ *
+ * The returned syncToken property should reflect the *current* syncToken
+ * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
+ * property This is * needed here too, to ensure the operation is atomic.
+ *
+ * If the $syncToken argument is specified as null, this is an initial
+ * sync, and all members should be reported.
+ *
+ * The modified property is an array of nodenames that have changed since
+ * the last token.
+ *
+ * The deleted property is an array with nodenames, that have been deleted
+ * from collection.
+ *
+ * The $syncLevel argument is basically the 'depth' of the report. If it's
+ * 1, you only have to report changes that happened only directly in
+ * immediate descendants. If it's 2, it should also include changes from
+ * the nodes below the child collections. (grandchildren)
+ *
+ * The $limit argument allows a client to specify how many results should
+ * be returned at most. If the limit is not specified, it should be treated
+ * as infinite.
+ *
+ * If the limit (infinite or not) is higher than you're willing to return,
+ * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
+ *
+ * If the syncToken is expired (due to data cleanup) or unknown, you must
+ * return null.
+ *
+ * The limit is 'suggestive'. You are free to ignore it.
+ *
+ * @param string $calendarId
+ * @param string $syncToken
+ * @param int $syncLevel
+ * @param int $limit
+ *
+ * @return array|null
+ */
+ public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null);
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Calendar.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Calendar.php
new file mode 100644
index 0000000..ba8c704
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Calendar.php
@@ -0,0 +1,460 @@
+caldavBackend = $caldavBackend;
+ $this->calendarInfo = $calendarInfo;
+ }
+
+ /**
+ * Returns the name of the calendar.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->calendarInfo['uri'];
+ }
+
+ /**
+ * Updates properties on this node.
+ *
+ * This method received a PropPatch object, which contains all the
+ * information about the update.
+ *
+ * To update specific properties, call the 'handle' method on this object.
+ * Read the PropPatch documentation for more information.
+ */
+ public function propPatch(PropPatch $propPatch)
+ {
+ return $this->caldavBackend->updateCalendar($this->calendarInfo['id'], $propPatch);
+ }
+
+ /**
+ * Returns the list of properties.
+ *
+ * @param array $requestedProperties
+ *
+ * @return array
+ */
+ public function getProperties($requestedProperties)
+ {
+ $response = [];
+
+ foreach ($this->calendarInfo as $propName => $propValue) {
+ if (!is_null($propValue) && '{' === $propName[0]) {
+ $response[$propName] = $this->calendarInfo[$propName];
+ }
+ }
+
+ return $response;
+ }
+
+ /**
+ * Returns a calendar object.
+ *
+ * The contained calendar objects are for example Events or Todo's.
+ *
+ * @param string $name
+ *
+ * @return \Sabre\CalDAV\ICalendarObject
+ */
+ public function getChild($name)
+ {
+ $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
+
+ if (!$obj) {
+ throw new DAV\Exception\NotFound('Calendar object not found');
+ }
+ $obj['acl'] = $this->getChildACL();
+
+ return new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
+ }
+
+ /**
+ * Returns the full list of calendar objects.
+ *
+ * @return array
+ */
+ public function getChildren()
+ {
+ $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
+ $children = [];
+ foreach ($objs as $obj) {
+ $obj['acl'] = $this->getChildACL();
+ $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
+ }
+
+ return $children;
+ }
+
+ /**
+ * This method receives a list of paths in it's first argument.
+ * It must return an array with Node objects.
+ *
+ * If any children are not found, you do not have to return them.
+ *
+ * @param string[] $paths
+ *
+ * @return array
+ */
+ public function getMultipleChildren(array $paths)
+ {
+ $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
+ $children = [];
+ foreach ($objs as $obj) {
+ $obj['acl'] = $this->getChildACL();
+ $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
+ }
+
+ return $children;
+ }
+
+ /**
+ * Checks if a child-node exists.
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ public function childExists($name)
+ {
+ $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
+ if (!$obj) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Creates a new directory.
+ *
+ * We actually block this, as subdirectories are not allowed in calendars.
+ *
+ * @param string $name
+ */
+ public function createDirectory($name)
+ {
+ throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
+ }
+
+ /**
+ * Creates a new file.
+ *
+ * The contents of the new file must be a valid ICalendar string.
+ *
+ * @param string $name
+ * @param resource $data
+ *
+ * @return string|null
+ */
+ public function createFile($name, $data = null)
+ {
+ if (is_resource($data)) {
+ $data = stream_get_contents($data);
+ }
+
+ return $this->caldavBackend->createCalendarObject($this->calendarInfo['id'], $name, $data);
+ }
+
+ /**
+ * Deletes the calendar.
+ */
+ public function delete()
+ {
+ $this->caldavBackend->deleteCalendar($this->calendarInfo['id']);
+ }
+
+ /**
+ * Renames the calendar. Note that most calendars use the
+ * {DAV:}displayname to display a name to display a name.
+ *
+ * @param string $newName
+ */
+ public function setName($newName)
+ {
+ throw new DAV\Exception\MethodNotAllowed('Renaming calendars is not yet supported');
+ }
+
+ /**
+ * Returns the last modification date as a unix timestamp.
+ */
+ public function getLastModified()
+ {
+ return null;
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->calendarInfo['principaluri'];
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ $acl = [
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner().'/calendar-proxy-read',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy',
+ 'principal' => '{DAV:}authenticated',
+ 'protected' => true,
+ ],
+ ];
+ if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) {
+ $acl[] = [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+ }
+
+ return $acl;
+ }
+
+ /**
+ * This method returns the ACL's for calendar objects in this calendar.
+ * The result of this method automatically gets passed to the
+ * calendar-object nodes in the calendar.
+ *
+ * @return array
+ */
+ public function getChildACL()
+ {
+ $acl = [
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner().'/calendar-proxy-read',
+ 'protected' => true,
+ ],
+ ];
+ if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) {
+ $acl[] = [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+ }
+
+ return $acl;
+ }
+
+ /**
+ * Performs a calendar-query on the contents of this calendar.
+ *
+ * The calendar-query is defined in RFC4791 : CalDAV. Using the
+ * calendar-query it is possible for a client to request a specific set of
+ * object, based on contents of iCalendar properties, date-ranges and
+ * iCalendar component types (VTODO, VEVENT).
+ *
+ * This method should just return a list of (relative) urls that match this
+ * query.
+ *
+ * The list of filters are specified as an array. The exact array is
+ * documented by Sabre\CalDAV\CalendarQueryParser.
+ *
+ * @return array
+ */
+ public function calendarQuery(array $filters)
+ {
+ return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters);
+ }
+
+ /**
+ * This method returns the current sync-token for this collection.
+ * This can be any string.
+ *
+ * If null is returned from this function, the plugin assumes there's no
+ * sync information available.
+ *
+ * @return string|null
+ */
+ public function getSyncToken()
+ {
+ if (
+ $this->caldavBackend instanceof Backend\SyncSupport &&
+ isset($this->calendarInfo['{DAV:}sync-token'])
+ ) {
+ return $this->calendarInfo['{DAV:}sync-token'];
+ }
+ if (
+ $this->caldavBackend instanceof Backend\SyncSupport &&
+ isset($this->calendarInfo['{http://sabredav.org/ns}sync-token'])
+ ) {
+ return $this->calendarInfo['{http://sabredav.org/ns}sync-token'];
+ }
+ }
+
+ /**
+ * The getChanges method returns all the changes that have happened, since
+ * the specified syncToken and the current collection.
+ *
+ * This function should return an array, such as the following:
+ *
+ * [
+ * 'syncToken' => 'The current synctoken',
+ * 'added' => [
+ * 'new.txt',
+ * ],
+ * 'modified' => [
+ * 'modified.txt',
+ * ],
+ * 'deleted' => [
+ * 'foo.php.bak',
+ * 'old.txt'
+ * ],
+ * 'result_truncated' : true
+ * ];
+ *
+ * The syncToken property should reflect the *current* syncToken of the
+ * collection, as reported getSyncToken(). This is needed here too, to
+ * ensure the operation is atomic.
+ *
+ * If the syncToken is specified as null, this is an initial sync, and all
+ * members should be reported.
+ *
+ * If result is truncated due to server limitation or limit by client,
+ * set result_truncated to true, otherwise set to false or do not add the key.
+ *
+ * The modified property is an array of nodenames that have changed since
+ * the last token.
+ *
+ * The deleted property is an array with nodenames, that have been deleted
+ * from collection.
+ *
+ * The second argument is basically the 'depth' of the report. If it's 1,
+ * you only have to report changes that happened only directly in immediate
+ * descendants. If it's 2, it should also include changes from the nodes
+ * below the child collections. (grandchildren)
+ *
+ * The third (optional) argument allows a client to specify how many
+ * results should be returned at most. If the limit is not specified, it
+ * should be treated as infinite.
+ *
+ * If the limit (infinite or not) is higher than you're willing to return,
+ * the result should be truncated to fit the limit.
+ * Note that even when the result is truncated, syncToken must be consistent
+ * with the truncated result, not the result before truncation.
+ * (See RFC6578 Section 3.6 for detail)
+ *
+ * If the syncToken is expired (due to data cleanup) or unknown, you must
+ * return null.
+ *
+ * The limit is 'suggestive'. You are free to ignore it.
+ * TODO: RFC6578 Section 3.7 says that the server must fail when the server
+ * cannot truncate according to the limit, so it may not be just suggestive.
+ *
+ * @param string $syncToken
+ * @param int $syncLevel
+ * @param int $limit
+ *
+ * @return array|null
+ */
+ public function getChanges($syncToken, $syncLevel, $limit = null)
+ {
+ if (!$this->caldavBackend instanceof Backend\SyncSupport) {
+ return null;
+ }
+
+ return $this->caldavBackend->getChangesForCalendar(
+ $this->calendarInfo['id'],
+ $syncToken,
+ $syncLevel,
+ $limit
+ );
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarHome.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarHome.php
new file mode 100644
index 0000000..49c54a3
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarHome.php
@@ -0,0 +1,356 @@
+caldavBackend = $caldavBackend;
+ $this->principalInfo = $principalInfo;
+ }
+
+ /**
+ * Returns the name of this object.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ list(, $name) = Uri\split($this->principalInfo['uri']);
+
+ return $name;
+ }
+
+ /**
+ * Updates the name of this object.
+ *
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ throw new DAV\Exception\Forbidden();
+ }
+
+ /**
+ * Deletes this object.
+ */
+ public function delete()
+ {
+ throw new DAV\Exception\Forbidden();
+ }
+
+ /**
+ * Returns the last modification date.
+ *
+ * @return int
+ */
+ public function getLastModified()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new file under this object.
+ *
+ * This is currently not allowed
+ *
+ * @param string $name
+ * @param resource $data
+ */
+ public function createFile($name, $data = null)
+ {
+ throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported');
+ }
+
+ /**
+ * Creates a new directory under this object.
+ *
+ * This is currently not allowed.
+ *
+ * @param string $filename
+ */
+ public function createDirectory($filename)
+ {
+ throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported');
+ }
+
+ /**
+ * Returns a single calendar, by name.
+ *
+ * @param string $name
+ *
+ * @return Calendar
+ */
+ public function getChild($name)
+ {
+ // Special nodes
+ if ('inbox' === $name && $this->caldavBackend instanceof Backend\SchedulingSupport) {
+ return new Schedule\Inbox($this->caldavBackend, $this->principalInfo['uri']);
+ }
+ if ('outbox' === $name && $this->caldavBackend instanceof Backend\SchedulingSupport) {
+ return new Schedule\Outbox($this->principalInfo['uri']);
+ }
+ if ('notifications' === $name && $this->caldavBackend instanceof Backend\NotificationSupport) {
+ return new Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
+ }
+
+ // Calendars
+ foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
+ if ($calendar['uri'] === $name) {
+ if ($this->caldavBackend instanceof Backend\SharingSupport) {
+ return new SharedCalendar($this->caldavBackend, $calendar);
+ } else {
+ return new Calendar($this->caldavBackend, $calendar);
+ }
+ }
+ }
+
+ if ($this->caldavBackend instanceof Backend\SubscriptionSupport) {
+ foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
+ if ($subscription['uri'] === $name) {
+ return new Subscriptions\Subscription($this->caldavBackend, $subscription);
+ }
+ }
+ }
+
+ throw new NotFound('Node with name \''.$name.'\' could not be found');
+ }
+
+ /**
+ * Checks if a calendar exists.
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ public function childExists($name)
+ {
+ try {
+ return (bool) $this->getChild($name);
+ } catch (NotFound $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Returns a list of calendars.
+ *
+ * @return array
+ */
+ public function getChildren()
+ {
+ $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
+ $objs = [];
+ foreach ($calendars as $calendar) {
+ if ($this->caldavBackend instanceof Backend\SharingSupport) {
+ $objs[] = new SharedCalendar($this->caldavBackend, $calendar);
+ } else {
+ $objs[] = new Calendar($this->caldavBackend, $calendar);
+ }
+ }
+
+ if ($this->caldavBackend instanceof Backend\SchedulingSupport) {
+ $objs[] = new Schedule\Inbox($this->caldavBackend, $this->principalInfo['uri']);
+ $objs[] = new Schedule\Outbox($this->principalInfo['uri']);
+ }
+
+ // We're adding a notifications node, if it's supported by the backend.
+ if ($this->caldavBackend instanceof Backend\NotificationSupport) {
+ $objs[] = new Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
+ }
+
+ // If the backend supports subscriptions, we'll add those as well,
+ if ($this->caldavBackend instanceof Backend\SubscriptionSupport) {
+ foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
+ $objs[] = new Subscriptions\Subscription($this->caldavBackend, $subscription);
+ }
+ }
+
+ return $objs;
+ }
+
+ /**
+ * Creates a new calendar or subscription.
+ *
+ * @param string $name
+ *
+ * @throws DAV\Exception\InvalidResourceType
+ */
+ public function createExtendedCollection($name, MkCol $mkCol)
+ {
+ $isCalendar = false;
+ $isSubscription = false;
+ foreach ($mkCol->getResourceType() as $rt) {
+ switch ($rt) {
+ case '{DAV:}collection':
+ case '{http://calendarserver.org/ns/}shared-owner':
+ // ignore
+ break;
+ case '{urn:ietf:params:xml:ns:caldav}calendar':
+ $isCalendar = true;
+ break;
+ case '{http://calendarserver.org/ns/}subscribed':
+ $isSubscription = true;
+ break;
+ default:
+ throw new DAV\Exception\InvalidResourceType('Unknown resourceType: '.$rt);
+ }
+ }
+
+ $properties = $mkCol->getRemainingValues();
+ $mkCol->setRemainingResultCode(201);
+
+ if ($isSubscription) {
+ if (!$this->caldavBackend instanceof Backend\SubscriptionSupport) {
+ throw new DAV\Exception\InvalidResourceType('This backend does not support subscriptions');
+ }
+ $this->caldavBackend->createSubscription($this->principalInfo['uri'], $name, $properties);
+ } elseif ($isCalendar) {
+ $this->caldavBackend->createCalendar($this->principalInfo['uri'], $name, $properties);
+ } else {
+ throw new DAV\Exception\InvalidResourceType('You can only create calendars and subscriptions in this collection');
+ }
+ }
+
+ /**
+ * Returns the owner of the calendar home.
+ *
+ * @return string
+ */
+ public function getOwner()
+ {
+ return $this->principalInfo['uri'];
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ return [
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->principalInfo['uri'],
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->principalInfo['uri'],
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->principalInfo['uri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->principalInfo['uri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->principalInfo['uri'].'/calendar-proxy-read',
+ 'protected' => true,
+ ],
+ ];
+ }
+
+ /**
+ * This method is called when a user replied to a request to share.
+ *
+ * This method should return the url of the newly created calendar if the
+ * share was accepted.
+ *
+ * @param string $href The sharee who is replying (often a mailto: address)
+ * @param int $status One of the SharingPlugin::STATUS_* constants
+ * @param string $calendarUri The url to the calendar thats being shared
+ * @param string $inReplyTo The unique id this message is a response to
+ * @param string $summary A description of the reply
+ *
+ * @return string|null
+ */
+ public function shareReply($href, $status, $calendarUri, $inReplyTo, $summary = null)
+ {
+ if (!$this->caldavBackend instanceof Backend\SharingSupport) {
+ throw new DAV\Exception\NotImplemented('Sharing support is not implemented by this backend.');
+ }
+
+ return $this->caldavBackend->shareReply($href, $status, $calendarUri, $inReplyTo, $summary);
+ }
+
+ /**
+ * Searches through all of a users calendars and calendar objects to find
+ * an object with a specific UID.
+ *
+ * This method should return the path to this object, relative to the
+ * calendar home, so this path usually only contains two parts:
+ *
+ * calendarpath/objectpath.ics
+ *
+ * If the uid is not found, return null.
+ *
+ * This method should only consider * objects that the principal owns, so
+ * any calendars owned by other principals that also appear in this
+ * collection should be ignored.
+ *
+ * @param string $uid
+ *
+ * @return string|null
+ */
+ public function getCalendarObjectByUID($uid)
+ {
+ return $this->caldavBackend->getCalendarObjectByUID($this->principalInfo['uri'], $uid);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarObject.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarObject.php
new file mode 100644
index 0000000..671f4b5
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarObject.php
@@ -0,0 +1,223 @@
+caldavBackend = $caldavBackend;
+
+ if (!isset($objectData['uri'])) {
+ throw new \InvalidArgumentException('The objectData argument must contain an \'uri\' property');
+ }
+
+ $this->calendarInfo = $calendarInfo;
+ $this->objectData = $objectData;
+ }
+
+ /**
+ * Returns the uri for this object.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->objectData['uri'];
+ }
+
+ /**
+ * Returns the ICalendar-formatted object.
+ *
+ * @return string
+ */
+ public function get()
+ {
+ // Pre-populating the 'calendardata' is optional, if we don't have it
+ // already we fetch it from the backend.
+ if (!isset($this->objectData['calendardata'])) {
+ $this->objectData = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $this->objectData['uri']);
+ }
+
+ return $this->objectData['calendardata'];
+ }
+
+ /**
+ * Updates the ICalendar-formatted object.
+ *
+ * @param string|resource $calendarData
+ *
+ * @return string
+ */
+ public function put($calendarData)
+ {
+ if (is_resource($calendarData)) {
+ $calendarData = stream_get_contents($calendarData);
+ }
+ $etag = $this->caldavBackend->updateCalendarObject($this->calendarInfo['id'], $this->objectData['uri'], $calendarData);
+ $this->objectData['calendardata'] = $calendarData;
+ $this->objectData['etag'] = $etag;
+
+ return $etag;
+ }
+
+ /**
+ * Deletes the calendar object.
+ */
+ public function delete()
+ {
+ $this->caldavBackend->deleteCalendarObject($this->calendarInfo['id'], $this->objectData['uri']);
+ }
+
+ /**
+ * Returns the mime content-type.
+ *
+ * @return string
+ */
+ public function getContentType()
+ {
+ $mime = 'text/calendar; charset=utf-8';
+ if (isset($this->objectData['component']) && $this->objectData['component']) {
+ $mime .= '; component='.$this->objectData['component'];
+ }
+
+ return $mime;
+ }
+
+ /**
+ * Returns an ETag for this object.
+ *
+ * The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
+ *
+ * @return string
+ */
+ public function getETag()
+ {
+ if (isset($this->objectData['etag'])) {
+ return $this->objectData['etag'];
+ } else {
+ return '"'.md5($this->get()).'"';
+ }
+ }
+
+ /**
+ * Returns the last modification date as a unix timestamp.
+ *
+ * @return int
+ */
+ public function getLastModified()
+ {
+ return $this->objectData['lastmodified'];
+ }
+
+ /**
+ * Returns the size of this object in bytes.
+ *
+ * @return int
+ */
+ public function getSize()
+ {
+ if (array_key_exists('size', $this->objectData)) {
+ return $this->objectData['size'];
+ } else {
+ return strlen($this->get());
+ }
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->calendarInfo['principaluri'];
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ // An alternative acl may be specified in the object data.
+ if (isset($this->objectData['acl'])) {
+ return $this->objectData['acl'];
+ }
+
+ // The default ACL
+ return [
+ [
+ 'privilege' => '{DAV:}all',
+ 'principal' => $this->calendarInfo['principaluri'],
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}all',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
+ 'protected' => true,
+ ],
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php
new file mode 100644
index 0000000..ee525da
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarQueryValidator.php
@@ -0,0 +1,354 @@
+name !== $filters['name']) {
+ return false;
+ }
+
+ return
+ $this->validateCompFilters($vObject, $filters['comp-filters']) &&
+ $this->validatePropFilters($vObject, $filters['prop-filters']);
+ }
+
+ /**
+ * This method checks the validity of comp-filters.
+ *
+ * A list of comp-filters needs to be specified. Also the parent of the
+ * component we're checking should be specified, not the component to check
+ * itself.
+ *
+ * @return bool
+ */
+ protected function validateCompFilters(VObject\Component $parent, array $filters)
+ {
+ foreach ($filters as $filter) {
+ $isDefined = isset($parent->{$filter['name']});
+
+ if ($filter['is-not-defined']) {
+ if ($isDefined) {
+ return false;
+ } else {
+ continue;
+ }
+ }
+ if (!$isDefined) {
+ return false;
+ }
+
+ if (array_key_exists('time-range', $filter) && $filter['time-range']) {
+ foreach ($parent->{$filter['name']} as $subComponent) {
+ $start = null;
+ $end = null;
+ if (array_key_exists('start', $filter['time-range'])) {
+ $start = $filter['time-range']['start'];
+ }
+ if (array_key_exists('end', $filter['time-range'])) {
+ $end = $filter['time-range']['end'];
+ }
+ if ($this->validateTimeRange($subComponent, $start, $end)) {
+ continue 2;
+ }
+ }
+
+ return false;
+ }
+
+ if (!$filter['comp-filters'] && !$filter['prop-filters']) {
+ continue;
+ }
+
+ // If there are sub-filters, we need to find at least one component
+ // for which the subfilters hold true.
+ foreach ($parent->{$filter['name']} as $subComponent) {
+ if (
+ $this->validateCompFilters($subComponent, $filter['comp-filters']) &&
+ $this->validatePropFilters($subComponent, $filter['prop-filters'])) {
+ // We had a match, so this comp-filter succeeds
+ continue 2;
+ }
+ }
+
+ // If we got here it means there were sub-comp-filters or
+ // sub-prop-filters and there was no match. This means this filter
+ // needs to return false.
+ return false;
+ }
+
+ // If we got here it means we got through all comp-filters alive so the
+ // filters were all true.
+ return true;
+ }
+
+ /**
+ * This method checks the validity of prop-filters.
+ *
+ * A list of prop-filters needs to be specified. Also the parent of the
+ * property we're checking should be specified, not the property to check
+ * itself.
+ *
+ * @return bool
+ */
+ protected function validatePropFilters(VObject\Component $parent, array $filters)
+ {
+ foreach ($filters as $filter) {
+ $isDefined = isset($parent->{$filter['name']});
+
+ if ($filter['is-not-defined']) {
+ if ($isDefined) {
+ return false;
+ } else {
+ continue;
+ }
+ }
+ if (!$isDefined) {
+ return false;
+ }
+
+ if (array_key_exists('time-range', $filter) && $filter['time-range']) {
+ foreach ($parent->{$filter['name']} as $subComponent) {
+ $start = null;
+ $end = null;
+ if (array_key_exists('start', $filter['time-range'])) {
+ $start = $filter['time-range']['start'];
+ }
+ if (array_key_exists('end', $filter['time-range'])) {
+ $end = $filter['time-range']['end'];
+ }
+ if ($this->validateTimeRange($subComponent, $start, $end)) {
+ continue 2;
+ }
+ }
+
+ return false;
+ }
+
+ if (!$filter['param-filters'] && !$filter['text-match']) {
+ continue;
+ }
+
+ // If there are sub-filters, we need to find at least one property
+ // for which the subfilters hold true.
+ foreach ($parent->{$filter['name']} as $subComponent) {
+ if (
+ $this->validateParamFilters($subComponent, $filter['param-filters']) &&
+ (!$filter['text-match'] || $this->validateTextMatch($subComponent, $filter['text-match']))
+ ) {
+ // We had a match, so this prop-filter succeeds
+ continue 2;
+ }
+ }
+
+ // If we got here it means there were sub-param-filters or
+ // text-match filters and there was no match. This means the
+ // filter needs to return false.
+ return false;
+ }
+
+ // If we got here it means we got through all prop-filters alive so the
+ // filters were all true.
+ return true;
+ }
+
+ /**
+ * This method checks the validity of param-filters.
+ *
+ * A list of param-filters needs to be specified. Also the parent of the
+ * parameter we're checking should be specified, not the parameter to check
+ * itself.
+ *
+ * @return bool
+ */
+ protected function validateParamFilters(VObject\Property $parent, array $filters)
+ {
+ foreach ($filters as $filter) {
+ $isDefined = isset($parent[$filter['name']]);
+
+ if ($filter['is-not-defined']) {
+ if ($isDefined) {
+ return false;
+ } else {
+ continue;
+ }
+ }
+ if (!$isDefined) {
+ return false;
+ }
+
+ if (!$filter['text-match']) {
+ continue;
+ }
+
+ // If there are sub-filters, we need to find at least one parameter
+ // for which the subfilters hold true.
+ foreach ($parent[$filter['name']]->getParts() as $paramPart) {
+ if ($this->validateTextMatch($paramPart, $filter['text-match'])) {
+ // We had a match, so this param-filter succeeds
+ continue 2;
+ }
+ }
+
+ // If we got here it means there was a text-match filter and there
+ // were no matches. This means the filter needs to return false.
+ return false;
+ }
+
+ // If we got here it means we got through all param-filters alive so the
+ // filters were all true.
+ return true;
+ }
+
+ /**
+ * This method checks the validity of a text-match.
+ *
+ * A single text-match should be specified as well as the specific property
+ * or parameter we need to validate.
+ *
+ * @param VObject\Node|string $check value to check against
+ *
+ * @return bool
+ */
+ protected function validateTextMatch($check, array $textMatch)
+ {
+ if ($check instanceof VObject\Node) {
+ $check = $check->getValue();
+ }
+
+ $isMatching = \Sabre\DAV\StringUtil::textMatch($check, $textMatch['value'], $textMatch['collation']);
+
+ return $textMatch['negate-condition'] xor $isMatching;
+ }
+
+ /**
+ * Validates if a component matches the given time range.
+ *
+ * This is all based on the rules specified in rfc4791, which are quite
+ * complex.
+ *
+ * @param DateTime $start
+ * @param DateTime $end
+ *
+ * @return bool
+ */
+ protected function validateTimeRange(VObject\Node $component, $start, $end)
+ {
+ if (is_null($start)) {
+ $start = new DateTime('1900-01-01');
+ }
+ if (is_null($end)) {
+ $end = new DateTime('3000-01-01');
+ }
+
+ switch ($component->name) {
+ case 'VEVENT':
+ case 'VTODO':
+ case 'VJOURNAL':
+ return $component->isInTimeRange($start, $end);
+
+ case 'VALARM':
+ // If the valarm is wrapped in a recurring event, we need to
+ // expand the recursions, and validate each.
+ //
+ // Our datamodel doesn't easily allow us to do this straight
+ // in the VALARM component code, so this is a hack, and an
+ // expensive one too.
+ if ('VEVENT' === $component->parent->name && $component->parent->RRULE) {
+ // Fire up the iterator!
+ $it = new VObject\Recur\EventIterator($component->parent->parent, (string) $component->parent->UID);
+ while ($it->valid()) {
+ $expandedEvent = $it->getEventObject();
+
+ // We need to check from these expanded alarms, which
+ // one is the first to trigger. Based on this, we can
+ // determine if we can 'give up' expanding events.
+ $firstAlarm = null;
+ if (null !== $expandedEvent->VALARM) {
+ foreach ($expandedEvent->VALARM as $expandedAlarm) {
+ $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime();
+ if ($expandedAlarm->isInTimeRange($start, $end)) {
+ return true;
+ }
+
+ if ('DATE-TIME' === (string) $expandedAlarm->TRIGGER['VALUE']) {
+ // This is an alarm with a non-relative trigger
+ // time, likely created by a buggy client. The
+ // implication is that every alarm in this
+ // recurring event trigger at the exact same
+ // time. It doesn't make sense to traverse
+ // further.
+ } else {
+ // We store the first alarm as a means to
+ // figure out when we can stop traversing.
+ if (!$firstAlarm || $effectiveTrigger < $firstAlarm) {
+ $firstAlarm = $effectiveTrigger;
+ }
+ }
+ }
+ }
+ if (is_null($firstAlarm)) {
+ // No alarm was found.
+ //
+ // Or technically: No alarm that will change for
+ // every instance of the recurrence was found,
+ // which means we can assume there was no match.
+ return false;
+ }
+ if ($firstAlarm > $end) {
+ return false;
+ }
+ $it->next();
+ }
+
+ return false;
+ } else {
+ return $component->isInTimeRange($start, $end);
+ }
+
+ // no break
+ case 'VFREEBUSY':
+ throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on '.$component->name.' components');
+ case 'COMPLETED':
+ case 'CREATED':
+ case 'DTEND':
+ case 'DTSTAMP':
+ case 'DTSTART':
+ case 'DUE':
+ case 'LAST-MODIFIED':
+ return $start <= $component->getDateTime() && $end >= $component->getDateTime();
+
+ default:
+ throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a '.$component->name.' component');
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php
new file mode 100644
index 0000000..3038d21
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/CalendarRoot.php
@@ -0,0 +1,75 @@
+caldavBackend = $caldavBackend;
+ }
+
+ /**
+ * Returns the nodename.
+ *
+ * We're overriding this, because the default will be the 'principalPrefix',
+ * and we want it to be Sabre\CalDAV\Plugin::CALENDAR_ROOT
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return Plugin::CALENDAR_ROOT;
+ }
+
+ /**
+ * This method returns a node for a principal.
+ *
+ * The passed array contains principal information, and is guaranteed to
+ * at least contain a uri item. Other properties may or may not be
+ * supplied by the authentication backend.
+ *
+ * @return \Sabre\DAV\INode
+ */
+ public function getChildForPrincipal(array $principal)
+ {
+ return new CalendarHome($this->caldavBackend, $principal);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php
new file mode 100644
index 0000000..e94378a
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php
@@ -0,0 +1,31 @@
+ownerDocument;
+
+ $np = $doc->createElementNS(CalDAV\Plugin::NS_CALDAV, 'cal:supported-calendar-component');
+ $errorNode->appendChild($np);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php
new file mode 100644
index 0000000..9171e36
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/ICSExportPlugin.php
@@ -0,0 +1,377 @@
+server = $server;
+ $server->on('method:GET', [$this, 'httpGet'], 90);
+ $server->on('browserButtonActions', function ($path, $node, &$actions) {
+ if ($node instanceof ICalendar) {
+ $actions .= '';
+ }
+ });
+ }
+
+ /**
+ * Intercepts GET requests on calendar urls ending with ?export.
+ *
+ * @throws BadRequest
+ * @throws DAV\Exception\NotFound
+ * @throws VObject\InvalidDataException
+ *
+ * @return bool
+ */
+ public function httpGet(RequestInterface $request, ResponseInterface $response)
+ {
+ $queryParams = $request->getQueryParameters();
+ if (!array_key_exists('export', $queryParams)) {
+ return;
+ }
+
+ $path = $request->getPath();
+
+ $node = $this->server->getProperties($path, [
+ '{DAV:}resourcetype',
+ '{DAV:}displayname',
+ '{http://sabredav.org/ns}sync-token',
+ '{DAV:}sync-token',
+ '{http://apple.com/ns/ical/}calendar-color',
+ ]);
+
+ if (!isset($node['{DAV:}resourcetype']) || !$node['{DAV:}resourcetype']->is('{'.Plugin::NS_CALDAV.'}calendar')) {
+ return;
+ }
+ // Marking the transactionType, for logging purposes.
+ $this->server->transactionType = 'get-calendar-export';
+
+ $properties = $node;
+
+ $start = null;
+ $end = null;
+ $expand = false;
+ $componentType = false;
+ if (isset($queryParams['start'])) {
+ if (!ctype_digit($queryParams['start'])) {
+ throw new BadRequest('The start= parameter must contain a unix timestamp');
+ }
+ $start = DateTime::createFromFormat('U', $queryParams['start']);
+ }
+ if (isset($queryParams['end'])) {
+ if (!ctype_digit($queryParams['end'])) {
+ throw new BadRequest('The end= parameter must contain a unix timestamp');
+ }
+ $end = DateTime::createFromFormat('U', $queryParams['end']);
+ }
+ if (isset($queryParams['expand']) && (bool) $queryParams['expand']) {
+ if (!$start || !$end) {
+ throw new BadRequest('If you\'d like to expand recurrences, you must specify both a start= and end= parameter.');
+ }
+ $expand = true;
+ $componentType = 'VEVENT';
+ }
+ if (isset($queryParams['componentType'])) {
+ if (!in_array($queryParams['componentType'], ['VEVENT', 'VTODO', 'VJOURNAL'])) {
+ throw new BadRequest('You are not allowed to search for components of type: '.$queryParams['componentType'].' here');
+ }
+ $componentType = $queryParams['componentType'];
+ }
+
+ $format = \Sabre\HTTP\negotiateContentType(
+ $request->getHeader('Accept'),
+ [
+ 'text/calendar',
+ 'application/calendar+json',
+ ]
+ );
+
+ if (isset($queryParams['accept'])) {
+ if ('application/calendar+json' === $queryParams['accept'] || 'jcal' === $queryParams['accept']) {
+ $format = 'application/calendar+json';
+ }
+ }
+ if (!$format) {
+ $format = 'text/calendar';
+ }
+
+ $this->generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, $response);
+
+ // Returning false to break the event chain
+ return false;
+ }
+
+ /**
+ * This method is responsible for generating the actual, full response.
+ *
+ * @param string $path
+ * @param DateTime|null $start
+ * @param DateTime|null $end
+ * @param bool $expand
+ * @param string $componentType
+ * @param string $format
+ * @param array $properties
+ *
+ * @throws DAV\Exception\NotFound
+ * @throws VObject\InvalidDataException
+ */
+ protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response)
+ {
+ $calDataProp = '{'.Plugin::NS_CALDAV.'}calendar-data';
+ $calendarNode = $this->server->tree->getNodeForPath($path);
+
+ $blobs = [];
+ if ($start || $end || $componentType) {
+ // If there was a start or end filter, we need to enlist
+ // calendarQuery for speed.
+ $queryResult = $calendarNode->calendarQuery([
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => $componentType,
+ 'comp-filters' => [],
+ 'prop-filters' => [],
+ 'is-not-defined' => false,
+ 'time-range' => [
+ 'start' => $start,
+ 'end' => $end,
+ ],
+ ],
+ ],
+ 'prop-filters' => [],
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ ]);
+
+ // queryResult is just a list of base urls. We need to prefix the
+ // calendar path.
+ $queryResult = array_map(
+ function ($item) use ($path) {
+ return $path.'/'.$item;
+ },
+ $queryResult
+ );
+ $nodes = $this->server->getPropertiesForMultiplePaths($queryResult, [$calDataProp]);
+ unset($queryResult);
+ } else {
+ $nodes = $this->server->getPropertiesForPath($path, [$calDataProp], 1);
+ }
+
+ // Flattening the arrays
+ foreach ($nodes as $node) {
+ if (isset($node[200][$calDataProp])) {
+ $blobs[$node['href']] = $node[200][$calDataProp];
+ }
+ }
+ unset($nodes);
+
+ $mergedCalendar = $this->mergeObjects(
+ $properties,
+ $blobs
+ );
+
+ if ($expand) {
+ $calendarTimeZone = null;
+ // We're expanding, and for that we need to figure out the
+ // calendar's timezone.
+ $tzProp = '{'.Plugin::NS_CALDAV.'}calendar-timezone';
+ $tzResult = $this->server->getProperties($path, [$tzProp]);
+ if (isset($tzResult[$tzProp])) {
+ // This property contains a VCALENDAR with a single
+ // VTIMEZONE.
+ $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]);
+ $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
+ // Destroy circular references to PHP will GC the object.
+ $vtimezoneObj->destroy();
+ unset($vtimezoneObj);
+ } else {
+ // Defaulting to UTC.
+ $calendarTimeZone = new DateTimeZone('UTC');
+ }
+
+ $mergedCalendar = $mergedCalendar->expand($start, $end, $calendarTimeZone);
+ }
+
+ $filenameExtension = '.ics';
+
+ switch ($format) {
+ case 'text/calendar':
+ $mergedCalendar = $mergedCalendar->serialize();
+ $filenameExtension = '.ics';
+ break;
+ case 'application/calendar+json':
+ $mergedCalendar = json_encode($mergedCalendar->jsonSerialize());
+ $filenameExtension = '.json';
+ break;
+ }
+
+ $filename = preg_replace(
+ '/[^a-zA-Z0-9-_ ]/um',
+ '',
+ $calendarNode->getName()
+ );
+ $filename .= '-'.date('Y-m-d').$filenameExtension;
+
+ $response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"');
+ $response->setHeader('Content-Type', $format);
+
+ $response->setStatus(200);
+ $response->setBody($mergedCalendar);
+ }
+
+ /**
+ * Merges all calendar objects, and builds one big iCalendar blob.
+ *
+ * @param array $properties Some CalDAV properties
+ *
+ * @return VObject\Component\VCalendar
+ */
+ public function mergeObjects(array $properties, array $inputObjects)
+ {
+ $calendar = new VObject\Component\VCalendar();
+ $calendar->VERSION = '2.0';
+ if (DAV\Server::$exposeVersion) {
+ $calendar->PRODID = '-//SabreDAV//SabreDAV '.DAV\Version::VERSION.'//EN';
+ } else {
+ $calendar->PRODID = '-//SabreDAV//SabreDAV//EN';
+ }
+ if (isset($properties['{DAV:}displayname'])) {
+ $calendar->{'X-WR-CALNAME'} = $properties['{DAV:}displayname'];
+ }
+ if (isset($properties['{http://apple.com/ns/ical/}calendar-color'])) {
+ $calendar->{'X-APPLE-CALENDAR-COLOR'} = $properties['{http://apple.com/ns/ical/}calendar-color'];
+ }
+
+ $collectedTimezones = [];
+
+ $timezones = [];
+ $objects = [];
+
+ foreach ($inputObjects as $href => $inputObject) {
+ $nodeComp = VObject\Reader::read($inputObject);
+
+ foreach ($nodeComp->children() as $child) {
+ switch ($child->name) {
+ case 'VEVENT':
+ case 'VTODO':
+ case 'VJOURNAL':
+ $objects[] = clone $child;
+ break;
+
+ // VTIMEZONE is special, because we need to filter out the duplicates
+ case 'VTIMEZONE':
+ // Naively just checking tzid.
+ if (in_array((string) $child->TZID, $collectedTimezones)) {
+ break;
+ }
+
+ $timezones[] = clone $child;
+ $collectedTimezones[] = $child->TZID;
+ break;
+ }
+ }
+ // Destroy circular references to PHP will GC the object.
+ $nodeComp->destroy();
+ unset($nodeComp);
+ }
+
+ foreach ($timezones as $tz) {
+ $calendar->add($tz);
+ }
+ foreach ($objects as $obj) {
+ $calendar->add($obj);
+ }
+
+ return $calendar;
+ }
+
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins
+ * using \Sabre\DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return 'ics-export';
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds the ability to export CalDAV calendars as a single iCalendar file.',
+ 'link' => 'http://sabre.io/dav/ics-export-plugin/',
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/ICalendar.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/ICalendar.php
new file mode 100644
index 0000000..8636e0b
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/ICalendar.php
@@ -0,0 +1,20 @@
+caldavBackend = $caldavBackend;
+ $this->principalUri = $principalUri;
+ }
+
+ /**
+ * Returns all notifications for a principal.
+ *
+ * @return array
+ */
+ public function getChildren()
+ {
+ $children = [];
+ $notifications = $this->caldavBackend->getNotificationsForPrincipal($this->principalUri);
+
+ foreach ($notifications as $notification) {
+ $children[] = new Node(
+ $this->caldavBackend,
+ $this->principalUri,
+ $notification
+ );
+ }
+
+ return $children;
+ }
+
+ /**
+ * Returns the name of this object.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'notifications';
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->principalUri;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php
new file mode 100644
index 0000000..b12fb39
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Notifications/ICollection.php
@@ -0,0 +1,25 @@
+caldavBackend = $caldavBackend;
+ $this->principalUri = $principalUri;
+ $this->notification = $notification;
+ }
+
+ /**
+ * Returns the path name for this notification.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->notification->getId().'.xml';
+ }
+
+ /**
+ * Returns the etag for the notification.
+ *
+ * The etag must be surrounded by literal double-quotes.
+ *
+ * @return string
+ */
+ public function getETag()
+ {
+ return $this->notification->getETag();
+ }
+
+ /**
+ * This method must return an xml element, using the
+ * Sabre\CalDAV\Xml\Notification\NotificationInterface classes.
+ *
+ * @return NotificationInterface
+ */
+ public function getNotificationType()
+ {
+ return $this->notification;
+ }
+
+ /**
+ * Deletes this notification.
+ */
+ public function delete()
+ {
+ $this->caldavBackend->deleteNotification($this->getOwner(), $this->notification);
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be an url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->principalUri;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php
new file mode 100644
index 0000000..56b2fe9
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Notifications/Plugin.php
@@ -0,0 +1,161 @@
+server = $server;
+ $server->on('method:GET', [$this, 'httpGet'], 90);
+ $server->on('propFind', [$this, 'propFind']);
+
+ $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs';
+ $server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{'.self::NS_CALENDARSERVER.'}notification';
+
+ array_push($server->protectedProperties,
+ '{'.self::NS_CALENDARSERVER.'}notification-URL',
+ '{'.self::NS_CALENDARSERVER.'}notificationtype'
+ );
+ }
+
+ /**
+ * PropFind.
+ */
+ public function propFind(PropFind $propFind, BaseINode $node)
+ {
+ $caldavPlugin = $this->server->getPlugin('caldav');
+
+ if ($node instanceof DAVACL\IPrincipal) {
+ $principalUrl = $node->getPrincipalUrl();
+
+ // notification-URL property
+ $propFind->handle('{'.self::NS_CALENDARSERVER.'}notification-URL', function () use ($principalUrl, $caldavPlugin) {
+ $notificationPath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl).'/notifications/';
+
+ return new DAV\Xml\Property\Href($notificationPath);
+ });
+ }
+
+ if ($node instanceof INode) {
+ $propFind->handle(
+ '{'.self::NS_CALENDARSERVER.'}notificationtype',
+ [$node, 'getNotificationType']
+ );
+ }
+ }
+
+ /**
+ * This event is triggered before the usual GET request handler.
+ *
+ * We use this to intercept GET calls to notification nodes, and return the
+ * proper response.
+ */
+ public function httpGet(RequestInterface $request, ResponseInterface $response)
+ {
+ $path = $request->getPath();
+
+ try {
+ $node = $this->server->tree->getNodeForPath($path);
+ } catch (DAV\Exception\NotFound $e) {
+ return;
+ }
+
+ if (!$node instanceof INode) {
+ return;
+ }
+
+ $writer = $this->server->xml->getWriter();
+ $writer->contextUri = $this->server->getBaseUri();
+ $writer->openMemory();
+ $writer->startDocument('1.0', 'UTF-8');
+ $writer->startElement('{http://calendarserver.org/ns/}notification');
+ $node->getNotificationType()->xmlSerializeFull($writer);
+ $writer->endElement();
+
+ $response->setHeader('Content-Type', 'application/xml');
+ $response->setHeader('ETag', $node->getETag());
+ $response->setStatus(200);
+ $response->setBody($writer->outputMemory());
+
+ // Return false to break the event chain.
+ return false;
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds support for caldav-notifications, which is required to enable caldav-sharing.',
+ 'link' => 'http://sabre.io/dav/caldav-sharing/',
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Plugin.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Plugin.php
new file mode 100644
index 0000000..ccb722f
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Plugin.php
@@ -0,0 +1,1011 @@
+server->tree->getNodeForPath($parent);
+
+ if ($node instanceof DAV\IExtendedCollection) {
+ try {
+ $node->getChild($name);
+ } catch (DAV\Exception\NotFound $e) {
+ return ['MKCALENDAR'];
+ }
+ }
+
+ return [];
+ }
+
+ /**
+ * Returns the path to a principal's calendar home.
+ *
+ * The return url must not end with a slash.
+ * This function should return null in case a principal did not have
+ * a calendar home.
+ *
+ * @param string $principalUrl
+ *
+ * @return string
+ */
+ public function getCalendarHomeForPrincipal($principalUrl)
+ {
+ // The default behavior for most sabre/dav servers is that there is a
+ // principals root node, which contains users directly under it.
+ //
+ // This function assumes that there are two components in a principal
+ // path. If there's more, we don't return a calendar home. This
+ // excludes things like the calendar-proxy-read principal (which it
+ // should).
+ $parts = explode('/', trim($principalUrl, '/'));
+ if (2 !== count($parts)) {
+ return;
+ }
+ if ('principals' !== $parts[0]) {
+ return;
+ }
+
+ return self::CALENDAR_ROOT.'/'.$parts[1];
+ }
+
+ /**
+ * Returns a list of features for the DAV: HTTP header.
+ *
+ * @return array
+ */
+ public function getFeatures()
+ {
+ return ['calendar-access', 'calendar-proxy'];
+ }
+
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins
+ * using DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return 'caldav';
+ }
+
+ /**
+ * Returns a list of reports this plugin supports.
+ *
+ * This will be used in the {DAV:}supported-report-set property.
+ * Note that you still need to subscribe to the 'report' event to actually
+ * implement them
+ *
+ * @param string $uri
+ *
+ * @return array
+ */
+ public function getSupportedReportSet($uri)
+ {
+ $node = $this->server->tree->getNodeForPath($uri);
+
+ $reports = [];
+ if ($node instanceof ICalendarObjectContainer || $node instanceof ICalendarObject) {
+ $reports[] = '{'.self::NS_CALDAV.'}calendar-multiget';
+ $reports[] = '{'.self::NS_CALDAV.'}calendar-query';
+ }
+ if ($node instanceof ICalendar) {
+ $reports[] = '{'.self::NS_CALDAV.'}free-busy-query';
+ }
+ // iCal has a bug where it assumes that sync support is enabled, only
+ // if we say we support it on the calendar-home, even though this is
+ // not actually the case.
+ if ($node instanceof CalendarHome && $this->server->getPlugin('sync')) {
+ $reports[] = '{DAV:}sync-collection';
+ }
+
+ return $reports;
+ }
+
+ /**
+ * Initializes the plugin.
+ */
+ public function initialize(DAV\Server $server)
+ {
+ $this->server = $server;
+
+ $server->on('method:MKCALENDAR', [$this, 'httpMkCalendar']);
+ $server->on('report', [$this, 'report']);
+ $server->on('propFind', [$this, 'propFind']);
+ $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
+ $server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
+ $server->on('beforeWriteContent', [$this, 'beforeWriteContent']);
+ $server->on('afterMethod:GET', [$this, 'httpAfterGET']);
+ $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']);
+
+ $server->xml->namespaceMap[self::NS_CALDAV] = 'cal';
+ $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs';
+
+ $server->xml->elementMap['{'.self::NS_CALDAV.'}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet';
+ $server->xml->elementMap['{'.self::NS_CALDAV.'}calendar-query'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarQueryReport';
+ $server->xml->elementMap['{'.self::NS_CALDAV.'}calendar-multiget'] = 'Sabre\\CalDAV\\Xml\\Request\\CalendarMultiGetReport';
+ $server->xml->elementMap['{'.self::NS_CALDAV.'}free-busy-query'] = 'Sabre\\CalDAV\\Xml\\Request\\FreeBusyQueryReport';
+ $server->xml->elementMap['{'.self::NS_CALDAV.'}mkcalendar'] = 'Sabre\\CalDAV\\Xml\\Request\\MkCalendar';
+ $server->xml->elementMap['{'.self::NS_CALDAV.'}schedule-calendar-transp'] = 'Sabre\\CalDAV\\Xml\\Property\\ScheduleCalendarTransp';
+ $server->xml->elementMap['{'.self::NS_CALDAV.'}supported-calendar-component-set'] = 'Sabre\\CalDAV\\Xml\\Property\\SupportedCalendarComponentSet';
+
+ $server->resourceTypeMapping['\\Sabre\\CalDAV\\ICalendar'] = '{urn:ietf:params:xml:ns:caldav}calendar';
+
+ $server->resourceTypeMapping['\\Sabre\\CalDAV\\Principal\\IProxyRead'] = '{http://calendarserver.org/ns/}calendar-proxy-read';
+ $server->resourceTypeMapping['\\Sabre\\CalDAV\\Principal\\IProxyWrite'] = '{http://calendarserver.org/ns/}calendar-proxy-write';
+
+ array_push($server->protectedProperties,
+ '{'.self::NS_CALDAV.'}supported-calendar-component-set',
+ '{'.self::NS_CALDAV.'}supported-calendar-data',
+ '{'.self::NS_CALDAV.'}max-resource-size',
+ '{'.self::NS_CALDAV.'}min-date-time',
+ '{'.self::NS_CALDAV.'}max-date-time',
+ '{'.self::NS_CALDAV.'}max-instances',
+ '{'.self::NS_CALDAV.'}max-attendees-per-instance',
+ '{'.self::NS_CALDAV.'}calendar-home-set',
+ '{'.self::NS_CALDAV.'}supported-collation-set',
+ '{'.self::NS_CALDAV.'}calendar-data',
+
+ // CalendarServer extensions
+ '{'.self::NS_CALENDARSERVER.'}getctag',
+ '{'.self::NS_CALENDARSERVER.'}calendar-proxy-read-for',
+ '{'.self::NS_CALENDARSERVER.'}calendar-proxy-write-for'
+ );
+
+ if ($aclPlugin = $server->getPlugin('acl')) {
+ $aclPlugin->principalSearchPropertySet['{'.self::NS_CALDAV.'}calendar-user-address-set'] = 'Calendar address';
+ }
+ }
+
+ /**
+ * This functions handles REPORT requests specific to CalDAV.
+ *
+ * @param string $reportName
+ * @param mixed $report
+ * @param mixed $path
+ *
+ * @return bool|null
+ */
+ public function report($reportName, $report, $path)
+ {
+ switch ($reportName) {
+ case '{'.self::NS_CALDAV.'}calendar-multiget':
+ $this->server->transactionType = 'report-calendar-multiget';
+ $this->calendarMultiGetReport($report);
+
+ return false;
+ case '{'.self::NS_CALDAV.'}calendar-query':
+ $this->server->transactionType = 'report-calendar-query';
+ $this->calendarQueryReport($report);
+
+ return false;
+ case '{'.self::NS_CALDAV.'}free-busy-query':
+ $this->server->transactionType = 'report-free-busy-query';
+ $this->freeBusyQueryReport($report);
+
+ return false;
+ }
+ }
+
+ /**
+ * This function handles the MKCALENDAR HTTP method, which creates
+ * a new calendar.
+ *
+ * @return bool
+ */
+ public function httpMkCalendar(RequestInterface $request, ResponseInterface $response)
+ {
+ $body = $request->getBodyAsString();
+ $path = $request->getPath();
+
+ $properties = [];
+
+ if ($body) {
+ try {
+ $mkcalendar = $this->server->xml->expect(
+ '{urn:ietf:params:xml:ns:caldav}mkcalendar',
+ $body
+ );
+ } catch (\Sabre\Xml\ParseException $e) {
+ throw new BadRequest($e->getMessage(), 0, $e);
+ }
+ $properties = $mkcalendar->getProperties();
+ }
+
+ // iCal abuses MKCALENDAR since iCal 10.9.2 to create server-stored
+ // subscriptions. Before that it used MKCOL which was the correct way
+ // to do this.
+ //
+ // If the body had a {DAV:}resourcetype, it means we stumbled upon this
+ // request, and we simply use it instead of the pre-defined list.
+ if (isset($properties['{DAV:}resourcetype'])) {
+ $resourceType = $properties['{DAV:}resourcetype']->getValue();
+ } else {
+ $resourceType = ['{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'];
+ }
+
+ $this->server->createCollection($path, new MkCol($resourceType, $properties));
+
+ $response->setStatus(201);
+ $response->setHeader('Content-Length', 0);
+
+ // This breaks the method chain.
+ return false;
+ }
+
+ /**
+ * PropFind.
+ *
+ * This method handler is invoked before any after properties for a
+ * resource are fetched. This allows us to add in any CalDAV specific
+ * properties.
+ */
+ public function propFind(DAV\PropFind $propFind, DAV\INode $node)
+ {
+ $ns = '{'.self::NS_CALDAV.'}';
+
+ if ($node instanceof ICalendarObjectContainer) {
+ $propFind->handle($ns.'max-resource-size', $this->maxResourceSize);
+ $propFind->handle($ns.'supported-calendar-data', function () {
+ return new Xml\Property\SupportedCalendarData();
+ });
+ $propFind->handle($ns.'supported-collation-set', function () {
+ return new Xml\Property\SupportedCollationSet();
+ });
+ }
+
+ if ($node instanceof DAVACL\IPrincipal) {
+ $principalUrl = $node->getPrincipalUrl();
+
+ $propFind->handle('{'.self::NS_CALDAV.'}calendar-home-set', function () use ($principalUrl) {
+ $calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl);
+ if (is_null($calendarHomePath)) {
+ return null;
+ }
+
+ return new LocalHref($calendarHomePath.'/');
+ });
+ // The calendar-user-address-set property is basically mapped to
+ // the {DAV:}alternate-URI-set property.
+ $propFind->handle('{'.self::NS_CALDAV.'}calendar-user-address-set', function () use ($node) {
+ $addresses = $node->getAlternateUriSet();
+ $addresses[] = $this->server->getBaseUri().$node->getPrincipalUrl().'/';
+
+ return new LocalHref($addresses);
+ });
+ // For some reason somebody thought it was a good idea to add
+ // another one of these properties. We're supporting it too.
+ $propFind->handle('{'.self::NS_CALENDARSERVER.'}email-address-set', function () use ($node) {
+ $addresses = $node->getAlternateUriSet();
+ $emails = [];
+ foreach ($addresses as $address) {
+ if ('mailto:' === substr($address, 0, 7)) {
+ $emails[] = substr($address, 7);
+ }
+ }
+
+ return new Xml\Property\EmailAddressSet($emails);
+ });
+
+ // These two properties are shortcuts for ical to easily find
+ // other principals this principal has access to.
+ $propRead = '{'.self::NS_CALENDARSERVER.'}calendar-proxy-read-for';
+ $propWrite = '{'.self::NS_CALENDARSERVER.'}calendar-proxy-write-for';
+
+ if (404 === $propFind->getStatus($propRead) || 404 === $propFind->getStatus($propWrite)) {
+ $aclPlugin = $this->server->getPlugin('acl');
+ $membership = $aclPlugin->getPrincipalMembership($propFind->getPath());
+ $readList = [];
+ $writeList = [];
+
+ foreach ($membership as $group) {
+ $groupNode = $this->server->tree->getNodeForPath($group);
+
+ $listItem = Uri\split($group)[0].'/';
+
+ // If the node is either ap proxy-read or proxy-write
+ // group, we grab the parent principal and add it to the
+ // list.
+ if ($groupNode instanceof Principal\IProxyRead) {
+ $readList[] = $listItem;
+ }
+ if ($groupNode instanceof Principal\IProxyWrite) {
+ $writeList[] = $listItem;
+ }
+ }
+
+ $propFind->set($propRead, new LocalHref($readList));
+ $propFind->set($propWrite, new LocalHref($writeList));
+ }
+ } // instanceof IPrincipal
+
+ if ($node instanceof ICalendarObject) {
+ // The calendar-data property is not supposed to be a 'real'
+ // property, but in large chunks of the spec it does act as such.
+ // Therefore we simply expose it as a property.
+ $propFind->handle('{'.self::NS_CALDAV.'}calendar-data', function () use ($node) {
+ $val = $node->get();
+ if (is_resource($val)) {
+ $val = stream_get_contents($val);
+ }
+
+ // Taking out \r to not screw up the xml output
+ return str_replace("\r", '', $val);
+ });
+ }
+ }
+
+ /**
+ * This function handles the calendar-multiget REPORT.
+ *
+ * This report is used by the client to fetch the content of a series
+ * of urls. Effectively avoiding a lot of redundant requests.
+ *
+ * @param CalendarMultiGetReport $report
+ */
+ public function calendarMultiGetReport($report)
+ {
+ $needsJson = 'application/calendar+json' === $report->contentType;
+
+ $timeZones = [];
+ $propertyList = [];
+
+ $paths = array_map(
+ [$this->server, 'calculateUri'],
+ $report->hrefs
+ );
+
+ foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $uri => $objProps) {
+ if (($needsJson || $report->expand) && isset($objProps[200]['{'.self::NS_CALDAV.'}calendar-data'])) {
+ $vObject = VObject\Reader::read($objProps[200]['{'.self::NS_CALDAV.'}calendar-data']);
+
+ if ($report->expand) {
+ // We're expanding, and for that we need to figure out the
+ // calendar's timezone.
+ list($calendarPath) = Uri\split($uri);
+ if (!isset($timeZones[$calendarPath])) {
+ // Checking the calendar-timezone property.
+ $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone';
+ $tzResult = $this->server->getProperties($calendarPath, [$tzProp]);
+ if (isset($tzResult[$tzProp])) {
+ // This property contains a VCALENDAR with a single
+ // VTIMEZONE.
+ $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]);
+ $timeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
+ } else {
+ // Defaulting to UTC.
+ $timeZone = new DateTimeZone('UTC');
+ }
+ $timeZones[$calendarPath] = $timeZone;
+ }
+
+ $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $timeZones[$calendarPath]);
+ }
+ if ($needsJson) {
+ $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize());
+ } else {
+ $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize();
+ }
+ // Destroy circular references so PHP will garbage collect the
+ // object.
+ $vObject->destroy();
+ }
+
+ $propertyList[] = $objProps;
+ }
+
+ $prefer = $this->server->getHTTPPrefer();
+
+ $this->server->httpResponse->setStatus(207);
+ $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
+ $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
+ $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, 'minimal' === $prefer['return']));
+ }
+
+ /**
+ * This function handles the calendar-query REPORT.
+ *
+ * This report is used by clients to request calendar objects based on
+ * complex conditions.
+ *
+ * @param Xml\Request\CalendarQueryReport $report
+ */
+ public function calendarQueryReport($report)
+ {
+ $path = $this->server->getRequestUri();
+
+ $needsJson = 'application/calendar+json' === $report->contentType;
+
+ $node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
+ $depth = $this->server->getHTTPDepth(0);
+
+ // The default result is an empty array
+ $result = [];
+
+ $calendarTimeZone = null;
+ if ($report->expand) {
+ // We're expanding, and for that we need to figure out the
+ // calendar's timezone.
+ $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone';
+ $tzResult = $this->server->getProperties($path, [$tzProp]);
+ if (isset($tzResult[$tzProp])) {
+ // This property contains a VCALENDAR with a single
+ // VTIMEZONE.
+ $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]);
+ $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
+
+ // Destroy circular references so PHP will garbage collect the
+ // object.
+ $vtimezoneObj->destroy();
+ } else {
+ // Defaulting to UTC.
+ $calendarTimeZone = new DateTimeZone('UTC');
+ }
+ }
+
+ // The calendarobject was requested directly. In this case we handle
+ // this locally.
+ if (0 == $depth && $node instanceof ICalendarObject) {
+ $requestedCalendarData = true;
+ $requestedProperties = $report->properties;
+
+ if (!in_array('{urn:ietf:params:xml:ns:caldav}calendar-data', $requestedProperties)) {
+ // We always retrieve calendar-data, as we need it for filtering.
+ $requestedProperties[] = '{urn:ietf:params:xml:ns:caldav}calendar-data';
+
+ // If calendar-data wasn't explicitly requested, we need to remove
+ // it after processing.
+ $requestedCalendarData = false;
+ }
+
+ $properties = $this->server->getPropertiesForPath(
+ $path,
+ $requestedProperties,
+ 0
+ );
+
+ // This array should have only 1 element, the first calendar
+ // object.
+ $properties = current($properties);
+
+ // If there wasn't any calendar-data returned somehow, we ignore
+ // this.
+ if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) {
+ $validator = new CalendarQueryValidator();
+
+ $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
+ if ($validator->validate($vObject, $report->filters)) {
+ // If the client didn't require the calendar-data property,
+ // we won't give it back.
+ if (!$requestedCalendarData) {
+ unset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']);
+ } else {
+ if ($report->expand) {
+ $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone);
+ }
+ if ($needsJson) {
+ $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize());
+ } elseif ($report->expand) {
+ $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize();
+ }
+ }
+
+ $result = [$properties];
+ }
+ // Destroy circular references so PHP will garbage collect the
+ // object.
+ $vObject->destroy();
+ }
+ }
+
+ if ($node instanceof ICalendarObjectContainer && 0 === $depth) {
+ if (0 === strpos((string) $this->server->httpRequest->getHeader('User-Agent'), 'MSFT-')) {
+ // Microsoft clients incorrectly supplied depth as 0, when it actually
+ // should have set depth to 1. We're implementing a workaround here
+ // to deal with this.
+ //
+ // This targets at least the following clients:
+ // Windows 10
+ // Windows Phone 8, 10
+ $depth = 1;
+ } else {
+ throw new BadRequest('A calendar-query REPORT on a calendar with a Depth: 0 is undefined. Set Depth to 1');
+ }
+ }
+
+ // If we're dealing with a calendar, the calendar itself is responsible
+ // for the calendar-query.
+ if ($node instanceof ICalendarObjectContainer && 1 == $depth) {
+ $nodePaths = $node->calendarQuery($report->filters);
+
+ foreach ($nodePaths as $path) {
+ list($properties) =
+ $this->server->getPropertiesForPath($this->server->getRequestUri().'/'.$path, $report->properties);
+
+ if (($needsJson || $report->expand)) {
+ $vObject = VObject\Reader::read($properties[200]['{'.self::NS_CALDAV.'}calendar-data']);
+
+ if ($report->expand) {
+ $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $calendarTimeZone);
+ }
+
+ if ($needsJson) {
+ $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize());
+ } else {
+ $properties[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize();
+ }
+
+ // Destroy circular references so PHP will garbage collect the
+ // object.
+ $vObject->destroy();
+ }
+ $result[] = $properties;
+ }
+ }
+
+ $prefer = $this->server->getHTTPPrefer();
+
+ $this->server->httpResponse->setStatus(207);
+ $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
+ $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
+ $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return']));
+ }
+
+ /**
+ * This method is responsible for parsing the request and generating the
+ * response for the CALDAV:free-busy-query REPORT.
+ */
+ protected function freeBusyQueryReport(Xml\Request\FreeBusyQueryReport $report)
+ {
+ $uri = $this->server->getRequestUri();
+
+ $acl = $this->server->getPlugin('acl');
+ if ($acl) {
+ $acl->checkPrivileges($uri, '{'.self::NS_CALDAV.'}read-free-busy');
+ }
+
+ $calendar = $this->server->tree->getNodeForPath($uri);
+ if (!$calendar instanceof ICalendar) {
+ throw new DAV\Exception\NotImplemented('The free-busy-query REPORT is only implemented on calendars');
+ }
+
+ $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone';
+
+ // Figuring out the default timezone for the calendar, for floating
+ // times.
+ $calendarProps = $this->server->getProperties($uri, [$tzProp]);
+
+ if (isset($calendarProps[$tzProp])) {
+ $vtimezoneObj = VObject\Reader::read($calendarProps[$tzProp]);
+ $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
+ // Destroy circular references so PHP will garbage collect the object.
+ $vtimezoneObj->destroy();
+ } else {
+ $calendarTimeZone = new DateTimeZone('UTC');
+ }
+
+ // Doing a calendar-query first, to make sure we get the most
+ // performance.
+ $urls = $calendar->calendarQuery([
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => 'VEVENT',
+ 'comp-filters' => [],
+ 'prop-filters' => [],
+ 'is-not-defined' => false,
+ 'time-range' => [
+ 'start' => $report->start,
+ 'end' => $report->end,
+ ],
+ ],
+ ],
+ 'prop-filters' => [],
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ ]);
+
+ $objects = array_map(function ($url) use ($calendar) {
+ $obj = $calendar->getChild($url)->get();
+
+ return $obj;
+ }, $urls);
+
+ $generator = new VObject\FreeBusyGenerator();
+ $generator->setObjects($objects);
+ $generator->setTimeRange($report->start, $report->end);
+ $generator->setTimeZone($calendarTimeZone);
+ $result = $generator->getResult();
+ $result = $result->serialize();
+
+ $this->server->httpResponse->setStatus(200);
+ $this->server->httpResponse->setHeader('Content-Type', 'text/calendar');
+ $this->server->httpResponse->setHeader('Content-Length', strlen($result));
+ $this->server->httpResponse->setBody($result);
+ }
+
+ /**
+ * This method is triggered before a file gets updated with new content.
+ *
+ * This plugin uses this method to ensure that CalDAV objects receive
+ * valid calendar data.
+ *
+ * @param string $path
+ * @param resource $data
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
+ */
+ public function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified)
+ {
+ if (!$node instanceof ICalendarObject) {
+ return;
+ }
+
+ // We're only interested in ICalendarObject nodes that are inside of a
+ // real calendar. This is to avoid triggering validation and scheduling
+ // for non-calendars (such as an inbox).
+ list($parent) = Uri\split($path);
+ $parentNode = $this->server->tree->getNodeForPath($parent);
+
+ if (!$parentNode instanceof ICalendar) {
+ return;
+ }
+
+ $this->validateICalendar(
+ $data,
+ $path,
+ $modified,
+ $this->server->httpRequest,
+ $this->server->httpResponse,
+ false
+ );
+ }
+
+ /**
+ * This method is triggered before a new file is created.
+ *
+ * This plugin uses this method to ensure that newly created calendar
+ * objects contain valid calendar data.
+ *
+ * @param string $path
+ * @param resource $data
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
+ */
+ public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified)
+ {
+ if (!$parentNode instanceof ICalendar) {
+ return;
+ }
+
+ $this->validateICalendar(
+ $data,
+ $path,
+ $modified,
+ $this->server->httpRequest,
+ $this->server->httpResponse,
+ true
+ );
+ }
+
+ /**
+ * Checks if the submitted iCalendar data is in fact, valid.
+ *
+ * An exception is thrown if it's not.
+ *
+ * @param resource|string $data
+ * @param string $path
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
+ * @param RequestInterface $request the http request
+ * @param ResponseInterface $response the http response
+ * @param bool $isNew is the item a new one, or an update
+ */
+ protected function validateICalendar(&$data, $path, &$modified, RequestInterface $request, ResponseInterface $response, $isNew)
+ {
+ // If it's a stream, we convert it to a string first.
+ if (is_resource($data)) {
+ $data = stream_get_contents($data);
+ }
+
+ $before = $data;
+
+ try {
+ // If the data starts with a [, we can reasonably assume we're dealing
+ // with a jCal object.
+ if ('[' === substr($data, 0, 1)) {
+ $vobj = VObject\Reader::readJson($data);
+
+ // Converting $data back to iCalendar, as that's what we
+ // technically support everywhere.
+ $data = $vobj->serialize();
+ $modified = true;
+ } else {
+ $vobj = VObject\Reader::read($data);
+ }
+ } catch (VObject\ParseException $e) {
+ throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid iCalendar 2.0 data. Parse error: '.$e->getMessage());
+ }
+
+ if ('VCALENDAR' !== $vobj->name) {
+ throw new DAV\Exception\UnsupportedMediaType('This collection can only support iCalendar objects.');
+ }
+
+ $sCCS = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
+
+ // Get the Supported Components for the target calendar
+ list($parentPath) = Uri\split($path);
+ $calendarProperties = $this->server->getProperties($parentPath, [$sCCS]);
+
+ if (isset($calendarProperties[$sCCS])) {
+ $supportedComponents = $calendarProperties[$sCCS]->getValue();
+ } else {
+ $supportedComponents = ['VJOURNAL', 'VTODO', 'VEVENT'];
+ }
+
+ $foundType = null;
+
+ foreach ($vobj->getComponents() as $component) {
+ switch ($component->name) {
+ case 'VTIMEZONE':
+ continue 2;
+ case 'VEVENT':
+ case 'VTODO':
+ case 'VJOURNAL':
+ $foundType = $component->name;
+ break;
+ }
+ }
+
+ if (!$foundType || !in_array($foundType, $supportedComponents)) {
+ throw new Exception\InvalidComponentType('iCalendar objects must at least have a component of type '.implode(', ', $supportedComponents));
+ }
+
+ $options = VObject\Node::PROFILE_CALDAV;
+ $prefer = $this->server->getHTTPPrefer();
+
+ if ('strict' !== $prefer['handling']) {
+ $options |= VObject\Node::REPAIR;
+ }
+
+ $messages = $vobj->validate($options);
+
+ $highestLevel = 0;
+ $warningMessage = null;
+
+ // $messages contains a list of problems with the vcard, along with
+ // their severity.
+ foreach ($messages as $message) {
+ if ($message['level'] > $highestLevel) {
+ // Recording the highest reported error level.
+ $highestLevel = $message['level'];
+ $warningMessage = $message['message'];
+ }
+ switch ($message['level']) {
+ case 1:
+ // Level 1 means that there was a problem, but it was repaired.
+ $modified = true;
+ break;
+ case 2:
+ // Level 2 means a warning, but not critical
+ break;
+ case 3:
+ // Level 3 means a critical error
+ throw new DAV\Exception\UnsupportedMediaType('Validation error in iCalendar: '.$message['message']);
+ }
+ }
+ if ($warningMessage) {
+ $response->setHeader(
+ 'X-Sabre-Ew-Gross',
+ 'iCalendar validation warning: '.$warningMessage
+ );
+ }
+
+ // We use an extra variable to allow event handles to tell us whether
+ // the object was modified or not.
+ //
+ // This helps us determine if we need to re-serialize the object.
+ $subModified = false;
+
+ $this->server->emit(
+ 'calendarObjectChange',
+ [
+ $request,
+ $response,
+ $vobj,
+ $parentPath,
+ &$subModified,
+ $isNew,
+ ]
+ );
+
+ if ($modified || $subModified) {
+ // An event handler told us that it modified the object.
+ $data = $vobj->serialize();
+
+ // Using md5 to figure out if there was an *actual* change.
+ if (!$modified && 0 !== strcmp($data, $before)) {
+ $modified = true;
+ }
+ }
+
+ // Destroy circular references so PHP will garbage collect the object.
+ $vobj->destroy();
+ }
+
+ /**
+ * This method is triggered whenever a subsystem requests the privileges
+ * that are supported on a particular node.
+ */
+ public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet)
+ {
+ if ($node instanceof ICalendar) {
+ $supportedPrivilegeSet['{DAV:}read']['aggregates']['{'.self::NS_CALDAV.'}read-free-busy'] = [
+ 'abstract' => false,
+ 'aggregates' => [],
+ ];
+ }
+ }
+
+ /**
+ * This method is used to generate HTML output for the
+ * DAV\Browser\Plugin. This allows us to generate an interface users
+ * can use to create new calendars.
+ *
+ * @param string $output
+ *
+ * @return bool
+ */
+ public function htmlActionsPanel(DAV\INode $node, &$output)
+ {
+ if (!$node instanceof CalendarHome) {
+ return;
+ }
+
+ $output .= '
+
';
+
+ return false;
+ }
+
+ /**
+ * This event is triggered after GET requests.
+ *
+ * This is used to transform data into jCal, if this was requested.
+ */
+ public function httpAfterGet(RequestInterface $request, ResponseInterface $response)
+ {
+ $contentType = $response->getHeader('Content-Type');
+ if (null === $contentType || false === strpos($contentType, 'text/calendar')) {
+ return;
+ }
+
+ $result = HTTP\negotiateContentType(
+ $request->getHeader('Accept'),
+ ['text/calendar', 'application/calendar+json']
+ );
+
+ if ('application/calendar+json' !== $result) {
+ // Do nothing
+ return;
+ }
+
+ // Transforming.
+ $vobj = VObject\Reader::read($response->getBody());
+
+ $jsonBody = json_encode($vobj->jsonSerialize());
+ $response->setBody($jsonBody);
+
+ // Destroy circular references so PHP will garbage collect the object.
+ $vobj->destroy();
+
+ $response->setHeader('Content-Type', 'application/calendar+json');
+ $response->setHeader('Content-Length', strlen($jsonBody));
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds support for CalDAV (rfc4791)',
+ 'link' => 'http://sabre.io/dav/caldav/',
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php
new file mode 100644
index 0000000..6d02303
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/Collection.php
@@ -0,0 +1,32 @@
+principalBackend, $principalInfo);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php
new file mode 100644
index 0000000..96e6991
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/IProxyRead.php
@@ -0,0 +1,21 @@
+principalInfo = $principalInfo;
+ $this->principalBackend = $principalBackend;
+ }
+
+ /**
+ * Returns this principals name.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'calendar-proxy-read';
+ }
+
+ /**
+ * Returns the last modification time.
+ */
+ public function getLastModified()
+ {
+ return null;
+ }
+
+ /**
+ * Deletes the current node.
+ *
+ * @throws DAV\Exception\Forbidden
+ */
+ public function delete()
+ {
+ throw new DAV\Exception\Forbidden('Permission denied to delete node');
+ }
+
+ /**
+ * Renames the node.
+ *
+ * @param string $name The new name
+ *
+ * @throws DAV\Exception\Forbidden
+ */
+ public function setName($name)
+ {
+ throw new DAV\Exception\Forbidden('Permission denied to rename file');
+ }
+
+ /**
+ * Returns a list of alternative urls for a principal.
+ *
+ * This can for example be an email address, or ldap url.
+ *
+ * @return array
+ */
+ public function getAlternateUriSet()
+ {
+ return [];
+ }
+
+ /**
+ * Returns the full principal url.
+ *
+ * @return string
+ */
+ public function getPrincipalUrl()
+ {
+ return $this->principalInfo['uri'].'/'.$this->getName();
+ }
+
+ /**
+ * Returns the list of group members.
+ *
+ * If this principal is a group, this function should return
+ * all member principal uri's for the group.
+ *
+ * @return array
+ */
+ public function getGroupMemberSet()
+ {
+ return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl());
+ }
+
+ /**
+ * Returns the list of groups this principal is member of.
+ *
+ * If this principal is a member of a (list of) groups, this function
+ * should return a list of principal uri's for it's members.
+ *
+ * @return array
+ */
+ public function getGroupMembership()
+ {
+ return $this->principalBackend->getGroupMembership($this->getPrincipalUrl());
+ }
+
+ /**
+ * Sets a list of group members.
+ *
+ * If this principal is a group, this method sets all the group members.
+ * The list of members is always overwritten, never appended to.
+ *
+ * This method should throw an exception if the members could not be set.
+ */
+ public function setGroupMemberSet(array $principals)
+ {
+ $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals);
+ }
+
+ /**
+ * Returns the displayname.
+ *
+ * This should be a human readable name for the principal.
+ * If none is available, return the nodename.
+ *
+ * @return string
+ */
+ public function getDisplayName()
+ {
+ return $this->getName();
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php
new file mode 100644
index 0000000..2d1ce7c
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/ProxyWrite.php
@@ -0,0 +1,161 @@
+principalInfo = $principalInfo;
+ $this->principalBackend = $principalBackend;
+ }
+
+ /**
+ * Returns this principals name.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'calendar-proxy-write';
+ }
+
+ /**
+ * Returns the last modification time.
+ */
+ public function getLastModified()
+ {
+ return null;
+ }
+
+ /**
+ * Deletes the current node.
+ *
+ * @throws DAV\Exception\Forbidden
+ */
+ public function delete()
+ {
+ throw new DAV\Exception\Forbidden('Permission denied to delete node');
+ }
+
+ /**
+ * Renames the node.
+ *
+ * @param string $name The new name
+ *
+ * @throws DAV\Exception\Forbidden
+ */
+ public function setName($name)
+ {
+ throw new DAV\Exception\Forbidden('Permission denied to rename file');
+ }
+
+ /**
+ * Returns a list of alternative urls for a principal.
+ *
+ * This can for example be an email address, or ldap url.
+ *
+ * @return array
+ */
+ public function getAlternateUriSet()
+ {
+ return [];
+ }
+
+ /**
+ * Returns the full principal url.
+ *
+ * @return string
+ */
+ public function getPrincipalUrl()
+ {
+ return $this->principalInfo['uri'].'/'.$this->getName();
+ }
+
+ /**
+ * Returns the list of group members.
+ *
+ * If this principal is a group, this function should return
+ * all member principal uri's for the group.
+ *
+ * @return array
+ */
+ public function getGroupMemberSet()
+ {
+ return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl());
+ }
+
+ /**
+ * Returns the list of groups this principal is member of.
+ *
+ * If this principal is a member of a (list of) groups, this function
+ * should return a list of principal uri's for it's members.
+ *
+ * @return array
+ */
+ public function getGroupMembership()
+ {
+ return $this->principalBackend->getGroupMembership($this->getPrincipalUrl());
+ }
+
+ /**
+ * Sets a list of group members.
+ *
+ * If this principal is a group, this method sets all the group members.
+ * The list of members is always overwritten, never appended to.
+ *
+ * This method should throw an exception if the members could not be set.
+ */
+ public function setGroupMemberSet(array $principals)
+ {
+ $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals);
+ }
+
+ /**
+ * Returns the displayname.
+ *
+ * This should be a human readable name for the principal.
+ * If none is available, return the nodename.
+ *
+ * @return string
+ */
+ public function getDisplayName()
+ {
+ return $this->getName();
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/User.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/User.php
new file mode 100644
index 0000000..88bf4b4
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Principal/User.php
@@ -0,0 +1,136 @@
+principalBackend->getPrincipalByPath($this->getPrincipalURL().'/'.$name);
+ if (!$principal) {
+ throw new DAV\Exception\NotFound('Node with name '.$name.' was not found');
+ }
+ if ('calendar-proxy-read' === $name) {
+ return new ProxyRead($this->principalBackend, $this->principalProperties);
+ }
+
+ if ('calendar-proxy-write' === $name) {
+ return new ProxyWrite($this->principalBackend, $this->principalProperties);
+ }
+
+ throw new DAV\Exception\NotFound('Node with name '.$name.' was not found');
+ }
+
+ /**
+ * Returns an array with all the child nodes.
+ *
+ * @return DAV\INode[]
+ */
+ public function getChildren()
+ {
+ $r = [];
+ if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL().'/calendar-proxy-read')) {
+ $r[] = new ProxyRead($this->principalBackend, $this->principalProperties);
+ }
+ if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL().'/calendar-proxy-write')) {
+ $r[] = new ProxyWrite($this->principalBackend, $this->principalProperties);
+ }
+
+ return $r;
+ }
+
+ /**
+ * Returns whether or not the child node exists.
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ public function childExists($name)
+ {
+ try {
+ $this->getChild($name);
+
+ return true;
+ } catch (DAV\Exception\NotFound $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ $acl = parent::getACL();
+ $acl[] = [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->principalProperties['uri'].'/calendar-proxy-read',
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->principalProperties['uri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+
+ return $acl;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php
new file mode 100644
index 0000000..64a94be
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php
@@ -0,0 +1,17 @@
+senderEmail = $senderEmail;
+ }
+
+ /*
+ * This initializes the plugin.
+ *
+ * This function is called by Sabre\DAV\Server, after
+ * addPlugin is called.
+ *
+ * This method should set up the required event subscriptions.
+ *
+ * @param DAV\Server $server
+ * @return void
+ */
+ public function initialize(DAV\Server $server)
+ {
+ $server->on('schedule', [$this, 'schedule'], 120);
+ }
+
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins
+ * using \Sabre\DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return 'imip';
+ }
+
+ /**
+ * Event handler for the 'schedule' event.
+ */
+ public function schedule(ITip\Message $iTipMessage)
+ {
+ // Not sending any emails if the system considers the update
+ // insignificant.
+ if (!$iTipMessage->significantChange) {
+ if (!$iTipMessage->scheduleStatus) {
+ $iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email';
+ }
+
+ return;
+ }
+
+ $summary = $iTipMessage->message->VEVENT->SUMMARY;
+
+ if ('mailto' !== parse_url($iTipMessage->sender, PHP_URL_SCHEME)) {
+ return;
+ }
+
+ if ('mailto' !== parse_url($iTipMessage->recipient, PHP_URL_SCHEME)) {
+ return;
+ }
+
+ $sender = substr($iTipMessage->sender, 7);
+ $recipient = substr($iTipMessage->recipient, 7);
+
+ if ($iTipMessage->senderName) {
+ $sender = $iTipMessage->senderName.' <'.$sender.'>';
+ }
+ if ($iTipMessage->recipientName && $iTipMessage->recipientName != $recipient) {
+ $recipient = $iTipMessage->recipientName.' <'.$recipient.'>';
+ }
+
+ $subject = 'SabreDAV iTIP message';
+ switch (strtoupper($iTipMessage->method)) {
+ case 'REPLY':
+ $subject = 'Re: '.$summary;
+ break;
+ case 'REQUEST':
+ $subject = 'Invitation: '.$summary;
+ break;
+ case 'CANCEL':
+ $subject = 'Cancelled: '.$summary;
+ break;
+ }
+
+ $headers = [
+ 'Reply-To: '.$sender,
+ 'From: '.$iTipMessage->senderName.' <'.$this->senderEmail.'>',
+ 'MIME-Version: 1.0',
+ 'Content-Type: text/calendar; charset=UTF-8; method='.$iTipMessage->method,
+ ];
+ if (DAV\Server::$exposeVersion) {
+ $headers[] = 'X-Sabre-Version: '.DAV\Version::VERSION;
+ }
+ $this->mail(
+ $recipient,
+ $subject,
+ $iTipMessage->message->serialize(),
+ $headers
+ );
+ $iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip';
+ }
+
+ // @codeCoverageIgnoreStart
+ // This is deemed untestable in a reasonable manner
+
+ /**
+ * This function is responsible for sending the actual email.
+ *
+ * @param string $to Recipient email address
+ * @param string $subject Subject of the email
+ * @param string $body iCalendar body
+ * @param array $headers List of headers
+ */
+ protected function mail($to, $subject, $body, array $headers)
+ {
+ mail($to, $subject, $body, implode("\r\n", $headers));
+ }
+
+ // @codeCoverageIgnoreEnd
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Email delivery (rfc6047) for CalDAV scheduling',
+ 'link' => 'http://sabre.io/dav/scheduling/',
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php
new file mode 100644
index 0000000..384b503
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php
@@ -0,0 +1,17 @@
+caldavBackend = $caldavBackend;
+ $this->principalUri = $principalUri;
+ }
+
+ /**
+ * Returns the name of the node.
+ *
+ * This is used to generate the url.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'inbox';
+ }
+
+ /**
+ * Returns an array with all the child nodes.
+ *
+ * @return \Sabre\DAV\INode[]
+ */
+ public function getChildren()
+ {
+ $objs = $this->caldavBackend->getSchedulingObjects($this->principalUri);
+ $children = [];
+ foreach ($objs as $obj) {
+ //$obj['acl'] = $this->getACL();
+ $obj['principaluri'] = $this->principalUri;
+ $children[] = new SchedulingObject($this->caldavBackend, $obj);
+ }
+
+ return $children;
+ }
+
+ /**
+ * Creates a new file in the directory.
+ *
+ * Data will either be supplied as a stream resource, or in certain cases
+ * as a string. Keep in mind that you may have to support either.
+ *
+ * After successful creation of the file, you may choose to return the ETag
+ * of the new file here.
+ *
+ * The returned ETag must be surrounded by double-quotes (The quotes should
+ * be part of the actual string).
+ *
+ * If you cannot accurately determine the ETag, you should not return it.
+ * If you don't store the file exactly as-is (you're transforming it
+ * somehow) you should also not return an ETag.
+ *
+ * This means that if a subsequent GET to this new file does not exactly
+ * return the same contents of what was submitted here, you are strongly
+ * recommended to omit the ETag.
+ *
+ * @param string $name Name of the file
+ * @param resource|string $data Initial payload
+ *
+ * @return string|null
+ */
+ public function createFile($name, $data = null)
+ {
+ $this->caldavBackend->createSchedulingObject($this->principalUri, $name, $data);
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->principalUri;
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ return [
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => '{DAV:}authenticated',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}write-properties',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}unbind',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}unbind',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-deliver',
+ 'principal' => '{DAV:}authenticated',
+ 'protected' => true,
+ ],
+ ];
+ }
+
+ /**
+ * Performs a calendar-query on the contents of this calendar.
+ *
+ * The calendar-query is defined in RFC4791 : CalDAV. Using the
+ * calendar-query it is possible for a client to request a specific set of
+ * object, based on contents of iCalendar properties, date-ranges and
+ * iCalendar component types (VTODO, VEVENT).
+ *
+ * This method should just return a list of (relative) urls that match this
+ * query.
+ *
+ * The list of filters are specified as an array. The exact array is
+ * documented by \Sabre\CalDAV\CalendarQueryParser.
+ *
+ * @return array
+ */
+ public function calendarQuery(array $filters)
+ {
+ $result = [];
+ $validator = new CalDAV\CalendarQueryValidator();
+
+ $objects = $this->caldavBackend->getSchedulingObjects($this->principalUri);
+ foreach ($objects as $object) {
+ $vObject = VObject\Reader::read($object['calendardata']);
+ if ($validator->validate($vObject, $filters)) {
+ $result[] = $object['uri'];
+ }
+
+ // Destroy circular references to PHP will GC the object.
+ $vObject->destroy();
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php
new file mode 100644
index 0000000..1442c4c
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php
@@ -0,0 +1,119 @@
+principalUri = $principalUri;
+ }
+
+ /**
+ * Returns the name of the node.
+ *
+ * This is used to generate the url.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return 'outbox';
+ }
+
+ /**
+ * Returns an array with all the child nodes.
+ *
+ * @return \Sabre\DAV\INode[]
+ */
+ public function getChildren()
+ {
+ return [];
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->principalUri;
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ return [
+ [
+ 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner().'/calendar-proxy-read',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php
new file mode 100644
index 0000000..5bca56d
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php
@@ -0,0 +1,1006 @@
+server = $server;
+ $server->on('method:POST', [$this, 'httpPost']);
+ $server->on('propFind', [$this, 'propFind']);
+ $server->on('propPatch', [$this, 'propPatch']);
+ $server->on('calendarObjectChange', [$this, 'calendarObjectChange']);
+ $server->on('beforeUnbind', [$this, 'beforeUnbind']);
+ $server->on('schedule', [$this, 'scheduleLocalDelivery']);
+ $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']);
+
+ $ns = '{'.self::NS_CALDAV.'}';
+
+ /*
+ * This information ensures that the {DAV:}resourcetype property has
+ * the correct values.
+ */
+ $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns.'schedule-outbox';
+ $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns.'schedule-inbox';
+
+ /*
+ * Properties we protect are made read-only by the server.
+ */
+ array_push($server->protectedProperties,
+ $ns.'schedule-inbox-URL',
+ $ns.'schedule-outbox-URL',
+ $ns.'calendar-user-address-set',
+ $ns.'calendar-user-type',
+ $ns.'schedule-default-calendar-URL'
+ );
+ }
+
+ /**
+ * Use this method to tell the server this plugin defines additional
+ * HTTP methods.
+ *
+ * This method is passed a uri. It should only return HTTP methods that are
+ * available for the specified uri.
+ *
+ * @param string $uri
+ *
+ * @return array
+ */
+ public function getHTTPMethods($uri)
+ {
+ try {
+ $node = $this->server->tree->getNodeForPath($uri);
+ } catch (NotFound $e) {
+ return [];
+ }
+
+ if ($node instanceof IOutbox) {
+ return ['POST'];
+ }
+
+ return [];
+ }
+
+ /**
+ * This method handles POST request for the outbox.
+ *
+ * @return bool
+ */
+ public function httpPost(RequestInterface $request, ResponseInterface $response)
+ {
+ // Checking if this is a text/calendar content type
+ $contentType = $request->getHeader('Content-Type');
+ if (!$contentType || 0 !== strpos($contentType, 'text/calendar')) {
+ return;
+ }
+
+ $path = $request->getPath();
+
+ // Checking if we're talking to an outbox
+ try {
+ $node = $this->server->tree->getNodeForPath($path);
+ } catch (NotFound $e) {
+ return;
+ }
+ if (!$node instanceof IOutbox) {
+ return;
+ }
+
+ $this->server->transactionType = 'post-caldav-outbox';
+ $this->outboxRequest($node, $request, $response);
+
+ // Returning false breaks the event chain and tells the server we've
+ // handled the request.
+ return false;
+ }
+
+ /**
+ * This method handler is invoked during fetching of properties.
+ *
+ * We use this event to add calendar-auto-schedule-specific properties.
+ */
+ public function propFind(PropFind $propFind, INode $node)
+ {
+ if ($node instanceof DAVACL\IPrincipal) {
+ $caldavPlugin = $this->server->getPlugin('caldav');
+ $principalUrl = $node->getPrincipalUrl();
+
+ // schedule-outbox-URL property
+ $propFind->handle('{'.self::NS_CALDAV.'}schedule-outbox-URL', function () use ($principalUrl, $caldavPlugin) {
+ $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
+ if (!$calendarHomePath) {
+ return null;
+ }
+ $outboxPath = $calendarHomePath.'/outbox/';
+
+ return new LocalHref($outboxPath);
+ });
+ // schedule-inbox-URL property
+ $propFind->handle('{'.self::NS_CALDAV.'}schedule-inbox-URL', function () use ($principalUrl, $caldavPlugin) {
+ $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
+ if (!$calendarHomePath) {
+ return null;
+ }
+ $inboxPath = $calendarHomePath.'/inbox/';
+
+ return new LocalHref($inboxPath);
+ });
+
+ $propFind->handle('{'.self::NS_CALDAV.'}schedule-default-calendar-URL', function () use ($principalUrl, $caldavPlugin) {
+ // We don't support customizing this property yet, so in the
+ // meantime we just grab the first calendar in the home-set.
+ $calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
+
+ if (!$calendarHomePath) {
+ return null;
+ }
+
+ $sccs = '{'.self::NS_CALDAV.'}supported-calendar-component-set';
+
+ $result = $this->server->getPropertiesForPath($calendarHomePath, [
+ '{DAV:}resourcetype',
+ '{DAV:}share-access',
+ $sccs,
+ ], 1);
+
+ foreach ($result as $child) {
+ if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{'.self::NS_CALDAV.'}calendar')) {
+ // Node is either not a calendar
+ continue;
+ }
+ if (isset($child[200]['{DAV:}share-access'])) {
+ $shareAccess = $child[200]['{DAV:}share-access']->getValue();
+ if (Sharing\Plugin::ACCESS_NOTSHARED !== $shareAccess && Sharing\Plugin::ACCESS_SHAREDOWNER !== $shareAccess) {
+ // Node is a shared node, not owned by the relevant
+ // user.
+ continue;
+ }
+ }
+ if (!isset($child[200][$sccs]) || in_array('VEVENT', $child[200][$sccs]->getValue())) {
+ // Either there is no supported-calendar-component-set
+ // (which is fine) or we found one that supports VEVENT.
+ return new LocalHref($child['href']);
+ }
+ }
+ });
+
+ // The server currently reports every principal to be of type
+ // 'INDIVIDUAL'
+ $propFind->handle('{'.self::NS_CALDAV.'}calendar-user-type', function () {
+ return 'INDIVIDUAL';
+ });
+ }
+
+ // Mapping the old property to the new property.
+ $propFind->handle('{http://calendarserver.org/ns/}calendar-availability', function () use ($propFind, $node) {
+ // In case it wasn't clear, the only difference is that we map the
+ // old property to a different namespace.
+ $availProp = '{'.self::NS_CALDAV.'}calendar-availability';
+ $subPropFind = new PropFind(
+ $propFind->getPath(),
+ [$availProp]
+ );
+
+ $this->server->getPropertiesByNode(
+ $subPropFind,
+ $node
+ );
+
+ $propFind->set(
+ '{http://calendarserver.org/ns/}calendar-availability',
+ $subPropFind->get($availProp),
+ $subPropFind->getStatus($availProp)
+ );
+ });
+ }
+
+ /**
+ * This method is called during property updates.
+ *
+ * @param string $path
+ */
+ public function propPatch($path, PropPatch $propPatch)
+ {
+ // Mapping the old property to the new property.
+ $propPatch->handle('{http://calendarserver.org/ns/}calendar-availability', function ($value) use ($path) {
+ $availProp = '{'.self::NS_CALDAV.'}calendar-availability';
+ $subPropPatch = new PropPatch([$availProp => $value]);
+ $this->server->emit('propPatch', [$path, $subPropPatch]);
+ $subPropPatch->commit();
+
+ return $subPropPatch->getResult()[$availProp];
+ });
+ }
+
+ /**
+ * This method is triggered whenever there was a calendar object gets
+ * created or updated.
+ *
+ * @param RequestInterface $request HTTP request
+ * @param ResponseInterface $response HTTP Response
+ * @param VCalendar $vCal Parsed iCalendar object
+ * @param mixed $calendarPath Path to calendar collection
+ * @param mixed $modified the iCalendar object has been touched
+ * @param mixed $isNew Whether this was a new item or we're updating one
+ */
+ public function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew)
+ {
+ if (!$this->scheduleReply($this->server->httpRequest)) {
+ return;
+ }
+
+ $calendarNode = $this->server->tree->getNodeForPath($calendarPath);
+
+ $addresses = $this->getAddressesForPrincipal(
+ $calendarNode->getOwner()
+ );
+
+ if (!$isNew) {
+ $node = $this->server->tree->getNodeForPath($request->getPath());
+ $oldObj = Reader::read($node->get());
+ } else {
+ $oldObj = null;
+ }
+
+ $this->processICalendarChange($oldObj, $vCal, $addresses, [], $modified);
+
+ if ($oldObj) {
+ // Destroy circular references so PHP will GC the object.
+ $oldObj->destroy();
+ }
+ }
+
+ /**
+ * This method is responsible for delivering the ITip message.
+ */
+ public function deliver(ITip\Message $iTipMessage)
+ {
+ $this->server->emit('schedule', [$iTipMessage]);
+ if (!$iTipMessage->scheduleStatus) {
+ $iTipMessage->scheduleStatus = '5.2;There was no system capable of delivering the scheduling message';
+ }
+ // In case the change was considered 'insignificant', we are going to
+ // remove any error statuses, if any. See ticket #525.
+ list($baseCode) = explode('.', $iTipMessage->scheduleStatus);
+ if (!$iTipMessage->significantChange && in_array($baseCode, ['3', '5'])) {
+ $iTipMessage->scheduleStatus = null;
+ }
+ }
+
+ /**
+ * This method is triggered before a file gets deleted.
+ *
+ * We use this event to make sure that when this happens, attendees get
+ * cancellations, and organizers get 'DECLINED' statuses.
+ *
+ * @param string $path
+ */
+ public function beforeUnbind($path)
+ {
+ // FIXME: We shouldn't trigger this functionality when we're issuing a
+ // MOVE. This is a hack.
+ if ('MOVE' === $this->server->httpRequest->getMethod()) {
+ return;
+ }
+
+ $node = $this->server->tree->getNodeForPath($path);
+
+ if (!$node instanceof ICalendarObject || $node instanceof ISchedulingObject) {
+ return;
+ }
+
+ if (!$this->scheduleReply($this->server->httpRequest)) {
+ return;
+ }
+
+ $addresses = $this->getAddressesForPrincipal(
+ $node->getOwner()
+ );
+
+ $broker = $this->createITipBroker();
+ $messages = $broker->parseEvent(null, $addresses, $node->get());
+
+ foreach ($messages as $message) {
+ $this->deliver($message);
+ }
+ }
+
+ /**
+ * Event handler for the 'schedule' event.
+ *
+ * This handler attempts to look at local accounts to deliver the
+ * scheduling object.
+ */
+ public function scheduleLocalDelivery(ITip\Message $iTipMessage)
+ {
+ $aclPlugin = $this->server->getPlugin('acl');
+
+ // Local delivery is not available if the ACL plugin is not loaded.
+ if (!$aclPlugin) {
+ return;
+ }
+
+ $caldavNS = '{'.self::NS_CALDAV.'}';
+
+ $principalUri = $aclPlugin->getPrincipalByUri($iTipMessage->recipient);
+ if (!$principalUri) {
+ $iTipMessage->scheduleStatus = '3.7;Could not find principal.';
+
+ return;
+ }
+
+ // We found a principal URL, now we need to find its inbox.
+ // Unfortunately we may not have sufficient privileges to find this, so
+ // we are temporarily turning off ACL to let this come through.
+ //
+ // Once we support PHP 5.5, this should be wrapped in a try..finally
+ // block so we can ensure that this privilege gets added again after.
+ $this->server->removeListener('propFind', [$aclPlugin, 'propFind']);
+
+ $result = $this->server->getProperties(
+ $principalUri,
+ [
+ '{DAV:}principal-URL',
+ $caldavNS.'calendar-home-set',
+ $caldavNS.'schedule-inbox-URL',
+ $caldavNS.'schedule-default-calendar-URL',
+ '{http://sabredav.org/ns}email-address',
+ ]
+ );
+
+ // Re-registering the ACL event
+ $this->server->on('propFind', [$aclPlugin, 'propFind'], 20);
+
+ if (!isset($result[$caldavNS.'schedule-inbox-URL'])) {
+ $iTipMessage->scheduleStatus = '5.2;Could not find local inbox';
+
+ return;
+ }
+ if (!isset($result[$caldavNS.'calendar-home-set'])) {
+ $iTipMessage->scheduleStatus = '5.2;Could not locate a calendar-home-set';
+
+ return;
+ }
+ if (!isset($result[$caldavNS.'schedule-default-calendar-URL'])) {
+ $iTipMessage->scheduleStatus = '5.2;Could not find a schedule-default-calendar-URL property';
+
+ return;
+ }
+
+ $calendarPath = $result[$caldavNS.'schedule-default-calendar-URL']->getHref();
+ $homePath = $result[$caldavNS.'calendar-home-set']->getHref();
+ $inboxPath = $result[$caldavNS.'schedule-inbox-URL']->getHref();
+
+ if ('REPLY' === $iTipMessage->method) {
+ $privilege = 'schedule-deliver-reply';
+ } else {
+ $privilege = 'schedule-deliver-invite';
+ }
+
+ if (!$aclPlugin->checkPrivileges($inboxPath, $caldavNS.$privilege, DAVACL\Plugin::R_PARENT, false)) {
+ $iTipMessage->scheduleStatus = '3.8;insufficient privileges: '.$privilege.' is required on the recipient schedule inbox.';
+
+ return;
+ }
+
+ // Next, we're going to find out if the item already exits in one of
+ // the users' calendars.
+ $uid = $iTipMessage->uid;
+
+ $newFileName = 'sabredav-'.\Sabre\DAV\UUIDUtil::getUUID().'.ics';
+
+ $home = $this->server->tree->getNodeForPath($homePath);
+ $inbox = $this->server->tree->getNodeForPath($inboxPath);
+
+ $currentObject = null;
+ $objectNode = null;
+ $oldICalendarData = null;
+ $isNewNode = false;
+
+ $result = $home->getCalendarObjectByUID($uid);
+ if ($result) {
+ // There was an existing object, we need to update probably.
+ $objectPath = $homePath.'/'.$result;
+ $objectNode = $this->server->tree->getNodeForPath($objectPath);
+ $oldICalendarData = $objectNode->get();
+ $currentObject = Reader::read($oldICalendarData);
+ } else {
+ $isNewNode = true;
+ }
+
+ $broker = $this->createITipBroker();
+ $newObject = $broker->processMessage($iTipMessage, $currentObject);
+
+ $inbox->createFile($newFileName, $iTipMessage->message->serialize());
+
+ if (!$newObject) {
+ // We received an iTip message referring to a UID that we don't
+ // have in any calendars yet, and processMessage did not give us a
+ // calendarobject back.
+ //
+ // The implication is that processMessage did not understand the
+ // iTip message.
+ $iTipMessage->scheduleStatus = '5.0;iTip message was not processed by the server, likely because we didn\'t understand it.';
+
+ return;
+ }
+
+ // Note that we are bypassing ACL on purpose by calling this directly.
+ // We may need to look a bit deeper into this later. Supporting ACL
+ // here would be nice.
+ if ($isNewNode) {
+ $calendar = $this->server->tree->getNodeForPath($calendarPath);
+ $calendar->createFile($newFileName, $newObject->serialize());
+ } else {
+ // If the message was a reply, we may have to inform other
+ // attendees of this attendees status. Therefore we're shooting off
+ // another itipMessage.
+ if ('REPLY' === $iTipMessage->method) {
+ $this->processICalendarChange(
+ $oldICalendarData,
+ $newObject,
+ [$iTipMessage->recipient],
+ [$iTipMessage->sender]
+ );
+ }
+ $objectNode->put($newObject->serialize());
+ }
+ $iTipMessage->scheduleStatus = '1.2;Message delivered locally';
+ }
+
+ /**
+ * This method is triggered whenever a subsystem requests the privileges
+ * that are supported on a particular node.
+ *
+ * We need to add a number of privileges for scheduling purposes.
+ */
+ public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet)
+ {
+ $ns = '{'.self::NS_CALDAV.'}';
+ if ($node instanceof IOutbox) {
+ $supportedPrivilegeSet[$ns.'schedule-send'] = [
+ 'abstract' => false,
+ 'aggregates' => [
+ $ns.'schedule-send-invite' => [
+ 'abstract' => false,
+ 'aggregates' => [],
+ ],
+ $ns.'schedule-send-reply' => [
+ 'abstract' => false,
+ 'aggregates' => [],
+ ],
+ $ns.'schedule-send-freebusy' => [
+ 'abstract' => false,
+ 'aggregates' => [],
+ ],
+ // Privilege from an earlier scheduling draft, but still
+ // used by some clients.
+ $ns.'schedule-post-vevent' => [
+ 'abstract' => false,
+ 'aggregates' => [],
+ ],
+ ],
+ ];
+ }
+ if ($node instanceof IInbox) {
+ $supportedPrivilegeSet[$ns.'schedule-deliver'] = [
+ 'abstract' => false,
+ 'aggregates' => [
+ $ns.'schedule-deliver-invite' => [
+ 'abstract' => false,
+ 'aggregates' => [],
+ ],
+ $ns.'schedule-deliver-reply' => [
+ 'abstract' => false,
+ 'aggregates' => [],
+ ],
+ $ns.'schedule-query-freebusy' => [
+ 'abstract' => false,
+ 'aggregates' => [],
+ ],
+ ],
+ ];
+ }
+ }
+
+ /**
+ * This method looks at an old iCalendar object, a new iCalendar object and
+ * starts sending scheduling messages based on the changes.
+ *
+ * A list of addresses needs to be specified, so the system knows who made
+ * the update, because the behavior may be different based on if it's an
+ * attendee or an organizer.
+ *
+ * This method may update $newObject to add any status changes.
+ *
+ * @param VCalendar|string|null $oldObject
+ * @param array $ignore any addresses to not send messages to
+ * @param bool $modified a marker to indicate that the original object modified by this process
+ */
+ protected function processICalendarChange($oldObject, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false)
+ {
+ $broker = $this->createITipBroker();
+ $messages = $broker->parseEvent($newObject, $addresses, $oldObject);
+
+ if ($messages) {
+ $modified = true;
+ }
+
+ foreach ($messages as $message) {
+ if (in_array($message->recipient, $ignore)) {
+ continue;
+ }
+
+ $this->deliver($message);
+
+ if (isset($newObject->VEVENT->ORGANIZER) && ($newObject->VEVENT->ORGANIZER->getNormalizedValue() === $message->recipient)) {
+ if ($message->scheduleStatus) {
+ $newObject->VEVENT->ORGANIZER['SCHEDULE-STATUS'] = $message->getScheduleStatus();
+ }
+ unset($newObject->VEVENT->ORGANIZER['SCHEDULE-FORCE-SEND']);
+ } else {
+ if (isset($newObject->VEVENT->ATTENDEE)) {
+ foreach ($newObject->VEVENT->ATTENDEE as $attendee) {
+ if ($attendee->getNormalizedValue() === $message->recipient) {
+ if ($message->scheduleStatus) {
+ $attendee['SCHEDULE-STATUS'] = $message->getScheduleStatus();
+ }
+ unset($attendee['SCHEDULE-FORCE-SEND']);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns a list of addresses that are associated with a principal.
+ *
+ * @param string $principal
+ *
+ * @return array
+ */
+ protected function getAddressesForPrincipal($principal)
+ {
+ $CUAS = '{'.self::NS_CALDAV.'}calendar-user-address-set';
+
+ $properties = $this->server->getProperties(
+ $principal,
+ [$CUAS]
+ );
+
+ // If we can't find this information, we'll stop processing
+ if (!isset($properties[$CUAS])) {
+ return [];
+ }
+
+ $addresses = $properties[$CUAS]->getHrefs();
+
+ return $addresses;
+ }
+
+ /**
+ * This method handles POST requests to the schedule-outbox.
+ *
+ * Currently, two types of requests are supported:
+ * * FREEBUSY requests from RFC 6638
+ * * Simple iTIP messages from draft-desruisseaux-caldav-sched-04
+ *
+ * The latter is from an expired early draft of the CalDAV scheduling
+ * extensions, but iCal depends on a feature from that spec, so we
+ * implement it.
+ */
+ public function outboxRequest(IOutbox $outboxNode, RequestInterface $request, ResponseInterface $response)
+ {
+ $outboxPath = $request->getPath();
+
+ // Parsing the request body
+ try {
+ $vObject = VObject\Reader::read($request->getBody());
+ } catch (VObject\ParseException $e) {
+ throw new BadRequest('The request body must be a valid iCalendar object. Parse error: '.$e->getMessage());
+ }
+
+ // The incoming iCalendar object must have a METHOD property, and a
+ // component. The combination of both determines what type of request
+ // this is.
+ $componentType = null;
+ foreach ($vObject->getComponents() as $component) {
+ if ('VTIMEZONE' !== $component->name) {
+ $componentType = $component->name;
+ break;
+ }
+ }
+ if (is_null($componentType)) {
+ throw new BadRequest('We expected at least one VTODO, VJOURNAL, VFREEBUSY or VEVENT component');
+ }
+
+ // Validating the METHOD
+ $method = strtoupper((string) $vObject->METHOD);
+ if (!$method) {
+ throw new BadRequest('A METHOD property must be specified in iTIP messages');
+ }
+
+ // So we support one type of request:
+ //
+ // REQUEST with a VFREEBUSY component
+
+ $acl = $this->server->getPlugin('acl');
+
+ if ('VFREEBUSY' === $componentType && 'REQUEST' === $method) {
+ $acl && $acl->checkPrivileges($outboxPath, '{'.self::NS_CALDAV.'}schedule-send-freebusy');
+ $this->handleFreeBusyRequest($outboxNode, $vObject, $request, $response);
+
+ // Destroy circular references so PHP can GC the object.
+ $vObject->destroy();
+ unset($vObject);
+ } else {
+ throw new NotImplemented('We only support VFREEBUSY (REQUEST) on this endpoint');
+ }
+ }
+
+ /**
+ * This method is responsible for parsing a free-busy query request and
+ * returning its result in $response.
+ */
+ protected function handleFreeBusyRequest(IOutbox $outbox, VObject\Component $vObject, RequestInterface $request, ResponseInterface $response)
+ {
+ $vFreeBusy = $vObject->VFREEBUSY;
+ $organizer = $vFreeBusy->ORGANIZER;
+
+ $organizer = (string) $organizer;
+
+ // Validating if the organizer matches the owner of the inbox.
+ $owner = $outbox->getOwner();
+
+ $caldavNS = '{'.self::NS_CALDAV.'}';
+
+ $uas = $caldavNS.'calendar-user-address-set';
+ $props = $this->server->getProperties($owner, [$uas]);
+
+ if (empty($props[$uas]) || !in_array($organizer, $props[$uas]->getHrefs())) {
+ throw new Forbidden('The organizer in the request did not match any of the addresses for the owner of this inbox');
+ }
+
+ if (!isset($vFreeBusy->ATTENDEE)) {
+ throw new BadRequest('You must at least specify 1 attendee');
+ }
+
+ $attendees = [];
+ foreach ($vFreeBusy->ATTENDEE as $attendee) {
+ $attendees[] = (string) $attendee;
+ }
+
+ if (!isset($vFreeBusy->DTSTART) || !isset($vFreeBusy->DTEND)) {
+ throw new BadRequest('DTSTART and DTEND must both be specified');
+ }
+
+ $startRange = $vFreeBusy->DTSTART->getDateTime();
+ $endRange = $vFreeBusy->DTEND->getDateTime();
+
+ $results = [];
+ foreach ($attendees as $attendee) {
+ $results[] = $this->getFreeBusyForEmail($attendee, $startRange, $endRange, $vObject);
+ }
+
+ $dom = new \DOMDocument('1.0', 'utf-8');
+ $dom->formatOutput = true;
+ $scheduleResponse = $dom->createElement('cal:schedule-response');
+ foreach ($this->server->xml->namespaceMap as $namespace => $prefix) {
+ $scheduleResponse->setAttribute('xmlns:'.$prefix, $namespace);
+ }
+ $dom->appendChild($scheduleResponse);
+
+ foreach ($results as $result) {
+ $xresponse = $dom->createElement('cal:response');
+
+ $recipient = $dom->createElement('cal:recipient');
+ $recipientHref = $dom->createElement('d:href');
+
+ $recipientHref->appendChild($dom->createTextNode($result['href']));
+ $recipient->appendChild($recipientHref);
+ $xresponse->appendChild($recipient);
+
+ $reqStatus = $dom->createElement('cal:request-status');
+ $reqStatus->appendChild($dom->createTextNode($result['request-status']));
+ $xresponse->appendChild($reqStatus);
+
+ if (isset($result['calendar-data'])) {
+ $calendardata = $dom->createElement('cal:calendar-data');
+ $calendardata->appendChild($dom->createTextNode(str_replace("\r\n", "\n", $result['calendar-data']->serialize())));
+ $xresponse->appendChild($calendardata);
+ }
+ $scheduleResponse->appendChild($xresponse);
+ }
+
+ $response->setStatus(200);
+ $response->setHeader('Content-Type', 'application/xml');
+ $response->setBody($dom->saveXML());
+ }
+
+ /**
+ * Returns free-busy information for a specific address. The returned
+ * data is an array containing the following properties:.
+ *
+ * calendar-data : A VFREEBUSY VObject
+ * request-status : an iTip status code.
+ * href: The principal's email address, as requested
+ *
+ * The following request status codes may be returned:
+ * * 2.0;description
+ * * 3.7;description
+ *
+ * @param string $email address
+ *
+ * @return array
+ */
+ protected function getFreeBusyForEmail($email, \DateTimeInterface $start, \DateTimeInterface $end, VObject\Component $request)
+ {
+ $caldavNS = '{'.self::NS_CALDAV.'}';
+
+ $aclPlugin = $this->server->getPlugin('acl');
+ if ('mailto:' === substr($email, 0, 7)) {
+ $email = substr($email, 7);
+ }
+
+ $result = $aclPlugin->principalSearch(
+ ['{http://sabredav.org/ns}email-address' => $email],
+ [
+ '{DAV:}principal-URL',
+ $caldavNS.'calendar-home-set',
+ $caldavNS.'schedule-inbox-URL',
+ '{http://sabredav.org/ns}email-address',
+ ]
+ );
+
+ if (!count($result)) {
+ return [
+ 'request-status' => '3.7;Could not find principal',
+ 'href' => 'mailto:'.$email,
+ ];
+ }
+
+ if (!isset($result[0][200][$caldavNS.'calendar-home-set'])) {
+ return [
+ 'request-status' => '3.7;No calendar-home-set property found',
+ 'href' => 'mailto:'.$email,
+ ];
+ }
+ if (!isset($result[0][200][$caldavNS.'schedule-inbox-URL'])) {
+ return [
+ 'request-status' => '3.7;No schedule-inbox-URL property found',
+ 'href' => 'mailto:'.$email,
+ ];
+ }
+ $homeSet = $result[0][200][$caldavNS.'calendar-home-set']->getHref();
+ $inboxUrl = $result[0][200][$caldavNS.'schedule-inbox-URL']->getHref();
+
+ // Do we have permission?
+ $aclPlugin->checkPrivileges($inboxUrl, $caldavNS.'schedule-query-freebusy');
+
+ // Grabbing the calendar list
+ $objects = [];
+ $calendarTimeZone = new DateTimeZone('UTC');
+
+ foreach ($this->server->tree->getNodeForPath($homeSet)->getChildren() as $node) {
+ if (!$node instanceof ICalendar) {
+ continue;
+ }
+
+ $sct = $caldavNS.'schedule-calendar-transp';
+ $ctz = $caldavNS.'calendar-timezone';
+ $props = $node->getProperties([$sct, $ctz]);
+
+ if (isset($props[$sct]) && ScheduleCalendarTransp::TRANSPARENT == $props[$sct]->getValue()) {
+ // If a calendar is marked as 'transparent', it means we must
+ // ignore it for free-busy purposes.
+ continue;
+ }
+
+ if (isset($props[$ctz])) {
+ $vtimezoneObj = VObject\Reader::read($props[$ctz]);
+ $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
+
+ // Destroy circular references so PHP can garbage collect the object.
+ $vtimezoneObj->destroy();
+ }
+
+ // Getting the list of object uris within the time-range
+ $urls = $node->calendarQuery([
+ 'name' => 'VCALENDAR',
+ 'comp-filters' => [
+ [
+ 'name' => 'VEVENT',
+ 'comp-filters' => [],
+ 'prop-filters' => [],
+ 'is-not-defined' => false,
+ 'time-range' => [
+ 'start' => $start,
+ 'end' => $end,
+ ],
+ ],
+ ],
+ 'prop-filters' => [],
+ 'is-not-defined' => false,
+ 'time-range' => null,
+ ]);
+
+ $calObjects = array_map(function ($url) use ($node) {
+ $obj = $node->getChild($url)->get();
+
+ return $obj;
+ }, $urls);
+
+ $objects = array_merge($objects, $calObjects);
+ }
+
+ $inboxProps = $this->server->getProperties(
+ $inboxUrl,
+ $caldavNS.'calendar-availability'
+ );
+
+ $vcalendar = new VObject\Component\VCalendar();
+ $vcalendar->METHOD = 'REPLY';
+
+ $generator = new VObject\FreeBusyGenerator();
+ $generator->setObjects($objects);
+ $generator->setTimeRange($start, $end);
+ $generator->setBaseObject($vcalendar);
+ $generator->setTimeZone($calendarTimeZone);
+
+ if ($inboxProps) {
+ $generator->setVAvailability(
+ VObject\Reader::read(
+ $inboxProps[$caldavNS.'calendar-availability']
+ )
+ );
+ }
+
+ $result = $generator->getResult();
+
+ $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:'.$email;
+ $vcalendar->VFREEBUSY->UID = (string) $request->VFREEBUSY->UID;
+ $vcalendar->VFREEBUSY->ORGANIZER = clone $request->VFREEBUSY->ORGANIZER;
+
+ return [
+ 'calendar-data' => $result,
+ 'request-status' => '2.0;Success',
+ 'href' => 'mailto:'.$email,
+ ];
+ }
+
+ /**
+ * This method checks the 'Schedule-Reply' header
+ * and returns false if it's 'F', otherwise true.
+ *
+ * @return bool
+ */
+ protected function scheduleReply(RequestInterface $request)
+ {
+ $scheduleReply = $request->getHeader('Schedule-Reply');
+
+ return 'F' !== $scheduleReply;
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds calendar-auto-schedule, as defined in rfc6638',
+ 'link' => 'http://sabre.io/dav/scheduling/',
+ ];
+ }
+
+ /**
+ * Returns an instance of the iTip\Broker.
+ */
+ protected function createITipBroker(): Broker
+ {
+ return new Broker();
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php
new file mode 100644
index 0000000..b40f28a
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php
@@ -0,0 +1,130 @@
+objectData['calendardata'])) {
+ $this->objectData = $this->caldavBackend->getSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']);
+ }
+
+ return $this->objectData['calendardata'];
+ }
+
+ /**
+ * Updates the ICalendar-formatted object.
+ *
+ * @param string|resource $calendarData
+ *
+ * @return string
+ */
+ public function put($calendarData)
+ {
+ throw new MethodNotAllowed('Updating scheduling objects is not supported');
+ }
+
+ /**
+ * Deletes the scheduling message.
+ */
+ public function delete()
+ {
+ $this->caldavBackend->deleteSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']);
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->objectData['principaluri'];
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ // An alternative acl may be specified in the object data.
+ //
+
+ if (isset($this->objectData['acl'])) {
+ return $this->objectData['acl'];
+ }
+
+ // The default ACL
+ return [
+ [
+ 'privilege' => '{DAV:}all',
+ 'principal' => '{DAV:}owner',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}all',
+ 'principal' => $this->objectData['principaluri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->objectData['principaluri'].'/calendar-proxy-read',
+ 'protected' => true,
+ ],
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php
new file mode 100644
index 0000000..818392f
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/SharedCalendar.php
@@ -0,0 +1,219 @@
+calendarInfo['share-access']) ? $this->calendarInfo['share-access'] : SPlugin::ACCESS_NOTSHARED;
+ }
+
+ /**
+ * This function must return a URI that uniquely identifies the shared
+ * resource. This URI should be identical across instances, and is
+ * also used in several other XML bodies to connect invites to
+ * resources.
+ *
+ * This may simply be a relative reference to the original shared instance,
+ * but it could also be a urn. As long as it's a valid URI and unique.
+ *
+ * @return string
+ */
+ public function getShareResourceUri()
+ {
+ return $this->calendarInfo['share-resource-uri'];
+ }
+
+ /**
+ * Updates the list of sharees.
+ *
+ * Every item must be a Sharee object.
+ *
+ * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees
+ */
+ public function updateInvites(array $sharees)
+ {
+ $this->caldavBackend->updateInvites($this->calendarInfo['id'], $sharees);
+ }
+
+ /**
+ * Returns the list of people whom this resource is shared with.
+ *
+ * Every item in the returned array must be a Sharee object with
+ * at least the following properties set:
+ *
+ * * $href
+ * * $shareAccess
+ * * $inviteStatus
+ *
+ * and optionally:
+ *
+ * * $properties
+ *
+ * @return \Sabre\DAV\Xml\Element\Sharee[]
+ */
+ public function getInvites()
+ {
+ return $this->caldavBackend->getInvites($this->calendarInfo['id']);
+ }
+
+ /**
+ * Marks this calendar as published.
+ *
+ * Publishing a calendar should automatically create a read-only, public,
+ * subscribable calendar.
+ *
+ * @param bool $value
+ */
+ public function setPublishStatus($value)
+ {
+ $this->caldavBackend->setPublishStatus($this->calendarInfo['id'], $value);
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ $acl = [];
+
+ switch ($this->getShareAccess()) {
+ case SPlugin::ACCESS_NOTSHARED:
+ case SPlugin::ACCESS_SHAREDOWNER:
+ $acl[] = [
+ 'privilege' => '{DAV:}share',
+ 'principal' => $this->calendarInfo['principaluri'],
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}share',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+ // no break intentional!
+ case SPlugin::ACCESS_READWRITE:
+ $acl[] = [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->calendarInfo['principaluri'],
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+ // no break intentional!
+ case SPlugin::ACCESS_READ:
+ $acl[] = [
+ 'privilege' => '{DAV:}write-properties',
+ 'principal' => $this->calendarInfo['principaluri'],
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}write-properties',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->calendarInfo['principaluri'],
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy',
+ 'principal' => '{DAV:}authenticated',
+ 'protected' => true,
+ ];
+ break;
+ }
+
+ return $acl;
+ }
+
+ /**
+ * This method returns the ACL's for calendar objects in this calendar.
+ * The result of this method automatically gets passed to the
+ * calendar-object nodes in the calendar.
+ *
+ * @return array
+ */
+ public function getChildACL()
+ {
+ $acl = [];
+
+ switch ($this->getShareAccess()) {
+ case SPlugin::ACCESS_NOTSHARED:
+ case SPlugin::ACCESS_SHAREDOWNER:
+ case SPlugin::ACCESS_READWRITE:
+ $acl[] = [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->calendarInfo['principaluri'],
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+ // no break intentional
+ case SPlugin::ACCESS_READ:
+ $acl[] = [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->calendarInfo['principaluri'],
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
+ 'protected' => true,
+ ];
+ $acl[] = [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
+ 'protected' => true,
+ ];
+ break;
+ }
+
+ return $acl;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php
new file mode 100644
index 0000000..bacfe04
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/SharingPlugin.php
@@ -0,0 +1,346 @@
+server = $server;
+
+ if (is_null($this->server->getPlugin('sharing'))) {
+ throw new \LogicException('The generic "sharing" plugin must be loaded before the caldav sharing plugin. Call $server->addPlugin(new \Sabre\DAV\Sharing\Plugin()); before this one.');
+ }
+
+ array_push(
+ $this->server->protectedProperties,
+ '{'.Plugin::NS_CALENDARSERVER.'}invite',
+ '{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes',
+ '{'.Plugin::NS_CALENDARSERVER.'}shared-url'
+ );
+
+ $this->server->xml->elementMap['{'.Plugin::NS_CALENDARSERVER.'}share'] = 'Sabre\\CalDAV\\Xml\\Request\\Share';
+ $this->server->xml->elementMap['{'.Plugin::NS_CALENDARSERVER.'}invite-reply'] = 'Sabre\\CalDAV\\Xml\\Request\\InviteReply';
+
+ $this->server->on('propFind', [$this, 'propFindEarly']);
+ $this->server->on('propFind', [$this, 'propFindLate'], 150);
+ $this->server->on('propPatch', [$this, 'propPatch'], 40);
+ $this->server->on('method:POST', [$this, 'httpPost']);
+ }
+
+ /**
+ * This event is triggered when properties are requested for a certain
+ * node.
+ *
+ * This allows us to inject any properties early.
+ */
+ public function propFindEarly(DAV\PropFind $propFind, DAV\INode $node)
+ {
+ if ($node instanceof ISharedCalendar) {
+ $propFind->handle('{'.Plugin::NS_CALENDARSERVER.'}invite', function () use ($node) {
+ return new Xml\Property\Invite(
+ $node->getInvites()
+ );
+ });
+ }
+ }
+
+ /**
+ * This method is triggered *after* all properties have been retrieved.
+ * This allows us to inject the correct resourcetype for calendars that
+ * have been shared.
+ */
+ public function propFindLate(DAV\PropFind $propFind, DAV\INode $node)
+ {
+ if ($node instanceof ISharedCalendar) {
+ $shareAccess = $node->getShareAccess();
+ if ($rt = $propFind->get('{DAV:}resourcetype')) {
+ switch ($shareAccess) {
+ case \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER:
+ $rt->add('{'.Plugin::NS_CALENDARSERVER.'}shared-owner');
+ break;
+ case \Sabre\DAV\Sharing\Plugin::ACCESS_READ:
+ case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE:
+ $rt->add('{'.Plugin::NS_CALENDARSERVER.'}shared');
+ break;
+ }
+ }
+ $propFind->handle('{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes', function () {
+ return new Xml\Property\AllowedSharingModes(true, false);
+ });
+ }
+ }
+
+ /**
+ * This method is triggered when a user attempts to update a node's
+ * properties.
+ *
+ * A previous draft of the sharing spec stated that it was possible to use
+ * PROPPATCH to remove 'shared-owner' from the resourcetype, thus unsharing
+ * the calendar.
+ *
+ * Even though this is no longer in the current spec, we keep this around
+ * because OS X 10.7 may still make use of this feature.
+ *
+ * @param string $path
+ */
+ public function propPatch($path, DAV\PropPatch $propPatch)
+ {
+ $node = $this->server->tree->getNodeForPath($path);
+ if (!$node instanceof ISharedCalendar) {
+ return;
+ }
+
+ if (\Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $node->getShareAccess() || \Sabre\DAV\Sharing\Plugin::ACCESS_NOTSHARED === $node->getShareAccess()) {
+ $propPatch->handle('{DAV:}resourcetype', function ($value) use ($node) {
+ if ($value->is('{'.Plugin::NS_CALENDARSERVER.'}shared-owner')) {
+ return false;
+ }
+ $shares = $node->getInvites();
+ foreach ($shares as $share) {
+ $share->access = DAV\Sharing\Plugin::ACCESS_NOACCESS;
+ }
+ $node->updateInvites($shares);
+
+ return true;
+ });
+ }
+ }
+
+ /**
+ * We intercept this to handle POST requests on calendars.
+ *
+ * @return bool|null
+ */
+ public function httpPost(RequestInterface $request, ResponseInterface $response)
+ {
+ $path = $request->getPath();
+
+ // Only handling xml
+ $contentType = $request->getHeader('Content-Type');
+ if (null === $contentType) {
+ return;
+ }
+ if (false === strpos($contentType, 'application/xml') && false === strpos($contentType, 'text/xml')) {
+ return;
+ }
+
+ // Making sure the node exists
+ try {
+ $node = $this->server->tree->getNodeForPath($path);
+ } catch (DAV\Exception\NotFound $e) {
+ return;
+ }
+
+ $requestBody = $request->getBodyAsString();
+
+ // If this request handler could not deal with this POST request, it
+ // will return 'null' and other plugins get a chance to handle the
+ // request.
+ //
+ // However, we already requested the full body. This is a problem,
+ // because a body can only be read once. This is why we preemptively
+ // re-populated the request body with the existing data.
+ $request->setBody($requestBody);
+
+ $message = $this->server->xml->parse($requestBody, $request->getUrl(), $documentType);
+
+ switch ($documentType) {
+ // Both the DAV:share-resource and CALENDARSERVER:share requests
+ // behave identically.
+ case '{'.Plugin::NS_CALENDARSERVER.'}share':
+ $sharingPlugin = $this->server->getPlugin('sharing');
+ $sharingPlugin->shareResource($path, $message->sharees);
+
+ $response->setStatus(200);
+ // Adding this because sending a response body may cause issues,
+ // and I wanted some type of indicator the response was handled.
+ $response->setHeader('X-Sabre-Status', 'everything-went-well');
+
+ // Breaking the event chain
+ return false;
+
+ // The invite-reply document is sent when the user replies to an
+ // invitation of a calendar share.
+ case '{'.Plugin::NS_CALENDARSERVER.'}invite-reply':
+ // This only works on the calendar-home-root node.
+ if (!$node instanceof CalendarHome) {
+ return;
+ }
+ $this->server->transactionType = 'post-invite-reply';
+
+ // Getting ACL info
+ $acl = $this->server->getPlugin('acl');
+
+ // If there's no ACL support, we allow everything
+ if ($acl) {
+ $acl->checkPrivileges($path, '{DAV:}write');
+ }
+
+ $url = $node->shareReply(
+ $message->href,
+ $message->status,
+ $message->calendarUri,
+ $message->inReplyTo,
+ $message->summary
+ );
+
+ $response->setStatus(200);
+ // Adding this because sending a response body may cause issues,
+ // and I wanted some type of indicator the response was handled.
+ $response->setHeader('X-Sabre-Status', 'everything-went-well');
+
+ if ($url) {
+ $writer = $this->server->xml->getWriter();
+ $writer->contextUri = $request->getUrl();
+ $writer->openMemory();
+ $writer->startDocument();
+ $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}shared-as');
+ $writer->write(new LocalHref($url));
+ $writer->endElement();
+ $response->setHeader('Content-Type', 'application/xml');
+ $response->setBody($writer->outputMemory());
+ }
+
+ // Breaking the event chain
+ return false;
+
+ case '{'.Plugin::NS_CALENDARSERVER.'}publish-calendar':
+ // We can only deal with IShareableCalendar objects
+ if (!$node instanceof ISharedCalendar) {
+ return;
+ }
+ $this->server->transactionType = 'post-publish-calendar';
+
+ // Getting ACL info
+ $acl = $this->server->getPlugin('acl');
+
+ // If there's no ACL support, we allow everything
+ if ($acl) {
+ $acl->checkPrivileges($path, '{DAV:}share');
+ }
+
+ $node->setPublishStatus(true);
+
+ // iCloud sends back the 202, so we will too.
+ $response->setStatus(202);
+
+ // Adding this because sending a response body may cause issues,
+ // and I wanted some type of indicator the response was handled.
+ $response->setHeader('X-Sabre-Status', 'everything-went-well');
+
+ // Breaking the event chain
+ return false;
+
+ case '{'.Plugin::NS_CALENDARSERVER.'}unpublish-calendar':
+ // We can only deal with IShareableCalendar objects
+ if (!$node instanceof ISharedCalendar) {
+ return;
+ }
+ $this->server->transactionType = 'post-unpublish-calendar';
+
+ // Getting ACL info
+ $acl = $this->server->getPlugin('acl');
+
+ // If there's no ACL support, we allow everything
+ if ($acl) {
+ $acl->checkPrivileges($path, '{DAV:}share');
+ }
+
+ $node->setPublishStatus(false);
+
+ $response->setStatus(200);
+
+ // Adding this because sending a response body may cause issues,
+ // and I wanted some type of indicator the response was handled.
+ $response->setHeader('X-Sabre-Status', 'everything-went-well');
+
+ // Breaking the event chain
+ return false;
+ }
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds support for caldav-sharing.',
+ 'link' => 'http://sabre.io/dav/caldav-sharing/',
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php
new file mode 100644
index 0000000..e83082c
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Subscriptions/ISubscription.php
@@ -0,0 +1,41 @@
+resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] =
+ '{http://calendarserver.org/ns/}subscribed';
+
+ $server->xml->elementMap['{http://calendarserver.org/ns/}source'] =
+ 'Sabre\\DAV\\Xml\\Property\\Href';
+
+ $server->on('propFind', [$this, 'propFind'], 150);
+ }
+
+ /**
+ * This method should return a list of server-features.
+ *
+ * This is for example 'versioning' and is added to the DAV: header
+ * in an OPTIONS response.
+ *
+ * @return array
+ */
+ public function getFeatures()
+ {
+ return ['calendarserver-subscribed'];
+ }
+
+ /**
+ * Triggered after properties have been fetched.
+ */
+ public function propFind(PropFind $propFind, INode $node)
+ {
+ // There's a bunch of properties that must appear as a self-closing
+ // xml-element. This event handler ensures that this will be the case.
+ $props = [
+ '{http://calendarserver.org/ns/}subscribed-strip-alarms',
+ '{http://calendarserver.org/ns/}subscribed-strip-attachments',
+ '{http://calendarserver.org/ns/}subscribed-strip-todos',
+ ];
+
+ foreach ($props as $prop) {
+ if (200 === $propFind->getStatus($prop)) {
+ $propFind->set($prop, '', 200);
+ }
+ }
+ }
+
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins
+ * using \Sabre\DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return 'subscriptions';
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.',
+ 'link' => null,
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php
new file mode 100644
index 0000000..8d56e64
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Subscriptions/Subscription.php
@@ -0,0 +1,204 @@
+caldavBackend = $caldavBackend;
+ $this->subscriptionInfo = $subscriptionInfo;
+
+ $required = [
+ 'id',
+ 'uri',
+ 'principaluri',
+ 'source',
+ ];
+
+ foreach ($required as $r) {
+ if (!isset($subscriptionInfo[$r])) {
+ throw new \InvalidArgumentException('The '.$r.' field is required when creating a subscription node');
+ }
+ }
+ }
+
+ /**
+ * Returns the name of the node.
+ *
+ * This is used to generate the url.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->subscriptionInfo['uri'];
+ }
+
+ /**
+ * Returns the last modification time.
+ *
+ * @return int|null
+ */
+ public function getLastModified()
+ {
+ if (isset($this->subscriptionInfo['lastmodified'])) {
+ return $this->subscriptionInfo['lastmodified'];
+ }
+ }
+
+ /**
+ * Deletes the current node.
+ */
+ public function delete()
+ {
+ $this->caldavBackend->deleteSubscription(
+ $this->subscriptionInfo['id']
+ );
+ }
+
+ /**
+ * Returns an array with all the child nodes.
+ *
+ * @return \Sabre\DAV\INode[]
+ */
+ public function getChildren()
+ {
+ return [];
+ }
+
+ /**
+ * Updates properties on this node.
+ *
+ * This method received a PropPatch object, which contains all the
+ * information about the update.
+ *
+ * To update specific properties, call the 'handle' method on this object.
+ * Read the PropPatch documentation for more information.
+ */
+ public function propPatch(PropPatch $propPatch)
+ {
+ return $this->caldavBackend->updateSubscription(
+ $this->subscriptionInfo['id'],
+ $propPatch
+ );
+ }
+
+ /**
+ * Returns a list of properties for this nodes.
+ *
+ * The properties list is a list of propertynames the client requested,
+ * encoded in clark-notation {xmlnamespace}tagname.
+ *
+ * If the array is empty, it means 'all properties' were requested.
+ *
+ * Note that it's fine to liberally give properties back, instead of
+ * conforming to the list of requested properties.
+ * The Server class will filter out the extra.
+ *
+ * @param array $properties
+ *
+ * @return array
+ */
+ public function getProperties($properties)
+ {
+ $r = [];
+
+ foreach ($properties as $prop) {
+ switch ($prop) {
+ case '{http://calendarserver.org/ns/}source':
+ $r[$prop] = new Href($this->subscriptionInfo['source']);
+ break;
+ default:
+ if (array_key_exists($prop, $this->subscriptionInfo)) {
+ $r[$prop] = $this->subscriptionInfo[$prop];
+ }
+ break;
+ }
+ }
+
+ return $r;
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->subscriptionInfo['principaluri'];
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ return [
+ [
+ 'privilege' => '{DAV:}all',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}all',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $this->getOwner().'/calendar-proxy-read',
+ 'protected' => true,
+ ],
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php
new file mode 100644
index 0000000..c9656d8
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CalendarData.php
@@ -0,0 +1,80 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $result = [
+ 'contentType' => $reader->getAttribute('content-type') ?: 'text/calendar',
+ 'version' => $reader->getAttribute('version') ?: '2.0',
+ ];
+
+ $elems = (array) $reader->parseInnerTree();
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CALDAV.'}expand':
+ $result['expand'] = [
+ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null,
+ 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null,
+ ];
+
+ if (!$result['expand']['start'] || !$result['expand']['end']) {
+ throw new BadRequest('The "start" and "end" attributes are required when expanding calendar-data');
+ }
+ if ($result['expand']['end'] <= $result['expand']['start']) {
+ throw new BadRequest('The end-date must be larger than the start-date when expanding calendar-data');
+ }
+ break;
+ }
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php
new file mode 100644
index 0000000..929000b
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/CompFilter.php
@@ -0,0 +1,94 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $result = [
+ 'name' => null,
+ 'is-not-defined' => false,
+ 'comp-filters' => [],
+ 'prop-filters' => [],
+ 'time-range' => false,
+ ];
+
+ $att = $reader->parseAttributes();
+ $result['name'] = $att['name'];
+
+ $elems = $reader->parseInnerTree();
+
+ if (is_array($elems)) {
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CALDAV.'}comp-filter':
+ $result['comp-filters'][] = $elem['value'];
+ break;
+ case '{'.Plugin::NS_CALDAV.'}prop-filter':
+ $result['prop-filters'][] = $elem['value'];
+ break;
+ case '{'.Plugin::NS_CALDAV.'}is-not-defined':
+ $result['is-not-defined'] = true;
+ break;
+ case '{'.Plugin::NS_CALDAV.'}time-range':
+ if ('VCALENDAR' === $result['name']) {
+ throw new BadRequest('You cannot add time-range filters on the VCALENDAR component');
+ }
+ $result['time-range'] = [
+ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null,
+ 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null,
+ ];
+ if ($result['time-range']['start'] && $result['time-range']['end'] && $result['time-range']['end'] <= $result['time-range']['start']) {
+ throw new BadRequest('The end-date must be larger than the start-date');
+ }
+ break;
+ }
+ }
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php
new file mode 100644
index 0000000..1e6dd59
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/ParamFilter.php
@@ -0,0 +1,79 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $result = [
+ 'name' => null,
+ 'is-not-defined' => false,
+ 'text-match' => null,
+ ];
+
+ $att = $reader->parseAttributes();
+ $result['name'] = $att['name'];
+
+ $elems = $reader->parseInnerTree();
+
+ if (is_array($elems)) {
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CALDAV.'}is-not-defined':
+ $result['is-not-defined'] = true;
+ break;
+ case '{'.Plugin::NS_CALDAV.'}text-match':
+ $result['text-match'] = [
+ 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'],
+ 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap',
+ 'value' => $elem['value'],
+ ];
+ break;
+ }
+ }
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php
new file mode 100644
index 0000000..f1d66cc
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Filter/PropFilter.php
@@ -0,0 +1,95 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $result = [
+ 'name' => null,
+ 'is-not-defined' => false,
+ 'param-filters' => [],
+ 'text-match' => null,
+ 'time-range' => [],
+ ];
+
+ $att = $reader->parseAttributes();
+ $result['name'] = $att['name'];
+
+ $elems = $reader->parseInnerTree();
+
+ if (is_array($elems)) {
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CALDAV.'}param-filter':
+ $result['param-filters'][] = $elem['value'];
+ break;
+ case '{'.Plugin::NS_CALDAV.'}is-not-defined':
+ $result['is-not-defined'] = true;
+ break;
+ case '{'.Plugin::NS_CALDAV.'}time-range':
+ $result['time-range'] = [
+ 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null,
+ 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null,
+ ];
+ if ($result['time-range']['start'] && $result['time-range']['end'] && $result['time-range']['end'] <= $result['time-range']['start']) {
+ throw new BadRequest('The end-date must be larger than the start-date');
+ }
+ break;
+ case '{'.Plugin::NS_CALDAV.'}text-match':
+ $result['text-match'] = [
+ 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'],
+ 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;ascii-casemap',
+ 'value' => $elem['value'],
+ ];
+ break;
+ }
+ }
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php
new file mode 100644
index 0000000..2dbb0f4
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/Invite.php
@@ -0,0 +1,290 @@
+ $value) {
+ if (!property_exists($this, $key)) {
+ throw new \InvalidArgumentException('Unknown option: '.$key);
+ }
+ $this->$key = $value;
+ }
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializable should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-notification');
+ }
+
+ /**
+ * This method serializes the entire notification, as it is used in the
+ * response body.
+ */
+ public function xmlSerializeFull(Writer $writer)
+ {
+ $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}';
+
+ $this->dtStamp->setTimezone(new \DateTimeZone('GMT'));
+ $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z'));
+
+ $writer->startElement($cs.'invite-notification');
+
+ $writer->writeElement($cs.'uid', $this->id);
+ $writer->writeElement('{DAV:}href', $this->href);
+
+ switch ($this->type) {
+ case DAV\Sharing\Plugin::INVITE_ACCEPTED:
+ $writer->writeElement($cs.'invite-accepted');
+ break;
+ case DAV\Sharing\Plugin::INVITE_NORESPONSE:
+ $writer->writeElement($cs.'invite-noresponse');
+ break;
+ }
+
+ $writer->writeElement($cs.'hosturl', [
+ '{DAV:}href' => $writer->contextUri.$this->hostUrl,
+ ]);
+
+ if ($this->summary) {
+ $writer->writeElement($cs.'summary', $this->summary);
+ }
+
+ $writer->startElement($cs.'access');
+ if ($this->readOnly) {
+ $writer->writeElement($cs.'read');
+ } else {
+ $writer->writeElement($cs.'read-write');
+ }
+ $writer->endElement(); // access
+
+ $writer->startElement($cs.'organizer');
+ // If the organizer contains a 'mailto:' part, it means it should be
+ // treated as absolute.
+ if ('mailto:' === strtolower(substr($this->organizer, 0, 7))) {
+ $writer->writeElement('{DAV:}href', $this->organizer);
+ } else {
+ $writer->writeElement('{DAV:}href', $writer->contextUri.$this->organizer);
+ }
+ if ($this->commonName) {
+ $writer->writeElement($cs.'common-name', $this->commonName);
+ }
+ if ($this->firstName) {
+ $writer->writeElement($cs.'first-name', $this->firstName);
+ }
+ if ($this->lastName) {
+ $writer->writeElement($cs.'last-name', $this->lastName);
+ }
+ $writer->endElement(); // organizer
+
+ if ($this->commonName) {
+ $writer->writeElement($cs.'organizer-cn', $this->commonName);
+ }
+ if ($this->firstName) {
+ $writer->writeElement($cs.'organizer-first', $this->firstName);
+ }
+ if ($this->lastName) {
+ $writer->writeElement($cs.'organizer-last', $this->lastName);
+ }
+ if ($this->supportedComponents) {
+ $writer->writeElement('{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set', $this->supportedComponents);
+ }
+
+ $writer->endElement(); // invite-notification
+ }
+
+ /**
+ * Returns a unique id for this notification.
+ *
+ * This is just the base url. This should generally be some kind of unique
+ * id.
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Returns the ETag for this notification.
+ *
+ * The ETag must be surrounded by literal double-quotes.
+ *
+ * @return string
+ */
+ public function getETag()
+ {
+ return $this->etag;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php
new file mode 100644
index 0000000..dbdba3b
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/InviteReply.php
@@ -0,0 +1,199 @@
+ $value) {
+ if (!property_exists($this, $key)) {
+ throw new \InvalidArgumentException('Unknown option: '.$key);
+ }
+ $this->$key = $value;
+ }
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializable should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply');
+ }
+
+ /**
+ * This method serializes the entire notification, as it is used in the
+ * response body.
+ */
+ public function xmlSerializeFull(Writer $writer)
+ {
+ $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}';
+
+ $this->dtStamp->setTimezone(new \DateTimeZone('GMT'));
+ $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z'));
+
+ $writer->startElement($cs.'invite-reply');
+
+ $writer->writeElement($cs.'uid', $this->id);
+ $writer->writeElement($cs.'in-reply-to', $this->inReplyTo);
+ $writer->writeElement('{DAV:}href', $this->href);
+
+ switch ($this->type) {
+ case DAV\Sharing\Plugin::INVITE_ACCEPTED:
+ $writer->writeElement($cs.'invite-accepted');
+ break;
+ case DAV\Sharing\Plugin::INVITE_DECLINED:
+ $writer->writeElement($cs.'invite-declined');
+ break;
+ }
+
+ $writer->writeElement($cs.'hosturl', [
+ '{DAV:}href' => $writer->contextUri.$this->hostUrl,
+ ]);
+
+ if ($this->summary) {
+ $writer->writeElement($cs.'summary', $this->summary);
+ }
+ $writer->endElement(); // invite-reply
+ }
+
+ /**
+ * Returns a unique id for this notification.
+ *
+ * This is just the base url. This should generally be some kind of unique
+ * id.
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Returns the ETag for this notification.
+ *
+ * The ETag must be surrounded by literal double-quotes.
+ *
+ * @return string
+ */
+ public function getETag()
+ {
+ return $this->etag;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php
new file mode 100644
index 0000000..e1b393f
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Notification/NotificationInterface.php
@@ -0,0 +1,43 @@
+id = $id;
+ $this->type = $type;
+ $this->description = $description;
+ $this->href = $href;
+ $this->etag = $etag;
+ }
+
+ /**
+ * The serialize method is called during xml writing.
+ *
+ * It should use the $writer argument to encode this object into XML.
+ *
+ * Important note: it is not needed to create the parent element. The
+ * parent element is already created, and we only have to worry about
+ * attributes, child elements and text (if any).
+ *
+ * Important note 2: If you are writing any new elements, you are also
+ * responsible for closing them.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ switch ($this->type) {
+ case self::TYPE_LOW:
+ $type = 'low';
+ break;
+ case self::TYPE_MEDIUM:
+ $type = 'medium';
+ break;
+ default:
+ case self::TYPE_HIGH:
+ $type = 'high';
+ break;
+ }
+
+ $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus');
+ $writer->writeAttribute('type', $type);
+ $writer->endElement();
+ }
+
+ /**
+ * This method serializes the entire notification, as it is used in the
+ * response body.
+ */
+ public function xmlSerializeFull(Writer $writer)
+ {
+ $cs = '{'.Plugin::NS_CALENDARSERVER.'}';
+ switch ($this->type) {
+ case self::TYPE_LOW:
+ $type = 'low';
+ break;
+ case self::TYPE_MEDIUM:
+ $type = 'medium';
+ break;
+ default:
+ case self::TYPE_HIGH:
+ $type = 'high';
+ break;
+ }
+
+ $writer->startElement($cs.'systemstatus');
+ $writer->writeAttribute('type', $type);
+
+ if ($this->description) {
+ $writer->writeElement($cs.'description', $this->description);
+ }
+ if ($this->href) {
+ $writer->writeElement('{DAV:}href', $this->href);
+ }
+
+ $writer->endElement(); // systemstatus
+ }
+
+ /**
+ * Returns a unique id for this notification.
+ *
+ * This is just the base url. This should generally be some kind of unique
+ * id.
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /*
+ * Returns the ETag for this notification.
+ *
+ * The ETag must be surrounded by literal double-quotes.
+ *
+ * @return string
+ */
+ public function getETag()
+ {
+ return $this->etag;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php
new file mode 100644
index 0000000..58acb6d
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php
@@ -0,0 +1,81 @@
+canBeShared = $canBeShared;
+ $this->canBePublished = $canBePublished;
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializable should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ if ($this->canBeShared) {
+ $writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-shared');
+ }
+ if ($this->canBePublished) {
+ $writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-published');
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php
new file mode 100644
index 0000000..84f7ae0
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php
@@ -0,0 +1,71 @@
+emails = $emails;
+ }
+
+ /**
+ * Returns the email addresses.
+ *
+ * @return array
+ */
+ public function getValue()
+ {
+ return $this->emails;
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializable should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ foreach ($this->emails as $email) {
+ $writer->writeElement('{http://calendarserver.org/ns/}email-address', $email);
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php
new file mode 100644
index 0000000..c389ca8
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/Invite.php
@@ -0,0 +1,120 @@
+sharees = $sharees;
+ }
+
+ /**
+ * Returns the list of users, as it was passed to the constructor.
+ *
+ * @return array
+ */
+ public function getValue()
+ {
+ return $this->sharees;
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializable should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ $cs = '{'.Plugin::NS_CALENDARSERVER.'}';
+
+ foreach ($this->sharees as $sharee) {
+ if (DAV\Sharing\Plugin::ACCESS_SHAREDOWNER === $sharee->access) {
+ $writer->startElement($cs.'organizer');
+ } else {
+ $writer->startElement($cs.'user');
+
+ switch ($sharee->inviteStatus) {
+ case DAV\Sharing\Plugin::INVITE_ACCEPTED:
+ $writer->writeElement($cs.'invite-accepted');
+ break;
+ case DAV\Sharing\Plugin::INVITE_DECLINED:
+ $writer->writeElement($cs.'invite-declined');
+ break;
+ case DAV\Sharing\Plugin::INVITE_NORESPONSE:
+ $writer->writeElement($cs.'invite-noresponse');
+ break;
+ case DAV\Sharing\Plugin::INVITE_INVALID:
+ $writer->writeElement($cs.'invite-invalid');
+ break;
+ }
+
+ $writer->startElement($cs.'access');
+ switch ($sharee->access) {
+ case DAV\Sharing\Plugin::ACCESS_READWRITE:
+ $writer->writeElement($cs.'read-write');
+ break;
+ case DAV\Sharing\Plugin::ACCESS_READ:
+ $writer->writeElement($cs.'read');
+ break;
+ }
+ $writer->endElement(); // access
+ }
+
+ $href = new DAV\Xml\Property\Href($sharee->href);
+ $href->xmlSerialize($writer);
+
+ if (isset($sharee->properties['{DAV:}displayname'])) {
+ $writer->writeElement($cs.'common-name', $sharee->properties['{DAV:}displayname']);
+ }
+ if ($sharee->comment) {
+ $writer->writeElement($cs.'summary', $sharee->comment);
+ }
+ $writer->endElement(); // organizer or user
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php
new file mode 100644
index 0000000..1595220
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php
@@ -0,0 +1,124 @@
+value = $value;
+ }
+
+ /**
+ * Returns the current value.
+ *
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializable should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ switch ($this->value) {
+ case self::TRANSPARENT:
+ $writer->writeElement('{'.Plugin::NS_CALDAV.'}transparent');
+ break;
+ case self::OPAQUE:
+ $writer->writeElement('{'.Plugin::NS_CALDAV.'}opaque');
+ break;
+ }
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statically, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = Deserializer\enum($reader, Plugin::NS_CALDAV);
+
+ if (in_array('transparent', $elems)) {
+ $value = self::TRANSPARENT;
+ } else {
+ $value = self::OPAQUE;
+ }
+
+ return new self($value);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php
new file mode 100644
index 0000000..d86e7b7
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php
@@ -0,0 +1,118 @@
+components = $components;
+ }
+
+ /**
+ * Returns the list of supported components.
+ *
+ * @return array
+ */
+ public function getValue()
+ {
+ return $this->components;
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializable should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ foreach ($this->components as $component) {
+ $writer->startElement('{'.Plugin::NS_CALDAV.'}comp');
+ $writer->writeAttributes(['name' => $component]);
+ $writer->endElement();
+ }
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statically, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = $reader->parseInnerTree();
+
+ $components = [];
+
+ foreach ((array) $elems as $elem) {
+ if ($elem['name'] === '{'.Plugin::NS_CALDAV.'}comp') {
+ $components[] = $elem['attributes']['name'];
+ }
+ }
+
+ if (!$components) {
+ throw new ParseException('supported-calendar-component-set must have at least one CALDAV:comp element');
+ }
+
+ return new self($components);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php
new file mode 100644
index 0000000..5b08933
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php
@@ -0,0 +1,57 @@
+startElement('{'.Plugin::NS_CALDAV.'}calendar-data');
+ $writer->writeAttributes([
+ 'content-type' => 'text/calendar',
+ 'version' => '2.0',
+ ]);
+ $writer->endElement(); // calendar-data
+ $writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data');
+ $writer->writeAttributes([
+ 'content-type' => 'application/calendar+json',
+ ]);
+ $writer->endElement(); // calendar-data
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php
new file mode 100644
index 0000000..c5ffeee
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php
@@ -0,0 +1,54 @@
+writeElement('{'.Plugin::NS_CALDAV.'}supported-collation', $collation);
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php
new file mode 100644
index 0000000..4771a20
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarMultiGetReport.php
@@ -0,0 +1,119 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = $reader->parseInnerTree([
+ '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData',
+ '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
+ ]);
+
+ $newProps = [
+ 'hrefs' => [],
+ 'properties' => [],
+ ];
+
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{DAV:}prop':
+ $newProps['properties'] = array_keys($elem['value']);
+ if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) {
+ $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'];
+ }
+ break;
+ case '{DAV:}href':
+ $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']);
+ break;
+ }
+ }
+
+ $obj = new self();
+ foreach ($newProps as $key => $value) {
+ $obj->$key = $value;
+ }
+
+ return $obj;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php
new file mode 100644
index 0000000..5a4df46
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/CalendarQueryReport.php
@@ -0,0 +1,137 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = $reader->parseInnerTree([
+ '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter',
+ '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter',
+ '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter',
+ '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData',
+ '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
+ ]);
+
+ $newProps = [
+ 'filters' => null,
+ 'properties' => [],
+ ];
+
+ if (!is_array($elems)) {
+ $elems = [];
+ }
+
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{DAV:}prop':
+ $newProps['properties'] = array_keys($elem['value']);
+ if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) {
+ $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'];
+ }
+ break;
+ case '{'.Plugin::NS_CALDAV.'}filter':
+ foreach ($elem['value'] as $subElem) {
+ if ($subElem['name'] === '{'.Plugin::NS_CALDAV.'}comp-filter') {
+ if (!is_null($newProps['filters'])) {
+ throw new BadRequest('Only one top-level comp-filter may be defined');
+ }
+ $newProps['filters'] = $subElem['value'];
+ }
+ }
+ break;
+ }
+ }
+
+ if (is_null($newProps['filters'])) {
+ throw new BadRequest('The {'.Plugin::NS_CALDAV.'}filter element is required for this request');
+ }
+
+ $obj = new self();
+ foreach ($newProps as $key => $value) {
+ $obj->$key = $value;
+ }
+
+ return $obj;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php
new file mode 100644
index 0000000..17df05a
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/FreeBusyQueryReport.php
@@ -0,0 +1,90 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $timeRange = '{'.Plugin::NS_CALDAV.'}time-range';
+
+ $start = null;
+ $end = null;
+
+ foreach ((array) $reader->parseInnerTree([]) as $elem) {
+ if ($elem['name'] !== $timeRange) {
+ continue;
+ }
+
+ $start = empty($elem['attributes']['start']) ?: $elem['attributes']['start'];
+ $end = empty($elem['attributes']['end']) ?: $elem['attributes']['end'];
+ }
+ if (!$start && !$end) {
+ throw new BadRequest('The freebusy report must have a time-range element');
+ }
+ if ($start) {
+ $start = DateTimeParser::parseDateTime($start);
+ }
+ if ($end) {
+ $end = DateTimeParser::parseDateTime($end);
+ }
+ $result = new self();
+ $result->start = $start;
+ $result->end = $end;
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php
new file mode 100644
index 0000000..166721e
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/InviteReply.php
@@ -0,0 +1,145 @@
+href = $href;
+ $this->calendarUri = $calendarUri;
+ $this->inReplyTo = $inReplyTo;
+ $this->summary = $summary;
+ $this->status = $status;
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statically, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = KeyValue::xmlDeserialize($reader);
+
+ $href = null;
+ $calendarUri = null;
+ $inReplyTo = null;
+ $summary = null;
+ $status = null;
+
+ foreach ($elems as $name => $value) {
+ switch ($name) {
+ case '{'.Plugin::NS_CALENDARSERVER.'}hosturl':
+ foreach ($value as $bla) {
+ if ('{DAV:}href' === $bla['name']) {
+ $calendarUri = $bla['value'];
+ }
+ }
+ break;
+ case '{'.Plugin::NS_CALENDARSERVER.'}invite-accepted':
+ $status = DAV\Sharing\Plugin::INVITE_ACCEPTED;
+ break;
+ case '{'.Plugin::NS_CALENDARSERVER.'}invite-declined':
+ $status = DAV\Sharing\Plugin::INVITE_DECLINED;
+ break;
+ case '{'.Plugin::NS_CALENDARSERVER.'}in-reply-to':
+ $inReplyTo = $value;
+ break;
+ case '{'.Plugin::NS_CALENDARSERVER.'}summary':
+ $summary = $value;
+ break;
+ case '{DAV:}href':
+ $href = $value;
+ break;
+ }
+ }
+ if (is_null($calendarUri)) {
+ throw new BadRequest('The {http://calendarserver.org/ns/}hosturl/{DAV:}href element must exist');
+ }
+
+ return new self($href, $calendarUri, $inReplyTo, $summary, $status);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php
new file mode 100644
index 0000000..b5701e2
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/MkCalendar.php
@@ -0,0 +1,77 @@
+properties;
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statically, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $self = new self();
+
+ $elementMap = $reader->elementMap;
+ $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop';
+ $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue';
+ $elems = $reader->parseInnerTree($elementMap);
+
+ foreach ($elems as $elem) {
+ if ('{DAV:}set' === $elem['name']) {
+ $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']);
+ }
+ }
+
+ return $self;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php
new file mode 100644
index 0000000..d597b76
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CalDAV/Xml/Request/Share.php
@@ -0,0 +1,107 @@
+sharees = $sharees;
+ }
+
+ /**
+ * The deserialize method is called during xml parsing.
+ *
+ * This method is called statically, this is because in theory this method
+ * may be used as a type of constructor, or factory method.
+ *
+ * Often you want to return an instance of the current class, but you are
+ * free to return other data as well.
+ *
+ * You are responsible for advancing the reader to the next element. Not
+ * doing anything will result in a never-ending loop.
+ *
+ * If you just want to skip parsing for this element altogether, you can
+ * just call $reader->next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = $reader->parseGetElements([
+ '{'.Plugin::NS_CALENDARSERVER.'}set' => 'Sabre\\Xml\\Element\\KeyValue',
+ '{'.Plugin::NS_CALENDARSERVER.'}remove' => 'Sabre\\Xml\\Element\\KeyValue',
+ ]);
+
+ $sharees = [];
+
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CALENDARSERVER.'}set':
+ $sharee = $elem['value'];
+
+ $sumElem = '{'.Plugin::NS_CALENDARSERVER.'}summary';
+ $commonName = '{'.Plugin::NS_CALENDARSERVER.'}common-name';
+
+ $properties = [];
+ if (isset($sharee[$commonName])) {
+ $properties['{DAV:}displayname'] = $sharee[$commonName];
+ }
+
+ $access = array_key_exists('{'.Plugin::NS_CALENDARSERVER.'}read-write', $sharee)
+ ? \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE
+ : \Sabre\DAV\Sharing\Plugin::ACCESS_READ;
+
+ $sharees[] = new Sharee([
+ 'href' => $sharee['{DAV:}href'],
+ 'properties' => $properties,
+ 'access' => $access,
+ 'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null,
+ ]);
+ break;
+
+ case '{'.Plugin::NS_CALENDARSERVER.'}remove':
+ $sharees[] = new Sharee([
+ 'href' => $elem['value']['{DAV:}href'],
+ 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS,
+ ]);
+ break;
+ }
+ }
+
+ return new self($sharees);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBook.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBook.php
new file mode 100644
index 0000000..f5744f6
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBook.php
@@ -0,0 +1,335 @@
+carddavBackend = $carddavBackend;
+ $this->addressBookInfo = $addressBookInfo;
+ }
+
+ /**
+ * Returns the name of the addressbook.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->addressBookInfo['uri'];
+ }
+
+ /**
+ * Returns a card.
+ *
+ * @param string $name
+ *
+ * @return Card
+ */
+ public function getChild($name)
+ {
+ $obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name);
+ if (!$obj) {
+ throw new DAV\Exception\NotFound('Card not found');
+ }
+
+ return new Card($this->carddavBackend, $this->addressBookInfo, $obj);
+ }
+
+ /**
+ * Returns the full list of cards.
+ *
+ * @return array
+ */
+ public function getChildren()
+ {
+ $objs = $this->carddavBackend->getCards($this->addressBookInfo['id']);
+ $children = [];
+ foreach ($objs as $obj) {
+ $obj['acl'] = $this->getChildACL();
+ $children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj);
+ }
+
+ return $children;
+ }
+
+ /**
+ * This method receives a list of paths in it's first argument.
+ * It must return an array with Node objects.
+ *
+ * If any children are not found, you do not have to return them.
+ *
+ * @param string[] $paths
+ *
+ * @return array
+ */
+ public function getMultipleChildren(array $paths)
+ {
+ $objs = $this->carddavBackend->getMultipleCards($this->addressBookInfo['id'], $paths);
+ $children = [];
+ foreach ($objs as $obj) {
+ $obj['acl'] = $this->getChildACL();
+ $children[] = new Card($this->carddavBackend, $this->addressBookInfo, $obj);
+ }
+
+ return $children;
+ }
+
+ /**
+ * Creates a new directory.
+ *
+ * We actually block this, as subdirectories are not allowed in addressbooks.
+ *
+ * @param string $name
+ */
+ public function createDirectory($name)
+ {
+ throw new DAV\Exception\MethodNotAllowed('Creating collections in addressbooks is not allowed');
+ }
+
+ /**
+ * Creates a new file.
+ *
+ * The contents of the new file must be a valid VCARD.
+ *
+ * This method may return an ETag.
+ *
+ * @param string $name
+ * @param resource $data
+ *
+ * @return string|null
+ */
+ public function createFile($name, $data = null)
+ {
+ if (is_resource($data)) {
+ $data = stream_get_contents($data);
+ }
+ // Converting to UTF-8, if needed
+ $data = DAV\StringUtil::ensureUTF8($data);
+
+ return $this->carddavBackend->createCard($this->addressBookInfo['id'], $name, $data);
+ }
+
+ /**
+ * Deletes the entire addressbook.
+ */
+ public function delete()
+ {
+ $this->carddavBackend->deleteAddressBook($this->addressBookInfo['id']);
+ }
+
+ /**
+ * Renames the addressbook.
+ *
+ * @param string $newName
+ */
+ public function setName($newName)
+ {
+ throw new DAV\Exception\MethodNotAllowed('Renaming addressbooks is not yet supported');
+ }
+
+ /**
+ * Returns the last modification date as a unix timestamp.
+ */
+ public function getLastModified()
+ {
+ return null;
+ }
+
+ /**
+ * Updates properties on this node.
+ *
+ * This method received a PropPatch object, which contains all the
+ * information about the update.
+ *
+ * To update specific properties, call the 'handle' method on this object.
+ * Read the PropPatch documentation for more information.
+ */
+ public function propPatch(DAV\PropPatch $propPatch)
+ {
+ return $this->carddavBackend->updateAddressBook($this->addressBookInfo['id'], $propPatch);
+ }
+
+ /**
+ * Returns a list of properties for this nodes.
+ *
+ * The properties list is a list of propertynames the client requested,
+ * encoded in clark-notation {xmlnamespace}tagname
+ *
+ * If the array is empty, it means 'all properties' were requested.
+ *
+ * @param array $properties
+ *
+ * @return array
+ */
+ public function getProperties($properties)
+ {
+ $response = [];
+ foreach ($properties as $propertyName) {
+ if (isset($this->addressBookInfo[$propertyName])) {
+ $response[$propertyName] = $this->addressBookInfo[$propertyName];
+ }
+ }
+
+ return $response;
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->addressBookInfo['principaluri'];
+ }
+
+ /**
+ * This method returns the ACL's for card nodes in this address book.
+ * The result of this method automatically gets passed to the
+ * card nodes in this address book.
+ *
+ * @return array
+ */
+ public function getChildACL()
+ {
+ return [
+ [
+ 'privilege' => '{DAV:}all',
+ 'principal' => $this->getOwner(),
+ 'protected' => true,
+ ],
+ ];
+ }
+
+ /**
+ * This method returns the current sync-token for this collection.
+ * This can be any string.
+ *
+ * If null is returned from this function, the plugin assumes there's no
+ * sync information available.
+ *
+ * @return string|null
+ */
+ public function getSyncToken()
+ {
+ if (
+ $this->carddavBackend instanceof Backend\SyncSupport &&
+ isset($this->addressBookInfo['{DAV:}sync-token'])
+ ) {
+ return $this->addressBookInfo['{DAV:}sync-token'];
+ }
+ if (
+ $this->carddavBackend instanceof Backend\SyncSupport &&
+ isset($this->addressBookInfo['{http://sabredav.org/ns}sync-token'])
+ ) {
+ return $this->addressBookInfo['{http://sabredav.org/ns}sync-token'];
+ }
+ }
+
+ /**
+ * The getChanges method returns all the changes that have happened, since
+ * the specified syncToken and the current collection.
+ *
+ * This function should return an array, such as the following:
+ *
+ * [
+ * 'syncToken' => 'The current synctoken',
+ * 'added' => [
+ * 'new.txt',
+ * ],
+ * 'modified' => [
+ * 'modified.txt',
+ * ],
+ * 'deleted' => [
+ * 'foo.php.bak',
+ * 'old.txt'
+ * ]
+ * ];
+ *
+ * The syncToken property should reflect the *current* syncToken of the
+ * collection, as reported getSyncToken(). This is needed here too, to
+ * ensure the operation is atomic.
+ *
+ * If the syncToken is specified as null, this is an initial sync, and all
+ * members should be reported.
+ *
+ * The modified property is an array of nodenames that have changed since
+ * the last token.
+ *
+ * The deleted property is an array with nodenames, that have been deleted
+ * from collection.
+ *
+ * The second argument is basically the 'depth' of the report. If it's 1,
+ * you only have to report changes that happened only directly in immediate
+ * descendants. If it's 2, it should also include changes from the nodes
+ * below the child collections. (grandchildren)
+ *
+ * The third (optional) argument allows a client to specify how many
+ * results should be returned at most. If the limit is not specified, it
+ * should be treated as infinite.
+ *
+ * If the limit (infinite or not) is higher than you're willing to return,
+ * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
+ *
+ * If the syncToken is expired (due to data cleanup) or unknown, you must
+ * return null.
+ *
+ * The limit is 'suggestive'. You are free to ignore it.
+ *
+ * @param string $syncToken
+ * @param int $syncLevel
+ * @param int $limit
+ *
+ * @return array|null
+ */
+ public function getChanges($syncToken, $syncLevel, $limit = null)
+ {
+ if (!$this->carddavBackend instanceof Backend\SyncSupport) {
+ return null;
+ }
+
+ return $this->carddavBackend->getChangesForAddressBook(
+ $this->addressBookInfo['id'],
+ $syncToken,
+ $syncLevel,
+ $limit
+ );
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php
new file mode 100644
index 0000000..d7365fb
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBookHome.php
@@ -0,0 +1,178 @@
+carddavBackend = $carddavBackend;
+ $this->principalUri = $principalUri;
+ }
+
+ /**
+ * Returns the name of this object.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ list(, $name) = Uri\split($this->principalUri);
+
+ return $name;
+ }
+
+ /**
+ * Updates the name of this object.
+ *
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ throw new DAV\Exception\MethodNotAllowed();
+ }
+
+ /**
+ * Deletes this object.
+ */
+ public function delete()
+ {
+ throw new DAV\Exception\MethodNotAllowed();
+ }
+
+ /**
+ * Returns the last modification date.
+ *
+ * @return int
+ */
+ public function getLastModified()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a new file under this object.
+ *
+ * This is currently not allowed
+ *
+ * @param string $name
+ * @param resource $data
+ */
+ public function createFile($name, $data = null)
+ {
+ throw new DAV\Exception\MethodNotAllowed('Creating new files in this collection is not supported');
+ }
+
+ /**
+ * Creates a new directory under this object.
+ *
+ * This is currently not allowed.
+ *
+ * @param string $filename
+ */
+ public function createDirectory($filename)
+ {
+ throw new DAV\Exception\MethodNotAllowed('Creating new collections in this collection is not supported');
+ }
+
+ /**
+ * Returns a single addressbook, by name.
+ *
+ * @param string $name
+ *
+ * @todo needs optimizing
+ *
+ * @return AddressBook
+ */
+ public function getChild($name)
+ {
+ foreach ($this->getChildren() as $child) {
+ if ($name == $child->getName()) {
+ return $child;
+ }
+ }
+ throw new DAV\Exception\NotFound('Addressbook with name \''.$name.'\' could not be found');
+ }
+
+ /**
+ * Returns a list of addressbooks.
+ *
+ * @return array
+ */
+ public function getChildren()
+ {
+ $addressbooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri);
+ $objs = [];
+ foreach ($addressbooks as $addressbook) {
+ $objs[] = new AddressBook($this->carddavBackend, $addressbook);
+ }
+
+ return $objs;
+ }
+
+ /**
+ * Creates a new address book.
+ *
+ * @param string $name
+ *
+ * @throws DAV\Exception\InvalidResourceType
+ */
+ public function createExtendedCollection($name, MkCol $mkCol)
+ {
+ if (!$mkCol->hasResourceType('{'.Plugin::NS_CARDDAV.'}addressbook')) {
+ throw new DAV\Exception\InvalidResourceType('Unknown resourceType for this collection');
+ }
+ $properties = $mkCol->getRemainingValues();
+ $mkCol->setRemainingResultCode(201);
+ $this->carddavBackend->createAddressBook($this->principalUri, $name, $properties);
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->principalUri;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php
new file mode 100644
index 0000000..ee1721a
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/AddressBookRoot.php
@@ -0,0 +1,75 @@
+carddavBackend = $carddavBackend;
+ parent::__construct($principalBackend, $principalPrefix);
+ }
+
+ /**
+ * Returns the name of the node.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return Plugin::ADDRESSBOOK_ROOT;
+ }
+
+ /**
+ * This method returns a node for a principal.
+ *
+ * The passed array contains principal information, and is guaranteed to
+ * at least contain a uri item. Other properties may or may not be
+ * supplied by the authentication backend.
+ *
+ * @return \Sabre\DAV\INode
+ */
+ public function getChildForPrincipal(array $principal)
+ {
+ return new AddressBookHome($this->carddavBackend, $principal['uri']);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php
new file mode 100644
index 0000000..a900c62
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/AbstractBackend.php
@@ -0,0 +1,38 @@
+getCard($addressBookId, $uri);
+ }, $uris);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php
new file mode 100644
index 0000000..f9955ac
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/BackendInterface.php
@@ -0,0 +1,194 @@
+pdo = $pdo;
+ }
+
+ /**
+ * Returns the list of addressbooks for a specific user.
+ *
+ * @param string $principalUri
+ *
+ * @return array
+ */
+ public function getAddressBooksForUser($principalUri)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, uri, displayname, principaluri, description, synctoken FROM '.$this->addressBooksTableName.' WHERE principaluri = ?');
+ $stmt->execute([$principalUri]);
+
+ $addressBooks = [];
+
+ foreach ($stmt->fetchAll() as $row) {
+ $addressBooks[] = [
+ 'id' => $row['id'],
+ 'uri' => $row['uri'],
+ 'principaluri' => $row['principaluri'],
+ '{DAV:}displayname' => $row['displayname'],
+ '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description' => $row['description'],
+ '{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
+ '{http://sabredav.org/ns}sync-token' => $row['synctoken'] ? $row['synctoken'] : '0',
+ ];
+ }
+
+ return $addressBooks;
+ }
+
+ /**
+ * Updates properties for an address book.
+ *
+ * The list of mutations is stored in a Sabre\DAV\PropPatch object.
+ * To do the actual updates, you must tell this object which properties
+ * you're going to process with the handle() method.
+ *
+ * Calling the handle method is like telling the PropPatch object "I
+ * promise I can handle updating this property".
+ *
+ * Read the PropPatch documentation for more info and examples.
+ *
+ * @param string $addressBookId
+ */
+ public function updateAddressBook($addressBookId, PropPatch $propPatch)
+ {
+ $supportedProperties = [
+ '{DAV:}displayname',
+ '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description',
+ ];
+
+ $propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
+ $updates = [];
+ foreach ($mutations as $property => $newValue) {
+ switch ($property) {
+ case '{DAV:}displayname':
+ $updates['displayname'] = $newValue;
+ break;
+ case '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description':
+ $updates['description'] = $newValue;
+ break;
+ }
+ }
+ $query = 'UPDATE '.$this->addressBooksTableName.' SET ';
+ $first = true;
+ foreach ($updates as $key => $value) {
+ if ($first) {
+ $first = false;
+ } else {
+ $query .= ', ';
+ }
+ $query .= ' '.$key.' = :'.$key.' ';
+ }
+ $query .= ' WHERE id = :addressbookid';
+
+ $stmt = $this->pdo->prepare($query);
+ $updates['addressbookid'] = $addressBookId;
+
+ $stmt->execute($updates);
+
+ $this->addChange($addressBookId, '', 2);
+
+ return true;
+ });
+ }
+
+ /**
+ * Creates a new address book.
+ *
+ * @param string $principalUri
+ * @param string $url just the 'basename' of the url
+ *
+ * @return int Last insert id
+ */
+ public function createAddressBook($principalUri, $url, array $properties)
+ {
+ $values = [
+ 'displayname' => null,
+ 'description' => null,
+ 'principaluri' => $principalUri,
+ 'uri' => $url,
+ ];
+
+ foreach ($properties as $property => $newValue) {
+ switch ($property) {
+ case '{DAV:}displayname':
+ $values['displayname'] = $newValue;
+ break;
+ case '{'.CardDAV\Plugin::NS_CARDDAV.'}addressbook-description':
+ $values['description'] = $newValue;
+ break;
+ default:
+ throw new DAV\Exception\BadRequest('Unknown property: '.$property);
+ }
+ }
+
+ $query = 'INSERT INTO '.$this->addressBooksTableName.' (uri, displayname, description, principaluri, synctoken) VALUES (:uri, :displayname, :description, :principaluri, 1)';
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute($values);
+
+ return $this->pdo->lastInsertId(
+ $this->addressBooksTableName.'_id_seq'
+ );
+ }
+
+ /**
+ * Deletes an entire addressbook and all its contents.
+ *
+ * @param int $addressBookId
+ */
+ public function deleteAddressBook($addressBookId)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->cardsTableName.' WHERE addressbookid = ?');
+ $stmt->execute([$addressBookId]);
+
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->addressBooksTableName.' WHERE id = ?');
+ $stmt->execute([$addressBookId]);
+
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->addressBookChangesTableName.' WHERE addressbookid = ?');
+ $stmt->execute([$addressBookId]);
+ }
+
+ /**
+ * 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 omit carddata.
+ * This may speed up certain requests, especially with large cards.
+ *
+ * @param mixed $addressbookId
+ *
+ * @return array
+ */
+ public function getCards($addressbookId)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, uri, lastmodified, etag, size FROM '.$this->cardsTableName.' WHERE addressbookid = ?');
+ $stmt->execute([$addressbookId]);
+
+ $result = [];
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $row['etag'] = '"'.$row['etag'].'"';
+ $row['lastmodified'] = (int) $row['lastmodified'];
+ $result[] = $row;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns a specific card.
+ *
+ * The same set of properties must be returned as with getCards. The only
+ * exception is that 'carddata' is absolutely required.
+ *
+ * If the card does not exist, you must return false.
+ *
+ * @param mixed $addressBookId
+ * @param string $cardUri
+ *
+ * @return array
+ */
+ public function getCard($addressBookId, $cardUri)
+ {
+ $stmt = $this->pdo->prepare('SELECT id, carddata, uri, lastmodified, etag, size FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri = ? LIMIT 1');
+ $stmt->execute([$addressBookId, $cardUri]);
+
+ $result = $stmt->fetch(\PDO::FETCH_ASSOC);
+
+ if (!$result) {
+ return false;
+ }
+
+ $result['etag'] = '"'.$result['etag'].'"';
+ $result['lastmodified'] = (int) $result['lastmodified'];
+
+ return $result;
+ }
+
+ /**
+ * Returns a list of cards.
+ *
+ * This method should work identical to getCard, but instead return all the
+ * cards in the list as an array.
+ *
+ * If the backend supports this, it may allow for some speed-ups.
+ *
+ * @param mixed $addressBookId
+ *
+ * @return array
+ */
+ public function getMultipleCards($addressBookId, array $uris)
+ {
+ $query = 'SELECT id, uri, lastmodified, etag, size, carddata FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri IN (';
+ // Inserting a whole bunch of question marks
+ $query .= implode(',', array_fill(0, count($uris), '?'));
+ $query .= ')';
+
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute(array_merge([$addressBookId], $uris));
+ $result = [];
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $row['etag'] = '"'.$row['etag'].'"';
+ $row['lastmodified'] = (int) $row['lastmodified'];
+ $result[] = $row;
+ }
+
+ return $result;
+ }
+
+ /**
+ * 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 mixed $addressBookId
+ * @param string $cardUri
+ * @param string $cardData
+ *
+ * @return string|null
+ */
+ public function createCard($addressBookId, $cardUri, $cardData)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->cardsTableName.' (carddata, uri, lastmodified, addressbookid, size, etag) VALUES (?, ?, ?, ?, ?, ?)');
+
+ $etag = md5($cardData);
+
+ $stmt->execute([
+ $cardData,
+ $cardUri,
+ time(),
+ $addressBookId,
+ strlen($cardData),
+ $etag,
+ ]);
+
+ $this->addChange($addressBookId, $cardUri, 1);
+
+ return '"'.$etag.'"';
+ }
+
+ /**
+ * 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 mixed $addressBookId
+ * @param string $cardUri
+ * @param string $cardData
+ *
+ * @return string|null
+ */
+ public function updateCard($addressBookId, $cardUri, $cardData)
+ {
+ $stmt = $this->pdo->prepare('UPDATE '.$this->cardsTableName.' SET carddata = ?, lastmodified = ?, size = ?, etag = ? WHERE uri = ? AND addressbookid =?');
+
+ $etag = md5($cardData);
+ $stmt->execute([
+ $cardData,
+ time(),
+ strlen($cardData),
+ $etag,
+ $cardUri,
+ $addressBookId,
+ ]);
+
+ $this->addChange($addressBookId, $cardUri, 2);
+
+ return '"'.$etag.'"';
+ }
+
+ /**
+ * Deletes a card.
+ *
+ * @param mixed $addressBookId
+ * @param string $cardUri
+ *
+ * @return bool
+ */
+ public function deleteCard($addressBookId, $cardUri)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->cardsTableName.' WHERE addressbookid = ? AND uri = ?');
+ $stmt->execute([$addressBookId, $cardUri]);
+
+ $this->addChange($addressBookId, $cardUri, 3);
+
+ return 1 === $stmt->rowCount();
+ }
+
+ /**
+ * The getChanges method returns all the changes that have happened, since
+ * the specified syncToken in the specified address book.
+ *
+ * This function should return an array, such as the following:
+ *
+ * [
+ * 'syncToken' => 'The current synctoken',
+ * 'added' => [
+ * 'new.txt',
+ * ],
+ * 'modified' => [
+ * 'updated.txt',
+ * ],
+ * 'deleted' => [
+ * 'foo.php.bak',
+ * 'old.txt'
+ * ]
+ * ];
+ *
+ * The returned syncToken property should reflect the *current* syncToken
+ * of the addressbook, as reported in the {http://sabredav.org/ns}sync-token
+ * property. This is needed here too, to ensure the operation is atomic.
+ *
+ * If the $syncToken argument is specified as null, this is an initial
+ * sync, and all members should be reported.
+ *
+ * The modified property is an array of nodenames that have changed since
+ * the last token.
+ *
+ * The deleted property is an array with nodenames, that have been deleted
+ * from collection.
+ *
+ * The $syncLevel argument is basically the 'depth' of the report. If it's
+ * 1, you only have to report changes that happened only directly in
+ * immediate descendants. If it's 2, it should also include changes from
+ * the nodes below the child collections. (grandchildren)
+ *
+ * The $limit argument allows a client to specify how many results should
+ * be returned at most. If the limit is not specified, it should be treated
+ * as infinite.
+ *
+ * If the limit (infinite or not) is higher than you're willing to return,
+ * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
+ *
+ * If the syncToken is expired (due to data cleanup) or unknown, you must
+ * return null.
+ *
+ * The limit is 'suggestive'. You are free to ignore it.
+ *
+ * @param string $addressBookId
+ * @param string $syncToken
+ * @param int $syncLevel
+ * @param int $limit
+ *
+ * @return array|null
+ */
+ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null)
+ {
+ // Current synctoken
+ $stmt = $this->pdo->prepare('SELECT synctoken FROM '.$this->addressBooksTableName.' WHERE id = ?');
+ $stmt->execute([$addressBookId]);
+ $currentToken = $stmt->fetchColumn(0);
+
+ if (is_null($currentToken)) {
+ return null;
+ }
+
+ $result = [
+ 'syncToken' => $currentToken,
+ 'added' => [],
+ 'modified' => [],
+ 'deleted' => [],
+ ];
+
+ if ($syncToken) {
+ $query = 'SELECT uri, operation FROM '.$this->addressBookChangesTableName.' WHERE synctoken >= ? AND synctoken < ? AND addressbookid = ? ORDER BY synctoken';
+ if ($limit > 0) {
+ $query .= ' LIMIT '.(int) $limit;
+ }
+
+ // Fetching all changes
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute([$syncToken, $currentToken, $addressBookId]);
+
+ $changes = [];
+
+ // This loop ensures that any duplicates are overwritten, only the
+ // last change on a node is relevant.
+ while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
+ $changes[$row['uri']] = $row['operation'];
+ }
+
+ foreach ($changes as $uri => $operation) {
+ switch ($operation) {
+ case 1:
+ $result['added'][] = $uri;
+ break;
+ case 2:
+ $result['modified'][] = $uri;
+ break;
+ case 3:
+ $result['deleted'][] = $uri;
+ break;
+ }
+ }
+ } else {
+ // No synctoken supplied, this is the initial sync.
+ $query = 'SELECT uri FROM '.$this->cardsTableName.' WHERE addressbookid = ?';
+ $stmt = $this->pdo->prepare($query);
+ $stmt->execute([$addressBookId]);
+
+ $result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Adds a change record to the addressbookchanges table.
+ *
+ * @param mixed $addressBookId
+ * @param string $objectUri
+ * @param int $operation 1 = add, 2 = modify, 3 = delete
+ */
+ protected function addChange($addressBookId, $objectUri, $operation)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->addressBookChangesTableName.' (uri, synctoken, addressbookid, operation) SELECT ?, synctoken, ?, ? FROM '.$this->addressBooksTableName.' WHERE id = ?');
+ $stmt->execute([
+ $objectUri,
+ $addressBookId,
+ $operation,
+ $addressBookId,
+ ]);
+ $stmt = $this->pdo->prepare('UPDATE '.$this->addressBooksTableName.' SET synctoken = synctoken + 1 WHERE id = ?');
+ $stmt->execute([
+ $addressBookId,
+ ]);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php
new file mode 100644
index 0000000..6aaad14
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Backend/SyncSupport.php
@@ -0,0 +1,83 @@
+ 'The current synctoken',
+ * 'added' => [
+ * 'new.txt',
+ * ],
+ * 'modified' => [
+ * 'modified.txt',
+ * ],
+ * 'deleted' => [
+ * 'foo.php.bak',
+ * 'old.txt'
+ * ]
+ * ];
+ *
+ * The returned syncToken property should reflect the *current* syncToken
+ * of the calendar, as reported in the {http://sabredav.org/ns}sync-token
+ * property. This is needed here too, to ensure the operation is atomic.
+ *
+ * If the $syncToken argument is specified as null, this is an initial
+ * sync, and all members should be reported.
+ *
+ * The modified property is an array of nodenames that have changed since
+ * the last token.
+ *
+ * The deleted property is an array with nodenames, that have been deleted
+ * from collection.
+ *
+ * The $syncLevel argument is basically the 'depth' of the report. If it's
+ * 1, you only have to report changes that happened only directly in
+ * immediate descendants. If it's 2, it should also include changes from
+ * the nodes below the child collections. (grandchildren)
+ *
+ * The $limit argument allows a client to specify how many results should
+ * be returned at most. If the limit is not specified, it should be treated
+ * as infinite.
+ *
+ * If the limit (infinite or not) is higher than you're willing to return,
+ * you should throw a Sabre\DAV\Exception\TooMuchMatches() exception.
+ *
+ * If the syncToken is expired (due to data cleanup) or unknown, you must
+ * return null.
+ *
+ * The limit is 'suggestive'. You are free to ignore it.
+ *
+ * @param string $addressBookId
+ * @param string $syncToken
+ * @param int $syncLevel
+ * @param int $limit
+ *
+ * @return array|null
+ */
+ public function getChangesForAddressBook($addressBookId, $syncToken, $syncLevel, $limit = null);
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Card.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Card.php
new file mode 100644
index 0000000..c9cd2bb
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Card.php
@@ -0,0 +1,202 @@
+carddavBackend = $carddavBackend;
+ $this->addressBookInfo = $addressBookInfo;
+ $this->cardData = $cardData;
+ }
+
+ /**
+ * Returns the uri for this object.
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->cardData['uri'];
+ }
+
+ /**
+ * Returns the VCard-formatted object.
+ *
+ * @return string
+ */
+ public function get()
+ {
+ // Pre-populating 'carddata' is optional. If we don't yet have it
+ // already, we fetch it from the backend.
+ if (!isset($this->cardData['carddata'])) {
+ $this->cardData = $this->carddavBackend->getCard($this->addressBookInfo['id'], $this->cardData['uri']);
+ }
+
+ return $this->cardData['carddata'];
+ }
+
+ /**
+ * Updates the VCard-formatted object.
+ *
+ * @param string $cardData
+ *
+ * @return string|null
+ */
+ public function put($cardData)
+ {
+ if (is_resource($cardData)) {
+ $cardData = stream_get_contents($cardData);
+ }
+
+ // Converting to UTF-8, if needed
+ $cardData = DAV\StringUtil::ensureUTF8($cardData);
+
+ $etag = $this->carddavBackend->updateCard($this->addressBookInfo['id'], $this->cardData['uri'], $cardData);
+ $this->cardData['carddata'] = $cardData;
+ $this->cardData['etag'] = $etag;
+
+ return $etag;
+ }
+
+ /**
+ * Deletes the card.
+ */
+ public function delete()
+ {
+ $this->carddavBackend->deleteCard($this->addressBookInfo['id'], $this->cardData['uri']);
+ }
+
+ /**
+ * Returns the mime content-type.
+ *
+ * @return string
+ */
+ public function getContentType()
+ {
+ return 'text/vcard; charset=utf-8';
+ }
+
+ /**
+ * Returns an ETag for this object.
+ *
+ * @return string
+ */
+ public function getETag()
+ {
+ if (isset($this->cardData['etag'])) {
+ return $this->cardData['etag'];
+ } else {
+ $data = $this->get();
+ if (is_string($data)) {
+ return '"'.md5($data).'"';
+ } else {
+ // We refuse to calculate the md5 if it's a stream.
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Returns the last modification date as a unix timestamp.
+ *
+ * @return int
+ */
+ public function getLastModified()
+ {
+ return isset($this->cardData['lastmodified']) ? $this->cardData['lastmodified'] : null;
+ }
+
+ /**
+ * Returns the size of this object in bytes.
+ *
+ * @return int
+ */
+ public function getSize()
+ {
+ if (array_key_exists('size', $this->cardData)) {
+ return $this->cardData['size'];
+ } else {
+ return strlen($this->get());
+ }
+ }
+
+ /**
+ * Returns the owner principal.
+ *
+ * This must be a url to a principal, or null if there's no owner
+ *
+ * @return string|null
+ */
+ public function getOwner()
+ {
+ return $this->addressBookInfo['principaluri'];
+ }
+
+ /**
+ * Returns a list of ACE's for this node.
+ *
+ * Each ACE has the following properties:
+ * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
+ * currently the only supported privileges
+ * * 'principal', a url to the principal who owns the node
+ * * 'protected' (optional), indicating that this ACE is not allowed to
+ * be updated.
+ *
+ * @return array
+ */
+ public function getACL()
+ {
+ // An alternative acl may be specified through the cardData array.
+ if (isset($this->cardData['acl'])) {
+ return $this->cardData['acl'];
+ }
+
+ return [
+ [
+ 'privilege' => '{DAV:}all',
+ 'principal' => $this->addressBookInfo['principaluri'],
+ 'protected' => true,
+ ],
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/IAddressBook.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/IAddressBook.php
new file mode 100644
index 0000000..3f489f4
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/IAddressBook.php
@@ -0,0 +1,20 @@
+on('propFind', [$this, 'propFindEarly']);
+ $server->on('propFind', [$this, 'propFindLate'], 150);
+ $server->on('report', [$this, 'report']);
+ $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
+ $server->on('beforeWriteContent', [$this, 'beforeWriteContent']);
+ $server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
+ $server->on('afterMethod:GET', [$this, 'httpAfterGet']);
+
+ $server->xml->namespaceMap[self::NS_CARDDAV] = 'card';
+
+ $server->xml->elementMap['{'.self::NS_CARDDAV.'}addressbook-query'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookQueryReport';
+ $server->xml->elementMap['{'.self::NS_CARDDAV.'}addressbook-multiget'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookMultiGetReport';
+
+ /* Mapping Interfaces to {DAV:}resourcetype values */
+ $server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook'] = '{'.self::NS_CARDDAV.'}addressbook';
+ $server->resourceTypeMapping['Sabre\\CardDAV\\IDirectory'] = '{'.self::NS_CARDDAV.'}directory';
+
+ /* Adding properties that may never be changed */
+ $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}supported-address-data';
+ $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}max-resource-size';
+ $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}addressbook-home-set';
+ $server->protectedProperties[] = '{'.self::NS_CARDDAV.'}supported-collation-set';
+
+ $server->xml->elementMap['{http://calendarserver.org/ns/}me-card'] = 'Sabre\\DAV\\Xml\\Property\\Href';
+
+ $this->server = $server;
+ }
+
+ /**
+ * Returns a list of supported features.
+ *
+ * This is used in the DAV: header in the OPTIONS and PROPFIND requests.
+ *
+ * @return array
+ */
+ public function getFeatures()
+ {
+ return ['addressbook'];
+ }
+
+ /**
+ * Returns a list of reports this plugin supports.
+ *
+ * This will be used in the {DAV:}supported-report-set property.
+ * Note that you still need to subscribe to the 'report' event to actually
+ * implement them
+ *
+ * @param string $uri
+ *
+ * @return array
+ */
+ public function getSupportedReportSet($uri)
+ {
+ $node = $this->server->tree->getNodeForPath($uri);
+ if ($node instanceof IAddressBook || $node instanceof ICard) {
+ return [
+ '{'.self::NS_CARDDAV.'}addressbook-multiget',
+ '{'.self::NS_CARDDAV.'}addressbook-query',
+ ];
+ }
+
+ return [];
+ }
+
+ /**
+ * Adds all CardDAV-specific properties.
+ */
+ public function propFindEarly(DAV\PropFind $propFind, DAV\INode $node)
+ {
+ $ns = '{'.self::NS_CARDDAV.'}';
+
+ if ($node instanceof IAddressBook) {
+ $propFind->handle($ns.'max-resource-size', $this->maxResourceSize);
+ $propFind->handle($ns.'supported-address-data', function () {
+ return new Xml\Property\SupportedAddressData();
+ });
+ $propFind->handle($ns.'supported-collation-set', function () {
+ return new Xml\Property\SupportedCollationSet();
+ });
+ }
+ if ($node instanceof DAVACL\IPrincipal) {
+ $path = $propFind->getPath();
+
+ $propFind->handle('{'.self::NS_CARDDAV.'}addressbook-home-set', function () use ($path) {
+ return new LocalHref($this->getAddressBookHomeForPrincipal($path).'/');
+ });
+
+ if ($this->directories) {
+ $propFind->handle('{'.self::NS_CARDDAV.'}directory-gateway', function () {
+ return new LocalHref($this->directories);
+ });
+ }
+ }
+
+ if ($node instanceof ICard) {
+ // The address-data property is not supposed to be a 'real'
+ // property, but in large chunks of the spec it does act as such.
+ // Therefore we simply expose it as a property.
+ $propFind->handle('{'.self::NS_CARDDAV.'}address-data', function () use ($node) {
+ $val = $node->get();
+ if (is_resource($val)) {
+ $val = stream_get_contents($val);
+ }
+
+ return $val;
+ });
+ }
+ }
+
+ /**
+ * This functions handles REPORT requests specific to CardDAV.
+ *
+ * @param string $reportName
+ * @param \DOMNode $dom
+ * @param mixed $path
+ *
+ * @return bool
+ */
+ public function report($reportName, $dom, $path)
+ {
+ switch ($reportName) {
+ case '{'.self::NS_CARDDAV.'}addressbook-multiget':
+ $this->server->transactionType = 'report-addressbook-multiget';
+ $this->addressbookMultiGetReport($dom);
+
+ return false;
+ case '{'.self::NS_CARDDAV.'}addressbook-query':
+ $this->server->transactionType = 'report-addressbook-query';
+ $this->addressBookQueryReport($dom);
+
+ return false;
+ default:
+ return;
+ }
+ }
+
+ /**
+ * Returns the addressbook home for a given principal.
+ *
+ * @param string $principal
+ *
+ * @return string
+ */
+ protected function getAddressbookHomeForPrincipal($principal)
+ {
+ list(, $principalId) = Uri\split($principal);
+
+ return self::ADDRESSBOOK_ROOT.'/'.$principalId;
+ }
+
+ /**
+ * This function handles the addressbook-multiget REPORT.
+ *
+ * This report is used by the client to fetch the content of a series
+ * of urls. Effectively avoiding a lot of redundant requests.
+ *
+ * @param Xml\Request\AddressBookMultiGetReport $report
+ */
+ public function addressbookMultiGetReport($report)
+ {
+ $contentType = $report->contentType;
+ $version = $report->version;
+ if ($version) {
+ $contentType .= '; version='.$version;
+ }
+
+ $vcardType = $this->negotiateVCard(
+ $contentType
+ );
+
+ $propertyList = [];
+ $paths = array_map(
+ [$this->server, 'calculateUri'],
+ $report->hrefs
+ );
+ foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $props) {
+ if (isset($props['200']['{'.self::NS_CARDDAV.'}address-data'])) {
+ $props['200']['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard(
+ $props[200]['{'.self::NS_CARDDAV.'}address-data'],
+ $vcardType
+ );
+ }
+ $propertyList[] = $props;
+ }
+
+ $prefer = $this->server->getHTTPPrefer();
+
+ $this->server->httpResponse->setStatus(207);
+ $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
+ $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
+ $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, 'minimal' === $prefer['return']));
+ }
+
+ /**
+ * This method is triggered before a file gets updated with new content.
+ *
+ * This plugin uses this method to ensure that Card nodes receive valid
+ * vcard data.
+ *
+ * @param string $path
+ * @param resource $data
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
+ */
+ public function beforeWriteContent($path, DAV\IFile $node, &$data, &$modified)
+ {
+ if (!$node instanceof ICard) {
+ return;
+ }
+
+ $this->validateVCard($data, $modified);
+ }
+
+ /**
+ * This method is triggered before a new file is created.
+ *
+ * This plugin uses this method to ensure that Card nodes receive valid
+ * vcard data.
+ *
+ * @param string $path
+ * @param resource $data
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
+ */
+ public function beforeCreateFile($path, &$data, DAV\ICollection $parentNode, &$modified)
+ {
+ if (!$parentNode instanceof IAddressBook) {
+ return;
+ }
+
+ $this->validateVCard($data, $modified);
+ }
+
+ /**
+ * Checks if the submitted iCalendar data is in fact, valid.
+ *
+ * An exception is thrown if it's not.
+ *
+ * @param resource|string $data
+ * @param bool $modified should be set to true, if this event handler
+ * changed &$data
+ */
+ protected function validateVCard(&$data, &$modified)
+ {
+ // If it's a stream, we convert it to a string first.
+ if (is_resource($data)) {
+ $data = stream_get_contents($data);
+ }
+
+ $before = $data;
+
+ try {
+ // If the data starts with a [, we can reasonably assume we're dealing
+ // with a jCal object.
+ if ('[' === substr($data, 0, 1)) {
+ $vobj = VObject\Reader::readJson($data);
+
+ // Converting $data back to iCalendar, as that's what we
+ // technically support everywhere.
+ $data = $vobj->serialize();
+ $modified = true;
+ } else {
+ $vobj = VObject\Reader::read($data);
+ }
+ } catch (VObject\ParseException $e) {
+ throw new DAV\Exception\UnsupportedMediaType('This resource only supports valid vCard or jCard data. Parse error: '.$e->getMessage());
+ }
+
+ if ('VCARD' !== $vobj->name) {
+ throw new DAV\Exception\UnsupportedMediaType('This collection can only support vcard objects.');
+ }
+
+ $options = VObject\Node::PROFILE_CARDDAV;
+ $prefer = $this->server->getHTTPPrefer();
+
+ if ('strict' !== $prefer['handling']) {
+ $options |= VObject\Node::REPAIR;
+ }
+
+ $messages = $vobj->validate($options);
+
+ $highestLevel = 0;
+ $warningMessage = null;
+
+ // $messages contains a list of problems with the vcard, along with
+ // their severity.
+ foreach ($messages as $message) {
+ if ($message['level'] > $highestLevel) {
+ // Recording the highest reported error level.
+ $highestLevel = $message['level'];
+ $warningMessage = $message['message'];
+ }
+
+ switch ($message['level']) {
+ case 1:
+ // Level 1 means that there was a problem, but it was repaired.
+ $modified = true;
+ break;
+ case 2:
+ // Level 2 means a warning, but not critical
+ break;
+ case 3:
+ // Level 3 means a critical error
+ throw new DAV\Exception\UnsupportedMediaType('Validation error in vCard: '.$message['message']);
+ }
+ }
+ if ($warningMessage) {
+ $this->server->httpResponse->setHeader(
+ 'X-Sabre-Ew-Gross',
+ 'vCard validation warning: '.$warningMessage
+ );
+
+ // Re-serializing object.
+ $data = $vobj->serialize();
+ if (!$modified && 0 !== strcmp($data, $before)) {
+ // This ensures that the system does not send an ETag back.
+ $modified = true;
+ }
+ }
+
+ // Destroy circular references to PHP will GC the object.
+ $vobj->destroy();
+ }
+
+ /**
+ * This function handles the addressbook-query REPORT.
+ *
+ * This report is used by the client to filter an addressbook based on a
+ * complex query.
+ *
+ * @param Xml\Request\AddressBookQueryReport $report
+ */
+ protected function addressbookQueryReport($report)
+ {
+ $depth = $this->server->getHTTPDepth(0);
+
+ if (0 == $depth) {
+ $candidateNodes = [
+ $this->server->tree->getNodeForPath($this->server->getRequestUri()),
+ ];
+ if (!$candidateNodes[0] instanceof ICard) {
+ throw new ReportNotSupported('The addressbook-query report is not supported on this url with Depth: 0');
+ }
+ } else {
+ $candidateNodes = $this->server->tree->getChildren($this->server->getRequestUri());
+ }
+
+ $contentType = $report->contentType;
+ if ($report->version) {
+ $contentType .= '; version='.$report->version;
+ }
+
+ $vcardType = $this->negotiateVCard(
+ $contentType
+ );
+
+ $validNodes = [];
+ foreach ($candidateNodes as $node) {
+ if (!$node instanceof ICard) {
+ continue;
+ }
+
+ $blob = $node->get();
+ if (is_resource($blob)) {
+ $blob = stream_get_contents($blob);
+ }
+
+ if (!$this->validateFilters($blob, $report->filters, $report->test)) {
+ continue;
+ }
+
+ $validNodes[] = $node;
+
+ if ($report->limit && $report->limit <= count($validNodes)) {
+ // We hit the maximum number of items, we can stop now.
+ break;
+ }
+ }
+
+ $result = [];
+ foreach ($validNodes as $validNode) {
+ if (0 == $depth) {
+ $href = $this->server->getRequestUri();
+ } else {
+ $href = $this->server->getRequestUri().'/'.$validNode->getName();
+ }
+
+ list($props) = $this->server->getPropertiesForPath($href, $report->properties, 0);
+
+ if (isset($props[200]['{'.self::NS_CARDDAV.'}address-data'])) {
+ $props[200]['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard(
+ $props[200]['{'.self::NS_CARDDAV.'}address-data'],
+ $vcardType,
+ $report->addressDataProperties
+ );
+ }
+ $result[] = $props;
+ }
+
+ $prefer = $this->server->getHTTPPrefer();
+
+ $this->server->httpResponse->setStatus(207);
+ $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
+ $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
+ $this->server->httpResponse->setBody($this->server->generateMultiStatus($result, 'minimal' === $prefer['return']));
+ }
+
+ /**
+ * Validates if a vcard makes it throught a list of filters.
+ *
+ * @param string $vcardData
+ * @param string $test anyof or allof (which means OR or AND)
+ *
+ * @return bool
+ */
+ public function validateFilters($vcardData, array $filters, $test)
+ {
+ if (!$filters) {
+ return true;
+ }
+ $vcard = VObject\Reader::read($vcardData);
+
+ foreach ($filters as $filter) {
+ $isDefined = isset($vcard->{$filter['name']});
+ if ($filter['is-not-defined']) {
+ if ($isDefined) {
+ $success = false;
+ } else {
+ $success = true;
+ }
+ } elseif ((!$filter['param-filters'] && !$filter['text-matches']) || !$isDefined) {
+ // We only need to check for existence
+ $success = $isDefined;
+ } else {
+ $vProperties = $vcard->select($filter['name']);
+
+ $results = [];
+ if ($filter['param-filters']) {
+ $results[] = $this->validateParamFilters($vProperties, $filter['param-filters'], $filter['test']);
+ }
+ if ($filter['text-matches']) {
+ $texts = [];
+ foreach ($vProperties as $vProperty) {
+ $texts[] = $vProperty->getValue();
+ }
+
+ $results[] = $this->validateTextMatches($texts, $filter['text-matches'], $filter['test']);
+ }
+
+ if (1 === count($results)) {
+ $success = $results[0];
+ } else {
+ if ('anyof' === $filter['test']) {
+ $success = $results[0] || $results[1];
+ } else {
+ $success = $results[0] && $results[1];
+ }
+ }
+ } // else
+
+ // There are two conditions where we can already determine whether
+ // or not this filter succeeds.
+ if ('anyof' === $test && $success) {
+ // Destroy circular references to PHP will GC the object.
+ $vcard->destroy();
+
+ return true;
+ }
+ if ('allof' === $test && !$success) {
+ // Destroy circular references to PHP will GC the object.
+ $vcard->destroy();
+
+ return false;
+ }
+ } // foreach
+
+ // Destroy circular references to PHP will GC the object.
+ $vcard->destroy();
+
+ // If we got all the way here, it means we haven't been able to
+ // determine early if the test failed or not.
+ //
+ // This implies for 'anyof' that the test failed, and for 'allof' that
+ // we succeeded. Sounds weird, but makes sense.
+ return 'allof' === $test;
+ }
+
+ /**
+ * Validates if a param-filter can be applied to a specific property.
+ *
+ * @todo currently we're only validating the first parameter of the passed
+ * property. Any subsequence parameters with the same name are
+ * ignored.
+ *
+ * @param string $test
+ *
+ * @return bool
+ */
+ protected function validateParamFilters(array $vProperties, array $filters, $test)
+ {
+ foreach ($filters as $filter) {
+ $isDefined = false;
+ foreach ($vProperties as $vProperty) {
+ $isDefined = isset($vProperty[$filter['name']]);
+ if ($isDefined) {
+ break;
+ }
+ }
+
+ if ($filter['is-not-defined']) {
+ if ($isDefined) {
+ $success = false;
+ } else {
+ $success = true;
+ }
+
+ // If there's no text-match, we can just check for existence
+ } elseif (!$filter['text-match'] || !$isDefined) {
+ $success = $isDefined;
+ } else {
+ $success = false;
+ foreach ($vProperties as $vProperty) {
+ // If we got all the way here, we'll need to validate the
+ // text-match filter.
+ if (isset($vProperty[$filter['name']])) {
+ $success = DAV\StringUtil::textMatch(
+ $vProperty[$filter['name']]->getValue(),
+ $filter['text-match']['value'],
+ $filter['text-match']['collation'],
+ $filter['text-match']['match-type']
+ );
+ if ($filter['text-match']['negate-condition']) {
+ $success = !$success;
+ }
+ }
+ if ($success) {
+ break;
+ }
+ }
+ } // else
+
+ // There are two conditions where we can already determine whether
+ // or not this filter succeeds.
+ if ('anyof' === $test && $success) {
+ return true;
+ }
+ if ('allof' === $test && !$success) {
+ return false;
+ }
+ }
+
+ // If we got all the way here, it means we haven't been able to
+ // determine early if the test failed or not.
+ //
+ // This implies for 'anyof' that the test failed, and for 'allof' that
+ // we succeeded. Sounds weird, but makes sense.
+ return 'allof' === $test;
+ }
+
+ /**
+ * Validates if a text-filter can be applied to a specific property.
+ *
+ * @param string $test
+ *
+ * @return bool
+ */
+ protected function validateTextMatches(array $texts, array $filters, $test)
+ {
+ foreach ($filters as $filter) {
+ $success = false;
+ foreach ($texts as $haystack) {
+ $success = DAV\StringUtil::textMatch($haystack, $filter['value'], $filter['collation'], $filter['match-type']);
+ if ($filter['negate-condition']) {
+ $success = !$success;
+ }
+
+ // Breaking on the first match
+ if ($success) {
+ break;
+ }
+ }
+
+ if ($success && 'anyof' === $test) {
+ return true;
+ }
+
+ if (!$success && 'allof' == $test) {
+ return false;
+ }
+ }
+
+ // If we got all the way here, it means we haven't been able to
+ // determine early if the test failed or not.
+ //
+ // This implies for 'anyof' that the test failed, and for 'allof' that
+ // we succeeded. Sounds weird, but makes sense.
+ return 'allof' === $test;
+ }
+
+ /**
+ * This event is triggered when fetching properties.
+ *
+ * This event is scheduled late in the process, after most work for
+ * propfind has been done.
+ */
+ public function propFindLate(DAV\PropFind $propFind, DAV\INode $node)
+ {
+ // If the request was made using the SOGO connector, we must rewrite
+ // the content-type property. By default SabreDAV will send back
+ // text/x-vcard; charset=utf-8, but for SOGO we must strip that last
+ // part.
+ if (false === strpos((string) $this->server->httpRequest->getHeader('User-Agent'), 'Thunderbird')) {
+ return;
+ }
+ $contentType = $propFind->get('{DAV:}getcontenttype');
+ if (null !== $contentType) {
+ list($part) = explode(';', $contentType);
+ if ('text/x-vcard' === $part || 'text/vcard' === $part) {
+ $propFind->set('{DAV:}getcontenttype', 'text/x-vcard');
+ }
+ }
+ }
+
+ /**
+ * This method is used to generate HTML output for the
+ * Sabre\DAV\Browser\Plugin. This allows us to generate an interface users
+ * can use to create new addressbooks.
+ *
+ * @param string $output
+ *
+ * @return bool
+ */
+ public function htmlActionsPanel(DAV\INode $node, &$output)
+ {
+ if (!$node instanceof AddressBookHome) {
+ return;
+ }
+
+ $output .= '
+
';
+
+ return false;
+ }
+
+ /**
+ * This event is triggered after GET requests.
+ *
+ * This is used to transform data into jCal, if this was requested.
+ */
+ public function httpAfterGet(RequestInterface $request, ResponseInterface $response)
+ {
+ $contentType = $response->getHeader('Content-Type');
+ if (null === $contentType || false === strpos($contentType, 'text/vcard')) {
+ return;
+ }
+
+ $target = $this->negotiateVCard($request->getHeader('Accept'), $mimeType);
+
+ $newBody = $this->convertVCard(
+ $response->getBody(),
+ $target
+ );
+
+ $response->setBody($newBody);
+ $response->setHeader('Content-Type', $mimeType.'; charset=utf-8');
+ $response->setHeader('Content-Length', strlen($newBody));
+ }
+
+ /**
+ * This helper function performs the content-type negotiation for vcards.
+ *
+ * It will return one of the following strings:
+ * 1. vcard3
+ * 2. vcard4
+ * 3. jcard
+ *
+ * It defaults to vcard3.
+ *
+ * @param string $input
+ * @param string $mimeType
+ *
+ * @return string
+ */
+ protected function negotiateVCard($input, &$mimeType = null)
+ {
+ $result = HTTP\negotiateContentType(
+ $input,
+ [
+ // Most often used mime-type. Version 3
+ 'text/x-vcard',
+ // The correct standard mime-type. Defaults to version 3 as
+ // well.
+ 'text/vcard',
+ // vCard 4
+ 'text/vcard; version=4.0',
+ // vCard 3
+ 'text/vcard; version=3.0',
+ // jCard
+ 'application/vcard+json',
+ ]
+ );
+
+ $mimeType = $result;
+ switch ($result) {
+ default:
+ case 'text/x-vcard':
+ case 'text/vcard':
+ case 'text/vcard; version=3.0':
+ $mimeType = 'text/vcard';
+
+ return 'vcard3';
+ case 'text/vcard; version=4.0':
+ return 'vcard4';
+ case 'application/vcard+json':
+ return 'jcard';
+
+ // @codeCoverageIgnoreStart
+ }
+ // @codeCoverageIgnoreEnd
+ }
+
+ /**
+ * Converts a vcard blob to a different version, or jcard.
+ *
+ * @param string|resource $data
+ * @param string $target
+ * @param array $propertiesFilter
+ *
+ * @return string
+ */
+ protected function convertVCard($data, $target, ?array $propertiesFilter = null)
+ {
+ if (is_resource($data)) {
+ $data = stream_get_contents($data);
+ }
+ $input = VObject\Reader::read($data);
+ if (!empty($propertiesFilter)) {
+ $propertiesFilter = array_merge(['UID', 'VERSION', 'FN'], $propertiesFilter);
+ $keys = array_unique(array_map(function ($child) {
+ return $child->name;
+ }, $input->children()));
+ $keys = array_diff($keys, $propertiesFilter);
+ foreach ($keys as $key) {
+ unset($input->$key);
+ }
+ $data = $input->serialize();
+ }
+ $output = null;
+ try {
+ switch ($target) {
+ default:
+ case 'vcard3':
+ if (VObject\Document::VCARD30 === $input->getDocumentType()) {
+ // Do nothing
+ return $data;
+ }
+ $output = $input->convert(VObject\Document::VCARD30);
+
+ return $output->serialize();
+ case 'vcard4':
+ if (VObject\Document::VCARD40 === $input->getDocumentType()) {
+ // Do nothing
+ return $data;
+ }
+ $output = $input->convert(VObject\Document::VCARD40);
+
+ return $output->serialize();
+ case 'jcard':
+ $output = $input->convert(VObject\Document::VCARD40);
+
+ return json_encode($output);
+ }
+ } finally {
+ // Destroy circular references to PHP will GC the object.
+ $input->destroy();
+ if (!is_null($output)) {
+ $output->destroy();
+ }
+ }
+ }
+
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins
+ * using DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return 'carddav';
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds support for CardDAV (rfc6352)',
+ 'link' => 'http://sabre.io/dav/carddav/',
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
new file mode 100644
index 0000000..431391e
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
@@ -0,0 +1,165 @@
+server = $server;
+ $this->server->on('method:GET', [$this, 'httpGet'], 90);
+ $server->on('browserButtonActions', function ($path, $node, &$actions) {
+ if ($node instanceof IAddressBook) {
+ $actions .= '';
+ }
+ });
+ }
+
+ /**
+ * Intercepts GET requests on addressbook urls ending with ?export.
+ *
+ * @return bool
+ */
+ public function httpGet(RequestInterface $request, ResponseInterface $response)
+ {
+ $queryParams = $request->getQueryParameters();
+ if (!array_key_exists('export', $queryParams)) {
+ return;
+ }
+
+ $path = $request->getPath();
+
+ $node = $this->server->tree->getNodeForPath($path);
+
+ if (!($node instanceof IAddressBook)) {
+ return;
+ }
+
+ $this->server->transactionType = 'get-addressbook-export';
+
+ // Checking ACL, if available.
+ if ($aclPlugin = $this->server->getPlugin('acl')) {
+ $aclPlugin->checkPrivileges($path, '{DAV:}read');
+ }
+
+ $nodes = $this->server->getPropertiesForPath($path, [
+ '{'.Plugin::NS_CARDDAV.'}address-data',
+ ], 1);
+
+ $format = 'text/directory';
+
+ $output = null;
+ $filenameExtension = null;
+
+ switch ($format) {
+ case 'text/directory':
+ $output = $this->generateVCF($nodes);
+ $filenameExtension = '.vcf';
+ break;
+ }
+
+ $filename = preg_replace(
+ '/[^a-zA-Z0-9-_ ]/um',
+ '',
+ $node->getName()
+ );
+ $filename .= '-'.date('Y-m-d').$filenameExtension;
+
+ $response->setHeader('Content-Disposition', 'attachment; filename="'.$filename.'"');
+ $response->setHeader('Content-Type', $format);
+
+ $response->setStatus(200);
+ $response->setBody($output);
+
+ // Returning false to break the event chain
+ return false;
+ }
+
+ /**
+ * Merges all vcard objects, and builds one big vcf export.
+ *
+ * @return string
+ */
+ public function generateVCF(array $nodes)
+ {
+ $output = '';
+
+ foreach ($nodes as $node) {
+ if (!isset($node[200]['{'.Plugin::NS_CARDDAV.'}address-data'])) {
+ continue;
+ }
+ $nodeData = $node[200]['{'.Plugin::NS_CARDDAV.'}address-data'];
+
+ // Parsing this node so VObject can clean up the output.
+ $vcard = VObject\Reader::read($nodeData);
+ $output .= $vcard->serialize();
+
+ // Destroy circular references to PHP will GC the object.
+ $vcard->destroy();
+ }
+
+ return $output;
+ }
+
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins
+ * using \Sabre\DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return 'vcf-export';
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds the ability to export CardDAV addressbooks as a single vCard file.',
+ 'link' => 'http://sabre.io/dav/vcf-export-plugin/',
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php
new file mode 100644
index 0000000..b60fceb
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/AddressData.php
@@ -0,0 +1,66 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $result = [
+ 'contentType' => $reader->getAttribute('content-type') ?: 'text/vcard',
+ 'version' => $reader->getAttribute('version') ?: '3.0',
+ ];
+
+ $elems = (array) $reader->parseInnerTree();
+ $elems = array_filter($elems, function ($element) {
+ return '{urn:ietf:params:xml:ns:carddav}prop' === $element['name'] &&
+ isset($element['attributes']['name']);
+ });
+ $result['addressDataProperties'] = array_map(function ($element) {
+ return $element['attributes']['name'];
+ }, $elems);
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php
new file mode 100644
index 0000000..0a7ec06
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/ParamFilter.php
@@ -0,0 +1,86 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $result = [
+ 'name' => null,
+ 'is-not-defined' => false,
+ 'text-match' => null,
+ ];
+
+ $att = $reader->parseAttributes();
+ $result['name'] = $att['name'];
+
+ $elems = $reader->parseInnerTree();
+
+ if (is_array($elems)) {
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CARDDAV.'}is-not-defined':
+ $result['is-not-defined'] = true;
+ break;
+ case '{'.Plugin::NS_CARDDAV.'}text-match':
+ $matchType = isset($elem['attributes']['match-type']) ? $elem['attributes']['match-type'] : 'contains';
+
+ if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) {
+ throw new BadRequest('Unknown match-type: '.$matchType);
+ }
+ $result['text-match'] = [
+ 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'],
+ 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap',
+ 'value' => $elem['value'],
+ 'match-type' => $matchType,
+ ];
+ break;
+ }
+ }
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php
new file mode 100644
index 0000000..5dedac8
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Filter/PropFilter.php
@@ -0,0 +1,95 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $result = [
+ 'name' => null,
+ 'test' => 'anyof',
+ 'is-not-defined' => false,
+ 'param-filters' => [],
+ 'text-matches' => [],
+ ];
+
+ $att = $reader->parseAttributes();
+ $result['name'] = $att['name'];
+
+ if (isset($att['test']) && 'allof' === $att['test']) {
+ $result['test'] = 'allof';
+ }
+
+ $elems = $reader->parseInnerTree();
+
+ if (is_array($elems)) {
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{'.Plugin::NS_CARDDAV.'}param-filter':
+ $result['param-filters'][] = $elem['value'];
+ break;
+ case '{'.Plugin::NS_CARDDAV.'}is-not-defined':
+ $result['is-not-defined'] = true;
+ break;
+ case '{'.Plugin::NS_CARDDAV.'}text-match':
+ $matchType = isset($elem['attributes']['match-type']) ? $elem['attributes']['match-type'] : 'contains';
+
+ if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) {
+ throw new BadRequest('Unknown match-type: '.$matchType);
+ }
+ $result['text-matches'][] = [
+ 'negate-condition' => isset($elem['attributes']['negate-condition']) && 'yes' === $elem['attributes']['negate-condition'],
+ 'collation' => isset($elem['attributes']['collation']) ? $elem['attributes']['collation'] : 'i;unicode-casemap',
+ 'value' => $elem['value'],
+ 'match-type' => $matchType,
+ ];
+ break;
+ }
+ }
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php
new file mode 100644
index 0000000..536c5a1
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedAddressData.php
@@ -0,0 +1,77 @@
+ 'text/vcard', 'version' => '3.0'],
+ ['contentType' => 'text/vcard', 'version' => '4.0'],
+ ['contentType' => 'application/vcard+json', 'version' => '4.0'],
+ ];
+ }
+
+ $this->supportedData = $supportedData;
+ }
+
+ /**
+ * The xmlSerialize method is called during xml writing.
+ *
+ * Use the $writer argument to write its own xml serialization.
+ *
+ * An important note: do _not_ create a parent element. Any element
+ * implementing XmlSerializable should only ever write what's considered
+ * its 'inner xml'.
+ *
+ * The parent of the current element is responsible for writing a
+ * containing element.
+ *
+ * This allows serializers to be re-used for different element names.
+ *
+ * If you are opening new elements, you must also close them again.
+ */
+ public function xmlSerialize(Writer $writer)
+ {
+ foreach ($this->supportedData as $supported) {
+ $writer->startElement('{'.Plugin::NS_CARDDAV.'}address-data-type');
+ $writer->writeAttributes([
+ 'content-type' => $supported['contentType'],
+ 'version' => $supported['version'],
+ ]);
+ $writer->endElement(); // address-data-type
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php
new file mode 100644
index 0000000..b19eddd
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Property/SupportedCollationSet.php
@@ -0,0 +1,44 @@
+writeElement('{urn:ietf:params:xml:ns:carddav}supported-collation', $coll);
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
new file mode 100644
index 0000000..491f969
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
@@ -0,0 +1,116 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = $reader->parseInnerTree([
+ '{urn:ietf:params:xml:ns:carddav}address-data' => 'Sabre\\CardDAV\\Xml\\Filter\\AddressData',
+ '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
+ ]);
+
+ $newProps = [
+ 'hrefs' => [],
+ 'properties' => [],
+ ];
+
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{DAV:}prop':
+ $newProps['properties'] = array_keys($elem['value']);
+ if (isset($elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'])) {
+ $newProps += $elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'];
+ }
+ break;
+ case '{DAV:}href':
+ $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']);
+ break;
+ }
+ }
+
+ $obj = new self();
+ foreach ($newProps as $key => $value) {
+ $obj->$key = $value;
+ }
+
+ return $obj;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php
new file mode 100644
index 0000000..02402f6
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/CardDAV/Xml/Request/AddressBookQueryReport.php
@@ -0,0 +1,193 @@
+next();
+ *
+ * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+ * the next element.
+ *
+ * @return mixed
+ */
+ public static function xmlDeserialize(Reader $reader)
+ {
+ $elems = (array) $reader->parseInnerTree([
+ '{urn:ietf:params:xml:ns:carddav}prop-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\PropFilter',
+ '{urn:ietf:params:xml:ns:carddav}param-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\ParamFilter',
+ '{urn:ietf:params:xml:ns:carddav}address-data' => 'Sabre\\CardDAV\\Xml\\Filter\\AddressData',
+ '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue',
+ ]);
+
+ $newProps = [
+ 'filters' => null,
+ 'properties' => [],
+ 'test' => 'anyof',
+ 'limit' => null,
+ ];
+
+ if (!is_array($elems)) {
+ $elems = [];
+ }
+
+ foreach ($elems as $elem) {
+ switch ($elem['name']) {
+ case '{DAV:}prop':
+ $newProps['properties'] = array_keys($elem['value']);
+ if (isset($elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'])) {
+ $newProps += $elem['value']['{'.Plugin::NS_CARDDAV.'}address-data'];
+ }
+ break;
+ case '{'.Plugin::NS_CARDDAV.'}filter':
+ if (!is_null($newProps['filters'])) {
+ throw new BadRequest('You can only include 1 {'.Plugin::NS_CARDDAV.'}filter element');
+ }
+ if (isset($elem['attributes']['test'])) {
+ $newProps['test'] = $elem['attributes']['test'];
+ if ('allof' !== $newProps['test'] && 'anyof' !== $newProps['test']) {
+ throw new BadRequest('The "test" attribute must be one of "allof" or "anyof"');
+ }
+ }
+
+ $newProps['filters'] = [];
+ foreach ((array) $elem['value'] as $subElem) {
+ if ($subElem['name'] === '{'.Plugin::NS_CARDDAV.'}prop-filter') {
+ $newProps['filters'][] = $subElem['value'];
+ }
+ }
+ break;
+ case '{'.Plugin::NS_CARDDAV.'}limit':
+ foreach ($elem['value'] as $child) {
+ if ($child['name'] === '{'.Plugin::NS_CARDDAV.'}nresults') {
+ $newProps['limit'] = (int) $child['value'];
+ }
+ }
+ break;
+ }
+ }
+
+ if (is_null($newProps['filters'])) {
+ /*
+ * We are supposed to throw this error, but KDE sometimes does not
+ * include the filter element, and we need to treat it as if no
+ * filters are supplied
+ */
+ //throw new BadRequest('The {' . Plugin::NS_CARDDAV . '}filter element is required for this request');
+ $newProps['filters'] = [];
+ }
+
+ $obj = new self();
+ foreach ($newProps as $key => $value) {
+ $obj->$key = $value;
+ }
+
+ return $obj;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php
new file mode 100644
index 0000000..3132333
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php
@@ -0,0 +1,136 @@
+realm = $realm;
+ }
+
+ /**
+ * When this method is called, the backend must check if authentication was
+ * successful.
+ *
+ * The returned value must be one of the following
+ *
+ * [true, "principals/username"]
+ * [false, "reason for failure"]
+ *
+ * If authentication was successful, it's expected that the authentication
+ * backend returns a so-called principal url.
+ *
+ * Examples of a principal url:
+ *
+ * principals/admin
+ * principals/user1
+ * principals/users/joe
+ * principals/uid/123457
+ *
+ * If you don't use WebDAV ACL (RFC3744) we recommend that you simply
+ * return a string such as:
+ *
+ * principals/users/[username]
+ *
+ * @return array
+ */
+ public function check(RequestInterface $request, ResponseInterface $response)
+ {
+ $auth = new HTTP\Auth\Basic(
+ $this->realm,
+ $request,
+ $response
+ );
+
+ $userpass = $auth->getCredentials();
+ if (!$userpass) {
+ return [false, "No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured"];
+ }
+ if (!$this->validateUserPass($userpass[0], $userpass[1])) {
+ return [false, 'Username or password was incorrect'];
+ }
+
+ return [true, $this->principalPrefix.$userpass[0]];
+ }
+
+ /**
+ * This method is called when a user could not be authenticated, and
+ * authentication was required for the current request.
+ *
+ * This gives you the opportunity to set authentication headers. The 401
+ * status code will already be set.
+ *
+ * In this case of Basic Auth, this would for example mean that the
+ * following header needs to be set:
+ *
+ * $response->addHeader('WWW-Authenticate', 'Basic realm=SabreDAV');
+ *
+ * Keep in mind that in the case of multiple authentication backends, other
+ * WWW-Authenticate headers may already have been set, and you'll want to
+ * append your own WWW-Authenticate header instead of overwriting the
+ * existing one.
+ */
+ public function challenge(RequestInterface $request, ResponseInterface $response)
+ {
+ $auth = new HTTP\Auth\Basic(
+ $this->realm,
+ $request,
+ $response
+ );
+ $auth->requireLogin();
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php
new file mode 100644
index 0000000..b681747
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractBearer.php
@@ -0,0 +1,130 @@
+realm = $realm;
+ }
+
+ /**
+ * When this method is called, the backend must check if authentication was
+ * successful.
+ *
+ * The returned value must be one of the following
+ *
+ * [true, "principals/username"]
+ * [false, "reason for failure"]
+ *
+ * If authentication was successful, it's expected that the authentication
+ * backend returns a so-called principal url.
+ *
+ * Examples of a principal url:
+ *
+ * principals/admin
+ * principals/user1
+ * principals/users/joe
+ * principals/uid/123457
+ *
+ * If you don't use WebDAV ACL (RFC3744) we recommend that you simply
+ * return a string such as:
+ *
+ * principals/users/[username]
+ *
+ * @return array
+ */
+ public function check(RequestInterface $request, ResponseInterface $response)
+ {
+ $auth = new HTTP\Auth\Bearer(
+ $this->realm,
+ $request,
+ $response
+ );
+
+ $bearerToken = $auth->getToken($request);
+ if (!$bearerToken) {
+ return [false, "No 'Authorization: Bearer' header found. Either the client didn't send one, or the server is mis-configured"];
+ }
+ $principalUrl = $this->validateBearerToken($bearerToken);
+ if (!$principalUrl) {
+ return [false, 'Bearer token was incorrect'];
+ }
+
+ return [true, $principalUrl];
+ }
+
+ /**
+ * This method is called when a user could not be authenticated, and
+ * authentication was required for the current request.
+ *
+ * This gives you the opportunity to set authentication headers. The 401
+ * status code will already be set.
+ *
+ * In this case of Bearer Auth, this would for example mean that the
+ * following header needs to be set:
+ *
+ * $response->addHeader('WWW-Authenticate', 'Bearer realm=SabreDAV');
+ *
+ * Keep in mind that in the case of multiple authentication backends, other
+ * WWW-Authenticate headers may already have been set, and you'll want to
+ * append your own WWW-Authenticate header instead of overwriting the
+ * existing one.
+ */
+ public function challenge(RequestInterface $request, ResponseInterface $response)
+ {
+ $auth = new HTTP\Auth\Bearer(
+ $this->realm,
+ $request,
+ $response
+ );
+ $auth->requireLogin();
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php
new file mode 100644
index 0000000..297655d
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/AbstractDigest.php
@@ -0,0 +1,160 @@
+realm = $realm;
+ }
+
+ /**
+ * Returns a users digest hash based on the username and realm.
+ *
+ * If the user was not known, null must be returned.
+ *
+ * @param string $realm
+ * @param string $username
+ *
+ * @return string|null
+ */
+ abstract public function getDigestHash($realm, $username);
+
+ /**
+ * When this method is called, the backend must check if authentication was
+ * successful.
+ *
+ * The returned value must be one of the following
+ *
+ * [true, "principals/username"]
+ * [false, "reason for failure"]
+ *
+ * If authentication was successful, it's expected that the authentication
+ * backend returns a so-called principal url.
+ *
+ * Examples of a principal url:
+ *
+ * principals/admin
+ * principals/user1
+ * principals/users/joe
+ * principals/uid/123457
+ *
+ * If you don't use WebDAV ACL (RFC3744) we recommend that you simply
+ * return a string such as:
+ *
+ * principals/users/[username]
+ *
+ * @return array
+ */
+ public function check(RequestInterface $request, ResponseInterface $response)
+ {
+ $digest = new HTTP\Auth\Digest(
+ $this->realm,
+ $request,
+ $response
+ );
+ $digest->init();
+
+ $username = $digest->getUsername();
+
+ // No username was given
+ if (!$username) {
+ return [false, "No 'Authorization: Digest' header found. Either the client didn't send one, or the server is misconfigured"];
+ }
+
+ $hash = $this->getDigestHash($this->realm, $username);
+ // If this was false, the user account didn't exist
+ if (false === $hash || is_null($hash)) {
+ return [false, 'Username or password was incorrect'];
+ }
+ if (!is_string($hash)) {
+ throw new DAV\Exception('The returned value from getDigestHash must be a string or null');
+ }
+
+ // If this was false, the password or part of the hash was incorrect.
+ if (!$digest->validateA1($hash)) {
+ return [false, 'Username or password was incorrect'];
+ }
+
+ return [true, $this->principalPrefix.$username];
+ }
+
+ /**
+ * This method is called when a user could not be authenticated, and
+ * authentication was required for the current request.
+ *
+ * This gives you the opportunity to set authentication headers. The 401
+ * status code will already be set.
+ *
+ * In this case of Basic Auth, this would for example mean that the
+ * following header needs to be set:
+ *
+ * $response->addHeader('WWW-Authenticate', 'Basic realm=SabreDAV');
+ *
+ * Keep in mind that in the case of multiple authentication backends, other
+ * WWW-Authenticate headers may already have been set, and you'll want to
+ * append your own WWW-Authenticate header instead of overwriting the
+ * existing one.
+ */
+ public function challenge(RequestInterface $request, ResponseInterface $response)
+ {
+ $auth = new HTTP\Auth\Digest(
+ $this->realm,
+ $request,
+ $response
+ );
+ $auth->init();
+
+ $oldStatus = $response->getStatus() ?: 200;
+ $auth->requireLogin();
+
+ // Preventing the digest utility from modifying the http status code,
+ // this should be handled by the main plugin.
+ $response->setStatus($oldStatus);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php
new file mode 100644
index 0000000..ebf67ca
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/Apache.php
@@ -0,0 +1,93 @@
+getRawServerValue('REMOTE_USER');
+ if (is_null($remoteUser)) {
+ $remoteUser = $request->getRawServerValue('REDIRECT_REMOTE_USER');
+ }
+ if (is_null($remoteUser)) {
+ $remoteUser = $request->getRawServerValue('PHP_AUTH_USER');
+ }
+ if (is_null($remoteUser)) {
+ return [false, 'No REMOTE_USER, REDIRECT_REMOTE_USER, or PHP_AUTH_USER property was found in the PHP $_SERVER super-global. This likely means your server is not configured correctly'];
+ }
+
+ return [true, $this->principalPrefix.$remoteUser];
+ }
+
+ /**
+ * This method is called when a user could not be authenticated, and
+ * authentication was required for the current request.
+ *
+ * This gives you the opportunity to set authentication headers. The 401
+ * status code will already be set.
+ *
+ * In this case of Basic Auth, this would for example mean that the
+ * following header needs to be set:
+ *
+ * $response->addHeader('WWW-Authenticate', 'Basic realm=SabreDAV');
+ *
+ * Keep in mind that in the case of multiple authentication backends, other
+ * WWW-Authenticate headers may already have been set, and you'll want to
+ * append your own WWW-Authenticate header instead of overwriting the
+ * existing one.
+ */
+ public function challenge(RequestInterface $request, ResponseInterface $response)
+ {
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php
new file mode 100644
index 0000000..133eac9
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php
@@ -0,0 +1,65 @@
+addHeader('WWW-Authenticate', 'Basic realm=SabreDAV');
+ *
+ * Keep in mind that in the case of multiple authentication backends, other
+ * WWW-Authenticate headers may already have been set, and you'll want to
+ * append your own WWW-Authenticate header instead of overwriting the
+ * existing one.
+ */
+ public function challenge(RequestInterface $request, ResponseInterface $response);
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php
new file mode 100644
index 0000000..5a8bb98
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php
@@ -0,0 +1,56 @@
+callBack = $callBack;
+ }
+
+ /**
+ * Validates a username and password.
+ *
+ * This method should return true or false depending on if login
+ * succeeded.
+ *
+ * @param string $username
+ * @param string $password
+ *
+ * @return bool
+ */
+ protected function validateUserPass($username, $password)
+ {
+ $cb = $this->callBack;
+
+ return $cb($username, $password);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php
new file mode 100644
index 0000000..ea2d396
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php
@@ -0,0 +1,74 @@
+loadFile($filename);
+ }
+ }
+
+ /**
+ * Loads an htdigest-formatted file. This method can be called multiple times if
+ * more than 1 file is used.
+ *
+ * @param string $filename
+ */
+ public function loadFile($filename)
+ {
+ foreach (file($filename, FILE_IGNORE_NEW_LINES) as $line) {
+ if (2 !== substr_count($line, ':')) {
+ throw new DAV\Exception('Malformed htdigest file. Every line should contain 2 colons');
+ }
+ list($username, $realm, $A1) = explode(':', $line);
+
+ if (!preg_match('/^[a-zA-Z0-9]{32}$/', $A1)) {
+ throw new DAV\Exception('Malformed htdigest file. Invalid md5 hash');
+ }
+ $this->users[$realm.':'.$username] = $A1;
+ }
+ }
+
+ /**
+ * Returns a users' information.
+ *
+ * @param string $realm
+ * @param string $username
+ *
+ * @return string
+ */
+ public function getDigestHash($realm, $username)
+ {
+ return isset($this->users[$realm.':'.$username]) ? $this->users[$realm.':'.$username] : false;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php
new file mode 100644
index 0000000..3a18311
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php
@@ -0,0 +1,82 @@
+mailbox = $mailbox;
+ }
+
+ /**
+ * Connects to an IMAP server and tries to authenticate.
+ *
+ * @param string $username
+ * @param string $password
+ *
+ * @return bool
+ */
+ protected function imapOpen($username, $password)
+ {
+ $success = false;
+
+ try {
+ $imap = imap_open($this->mailbox, $username, $password, OP_HALFOPEN | OP_READONLY, 1);
+ if ($imap) {
+ $success = true;
+ }
+ } catch (\ErrorException $e) {
+ error_log($e->getMessage());
+ }
+
+ $errors = imap_errors();
+ if ($errors) {
+ foreach ($errors as $error) {
+ error_log($error);
+ }
+ }
+
+ if (isset($imap) && $imap) {
+ imap_close($imap);
+ }
+
+ return $success;
+ }
+
+ /**
+ * Validates a username and password by trying to authenticate against IMAP.
+ *
+ * @param string $username
+ * @param string $password
+ *
+ * @return bool
+ */
+ protected function validateUserPass($username, $password)
+ {
+ return $this->imapOpen($username, $password);
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php
new file mode 100644
index 0000000..9a06912
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php
@@ -0,0 +1,55 @@
+pdo = $pdo;
+ }
+
+ /**
+ * Returns the digest hash for a user.
+ *
+ * @param string $realm
+ * @param string $username
+ *
+ * @return string|null
+ */
+ public function getDigestHash($realm, $username)
+ {
+ $stmt = $this->pdo->prepare('SELECT digesta1 FROM '.$this->tableName.' WHERE username = ?');
+ $stmt->execute([$username]);
+
+ return $stmt->fetchColumn() ?: null;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/PDOBasicAuth.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/PDOBasicAuth.php
new file mode 100644
index 0000000..d142cbf
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Backend/PDOBasicAuth.php
@@ -0,0 +1,114 @@
+pdo = $pdo;
+ if (isset($options['tableName'])) {
+ $this->tableName = $options['tableName'];
+ } else {
+ $this->tableName = 'users';
+ }
+ if (isset($options['digestColumn'])) {
+ $this->digestColumn = $options['digestColumn'];
+ } else {
+ $this->digestColumn = 'digest';
+ }
+ if (isset($options['uuidColumn'])) {
+ $this->uuidColumn = $options['uuidColumn'];
+ } else {
+ $this->uuidColumn = 'username';
+ }
+ if (isset($options['digestPrefix'])) {
+ $this->digestPrefix = $options['digestPrefix'];
+ }
+ }
+
+ /**
+ * Validates a username and password.
+ *
+ * This method should return true or false depending on if login
+ * succeeded.
+ *
+ * @param string $username
+ * @param string $password
+ *
+ * @return bool
+ */
+ public function validateUserPass($username, $password)
+ {
+ $stmt = $this->pdo->prepare('SELECT '.$this->digestColumn.' FROM '.$this->tableName.' WHERE '.$this->uuidColumn.' = ?');
+ $stmt->execute([$username]);
+ $result = $stmt->fetchAll();
+
+ if (!count($result)) {
+ return false;
+ } else {
+ $digest = $result[0][$this->digestColumn];
+
+ if (isset($this->digestPrefix)) {
+ $digest = substr($digest, strlen($this->digestPrefix));
+ }
+
+ if (password_verify($password, $digest)) {
+ return true;
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Plugin.php b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Plugin.php
new file mode 100644
index 0000000..47fbe20
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Auth/Plugin.php
@@ -0,0 +1,255 @@
+addBackend($authBackend);
+ }
+ }
+
+ /**
+ * Adds an authentication backend to the plugin.
+ */
+ public function addBackend(Backend\BackendInterface $authBackend)
+ {
+ $this->backends[] = $authBackend;
+ }
+
+ /**
+ * Initializes the plugin. This function is automatically called by the server.
+ */
+ public function initialize(Server $server)
+ {
+ $server->on('beforeMethod:*', [$this, 'beforeMethod'], 10);
+ }
+
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins
+ * using DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return 'auth';
+ }
+
+ /**
+ * Returns the currently logged-in principal.
+ *
+ * This will return a string such as:
+ *
+ * principals/username
+ * principals/users/username
+ *
+ * This method will return null if nobody is logged in.
+ *
+ * @return string|null
+ */
+ public function getCurrentPrincipal()
+ {
+ return $this->currentPrincipal;
+ }
+
+ /**
+ * This method is called before any HTTP method and forces users to be authenticated.
+ */
+ public function beforeMethod(RequestInterface $request, ResponseInterface $response)
+ {
+ if ($this->currentPrincipal) {
+ // We already have authentication information. This means that the
+ // event has already fired earlier, and is now likely fired for a
+ // sub-request.
+ //
+ // We don't want to authenticate users twice, so we simply don't do
+ // anything here. See Issue #700 for additional reasoning.
+ //
+ // This is not a perfect solution, but will be fixed once the
+ // "currently authenticated principal" is information that's not
+ // not associated with the plugin, but rather per-request.
+ //
+ // See issue #580 for more information about that.
+ return;
+ }
+
+ $authResult = $this->check($request, $response);
+
+ if ($authResult[0]) {
+ // Auth was successful
+ $this->currentPrincipal = $authResult[1];
+ $this->loginFailedReasons = null;
+
+ return;
+ }
+
+ // If we got here, it means that no authentication backend was
+ // successful in authenticating the user.
+ $this->currentPrincipal = null;
+ $this->loginFailedReasons = $authResult[1];
+
+ if ($this->autoRequireLogin) {
+ $this->challenge($request, $response);
+ throw new NotAuthenticated(implode(', ', $authResult[1]));
+ }
+ }
+
+ /**
+ * Checks authentication credentials, and logs the user in if possible.
+ *
+ * This method returns an array. The first item in the array is a boolean
+ * indicating if login was successful.
+ *
+ * If login was successful, the second item in the array will contain the
+ * current principal url/path of the logged in user.
+ *
+ * If login was not successful, the second item in the array will contain a
+ * an array with strings. The strings are a list of reasons why login was
+ * unsuccessful. For every auth backend there will be one reason, so usually
+ * there's just one.
+ *
+ * @return array
+ */
+ public function check(RequestInterface $request, ResponseInterface $response)
+ {
+ if (!$this->backends) {
+ throw new \Sabre\DAV\Exception('No authentication backends were configured on this server.');
+ }
+ $reasons = [];
+ foreach ($this->backends as $backend) {
+ $result = $backend->check(
+ $request,
+ $response
+ );
+
+ if (!is_array($result) || 2 !== count($result) || !is_bool($result[0]) || !is_string($result[1])) {
+ throw new \Sabre\DAV\Exception('The authentication backend did not return a correct value from the check() method.');
+ }
+
+ if ($result[0]) {
+ $this->currentPrincipal = $result[1];
+ // Exit early
+ return [true, $result[1]];
+ }
+ $reasons[] = $result[1];
+ }
+
+ return [false, $reasons];
+ }
+
+ /**
+ * This method sends authentication challenges to the user.
+ *
+ * This method will for example cause a HTTP Basic backend to set a
+ * WWW-Authorization header, indicating to the client that it should
+ * authenticate.
+ */
+ public function challenge(RequestInterface $request, ResponseInterface $response)
+ {
+ foreach ($this->backends as $backend) {
+ $backend->challenge($request, $response);
+ }
+ }
+
+ /**
+ * List of reasons why login failed for the last login operation.
+ *
+ * @var string[]|null
+ */
+ protected $loginFailedReasons;
+
+ /**
+ * Returns a list of reasons why login was unsuccessful.
+ *
+ * This method will return the login failed reasons for the last login
+ * operation. One for each auth backend.
+ *
+ * This method returns null if the last authentication attempt was
+ * successful, or if there was no authentication attempt yet.
+ *
+ * @return string[]|null
+ */
+ public function getLoginFailedReasons()
+ {
+ return $this->loginFailedReasons;
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ public function getPluginInfo()
+ {
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Generic authentication plugin',
+ 'link' => 'http://sabre.io/dav/authentication/',
+ ];
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php b/lib/composer/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php
new file mode 100644
index 0000000..5cda0b8
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php
@@ -0,0 +1,93 @@
+ 'image/jpeg',
+ 'gif' => 'image/gif',
+ 'png' => 'image/png',
+
+ // groupware
+ 'ics' => 'text/calendar',
+ 'vcf' => 'text/vcard',
+
+ // text
+ 'txt' => 'text/plain',
+ ];
+
+ /**
+ * Initializes the plugin.
+ */
+ public function initialize(DAV\Server $server)
+ {
+ // Using a relatively low priority (200) to allow other extensions
+ // to set the content-type first.
+ $server->on('propFind', [$this, 'propFind'], 200);
+ }
+
+ /**
+ * Our PROPFIND handler.
+ *
+ * Here we set a contenttype, if the node didn't already have one.
+ */
+ public function propFind(PropFind $propFind, INode $node)
+ {
+ $propFind->handle('{DAV:}getcontenttype', function () use ($propFind) {
+ list(, $fileName) = Uri\split($propFind->getPath());
+
+ return $this->getContentType($fileName);
+ });
+ }
+
+ /**
+ * Simple method to return the contenttype.
+ *
+ * @param string $fileName
+ *
+ * @return string
+ */
+ protected function getContentType($fileName)
+ {
+ if (null !== $fileName) {
+ // Just grabbing the extension
+ $extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1));
+ if (isset($this->extensionMap[$extension])) {
+ return $this->extensionMap[$extension];
+ }
+ }
+
+ return 'application/octet-stream';
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php b/lib/composer/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php
new file mode 100644
index 0000000..be5a284
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Browser/HtmlOutput.php
@@ -0,0 +1,34 @@
+baseUri = $baseUri;
+ $this->namespaceMap = $namespaceMap;
+ }
+
+ /**
+ * Generates a 'full' url based on a relative one.
+ *
+ * For relative urls, the base of the application is taken as the reference
+ * url, not the 'current url of the current request'.
+ *
+ * Absolute urls are left alone.
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public function fullUrl($path)
+ {
+ return Uri\resolve($this->baseUri, $path);
+ }
+
+ /**
+ * Escape string for HTML output.
+ *
+ * @param scalar $input
+ *
+ * @return string
+ */
+ public function h($input)
+ {
+ return htmlspecialchars((string) $input, ENT_COMPAT, 'UTF-8');
+ }
+
+ /**
+ * Generates a full -tag.
+ *
+ * Url is automatically expanded. If label is not specified, we re-use the
+ * url.
+ *
+ * @param string $url
+ * @param string $label
+ *
+ * @return string
+ */
+ public function link($url, $label = null)
+ {
+ $url = $this->h($this->fullUrl($url));
+
+ return ''.($label ? $this->h($label) : $url).'';
+ }
+
+ /**
+ * This method takes an xml element in clark-notation, and turns it into a
+ * shortened version with a prefix, if it was a known namespace.
+ *
+ * @param string $element
+ *
+ * @return string
+ */
+ public function xmlName($element)
+ {
+ list($ns, $localName) = XmlService::parseClarkNotation($element);
+ if (isset($this->namespaceMap[$ns])) {
+ $propName = $this->namespaceMap[$ns].':'.$localName;
+ } else {
+ $propName = $element;
+ }
+
+ return ''.$this->h($propName).'';
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php b/lib/composer/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php
new file mode 100644
index 0000000..0bbe70c
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Browser/MapGetToPropFind.php
@@ -0,0 +1,58 @@
+server = $server;
+ $this->server->on('method:GET', [$this, 'httpGet'], 90);
+ }
+
+ /**
+ * This method intercepts GET requests to non-files, and changes it into an HTTP PROPFIND request.
+ *
+ * @return bool
+ */
+ public function httpGet(RequestInterface $request, ResponseInterface $response)
+ {
+ $node = $this->server->tree->getNodeForPath($request->getPath());
+ if ($node instanceof DAV\IFile) {
+ return;
+ }
+
+ $subRequest = clone $request;
+ $subRequest->setMethod('PROPFIND');
+
+ $this->server->invokeMethod($subRequest, $response);
+
+ return false;
+ }
+}
diff --git a/lib/composer/vendor/sabre/dav/lib/DAV/Browser/Plugin.php b/lib/composer/vendor/sabre/dav/lib/DAV/Browser/Plugin.php
new file mode 100644
index 0000000..a8a6f43
--- /dev/null
+++ b/lib/composer/vendor/sabre/dav/lib/DAV/Browser/Plugin.php
@@ -0,0 +1,789 @@
+enablePost = $enablePost;
+ }
+
+ /**
+ * Initializes the plugin and subscribes to events.
+ */
+ public function initialize(DAV\Server $server)
+ {
+ $this->server = $server;
+ $this->server->on('method:GET', [$this, 'httpGetEarly'], 90);
+ $this->server->on('method:GET', [$this, 'httpGet'], 200);
+ $this->server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel'], 200);
+ if ($this->enablePost) {
+ $this->server->on('method:POST', [$this, 'httpPOST']);
+ }
+ }
+
+ /**
+ * This method intercepts GET requests that have ?sabreAction=info
+ * appended to the URL.
+ */
+ public function httpGetEarly(RequestInterface $request, ResponseInterface $response)
+ {
+ $params = $request->getQueryParameters();
+ if (isset($params['sabreAction']) && 'info' === $params['sabreAction']) {
+ return $this->httpGet($request, $response);
+ }
+ }
+
+ /**
+ * This method intercepts GET requests to collections and returns the html.
+ *
+ * @return bool
+ */
+ public function httpGet(RequestInterface $request, ResponseInterface $response)
+ {
+ // We're not using straight-up $_GET, because we want everything to be
+ // unit testable.
+ $getVars = $request->getQueryParameters();
+
+ // CSP headers
+ $response->setHeader('Content-Security-Policy', "default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';");
+
+ $sabreAction = isset($getVars['sabreAction']) ? $getVars['sabreAction'] : null;
+
+ switch ($sabreAction) {
+ case 'asset':
+ // Asset handling, such as images
+ $this->serveAsset(isset($getVars['assetName']) ? $getVars['assetName'] : null);
+
+ return false;
+ default:
+ case 'info':
+ try {
+ $this->server->tree->getNodeForPath($request->getPath());
+ } catch (DAV\Exception\NotFound $e) {
+ // We're simply stopping when the file isn't found to not interfere
+ // with other plugins.
+ return;
+ }
+
+ $response->setStatus(200);
+ $response->setHeader('Content-Type', 'text/html; charset=utf-8');
+
+ $response->setBody(
+ $this->generateDirectoryIndex($request->getPath())
+ );
+
+ return false;
+
+ case 'plugins':
+ $response->setStatus(200);
+ $response->setHeader('Content-Type', 'text/html; charset=utf-8');
+
+ $response->setBody(
+ $this->generatePluginListing()
+ );
+
+ return false;
+ }
+ }
+
+ /**
+ * Handles POST requests for tree operations.
+ *
+ * @return bool
+ */
+ public function httpPOST(RequestInterface $request, ResponseInterface $response)
+ {
+ $contentType = $request->getHeader('Content-Type');
+ if (!\is_string($contentType)) {
+ return;
+ }
+ list($contentType) = explode(';', $contentType);
+ if ('application/x-www-form-urlencoded' !== $contentType &&
+ 'multipart/form-data' !== $contentType) {
+ return;
+ }
+ $postVars = $request->getPostData();
+
+ if (!isset($postVars['sabreAction'])) {
+ return;
+ }
+
+ $uri = $request->getPath();
+
+ if ($this->server->emit('onBrowserPostAction', [$uri, $postVars['sabreAction'], $postVars])) {
+ switch ($postVars['sabreAction']) {
+ case 'mkcol':
+ if (isset($postVars['name']) && trim($postVars['name'])) {
+ // Using basename() because we won't allow slashes
+ list(, $folderName) = Uri\split(trim($postVars['name']));
+
+ if (isset($postVars['resourceType'])) {
+ $resourceType = explode(',', $postVars['resourceType']);
+ } else {
+ $resourceType = ['{DAV:}collection'];
+ }
+
+ $properties = [];
+ foreach ($postVars as $varName => $varValue) {
+ // Any _POST variable in clark notation is treated
+ // like a property.
+ if ('{' === $varName[0]) {
+ // PHP will convert any dots to underscores.
+ // This leaves us with no way to differentiate
+ // the two.
+ // Therefore we replace the string *DOT* with a
+ // real dot. * is not allowed in uris so we
+ // should be good.
+ $varName = str_replace('*DOT*', '.', $varName);
+ $properties[$varName] = $varValue;
+ }
+ }
+
+ $mkCol = new MkCol(
+ $resourceType,
+ $properties
+ );
+ $this->server->createCollection($uri.'/'.$folderName, $mkCol);
+ }
+ break;
+
+ // @codeCoverageIgnoreStart
+ case 'put':
+ if ($_FILES) {
+ $file = current($_FILES);
+ } else {
+ break;
+ }
+
+ list(, $newName) = Uri\split(trim($file['name']));
+ if (isset($postVars['name']) && trim($postVars['name'])) {
+ $newName = trim($postVars['name']);
+ }
+
+ // Making sure we only have a 'basename' component
+ list(, $newName) = Uri\split($newName);
+
+ if (is_uploaded_file($file['tmp_name'])) {
+ $this->server->createFile($uri.'/'.$newName, fopen($file['tmp_name'], 'r'));
+ }
+ break;
+ // @codeCoverageIgnoreEnd
+ }
+ }
+ $response->setHeader('Location', $request->getUrl());
+ $response->setStatus(302);
+
+ return false;
+ }
+
+ /**
+ * Escapes a string for html.
+ *
+ * @param string $value
+ *
+ * @return string
+ */
+ public function escapeHTML($value)
+ {
+ return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
+ }
+
+ /**
+ * Generates the html directory index for a given url.
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+ public function generateDirectoryIndex($path)
+ {
+ $html = $this->generateHeader($path ? $path : '/', $path);
+
+ $node = $this->server->tree->getNodeForPath($path);
+ if ($node instanceof DAV\ICollection) {
+ $html .= "