]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 524669: Allow every simple field in fielddefs to be specified directly in search...
authormkanat%bugzilla.org <>
Mon, 9 Nov 2009 19:09:03 +0000 (19:09 +0000)
committermkanat%bugzilla.org <>
Mon, 9 Nov 2009 19:09:03 +0000 (19:09 +0000)
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=gerv, a=mkanat

Bugzilla/Constants.pm
Bugzilla/Search.pm
query.cgi

index 6c2e648bf2e524d77dd95fe22af29b0f398c4d2a..6e22eb79338a4ef802ff724570c4b2fef0e8de8e 100644 (file)
@@ -126,6 +126,8 @@ use File::Basename;
     FIELD_TYPE_BUG_ID
     FIELD_TYPE_BUG_URLS
 
+    TIMETRACKING_FIELDS
+
     USAGE_MODE_BROWSER
     USAGE_MODE_CMDLINE
     USAGE_MODE_XMLRPC
@@ -358,6 +360,12 @@ use constant FIELD_TYPE_DATETIME  => 5;
 use constant FIELD_TYPE_BUG_ID  => 6;
 use constant FIELD_TYPE_BUG_URLS => 7;
 
+# The fields from fielddefs that are blocked from non-timetracking users.
+# work_time is sometimes called actual_time.
+use constant TIMETRACKING_FIELDS =>
+    qw(estimated_time remaining_time work_time actual_time
+       percentage_complete deadline);
+
 # The maximum number of days a token will remain valid.
 use constant MAX_TOKEN_AGE => 3;
 # How many days a logincookie will remain valid if not used.
index 9ba7a8c42f9e727952d249f2edbcc82eb9b8acf9..fa18a0e787032792f17a61edb9506f4771d67ef4 100644 (file)
@@ -328,27 +328,30 @@ sub init {
         }
     }
     
-    my @legal_fields = ("product", "version", "assigned_to", "reporter", 
-                        "component", "classification", "target_milestone",
-                        "bug_group");
-
-    # Include custom select fields.
-    push(@legal_fields, map { $_->name } @select_fields);
-    push(@legal_fields, map { $_->name } @multi_select_fields);
-
-    foreach my $field ($params->param()) {
-        if (lsearch(\@legal_fields, $field) != -1) {
-            push(@specialchart, [$field, "anyexact",
-                                 join(',', $params->param($field))]);
+    # All fields that don't have a . in their name should be specifyable
+    # in the URL directly.
+    my @legal_fields = grep { $_->name !~ /\./ } Bugzilla->get_fields;
+    if (!$user->is_timetracker) {
+        foreach my $field (TIMETRACKING_FIELDS) {
+            @legal_fields = grep { $_->name ne $field } @legal_fields;
         }
     }
 
-    if ($params->param('keywords')) {
-        my $t = $params->param('keywords_type');
-        if (!$t || $t eq "or") {
-            $t = "anywords";
+    foreach my $field ($params->param()) {
+        if (grep { $_->name eq $field } @legal_fields) {
+            my $type = $params->param("${field}_type");
+            if (!$type) {
+                if ($field eq 'keywords') {
+                    $type = 'anywords';
+                }
+                else {
+                    $type = 'anyexact';
+                }
+            }
+            $type = 'matches' if $field eq 'content';
+            push(@specialchart, [$field, $type,
+                                 join(',', $params->param($field))]);
         }
-        push(@specialchart, ["keywords", $t, $params->param('keywords')]);
     }
 
     foreach my $id ("1", "2") {
@@ -574,10 +577,6 @@ sub init {
         }
     }
 
-    if (defined $params->param('content')) {
-        push(@specialchart, ['content', 'matches', $params->param('content')]);
-    }
-
     my $multi_fields = join('|', map($_->name, @multi_select_fields));
 
     my $chartid;
index d07773bde342cfb113157c0349860a2f9bda0c0b..fd18bab67a08ea1a2968f0a88cc95418ceac642a 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -266,10 +266,8 @@ $vars->{'resolution'} = Bugzilla::Field->new({name => 'resolution'})->legal_valu
 my @fields = Bugzilla->get_fields({ obsolete => 0 });
 
 # If we're not in the time-tracking group, exclude time-tracking fields.
-if (!Bugzilla->user->in_group(Bugzilla->params->{'timetrackinggroup'})) {
-    foreach my $tt_field (qw(estimated_time remaining_time work_time
-                             percentage_complete deadline))
-    {
+if (!Bugzilla->user->is_timetracker) {
+    foreach my $tt_field (TIMETRACKING_FIELDS) {
         @fields = grep($_->name ne $tt_field, @fields);
     }
 }