diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2013-02-07 15:35:30 +0100 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2013-02-07 15:35:30 +0100 |
commit | 86552ffc8f0f76651747a1faaed9bbda6d015f98 (patch) | |
tree | 3b04710a00f648af084b869ed22002fa6ae60159 /program/steps | |
parent | ec2185a1cb2a0d412ab9e916618972bc4c70f68c (diff) |
Finish hierarchical groups browsing in LDAP address books; add according UI elements and styles to the skins; adapt habavior of the compose address book widget
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/addressbook/func.inc | 32 | ||||
-rw-r--r-- | program/steps/addressbook/list.inc | 5 | ||||
-rw-r--r-- | program/steps/addressbook/show.inc | 5 | ||||
-rw-r--r-- | program/steps/mail/list_contacts.inc | 29 |
4 files changed, 60 insertions, 11 deletions
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index f921c8cda..4d4bf2246 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -343,6 +343,8 @@ function rcmail_js_contacts_list($result, $prefix='') while ($row = $result->next()) { $row['CID'] = $row['ID']; + $row['email'] = reset(rcube_addressbook::get_col_values('email', $row, true)); + $source_id = $OUTPUT->get_env('source'); $a_row_cols = array(); $classes = array($row['_type'] ? $row['_type'] : 'person'); @@ -367,7 +369,7 @@ function rcmail_js_contacts_list($result, $prefix='') 'href' => '#list', 'rel' => $row['ID'], 'title' => rcube_label('listgroup'), - 'onclick' => sprintf("return %s.command('pushgroup',{'source':'%s','id':'%s'},this)", JS_OBJECT_NAME, $source_id, $row['CID']), + 'onclick' => sprintf("return %s.command('pushgroup',{'source':'%s','id':'%s'},this,event)", JS_OBJECT_NAME, $source_id, $row['CID']), ), '»'); } break; @@ -383,11 +385,25 @@ function rcmail_js_contacts_list($result, $prefix='') if ($row['readonly']) $classes[] = 'readonly'; - $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols, join(' ', $classes), $row); + $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols, join(' ', $classes), array_intersect_key($row, array('ID'=>1,'readonly'=>1,'_type'=>1,'email'=>1,'name'=>1))); } } +function rcmail_contacts_list_title($attrib) +{ + global $OUTPUT; + + $attrib += array('label' => 'contacts', 'id' => 'rcmabooklisttitle', 'tag' => 'span'); + unset($attrib['name']); + + $OUTPUT->add_gui_object('addresslist_title', $attrib['id']); + $OUTPUT->add_label('contacts'); + + return html::tag($attrib['tag'], $attrib, rcube_label($attrib['label']), html::$common_attrib); +} + + // similar function as /steps/settings/identities.inc::rcmail_identity_frame() function rcmail_contact_frame($attrib) { @@ -456,7 +472,7 @@ function rcmail_get_type_label($type) function rcmail_contact_form($form, $record, $attrib = null) { - global $RCMAIL, $CONFIG; + global $RCMAIL; // Allow plugins to modify contact form content $plugin = $RCMAIL->plugins->exec_hook('contact_form', array( @@ -465,7 +481,7 @@ function rcmail_contact_form($form, $record, $attrib = null) $form = $plugin['form']; $record = $plugin['record']; $edit_mode = $RCMAIL->action != 'show'; - $del_button = $attrib['deleteicon'] ? html::img(array('src' => $CONFIG['skin_path'] . $attrib['deleteicon'], 'alt' => rcube_label('delete'))) : rcube_label('delete'); + $del_button = $attrib['deleteicon'] ? html::img(array('src' => $RCMAIL->output->get_skin_file($attrib['deleteicon']), 'alt' => rcube_label('delete'))) : rcube_label('delete'); unset($attrib['deleteicon']); $out = ''; @@ -731,12 +747,15 @@ function rcmail_contact_form($form, $record, $attrib = null) function rcmail_contact_photo($attrib) { - global $SOURCE_ID, $CONTACTS, $CONTACT_COLTYPES, $RCMAIL, $CONFIG; + global $SOURCE_ID, $CONTACTS, $CONTACT_COLTYPES, $RCMAIL; if ($result = $CONTACTS->get_result()) $record = $result->first(); - $photo_img = $attrib['placeholder'] ? $CONFIG['skin_path'] . $attrib['placeholder'] : 'program/resources/blank.gif'; + $photo_img = $attrib['placeholder'] ? $RCMAIL->output->get_skin_file($attrib['placeholder']) : 'program/resources/blank.gif'; + if ($record['_type'] == 'group' && $attrib['placeholdergroup']) + $photo_img = $RCMAIL->output->get_skin_file($attrib['placeholdergroup']); + $RCMAIL->output->set_env('photo_placeholder', $photo_img); unset($attrib['placeholder']); @@ -820,6 +839,7 @@ $OUTPUT->add_handlers(array( 'directorylist' => 'rcmail_directory_list', // 'groupslist' => 'rcmail_contact_groups', 'addresslist' => 'rcmail_contacts_list', + 'addresslisttitle' => 'rcmail_contacts_list_title', 'addressframe' => 'rcmail_contact_frame', 'recordscountdisplay' => 'rcmail_rowcount_display', 'searchform' => array($OUTPUT, 'search_form') diff --git a/program/steps/addressbook/list.inc b/program/steps/addressbook/list.inc index 1bb28658b..6f3a3e0f3 100644 --- a/program/steps/addressbook/list.inc +++ b/program/steps/addressbook/list.inc @@ -81,6 +81,11 @@ else { $OUTPUT->show_message('contactsearchonly', 'notice'); $OUTPUT->command('command', 'advanced-search'); } + + if ($CONTACTS->group_id) { + $OUTPUT->command('set_group_prop', array('ID' => $CONTACTS->group_id) + + array_intersect_key((array)$CONTACTS->get_group($CONTACTS->group_id), array('name'=>1,'email'=>1))); + } } // update message count display diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc index 16be89f94..b5870f463 100644 --- a/program/steps/addressbook/show.inc +++ b/program/steps/addressbook/show.inc @@ -215,8 +215,11 @@ function rcmail_contact_record_groups($contact_id) $checkbox = new html_checkbox(array('name' => '_gid[]', 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly)); - foreach ($GROUPS as $group) { + foreach (array_merge($GROUPS, $members) 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']))); diff --git a/program/steps/mail/list_contacts.inc b/program/steps/mail/list_contacts.inc index 7e3b349cd..a48109fed 100644 --- a/program/steps/mail/list_contacts.inc +++ b/program/steps/mail/list_contacts.inc @@ -73,8 +73,11 @@ else { $CONTACTS->set_pagesize($page_size); $CONTACTS->set_page($page); + if ($group_id = get_input_value('_gid', RCUBE_INPUT_GPC)) { + $CONTACTS->set_group($group_id); + } // list groups of this source (on page one) - if ($CONTACTS->groups && $CONTACTS->list_page == 1) { + else if ($CONTACTS->groups && $CONTACTS->list_page == 1) { foreach ($CONTACTS->list_groups() as $group) { $CONTACTS->reset(); $CONTACTS->set_group($group['ID']); @@ -89,6 +92,19 @@ else { 'contactgroup' => html::span(array('title' => $email), Q($group['name']))), 'group'); } } + // make virtual groups clickable to list their members + else if ($group_prop['virtual']) { + $row_id = 'G'.$group['ID']; + $OUTPUT->command('add_contact_row', $row_id, array( + 'contactgroup' => html::a(array( + 'href' => '#list', + 'rel' => $row['ID'], + 'title' => rcube_label('listgroup'), + 'onclick' => sprintf("return %s.command('pushgroup',{'source':'%s','id':'%s'},this,event)", JS_OBJECT_NAME, $source, $group['ID']), + ), Q($group['name']) . ' ' . html::span('action', '»'))), + 'group', + array('ID' => $group['ID'], 'name' => $group['name'], 'virtual' => true)); + } // show group with count else if (($result = $CONTACTS->count()) && $result->count) { $row_id = 'E'.$group['ID']; @@ -97,10 +113,12 @@ else { 'contactgroup' => Q($group['name'] . ' (' . intval($result->count) . ')')), 'group'); } } + + $CONTACTS->reset(); + $CONTACTS->set_group(0); } // get contacts for this user - $CONTACTS->set_group(0); $result = $CONTACTS->list_records($afields); } } @@ -118,10 +136,13 @@ else if (!empty($result) && $result->count > 0) { foreach ($emails as $i => $email) { $row_id = $row['ID'].$i; $jsresult[$row_id] = format_email_recipient($email, $name); + $classname = $row['_type'] == 'group' ? 'group' : 'person'; + $keyname = $row['_type'] == 'group' ? 'contactgroup' : 'contact'; + $OUTPUT->command('add_contact_row', $row_id, array( - 'contact' => html::span(array('title' => $email), Q($name ? $name : $email) . + $keyname => html::span(array('title' => $email), Q($name ? $name : $email) . ($name && count($emails) > 1 ? ' ' . html::span('email', Q($email)) : '') - )), 'person'); + )), $classname); } } } |