summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-08-22 18:50:50 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-08-22 18:51:17 +0200
commit61c7700ce61772bce30791705625022e162b7cd7 (patch)
tree3ebf94ecc758d458df251dc738a7e68fc98b8366 /apps/contacts/ajax
parent885b8c481bed58a41b5f458decafa8bbfe1635c1 (diff)
downloadnextcloud-server-61c7700ce61772bce30791705625022e162b7cd7.tar.gz
nextcloud-server-61c7700ce61772bce30791705625022e162b7cd7.zip
Add support for IMPP properties.
Diffstat (limited to 'apps/contacts/ajax')
-rw-r--r--apps/contacts/ajax/contact/addproperty.php14
-rw-r--r--apps/contacts/ajax/contact/saveproperty.php26
2 files changed, 34 insertions, 6 deletions
diff --git a/apps/contacts/ajax/contact/addproperty.php b/apps/contacts/ajax/contact/addproperty.php
index 1412cad1cbc..0447950fbdd 100644
--- a/apps/contacts/ajax/contact/addproperty.php
+++ b/apps/contacts/ajax/contact/addproperty.php
@@ -108,7 +108,17 @@ switch($name) {
$value = strtolower($value);
break;
case 'TEL':
- case 'ADR': // should I delete the property if empty or throw an error?
+ case 'ADR':
+ break;
+ case 'IMPP':
+ if(is_null($parameters) || !isset($parameters['X-SERVICE-TYPE'])) {
+ bailOut(OC_Contacts_App::$l10n->t('Missing IM parameter.'));
+ }
+ $impp = OC_Contacts_App::getIMOptions($parameters['X-SERVICE-TYPE']);
+ if(is_null($impp)) {
+ bailOut(OC_Contacts_App::$l10n->t('Unknown IM: '.$parameters['X-SERVICE-TYPE']));
+ }
+ $value = $impp['protocol'] . ':' . $value;
break;
}
@@ -126,7 +136,7 @@ $line = count($vcard->children) - 1;
// Apparently Sabre_VObject_Parameter doesn't do well with
// multiple values or I don't know how to do it. Tanghus.
foreach ($parameters as $key=>$element) {
- if(is_array($element) && strtoupper($key) == 'TYPE') {
+ if(is_array($element) /*&& strtoupper($key) == 'TYPE'*/) {
// NOTE: Maybe this doesn't only apply for TYPE?
// And it probably shouldn't be done here anyways :-/
foreach($element as $e) {
diff --git a/apps/contacts/ajax/contact/saveproperty.php b/apps/contacts/ajax/contact/saveproperty.php
index fd541b7361e..9556c4a44c3 100644
--- a/apps/contacts/ajax/contact/saveproperty.php
+++ b/apps/contacts/ajax/contact/saveproperty.php
@@ -88,6 +88,16 @@ switch($element) {
case 'EMAIL':
$value = strtolower($value);
break;
+ case 'IMPP':
+ if(is_null($parameters) || !isset($parameters['X-SERVICE-TYPE'])) {
+ bailOut(OC_Contacts_App::$l10n->t('Missing IM parameter.'));
+ }
+ $impp = OC_Contacts_App::getIMOptions($parameters['X-SERVICE-TYPE']);
+ if(is_null($impp)) {
+ bailOut(OC_Contacts_App::$l10n->t('Unknown IM: '.$parameters['X-SERVICE-TYPE']));
+ }
+ $value = $impp['protocol'] . ':' . $value;
+ break;
}
if(!$value) {
@@ -112,7 +122,8 @@ if(!$value) {
break;
case 'EMAIL':
case 'TEL':
- case 'ADR': // should I delete the property if empty or throw an error?
+ case 'ADR':
+ case 'IMPP':
debug('Setting element: (EMAIL/TEL/ADR)'.$element);
$vcard->children[$line]->setValue($value);
$vcard->children[$line]->parameters = array();
@@ -120,11 +131,18 @@ if(!$value) {
debug('Setting parameters: '.$parameters);
foreach($parameters as $key => $parameter) {
debug('Adding parameter: '.$key);
- foreach($parameter as $val) {
- debug('Adding parameter: '.$key.'=>'.$val);
+ if(is_array($parameter)) {
+ foreach($parameter as $val) {
+ debug('Adding parameter: '.$key.'=>'.$val);
+ $vcard->children[$line]->add(new Sabre_VObject_Parameter(
+ $key,
+ strtoupper(strip_tags($val)))
+ );
+ }
+ } else {
$vcard->children[$line]->add(new Sabre_VObject_Parameter(
$key,
- strtoupper(strip_tags($val)))
+ strtoupper(strip_tags($parameter)))
);
}
}