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
da8a6f8b
Commit
da8a6f8b
authored
Aug 20, 2008
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 442016: Bugzilla::User::bless_groups should be returning Bugzilla::Group objects
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
parent
83457018
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
45 deletions
+34
-45
User.pm
Bugzilla/User.pm
+30
-41
editusers.cgi
editusers.cgi
+3
-3
userprefs.cgi
userprefs.cgi
+1
-1
No files found.
Bugzilla/User.pm
View file @
da8a6f8b
...
@@ -425,49 +425,39 @@ sub bless_groups {
...
@@ -425,49 +425,39 @@ sub bless_groups {
return
$self
->
{
'bless_groups'
}
if
defined
$self
->
{
'bless_groups'
};
return
$self
->
{
'bless_groups'
}
if
defined
$self
->
{
'bless_groups'
};
return
[]
unless
$self
->
id
;
return
[]
unless
$self
->
id
;
my
$dbh
=
Bugzilla
->
dbh
;
my
$query
;
my
$connector
;
my
@bindValues
;
if
(
$self
->
in_group
(
'editusers'
))
{
if
(
$self
->
in_group
(
'editusers'
))
{
# Users having editusers permissions may bless all groups.
# Users having editusers permissions may bless all groups.
$query
=
'SELECT DISTINCT id, name, description FROM groups'
;
$self
->
{
'bless_groups'
}
=
[
Bugzilla::
Group
->
get_all
];
$connector
=
'WHERE'
;
return
$self
->
{
'bless_groups'
};
}
else
{
# Get all groups for the user where:
# + They have direct bless privileges
# + They are a member of a group that inherits bless privs.
$query
=
q{
SELECT DISTINCT groups.id, groups.name, groups.description
FROM groups, user_group_map, group_group_map AS ggm
WHERE user_group_map.user_id = ?
AND ((user_group_map.isbless = 1
AND groups.id=user_group_map.group_id)
OR (groups.id = ggm.grantor_id
AND ggm.grant_type = ?
AND ggm.member_id IN(}
.
$self
->
groups_as_string
.
q{)))}
;
$connector
=
'AND'
;
@bindValues
=
(
$self
->
id
,
GROUP_BLESS
);
}
}
my
$dbh
=
Bugzilla
->
dbh
;
# Get all groups for the user where:
# + They have direct bless privileges
# + They are a member of a group that inherits bless privs.
my
@group_ids
=
(
map
{
$_
->
id
}
@
{
$self
->
groups
})
||
(
-
1
);
my
$query
=
'SELECT DISTINCT groups.id
FROM groups, user_group_map, group_group_map AS ggm
WHERE user_group_map.user_id = ?
AND ( (user_group_map.isbless = 1
AND groups.id=user_group_map.group_id)
OR (groups.id = ggm.grantor_id
AND ggm.grant_type = '
.
GROUP_BLESS
.
'
AND ggm.member_id '
.
$dbh
->
sql_in
(
\
@group_ids
)
.
') )'
;
# If visibilitygroups are used, restrict the set of groups.
# If visibilitygroups are used, restrict the set of groups.
if
(
!
$self
->
in_group
(
'editusers'
)
if
(
Bugzilla
->
params
->
{
'usevisibilitygroups'
})
{
&&
Bugzilla
->
params
->
{
'usevisibilitygroups'
})
return
[]
if
!
$self
->
visible_groups_as_string
;
{
# Users need to see a group in order to bless it.
# Users need to see a group in order to bless it.
my
$visibleGroups
=
join
(
', '
,
@
{
$self
->
visible_groups_direct
()})
$query
.=
" AND groups.id "
||
return
$self
->
{
'bless_groups'
}
=
[]
;
.
$dbh
->
sql_in
(
$self
->
visible_groups_inherited
);
$query
.=
" $connector id in ($visibleGroups)"
;
}
}
$query
.=
' ORDER BY name'
;
my
$ids
=
$dbh
->
selectcol_arrayref
(
$query
,
undef
,
$self
->
id
);
return
$self
->
{
'bless_groups'
}
=
Bugzilla::
Group
->
new_from_list
(
$ids
);
return
$self
->
{
'bless_groups'
}
=
$dbh
->
selectall_arrayref
(
$query
,
{
'Slice'
=>
{}},
@bindValues
);
}
}
sub
in_group
{
sub
in_group
{
...
@@ -979,12 +969,12 @@ sub can_bless {
...
@@ -979,12 +969,12 @@ sub can_bless {
if
(
!
scalar
(
@_
))
{
if
(
!
scalar
(
@_
))
{
# If we're called without an argument, just return
# If we're called without an argument, just return
# whether or not we can bless at all.
# whether or not we can bless at all.
return
scalar
(
@
{
$self
->
bless_groups
})
?
1
:
0
;
return
scalar
(
@
{
$self
->
bless_groups
})
?
1
:
0
;
}
}
# Otherwise, we're checking a specific group
# Otherwise, we're checking a specific group
my
$group_id
=
shift
;
my
$group_id
=
shift
;
return
(
grep
{
$$_
{
'id'
}
eq
$group_id
}
(
@
{
$self
->
bless_groups
})
)
?
1
:
0
;
return
grep
(
$_
->
id
==
$group_id
,
@
{
$self
->
bless_groups
}
)
?
1
:
0
;
}
}
sub
flatten_group_membership
{
sub
flatten_group_membership
{
...
@@ -1917,12 +1907,11 @@ Determines whether or not a user is in the given group by id.
...
@@ -1917,12 +1907,11 @@ Determines whether or not a user is in the given group by id.
=item C<bless_groups>
=item C<bless_groups>
Returns an arrayref of hashes of C<groups> entries, where the keys of each hash
Returns an arrayref of L<Bugzilla::Group> objects.
are the names of C<id>, C<name> and C<description> columns of the C<groups>
table.
The arrayref consists of the groups the user can bless, taking into account
The arrayref consists of the groups the user can bless, taking into account
that having editusers permissions means that you can bless all groups, and
that having editusers permissions means that you can bless all groups, and
that you need to be a
ware of a group in order to bless a group
.
that you need to be a
ble to see a group in order to bless it
.
=item C<get_products_by_permission($group)>
=item C<get_products_by_permission($group)>
...
...
editusers.cgi
View file @
da8a6f8b
...
@@ -276,9 +276,9 @@ if ($action eq 'search') {
...
@@ -276,9 +276,9 @@ if ($action eq 'search') {
# would allow to display a friendlier error message on page reloads.
# would allow to display a friendlier error message on page reloads.
userDataToVars
(
$otherUserID
);
userDataToVars
(
$otherUserID
);
my
$permissions
=
$vars
->
{
'permissions'
};
my
$permissions
=
$vars
->
{
'permissions'
};
foreach
(
@
{
$user
->
bless_groups
()})
{
foreach
my
$blessable
(
@
{
$user
->
bless_groups
()})
{
my
$id
=
$
$_
{
'id'
}
;
my
$id
=
$
blessable
->
id
;
my
$name
=
$
$_
{
'name'
}
;
my
$name
=
$
blessable
->
name
;
# Change memberships.
# Change memberships.
my
$groupid
=
$cgi
->
param
(
"group_$id"
)
||
0
;
my
$groupid
=
$cgi
->
param
(
"group_$id"
)
||
0
;
...
...
userprefs.cgi
View file @
da8a6f8b
...
@@ -400,7 +400,7 @@ sub DoSavedSearches {
...
@@ -400,7 +400,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
}];
$vars
->
{
'bless_group_ids'
}
=
[
map
{
$_
->
id
}
@
{
$user
->
bless_groups
}];
}
}
sub
SaveSavedSearches
{
sub
SaveSavedSearches
{
...
...
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