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
9fcdc67a
Commit
9fcdc67a
authored
Mar 02, 2006
by
mkanat%kerio.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 328435: Move GroupNameToId into Bugzilla/Group.pm and eliminate GroupExists
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=wicked, a=justdave
parent
877a6c19
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
22 deletions
+31
-22
Group.pm
Bugzilla/Group.pm
+27
-1
editgroups.cgi
editgroups.cgi
+1
-1
editproducts.cgi
editproducts.cgi
+3
-2
globals.pl
globals.pl
+0
-18
No files found.
Bugzilla/Group.pm
View file @
9fcdc67a
...
...
@@ -25,6 +25,11 @@ use strict;
package
Bugzilla::
Group
;
use
base
qw(Exporter)
;
@
Bugzilla::Group::
EXPORT
=
qw(
group_name_to_id
)
;
use
Bugzilla::
Config
;
use
Bugzilla::
Util
;
use
Bugzilla::
Error
;
...
...
@@ -140,6 +145,14 @@ sub get_all_groups {
return
@groups
;
}
sub
group_name_to_id
{
my
(
$name
)
=
@_
;
trick_taint
(
$name
);
my
(
$id
)
=
Bugzilla
->
dbh
->
selectrow_array
(
"SELECT id FROM groups WHERE name = ?"
,
undef
,
$name
);
return
$id
;
}
1
;
__END__
...
...
@@ -163,7 +176,8 @@ Bugzilla::Group - Bugzilla group class.
my $is_active = $group->is_active;
my $group_id = Bugzilla::Group::ValidateGroupName('admin', @users);
my @groups = Bugzilla::get_all_groups();
my @groups = Bugzilla::Group::get_all_groups();
my $group_id = group_name_to_id('admin');
=head1 DESCRIPTION
...
...
@@ -213,6 +227,18 @@ Group.pm represents a Bugzilla Group object.
Returns: An array of group objects.
=item C<group_name_to_id($name)>
Description: Converts a group name to an id.
In general, instead of using this function, you should
create a Group object and get its name. This function
does not offer any real performance advantage.
Params: $name - The name of a group.
Returns: The numeric id of the group with that name,
or C<undef> if the group does not exist.
=back
=cut
editgroups.cgi
View file @
9fcdc67a
...
...
@@ -294,7 +294,7 @@ if ($action eq 'new') {
undef
,
(
$name
,
$desc
,
$regexp
,
$isactive
));
my
$gid
=
$dbh
->
bz_last_key
(
'groups'
,
'id'
);
my
$admin
=
GroupNameToI
d
(
'admin'
);
my
$admin
=
group_name_to_i
d
(
'admin'
);
# Since we created a new group, give the "admin" group all privileges
# initially.
my
$sth
=
$dbh
->
prepare
(
'INSERT INTO group_group_map
...
...
editproducts.cgi
View file @
9fcdc67a
...
...
@@ -43,6 +43,7 @@ use Bugzilla::BugMail;
use
Bugzilla::
Product
;
use
Bugzilla::
Classification
;
use
Bugzilla::
Milestone
;
use
Bugzilla::
Group
;
# Shut up misguided -w warnings about "used only once". "use vars" just
# doesn't work for me.
...
...
@@ -234,7 +235,7 @@ if ($action eq 'new') {
if
(
Param
(
"makeproductgroups"
))
{
# Next we insert into the groups table
my
$productgroup
=
$product
->
name
;
while
(
GroupExists
(
$productgroup
))
{
while
(
group_name_to_id
(
$productgroup
))
{
$productgroup
.=
'_'
;
}
my
$group_description
=
"Access to bugs in the "
.
...
...
@@ -249,7 +250,7 @@ if ($action eq 'new') {
# If we created a new group, give the "admin" group priviledges
# initially.
my
$admin
=
GroupNameToI
d
(
'admin'
);
my
$admin
=
group_name_to_i
d
(
'admin'
);
my
$sth
=
$dbh
->
prepare
(
'INSERT INTO group_group_map
(member_id, grantor_id, grant_type)
...
...
globals.pl
View file @
9fcdc67a
...
...
@@ -499,24 +499,6 @@ sub BugInGroupId {
return
$bugingroup
;
}
sub
GroupExists
{
my
(
$groupname
)
=
(
@_
);
PushGlobalSQLState
();
SendSQL
(
"SELECT id FROM groups WHERE name="
.
SqlQuote
(
$groupname
));
my
$id
=
FetchOneColumn
();
PopGlobalSQLState
();
return
$id
;
}
sub
GroupNameToId
{
my
(
$groupname
)
=
(
@_
);
PushGlobalSQLState
();
SendSQL
(
"SELECT id FROM groups WHERE name="
.
SqlQuote
(
$groupname
));
my
$id
=
FetchOneColumn
();
PopGlobalSQLState
();
return
$id
;
}
sub
GroupIdToName
{
my
(
$groupid
)
=
(
@_
);
PushGlobalSQLState
();
...
...
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