2015-12-14 18:14:35 +03:00
|
|
|
<?php
|
2016-01-12 17:02:16 +03:00
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2020-04-29 12:57:22 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-01-12 17:02:16 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @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,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2016-01-12 17:02:16 +03:00
|
|
|
*
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
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 {
|
2020-04-09 10:22:29 +03:00
|
|
|
public $set = [];
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 10:22:29 +03:00
|
|
|
public $remove = [];
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 10:22:29 +03:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param array $set
|
|
|
|
* @param array $remove
|
|
|
|
*/
|
2020-04-10 17:51:06 +03:00
|
|
|
public function __construct(array $set, array $remove) {
|
2020-04-09 10:22:29 +03:00
|
|
|
$this->set = $set;
|
|
|
|
$this->remove = $remove;
|
|
|
|
}
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-10 17:51:06 +03:00
|
|
|
public static function xmlDeserialize(Reader $reader) {
|
2020-04-09 10:22:29 +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
|
|
|
|
2020-04-09 10:22:29 +03:00
|
|
|
$set = [];
|
|
|
|
$remove = [];
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 10:22:29 +03:00
|
|
|
foreach ($elements as $elem) {
|
|
|
|
switch ($elem['name']) {
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 17:17:53 +03:00
|
|
|
case '{' . Plugin::NS_OWNCLOUD . '}set':
|
2020-04-09 10:22:29 +03:00
|
|
|
$sharee = $elem['value'];
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 10:22:29 +03:00
|
|
|
$sumElem = '{' . Plugin::NS_OWNCLOUD . '}summary';
|
|
|
|
$commonName = '{' . Plugin::NS_OWNCLOUD . '}common-name';
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 10:22:29 +03:00
|
|
|
$set[] = [
|
|
|
|
'href' => $sharee['{DAV:}href'],
|
|
|
|
'commonName' => isset($sharee[$commonName]) ? $sharee[$commonName] : null,
|
|
|
|
'summary' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null,
|
|
|
|
'readOnly' => !array_key_exists('{' . Plugin::NS_OWNCLOUD . '}read-write', $sharee),
|
|
|
|
];
|
|
|
|
break;
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 17:17:53 +03:00
|
|
|
case '{' . Plugin::NS_OWNCLOUD . '}remove':
|
2020-04-09 10:22:29 +03:00
|
|
|
$remove[] = $elem['value']['{DAV:}href'];
|
|
|
|
break;
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 10:22:29 +03:00
|
|
|
}
|
|
|
|
}
|
2015-12-14 18:14:35 +03:00
|
|
|
|
2020-04-09 10:22:29 +03:00
|
|
|
return new self($set, $remove);
|
|
|
|
}
|
2015-12-14 18:14:35 +03:00
|
|
|
}
|