diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php index 8abdab6d..ef6d11a0 100644 --- a/plugins/kolab_addressbook/kolab_addressbook.php +++ b/plugins/kolab_addressbook/kolab_addressbook.php @@ -289,12 +289,10 @@ class kolab_addressbook extends rcube_plugin // extend the list of contact fields to be displayed in the 'personal' section if (is_array($p['form']['personal'])) { - $p['form']['contact']['content']['officelocation'] = array('size' => 40); - $p['form']['personal']['content']['initials'] = array('size' => 6); $p['form']['personal']['content']['profession'] = array('size' => 40); $p['form']['personal']['content']['children'] = array('size' => 40); - $p['form']['personal']['content']['pgppublickey'] = array('size' => 40); $p['form']['personal']['content']['freebusyurl'] = array('size' => 40); + $p['form']['personal']['content']['pgppublickey'] = array('size' => 40); // re-order fields according to the coltypes list $p['form']['contact']['content'] = $this->_sort_form_fields($p['form']['contact']['content']); diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index 41f910ea..58ba389d 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -46,14 +46,10 @@ class rcube_kolab_contacts extends rcube_addressbook 'department' => array('limit' => 1), 'email' => array('subtypes' => null), 'phone' => array(), - 'address' => array('subtypes' => array('home','work')), -// 'officelocation' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, -// 'label' => 'kolab_addressbook.officelocation', 'category' => 'main'), + 'address' => array('subtypes' => array('home','work','office')), 'website' => array('subtypes' => null), 'im' => array('subtypes' => null), 'gender' => array('limit' => 1), - 'initials' => array('type' => 'text', 'size' => 6, 'maxlength' => 10, 'limit' => 1, - 'label' => 'kolab_addressbook.initials', 'category' => 'personal'), 'birthday' => array('limit' => 1), 'anniversary' => array('limit' => 1), 'profession' => array('type' => 'text', 'size' => 40, 'maxlength' => 80, 'limit' => 1, @@ -63,10 +59,10 @@ class rcube_kolab_contacts extends rcube_addressbook 'spouse' => array('limit' => 1), 'children' => array('type' => 'text', 'size' => 40, 'maxlength' => 80, 'limit' => null, 'label' => 'kolab_addressbook.children', 'category' => 'personal'), - 'pgppublickey' => array('type' => 'text', 'size' => 40, 'limit' => 1, - 'label' => 'kolab_addressbook.pgppublickey'), 'freebusyurl' => array('type' => 'text', 'size' => 40, 'limit' => 1, 'label' => 'kolab_addressbook.freebusyurl'), + 'pgppublickey' => array('type' => 'textarea', 'size' => 70, 'rows' => 10, 'limit' => 1, + 'label' => 'kolab_addressbook.pgppublickey'), 'notes' => array(), 'photo' => array(), // TODO: define more Kolab-specific fields such as: language, latitude, longitude @@ -93,6 +89,7 @@ class rcube_kolab_contacts extends rcube_addressbook private $result; private $namespace; private $imap_folder = 'INBOX/Contacts'; + private $action; public function __construct($imap_folder = null) @@ -132,6 +129,8 @@ class rcube_kolab_contacts extends rcube_addressbook } } } + + $this->action = rcmail::get_instance()->action; } @@ -1046,10 +1045,14 @@ class rcube_kolab_contacts extends rcube_addressbook // photo is stored as separate attachment if ($record['photo'] && strlen($record['photo']) < 255 && ($att = $record['_attachments'][$record['photo']])) { // only fetch photo content if requested - if (rcmail::get_instance()->action == 'photo') + if ($this->action == 'photo') $record['photo'] = $att['content'] ? $att['content'] : $this->storagefolder->get_attachment($record['uid'], $att['key']); } + // truncate publickey value for display + if ($record['pgppublickey'] && $this->action == 'show') + $record['pgppublickey'] = substr($record['pgppublickey'], 0, 140) . '...'; + // remove empty fields return array_filter($record); } diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php index 5615c21e..eb09d64a 100644 --- a/plugins/libkolab/lib/kolab_format_contact.php +++ b/plugins/libkolab/lib/kolab_format_contact.php @@ -264,7 +264,13 @@ class kolab_format_contact extends kolab_format } $this->obj->setRelateds($rels); - // TODO: handle language, pgppublickey, etc. + if (isset($object['pgppublickey'])) { + $crypto = new Crypto; + $crypto->setPGPKey($object['pgppublickey']); + $this->obj->setCrypto($crypto); + } + + // TODO: handle language, gpslocation, etc. // cache this data @@ -352,6 +358,11 @@ class kolab_format_contact extends kolab_format // relateds -> spouse, children $this->read_relateds($this->obj->relateds(), $object); + // crypto settings: currently only pgpkey is supported + $crypto = $this->obj->crypto(); + if ($pgpkey = $crypto->pgpKey()) + $object['pgppublickey'] = $pgpkey; + $this->data = $object; return $this->data; }