From: Gervase Markham Date: Thu, 27 Jan 2011 12:57:15 +0000 (+0000) Subject: Allow extensions to alter quicksearch terms and search format. r=mkanat. X-Git-Tag: bugzilla-4.0~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a31145ec99623133f2120a4a9ad597214e499682;p=thirdparty%2Fbugzilla.git Allow extensions to alter quicksearch terms and search format. r=mkanat. https://bugzilla.mozilla.org/show_bug.cgi?id=621878 --- diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index a08e160a89..14b27b48d5 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -1103,6 +1103,21 @@ Params: =back +=head2 quicksearch_map + +This hook allows you to alter the Quicksearch syntax to include e.g. special +searches for custom fields you have. + +Params: + +=over + +=item C - a hash where the key is the name you want to use in +Quicksearch, and the value is the name from the C table that you +want it to map to. You can modify existing mappings or add new ones. + +=back + =head2 sanitycheck_check This hook allows for extra sanity checks to be added, for use by diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index f24bf20755..c501ed3ba8 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -101,6 +101,8 @@ sub FIELD_MAP { status_whiteboard cclist_accessible reporter_accessible)}; + Bugzilla::Hook::process('quicksearch_map', {'map' => \%full_map} ); + $cache->{quicksearch_fields} = \%full_map; return $cache->{quicksearch_fields}; diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm index 0e4cf0d520..9162ccd234 100644 --- a/extensions/Example/Extension.pm +++ b/extensions/Example/Extension.pm @@ -627,6 +627,14 @@ sub product_end_of_create { } } +sub quicksearch_map { + my ($self, $args) = @_; + my $map = $args->{'map'}; + + # This demonstrates adding a shorter alias for a long custom field name. + $map->{'impact'} = $map->{'cf_long_field_name_for_impact_field'}; +} + sub sanitycheck_check { my ($self, $args) = @_;