From 41c0903a598da931b38f0482a040730c07302181 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Thu, 27 Jan 2011 13:03:40 +0000 Subject: [PATCH] Allow extensions to alter quicksearch terms and search format. r=mkanat. git-svn-id: svn://10.0.0.236/trunk@261850 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/Bugzilla/Hook.pm | 15 +++++++++++++++ .../bugzilla/Bugzilla/Search/Quicksearch.pm | 2 ++ .../bugzilla/extensions/Example/Extension.pm | 8 ++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index 01efca50358..854229122b2 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -7683 \ No newline at end of file +7684 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/Hook.pm b/mozilla/webtools/bugzilla/Bugzilla/Hook.pm index de46f9a25cc..cf81e9c7d07 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Hook.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Hook.pm @@ -1136,6 +1136,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/mozilla/webtools/bugzilla/Bugzilla/Search/Quicksearch.pm b/mozilla/webtools/bugzilla/Bugzilla/Search/Quicksearch.pm index b2151ba3a88..340421bbb7e 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Search/Quicksearch.pm +++ b/mozilla/webtools/bugzilla/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/mozilla/webtools/bugzilla/extensions/Example/Extension.pm b/mozilla/webtools/bugzilla/extensions/Example/Extension.pm index 14bf6df8732..f5641655956 100644 --- a/mozilla/webtools/bugzilla/extensions/Example/Extension.pm +++ b/mozilla/webtools/bugzilla/extensions/Example/Extension.pm @@ -649,6 +649,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) = @_;