summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/func.inc6
-rw-r--r--program/steps/addressbook/search.inc31
2 files changed, 27 insertions, 10 deletions
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index 8b4a9f10f..545f140bf 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -19,6 +19,8 @@
*/
+$SEARCH_MODS_DEFAULT = array('name'=>1, 'firstname'=>1, 'surname'=>1, 'email'=>1, '*'=>1);
+
// add list of address sources to client env
$js_list = $RCMAIL->get_address_sources();
@@ -39,7 +41,7 @@ if (!empty($_GET['_page']))
$CONTACTS->set_page(($_SESSION['page'] = intval($_GET['_page'])));
else
$CONTACTS->set_page(isset($_SESSION['page']) ?$_SESSION['page'] : 1);
-
+
if (!empty($_REQUEST['_gid']))
$CONTACTS->set_group(get_input_value('_gid', RCUBE_INPUT_GPC));
@@ -51,6 +53,8 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
$OUTPUT->set_env('source', $source ? $source : '0');
$OUTPUT->set_env('readonly', $CONTACTS->readonly, false);
if (!$OUTPUT->ajax_call) {
+ $search_mods = $RCMAIL->config->get('addressbook_search_mods', $SEARCH_MODS_DEFAULT);
+ $OUTPUT->set_env('search_mods', $search_mods);
$OUTPUT->set_env('address_sources', $js_list);
$OUTPUT->set_pagetitle(rcube_label('addressbook'));
}
diff --git a/program/steps/addressbook/search.inc b/program/steps/addressbook/search.inc
index 8d25a8fbc..fe7099fac 100644
--- a/program/steps/addressbook/search.inc
+++ b/program/steps/addressbook/search.inc
@@ -22,22 +22,35 @@
$CONTACTS->set_page(1);
$_SESSION['page'] = 1;
+// get input
$search = trim(get_input_value('_q', RCUBE_INPUT_GET, true));
-$search_request = md5('addr'.$search);
+$fields = explode(',', get_input_value('_headers', RCUBE_INPUT_GET));
+
+if (empty($fields)) {
+ $fields = $SEARCH_MODS_DEFAULT;
+}
+
+$search_request = md5('addr'.$search.implode($fields, ','));
+
+// update search_mods setting
+$search_mods = array_fill_keys($fields, 1);
+$RCMAIL->user->save_prefs(array('addressbook_search_mods' => $search_mods));
+
+if ($fields['all'] || count($fields) == count($SEARCH_MODS_DEFAULT)) {
+ $fields = '*';
+}
// get contacts for this user
-$result = $CONTACTS->search('*', $search);
+$result = $CONTACTS->search($fields, $search);
// save search settings in session
$_SESSION['search'][$search_request] = $CONTACTS->get_search_set();
-if ($result->count > 0)
-{
- // create javascript list
- rcmail_js_contacts_list($result);
+if ($result->count > 0) {
+ // create javascript list
+ rcmail_js_contacts_list($result);
}
-else
-{
+else {
$OUTPUT->show_message('nocontactsfound', 'notice');
}
@@ -45,6 +58,6 @@ else
$OUTPUT->set_env('search_request', $search_request);
$OUTPUT->set_env('pagecount', ceil($result->count / $CONTACTS->page_size));
$OUTPUT->command('set_rowcount', rcmail_get_rowcount_text());
-
+
// send response
$OUTPUT->send();