Bug 64562 - Remove explicit send_header()s

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@1457 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2011-10-28 17:01:59 +00:00
parent 12f37591f3
commit f5fd69a95c
41 changed files with 29 additions and 154 deletions

View File

@ -31,8 +31,6 @@ my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $user = Bugzilla->login(LOGIN_REQUIRED);
$cgi->send_header();
$user->administration_visible
|| ThrowUserError('auth_failure', {action => 'access', object => 'administrative_pages'});

View File

@ -496,7 +496,6 @@ if ($cmdtype eq "dorem") {
# Now reset the cached queries
$user->flush_queries_cache();
$cgi->send_header();
# Generate and return the UI (HTML page) from the appropriate template.
$vars->{'message'} = "buglist_query_gone";
$vars->{'namedcmd'} = $qname;
@ -604,7 +603,6 @@ elsif (($cmdtype eq "doit") && defined $cgi->param('remtype')) {
$vars->{'queryname'} = $query_name;
$cgi->send_header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;

View File

@ -190,8 +190,6 @@ elsif ($action eq "alter") {
}
elsif ($action eq "confirm-delete") {
$vars->{'series'} = assertCanEdit($series_id);
$cgi->send_header();
$template->process("reports/delete-series.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -308,7 +306,6 @@ sub edit {
$vars->{'category'} = Bugzilla::Chart::getVisibleSeries();
$vars->{'default'} = $series;
$cgi->send_header();
$template->process("reports/edit-series.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -343,7 +340,6 @@ sub wrap {
$vars->{'imagebase'} = $cgi->canonicalise_query(
"action", "action-wrap", "ctype", "format", "width", "height");
$cgi->send_header();
$template->process("reports/chart.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -360,8 +356,6 @@ sub view {
$vars->{'chart'} = $chart;
$vars->{'category'} = Bugzilla::Chart::getVisibleSeries();
$cgi->send_header();
# If we have having problems with bad data, we can set debug=1 to dump
# the data structure.
$chart->dump() if $cgi->param('debug');

View File

@ -161,6 +161,5 @@ if (defined $cgi->param('query_based_on')) {
}
# Generate and return the UI (HTML page) from the appropriate template.
$cgi->send_header();
$template->process("list/change-columns.html.tmpl", $vars)
|| ThrowTemplateError($template->error());

View File

@ -47,8 +47,6 @@ my $vars = {};
$vars->{'doc_section'} = 'myaccount.html';
$cgi->send_header();
# If we're using LDAP for login, then we can't create a new account here.
unless (Bugzilla->user->authorizer->user_can_create_account) {
ThrowUserError("auth_cant_create_account");

View File

@ -36,8 +36,6 @@ my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
$cgi->send_header();
# This script does nothing but displaying mostly static data.
Bugzilla->switch_to_shadow_db;

View File

@ -41,6 +41,5 @@ Bugzilla->switch_to_shadow_db;
$vars->{'keywords'} = Bugzilla::Keyword->get_all_with_bug_count();
$vars->{'caneditkeywords'} = Bugzilla->user->in_group("editkeywords");
Bugzilla->cgi->send_header();
$template->process("reports/keywords.html.tmpl", $vars)
|| ThrowTemplateError($template->error());

View File

@ -256,7 +256,6 @@ my %vars = (
);
my $format = $template->get_format("reports/duplicates", $vars{'format'});
$cgi->send_header;
# Generate and return the UI (HTML page) from the appropriate template.
$template->process($format->{'template'}, \%vars)

View File

@ -48,7 +48,6 @@ sub LoadTemplate {
$action =~ /(\w+)/;
$action = $1;
$cgi->send_header();
$template->process("admin/classifications/$action.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@ -60,8 +59,6 @@ sub LoadTemplate {
Bugzilla->login(LOGIN_REQUIRED);
$cgi->send_header();
Bugzilla->user->in_group('editclassifications')
|| ThrowUserError("auth_failure", {group => "editclassifications",
action => "edit",

View File

@ -47,8 +47,6 @@ $vars->{'doc_section'} = 'components.html';
my $user = Bugzilla->login(LOGIN_REQUIRED);
$cgi->send_header();
$user->in_group('editcomponents')
|| scalar(@{$user->get_editable_products})
|| ThrowUserError("auth_failure", {group => "editcomponents",

View File

@ -102,7 +102,6 @@ if (!$vars->{mode_add})
) || [];
}
$cgi->send_header();
$template->process("admin/editemailin.html.tmpl", $vars)
|| ThrowTemplateError($template->error());

View File

@ -39,8 +39,6 @@ $user->in_group('editfields')
my $action = trim($cgi->param('action') || '');
my $token = $cgi->param('token');
$cgi->send_header();
$vars->{field_types} = Bugzilla->messages->{field_types};
# List all existing custom fields if no action is given.
if (!$action)

View File

@ -158,9 +158,6 @@ sub ft_list {
$vars->{'bug_types'} = $bug_flagtypes;
$vars->{'attachment_types'} = $attach_flagtypes;
# Return the appropriate HTTP response headers.
$cgi->send_header();
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@ -203,8 +200,6 @@ sub edit {
# Get a list of groups available to restrict this flag type against.
my @groups = Bugzilla::Group->get_all;
$vars->{'groups'} = \@groups;
# Return the appropriate HTTP response headers.
$cgi->send_header();
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/edit.html.tmpl", $vars)
@ -266,9 +261,6 @@ sub processCategoryChange {
$vars->{'type'} = $type;
$vars->{'token'} = $token;
# Return the appropriate HTTP response headers.
$cgi->send_header();
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@ -347,9 +339,6 @@ sub insert {
$vars->{'bug_types'} = Bugzilla::FlagType::match({'target_type' => 'bug'});
$vars->{'attachment_types'} = Bugzilla::FlagType::match({'target_type' => 'attachment'});
# Return the appropriate HTTP response headers.
$cgi->send_header();
$template->process("admin/flag-type/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -436,9 +425,6 @@ sub update {
$vars->{'bug_types'} = Bugzilla::FlagType::match({'target_type' => 'bug'});
$vars->{'attachment_types'} = Bugzilla::FlagType::match({'target_type' => 'attachment'});
# Return the appropriate HTTP response headers.
$cgi->send_header();
$template->process("admin/flag-type/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -448,8 +434,6 @@ sub confirmDelete {
$vars->{'flag_type'} = $flag_type;
$vars->{'token'} = issue_session_token('delete_flagtype');
# Return the appropriate HTTP response headers.
$cgi->send_header();
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/confirm-delete.html.tmpl", $vars)
@ -481,9 +465,6 @@ sub deleteType {
$vars->{'bug_types'} = Bugzilla::FlagType::match({'target_type' => 'bug'});
$vars->{'attachment_types'} = Bugzilla::FlagType::match({'target_type' => 'attachment'});
# Return the appropriate HTTP response headers.
$cgi->send_header();
$template->process("admin/flag-type/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -507,9 +488,6 @@ sub deactivate {
$vars->{'bug_types'} = Bugzilla::FlagType::match({'target_type' => 'bug'});
$vars->{'attachment_types'} = Bugzilla::FlagType::match({'target_type' => 'attachment'});
# Return the appropriate HTTP response headers.
$cgi->send_header();
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("admin/flag-type/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());

View File

@ -48,8 +48,6 @@ my $vars = {};
my $user = Bugzilla->login(LOGIN_REQUIRED);
$cgi->send_header();
$user->in_group('creategroups')
|| ThrowUserError("auth_failure", {group => "creategroups",
action => "edit",
@ -155,7 +153,6 @@ unless ($action) {
my @groups = Bugzilla::Group->get_all;
$vars->{'groups'} = \@groups;
$cgi->send_header();
$template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@ -176,7 +173,6 @@ if ($action eq 'changeform') {
$vars->{'group'} = $group;
$vars->{'token'} = issue_session_token('edit_group');
$cgi->send_header();
$template->process("admin/groups/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@ -191,7 +187,6 @@ if ($action eq 'changeform') {
if ($action eq 'add') {
$vars->{'token'} = issue_session_token('add_group');
$cgi->send_header();
$template->process("admin/groups/create.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@ -232,7 +227,6 @@ if ($action eq 'new') {
get_current_and_available($group, $vars);
$vars->{'token'} = issue_session_token('edit_group');
$cgi->send_header();
$template->process("admin/groups/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@ -256,7 +250,6 @@ if ($action eq 'del') {
$vars->{'group'} = $group;
$vars->{'token'} = issue_session_token('delete_group');
$cgi->send_header();
$template->process("admin/groups/delete.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@ -285,7 +278,6 @@ if ($action eq 'delete') {
$vars->{'message'} = 'group_deleted';
$vars->{'groups'} = [Bugzilla::Group->get_all];
$cgi->send_header();
$template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@ -310,7 +302,6 @@ if ($action eq 'postchanges') {
$vars->{'changes'} = $changes;
$vars->{'token'} = issue_session_token('edit_group');
$cgi->send_header();
$template->process("admin/groups/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@ -362,10 +353,8 @@ if ($action eq 'remove_regexp') {
$vars->{'group'} = $group->name;
$vars->{'groups'} = [Bugzilla::Group->get_all];
$cgi->send_header();
$template->process("admin/groups/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}

View File

@ -41,8 +41,6 @@ my $vars = {};
my $user = Bugzilla->login(LOGIN_REQUIRED);
$cgi->send_header();
$user->in_group('editkeywords')
|| ThrowUserError("auth_failure", {group => "editkeywords",
action => "edit",
@ -58,7 +56,6 @@ $vars->{'action'} = $action;
if ($action eq "") {
$vars->{'keywords'} = Bugzilla::Keyword->get_all_with_bug_count();
$cgi->send_header();
$template->process("admin/keywords/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@ -69,8 +66,6 @@ if ($action eq "") {
if ($action eq 'add') {
$vars->{'token'} = issue_session_token('add_keyword');
$cgi->send_header();
$template->process("admin/keywords/create.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@ -90,8 +85,6 @@ if ($action eq 'new') {
delete_token($token);
$cgi->send_header();
$vars->{'message'} = 'keyword_created';
$vars->{'name'} = $keyword->name;
$vars->{'keywords'} = Bugzilla::Keyword->get_all_with_bug_count();
@ -115,7 +108,6 @@ if ($action eq 'edit') {
$vars->{'keyword'} = $keyword;
$vars->{'token'} = issue_session_token('edit_keyword');
$cgi->send_header();
$template->process("admin/keywords/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@ -139,8 +131,6 @@ if ($action eq 'update') {
delete_token($token);
$cgi->send_header();
$vars->{'message'} = 'keyword_updated';
$vars->{'keyword'} = $keyword;
$vars->{'changes'} = $changes;
@ -158,7 +148,6 @@ if ($action eq 'del') {
$vars->{'keyword'} = $keyword;
$vars->{'token'} = issue_session_token('delete_keyword');
$cgi->send_header();
$template->process("admin/keywords/confirm-delete.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@ -173,8 +162,6 @@ if ($action eq 'delete') {
delete_token($token);
$cgi->send_header();
$vars->{'message'} = 'keyword_deleted';
$vars->{'keyword'} = $keyword;
$vars->{'keywords'} = Bugzilla::Keyword->get_all_with_bug_count();

View File

@ -43,8 +43,6 @@ $vars->{'doc_section'} = 'milestones.html';
my $user = Bugzilla->login(LOGIN_REQUIRED);
$cgi->send_header();
$user->in_group('editcomponents')
|| scalar(@{$user->get_editable_products})
|| ThrowUserError("auth_failure", {group => "editcomponents",

View File

@ -42,8 +42,6 @@ my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
$cgi->send_header();
$user->in_group('tweakparams')
|| ThrowUserError("auth_failure", {group => "tweakparams",
action => "access",

View File

@ -55,8 +55,6 @@ my $vars = {};
# improved and each action has its own section.
$vars->{'doc_section'} = 'products.html';
$cgi->send_header();
$user->in_group('editcomponents')
|| scalar(@{$user->get_editable_products})
|| ThrowUserError("auth_failure", {group => "editcomponents",

View File

@ -31,8 +31,6 @@ my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
my $vars = {};
$cgi->send_header;
$user->in_group('tweakparams')
|| ThrowUserError("auth_failure", {group => "tweakparams",
action => "modify",

View File

@ -53,8 +53,6 @@ $editusers
action => "edit",
object => "users"});
$cgi->send_header();
# Common CGI params
my $action = $cgi->param('action') || 'search';
my $otherUserID = $cgi->param('userid');

View File

@ -112,7 +112,6 @@ $vars->{isbuggroup} = $isbuggroup;
$vars->{users} = get_users_from_group($group_id);
$vars->{user} = $user;
$cgi->send_header();
$template->process("admin/groups/usersingroup.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
$template->process("global/footer.html.tmpl", $vars)

View File

@ -58,8 +58,6 @@ my $vars = {};
# the documentation about legal values becomes bigger.
$vars->{'doc_section'} = 'edit-values.html';
$cgi->send_header();
Bugzilla->user->in_group('editvalues') ||
ThrowUserError('auth_failure', {group => "admin",
action => "edit",

View File

@ -47,8 +47,6 @@ $vars->{'doc_section'} = 'versions.html';
my $user = Bugzilla->login(LOGIN_REQUIRED);
$cgi->send_header();
$user->in_group('editcomponents')
|| scalar(@{$user->get_editable_products})
|| ThrowUserError("auth_failure", {group => "editcomponents",

View File

@ -327,9 +327,6 @@ if ($cgi->param('update')) {
$vars->{'mail_others'} = $can_mail_others;
# Return the appropriate HTTP response headers.
$cgi->send_header();
# Get events again, to cover any updates that were made
$events = get_events($userid);

View File

@ -33,8 +33,6 @@ my $cgi = Bugzilla->cgi;
my $dbh = Bugzilla->dbh;
my $user = Bugzilla->login(LOGIN_REQUIRED);
$cgi->send_header();
$user->in_group('admin')
|| ThrowUserError('auth_failure', {group => 'admin',
action => 'modify',

View File

@ -113,7 +113,6 @@ if ($product_name eq '') {
$vars->{'cloned_bug_id'} = $cgi->param('cloned_bug_id');
$vars->{'cloned_comment'} = $cgi->param('cloned_comment');
$cgi->send_header();
$template->process("global/choose-classification.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
@ -146,7 +145,6 @@ if ($product_name eq '') {
$vars->{'cloned_bug_id'} = $cgi->param('cloned_bug_id');
$vars->{'cloned_comment'} = $cgi->param('cloned_comment');
$cgi->send_header();
$template->process("global/choose-product.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;

View File

@ -115,8 +115,6 @@ if (@idlist || @lines)
exit;
}
$cgi->send_header();
my ($query, $query_id) = Bugzilla::Search::LookupNamedQuery('MyWorktimeBugs', undef, undef, 0);
my $sqlquery = "";

View File

@ -56,9 +56,6 @@ if ($cgi->param('logout')) {
# Main Body Execution
###############################################################################
# Return the appropriate HTTP response headers.
$cgi->send_header();
if ($user->in_group('admin')) {
# If 'urlbase' is not set, display the Welcome page.
unless (Bugzilla->params->{'urlbase'}) {

View File

@ -146,6 +146,6 @@ if ($action eq "delete") {
$dbh->do("DELETE FROM quips WHERE quipid = ?", undef, $quipid);
}
$cgi->send_header();
$template->process("list/quips.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;

View File

@ -200,6 +200,6 @@ else {
}
# Display the template
$cgi->send_header();
$template->process($target, $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
exit;

View File

@ -54,7 +54,6 @@ my $action = $cgi->param('action') || 'menu';
if ($action eq "menu") {
# No need to do any searching in this case, so bail out early.
$cgi->send_header();
$template->process("reports/menu.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;

View File

@ -47,8 +47,6 @@ Bugzilla->switch_to_shadow_db;
my $template = Bugzilla->template;
my $action = $cgi->param('action') || '';
$cgi->send_header();
################################################################################
# Main Body Execution
################################################################################

View File

@ -38,6 +38,6 @@ foreach my $user (@{$vars->{users}})
$user->{list} = join ', ', @$users_in_group;
}
$cgi->send_header();
$template->process('list-of-mail-groups.html.tmpl', $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
exit;

View File

@ -59,8 +59,6 @@ Bugzilla->switch_to_shadow_db;
$vars->{'bug'} = $bug;
$cgi->send_header();
$template->process("bug/activity/show.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;

View File

@ -45,7 +45,6 @@ $vars->{multiple} = !$single;
# If we don't have an ID, _AND_ we're only doing a single bug, then prompt
if (!$cgi->param('id') && $single) {
Bugzilla->cgi->send_header();
$template->process("bug/choose.html.tmpl", $vars) ||
ThrowTemplateError($template->error());
exit;

View File

@ -73,9 +73,9 @@ $vars->{display} = $display;
$vars->{graphs} = $graphs;
# Generate and return the UI (HTML page) from the appropriate template.
$cgi->send_header();
$template->process("bug/dependency-graph.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
exit;
# Divide the overall graph into closed clusters
sub GetClusters

View File

@ -86,9 +86,9 @@ $vars->{'bugid'} = $id;
$vars->{'maxdepth'} = $maxdepth;
$vars->{'hide_resolved'} = $hide_resolved;
$cgi->send_header();
$template->process("bug/dependency-tree.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
exit;
################################################################################
# Recursive Tree Generation Function #

View File

@ -181,7 +181,6 @@ sub requestChangePassword {
$vars->{'message'} = "password_change_request";
$cgi->send_header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -190,7 +189,6 @@ sub confirmChangePassword {
my $token = shift;
$vars->{'token'} = $token;
$cgi->send_header();
$template->process("account/password/set-forgotten-password.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -200,7 +198,6 @@ sub cancelChangePassword {
$vars->{'message'} = "password_change_canceled";
Bugzilla::Token::Cancel($token, $vars->{'message'});
$cgi->send_header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -230,7 +227,6 @@ sub changePassword {
$vars->{'message'} = "password_changed";
$cgi->send_header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -239,7 +235,6 @@ sub confirmChangeEmail {
my $token = shift;
$vars->{'token'} = $token;
$cgi->send_header();
$template->process("account/email/confirm.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -283,11 +278,7 @@ sub changeEmail {
$dbh->bz_commit_transaction();
# Return HTTP response headers.
$cgi->send_header();
# Let the user know their email address has been changed.
$vars->{'message'} = "login_changed";
$template->process("global/message.html.tmpl", $vars)
@ -345,9 +336,6 @@ sub cancelChangeEmail {
$dbh->bz_commit_transaction();
# Return HTTP response headers.
$cgi->send_header();
$template->process("global/message.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
@ -360,7 +348,6 @@ sub request_create_account {
$vars->{'email'} = $login_name . Bugzilla->params->{'emailsuffix'};
$vars->{'expiration_ts'} = ctime(str2time($date) + MAX_TOKEN_AGE * 86400);
$cgi->send_header();
$template->process('account/email/confirm-new.html.tmpl', $vars)
|| ThrowTemplateError($template->error());
}
@ -394,8 +381,6 @@ sub confirm_create_account {
delete Bugzilla->request_cache->{sub_login_to_id}->{$otheruser->login};
Bugzilla->login(LOGIN_OPTIONAL);
$cgi->send_header();
$template->process('index.html.tmpl', $vars)
|| ThrowTemplateError($template->error());
}
@ -409,7 +394,6 @@ sub cancel_create_account {
$vars->{'account'} = $login_name;
Bugzilla::Token::Cancel($token, $vars->{'message'});
$cgi->send_header();
$template->process('global/message.html.tmpl', $vars)
|| ThrowTemplateError($template->error());
}

View File

@ -38,10 +38,8 @@ else
$vars->{not_in_cc} = 1;
}
$cgi->send_header();
$template->process('bug/process/unsubscribe.html.tmpl', $vars)
|| ThrowTemplateError($template->error());
exit;
1;

View File

@ -543,6 +543,6 @@ if ($current_tab_name ne 'permissions') {
}
# Generate and return the UI (HTML page) from the appropriate template.
$cgi->send_header();
$template->process("account/prefs/prefs.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
exit;

View File

@ -45,7 +45,7 @@ local our $vars = {};
# If the action is show_bug, you need a bug_id.
# If the action is show_user, you can supply a userid to show the votes for
# another user, otherwise you see your own.
# If the action is vote, your votes are set to those encoded in the URL as
# If the action is vote, your votes are set to those encoded in the URL as
# <bug_id>=<votes>.
#
# If no action is defined, we default to show_bug if a bug_id is given,
@ -80,7 +80,7 @@ if (defined $bug_id) {
if ($action eq "show_bug") {
show_bug($bug_id);
}
}
elsif ($action eq "show_user") {
show_user($bug_id);
}
@ -109,14 +109,13 @@ sub show_bug {
profiles.userid AS id,
votes.vote_count
FROM votes
INNER JOIN profiles
INNER JOIN profiles
ON profiles.userid = votes.who
WHERE votes.bug_id = ?',
{'Slice' => {}}, $bug_id);
$cgi->send_header();
$template->process("bug/votes/list-for-bug.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
}
# Display all the votes for a particular user. If it's the user
@ -134,7 +133,7 @@ sub show_user {
my $who_id = $cgi->param('user_id') || $user->id;
my $who = Bugzilla::User->check({ id => $who_id });
my $canedit = (Bugzilla->params->{'usevotes'} && $user->id == $who->id)
my $canedit = (Bugzilla->params->{'usevotes'} && $user->id == $who->id)
? 1 : 0;
$dbh->bz_start_transaction();
@ -142,11 +141,11 @@ sub show_user {
if ($canedit && $bug_id) {
# Make sure there is an entry for this bug
# in the vote table, just so that things display right.
my $has_votes = $dbh->selectrow_array('SELECT vote_count FROM votes
my $has_votes = $dbh->selectrow_array('SELECT vote_count FROM votes
WHERE bug_id = ? AND who = ?',
undef, ($bug_id, $who->id));
if (!$has_votes) {
$dbh->do('INSERT INTO votes (who, bug_id, vote_count)
$dbh->do('INSERT INTO votes (who, bug_id, vote_count)
VALUES (?, ?, 0)', undef, ($who->id, $bug_id));
}
}
@ -184,7 +183,7 @@ sub show_user {
# to lie in the totals.
next if !$user->can_see_bug($id);
push (@bugs, { id => $id,
push (@bugs, { id => $id,
summary => $summary,
count => $count });
push (@bug_ids, $id);
@ -215,9 +214,8 @@ sub show_user {
$vars->{'bug_id'} = $bug_id;
$vars->{'all_bug_ids'} = \@all_bug_ids;
$cgi->send_header();
$template->process("bug/votes/list-for-user.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
}
# Update the user's votes in the database.
@ -231,7 +229,7 @@ sub record_votes {
my $template = Bugzilla->template;
# Build a list of bug IDs for which votes have been submitted. Votes
# are submitted in form fields in which the field names are the bug
# are submitted in form fields in which the field names are the bug
# IDs and the field values are the number of votes.
my @buglist = grep {/^[1-9][0-9]*$/} $cgi->param();
@ -240,7 +238,6 @@ sub record_votes {
# that their votes will get nuked if they continue.
if (scalar(@buglist) == 0) {
if (!defined $cgi->param('delete_all_votes')) {
$cgi->send_header();
$template->process("bug/votes/delete-all.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit();
@ -252,7 +249,7 @@ sub record_votes {
}
# Call check() on each bug ID to make sure it is a positive
# integer representing an existing bug that the user is authorized
# integer representing an existing bug that the user is authorized
# to access, and make sure the number of votes submitted is also
# a non-negative integer (a series of digits not preceded by a
# minus sign).
@ -261,7 +258,7 @@ sub record_votes {
my $bug = Bugzilla::Bug->check($id);
$id = $bug->id;
$votes{$id} = $cgi->param($id);
detaint_natural($votes{$id})
detaint_natural($votes{$id})
|| ThrowUserError("votes_must_be_nonnegative");
}
@ -304,7 +301,7 @@ sub record_votes {
}
}
# Update the user's votes in the database. If the user did not submit
# Update the user's votes in the database. If the user did not submit
# any votes, they may be using a form with checkboxes to remove all their
# votes (checkboxes are not submitted along with other form data when
# they are not checked, and Bugzilla uses them to represent single votes
@ -312,7 +309,7 @@ sub record_votes {
# need to clear the user's votes from the database.
my %affected;
$dbh->bz_start_transaction();
# Take note of, and delete the user's old votes from the database.
my $bug_list = $dbh->selectcol_arrayref('SELECT bug_id FROM votes
WHERE who = ?', undef, $who);
@ -333,7 +330,6 @@ sub record_votes {
}
# Update the cached values in the bugs table
$cgi->send_header();
my @updated_bugs = ();
my $sth_getVotes = $dbh->prepare("SELECT SUM(vote_count) FROM votes
@ -355,7 +351,8 @@ sub record_votes {
$vars->{'type'} = "votes";
$vars->{'title_tag'} = 'change_votes';
foreach my $bug_id (@updated_bugs) {
foreach my $bug_id (@updated_bugs)
{
# TODO save this into session and redirect
my $sent = send_results({
bug_id => $bug_id,
@ -365,7 +362,7 @@ sub record_votes {
$vars->{$_} = $sent->{$_} for keys %$sent;
$template->process("bug/process/results.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
|| ThrowTemplateError($template->error());
# Set header_done to 1 only after the first bug.
$vars->{'header_done'} = 1;
}