Commit fcccff08 authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 574556: Refactor Search.pm so that we're not doing $$some_var everywhere.

Instead, we pass around a hashref and update the hashref. This patch also includes some cleanup for bugs surrounding percentage_complete, attachments.isobsolete, attachments.ispatch, and owner_idle_time. r=mkanat, a=mkanat
parent 0e8eb403
...@@ -1632,8 +1632,7 @@ sub _check_keywords { ...@@ -1632,8 +1632,7 @@ sub _check_keywords {
my %keywords; my %keywords;
foreach my $keyword (@$keyword_array) { foreach my $keyword (@$keyword_array) {
next unless $keyword; next unless $keyword;
my $obj = new Bugzilla::Keyword({ name => $keyword }); my $obj = Bugzilla::Keyword->check($keyword);
ThrowUserError("unknown_keyword", { keyword => $keyword }) if !$obj;
$keywords{$obj->id} = $obj; $keywords{$obj->id} = $obj;
} }
return [values %keywords]; return [values %keywords];
......
...@@ -185,6 +185,16 @@ sub products { ...@@ -185,6 +185,16 @@ sub products {
#### Methods #### #### Methods ####
############################### ###############################
sub check_members_are_visible {
my $self = shift;
my $user = Bugzilla->user;
return if !Bugzilla->params->{'usevisibilitygroups'};
my $is_visible = grep { $_->id == $_ } @{ $user->visible_groups_inherited };
if (!$is_visible) {
ThrowUserError('group_not_visible', { group => $self });
}
}
sub set_description { $_[0]->set('description', $_[1]); } sub set_description { $_[0]->set('description', $_[1]); }
sub set_is_active { $_[0]->set('isactive', $_[1]); } sub set_is_active { $_[0]->set('isactive', $_[1]); }
sub set_name { $_[0]->set('name', $_[1]); } sub set_name { $_[0]->set('name', $_[1]); }
...@@ -407,25 +417,6 @@ sub create { ...@@ -407,25 +417,6 @@ sub create {
return $group; return $group;
} }
sub ValidateGroupName {
my ($name, @users) = (@_);
my $dbh = Bugzilla->dbh;
my $query = "SELECT id FROM groups " .
"WHERE name = ?";
if (Bugzilla->params->{'usevisibilitygroups'}) {
my @visible = (-1);
foreach my $user (@users) {
$user && push @visible, @{$user->visible_groups_direct};
}
my $visible = join(', ', @visible);
$query .= " AND id IN($visible)";
}
my $sth = $dbh->prepare($query);
$sth->execute($name);
my ($ret) = $sth->fetchrow_array();
return $ret;
}
############################### ###############################
### Validators ### ### Validators ###
############################### ###############################
...@@ -486,7 +477,6 @@ Bugzilla::Group - Bugzilla group class. ...@@ -486,7 +477,6 @@ Bugzilla::Group - Bugzilla group class.
my $icon_url = $group->icon_url; my $icon_url = $group->icon_url;
my $is_active_bug_group = $group->is_active_bug_group; my $is_active_bug_group = $group->is_active_bug_group;
my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users);
my @groups = Bugzilla::Group->get_all; my @groups = Bugzilla::Group->get_all;
=head1 DESCRIPTION =head1 DESCRIPTION
...@@ -506,24 +496,15 @@ normally does, this function also makes the new group be inherited ...@@ -506,24 +496,15 @@ normally does, this function also makes the new group be inherited
by the C<admin> group. That is, the C<admin> group will automatically by the C<admin> group. That is, the C<admin> group will automatically
be a member of this group. be a member of this group.
=item C<ValidateGroupName($name, @users)>
Description: ValidateGroupName checks to see if ANY of the users
in the provided list of user objects can see the
named group.
Params: $name - String with the group name.
@users - An array with Bugzilla::User objects.
Returns: It returns the group id if successful
and undef otherwise.
=back
=head1 METHODS =head1 METHODS
=over =over
=item C<check_members_are_visible>
Throws an error if this group is not visible (according to
visibility groups) to the currently-logged-in user.
=item C<check_remove> =item C<check_remove>
=over =over
......
...@@ -184,10 +184,6 @@ ...@@ -184,10 +184,6 @@
'[% field.description FILTER html %]' ([% field.name FILTER html %]) '[% field.description FILTER html %]' ([% field.name FILTER html %])
is not a custom field. is not a custom field.
[% ELSIF error == "field_type_mismatch" %]
Cannot seem to handle <code>[% field FILTER html %]</code>
and <code>[% type FILTER html %]</code> together.
[% ELSIF error == "field_type_not_specified" %] [% ELSIF error == "field_type_not_specified" %]
[% title = "Field Type Not Specified" %] [% title = "Field Type Not Specified" %]
You must specify a type when creating a custom field. You must specify a type when creating a custom field.
......
...@@ -744,11 +744,15 @@ ...@@ -744,11 +744,15 @@
[% title = "Group not specified" %] [% title = "Group not specified" %]
No group was specified. No group was specified.
[% ELSIF error == "group_not_visible" %]
[% title = "Group Not Allowed" %]
You are not allowed to see members of the [% group.name FILTER html %]
group.
[% ELSIF error == "system_group_not_deletable" %] [% ELSIF error == "system_group_not_deletable" %]
[% title = "System Groups not deletable" %] [% title = "System Groups not deletable" %]
<em>[% name FILTER html %]</em> is a system group. <em>[% name FILTER html %]</em> is a system group.
This group cannot be deleted. This group cannot be deleted.
[% ELSIF error == "group_unknown" %] [% ELSIF error == "group_unknown" %]
[% title = "Unknown Group" %] [% title = "Unknown Group" %]
The group [% name FILTER html %] does not exist. Please specify The group [% name FILTER html %] does not exist. Please specify
...@@ -1288,6 +1292,9 @@ ...@@ -1288,6 +1292,9 @@
[% IF class == "Bugzilla::User" %] [% IF class == "Bugzilla::User" %]
Either you mis-typed the name or that user has not yet registered Either you mis-typed the name or that user has not yet registered
for a [% terms.Bugzilla %] account. for a [% terms.Bugzilla %] account.
[% ELSIF class == "Bugzilla::Keyword" %]
The legal keyword names are <a href="describekeywords.cgi">listed
here</a>.
[% END %] [% END %]
[% ELSIF error == "old_password_incorrect" %] [% ELSIF error == "old_password_incorrect" %]
...@@ -1477,6 +1484,12 @@ ...@@ -1477,6 +1484,12 @@
and the "matches" search can only be used with the "content" and the "matches" search can only be used with the "content"
field. field.
[% ELSIF error == "search_field_operator_invalid" %]
[% terms.Bugzilla %] does not support using the
"[%+ field_descs.$field FILTER html %]" ([% field FILTER html %])
field with the "[% search_descs.$operator %]" ([% operator FILTER html %])
search type.
[% ELSIF error == "series_already_exists" %] [% ELSIF error == "series_already_exists" %]
[% title = "Series Already Exists" %] [% title = "Series Already Exists" %]
[% docslinks = {'reporting.html' => 'Reporting'} %] [% docslinks = {'reporting.html' => 'Reporting'} %]
...@@ -1562,11 +1575,6 @@ ...@@ -1562,11 +1575,6 @@
I could not figure out what you wanted to do. I could not figure out what you wanted to do.
[% END %] [% END %]
[% ELSIF error == "unknown_keyword" %]
[% title = "Unknown Keyword" %]
<code>[% keyword FILTER html %]</code> is not a known keyword.
The legal keyword names are <a href="describekeywords.cgi">listed here</a>.
[% ELSIF error == "unknown_tab" %] [% ELSIF error == "unknown_tab" %]
[% title = "Unknown Tab" %] [% title = "Unknown Tab" %]
<code>[% current_tab_name FILTER html %]</code> is not a legal tab name. <code>[% current_tab_name FILTER html %]</code> is not a legal tab name.
...@@ -1759,6 +1767,8 @@ ...@@ -1759,6 +1767,8 @@
field field
[% ELSIF class == "Bugzilla::Group" %] [% ELSIF class == "Bugzilla::Group" %]
group group
[% ELSIF class == "Bugzilla::Keyword" %]
keyword
[% ELSIF class == "Bugzilla::Product" %] [% ELSIF class == "Bugzilla::Product" %]
product product
[% ELSIF class == "Bugzilla::Search::Recent" %] [% ELSIF class == "Bugzilla::Search::Recent" %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment