2015-12-14 18:14:35 +03:00
|
|
|
<?php
|
2016-01-12 17:02:16 +03:00
|
|
|
/**
|
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
2016-01-25 19:50:39 +03:00
|
|
|
namespace OCA\DAV\DAV\Sharing\Xml;
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2016-01-25 19:50:39 +03:00
|
|
|
use OCA\DAV\DAV\Sharing\Plugin;
|
2015-12-14 18:14:35 +03:00
|
|
|
use Sabre\Xml\Reader;
|
|
|
|
use Sabre\Xml\XmlDeserializable;
|
|
|
|
|
|
|
|
class ShareRequest implements XmlDeserializable {
|
|
|
|
|
|
|
|
public $set = [];
|
|
|
|
|
|
|
|
public $remove = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param array $set
|
|
|
|
* @param array $remove
|
|
|
|
*/
|
|
|
|
function __construct(array $set, array $remove) {
|
|
|
|
|
|
|
|
$this->set = $set;
|
|
|
|
$this->remove = $remove;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static function xmlDeserialize(Reader $reader) {
|
|
|
|
|
2016-01-12 15:23:50 +03:00
|
|
|
$elements = $reader->parseInnerTree([
|
|
|
|
'{' . Plugin::NS_OWNCLOUD. '}set' => 'Sabre\\Xml\\Element\\KeyValue',
|
|
|
|
'{' . Plugin::NS_OWNCLOUD . '}remove' => 'Sabre\\Xml\\Element\\KeyValue',
|
2015-12-14 18:14:35 +03:00
|
|
|
]);
|
|
|
|
|
|
|
|
$set = [];
|
|
|
|
$remove = [];
|
|
|
|
|
2016-01-12 15:23:50 +03:00
|
|
|
foreach ($elements as $elem) {
|
2015-12-14 18:14:35 +03:00
|
|
|
switch ($elem['name']) {
|
|
|
|
|
2016-01-12 15:23:50 +03:00
|
|
|
case '{' . Plugin::NS_OWNCLOUD . '}set' :
|
2015-12-14 18:14:35 +03:00
|
|
|
$sharee = $elem['value'];
|
|
|
|
|
2016-01-12 15:23:50 +03:00
|
|
|
$sumElem = '{' . Plugin::NS_OWNCLOUD . '}summary';
|
|
|
|
$commonName = '{' . Plugin::NS_OWNCLOUD . '}common-name';
|
2015-12-14 18:14:35 +03:00
|
|
|
|
|
|
|
$set[] = [
|
|
|
|
'href' => $sharee['{DAV:}href'],
|
|
|
|
'commonName' => isset($sharee[$commonName]) ? $sharee[$commonName] : null,
|
|
|
|
'summary' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null,
|
2016-01-12 15:23:50 +03:00
|
|
|
'readOnly' => !array_key_exists('{' . Plugin::NS_OWNCLOUD . '}read-write', $sharee),
|
2015-12-14 18:14:35 +03:00
|
|
|
];
|
|
|
|
break;
|
|
|
|
|
2016-01-12 15:23:50 +03:00
|
|
|
case '{' . Plugin::NS_OWNCLOUD . '}remove' :
|
2015-12-14 18:14:35 +03:00
|
|
|
$remove[] = $elem['value']['{DAV:}href'];
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new self($set, $remove);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|