Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
e0fbbde6
Commit
e0fbbde6
authored
Sep 02, 2014
by
Simon Green
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 281791 - Add ability to change flags in "change several bugs at once"
r=glob, a=sgreen
parent
92b5ff14
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
183 additions
and
0 deletions
+183
-0
Flag.pm
Bugzilla/Flag.pm
+111
-0
Search.pm
Bugzilla/Search.pm
+1
-0
buglist.cgi
buglist.cgi
+37
-0
process_bug.cgi
process_bug.cgi
+11
-0
list.html.tmpl
template/en/default/flag/list.html.tmpl
+16
-0
edit-multiple.html.tmpl
template/en/default/list/edit-multiple.html.tmpl
+7
-0
No files found.
Bugzilla/Flag.pm
View file @
e0fbbde6
...
@@ -932,6 +932,117 @@ sub extract_flags_from_cgi {
...
@@ -932,6 +932,117 @@ sub extract_flags_from_cgi {
=over
=over
=item C<multi_extract_flags_from_cgi($bug, $hr_vars)>
Checks whether or not there are new flags to create and returns an
array of hashes. This array is then passed to Flag::create(). This differs
from the previous sub-routine as it is called for changing multiple bugs
=back
=cut
sub
multi_extract_flags_from_cgi
{
my
(
$class
,
$bug
,
$vars
,
$skip
)
=
@_
;
my
$cgi
=
Bugzilla
->
cgi
;
my
$match_status
=
Bugzilla::User::
match_field
({
'^requestee(_type)?-(\d+)$'
=>
{
'type'
=>
'multi'
},
},
undef
,
$skip
);
$vars
->
{
'match_field'
}
=
'requestee'
;
if
(
$match_status
==
USER_MATCH_FAILED
)
{
$vars
->
{
'message'
}
=
'user_match_failed'
;
}
elsif
(
$match_status
==
USER_MATCH_MULTIPLE
)
{
$vars
->
{
'message'
}
=
'user_match_multiple'
;
}
# Extract a list of flag type IDs from field names.
my
@flagtype_ids
=
map
(
/^flag_type-(\d+)$/
?
$1
:
(),
$cgi
->
param
());
my
(
@new_flags
,
@flags
);
# Get a list of active flag types available for this product/component.
my
$flag_types
=
Bugzilla::FlagType::
match
(
{
'product_id'
=>
$bug
->
{
'product_id'
},
'component_id'
=>
$bug
->
{
'component_id'
},
'is_active'
=>
1
});
foreach
my
$flagtype_id
(
@flagtype_ids
)
{
# Checks if there are unexpected flags for the product/component.
if
(
!
scalar
(
grep
{
$_
->
id
==
$flagtype_id
}
@$flag_types
))
{
$vars
->
{
'message'
}
=
'unexpected_flag_types'
;
last
;
}
}
foreach
my
$flag_type
(
@$flag_types
)
{
my
$type_id
=
$flag_type
->
id
;
# Bug flags are only valid for bugs
next
unless
(
$flag_type
->
target_type
eq
'bug'
);
# We are only interested in flags the user tries to create.
next
unless
scalar
(
grep
{
$_
==
$type_id
}
@flagtype_ids
);
# Get the flags of this type already set for this bug.
my
$current_flags
=
$class
->
match
(
{
'type_id'
=>
$type_id
,
'target_type'
=>
'bug'
,
'bug_id'
=>
$bug
->
bug_id
});
# We will update existing flags (instead of creating new ones)
# if the flag exists and the user has not chosen the 'always add'
# option
my
$update
=
scalar
(
@$current_flags
)
&&
!
$cgi
->
param
(
"flags_add-$type_id"
);
my
$status
=
$cgi
->
param
(
"flag_type-$type_id"
);
trick_taint
(
$status
);
my
@logins
=
$cgi
->
param
(
"requestee_type-$type_id"
);
if
(
$status
eq
"?"
&&
scalar
(
@logins
))
{
foreach
my
$login
(
@logins
)
{
if
(
$update
)
{
foreach
my
$current_flag
(
@$current_flags
)
{
push
(
@flags
,
{
id
=>
$current_flag
->
id
,
status
=>
$status
,
requestee
=>
$login
,
skip_roe
=>
$skip
});
}
}
else
{
push
(
@new_flags
,
{
type_id
=>
$type_id
,
status
=>
$status
,
requestee
=>
$login
,
skip_roe
=>
$skip
});
}
last
unless
$flag_type
->
is_multiplicable
;
}
}
else
{
if
(
$update
)
{
foreach
my
$current_flag
(
@$current_flags
)
{
push
(
@flags
,
{
id
=>
$current_flag
->
id
,
status
=>
$status
});
}
}
else
{
push
(
@new_flags
,
{
type_id
=>
$type_id
,
status
=>
$status
});
}
}
}
# Return the list of flags to update and/or to create.
return
(
\
@flags
,
\
@new_flags
);
}
=pod
=over
=item C<notify($flag, $old_flag, $object, $timestamp)>
=item C<notify($flag, $old_flag, $object, $timestamp)>
Sends an email notification about a flag being created, fulfilled
Sends an email notification about a flag being created, fulfilled
...
...
Bugzilla/Search.pm
View file @
e0fbbde6
...
@@ -647,6 +647,7 @@ sub COLUMNS {
...
@@ -647,6 +647,7 @@ sub COLUMNS {
foreach
my
$col
(
@id_fields
)
{
foreach
my
$col
(
@id_fields
)
{
$special_sql
{
$col
}
=
"map_${col}.name"
;
$special_sql
{
$col
}
=
"map_${col}.name"
;
$columns
{
"${col}_id"
}{
name
}
=
"bugs.${col}_id"
;
}
}
# Do the actual column-getting from fielddefs, now.
# Do the actual column-getting from fielddefs, now.
...
...
buglist.cgi
View file @
e0fbbde6
...
@@ -510,6 +510,37 @@ if (grep('relevance', @displaycolumns) && !$fulltext) {
...
@@ -510,6 +510,37 @@ if (grep('relevance', @displaycolumns) && !$fulltext) {
@displaycolumns
=
grep
(
$_
ne
'relevance'
,
@displaycolumns
);
@displaycolumns
=
grep
(
$_
ne
'relevance'
,
@displaycolumns
);
}
}
sub
_get_common_flag_types
{
my
$component_ids
=
shift
;
# Get all the different components in the bug list
my
$components
=
Bugzilla::
Component
->
new_from_list
(
$component_ids
);
my
%
flag_types
;
my
@flag_types_ids
;
foreach
my
$component
(
@$components
)
{
foreach
my
$flag_type
(
@
{
$component
->
flag_types
->
{
'bug'
}})
{
push
@flag_types_ids
,
$flag_type
->
id
;
$flag_types
{
$flag_type
->
id
}
=
$flag_type
;
}
}
# We only want flags that appear in all components
my
%
common_flag_types
;
foreach
my
$id
(
keys
%
flag_types
)
{
my
$flag_type_count
=
scalar
grep
{
$_
==
$id
}
@flag_types_ids
;
$common_flag_types
{
$id
}
=
$flag_types
{
$id
}
if
$flag_type_count
==
scalar
@$components
;
}
# We only show flags that a user has request or set rights on
my
@show_flag_types
=
grep
{
$user
->
can_request_flag
(
$_
)
||
$user
->
can_set_flag
(
$_
)
}
values
%
common_flag_types
;
my
$any_flags_requesteeble
=
grep
(
$_
->
is_requesteeble
,
@show_flag_types
);
return
(
\
@show_flag_types
,
$any_flags_requesteeble
);
}
################################################################################
################################################################################
# Select Column Determination
# Select Column Determination
...
@@ -551,6 +582,7 @@ foreach my $col (@displaycolumns) {
...
@@ -551,6 +582,7 @@ foreach my $col (@displaycolumns) {
# has for modifying the bugs.
# has for modifying the bugs.
if
(
$dotweak
)
{
if
(
$dotweak
)
{
push
(
@selectcolumns
,
"bug_status"
)
if
!
grep
(
$_
eq
'bug_status'
,
@selectcolumns
);
push
(
@selectcolumns
,
"bug_status"
)
if
!
grep
(
$_
eq
'bug_status'
,
@selectcolumns
);
push
(
@selectcolumns
,
"component_id"
)
if
!
grep
(
$_
eq
'component_id'
,
@selectcolumns
);
}
}
if
(
$format
->
{
'extension'
}
eq
'ics'
)
{
if
(
$format
->
{
'extension'
}
eq
'ics'
)
{
...
@@ -756,6 +788,7 @@ my $time_info = { 'estimated_time' => 0,
...
@@ -756,6 +788,7 @@ my $time_info = { 'estimated_time' => 0,
my
$bugowners
=
{};
my
$bugowners
=
{};
my
$bugproducts
=
{};
my
$bugproducts
=
{};
my
$bugcomponentids
=
{};
my
$bugcomponents
=
{};
my
$bugcomponents
=
{};
my
$bugstatuses
=
{};
my
$bugstatuses
=
{};
my
@bugidlist
;
my
@bugidlist
;
...
@@ -789,6 +822,7 @@ foreach my $row (@$data) {
...
@@ -789,6 +822,7 @@ foreach my $row (@$data) {
# Record the assignee, product, and status in the big hashes of those things.
# Record the assignee, product, and status in the big hashes of those things.
$bugowners
->
{
$bug
->
{
'assigned_to'
}}
=
1
if
$bug
->
{
'assigned_to'
};
$bugowners
->
{
$bug
->
{
'assigned_to'
}}
=
1
if
$bug
->
{
'assigned_to'
};
$bugproducts
->
{
$bug
->
{
'product'
}}
=
1
if
$bug
->
{
'product'
};
$bugproducts
->
{
$bug
->
{
'product'
}}
=
1
if
$bug
->
{
'product'
};
$bugcomponentids
->
{
$bug
->
{
'component_id'
}}
=
1
if
$bug
->
{
'component_id'
};
$bugcomponents
->
{
$bug
->
{
'component'
}}
=
1
if
$bug
->
{
'component'
};
$bugcomponents
->
{
$bug
->
{
'component'
}}
=
1
if
$bug
->
{
'component'
};
$bugstatuses
->
{
$bug
->
{
'bug_status'
}}
=
1
if
$bug
->
{
'bug_status'
};
$bugstatuses
->
{
$bug
->
{
'bug_status'
}}
=
1
if
$bug
->
{
'bug_status'
};
...
@@ -956,6 +990,9 @@ if ($dotweak && scalar @bugs) {
...
@@ -956,6 +990,9 @@ if ($dotweak && scalar @bugs) {
$vars
->
{
'severities'
}
=
get_legal_field_values
(
'bug_severity'
);
$vars
->
{
'severities'
}
=
get_legal_field_values
(
'bug_severity'
);
$vars
->
{
'resolutions'
}
=
get_legal_field_values
(
'resolution'
);
$vars
->
{
'resolutions'
}
=
get_legal_field_values
(
'resolution'
);
(
$vars
->
{
'flag_types'
},
$vars
->
{
any_flags_requesteeble
})
=
_get_common_flag_types
([
keys
%
$bugcomponentids
]);
# Convert bug statuses to their ID.
# Convert bug statuses to their ID.
my
@bug_statuses
=
map
{
$dbh
->
quote
(
$_
)}
keys
%
$bugstatuses
;
my
@bug_statuses
=
map
{
$dbh
->
quote
(
$_
)}
keys
%
$bugstatuses
;
my
$bug_status_ids
=
my
$bug_status_ids
=
...
...
process_bug.cgi
View file @
e0fbbde6
...
@@ -358,6 +358,17 @@ if (defined $cgi->param('id')) {
...
@@ -358,6 +358,17 @@ if (defined $cgi->param('id')) {
$first_bug
->
add_tag
(
$_
)
foreach
@$tags_added
;
$first_bug
->
add_tag
(
$_
)
foreach
@$tags_added
;
}
}
}
}
else
{
# Update flags on multiple bugs. The cgi params are slightly different
# than on a single bug, so we need to call a different sub. We also
# need to call this per bug, since we might be updating a flag in one
# bug, but adding it to a second bug
foreach
my
$b
(
@bug_objects
)
{
my
(
$flags
,
$new_flags
)
=
Bugzilla::
Flag
->
multi_extract_flags_from_cgi
(
$b
,
$vars
);
$b
->
set_flags
(
$flags
,
$new_flags
);
}
}
##############################
##############################
# Do Actual Database Updates #
# Do Actual Database Updates #
...
...
template/en/default/flag/list.html.tmpl
View file @
e0fbbde6
...
@@ -119,6 +119,9 @@
...
@@ -119,6 +119,9 @@
class="flag_select flag_type-[% type.id %]"
class="flag_select flag_type-[% type.id %]"
[% IF !can_edit_flag %] disabled="disabled"[% END %]>
[% IF !can_edit_flag %] disabled="disabled"[% END %]>
[%# Only display statuses the user is allowed to set. %]
[%# Only display statuses the user is allowed to set. %]
[% IF edit_multiple_bugs %]
<option value="--do_not_change--">--do_not_change--</option>
[% END %]
[% IF !flag || (can_edit_flag && user.can_request_flag(type)) || flag.setter_id == user.id %]
[% IF !flag || (can_edit_flag && user.can_request_flag(type)) || flag.setter_id == user.id %]
<option value="X"></option>
<option value="X"></option>
[% END %]
[% END %]
...
@@ -168,6 +171,19 @@
...
@@ -168,6 +171,19 @@
[% END %]
[% END %]
</td>
</td>
[% END %]
[% END %]
<td>
[% IF type.is_multiplicable && edit_multiple_bugs %]
<input type="checkbox"
name="flags_add-[% type.id %]"
id="flags_add-[% type.id %]">
<label for="flags_add-[% type.id %]">
<a class="field_help_link"
title="If ticked, always create a new flag. Leaving it unchecked will update existing flag(s) and add a new flag if it does not exist">
Always add?
</a>
</label>
[% END %]
<td>
</tr>
</tr>
</tbody>
</tbody>
[% END %]
[% END %]
template/en/default/list/edit-multiple.html.tmpl
View file @
e0fbbde6
...
@@ -321,6 +321,13 @@
...
@@ -321,6 +321,13 @@
</script>
</script>
[% END %]
[% END %]
[% IF flag_types %]
<b><label for="flags">Flags:</label></b><br>
[% PROCESS "flag/list.html.tmpl"
edit_multiple_bugs = 1
flag_no_header = 1 %]
[% END %]
[% Hook.process('before_groups') %]
[% Hook.process('before_groups') %]
[% IF groups.size > 0 %]
[% IF groups.size > 0 %]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment