mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-29 18:52:18 +01:00
Contacts: Properly namespace VObject subclasses.
This commit is contained in:
parent
ac19b7f0f3
commit
99e8f5b5f6
@ -6,8 +6,8 @@ OC::$CLASSPATH['OCA\Contacts\Hooks'] = 'contacts/lib/hooks.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\Share_Backend_Contact'] = 'contacts/lib/share/contact.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\Share_Backend_Addressbook'] = 'contacts/lib/share/addressbook.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\AddressbookProvider'] = 'contacts/lib/addressbookprovider.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\VCardObject'] = 'contacts/lib/sabre/vcard.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\StringProperty'] = 'contacts/lib/sabre/stringproperty.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\VObject\VCard'] = 'contacts/lib/vobject/vcard.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\VObject\StringProperty'] = 'contacts/lib/vobject/stringproperty.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\CardDAV\Backend'] = 'contacts/lib/sabre/backend.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\CardDAV\Plugin'] = 'contacts/lib/sabre/plugin.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\CardDAV\AddressBookRoot'] = 'contacts/lib/sabre/addressbookroot.php';
|
||||
@ -16,16 +16,16 @@ OC::$CLASSPATH['OCA\Contacts\CardDAV\AddressBook'] = 'contacts/lib/sabre/address
|
||||
OC::$CLASSPATH['OCA\Contacts\CardDAV\Card'] = 'contacts/lib/sabre/card.php';
|
||||
OC::$CLASSPATH['OCA\Contacts\SearchProvider'] = 'contacts/lib/search.php';
|
||||
|
||||
require_once __DIR__ . '/../lib/sabre/vcard.php';
|
||||
require_once __DIR__ . '/../lib/vobject/vcard.php';
|
||||
//require_once __DIR__ . '/../lib/sabre/stringproperty.php';
|
||||
Sabre\VObject\Component::$classMap['VCARD'] = 'OCA\Contacts\VCardObject';
|
||||
Sabre\VObject\Property::$classMap['FN'] = 'OCA\Contacts\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['NOTE'] = 'OCA\Contacts\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['NICKNAME'] = 'OCA\Contacts\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['EMAIL'] = 'OCA\Contacts\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['TEL'] = 'OCA\Contacts\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['IMPP'] = 'OCA\Contacts\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['URL'] = 'OCA\Contacts\StringProperty';
|
||||
Sabre\VObject\Component::$classMap['VCARD'] = 'OCA\Contacts\VObject\VCard';
|
||||
Sabre\VObject\Property::$classMap['FN'] = 'OCA\Contacts\VObject\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['NOTE'] = 'OCA\Contacts\VObject\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['NICKNAME'] = 'OCA\Contacts\VObject\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['EMAIL'] = 'OCA\Contacts\VObject\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['TEL'] = 'OCA\Contacts\VObject\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['IMPP'] = 'OCA\Contacts\VObject\StringProperty';
|
||||
Sabre\VObject\Property::$classMap['URL'] = 'OCA\Contacts\VObject\StringProperty';
|
||||
|
||||
OCP\Util::connectHook('OC_User', 'post_createUser', 'OCA\Contacts\Hooks', 'createUser');
|
||||
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OCA\Contacts\Hooks', 'deleteUser');
|
||||
|
@ -146,7 +146,7 @@ foreach($parts as $part) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
$vcard->validate(VCardObject::REPAIR|VCardObject::UPGRADE);
|
||||
$vcard->validate(VCard::REPAIR|VCard::UPGRADE);
|
||||
} catch (\Exception $e) {
|
||||
OCP\Util::writeLog('contacts', __LINE__ . ' ' .
|
||||
'Error validating vcard: ' . $e->getMessage() . $nl . $vcard->serialize(),
|
||||
|
@ -30,7 +30,7 @@ use OCA\Contacts;
|
||||
/**
|
||||
* 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\VCardObject.
|
||||
* validate and upgrade using \OCA\Contacts\VCard.
|
||||
*/
|
||||
class Plugin extends \Sabre_CardDAV_Plugin {
|
||||
|
||||
@ -63,7 +63,7 @@ class Plugin extends \Sabre_CardDAV_Plugin {
|
||||
throw new \Sabre_DAV_Exception_UnsupportedMediaType('This collection can only support vcard objects.');
|
||||
}
|
||||
|
||||
$vobj->validate(VCardObject::REPAIR|VCardObject::UPGRADE);
|
||||
$vobj->validate(VCard::REPAIR|VCard::UPGRADE);
|
||||
$data = $vobj->serialize();
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Contacts;
|
||||
namespace OCA\Contacts\VObject;
|
||||
|
||||
use Sabre\VObject;
|
||||
|
@ -23,8 +23,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Contacts;
|
||||
namespace OCA\Contacts\VObject;
|
||||
|
||||
use OCA\Contacts;
|
||||
use Sabre\VObject;
|
||||
|
||||
/**
|
||||
@ -32,7 +33,7 @@ use Sabre\VObject;
|
||||
* to import partially invalid vCards by ignoring invalid lines and to
|
||||
* validate and upgrade using ....
|
||||
*/
|
||||
class VCardObject extends VObject\Component\VCard {
|
||||
class VCard extends VObject\Component\VCard {
|
||||
|
||||
/**
|
||||
* The following constants are used by the validate() method.
|
||||
@ -56,7 +57,7 @@ class VCardObject extends VObject\Component\VCard {
|
||||
*/
|
||||
protected function formatPropertyTypes(&$property) {
|
||||
foreach($property->parameters as $key=>&$parameter) {
|
||||
$types = App::getTypesOfProperty($property->name);
|
||||
$types = Contacts\App::getTypesOfProperty($property->name);
|
||||
if(is_array($types) && in_array(strtoupper($parameter->name), array_keys($types))
|
||||
|| strtoupper($parameter->name) == 'PREF') {
|
||||
unset($property->parameters[$key]);
|
||||
@ -98,9 +99,9 @@ class VCardObject extends VObject\Component\VCard {
|
||||
* Validates the node for correctness.
|
||||
*
|
||||
* The following options are supported:
|
||||
* - Node::REPAIR - If something is broken, and automatic repair may
|
||||
* - VCard::REPAIR - If something is broken, and automatic repair may
|
||||
* be attempted.
|
||||
* - VCardObject::UPGRADE - If needed the vCard will be upgraded to version 3.0.
|
||||
* - VCard::UPGRADE - If needed the vCard will be upgraded to version 3.0.
|
||||
*
|
||||
* An array is returned with warnings.
|
||||
*
|
Loading…
x
Reference in New Issue
Block a user