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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
bugzilla
Commits
29b9cbc4
Commit
29b9cbc4
authored
May 22, 2006
by
lpsolit%gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 332522: Remove $::prodmaxvotes - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=myk
parent
1c1c8c15
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
73 deletions
+47
-73
Bug.pm
Bugzilla/Bug.pm
+4
-3
globals.pl
globals.pl
+3
-12
votes.cgi
votes.cgi
+40
-58
No files found.
Bugzilla/Bug.pm
View file @
29b9cbc4
...
...
@@ -32,7 +32,7 @@ use strict;
use
vars
qw(@legal_platform
@legal_priority @legal_severity @legal_opsys @legal_bug_status
@settable_resolution
%prodmaxvotes
)
;
@settable_resolution)
;
use
CGI::
Carp
qw(fatalsToBrowser)
;
...
...
@@ -526,8 +526,9 @@ sub use_votes {
my
(
$self
)
=
@_
;
return
0
if
$self
->
{
'error'
};
return
Param
(
'usevotes'
)
&&
$::prodmaxvotes
{
$self
->
{
product
}}
>
0
;
$self
->
{
'prod_obj'
}
||=
new
Bugzilla::
Product
({
name
=>
$self
->
{
'product'
}});
return
Param
(
'usevotes'
)
&&
$self
->
{
'prod_obj'
}
->
votes_per_user
>
0
;
}
sub
groups
{
...
...
globals.pl
View file @
29b9cbc4
...
...
@@ -49,7 +49,6 @@ sub globals_pl_sillyness {
$zz
=
@
main::
legal_platform
;
$zz
=
@
main::
legal_priority
;
$zz
=
@
main::
legal_severity
;
$zz
=
@
main::
prodmaxvotes
;
}
#
...
...
@@ -99,16 +98,8 @@ $::SIG{PIPE} = 'IGNORE';
sub
GenerateVersionTable
{
my
$dbh
=
Bugzilla
->
dbh
;
my
@line
;
SendSQL
(
"SELECT name, votesperuser "
.
"FROM products ORDER BY name"
);
while
(
@line
=
FetchSQLData
())
{
my
(
$p
,
$votesperuser
)
=
(
@line
);
$::prodmaxvotes
{
$p
}
=
$votesperuser
;
}
@::log_columns
=
$dbh
->
bz_table_columns
(
'bugs'
);
foreach
my
$i
(
"bug_id"
,
"creation_ts"
,
"delta_ts"
,
"lastdiffed"
)
{
my
$w
=
lsearch
(
\
@::log_columns
,
$i
);
if
(
$w
>=
0
)
{
...
...
@@ -161,8 +152,8 @@ sub GenerateVersionTable {
'*::legal_platform'
,
'*::legal_opsys'
,
'*::legal_bug_status'
,
'*::legal_resolution'
]));
print
$fh
(
Data::
Dumper
->
Dump
([
\
@::settable_resolution
,
\%::
prodmaxvotes
],
[
'*::settable_resolution'
,
'*::prodmaxvotes'
]));
print
$fh
(
Data::
Dumper
->
Dump
([
\
@::settable_resolution
],
[
'*::settable_resolution'
]));
print
$fh
"1;\n"
;
close
$fh
;
...
...
votes.cgi
View file @
29b9cbc4
...
...
@@ -22,6 +22,7 @@
# Stephan Niemz <st.n@gmx.net>
# Christopher Aillon <christopher@aillon.com>
# Gervase Markham <gerv@gerv.net>
# Frédéric Buclin <LpSolit@gmail.com>
use
strict
;
use
lib
"."
;
...
...
@@ -30,6 +31,7 @@ use Bugzilla;
use
Bugzilla::
Constants
;
use
Bugzilla::
Bug
;
use
Bugzilla::
User
;
use
Bugzilla::
Product
;
require
"globals.pl"
;
...
...
@@ -127,7 +129,7 @@ sub show_user {
$dbh
->
bz_lock_tables
(
'bugs READ'
,
'products READ'
,
'votes WRITE'
,
'cc READ'
,
'bug_group_map READ'
,
'user_group_map READ'
,
'group_group_map READ'
,
'groups READ'
);
'group_group_map READ'
,
'groups READ'
,
'group_control_map READ'
);
if
(
$canedit
&&
$bug_id
)
{
# Make sure there is an entry for this bug
...
...
@@ -140,38 +142,27 @@ sub show_user {
VALUES (?, ?, 0)'
,
undef
,
(
$who
,
$bug_id
));
}
}
# Calculate the max votes per bug for each product; doing it here means
# we can do it all in one query.
my
%
maxvotesperbug
;
if
(
$canedit
)
{
my
$products
=
$dbh
->
selectall_arrayref
(
'SELECT name, maxvotesperbug
FROM products'
);
foreach
(
@$products
)
{
my
(
$prod
,
$max
)
=
@$_
;
$maxvotesperbug
{
$prod
}
=
$max
;
}
}
my
@products
;
# Read the votes data for this user for each product
foreach
my
$product
(
sort
(
keys
(
%::
prodmaxvotes
))
)
{
next
if
$::prodmaxvotes
{
$product
}
<=
0
;
my
$products
=
$user
->
get_selectable_products
;
# Read the votes data for this user for each product
.
foreach
my
$product
(
@$products
)
{
next
unless
(
$product
->
votes_per_user
>
0
)
;
my
@bugs
;
my
$total
=
0
;
my
$onevoteonly
=
0
;
my
$vote_list
=
$dbh
->
selectall_arrayref
(
'SELECT votes.bug_id, votes.vote_count,
bugs.short_desc, bugs.bug_status
FROM votes
INNER JOIN bugs ON votes.bug_id = bugs.bug_id
INNER JOIN products ON bugs.product_id = products.id
WHERE votes.who = ? AND products.name = ?
bugs.short_desc, bugs.bug_status
FROM votes
INNER JOIN bugs
ON votes.bug_id = bugs.bug_id
WHERE votes.who = ?
AND bugs.product_id = ?
ORDER BY votes.bug_id'
,
undef
,
(
$who
,
$product
));
undef
,
(
$who
,
$product
->
id
));
foreach
(
@$vote_list
)
{
my
(
$id
,
$count
,
$summary
,
$status
)
=
@$_
;
...
...
@@ -181,29 +172,25 @@ sub show_user {
# and they can see there are votes 'missing', but not on what bug
# they are. This seems a reasonable compromise; the alternative is
# to lie in the totals.
next
if
!
$user
->
can_see_bug
(
$id
);
next
if
!
$user
->
can_see_bug
(
$id
);
push
(
@bugs
,
{
id
=>
$id
,
summary
=>
$summary
,
count
=>
$count
,
opened
=>
is_open_state
(
$status
)
});
}
# In case we didn't populate this earlier (i.e. an error, or
# a not logged in user viewing a users votes)
$maxvotesperbug
{
$product
}
||=
0
;
$onevoteonly
=
1
if
(
min
(
$::prodmaxvotes
{
$product
},
$maxvotesperbug
{
$product
})
==
1
);
$onevoteonly
=
1
if
(
min
(
$product
->
votes_per_user
,
$product
->
max_votes_per_bug
)
==
1
);
# Only add the product for display if there are any bugs in it.
if
(
$#bugs
>
-
1
)
{
push
(
@products
,
{
name
=>
$product
,
if
(
$#bugs
>
-
1
)
{
push
(
@products
,
{
name
=>
$product
->
name
,
bugs
=>
\
@bugs
,
onevoteonly
=>
$onevoteonly
,
total
=>
$total
,
maxvotes
=>
$
::prodmaxvotes
{
$product
}
,
maxperbug
=>
$
maxvotesperbug
{
$product
}
});
maxvotes
=>
$
product
->
votes_per_user
,
maxperbug
=>
$
product
->
max_votes_per_bug
});
}
}
...
...
@@ -274,35 +261,30 @@ sub record_votes {
# If the user is voting for bugs, make sure they aren't overstuffing
# the ballot box.
if
(
scalar
(
@buglist
))
{
my
$product_vote_settings
=
$dbh
->
selectall_arrayref
(
'SELECT bugs.bug_id, products.name,
products.maxvotesperbug
FROM bugs
INNER JOIN products
ON products.id = bugs.product_id
WHERE bugs.bug_id IN
('
.
join
(
', '
,
@buglist
)
.
')'
);
my
%
prodcount
;
foreach
(
@$product_vote_settings
)
{
my
(
$id
,
$prod
,
$max
)
=
@$_
;
my
%
products
=
{};
# XXX - We really need a $bug->product() method.
foreach
my
$bug_id
(
@buglist
)
{
my
$bug
=
new
Bugzilla::
Bug
(
$bug_id
,
$who
);
my
$prod
=
$bug
->
{
'product'
};
$products
{
$prod
}
||=
new
Bugzilla::
Product
({
name
=>
$prod
});
$prodcount
{
$prod
}
||=
0
;
$prodcount
{
$prod
}
+=
$votes
{
$id
};
$prodcount
{
$prod
}
+=
$votes
{
$
bug_
id
};
# Make sure we haven't broken the votes-per-bug limit
(
$votes
{
$
id
}
<=
$max
)
(
$votes
{
$
bug_id
}
<=
$products
{
$prod
}
->
max_votes_per_bug
)
||
ThrowUserError
(
"too_many_votes_for_bug"
,
{
max
=>
$
max
,
product
=>
$prod
,
votes
=>
$votes
{
$id
}});
{
max
=>
$
products
{
$prod
}
->
max_votes_per_bug
,
product
=>
$prod
,
votes
=>
$votes
{
$
bug_
id
}});
}
# Make sure we haven't broken the votes-per-product limit
foreach
my
$prod
(
keys
(
%
prodcount
))
{
(
$prodcount
{
$prod
}
<=
$
::prodmaxvotes
{
$prod
}
)
(
$prodcount
{
$prod
}
<=
$
products
{
$prod
}
->
votes_per_user
)
||
ThrowUserError
(
"too_many_votes_for_product"
,
{
max
=>
$
::prodmaxvotes
{
$prod
},
product
=>
$prod
,
{
max
=>
$
products
{
$prod
}
->
votes_per_user
,
product
=>
$prod
,
votes
=>
$prodcount
{
$prod
}});
}
}
...
...
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