summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2013-06-24 11:04:19 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2013-06-24 11:04:19 (GMT)
commitf14e8fec687dc02165e4bb7f97aaade8f8d262f8 (patch)
tree68920ef8848a96a0420bae555756e4e09d10874f /plugins
parent2880b3526afd15983b829c2d1e40a5b90d91b34d (diff)
downloadroundcubemail-plugins-kolab-f14e8fec687dc02165e4bb7f97aaade8f8d262f8.tar.gz
Revert "Adapt libkolab and kolab_addressbook to support type parameters for email addresses"
This reverts commit 9fc4a17451e2e700de8e29e68033bc5479f68ca0. Conflicts: plugins/libkolab/lib/kolab_format_contact.php
Diffstat (limited to 'plugins')
-rw-r--r--plugins/kolab_addressbook/lib/rcube_kolab_contacts.php57
-rw-r--r--plugins/libkolab/lib/kolab_format_contact.php36
2 files changed, 41 insertions, 52 deletions
diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
index 5437056..d94e4c8 100644
--- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
+++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
@@ -44,7 +44,7 @@ class rcube_kolab_contacts extends rcube_addressbook
'jobtitle' => array('limit' => 1),
'organization' => array('limit' => 1),
'department' => array('limit' => 1),
- 'email' => array('subtypes' => array('home','work','other')),
+ 'email' => array('subtypes' => null),
'phone' => array(),
'address' => array('subtypes' => array('home','work','office')),
'website' => array('subtypes' => array('homepage','blog')),
@@ -1037,15 +1037,21 @@ class rcube_kolab_contacts extends rcube_addressbook
{
$record['ID'] = $this->_uid2id($record['uid']);
- // convert email, website, phone values
- foreach (array('email'=>'address', 'website'=>'url', 'phone'=>'number') as $col => $propname) {
- if (is_array($record[$col])) {
- $values = $record[$col];
- unset($record[$col]);
- foreach ((array)$values as $i => $val) {
- $key = $col . ($val['type'] ? ':' . $val['type'] : '');
- $record[$key][] = $val[$propname];
- }
+ if (is_array($record['phone'])) {
+ $phones = $record['phone'];
+ unset($record['phone']);
+ foreach ((array)$phones as $i => $phone) {
+ $key = 'phone' . ($phone['type'] ? ':' . $phone['type'] : '');
+ $record[$key][] = $phone['number'];
+ }
+ }
+
+ if (is_array($record['website'])) {
+ $urls = $record['website'];
+ unset($record['website']);
+ foreach ((array)$urls as $i => $url) {
+ $key = 'website' . ($url['type'] ? ':' . $url['type'] : '');
+ $record[$key][] = $url['url'];
}
}
@@ -1094,22 +1100,31 @@ class rcube_kolab_contacts extends rcube_addressbook
else if (!$contact['uid'] && $old['uid'])
$contact['uid'] = $old['uid'];
+ $contact['email'] = array_filter($this->get_col_values('email', $contact, true));
$contact['im'] = array_filter($this->get_col_values('im', $contact, true));
- // convert email, website, phone values
- foreach (array('email'=>'address', 'website'=>'url', 'phone'=>'number') as $col => $propname) {
- $contact[$col] = array();
- foreach ($this->get_col_values($col, $contact) as $type => $values) {
- foreach ((array)$values as $val) {
- if (!empty($val)) {
- $contact[$col][] = array($propname => $val, 'type' => $type);
- }
+ $websites = array();
+ $phones = array();
+ $addresses = array();
+
+ foreach ($this->get_col_values('website', $contact) as $type => $values) {
+ foreach ((array)$values as $url) {
+ if (!empty($url)) {
+ $websites[] = array('url' => $url, 'type' => $type);
}
- unset($contact[$col.':'.$type]);
}
+ unset($contact['website:'.$type]);
+ }
+
+ foreach ($this->get_col_values('phone', $contact) as $type => $values) {
+ foreach ((array)$values as $phone) {
+ if (!empty($phone)) {
+ $phones[] = array('number' => $phone, 'type' => $type);
+ }
+ }
+ unset($contact['phone:'.$type]);
}
- $addresses = array();
foreach ($this->get_col_values('address', $contact) as $type => $values) {
foreach ((array)$values as $adr) {
// skip empty address
@@ -1130,6 +1145,8 @@ class rcube_kolab_contacts extends rcube_addressbook
unset($contact['address:'.$type]);
}
+ $contact['website'] = $websites;
+ $contact['phone'] = $phones;
$contact['address'] = $addresses;
// copy meta data (starting with _) from old object
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index 3852fb7..2f8bd14 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -47,12 +47,6 @@ class kolab_format_contact extends kolab_format
'other' => Telephone::Textphone,
);
- public $emailtypes = array(
- 'home' => Email::Home,
- 'work' => Email::Work,
- 'other' => Email::NoType,
- );
-
public $addresstypes = array(
'home' => Address::Home,
'work' => Address::Work,
@@ -131,21 +125,10 @@ class kolab_format_contact extends kolab_format
}
$org->setRelateds($rels);
- // im, email, url
+ // email, im, url
+ $this->obj->setEmailAddresses(self::array2vector($object['email']));
$this->obj->setIMaddresses(self::array2vector($object['im']));
- if (class_exists('vectoremail')) {
- $vemails = new vectoremail;
- foreach ((array)$object['email'] as $email) {
- $type = $this->emailtypes[$email['type']];
- $vemails->push(new Email($email['address'], intval($type)));
- }
- }
- else {
- $vemails = self::array2vector(array_map(function($v){ return $v['address']; }, $object['email']));
- }
- $this->obj->setEmailAddresses($vemails);
-
$vurls = new vectorurl;
foreach ((array)$object['website'] as $url) {
$type = $url['type'] == 'blog' ? Url::Blog : Url::NoType;
@@ -305,19 +288,8 @@ class kolab_format_contact extends kolab_format
$this->read_relateds($org->relateds(), $object);
}
- $object['im'] = self::vector2array($this->obj->imAddresses());
-
- $emails = $this->obj->emailAddresses();
- if ($emails instanceof vectoremail) {
- $emailtypes = array_flip($this->emailtypes);
- for ($i=0; $i < $emails->size(); $i++) {
- $email = $emails->get($i);
- $object['email'][] = array('address' => $email->address(), 'type' => $emailtypes[$email->types()]);
- }
- }
- else {
- $object['email'] = self::vector2array($emails);
- }
+ $object['email'] = self::vector2array($this->obj->emailAddresses());
+ $object['im'] = self::vector2array($this->obj->imAddresses());
$urls = $this->obj->urls();
for ($i=0; $i < $urls->size(); $i++) {