From 3412e50b54e3daac8745234e21ab6e72be0ed165 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli <thomas@roundcube.net> Date: Wed, 04 Jun 2014 11:20:33 -0400 Subject: [PATCH] Fix attachment menu structure and aria-attributes --- program/steps/addressbook/search.inc | 75 ++++++++++++++++++++++--------------- 1 files changed, 45 insertions(+), 30 deletions(-) diff --git a/program/steps/addressbook/search.inc b/program/steps/addressbook/search.inc index ad1df97..bb22ec1 100644 --- a/program/steps/addressbook/search.inc +++ b/program/steps/addressbook/search.inc @@ -7,7 +7,10 @@ | This file is part of the Roundcube Webmail client | | Copyright (C) 2005-2011, The Roundcube Dev Team | | Copyright (C) 2011, Kolab Systems AG | - | Licensed under the GNU GPL | + | | + | Licensed under the GNU General Public License version 3 or | + | any later version with exceptions for skins & plugins. | + | See the README file for a full license statement. | | | | PURPOSE: | | Search action (and form) for address book contacts | @@ -16,14 +19,11 @@ | Author: Thomas Bruederli <roundcube@gmail.com> | | Author: Aleksander Machniak <machniak@kolabsys.com> | +-----------------------------------------------------------------------+ - - $Id: search.inc 456 2007-01-10 12:34:33Z thomasb $ - */ if ($RCMAIL->action == 'search-create') { - $id = get_input_value('_search', RCUBE_INPUT_POST); - $name = get_input_value('_name', RCUBE_INPUT_POST, true); + $id = rcube_utils::get_input_value('_search', rcube_utils::INPUT_POST); + $name = rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true); if (($params = $_SESSION['search_params']) && $params['id'] == $id) { @@ -46,7 +46,7 @@ if ($result) { $OUTPUT->show_message('savedsearchcreated', 'confirmation'); - $OUTPUT->command('insert_saved_search', Q($name), Q($result)); + $OUTPUT->command('insert_saved_search', rcube::Q($name), rcube::Q($result)); } else $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'savedsearchcreateerror', 'error'); @@ -55,7 +55,7 @@ } if ($RCMAIL->action == 'search-delete') { - $id = get_input_value('_sid', RCUBE_INPUT_POST); + $id = rcube_utils::get_input_value('_sid', rcube_utils::INPUT_POST); $plugin = $RCMAIL->plugins->exec_hook('saved_search_delete', array('id' => $id)); @@ -66,7 +66,10 @@ if ($result) { $OUTPUT->show_message('savedsearchdeleted', 'confirmation'); - $OUTPUT->command('remove_search_item', Q($id)); + $OUTPUT->command('remove_search_item', rcube::Q($id)); + // contact list will be cleared, clear also page counter + $OUTPUT->command('set_rowcount', $RCMAIL->gettext('nocontactsfound')); + $OUTPUT->set_env('pagecount', 0); } else $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'savedsearchdeleteerror', 'error'); @@ -85,10 +88,10 @@ function rcmail_contact_search() { - global $RCMAIL, $OUTPUT, $CONFIG, $SEARCH_MODS_DEFAULT; + global $RCMAIL, $OUTPUT, $SEARCH_MODS_DEFAULT, $PAGE_SIZE; $adv = isset($_POST['_adv']); - $sid = get_input_value('_sid', RCUBE_INPUT_GET); + $sid = rcube_utils::get_input_value('_sid', rcube_utils::INPUT_GET); // get search criteria from saved search if ($sid && ($search = $RCMAIL->user->get_search($sid))) { @@ -98,7 +101,7 @@ // get fields/values from advanced search form else if ($adv) { foreach (array_keys($_POST) as $key) { - $s = trim(get_input_value($key, RCUBE_INPUT_POST, true)); + $s = trim(rcube_utils::get_input_value($key, rcube_utils::INPUT_POST, true)); if (strlen($s) && preg_match('/^_search_([a-zA-Z0-9_-]+)$/', $key, $m)) { $search[] = $s; $fields[] = $m[1]; @@ -112,8 +115,8 @@ } // quick-search else { - $search = trim(get_input_value('_q', RCUBE_INPUT_GET, true)); - $fields = explode(',', get_input_value('_headers', RCUBE_INPUT_GET)); + $search = trim(rcube_utils::get_input_value('_q', rcube_utils::INPUT_GET, true)); + $fields = explode(',', rcube_utils::get_input_value('_headers', rcube_utils::INPUT_GET)); if (empty($fields)) { $fields = array_keys($SEARCH_MODS_DEFAULT); @@ -134,10 +137,15 @@ } } + // Values matching mode + $mode = (int) $RCMAIL->config->get('addressbook_search_mode'); + // get sources list $sources = $RCMAIL->get_address_sources(); $search_set = array(); $records = array(); + $sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name'); + $afields = $RCMAIL->config->get('contactlist_fields'); foreach ($sources as $s) { $source = $RCMAIL->get_address_book($s['id']); @@ -165,18 +173,18 @@ $source->set_pagesize(9999); // get contacts count - $result = $source->search($fields, $search, false, false); + $result = $source->search($fields, $search, $mode, false); if (!$result->count) { continue; } // get records - $result = $source->list_records(array('name', 'email')); + $result = $source->list_records($afields); while ($row = $result->next()) { $row['sourceid'] = $s['id']; - $key = $row['name'] . ':' . $row['sourceid']; + $key = rcube_addressbook::compose_contact_key($row, $sort_col); $records[$key] = $row; } @@ -192,8 +200,8 @@ $result = new rcube_result_set($count); // cut first-page records - if ($CONFIG['pagesize'] < $count) { - $records = array_slice($records, 0, $CONFIG['pagesize']); + if ($PAGE_SIZE < $count) { + $records = array_slice($records, 0, $PAGE_SIZE); } $result->records = array_values($records); @@ -222,16 +230,19 @@ // update message count display $OUTPUT->command('set_env', 'search_request', $search_request); - $OUTPUT->command('set_env', 'pagecount', ceil($result->count / $CONFIG['pagesize'])); + $OUTPUT->command('set_env', 'pagecount', ceil($result->count / $PAGE_SIZE)); $OUTPUT->command('set_rowcount', rcmail_get_rowcount_text($result)); // Re-set current source $OUTPUT->command('set_env', 'search_id', $sid); $OUTPUT->command('set_env', 'source', ''); $OUTPUT->command('set_env', 'group', ''); - // unselect currently selected directory/group - if (!$sid) + if (!$sid) { + // unselect currently selected directory/group $OUTPUT->command('unselect_directory'); + // enable "Save search" command + $OUTPUT->command('enable_command', 'search-create', true); + } $OUTPUT->command('update_group_commands'); // send response @@ -246,17 +257,17 @@ $form = array( 'main' => array( - 'name' => rcube_label('contactproperties'), + 'name' => $RCMAIL->gettext('properties'), 'content' => array( ), ), 'personal' => array( - 'name' => rcube_label('personalinfo'), + 'name' => $RCMAIL->gettext('personalinfo'), 'content' => array( ), ), 'other' => array( - 'name' => rcube_label('other'), + 'name' => $RCMAIL->gettext('other'), 'content' => array( ), ), @@ -286,14 +297,18 @@ if ($colprop['type'] != 'image' && !$colprop['nosearch']) { $ftype = $colprop['type'] == 'select' ? 'select' : 'text'; - $label = isset($colprop['label']) ? $colprop['label'] : rcube_label($col); + $label = isset($colprop['label']) ? $colprop['label'] : $RCMAIL->gettext($col); $category = $colprop['category'] ? $colprop['category'] : 'other'; - if ($ftype == 'text') + // load jquery UI datepicker for date fields + if ($colprop['type'] == 'date') + $colprop['class'] .= ($colprop['class'] ? ' ' : '') . 'datepicker'; + else if ($ftype == 'text') $colprop['size'] = $i_size; - $content = html::div('row', html::div('contactfieldlabel label', Q($label)) - . html::div('contactfieldcontent', rcmail_get_edit_field('search_'.$col, '', $colprop, $ftype))); + + $content = html::div('row', html::div('contactfieldlabel label', rcube::Q($label)) + . html::div('contactfieldcontent', rcube_output::get_edit_field('search_'.$col, '', $colprop, $ftype))); $form[$category]['content'][] = $content; } @@ -317,7 +332,7 @@ $content = html::div('contactfieldgroup', join("\n", $f['content'])); $out .= html::tag('fieldset', $attrib, - html::tag('legend', null, Q($f['name'])) + html::tag('legend', null, rcube::Q($f['name'])) . $content) . "\n"; } } -- Gitblit v1.9.1