From 42b9ce64151f86e4f77d4b01b3fa36461ae9abcc Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 3 Jul 2013 12:00:25 +0200 Subject: Fix groups list in contact info page - get_record_groups() result is a ID=>Name hash and cannot be merged with list_groups() result --- program/lib/Roundcube/rcube_ldap.php | 8 ++++---- program/steps/addressbook/show.inc | 10 +++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/program/lib/Roundcube/rcube_ldap.php b/program/lib/Roundcube/rcube_ldap.php index 522c81d8b..29da13c13 100644 --- a/program/lib/Roundcube/rcube_ldap.php +++ b/program/lib/Roundcube/rcube_ldap.php @@ -1191,8 +1191,7 @@ class rcube_ldap extends rcube_addressbook // change the group membership of the contact if ($this->groups) { $group_ids = $this->get_record_groups($dn); - foreach ($group_ids as $group_id => $group_prop) - { + foreach (array_keys($group_ids) as $group_id) { $this->remove_from_group($group_id, $dn); $this->add_to_group($group_id, $newdn); } @@ -1257,7 +1256,7 @@ class rcube_ldap extends rcube_addressbook if ($this->groups) { $dn = self::dn_encode($dn); $group_ids = $this->get_record_groups($dn); - foreach ($group_ids as $group_id => $group_prop) { + foreach (array_keys($group_ids) as $group_id) { $this->remove_from_group($group_id, $dn); } } @@ -1879,8 +1878,9 @@ class rcube_ldap extends rcube_addressbook $entry['dn'] = $ldap_data->get_dn(); $group_name = $entry[$name_attr][0]; $group_id = self::dn_encode($entry['dn']); - $groups[$group_id] = array('ID' => $group_id, 'name' => $group_name, 'dn' => $entry['dn']); + $groups[$group_id] = $group_name; } + return $groups; } diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc index 63abc8c4b..950764bb1 100644 --- a/program/steps/addressbook/show.inc +++ b/program/steps/addressbook/show.inc @@ -207,17 +207,13 @@ function rcmail_contact_record_groups($contact_id) return ''; } - $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0)); - - $members = $CONTACTS->get_record_groups($contact_id); + $members = $CONTACTS->get_record_groups($contact_id); + $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0)); $checkbox = new html_checkbox(array('name' => '_gid[]', 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly)); - foreach (array_merge($GROUPS, $members) as $group) { + foreach ($GROUPS as $group) { $gid = $group['ID']; - if ($seen[$gid]++) - continue; - $table->add(null, $checkbox->show($members[$gid] ? $gid : null, array('value' => $gid, 'id' => 'ff_gid' . $gid))); $table->add(null, html::label('ff_gid' . $gid, Q($group['name']))); -- cgit v1.2.3