Completed
Branch develop (2e938f)
by
unknown
19:39
created
htdocs/includes/sabre/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -21,51 +21,51 @@
 block discarded – undo
21 21
  */
22 22
 class EmailAddressSet implements XmlSerializable
23 23
 {
24
-    /**
25
-     * emails.
26
-     *
27
-     * @var array
28
-     */
29
-    private $emails;
24
+	/**
25
+	 * emails.
26
+	 *
27
+	 * @var array
28
+	 */
29
+	private $emails;
30 30
 
31
-    /**
32
-     * __construct.
33
-     */
34
-    public function __construct(array $emails)
35
-    {
36
-        $this->emails = $emails;
37
-    }
31
+	/**
32
+	 * __construct.
33
+	 */
34
+	public function __construct(array $emails)
35
+	{
36
+		$this->emails = $emails;
37
+	}
38 38
 
39
-    /**
40
-     * Returns the email addresses.
41
-     *
42
-     * @return array
43
-     */
44
-    public function getValue()
45
-    {
46
-        return $this->emails;
47
-    }
39
+	/**
40
+	 * Returns the email addresses.
41
+	 *
42
+	 * @return array
43
+	 */
44
+	public function getValue()
45
+	{
46
+		return $this->emails;
47
+	}
48 48
 
49
-    /**
50
-     * The xmlSerialize method is called during xml writing.
51
-     *
52
-     * Use the $writer argument to write its own xml serialization.
53
-     *
54
-     * An important note: do _not_ create a parent element. Any element
55
-     * implementing XmlSerializable should only ever write what's considered
56
-     * its 'inner xml'.
57
-     *
58
-     * The parent of the current element is responsible for writing a
59
-     * containing element.
60
-     *
61
-     * This allows serializers to be re-used for different element names.
62
-     *
63
-     * If you are opening new elements, you must also close them again.
64
-     */
65
-    public function xmlSerialize(Writer $writer)
66
-    {
67
-        foreach ($this->emails as $email) {
68
-            $writer->writeElement('{http://calendarserver.org/ns/}email-address', $email);
69
-        }
70
-    }
49
+	/**
50
+	 * The xmlSerialize method is called during xml writing.
51
+	 *
52
+	 * Use the $writer argument to write its own xml serialization.
53
+	 *
54
+	 * An important note: do _not_ create a parent element. Any element
55
+	 * implementing XmlSerializable should only ever write what's considered
56
+	 * its 'inner xml'.
57
+	 *
58
+	 * The parent of the current element is responsible for writing a
59
+	 * containing element.
60
+	 *
61
+	 * This allows serializers to be re-used for different element names.
62
+	 *
63
+	 * If you are opening new elements, you must also close them again.
64
+	 */
65
+	public function xmlSerialize(Writer $writer)
66
+	{
67
+		foreach ($this->emails as $email) {
68
+			$writer->writeElement('{http://calendarserver.org/ns/}email-address', $email);
69
+		}
70
+	}
71 71
 }
Please login to merge, or discard this patch.
includes/sabre/sabre/dav/lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -28,97 +28,97 @@
 block discarded – undo
28 28
  */
29 29
 class ScheduleCalendarTransp implements Element
30 30
 {
31
-    const TRANSPARENT = 'transparent';
32
-    const OPAQUE = 'opaque';
31
+	const TRANSPARENT = 'transparent';
32
+	const OPAQUE = 'opaque';
33 33
 
34
-    /**
35
-     * value.
36
-     *
37
-     * @var string
38
-     */
39
-    protected $value;
34
+	/**
35
+	 * value.
36
+	 *
37
+	 * @var string
38
+	 */
39
+	protected $value;
40 40
 
41
-    /**
42
-     * Creates the property.
43
-     *
44
-     * @param string $value
45
-     */
46
-    public function __construct($value)
47
-    {
48
-        if (self::TRANSPARENT !== $value && self::OPAQUE !== $value) {
49
-            throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"');
50
-        }
51
-        $this->value = $value;
52
-    }
41
+	/**
42
+	 * Creates the property.
43
+	 *
44
+	 * @param string $value
45
+	 */
46
+	public function __construct($value)
47
+	{
48
+		if (self::TRANSPARENT !== $value && self::OPAQUE !== $value) {
49
+			throw new \InvalidArgumentException('The value must either be specified as "transparent" or "opaque"');
50
+		}
51
+		$this->value = $value;
52
+	}
53 53
 
54
-    /**
55
-     * Returns the current value.
56
-     *
57
-     * @return string
58
-     */
59
-    public function getValue()
60
-    {
61
-        return $this->value;
62
-    }
54
+	/**
55
+	 * Returns the current value.
56
+	 *
57
+	 * @return string
58
+	 */
59
+	public function getValue()
60
+	{
61
+		return $this->value;
62
+	}
63 63
 
64
-    /**
65
-     * The xmlSerialize method is called during xml writing.
66
-     *
67
-     * Use the $writer argument to write its own xml serialization.
68
-     *
69
-     * An important note: do _not_ create a parent element. Any element
70
-     * implementing XmlSerializable should only ever write what's considered
71
-     * its 'inner xml'.
72
-     *
73
-     * The parent of the current element is responsible for writing a
74
-     * containing element.
75
-     *
76
-     * This allows serializers to be re-used for different element names.
77
-     *
78
-     * If you are opening new elements, you must also close them again.
79
-     */
80
-    public function xmlSerialize(Writer $writer)
81
-    {
82
-        switch ($this->value) {
83
-            case self::TRANSPARENT:
84
-                $writer->writeElement('{'.Plugin::NS_CALDAV.'}transparent');
85
-                break;
86
-            case self::OPAQUE:
87
-                $writer->writeElement('{'.Plugin::NS_CALDAV.'}opaque');
88
-                break;
89
-        }
90
-    }
64
+	/**
65
+	 * The xmlSerialize method is called during xml writing.
66
+	 *
67
+	 * Use the $writer argument to write its own xml serialization.
68
+	 *
69
+	 * An important note: do _not_ create a parent element. Any element
70
+	 * implementing XmlSerializable should only ever write what's considered
71
+	 * its 'inner xml'.
72
+	 *
73
+	 * The parent of the current element is responsible for writing a
74
+	 * containing element.
75
+	 *
76
+	 * This allows serializers to be re-used for different element names.
77
+	 *
78
+	 * If you are opening new elements, you must also close them again.
79
+	 */
80
+	public function xmlSerialize(Writer $writer)
81
+	{
82
+		switch ($this->value) {
83
+			case self::TRANSPARENT:
84
+				$writer->writeElement('{'.Plugin::NS_CALDAV.'}transparent');
85
+				break;
86
+			case self::OPAQUE:
87
+				$writer->writeElement('{'.Plugin::NS_CALDAV.'}opaque');
88
+				break;
89
+		}
90
+	}
91 91
 
92
-    /**
93
-     * The deserialize method is called during xml parsing.
94
-     *
95
-     * This method is called statically, this is because in theory this method
96
-     * may be used as a type of constructor, or factory method.
97
-     *
98
-     * Often you want to return an instance of the current class, but you are
99
-     * free to return other data as well.
100
-     *
101
-     * You are responsible for advancing the reader to the next element. Not
102
-     * doing anything will result in a never-ending loop.
103
-     *
104
-     * If you just want to skip parsing for this element altogether, you can
105
-     * just call $reader->next();
106
-     *
107
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
108
-     * the next element.
109
-     *
110
-     * @return mixed
111
-     */
112
-    public static function xmlDeserialize(Reader $reader)
113
-    {
114
-        $elems = Deserializer\enum($reader, Plugin::NS_CALDAV);
92
+	/**
93
+	 * The deserialize method is called during xml parsing.
94
+	 *
95
+	 * This method is called statically, this is because in theory this method
96
+	 * may be used as a type of constructor, or factory method.
97
+	 *
98
+	 * Often you want to return an instance of the current class, but you are
99
+	 * free to return other data as well.
100
+	 *
101
+	 * You are responsible for advancing the reader to the next element. Not
102
+	 * doing anything will result in a never-ending loop.
103
+	 *
104
+	 * If you just want to skip parsing for this element altogether, you can
105
+	 * just call $reader->next();
106
+	 *
107
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
108
+	 * the next element.
109
+	 *
110
+	 * @return mixed
111
+	 */
112
+	public static function xmlDeserialize(Reader $reader)
113
+	{
114
+		$elems = Deserializer\enum($reader, Plugin::NS_CALDAV);
115 115
 
116
-        if (in_array('transparent', $elems)) {
117
-            $value = self::TRANSPARENT;
118
-        } else {
119
-            $value = self::OPAQUE;
120
-        }
116
+		if (in_array('transparent', $elems)) {
117
+			$value = self::TRANSPARENT;
118
+		} else {
119
+			$value = self::OPAQUE;
120
+		}
121 121
 
122
-        return new self($value);
123
-    }
122
+		return new self($value);
123
+	}
124 124
 }
Please login to merge, or discard this patch.
includes/sabre/sabre/dav/lib/CalDAV/Xml/Property/SupportedCollationSet.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -23,32 +23,32 @@
 block discarded – undo
23 23
  */
24 24
 class SupportedCollationSet implements XmlSerializable
25 25
 {
26
-    /**
27
-     * The xmlSerialize method is called during xml writing.
28
-     *
29
-     * Use the $writer argument to write its own xml serialization.
30
-     *
31
-     * An important note: do _not_ create a parent element. Any element
32
-     * implementing XmlSerializable should only ever write what's considered
33
-     * its 'inner xml'.
34
-     *
35
-     * The parent of the current element is responsible for writing a
36
-     * containing element.
37
-     *
38
-     * This allows serializers to be re-used for different element names.
39
-     *
40
-     * If you are opening new elements, you must also close them again.
41
-     */
42
-    public function xmlSerialize(Writer $writer)
43
-    {
44
-        $collations = [
45
-            'i;ascii-casemap',
46
-            'i;octet',
47
-            'i;unicode-casemap',
48
-        ];
26
+	/**
27
+	 * The xmlSerialize method is called during xml writing.
28
+	 *
29
+	 * Use the $writer argument to write its own xml serialization.
30
+	 *
31
+	 * An important note: do _not_ create a parent element. Any element
32
+	 * implementing XmlSerializable should only ever write what's considered
33
+	 * its 'inner xml'.
34
+	 *
35
+	 * The parent of the current element is responsible for writing a
36
+	 * containing element.
37
+	 *
38
+	 * This allows serializers to be re-used for different element names.
39
+	 *
40
+	 * If you are opening new elements, you must also close them again.
41
+	 */
42
+	public function xmlSerialize(Writer $writer)
43
+	{
44
+		$collations = [
45
+			'i;ascii-casemap',
46
+			'i;octet',
47
+			'i;unicode-casemap',
48
+		];
49 49
 
50
-        foreach ($collations as $collation) {
51
-            $writer->writeElement('{'.Plugin::NS_CALDAV.'}supported-collation', $collation);
52
-        }
53
-    }
50
+		foreach ($collations as $collation) {
51
+			$writer->writeElement('{'.Plugin::NS_CALDAV.'}supported-collation', $collation);
52
+		}
53
+	}
54 54
 }
Please login to merge, or discard this patch.
includes/sabre/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarData.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,34 +24,34 @@
 block discarded – undo
24 24
  */
25 25
 class SupportedCalendarData implements XmlSerializable
26 26
 {
27
-    /**
28
-     * The xmlSerialize method is called during xml writing.
29
-     *
30
-     * Use the $writer argument to write its own xml serialization.
31
-     *
32
-     * An important note: do _not_ create a parent element. Any element
33
-     * implementing XmlSerializable should only ever write what's considered
34
-     * its 'inner xml'.
35
-     *
36
-     * The parent of the current element is responsible for writing a
37
-     * containing element.
38
-     *
39
-     * This allows serializers to be re-used for different element names.
40
-     *
41
-     * If you are opening new elements, you must also close them again.
42
-     */
43
-    public function xmlSerialize(Writer $writer)
44
-    {
45
-        $writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data');
46
-        $writer->writeAttributes([
47
-            'content-type' => 'text/calendar',
48
-            'version' => '2.0',
49
-        ]);
50
-        $writer->endElement(); // calendar-data
51
-        $writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data');
52
-        $writer->writeAttributes([
53
-            'content-type' => 'application/calendar+json',
54
-        ]);
55
-        $writer->endElement(); // calendar-data
56
-    }
27
+	/**
28
+	 * The xmlSerialize method is called during xml writing.
29
+	 *
30
+	 * Use the $writer argument to write its own xml serialization.
31
+	 *
32
+	 * An important note: do _not_ create a parent element. Any element
33
+	 * implementing XmlSerializable should only ever write what's considered
34
+	 * its 'inner xml'.
35
+	 *
36
+	 * The parent of the current element is responsible for writing a
37
+	 * containing element.
38
+	 *
39
+	 * This allows serializers to be re-used for different element names.
40
+	 *
41
+	 * If you are opening new elements, you must also close them again.
42
+	 */
43
+	public function xmlSerialize(Writer $writer)
44
+	{
45
+		$writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data');
46
+		$writer->writeAttributes([
47
+			'content-type' => 'text/calendar',
48
+			'version' => '2.0',
49
+		]);
50
+		$writer->endElement(); // calendar-data
51
+		$writer->startElement('{'.Plugin::NS_CALDAV.'}calendar-data');
52
+		$writer->writeAttributes([
53
+			'content-type' => 'application/calendar+json',
54
+		]);
55
+		$writer->endElement(); // calendar-data
56
+	}
57 57
 }
Please login to merge, or discard this patch.
sabre/sabre/dav/lib/CalDAV/Xml/Property/SupportedCalendarComponentSet.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -25,94 +25,94 @@
 block discarded – undo
25 25
  */
26 26
 class SupportedCalendarComponentSet implements Element
27 27
 {
28
-    /**
29
-     * List of supported components.
30
-     *
31
-     * This array will contain values such as VEVENT, VTODO and VJOURNAL.
32
-     *
33
-     * @var array
34
-     */
35
-    protected $components = [];
28
+	/**
29
+	 * List of supported components.
30
+	 *
31
+	 * This array will contain values such as VEVENT, VTODO and VJOURNAL.
32
+	 *
33
+	 * @var array
34
+	 */
35
+	protected $components = [];
36 36
 
37
-    /**
38
-     * Creates the property.
39
-     */
40
-    public function __construct(array $components)
41
-    {
42
-        $this->components = $components;
43
-    }
37
+	/**
38
+	 * Creates the property.
39
+	 */
40
+	public function __construct(array $components)
41
+	{
42
+		$this->components = $components;
43
+	}
44 44
 
45
-    /**
46
-     * Returns the list of supported components.
47
-     *
48
-     * @return array
49
-     */
50
-    public function getValue()
51
-    {
52
-        return $this->components;
53
-    }
45
+	/**
46
+	 * Returns the list of supported components.
47
+	 *
48
+	 * @return array
49
+	 */
50
+	public function getValue()
51
+	{
52
+		return $this->components;
53
+	}
54 54
 
55
-    /**
56
-     * The xmlSerialize method is called during xml writing.
57
-     *
58
-     * Use the $writer argument to write its own xml serialization.
59
-     *
60
-     * An important note: do _not_ create a parent element. Any element
61
-     * implementing XmlSerializable should only ever write what's considered
62
-     * its 'inner xml'.
63
-     *
64
-     * The parent of the current element is responsible for writing a
65
-     * containing element.
66
-     *
67
-     * This allows serializers to be re-used for different element names.
68
-     *
69
-     * If you are opening new elements, you must also close them again.
70
-     */
71
-    public function xmlSerialize(Writer $writer)
72
-    {
73
-        foreach ($this->components as $component) {
74
-            $writer->startElement('{'.Plugin::NS_CALDAV.'}comp');
75
-            $writer->writeAttributes(['name' => $component]);
76
-            $writer->endElement();
77
-        }
78
-    }
55
+	/**
56
+	 * The xmlSerialize method is called during xml writing.
57
+	 *
58
+	 * Use the $writer argument to write its own xml serialization.
59
+	 *
60
+	 * An important note: do _not_ create a parent element. Any element
61
+	 * implementing XmlSerializable should only ever write what's considered
62
+	 * its 'inner xml'.
63
+	 *
64
+	 * The parent of the current element is responsible for writing a
65
+	 * containing element.
66
+	 *
67
+	 * This allows serializers to be re-used for different element names.
68
+	 *
69
+	 * If you are opening new elements, you must also close them again.
70
+	 */
71
+	public function xmlSerialize(Writer $writer)
72
+	{
73
+		foreach ($this->components as $component) {
74
+			$writer->startElement('{'.Plugin::NS_CALDAV.'}comp');
75
+			$writer->writeAttributes(['name' => $component]);
76
+			$writer->endElement();
77
+		}
78
+	}
79 79
 
80
-    /**
81
-     * The deserialize method is called during xml parsing.
82
-     *
83
-     * This method is called statically, this is because in theory this method
84
-     * may be used as a type of constructor, or factory method.
85
-     *
86
-     * Often you want to return an instance of the current class, but you are
87
-     * free to return other data as well.
88
-     *
89
-     * You are responsible for advancing the reader to the next element. Not
90
-     * doing anything will result in a never-ending loop.
91
-     *
92
-     * If you just want to skip parsing for this element altogether, you can
93
-     * just call $reader->next();
94
-     *
95
-     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
96
-     * the next element.
97
-     *
98
-     * @return mixed
99
-     */
100
-    public static function xmlDeserialize(Reader $reader)
101
-    {
102
-        $elems = $reader->parseInnerTree();
80
+	/**
81
+	 * The deserialize method is called during xml parsing.
82
+	 *
83
+	 * This method is called statically, this is because in theory this method
84
+	 * may be used as a type of constructor, or factory method.
85
+	 *
86
+	 * Often you want to return an instance of the current class, but you are
87
+	 * free to return other data as well.
88
+	 *
89
+	 * You are responsible for advancing the reader to the next element. Not
90
+	 * doing anything will result in a never-ending loop.
91
+	 *
92
+	 * If you just want to skip parsing for this element altogether, you can
93
+	 * just call $reader->next();
94
+	 *
95
+	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
96
+	 * the next element.
97
+	 *
98
+	 * @return mixed
99
+	 */
100
+	public static function xmlDeserialize(Reader $reader)
101
+	{
102
+		$elems = $reader->parseInnerTree();
103 103
 
104
-        $components = [];
104
+		$components = [];
105 105
 
106
-        foreach ((array) $elems as $elem) {
107
-            if ($elem['name'] === '{'.Plugin::NS_CALDAV.'}comp') {
108
-                $components[] = $elem['attributes']['name'];
109
-            }
110
-        }
106
+		foreach ((array) $elems as $elem) {
107
+			if ($elem['name'] === '{'.Plugin::NS_CALDAV.'}comp') {
108
+				$components[] = $elem['attributes']['name'];
109
+			}
110
+		}
111 111
 
112
-        if (!$components) {
113
-            throw new ParseException('supported-calendar-component-set must have at least one CALDAV:comp element');
114
-        }
112
+		if (!$components) {
113
+			throw new ParseException('supported-calendar-component-set must have at least one CALDAV:comp element');
114
+		}
115 115
 
116
-        return new self($components);
117
-    }
116
+		return new self($components);
117
+	}
118 118
 }
Please login to merge, or discard this patch.
includes/sabre/sabre/dav/lib/CalDAV/Xml/Property/AllowedSharingModes.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -27,55 +27,55 @@
 block discarded – undo
27 27
  */
28 28
 class AllowedSharingModes implements XmlSerializable
29 29
 {
30
-    /**
31
-     * Whether or not a calendar can be shared with another user.
32
-     *
33
-     * @var bool
34
-     */
35
-    protected $canBeShared;
30
+	/**
31
+	 * Whether or not a calendar can be shared with another user.
32
+	 *
33
+	 * @var bool
34
+	 */
35
+	protected $canBeShared;
36 36
 
37
-    /**
38
-     * Whether or not the calendar can be placed on a public url.
39
-     *
40
-     * @var bool
41
-     */
42
-    protected $canBePublished;
37
+	/**
38
+	 * Whether or not the calendar can be placed on a public url.
39
+	 *
40
+	 * @var bool
41
+	 */
42
+	protected $canBePublished;
43 43
 
44
-    /**
45
-     * Constructor.
46
-     *
47
-     * @param bool $canBeShared
48
-     * @param bool $canBePublished
49
-     */
50
-    public function __construct($canBeShared, $canBePublished)
51
-    {
52
-        $this->canBeShared = $canBeShared;
53
-        $this->canBePublished = $canBePublished;
54
-    }
44
+	/**
45
+	 * Constructor.
46
+	 *
47
+	 * @param bool $canBeShared
48
+	 * @param bool $canBePublished
49
+	 */
50
+	public function __construct($canBeShared, $canBePublished)
51
+	{
52
+		$this->canBeShared = $canBeShared;
53
+		$this->canBePublished = $canBePublished;
54
+	}
55 55
 
56
-    /**
57
-     * The xmlSerialize method is called during xml writing.
58
-     *
59
-     * Use the $writer argument to write its own xml serialization.
60
-     *
61
-     * An important note: do _not_ create a parent element. Any element
62
-     * implementing XmlSerializable should only ever write what's considered
63
-     * its 'inner xml'.
64
-     *
65
-     * The parent of the current element is responsible for writing a
66
-     * containing element.
67
-     *
68
-     * This allows serializers to be re-used for different element names.
69
-     *
70
-     * If you are opening new elements, you must also close them again.
71
-     */
72
-    public function xmlSerialize(Writer $writer)
73
-    {
74
-        if ($this->canBeShared) {
75
-            $writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-shared');
76
-        }
77
-        if ($this->canBePublished) {
78
-            $writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-published');
79
-        }
80
-    }
56
+	/**
57
+	 * The xmlSerialize method is called during xml writing.
58
+	 *
59
+	 * Use the $writer argument to write its own xml serialization.
60
+	 *
61
+	 * An important note: do _not_ create a parent element. Any element
62
+	 * implementing XmlSerializable should only ever write what's considered
63
+	 * its 'inner xml'.
64
+	 *
65
+	 * The parent of the current element is responsible for writing a
66
+	 * containing element.
67
+	 *
68
+	 * This allows serializers to be re-used for different element names.
69
+	 *
70
+	 * If you are opening new elements, you must also close them again.
71
+	 */
72
+	public function xmlSerialize(Writer $writer)
73
+	{
74
+		if ($this->canBeShared) {
75
+			$writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-shared');
76
+		}
77
+		if ($this->canBePublished) {
78
+			$writer->writeElement('{'.Plugin::NS_CALENDARSERVER.'}can-be-published');
79
+		}
80
+	}
81 81
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/dav/lib/CalDAV/SharedCalendar.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -15,205 +15,205 @@
 block discarded – undo
15 15
  */
16 16
 class SharedCalendar extends Calendar implements ISharedCalendar
17 17
 {
18
-    /**
19
-     * Returns the 'access level' for the instance of this shared resource.
20
-     *
21
-     * The value should be one of the Sabre\DAV\Sharing\Plugin::ACCESS_
22
-     * constants.
23
-     *
24
-     * @return int
25
-     */
26
-    public function getShareAccess()
27
-    {
28
-        return isset($this->calendarInfo['share-access']) ? $this->calendarInfo['share-access'] : SPlugin::ACCESS_NOTSHARED;
29
-    }
18
+	/**
19
+	 * Returns the 'access level' for the instance of this shared resource.
20
+	 *
21
+	 * The value should be one of the Sabre\DAV\Sharing\Plugin::ACCESS_
22
+	 * constants.
23
+	 *
24
+	 * @return int
25
+	 */
26
+	public function getShareAccess()
27
+	{
28
+		return isset($this->calendarInfo['share-access']) ? $this->calendarInfo['share-access'] : SPlugin::ACCESS_NOTSHARED;
29
+	}
30 30
 
31
-    /**
32
-     * This function must return a URI that uniquely identifies the shared
33
-     * resource. This URI should be identical across instances, and is
34
-     * also used in several other XML bodies to connect invites to
35
-     * resources.
36
-     *
37
-     * This may simply be a relative reference to the original shared instance,
38
-     * but it could also be a urn. As long as it's a valid URI and unique.
39
-     *
40
-     * @return string
41
-     */
42
-    public function getShareResourceUri()
43
-    {
44
-        return $this->calendarInfo['share-resource-uri'];
45
-    }
31
+	/**
32
+	 * This function must return a URI that uniquely identifies the shared
33
+	 * resource. This URI should be identical across instances, and is
34
+	 * also used in several other XML bodies to connect invites to
35
+	 * resources.
36
+	 *
37
+	 * This may simply be a relative reference to the original shared instance,
38
+	 * but it could also be a urn. As long as it's a valid URI and unique.
39
+	 *
40
+	 * @return string
41
+	 */
42
+	public function getShareResourceUri()
43
+	{
44
+		return $this->calendarInfo['share-resource-uri'];
45
+	}
46 46
 
47
-    /**
48
-     * Updates the list of sharees.
49
-     *
50
-     * Every item must be a Sharee object.
51
-     *
52
-     * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees
53
-     */
54
-    public function updateInvites(array $sharees)
55
-    {
56
-        $this->caldavBackend->updateInvites($this->calendarInfo['id'], $sharees);
57
-    }
47
+	/**
48
+	 * Updates the list of sharees.
49
+	 *
50
+	 * Every item must be a Sharee object.
51
+	 *
52
+	 * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees
53
+	 */
54
+	public function updateInvites(array $sharees)
55
+	{
56
+		$this->caldavBackend->updateInvites($this->calendarInfo['id'], $sharees);
57
+	}
58 58
 
59
-    /**
60
-     * Returns the list of people whom this resource is shared with.
61
-     *
62
-     * Every item in the returned array must be a Sharee object with
63
-     * at least the following properties set:
64
-     *
65
-     * * $href
66
-     * * $shareAccess
67
-     * * $inviteStatus
68
-     *
69
-     * and optionally:
70
-     *
71
-     * * $properties
72
-     *
73
-     * @return \Sabre\DAV\Xml\Element\Sharee[]
74
-     */
75
-    public function getInvites()
76
-    {
77
-        return $this->caldavBackend->getInvites($this->calendarInfo['id']);
78
-    }
59
+	/**
60
+	 * Returns the list of people whom this resource is shared with.
61
+	 *
62
+	 * Every item in the returned array must be a Sharee object with
63
+	 * at least the following properties set:
64
+	 *
65
+	 * * $href
66
+	 * * $shareAccess
67
+	 * * $inviteStatus
68
+	 *
69
+	 * and optionally:
70
+	 *
71
+	 * * $properties
72
+	 *
73
+	 * @return \Sabre\DAV\Xml\Element\Sharee[]
74
+	 */
75
+	public function getInvites()
76
+	{
77
+		return $this->caldavBackend->getInvites($this->calendarInfo['id']);
78
+	}
79 79
 
80
-    /**
81
-     * Marks this calendar as published.
82
-     *
83
-     * Publishing a calendar should automatically create a read-only, public,
84
-     * subscribable calendar.
85
-     *
86
-     * @param bool $value
87
-     */
88
-    public function setPublishStatus($value)
89
-    {
90
-        $this->caldavBackend->setPublishStatus($this->calendarInfo['id'], $value);
91
-    }
80
+	/**
81
+	 * Marks this calendar as published.
82
+	 *
83
+	 * Publishing a calendar should automatically create a read-only, public,
84
+	 * subscribable calendar.
85
+	 *
86
+	 * @param bool $value
87
+	 */
88
+	public function setPublishStatus($value)
89
+	{
90
+		$this->caldavBackend->setPublishStatus($this->calendarInfo['id'], $value);
91
+	}
92 92
 
93
-    /**
94
-     * Returns a list of ACE's for this node.
95
-     *
96
-     * Each ACE has the following properties:
97
-     *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
98
-     *     currently the only supported privileges
99
-     *   * 'principal', a url to the principal who owns the node
100
-     *   * 'protected' (optional), indicating that this ACE is not allowed to
101
-     *      be updated.
102
-     *
103
-     * @return array
104
-     */
105
-    public function getACL()
106
-    {
107
-        $acl = [];
93
+	/**
94
+	 * Returns a list of ACE's for this node.
95
+	 *
96
+	 * Each ACE has the following properties:
97
+	 *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
98
+	 *     currently the only supported privileges
99
+	 *   * 'principal', a url to the principal who owns the node
100
+	 *   * 'protected' (optional), indicating that this ACE is not allowed to
101
+	 *      be updated.
102
+	 *
103
+	 * @return array
104
+	 */
105
+	public function getACL()
106
+	{
107
+		$acl = [];
108 108
 
109
-        switch ($this->getShareAccess()) {
110
-            case SPlugin::ACCESS_NOTSHARED:
111
-            case SPlugin::ACCESS_SHAREDOWNER:
112
-                $acl[] = [
113
-                    'privilege' => '{DAV:}share',
114
-                    'principal' => $this->calendarInfo['principaluri'],
115
-                    'protected' => true,
116
-                ];
117
-                $acl[] = [
118
-                    'privilege' => '{DAV:}share',
119
-                    'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
120
-                    'protected' => true,
121
-                ];
122
-                // no break intentional!
123
-            case SPlugin::ACCESS_READWRITE:
124
-                $acl[] = [
125
-                    'privilege' => '{DAV:}write',
126
-                    'principal' => $this->calendarInfo['principaluri'],
127
-                    'protected' => true,
128
-                ];
129
-                $acl[] = [
130
-                    'privilege' => '{DAV:}write',
131
-                    'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
132
-                    'protected' => true,
133
-                ];
134
-                // no break intentional!
135
-            case SPlugin::ACCESS_READ:
136
-                $acl[] = [
137
-                    'privilege' => '{DAV:}write-properties',
138
-                    'principal' => $this->calendarInfo['principaluri'],
139
-                    'protected' => true,
140
-                ];
141
-                $acl[] = [
142
-                    'privilege' => '{DAV:}write-properties',
143
-                    'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
144
-                    'protected' => true,
145
-                ];
146
-                $acl[] = [
147
-                    'privilege' => '{DAV:}read',
148
-                    'principal' => $this->calendarInfo['principaluri'],
149
-                    'protected' => true,
150
-                ];
151
-                $acl[] = [
152
-                    'privilege' => '{DAV:}read',
153
-                    'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
154
-                    'protected' => true,
155
-                ];
156
-                $acl[] = [
157
-                    'privilege' => '{DAV:}read',
158
-                    'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
159
-                    'protected' => true,
160
-                ];
161
-                $acl[] = [
162
-                    'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy',
163
-                    'principal' => '{DAV:}authenticated',
164
-                    'protected' => true,
165
-                ];
166
-                break;
167
-        }
109
+		switch ($this->getShareAccess()) {
110
+			case SPlugin::ACCESS_NOTSHARED:
111
+			case SPlugin::ACCESS_SHAREDOWNER:
112
+				$acl[] = [
113
+					'privilege' => '{DAV:}share',
114
+					'principal' => $this->calendarInfo['principaluri'],
115
+					'protected' => true,
116
+				];
117
+				$acl[] = [
118
+					'privilege' => '{DAV:}share',
119
+					'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
120
+					'protected' => true,
121
+				];
122
+				// no break intentional!
123
+			case SPlugin::ACCESS_READWRITE:
124
+				$acl[] = [
125
+					'privilege' => '{DAV:}write',
126
+					'principal' => $this->calendarInfo['principaluri'],
127
+					'protected' => true,
128
+				];
129
+				$acl[] = [
130
+					'privilege' => '{DAV:}write',
131
+					'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
132
+					'protected' => true,
133
+				];
134
+				// no break intentional!
135
+			case SPlugin::ACCESS_READ:
136
+				$acl[] = [
137
+					'privilege' => '{DAV:}write-properties',
138
+					'principal' => $this->calendarInfo['principaluri'],
139
+					'protected' => true,
140
+				];
141
+				$acl[] = [
142
+					'privilege' => '{DAV:}write-properties',
143
+					'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
144
+					'protected' => true,
145
+				];
146
+				$acl[] = [
147
+					'privilege' => '{DAV:}read',
148
+					'principal' => $this->calendarInfo['principaluri'],
149
+					'protected' => true,
150
+				];
151
+				$acl[] = [
152
+					'privilege' => '{DAV:}read',
153
+					'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
154
+					'protected' => true,
155
+				];
156
+				$acl[] = [
157
+					'privilege' => '{DAV:}read',
158
+					'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
159
+					'protected' => true,
160
+				];
161
+				$acl[] = [
162
+					'privilege' => '{'.Plugin::NS_CALDAV.'}read-free-busy',
163
+					'principal' => '{DAV:}authenticated',
164
+					'protected' => true,
165
+				];
166
+				break;
167
+		}
168 168
 
169
-        return $acl;
170
-    }
169
+		return $acl;
170
+	}
171 171
 
172
-    /**
173
-     * This method returns the ACL's for calendar objects in this calendar.
174
-     * The result of this method automatically gets passed to the
175
-     * calendar-object nodes in the calendar.
176
-     *
177
-     * @return array
178
-     */
179
-    public function getChildACL()
180
-    {
181
-        $acl = [];
172
+	/**
173
+	 * This method returns the ACL's for calendar objects in this calendar.
174
+	 * The result of this method automatically gets passed to the
175
+	 * calendar-object nodes in the calendar.
176
+	 *
177
+	 * @return array
178
+	 */
179
+	public function getChildACL()
180
+	{
181
+		$acl = [];
182 182
 
183
-        switch ($this->getShareAccess()) {
184
-            case SPlugin::ACCESS_NOTSHARED:
185
-            case SPlugin::ACCESS_SHAREDOWNER:
186
-            case SPlugin::ACCESS_READWRITE:
187
-                $acl[] = [
188
-                    'privilege' => '{DAV:}write',
189
-                    'principal' => $this->calendarInfo['principaluri'],
190
-                    'protected' => true,
191
-                ];
192
-                $acl[] = [
193
-                    'privilege' => '{DAV:}write',
194
-                    'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
195
-                    'protected' => true,
196
-                ];
197
-                // no break intentional
198
-            case SPlugin::ACCESS_READ:
199
-                $acl[] = [
200
-                    'privilege' => '{DAV:}read',
201
-                    'principal' => $this->calendarInfo['principaluri'],
202
-                    'protected' => true,
203
-                ];
204
-                $acl[] = [
205
-                    'privilege' => '{DAV:}read',
206
-                    'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
207
-                    'protected' => true,
208
-                ];
209
-                $acl[] = [
210
-                    'privilege' => '{DAV:}read',
211
-                    'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
212
-                    'protected' => true,
213
-                ];
214
-                break;
215
-        }
183
+		switch ($this->getShareAccess()) {
184
+			case SPlugin::ACCESS_NOTSHARED:
185
+			case SPlugin::ACCESS_SHAREDOWNER:
186
+			case SPlugin::ACCESS_READWRITE:
187
+				$acl[] = [
188
+					'privilege' => '{DAV:}write',
189
+					'principal' => $this->calendarInfo['principaluri'],
190
+					'protected' => true,
191
+				];
192
+				$acl[] = [
193
+					'privilege' => '{DAV:}write',
194
+					'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
195
+					'protected' => true,
196
+				];
197
+				// no break intentional
198
+			case SPlugin::ACCESS_READ:
199
+				$acl[] = [
200
+					'privilege' => '{DAV:}read',
201
+					'principal' => $this->calendarInfo['principaluri'],
202
+					'protected' => true,
203
+				];
204
+				$acl[] = [
205
+					'privilege' => '{DAV:}read',
206
+					'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-write',
207
+					'protected' => true,
208
+				];
209
+				$acl[] = [
210
+					'privilege' => '{DAV:}read',
211
+					'principal' => $this->calendarInfo['principaluri'].'/calendar-proxy-read',
212
+					'protected' => true,
213
+				];
214
+				break;
215
+		}
216 216
 
217
-        return $acl;
218
-    }
217
+		return $acl;
218
+	}
219 219
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/dav/lib/CalDAV/CalendarQueryValidator.php 1 patch
Indentation   +329 added lines, -329 removed lines patch added patch discarded remove patch
@@ -22,333 +22,333 @@
 block discarded – undo
22 22
  */
23 23
 class CalendarQueryValidator
24 24
 {
25
-    /**
26
-     * Verify if a list of filters applies to the calendar data object.
27
-     *
28
-     * The list of filters must be formatted as parsed by \Sabre\CalDAV\CalendarQueryParser
29
-     *
30
-     * @return bool
31
-     */
32
-    public function validate(VObject\Component\VCalendar $vObject, array $filters)
33
-    {
34
-        // The top level object is always a component filter.
35
-        // We'll parse it manually, as it's pretty simple.
36
-        if ($vObject->name !== $filters['name']) {
37
-            return false;
38
-        }
39
-
40
-        return
41
-            $this->validateCompFilters($vObject, $filters['comp-filters']) &&
42
-            $this->validatePropFilters($vObject, $filters['prop-filters']);
43
-    }
44
-
45
-    /**
46
-     * This method checks the validity of comp-filters.
47
-     *
48
-     * A list of comp-filters needs to be specified. Also the parent of the
49
-     * component we're checking should be specified, not the component to check
50
-     * itself.
51
-     *
52
-     * @return bool
53
-     */
54
-    protected function validateCompFilters(VObject\Component $parent, array $filters)
55
-    {
56
-        foreach ($filters as $filter) {
57
-            $isDefined = isset($parent->{$filter['name']});
58
-
59
-            if ($filter['is-not-defined']) {
60
-                if ($isDefined) {
61
-                    return false;
62
-                } else {
63
-                    continue;
64
-                }
65
-            }
66
-            if (!$isDefined) {
67
-                return false;
68
-            }
69
-
70
-            if (array_key_exists('time-range', $filter) && $filter['time-range']) {
71
-                foreach ($parent->{$filter['name']} as $subComponent) {
72
-                    $start = null;
73
-                    $end = null;
74
-                    if (array_key_exists('start', $filter['time-range'])) {
75
-                        $start = $filter['time-range']['start'];
76
-                    }
77
-                    if (array_key_exists('end', $filter['time-range'])) {
78
-                        $end = $filter['time-range']['end'];
79
-                    }
80
-                    if ($this->validateTimeRange($subComponent, $start, $end)) {
81
-                        continue 2;
82
-                    }
83
-                }
84
-
85
-                return false;
86
-            }
87
-
88
-            if (!$filter['comp-filters'] && !$filter['prop-filters']) {
89
-                continue;
90
-            }
91
-
92
-            // If there are sub-filters, we need to find at least one component
93
-            // for which the subfilters hold true.
94
-            foreach ($parent->{$filter['name']} as $subComponent) {
95
-                if (
96
-                    $this->validateCompFilters($subComponent, $filter['comp-filters']) &&
97
-                    $this->validatePropFilters($subComponent, $filter['prop-filters'])) {
98
-                    // We had a match, so this comp-filter succeeds
99
-                    continue 2;
100
-                }
101
-            }
102
-
103
-            // If we got here it means there were sub-comp-filters or
104
-            // sub-prop-filters and there was no match. This means this filter
105
-            // needs to return false.
106
-            return false;
107
-        }
108
-
109
-        // If we got here it means we got through all comp-filters alive so the
110
-        // filters were all true.
111
-        return true;
112
-    }
113
-
114
-    /**
115
-     * This method checks the validity of prop-filters.
116
-     *
117
-     * A list of prop-filters needs to be specified. Also the parent of the
118
-     * property we're checking should be specified, not the property to check
119
-     * itself.
120
-     *
121
-     * @return bool
122
-     */
123
-    protected function validatePropFilters(VObject\Component $parent, array $filters)
124
-    {
125
-        foreach ($filters as $filter) {
126
-            $isDefined = isset($parent->{$filter['name']});
127
-
128
-            if ($filter['is-not-defined']) {
129
-                if ($isDefined) {
130
-                    return false;
131
-                } else {
132
-                    continue;
133
-                }
134
-            }
135
-            if (!$isDefined) {
136
-                return false;
137
-            }
138
-
139
-            if (array_key_exists('time-range', $filter) && $filter['time-range']) {
140
-                foreach ($parent->{$filter['name']} as $subComponent) {
141
-                    $start = null;
142
-                    $end = null;
143
-                    if (array_key_exists('start', $filter['time-range'])) {
144
-                        $start = $filter['time-range']['start'];
145
-                    }
146
-                    if (array_key_exists('end', $filter['time-range'])) {
147
-                        $end = $filter['time-range']['end'];
148
-                    }
149
-                    if ($this->validateTimeRange($subComponent, $start, $end)) {
150
-                        continue 2;
151
-                    }
152
-                }
153
-
154
-                return false;
155
-            }
156
-
157
-            if (!$filter['param-filters'] && !$filter['text-match']) {
158
-                continue;
159
-            }
160
-
161
-            // If there are sub-filters, we need to find at least one property
162
-            // for which the subfilters hold true.
163
-            foreach ($parent->{$filter['name']} as $subComponent) {
164
-                if (
165
-                    $this->validateParamFilters($subComponent, $filter['param-filters']) &&
166
-                    (!$filter['text-match'] || $this->validateTextMatch($subComponent, $filter['text-match']))
167
-                ) {
168
-                    // We had a match, so this prop-filter succeeds
169
-                    continue 2;
170
-                }
171
-            }
172
-
173
-            // If we got here it means there were sub-param-filters or
174
-            // text-match filters and there was no match. This means the
175
-            // filter needs to return false.
176
-            return false;
177
-        }
178
-
179
-        // If we got here it means we got through all prop-filters alive so the
180
-        // filters were all true.
181
-        return true;
182
-    }
183
-
184
-    /**
185
-     * This method checks the validity of param-filters.
186
-     *
187
-     * A list of param-filters needs to be specified. Also the parent of the
188
-     * parameter we're checking should be specified, not the parameter to check
189
-     * itself.
190
-     *
191
-     * @return bool
192
-     */
193
-    protected function validateParamFilters(VObject\Property $parent, array $filters)
194
-    {
195
-        foreach ($filters as $filter) {
196
-            $isDefined = isset($parent[$filter['name']]);
197
-
198
-            if ($filter['is-not-defined']) {
199
-                if ($isDefined) {
200
-                    return false;
201
-                } else {
202
-                    continue;
203
-                }
204
-            }
205
-            if (!$isDefined) {
206
-                return false;
207
-            }
208
-
209
-            if (!$filter['text-match']) {
210
-                continue;
211
-            }
212
-
213
-            // If there are sub-filters, we need to find at least one parameter
214
-            // for which the subfilters hold true.
215
-            foreach ($parent[$filter['name']]->getParts() as $paramPart) {
216
-                if ($this->validateTextMatch($paramPart, $filter['text-match'])) {
217
-                    // We had a match, so this param-filter succeeds
218
-                    continue 2;
219
-                }
220
-            }
221
-
222
-            // If we got here it means there was a text-match filter and there
223
-            // were no matches. This means the filter needs to return false.
224
-            return false;
225
-        }
226
-
227
-        // If we got here it means we got through all param-filters alive so the
228
-        // filters were all true.
229
-        return true;
230
-    }
231
-
232
-    /**
233
-     * This method checks the validity of a text-match.
234
-     *
235
-     * A single text-match should be specified as well as the specific property
236
-     * or parameter we need to validate.
237
-     *
238
-     * @param VObject\Node|string $check value to check against
239
-     *
240
-     * @return bool
241
-     */
242
-    protected function validateTextMatch($check, array $textMatch)
243
-    {
244
-        if ($check instanceof VObject\Node) {
245
-            $check = $check->getValue();
246
-        }
247
-
248
-        $isMatching = \Sabre\DAV\StringUtil::textMatch($check, $textMatch['value'], $textMatch['collation']);
249
-
250
-        return $textMatch['negate-condition'] xor $isMatching;
251
-    }
252
-
253
-    /**
254
-     * Validates if a component matches the given time range.
255
-     *
256
-     * This is all based on the rules specified in rfc4791, which are quite
257
-     * complex.
258
-     *
259
-     * @param DateTime $start
260
-     * @param DateTime $end
261
-     *
262
-     * @return bool
263
-     */
264
-    protected function validateTimeRange(VObject\Node $component, $start, $end)
265
-    {
266
-        if (is_null($start)) {
267
-            $start = new DateTime('1900-01-01');
268
-        }
269
-        if (is_null($end)) {
270
-            $end = new DateTime('3000-01-01');
271
-        }
272
-
273
-        switch ($component->name) {
274
-            case 'VEVENT':
275
-            case 'VTODO':
276
-            case 'VJOURNAL':
277
-                return $component->isInTimeRange($start, $end);
278
-
279
-            case 'VALARM':
280
-                // If the valarm is wrapped in a recurring event, we need to
281
-                // expand the recursions, and validate each.
282
-                //
283
-                // Our datamodel doesn't easily allow us to do this straight
284
-                // in the VALARM component code, so this is a hack, and an
285
-                // expensive one too.
286
-                if ('VEVENT' === $component->parent->name && $component->parent->RRULE) {
287
-                    // Fire up the iterator!
288
-                    $it = new VObject\Recur\EventIterator($component->parent->parent, (string) $component->parent->UID);
289
-                    while ($it->valid()) {
290
-                        $expandedEvent = $it->getEventObject();
291
-
292
-                        // We need to check from these expanded alarms, which
293
-                        // one is the first to trigger. Based on this, we can
294
-                        // determine if we can 'give up' expanding events.
295
-                        $firstAlarm = null;
296
-                        if (null !== $expandedEvent->VALARM) {
297
-                            foreach ($expandedEvent->VALARM as $expandedAlarm) {
298
-                                $effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime();
299
-                                if ($expandedAlarm->isInTimeRange($start, $end)) {
300
-                                    return true;
301
-                                }
302
-
303
-                                if ('DATE-TIME' === (string) $expandedAlarm->TRIGGER['VALUE']) {
304
-                                    // This is an alarm with a non-relative trigger
305
-                                    // time, likely created by a buggy client. The
306
-                                    // implication is that every alarm in this
307
-                                    // recurring event trigger at the exact same
308
-                                    // time. It doesn't make sense to traverse
309
-                                    // further.
310
-                                } else {
311
-                                    // We store the first alarm as a means to
312
-                                    // figure out when we can stop traversing.
313
-                                    if (!$firstAlarm || $effectiveTrigger < $firstAlarm) {
314
-                                        $firstAlarm = $effectiveTrigger;
315
-                                    }
316
-                                }
317
-                            }
318
-                        }
319
-                        if (is_null($firstAlarm)) {
320
-                            // No alarm was found.
321
-                            //
322
-                            // Or technically: No alarm that will change for
323
-                            // every instance of the recurrence was found,
324
-                            // which means we can assume there was no match.
325
-                            return false;
326
-                        }
327
-                        if ($firstAlarm > $end) {
328
-                            return false;
329
-                        }
330
-                        $it->next();
331
-                    }
332
-
333
-                    return false;
334
-                } else {
335
-                    return $component->isInTimeRange($start, $end);
336
-                }
337
-
338
-                // no break
339
-            case 'VFREEBUSY':
340
-                throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on '.$component->name.' components');
341
-            case 'COMPLETED':
342
-            case 'CREATED':
343
-            case 'DTEND':
344
-            case 'DTSTAMP':
345
-            case 'DTSTART':
346
-            case 'DUE':
347
-            case 'LAST-MODIFIED':
348
-                return $start <= $component->getDateTime() && $end >= $component->getDateTime();
349
-
350
-            default:
351
-                throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a '.$component->name.' component');
352
-        }
353
-    }
25
+	/**
26
+	 * Verify if a list of filters applies to the calendar data object.
27
+	 *
28
+	 * The list of filters must be formatted as parsed by \Sabre\CalDAV\CalendarQueryParser
29
+	 *
30
+	 * @return bool
31
+	 */
32
+	public function validate(VObject\Component\VCalendar $vObject, array $filters)
33
+	{
34
+		// The top level object is always a component filter.
35
+		// We'll parse it manually, as it's pretty simple.
36
+		if ($vObject->name !== $filters['name']) {
37
+			return false;
38
+		}
39
+
40
+		return
41
+			$this->validateCompFilters($vObject, $filters['comp-filters']) &&
42
+			$this->validatePropFilters($vObject, $filters['prop-filters']);
43
+	}
44
+
45
+	/**
46
+	 * This method checks the validity of comp-filters.
47
+	 *
48
+	 * A list of comp-filters needs to be specified. Also the parent of the
49
+	 * component we're checking should be specified, not the component to check
50
+	 * itself.
51
+	 *
52
+	 * @return bool
53
+	 */
54
+	protected function validateCompFilters(VObject\Component $parent, array $filters)
55
+	{
56
+		foreach ($filters as $filter) {
57
+			$isDefined = isset($parent->{$filter['name']});
58
+
59
+			if ($filter['is-not-defined']) {
60
+				if ($isDefined) {
61
+					return false;
62
+				} else {
63
+					continue;
64
+				}
65
+			}
66
+			if (!$isDefined) {
67
+				return false;
68
+			}
69
+
70
+			if (array_key_exists('time-range', $filter) && $filter['time-range']) {
71
+				foreach ($parent->{$filter['name']} as $subComponent) {
72
+					$start = null;
73
+					$end = null;
74
+					if (array_key_exists('start', $filter['time-range'])) {
75
+						$start = $filter['time-range']['start'];
76
+					}
77
+					if (array_key_exists('end', $filter['time-range'])) {
78
+						$end = $filter['time-range']['end'];
79
+					}
80
+					if ($this->validateTimeRange($subComponent, $start, $end)) {
81
+						continue 2;
82
+					}
83
+				}
84
+
85
+				return false;
86
+			}
87
+
88
+			if (!$filter['comp-filters'] && !$filter['prop-filters']) {
89
+				continue;
90
+			}
91
+
92
+			// If there are sub-filters, we need to find at least one component
93
+			// for which the subfilters hold true.
94
+			foreach ($parent->{$filter['name']} as $subComponent) {
95
+				if (
96
+					$this->validateCompFilters($subComponent, $filter['comp-filters']) &&
97
+					$this->validatePropFilters($subComponent, $filter['prop-filters'])) {
98
+					// We had a match, so this comp-filter succeeds
99
+					continue 2;
100
+				}
101
+			}
102
+
103
+			// If we got here it means there were sub-comp-filters or
104
+			// sub-prop-filters and there was no match. This means this filter
105
+			// needs to return false.
106
+			return false;
107
+		}
108
+
109
+		// If we got here it means we got through all comp-filters alive so the
110
+		// filters were all true.
111
+		return true;
112
+	}
113
+
114
+	/**
115
+	 * This method checks the validity of prop-filters.
116
+	 *
117
+	 * A list of prop-filters needs to be specified. Also the parent of the
118
+	 * property we're checking should be specified, not the property to check
119
+	 * itself.
120
+	 *
121
+	 * @return bool
122
+	 */
123
+	protected function validatePropFilters(VObject\Component $parent, array $filters)
124
+	{
125
+		foreach ($filters as $filter) {
126
+			$isDefined = isset($parent->{$filter['name']});
127
+
128
+			if ($filter['is-not-defined']) {
129
+				if ($isDefined) {
130
+					return false;
131
+				} else {
132
+					continue;
133
+				}
134
+			}
135
+			if (!$isDefined) {
136
+				return false;
137
+			}
138
+
139
+			if (array_key_exists('time-range', $filter) && $filter['time-range']) {
140
+				foreach ($parent->{$filter['name']} as $subComponent) {
141
+					$start = null;
142
+					$end = null;
143
+					if (array_key_exists('start', $filter['time-range'])) {
144
+						$start = $filter['time-range']['start'];
145
+					}
146
+					if (array_key_exists('end', $filter['time-range'])) {
147
+						$end = $filter['time-range']['end'];
148
+					}
149
+					if ($this->validateTimeRange($subComponent, $start, $end)) {
150
+						continue 2;
151
+					}
152
+				}
153
+
154
+				return false;
155
+			}
156
+
157
+			if (!$filter['param-filters'] && !$filter['text-match']) {
158
+				continue;
159
+			}
160
+
161
+			// If there are sub-filters, we need to find at least one property
162
+			// for which the subfilters hold true.
163
+			foreach ($parent->{$filter['name']} as $subComponent) {
164
+				if (
165
+					$this->validateParamFilters($subComponent, $filter['param-filters']) &&
166
+					(!$filter['text-match'] || $this->validateTextMatch($subComponent, $filter['text-match']))
167
+				) {
168
+					// We had a match, so this prop-filter succeeds
169
+					continue 2;
170
+				}
171
+			}
172
+
173
+			// If we got here it means there were sub-param-filters or
174
+			// text-match filters and there was no match. This means the
175
+			// filter needs to return false.
176
+			return false;
177
+		}
178
+
179
+		// If we got here it means we got through all prop-filters alive so the
180
+		// filters were all true.
181
+		return true;
182
+	}
183
+
184
+	/**
185
+	 * This method checks the validity of param-filters.
186
+	 *
187
+	 * A list of param-filters needs to be specified. Also the parent of the
188
+	 * parameter we're checking should be specified, not the parameter to check
189
+	 * itself.
190
+	 *
191
+	 * @return bool
192
+	 */
193
+	protected function validateParamFilters(VObject\Property $parent, array $filters)
194
+	{
195
+		foreach ($filters as $filter) {
196
+			$isDefined = isset($parent[$filter['name']]);
197
+
198
+			if ($filter['is-not-defined']) {
199
+				if ($isDefined) {
200
+					return false;
201
+				} else {
202
+					continue;
203
+				}
204
+			}
205
+			if (!$isDefined) {
206
+				return false;
207
+			}
208
+
209
+			if (!$filter['text-match']) {
210
+				continue;
211
+			}
212
+
213
+			// If there are sub-filters, we need to find at least one parameter
214
+			// for which the subfilters hold true.
215
+			foreach ($parent[$filter['name']]->getParts() as $paramPart) {
216
+				if ($this->validateTextMatch($paramPart, $filter['text-match'])) {
217
+					// We had a match, so this param-filter succeeds
218
+					continue 2;
219
+				}
220
+			}
221
+
222
+			// If we got here it means there was a text-match filter and there
223
+			// were no matches. This means the filter needs to return false.
224
+			return false;
225
+		}
226
+
227
+		// If we got here it means we got through all param-filters alive so the
228
+		// filters were all true.
229
+		return true;
230
+	}
231
+
232
+	/**
233
+	 * This method checks the validity of a text-match.
234
+	 *
235
+	 * A single text-match should be specified as well as the specific property
236
+	 * or parameter we need to validate.
237
+	 *
238
+	 * @param VObject\Node|string $check value to check against
239
+	 *
240
+	 * @return bool
241
+	 */
242
+	protected function validateTextMatch($check, array $textMatch)
243
+	{
244
+		if ($check instanceof VObject\Node) {
245
+			$check = $check->getValue();
246
+		}
247
+
248
+		$isMatching = \Sabre\DAV\StringUtil::textMatch($check, $textMatch['value'], $textMatch['collation']);
249
+
250
+		return $textMatch['negate-condition'] xor $isMatching;
251
+	}
252
+
253
+	/**
254
+	 * Validates if a component matches the given time range.
255
+	 *
256
+	 * This is all based on the rules specified in rfc4791, which are quite
257
+	 * complex.
258
+	 *
259
+	 * @param DateTime $start
260
+	 * @param DateTime $end
261
+	 *
262
+	 * @return bool
263
+	 */
264
+	protected function validateTimeRange(VObject\Node $component, $start, $end)
265
+	{
266
+		if (is_null($start)) {
267
+			$start = new DateTime('1900-01-01');
268
+		}
269
+		if (is_null($end)) {
270
+			$end = new DateTime('3000-01-01');
271
+		}
272
+
273
+		switch ($component->name) {
274
+			case 'VEVENT':
275
+			case 'VTODO':
276
+			case 'VJOURNAL':
277
+				return $component->isInTimeRange($start, $end);
278
+
279
+			case 'VALARM':
280
+				// If the valarm is wrapped in a recurring event, we need to
281
+				// expand the recursions, and validate each.
282
+				//
283
+				// Our datamodel doesn't easily allow us to do this straight
284
+				// in the VALARM component code, so this is a hack, and an
285
+				// expensive one too.
286
+				if ('VEVENT' === $component->parent->name && $component->parent->RRULE) {
287
+					// Fire up the iterator!
288
+					$it = new VObject\Recur\EventIterator($component->parent->parent, (string) $component->parent->UID);
289
+					while ($it->valid()) {
290
+						$expandedEvent = $it->getEventObject();
291
+
292
+						// We need to check from these expanded alarms, which
293
+						// one is the first to trigger. Based on this, we can
294
+						// determine if we can 'give up' expanding events.
295
+						$firstAlarm = null;
296
+						if (null !== $expandedEvent->VALARM) {
297
+							foreach ($expandedEvent->VALARM as $expandedAlarm) {
298
+								$effectiveTrigger = $expandedAlarm->getEffectiveTriggerTime();
299
+								if ($expandedAlarm->isInTimeRange($start, $end)) {
300
+									return true;
301
+								}
302
+
303
+								if ('DATE-TIME' === (string) $expandedAlarm->TRIGGER['VALUE']) {
304
+									// This is an alarm with a non-relative trigger
305
+									// time, likely created by a buggy client. The
306
+									// implication is that every alarm in this
307
+									// recurring event trigger at the exact same
308
+									// time. It doesn't make sense to traverse
309
+									// further.
310
+								} else {
311
+									// We store the first alarm as a means to
312
+									// figure out when we can stop traversing.
313
+									if (!$firstAlarm || $effectiveTrigger < $firstAlarm) {
314
+										$firstAlarm = $effectiveTrigger;
315
+									}
316
+								}
317
+							}
318
+						}
319
+						if (is_null($firstAlarm)) {
320
+							// No alarm was found.
321
+							//
322
+							// Or technically: No alarm that will change for
323
+							// every instance of the recurrence was found,
324
+							// which means we can assume there was no match.
325
+							return false;
326
+						}
327
+						if ($firstAlarm > $end) {
328
+							return false;
329
+						}
330
+						$it->next();
331
+					}
332
+
333
+					return false;
334
+				} else {
335
+					return $component->isInTimeRange($start, $end);
336
+				}
337
+
338
+				// no break
339
+			case 'VFREEBUSY':
340
+				throw new \Sabre\DAV\Exception\NotImplemented('time-range filters are currently not supported on '.$component->name.' components');
341
+			case 'COMPLETED':
342
+			case 'CREATED':
343
+			case 'DTEND':
344
+			case 'DTSTAMP':
345
+			case 'DTSTART':
346
+			case 'DUE':
347
+			case 'LAST-MODIFIED':
348
+				return $start <= $component->getDateTime() && $end >= $component->getDateTime();
349
+
350
+			default:
351
+				throw new \Sabre\DAV\Exception\BadRequest('You cannot create a time-range filter on a '.$component->name.' component');
352
+		}
353
+	}
354 354
 }
Please login to merge, or discard this patch.
includes/sabre/sabre/dav/lib/CalDAV/Exception/InvalidComponentType.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,16 +16,16 @@
 block discarded – undo
16 16
  */
17 17
 class InvalidComponentType extends DAV\Exception\Forbidden
18 18
 {
19
-    /**
20
-     * Adds in extra information in the xml response.
21
-     *
22
-     * This method adds the {CALDAV:}supported-calendar-component as defined in rfc4791
23
-     */
24
-    public function serialize(DAV\Server $server, \DOMElement $errorNode)
25
-    {
26
-        $doc = $errorNode->ownerDocument;
19
+	/**
20
+	 * Adds in extra information in the xml response.
21
+	 *
22
+	 * This method adds the {CALDAV:}supported-calendar-component as defined in rfc4791
23
+	 */
24
+	public function serialize(DAV\Server $server, \DOMElement $errorNode)
25
+	{
26
+		$doc = $errorNode->ownerDocument;
27 27
 
28
-        $np = $doc->createElementNS(CalDAV\Plugin::NS_CALDAV, 'cal:supported-calendar-component');
29
-        $errorNode->appendChild($np);
30
-    }
28
+		$np = $doc->createElementNS(CalDAV\Plugin::NS_CALDAV, 'cal:supported-calendar-component');
29
+		$errorNode->appendChild($np);
30
+	}
31 31
 }
Please login to merge, or discard this patch.