summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'apps/contacts/ajax')
-rw-r--r--apps/contacts/ajax/addcard.php5
-rw-r--r--apps/contacts/ajax/getdetails.php12
-rw-r--r--apps/contacts/ajax/setproperty.php17
-rw-r--r--apps/contacts/ajax/showaddcard.php5
-rw-r--r--apps/contacts/ajax/showsetproperty.php4
5 files changed, 42 insertions, 1 deletions
diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php
index 0cecd3bdc06..dd5b90651f5 100644
--- a/apps/contacts/ajax/addcard.php
+++ b/apps/contacts/ajax/addcard.php
@@ -68,11 +68,16 @@ foreach( $add as $propname){
}
$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
$details = OC_Contacts_VCard::structureContact($vcard);
$name = $details['FN'][0]['value'];
$tmpl = new OC_Template('contacts','part.details');
$tmpl->assign('details',$details);
$tmpl->assign('id',$id);
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'id' => $id, 'name' => $name, 'page' => $page )));
diff --git a/apps/contacts/ajax/getdetails.php b/apps/contacts/ajax/getdetails.php
index 0e76de61afb..260fb53a686 100644
--- a/apps/contacts/ajax/getdetails.php
+++ b/apps/contacts/ajax/getdetails.php
@@ -51,10 +51,22 @@ if(is_null($vcard)){
exit();
}
+$property_types = array(
+ 'ADR' => $l10n->t('Address'),
+ 'TEL' => $l10n->t('Telephone'),
+ 'EMAIL' => $l10n->t('Email'),
+ 'ORG' => $l10n->t('Organization'),
+);
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
$details = OC_Contacts_VCard::structureContact($vcard);
$tmpl = new OC_Template('contacts','part.details');
$tmpl->assign('details',$details);
$tmpl->assign('id',$id);
+$tmpl->assign('property_types',$property_types);
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php
index 18e00872473..c9102c4a2ee 100644
--- a/apps/contacts/ajax/setproperty.php
+++ b/apps/contacts/ajax/setproperty.php
@@ -70,6 +70,9 @@ $vcard->children[$line]->setValue($value);
// Add parameters
$postparameters = isset($_POST['parameters'])?$_POST['parameters']:array();
+if ($vcard->children[$line]->name == 'TEL' && !array_key_exists('TYPE', $postparameters)){
+ $postparameters['TYPE']='';
+}
for($i=0;$i<count($vcard->children[$line]->parameters);$i++){
$name = $vcard->children[$line]->parameters[$i]->name;
if(array_key_exists($name,$postparameters)){
@@ -77,7 +80,14 @@ for($i=0;$i<count($vcard->children[$line]->parameters);$i++){
unset($vcard->children[$line]->parameters[$i]);
}
else{
- $vcard->children[$line]->parameters[$i]->value = $postparameters[$name];
+ unset($vcard->children[$line][$name]);
+ $values = $postparameters[$name];
+ if (!is_array($values)){
+ $values = array($values);
+ }
+ foreach($values as $value){
+ $vcard->children[$line]->add($name, $value);
+ }
}
unset($postparameters[$name]);
}
@@ -94,7 +104,12 @@ $checksum = md5($vcard->children[$line]->serialize());
OC_Contacts_VCard::edit($id,$vcard->serialize());
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
$tmpl = new OC_Template('contacts','part.property');
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line],$line));
$page = $tmpl->fetchPage();
diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php
index 2f534f0fe2d..98367758fd4 100644
--- a/apps/contacts/ajax/showaddcard.php
+++ b/apps/contacts/ajax/showaddcard.php
@@ -29,9 +29,14 @@ $l10n = new OC_L10N('contacts');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
+
$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
$tmpl = new OC_Template('contacts','part.addcardform');
$tmpl->assign('addressbooks',$addressbooks);
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php
index 6188f4773c3..2ec4b89b824 100644
--- a/apps/contacts/ajax/showsetproperty.php
+++ b/apps/contacts/ajax/showsetproperty.php
@@ -61,11 +61,15 @@ if(is_null($line)){
exit();
}
+$adr_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'ADR');
+$phone_types = OC_Contacts_VCard::getTypesOfProperty($l10n, 'TEL');
$tmpl = new OC_Template('contacts','part.setpropertyform');
$tmpl->assign('id',$id);
$tmpl->assign('checksum',$checksum);
$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line]));
+$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('phone_types',$phone_types);
$page = $tmpl->fetchPage();
OC_JSON::success(array('data' => array( 'page' => $page )));