ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ShareAccess.php
Go to the documentation of this file.
1<?php
2
4
6use Sabre\DAV\Sharing\Plugin as SharingPlugin;
10
25class ShareAccess implements Element {
26
32 protected $value;
33
42 function __construct($shareAccess) {
43
44 $this->value = $shareAccess;
45
46 }
47
53 function getValue() {
54
55 return $this->value;
56
57 }
58
78 function xmlSerialize(Writer $writer) {
79
80 switch ($this->value) {
81
82 case SharingPlugin::ACCESS_NOTSHARED :
83 $writer->writeElement('{DAV:}not-shared');
84 break;
85 case SharingPlugin::ACCESS_SHAREDOWNER :
86 $writer->writeElement('{DAV:}shared-owner');
87 break;
88 case SharingPlugin::ACCESS_READ :
89 $writer->writeElement('{DAV:}read');
90 break;
91 case SharingPlugin::ACCESS_READWRITE :
92 $writer->writeElement('{DAV:}read-write');
93 break;
94 case SharingPlugin::ACCESS_NOACCESS :
95 $writer->writeElement('{DAV:}no-access');
96 break;
97
98 }
99
100 }
101
123 static function xmlDeserialize(Reader $reader) {
124
125 $elems = $reader->parseInnerTree();
126 foreach ($elems as $elem) {
127 switch ($elem['name']) {
128 case '{DAV:}not-shared' :
129 return new self(SharingPlugin::ACCESS_NOTSHARED);
130 case '{DAV:}shared-owner' :
131 return new self(SharingPlugin::ACCESS_SHAREDOWNER);
132 case '{DAV:}read' :
133 return new self(SharingPlugin::ACCESS_READ);
134 case '{DAV:}read-write' :
135 return new self(SharingPlugin::ACCESS_READWRITE);
136 case '{DAV:}no-access' :
137 return new self(SharingPlugin::ACCESS_NOACCESS);
138 }
139 }
140 throw new BadRequest('Invalid value for {DAV:}share-access element');
141
142 }
143}
An exception for terminatinating execution or to throw for unit testing.
This plugin implements HTTP requests and properties related to:
Definition: Plugin.php:27
This class represents the {DAV:}share-access property.
Definition: ShareAccess.php:25
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
__construct($shareAccess)
Creates the property.
Definition: ShareAccess.php:42
getValue()
Returns the current value.
Definition: ShareAccess.php:53
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
Definition: ShareAccess.php:78
The Reader class expands upon PHP's built-in XMLReader.
Definition: Reader.php:20
The XML Writer class.
Definition: Writer.php:31
writeElement($name, $content=null)
Write a full element tag and it's contents.
Definition: Writer.php:189
This is the XML element interface.
Definition: Element.php:18