summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-01-22 13:51:26 +0000
committerthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-01-22 13:51:26 +0000
commit0c4670ac8b9c6524536c28d3d3d38449015ed26c (patch)
tree157d7abd2a001ff72e3ad24fdf408c9e3ccf544c /plugins
parent159ffcf31fbb32251229169a1de7095ac2bc5874 (diff)
Spread Kolab-specific fields to the new form groups; check if connection to Kolab server succeeded; sort contacts by name
git-svn-id: https://svn.roundcube.net/trunk@4442 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/kolab_addressbook/kolab_addressbook.php34
-rw-r--r--plugins/kolab_addressbook/rcube_kolab_contacts.php22
-rw-r--r--plugins/kolab_core/rcube_kolab.php6
3 files changed, 41 insertions, 21 deletions
diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php
index 68179c387..3125bbd3d 100644
--- a/plugins/kolab_addressbook/kolab_addressbook.php
+++ b/plugins/kolab_addressbook/kolab_addressbook.php
@@ -120,22 +120,17 @@ class kolab_addressbook extends rcube_plugin
if (!is_a($GLOBALS['CONTACTS'], 'rcube_kolab_contacts'))
return $p;
- // extend the list of contact fields to be displayed in the 'info' section
- if (is_array($p['form']['info'])) {
- $p['form']['info']['content']['initials'] = array('size' => 6);
+ // extend the list of contact fields to be displayed in the 'personal' section
+ if (is_array($p['form']['personal'])) {
$p['form']['info']['content']['officelocation'] = array('size' => 40);
- $p['form']['info']['content']['profession'] = array('size' => 40);
- $p['form']['info']['content']['children'] = array('size' => 40);
- // re-order fields according to the coltypes list
- $block = array();
- $contacts = reset($this->sources);
- foreach ($contacts->coltypes as $col => $prop) {
- if (isset($p['form']['info']['content'][$col]))
- $block[$col] = $p['form']['info']['content'][$col];
- }
+ $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']['info']['content'] = $block;
+ // re-order fields according to the coltypes list
+ $p['form']['info']['content'] = $this->_sort_form_fields($p['form']['info']['content']);
+ $p['form']['personal']['content'] = $this->_sort_form_fields($p['form']['personal']['content']);
// define a separate section 'settings'
$p['form']['settings'] = array(
@@ -149,5 +144,18 @@ class kolab_addressbook extends rcube_plugin
return $p;
}
+
+
+ private function _sort_form_fields($contents)
+ {
+ $block = array();
+ $contacts = reset($this->sources);
+ foreach ($contacts->coltypes as $col => $prop) {
+ if (isset($contents[$col]))
+ $block[$col] = $contents[$col];
+ }
+
+ return $block;
+ }
}
diff --git a/plugins/kolab_addressbook/rcube_kolab_contacts.php b/plugins/kolab_addressbook/rcube_kolab_contacts.php
index 8eb1f7856..8ecb6a402 100644
--- a/plugins/kolab_addressbook/rcube_kolab_contacts.php
+++ b/plugins/kolab_addressbook/rcube_kolab_contacts.php
@@ -26,16 +26,16 @@ class rcube_kolab_contacts extends rcube_addressbook
'jobtitle' => array('limit' => 1),
'organization' => array('limit' => 1),
'department' => array('limit' => 1),
- 'gender' => array('limit' => 1),
- 'initials' => array('type' => 'text', 'size' => 6, 'limit' => 1, 'label' => 'kolab_addressbook.initials'),
'email' => array('subtypes' => null),
'phone' => array(),
- 'im' => array('limit' => 1, 'subtypes' => null),
- 'website' => array('limit' => 1, 'subtypes' => null),
'address' => array('limit' => 2, 'subtypes' => array('home','business')),
+ 'officelocation' => array('type' => 'text', 'size' => 40, 'limit' => 1, 'label' => 'kolab_addressbook.officelocation'),
+ 'website' => array('limit' => 1, 'subtypes' => null),
+ 'im' => array('limit' => 1, 'subtypes' => null),
+ 'gender' => array('limit' => 1),
+ 'initials' => array('type' => 'text', 'size' => 6, 'limit' => 1, 'label' => 'kolab_addressbook.initials'),
'birthday' => array('limit' => 1),
'anniversary' => array('limit' => 1),
- 'officelocation' => array('type' => 'text', 'size' => 40, 'limit' => 1, 'label' => 'kolab_addressbook.officelocation'),
'profession' => array('type' => 'text', 'size' => 40, 'limit' => 1, 'label' => 'kolab_addressbook.profession'),
'manager' => array('limit' => 1),
'assistant' => array('limit' => 1),
@@ -714,9 +714,19 @@ class rcube_kolab_contacts extends rcube_addressbook
$this->id2uid[$id] = $record['uid'];
}
- // TODO: sort data arrays according to desired list sorting
+ // sort data arrays according to desired list sorting
+ uasort($this->contacts, array($this, '_sort_contacts_comp'));
}
}
+
+
+ /**
+ * Callback function for sorting contacts
+ */
+ private function _sort_contacts_comp($a, $b)
+ {
+ return strcasecmp($a['name'], $b['name']);
+ }
/**
diff --git a/plugins/kolab_core/rcube_kolab.php b/plugins/kolab_core/rcube_kolab.php
index 4fadb23f4..a69a90365 100644
--- a/plugins/kolab_core/rcube_kolab.php
+++ b/plugins/kolab_core/rcube_kolab.php
@@ -15,6 +15,7 @@ require_once 'Horde/Perms.php';
class rcube_kolab
{
private static $horde_auth;
+ private static $ready = false;
/**
@@ -47,6 +48,7 @@ class rcube_kolab
'remote_addr' => $_SERVER['REMOTE_ADDR'],
);
Auth::setCredential('password', $pwd);
+ self::$ready = true;
}
NLS::setCharset('UTF-8');
@@ -76,7 +78,7 @@ class rcube_kolab
{
self::setup();
$kolab = Kolab_List::singleton();
- return $kolab->getByType($type);
+ return self::$ready ? $kolab->getByType($type) : array();
}
/**
@@ -90,7 +92,7 @@ class rcube_kolab
{
self::setup();
$kolab = Kolab_List::singleton();
- return $kolab->getFolder($folder)->getData($data_type);
+ return self::$ready ? $kolab->getFolder($folder)->getData($data_type) : null;
}
/**