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
fa9b63f5
Commit
fa9b63f5
authored
Feb 25, 2005
by
mkanat%kerio.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 283237: Move DBname_to_id out of globals.pl
Patch By Max Kanat-Alexander <mkanat@kerio.com> r=wurblzap, a=myk
parent
63dde600
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
62 additions
and
41 deletions
+62
-41
Bug.pm
Bugzilla/Bug.pm
+1
-1
BugMail.pm
Bugzilla/BugMail.pm
+1
-1
Flag.pm
Bugzilla/Flag.pm
+2
-2
Search.pm
Bugzilla/Search.pm
+2
-1
User.pm
Bugzilla/User.pm
+32
-2
bug_email.pl
contrib/bug_email.pl
+4
-3
sendbugmail.pl
contrib/sendbugmail.pl
+3
-2
editcomponents.cgi
editcomponents.cgi
+5
-4
editusers.cgi
editusers.cgi
+2
-2
editwhines.cgi
editwhines.cgi
+1
-1
globals.pl
globals.pl
+2
-16
importxml.pl
importxml.pl
+7
-6
No files found.
Bugzilla/Bug.pm
View file @
fa9b63f5
...
...
@@ -131,7 +131,7 @@ sub initBug {
}
else
{
if
(
$user_id
=~
/^\@/
)
{
$user_id
=
&::
DBname
_to_id
(
$user_id
);
$user_id
=
login
_to_id
(
$user_id
);
}
}
...
...
Bugzilla/BugMail.pm
View file @
fa9b63f5
...
...
@@ -627,7 +627,7 @@ sub filterEmailGroup ($$$) {
# but the code that was here before I re-wrote it allows this),
# then we do not have any preferences for them, so assume the
# default preference is to receive all mail.
my
$userid
=
DBname
_to_id
(
$user
);
my
$userid
=
login
_to_id
(
$user
);
if
(
!
$userid
)
{
push
(
@recipients
,
$user
);
next
;
...
...
Bugzilla/Flag.pm
View file @
fa9b63f5
...
...
@@ -449,7 +449,7 @@ sub modify {
# Get the requestee, if any.
my
$requestee_id
=
"NULL"
;
if
(
$requestee_email
)
{
$requestee_id
=
&::
DBname
_to_id
(
$requestee_email
);
$requestee_id
=
login
_to_id
(
$requestee_email
);
$flag
->
{
'requestee'
}
=
new
Bugzilla::
User
(
$requestee_id
);
}
...
...
@@ -531,7 +531,7 @@ sub FormToNewFlags {
if
(
$status
eq
"?"
)
{
my
$requestee
=
$data
->
{
"requestee_type-$type_id"
};
if
(
$requestee
)
{
my
$requestee_id
=
&::
DBname
_to_id
(
$requestee
);
my
$requestee_id
=
login
_to_id
(
$requestee
);
$flag
->
{
'requestee'
}
=
new
Bugzilla::
User
(
$requestee_id
);
}
}
...
...
Bugzilla/Search.pm
View file @
fa9b63f5
...
...
@@ -41,6 +41,7 @@ use Bugzilla::Error;
use
Bugzilla::
Util
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Group
;
use
Bugzilla::
User
;
use
Date::
Format
;
use
Date::
Parse
;
...
...
@@ -1414,7 +1415,7 @@ sub ListIDsForEmail {
if
(
$type
eq
'anyexact'
)
{
foreach
my
$w
(
split
(
/,/
,
$email
))
{
$w
=
trim
(
$w
);
my
$id
=
&::
DBname
_to_id
(
$w
);
my
$id
=
login
_to_id
(
$w
);
if
(
$id
>
0
)
{
push
(
@list
,
$id
)
}
...
...
Bugzilla/User.pm
View file @
fa9b63f5
...
...
@@ -22,6 +22,7 @@
# Bradley Baetz <bbaetz@acm.org>
# Joel Peshkin <bugreport@peshkin.net>
# Byron Jones <bugzilla@glob.com.au>
# Max Kanat-Alexander <mkanat@kerio.com>
################################################################################
# Module Initialization
...
...
@@ -40,7 +41,9 @@ use Bugzilla::Constants;
use
Bugzilla::
Auth
;
use
base
qw(Exporter)
;
@
Bugzilla::User::
EXPORT
=
qw(insert_new_user is_available_username)
;
@
Bugzilla::User::
EXPORT
=
qw(insert_new_user is_available_username
login_to_id
)
;
################################################################################
# Functions
...
...
@@ -961,7 +964,7 @@ sub insert_new_user ($$) {
sub
is_available_username
($;$) {
my
(
$username
,
$old_username
)
=
@_
;
if
(
&::
DBname
_to_id
(
$username
)
!=
0
)
{
if
(
login
_to_id
(
$username
)
!=
0
)
{
return
0
;
}
...
...
@@ -992,6 +995,19 @@ sub is_available_username ($;$) {
return
1
;
}
sub
login_to_id
($)
{
my
(
$login
)
=
(
@_
);
my
$dbh
=
Bugzilla
->
dbh
;
my
$user_id
=
$dbh
->
selectrow_array
(
"SELECT userid FROM profiles WHERE login_name = ?"
,
undef
,
$login
);
# $user_id should be a positive integer, this makes Taint mode happy
if
(
defined
$user_id
&&
detaint_natural
(
$user_id
))
{
return
$user_id
;
}
else
{
return
0
;
}
}
1
;
__END__
...
...
@@ -1232,6 +1248,20 @@ Params: $username (scalar, string) - The full login name of the username
=back
=item C<login_to_id($login)>
Takes a login name of a Bugzilla user and changes that into a numeric
ID for that user. This ID can then be passed to Bugzilla::User::new to
create a new user.
If no valid user exists with that login name, then the function will return 0.
This function can also be used when you want to just find out the userid
of a user, but you don't want the full weight of Bugzilla::User.
However, consider using a Bugzilla::User object instead of this function
if you need more information about the user than just their ID.
=head1 SEE ALSO
L<Bugzilla|Bugzilla>
contrib/bug_email.pl
View file @
fa9b63f5
...
...
@@ -38,7 +38,7 @@
#
# You need to work with bug_email.pl the MIME::Parser installed.
#
# $Id: bug_email.pl,v 1.2
4 2005/02/18 16:01
:48 mkanat%kerio.com Exp $
# $Id: bug_email.pl,v 1.2
5 2005/02/24 23:42
:48 mkanat%kerio.com Exp $
###############################################################
# 02/12/2000 (SML)
...
...
@@ -94,6 +94,7 @@ use lib ".";
use
lib
"../"
;
use
Bugzilla::
Constants
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
User
;
my
@mailerrors
=
();
# Buffer for Errors in the mail
my
@mailwarnings
=
();
# Buffer for Warnings found in the mail
...
...
@@ -920,7 +921,7 @@ $Control{'component'} = $Component;
# otherwise, retrieve it from the database.
if
(
defined
(
$Control
{
'assigned_to'
})
&&
$Control
{
'assigned_to'
}
!~
/^\s*$/
)
{
$Control
{
'assigned_to'
}
=
DBname
_to_id
(
$Control
{
'assigned_to'
});
$Control
{
'assigned_to'
}
=
login
_to_id
(
$Control
{
'assigned_to'
});
}
else
{
SendSQL
(
"select initialowner from components, products where "
.
" components.product_id=products.id AND products.name="
.
...
...
@@ -940,7 +941,7 @@ if ( $Control{'assigned_to'} == 0 ) {
}
$Control
{
'reporter'
}
=
DBname
_to_id
(
$Control
{
'reporter'
});
$Control
{
'reporter'
}
=
login
_to_id
(
$Control
{
'reporter'
});
if
(
!
$Control
{
'reporter'
}
)
{
BugMailError
(
1
,
"Could not resolve reporter !\n"
);
}
...
...
contrib/sendbugmail.pl
View file @
fa9b63f5
...
...
@@ -4,7 +4,7 @@
#
# Nick Barnes, Ravenbrook Limited, 2004-04-01.
#
# $Id: sendbugmail.pl,v 1.
2 2004/11/20 12:35:17 jocuri%softhome.net
Exp $
# $Id: sendbugmail.pl,v 1.
3 2005/02/24 23:42:48 mkanat%kerio.com
Exp $
#
# Bugzilla email script for Bugzilla 2.17.4 and later. Invoke this to send
# bugmail for a bug which has been changed directly in the database.
...
...
@@ -18,6 +18,7 @@ use lib qw(.);
require
"globals.pl"
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
User
;
sub
usage
{
print
STDERR
"Usage: $0 bug_id user_email\n"
;
...
...
@@ -53,7 +54,7 @@ if ($changer !~ /$match/) {
print
STDERR
"Changer \"$changer\" doesn't match email regular expression.\n"
;
usage
();
}
if
(
!
DBname
_to_id
(
$changer
))
{
if
(
!
login
_to_id
(
$changer
))
{
print
STDERR
"\"$changer\" is not a login ID.\n"
;
usage
();
}
...
...
editcomponents.cgi
View file @
fa9b63f5
...
...
@@ -35,6 +35,7 @@ use Bugzilla::Constants;
use
Bugzilla::
Config
qw(:DEFAULT $datadir)
;
use
Bugzilla::
Series
;
use
Bugzilla::
Util
;
use
Bugzilla::
User
;
use
vars
qw($template $vars)
;
...
...
@@ -296,7 +297,7 @@ if ($action eq 'new') {
exit
;
}
my
$initialownerid
=
DBname
_to_id
(
$initialowner
);
my
$initialownerid
=
login
_to_id
(
$initialowner
);
if
(
!
$initialownerid
)
{
ThrowUserError
(
'component_need_valid_initialowner'
,
{
'name'
=>
$component
});
...
...
@@ -304,7 +305,7 @@ if ($action eq 'new') {
}
my
$initialqacontact
=
trim
(
$cgi
->
param
(
'initialqacontact'
)
||
''
);
my
$initialqacontactid
=
DBname
_to_id
(
$initialqacontact
);
my
$initialqacontactid
=
login
_to_id
(
$initialqacontact
);
if
(
Param
(
'useqacontact'
))
{
if
(
!
$initialqacontactid
&&
$initialqacontact
ne
''
)
{
ThrowUserError
(
'component_need_valid_initialqacontact'
,
...
...
@@ -600,7 +601,7 @@ if ($action eq 'update') {
if
(
$initialowner
ne
$initialownerold
)
{
my
$initialownerid
=
DBname
_to_id
(
$initialowner
);
my
$initialownerid
=
login
_to_id
(
$initialowner
);
unless
(
$initialownerid
)
{
$dbh
->
bz_unlock_tables
(
UNLOCK_ABORT
);
ThrowUserError
(
'component_need_valid_initialowner'
,
...
...
@@ -618,7 +619,7 @@ if ($action eq 'update') {
}
if
(
Param
(
'useqacontact'
)
&&
$initialqacontact
ne
$initialqacontactold
)
{
my
$initialqacontactid
=
DBname
_to_id
(
$initialqacontact
);
my
$initialqacontactid
=
login
_to_id
(
$initialqacontact
);
if
(
!
$initialqacontactid
&&
$initialqacontact
ne
''
)
{
$dbh
->
bz_unlock_tables
(
UNLOCK_ABORT
);
ThrowUserError
(
'component_need_valid_initialqacontact'
,
...
...
editusers.cgi
View file @
fa9b63f5
...
...
@@ -536,7 +536,7 @@ if ($action eq 'del') {
SendSQL
(
"SELECT products.name, components.name "
.
"FROM products, components "
.
"WHERE products.id = components.product_id "
.
" AND initialowner="
.
DBname
_to_id
(
$user
));
" AND initialowner="
.
login
_to_id
(
$user
));
$found
=
0
;
while
(
MoreSQLData
())
{
if
(
$found
)
{
...
...
@@ -561,7 +561,7 @@ if ($action eq 'del') {
SendSQL
(
"SELECT products.name, components.name "
.
"FROM products, components "
.
"WHERE products.id = components.product_id "
.
" AND initialqacontact="
.
DBname
_to_id
(
$user
));
" AND initialqacontact="
.
login
_to_id
(
$user
));
$found
=
0
;
while
(
MoreSQLData
())
{
if
(
$found
)
{
...
...
editwhines.cgi
View file @
fa9b63f5
...
...
@@ -248,7 +248,7 @@ if ($cgi->param('update')) {
my
$emailregexp
=
Param
(
'emailregexp'
);
$mailto
=~
/($emailregexp)/
;
$mailto
=~
$1
;
$mailto_id
=
DBname
_to_id
(
$mailto
);
$mailto_id
=
login
_to_id
(
$mailto
);
}
elsif
(
$mailto_type
==
MAILTO_GROUP
)
{
# detaint the group parameter
...
...
globals.pl
View file @
fa9b63f5
...
...
@@ -37,6 +37,7 @@ use Bugzilla::Util;
use
Bugzilla::
Config
qw(:DEFAULT ChmodDataFile $localconfig $datadir)
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
Auth
;
use
Bugzilla::
User
;
# Shut up misguided -w warnings about "used only once". For some reason,
# "use vars" chokes on me when I try it here.
...
...
@@ -654,24 +655,9 @@ sub DBID_to_name {
return
$::cachedNameArray
{
$id
};
}
sub
DBname_to_id
{
my
(
$name
)
=
(
@_
);
PushGlobalSQLState
();
SendSQL
(
"select userid from profiles where login_name = @{[SqlQuote($name)]}"
);
my
$r
=
FetchOneColumn
();
PopGlobalSQLState
();
# $r should be a positive integer, this makes Taint mode happy
if
(
defined
$r
&&
$r
=~
m/^([1-9][0-9]*)$/
)
{
return
$1
;
}
else
{
return
0
;
}
}
sub
DBNameToIdAndCheck
{
my
(
$name
)
=
(
@_
);
my
$result
=
DBname
_to_id
(
$name
);
my
$result
=
login
_to_id
(
$name
);
if
(
$result
>
0
)
{
return
$result
;
}
...
...
importxml.pl
View file @
fa9b63f5
...
...
@@ -67,6 +67,7 @@ use XML::Parser;
use
Data::
Dumper
;
$
Data::Dumper::
Useqq
=
1
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
User
;
require
"CGI.pl"
;
require
"globals.pl"
;
...
...
@@ -202,7 +203,7 @@ unless ( Param("move-enabled") ) {
exit
;
}
my
$exporterid
=
DBname
_to_id
(
$exporter
);
my
$exporterid
=
login
_to_id
(
$exporter
);
if
(
!
$exporterid
)
{
my
$subject
=
"Bug import error: invalid exporter"
;
my
$message
=
"The user <$tree->[1][0]->{'exporter'}> who tried to move\n"
;
...
...
@@ -504,7 +505,7 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
$err
.=
". Setting to default severity \"normal\".\n"
;
}
my
$reporterid
=
DBname
_to_id
(
$bug_fields
{
'reporter'
});
my
$reporterid
=
login
_to_id
(
$bug_fields
{
'reporter'
});
if
(
(
$bug_fields
{
'reporter'
})
&&
(
$reporterid
)
)
{
push
(
@values
,
SqlQuote
(
$reporterid
));
push
(
@query
,
"reporter"
);
...
...
@@ -523,8 +524,8 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
my
$changed_owner
=
0
;
if
(
(
$bug_fields
{
'assigned_to'
})
&&
(
DBname
_to_id
(
$bug_fields
{
'assigned_to'
}))
)
{
push
(
@values
,
SqlQuote
(
DBname
_to_id
(
$bug_fields
{
'assigned_to'
})));
(
login
_to_id
(
$bug_fields
{
'assigned_to'
}))
)
{
push
(
@values
,
SqlQuote
(
login
_to_id
(
$bug_fields
{
'assigned_to'
})));
push
(
@query
,
"assigned_to"
);
}
else
{
push
(
@values
,
SqlQuote
(
$exporterid
)
);
...
...
@@ -587,7 +588,7 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
if
(
Param
(
"useqacontact"
))
{
my
$qa_contact
;
if
(
(
defined
$bug_fields
{
'qa_contact'
})
&&
(
$qa_contact
=
DBname
_to_id
(
$bug_fields
{
'qa_contact'
}))
){
(
$qa_contact
=
login
_to_id
(
$bug_fields
{
'qa_contact'
}))
){
push
(
@values
,
$qa_contact
);
push
(
@query
,
"qa_contact"
);
}
else
{
...
...
@@ -615,7 +616,7 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
if
(
defined
$bug_fields
{
'cc'
})
{
foreach
my
$person
(
split
(
/[ ,]/
,
$bug_fields
{
'cc'
}))
{
my
$uid
;
if
(
(
$person
ne
""
)
&&
(
$uid
=
DBname
_to_id
(
$person
))
)
{
if
(
(
$person
ne
""
)
&&
(
$uid
=
login
_to_id
(
$person
))
)
{
SendSQL
(
"insert into cc (bug_id, who) values ($id, "
.
SqlQuote
(
$uid
)
.
")"
);
}
}
...
...
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