Commit 1879703e authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 365890: Searches shared by users with bless rights are in the footer by…

Bug 365890: Searches shared by users with bless rights are in the footer by default, with no warning - Patch by Teemu Mannermaa <wicked@sci.fi> r/a=LpSolit
parent 1b984c11
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
title = "User Preferences" title = "User Preferences"
subheader = filtered_login subheader = filtered_login
style_urls = ['skins/standard/admin.css'] style_urls = ['skins/standard/admin.css']
javascript_urls = ['js/util.js']
%] %]
[% tabs = [{ name => "settings", label => "General Preferences", [% tabs = [{ name => "settings", label => "General Preferences",
......
...@@ -22,8 +22,25 @@ ...@@ -22,8 +22,25 @@
[%# INTERFACE: [%# INTERFACE:
# queryshare_groups: list of groups the user may share queries with # queryshare_groups: list of groups the user may share queries with
# (id, name). # (id, name).
# bless_group_ids: list of group ids the user may bless.
#%] #%]
[% IF user.can_bless %]
<script type="text/javascript"><!--
function update_checkbox(group) {
var bless_groups = [[% bless_group_ids.join(",") FILTER js %]];
var checkbox = document.getElementById(group.name.replace(/share_(\d+)/, "force_$1"));
if (bz_isValueInArray(bless_groups, group.value)) {
checkbox.disabled = false;
} else {
checkbox.disabled = true;
checkbox.checked = false;
}
} //-->
</script>
[% END %]
<p>Your saved searches are as follows:</p> <p>Your saved searches are as follows:</p>
<blockquote> <blockquote>
...@@ -103,7 +120,8 @@ ...@@ -103,7 +120,8 @@
</td> </td>
[% IF may_share %] [% IF may_share %]
<td> <td>
<select name="share_[% q.id FILTER html %]"> <select name="share_[% q.id FILTER html %]"
[% IF user.can_bless %] onchange="update_checkbox(this);"[% END %]>
<option value="">Don't share</option> <option value="">Don't share</option>
[% FOREACH group = queryshare_groups %] [% FOREACH group = queryshare_groups %]
<option value="[% group.id %]" <option value="[% group.id %]"
...@@ -112,6 +130,14 @@ ...@@ -112,6 +130,14 @@
>[% group.name FILTER html %]</option> >[% group.name FILTER html %]</option>
[% END %] [% END %]
</select> </select>
[% IF user.can_bless %]
<input type="checkbox" id="force_[% q.id FILTER html %]"
name="force_[% q.id FILTER html %]" value="1"
[% " disabled"
IF !bless_group_ids.grep("^$q.shared_with_group.id\$").0
%]>
<label for="force_[% q.id FILTER html %]">Add to footer</label>
[% END %]
[% IF q.shared_with_users %] [% IF q.shared_with_users %]
(shared with [% q.shared_with_users FILTER html %] (shared with [% q.shared_with_users FILTER html %]
[%+ q.shared_with_users > 1 ? "users" : "user" %]) [%+ q.shared_with_users > 1 ? "users" : "user" %])
...@@ -121,6 +147,11 @@ ...@@ -121,6 +147,11 @@
</tr> </tr>
[% END %] [% END %]
</table> </table>
[% IF user.can_bless %]
<p>Note that for every search that has the "Add to footer" selected, a
link to the shared search is added to the footer of every user that is
a direct member of the group at the time you click Submit Changes.</p>
[% END %]
</blockquote> </blockquote>
<p>You may use these searches saved and shared by others:</p> <p>You may use these searches saved and shared by others:</p>
......
...@@ -399,6 +399,7 @@ sub DoSavedSearches { ...@@ -399,6 +399,7 @@ sub DoSavedSearches {
$vars->{'queryshare_groups'} = $vars->{'queryshare_groups'} =
Bugzilla::Group->new_from_list($user->queryshare_groups); Bugzilla::Group->new_from_list($user->queryshare_groups);
} }
$vars->{'bless_group_ids'} = [map {$_->{'id'}} @{$user->bless_groups}];
} }
sub SaveSavedSearches { sub SaveSavedSearches {
...@@ -458,10 +459,9 @@ sub SaveSavedSearches { ...@@ -458,10 +459,9 @@ sub SaveSavedSearches {
} }
# If we're sharing our query with a group we can bless, we # If we're sharing our query with a group we can bless, we
# subscribe direct group members to our search automatically. # have the ability to add link to our search to the footer of
# Otherwise, the group members need to opt in. This behaviour # direct group members automatically.
# is deemed most likely to fit users' needs. if ($user->can_bless($group_id) && $cgi->param('force_' . $q->id)) {
if ($user->can_bless($group_id)) {
my $group = new Bugzilla::Group($group_id); my $group = new Bugzilla::Group($group_id);
my $members = $group->members_non_inherited; my $members = $group->members_non_inherited;
foreach my $member (@$members) { foreach my $member (@$members) {
......
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