ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Share.php
Go to the documentation of this file.
1 <?php
2 
4 
9 
21 class Share implements XmlDeserializable {
22 
28  public $sharees = [];
29 
35  function __construct(array $sharees) {
36 
37  $this->sharees = $sharees;
38 
39  }
40 
62  static function xmlDeserialize(Reader $reader) {
63 
64  $elems = $reader->parseGetElements([
65  '{' . Plugin::NS_CALENDARSERVER . '}set' => 'Sabre\\Xml\\Element\\KeyValue',
66  '{' . Plugin::NS_CALENDARSERVER . '}remove' => 'Sabre\\Xml\\Element\\KeyValue',
67  ]);
68 
69  $sharees = [];
70 
71  foreach ($elems as $elem) {
72  switch ($elem['name']) {
73 
74  case '{' . Plugin::NS_CALENDARSERVER . '}set' :
75  $sharee = $elem['value'];
76 
77  $sumElem = '{' . Plugin::NS_CALENDARSERVER . '}summary';
78  $commonName = '{' . Plugin::NS_CALENDARSERVER . '}common-name';
79 
80  $properties = [];
81  if (isset($sharee[$commonName])) {
82  $properties['{DAV:}displayname'] = $sharee[$commonName];
83  }
84 
85  $access = array_key_exists('{' . Plugin::NS_CALENDARSERVER . '}read-write', $sharee)
88 
89  $sharees[] = new Sharee([
90  'href' => $sharee['{DAV:}href'],
91  'properties' => $properties,
92  'access' => $access,
93  'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null
94  ]);
95  break;
96 
97  case '{' . Plugin::NS_CALENDARSERVER . '}remove' :
98  $sharees[] = new Sharee([
99  'href' => $elem['value']['{DAV:}href'],
100  'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS
101  ]);
102  break;
103 
104  }
105  }
106 
107  return new self($sharees);
108 
109  }
110 
111 }
This class represents the {DAV:}sharee element.
Definition: Sharee.php:21
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
Definition: Share.php:62
Share POST request parser.
Definition: Share.php:21
parseGetElements(array $elementMap=null)
parseGetElements parses everything in the current sub-tree, and returns a an array of elements...
Definition: Reader.php:105
const NS_CALENDARSERVER
This is the namespace for the proprietary calendarserver extensions.
Definition: Plugin.php:38
The Reader class expands upon PHP&#39;s built-in XMLReader.
Definition: Reader.php:20
Implementing the XmlDeserializable interface allows you to use a class as a deserializer for a specif...
__construct(array $sharees)
Constructor.
Definition: Share.php:35