1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Merge pull request #501 from owncloud/sabredav-1.8.10

update SabreDAV to 1.8.10
This commit is contained in:
jbtbnl 2014-06-18 11:11:29 +02:00
commit ebb7535c85
8 changed files with 44 additions and 44 deletions

View File

@ -48,7 +48,7 @@ $carddavBackend = new OCA\Contacts\CardDAV\Backend($backends);
$requestBackend = new OC_Connector_Sabre_Request();
// Root nodes
$principalCollection = new Sabre_CalDAV_Principal_Collection($principalBackend);
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
$principalCollection->disableListing = true; // Disable listing
$addressBookRoot = new OCA\Contacts\CardDAV\AddressBookRoot($principalBackend, $carddavBackend);
@ -60,15 +60,15 @@ $nodes = array(
);
// Fire up server
$server = new Sabre_DAV_Server($nodes);
$server = new \Sabre\DAV\Server($nodes);
$server->httpRequest = $requestBackend;
$server->setBaseUri($baseuri);
// Add plugins
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend, 'ownCloud'));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud'));
$server->addPlugin(new OCA\Contacts\CardDAV\Plugin());
$server->addPlugin(new Sabre_DAVACL_Plugin());
$server->addPlugin(new Sabre_DAV_Browser_Plugin(false)); // Show something in the Browser, but no upload
$server->addPlugin(new Sabre_CardDAV_VCFExportPlugin());
$server->addPlugin(new \Sabre\DAVACL\Plugin());
$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload
$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
$server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('carddav'));
if (defined('DEBUG') && DEBUG) {

View File

@ -26,28 +26,28 @@ use OCA\Contacts;
/**
* This class overrides __construct to get access to $addressBookInfo and
* $carddavBackend, Sabre_CardDAV_AddressBook::getACL() to return read/write
* $carddavBackend, \Sabre\CardDAV\AddressBook::getACL() to return read/write
* permissions based on user and shared state and it overrides
* Sabre_CardDAV_AddressBook::getChild() and Sabre_CardDAV_AddressBook::getChildren()
* \Sabre\CardDAV\AddressBook::getChild() and \Sabre\CardDAV\AddressBook::getChildren()
* to instantiate \OCA\Contacts\CardDAV\Cards.
*/
class AddressBook extends \Sabre_CardDAV_AddressBook {
class AddressBook extends \Sabre\CardDAV\AddressBook {
/**
* CardDAV backend
*
* @var Sabre_CardDAV_Backend_Abstract
* @var \Sabre\CardDAV\Backend\AbstractBackend
*/
protected $carddavBackend;
/**
* Constructor
*
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
* @param \Sabre\CardDAV\Backend\AbstractBackend $carddavBackend
* @param array $addressBookInfo
*/
public function __construct(
\Sabre_CardDAV_Backend_Abstract $carddavBackend,
\Sabre\CardDAV\Backend\AbstractBackend $carddavBackend,
array $addressBookInfo
) {
@ -199,13 +199,13 @@ class AddressBook extends \Sabre_CardDAV_AddressBook {
* Returns a card
*
* @param string $name
* @return OC_Connector_Sabre_DAV_Card
* @return Card
*/
public function getChild($name) {
$obj = $this->carddavBackend->getCard($this->addressBookInfo['id'],$name);
if (!$obj) {
throw new \Sabre_DAV_Exception_NotFound('Card not found');
throw new \Sabre\DAV\Exception\NotFound('Card not found');
}
return new Card($this->carddavBackend,$this->addressBookInfo,$obj);

View File

@ -23,10 +23,10 @@
namespace OCA\Contacts\CardDAV;
/**
* This class overrides Sabre_CardDAV_AddressBookRoot::getChildForPrincipal()
* This class overrides \Sabre\CardDAV\AddressBookRoot::getChildForPrincipal()
* to instantiate OC_Connector_CardDAV_UserAddressBooks.
*/
class AddressBookRoot extends \Sabre_CardDAV_AddressBookRoot {
class AddressBookRoot extends \Sabre\CardDAV\AddressBookRoot {
/**
* This method returns a node for a principal.
@ -36,7 +36,7 @@ class AddressBookRoot extends \Sabre_CardDAV_AddressBookRoot {
* supplied by the authentication backend.
*
* @param array $principal
* @return Sabre_DAV_INode
* @return \Sabre\DAV\INode
*/
public function getChildForPrincipal(array $principal) {
@ -44,4 +44,4 @@ class AddressBookRoot extends \Sabre_CardDAV_AddressBookRoot {
}
}
}

View File

@ -33,7 +33,7 @@ use OCA\Contacts;
* in that backend. For your own address books it can be e.g 'local::1' for
* an address book shared with you it could be 'shared::2' an so forth.
*/
class Backend extends \Sabre_CardDAV_Backend_Abstract {
class Backend extends \Sabre\CardDAV\Backend\AbstractBackend {
public function __construct($backends) {
$this->backends = $backends;
@ -64,11 +64,11 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
'uri' => $addressBook['uri'],
'principaluri' => 'principals/'.$addressBook['owner'],
'{DAV:}displayname' => $addressBook['displayname'],
'{' . \Sabre_CardDAV_Plugin::NS_CARDDAV . '}addressbook-description'
'{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}addressbook-description'
=> $addressBook['description'],
'{http://calendarserver.org/ns/}getctag' => $addressBook['lastmodified'],
'{' . \Sabre_CardDAV_Plugin::NS_CARDDAV . '}supported-address-data' =>
new \Sabre_CardDAV_Property_SupportedAddressData(),
'{' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '}supported-address-data' =>
new \Sabre\CardDAV\Property\SupportedAddressData(),
);
}
}
@ -81,12 +81,12 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
/**
* Updates an addressbook's properties
*
* See Sabre_DAV_IProperties for a description of the mutations array, as
* See \Sabre\DAV\IProperties for a description of the mutations array, as
* well as the return value.
*
* @param mixed $addressbookid
* @param array $mutations
* @see Sabre_DAV_IProperties::updateProperties
* @see \Sabre\DAV\IProperties::updateProperties
* @return bool|array
*/
public function updateAddressBook($addressbookid, array $mutations) {
@ -97,7 +97,7 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
case '{DAV:}displayname' :
$changes['displayname'] = $newvalue;
break;
case '{' . \Sabre_CardDAV_Plugin::NS_CARDDAV
case '{' . \Sabre\CardDAV\Plugin::NS_CARDDAV
. '}addressbook-description' :
$changes['description'] = $newvalue;
break;
@ -129,12 +129,12 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
case '{DAV:}displayname' :
$properties['displayname'] = $newvalue;
break;
case '{' . \Sabre_CardDAV_Plugin::NS_CARDDAV
case '{' . \Sabre\CardDAV\Plugin::NS_CARDDAV
. '}addressbook-description' :
$properties['description'] = $newvalue;
break;
default :
throw new \Sabre_DAV_Exception_BadRequest('Unknown property: '
throw new \Sabre\DAV\Exception\BadRequest('Unknown property: '
. $property);
}
@ -206,7 +206,7 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
try {
$contact = $backend->getContact($id, array('uri' => urldecode($carduri)));
} catch(\Exception $e) {
//throw new \Sabre_DAV_Exception_NotFound($e->getMessage());
//throw new \Sabre\DAV\Exception\NotFound($e->getMessage());
\OCP\Util::writeLog('contacts', __METHOD__.', Exception: '. $e->getMessage(), \OCP\Util::DEBUG);
return false;
}
@ -214,7 +214,7 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
$contact['etag'] = '"' . md5($contact['carddata']) . '"';
return $contact;
}
//throw new \Sabre_DAV_Exception('Error retrieving the card');
//throw new \Sabre\DAV\Exception('Error retrieving the card');
return false;
}
@ -266,7 +266,7 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
* @return string
*/
public function userIDByPrincipal($principaluri) {
list(, $userid) = \Sabre_DAV_URLUtil::splitPath($principaluri);
list(, $userid) = \Sabre\DAV\URLUtil::splitPath($principaluri);
return $userid;
}
@ -283,6 +283,6 @@ class Backend extends \Sabre_CardDAV_Backend_Abstract {
if($backend->name === $backendName && $backend->hasAddressBook($id)) {
return array($id, $backend);
}
throw new \Sabre_DAV_Exception_NotFound('Backend not found: ' . $addressbookid);
throw new \Sabre\DAV\Exception\NotFound('Backend not found: ' . $addressbookid);
}
}

View File

@ -25,10 +25,10 @@ namespace OCA\Contacts\CardDAV;
use OCA\Contacts;
/**
* This class overrides Sabre_CardDAV_Card::getACL()
* This class overrides \Sabre\CardDAV\Card::getACL()
* to return read/write permissions based on user and shared state.
*/
class Card extends \Sabre_CardDAV_Card {
class Card extends \Sabre\CardDAV\Card {
/**
* Array with information about the containing addressbook
@ -40,11 +40,11 @@ class Card extends \Sabre_CardDAV_Card {
/**
* Constructor
*
* @param Sabre_CardDAV_Backend_Abstract $carddavBackend
* @param \Sabre\CardDAV\Backend\AbstractBackend $carddavBackend
* @param array $addressBookInfo
* @param array $cardData
*/
public function __construct(\Sabre_CardDAV_Backend_Abstract $carddavBackend, array $addressBookInfo, array $cardData) {
public function __construct(\Sabre\CardDAV\Backend\AbstractBackend $carddavBackend, array $addressBookInfo, array $cardData) {
$this->addressBookInfo = $addressBookInfo;
parent::__construct($carddavBackend, $addressBookInfo, $cardData);
@ -96,4 +96,4 @@ class Card extends \Sabre_CardDAV_Card {
}
}
}

View File

@ -28,11 +28,11 @@ use Sabre\VObject;
use OCA\Contacts\VObject\VCard;
/**
* This class overrides Sabre_CardDAV_Plugin::validateVCard() to be able
* This class overrides \Sabre\CardDAV\Plugin::validateVCard() to be able
* to import partially invalid vCards by ignoring invalid lines and to
* validate and upgrade using \OCA\Contacts\VCard.
*/
class Plugin extends \Sabre_CardDAV_Plugin {
class Plugin extends \Sabre\CardDAV\Plugin {
/**
* Checks if the submitted vCard data is in fact, valid.
@ -54,14 +54,14 @@ class Plugin extends \Sabre_CardDAV_Plugin {
try {
$vobj = VObject\Reader::read($data, VObject\Reader::OPTION_IGNORE_INVALID_LINES);
} catch (VObject\ParseException $e) {
throw new \Sabre_DAV_Exception_UnsupportedMediaType('This resource only supports valid vcard data. Parse error: ' . $e->getMessage());
throw new \Sabre\DAV\Exception\UnsupportedMediaType('This resource only supports valid vcard data. Parse error: ' . $e->getMessage());
}
if ($vobj->name !== 'VCARD') {
throw new \Sabre_DAV_Exception_UnsupportedMediaType('This collection can only support vcard objects.');
throw new \Sabre\DAV\Exception\UnsupportedMediaType('This collection can only support vcard objects.');
}
$vobj->validate(VCard::REPAIR|VCard::UPGRADE);
$data = $vobj->serialize();
}
}
}

View File

@ -23,10 +23,10 @@
namespace OCA\Contacts\CardDAV;
/**
* This class overrides Sabre_CardDAV_UserAddressBooks::getChildren()
* This class overrides \Sabre\CardDAV\UserAddressBooks::getChildren()
* to instantiate \OCA\Contacts\CardDAV\AddressBooks.
*/
class UserAddressBooks extends \Sabre_CardDAV_UserAddressBooks {
class UserAddressBooks extends \Sabre\CardDAV\UserAddressBooks {
/**
* Returns a list of addressbooks

View File

@ -199,7 +199,7 @@ class JSONSerializer {
$parameter->name = 'PREF';
$parameter->value = '1';
}
// NOTE: Apparently Sabre_VObject_Reader can't always deal with value list parameters
// NOTE: Apparently \Sabre\VObject\Reader can't always deal with value list parameters
// like TYPE=HOME,CELL,VOICE. Tanghus.
// TODO: Check if parameter is has commas and split + merge if so.
if ($parameter->name == 'TYPE') {