1
# -*- Mode: perl; indent-tabs-mode: nil -*-
3
# The contents of this file are subject to the Mozilla Public
4
# License Version 1.1 (the "License"); you may not use this file
5
# except in compliance with the License. You may obtain a copy of
6
# the License at http://www.mozilla.org/MPL/
8
# Software distributed under the License is distributed on an "AS
9
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
# implied. See the License for the specific language governing
11
# rights and limitations under the License.
13
# The Original Code is the Bugzilla Bug Tracking System.
15
# The Initial Developer of the Original Code is Netscape Communications
16
# Corporation. Portions created by Netscape are
17
# Copyright (C) 1998 Netscape Communications Corporation. All
20
# Contributor(s): Terry Weissman <terry@mozilla.org>
21
# Dave Miller <justdave@syndicomm.com>
28
# Use the Attachment module to display attachments for the bug.
32
# Shut up misguided -w warnings about "used only once". For some reason,
33
# "use vars" chokes on me when I try it here.
34
sub bug_form_pl_sillyness {
38
$zz = %::prodmaxvotes;
39
$zz = @::enterable_products;
40
$zz = @::settable_resolution;
41
$zz = $::unconfirmedstate;
42
$zz = $::milestoneurl;
45
$zz = @::legal_priority;
46
$zz = @::legal_platform;
47
$zz = @::legal_severity;
48
$zz = @::legal_bug_status;
49
$zz = @::target_milestone;
51
$zz = @::legal_keywords;
57
my $template = $::template;
60
$vars->{'GetBugLink'} = \&GetBugLink;
61
$vars->{'quoteUrls'} = \"eUrls,
62
$vars->{'lsearch'} = \&lsearch,
63
$vars->{'header_done'} = (@_),
65
quietly_check_login();
67
my $id = $::FORM{'id'};
70
$template->process("bug/choose.html.tmpl", $vars)
71
|| ThrowTemplateError($template->error());
75
my %user = %{$vars->{'user'}};
78
# Populate the bug hash with the info we get directly from the DB.
80
SELECT bugs.bug_id, product, version, rep_platform,
81
op_sys, bug_status, resolution, priority,
82
bug_severity, component, assigned_to, reporter,
83
bug_file_loc, short_desc, target_milestone,
84
qa_contact, status_whiteboard,
85
date_format(creation_ts,'%Y-%m-%d %H:%i'),
86
groupset, delta_ts, ifnull(sum(votes.count),0)
87
FROM bugs LEFT JOIN votes USING(bug_id)
88
WHERE bugs.bug_id = $id
89
GROUP BY bugs.bug_id";
94
my @row = FetchSQLData();
95
foreach my $field ("bug_id", "product", "version", "rep_platform",
96
"op_sys", "bug_status", "resolution", "priority",
97
"bug_severity", "component", "assigned_to", "reporter",
98
"bug_file_loc", "short_desc", "target_milestone",
99
"qa_contact", "status_whiteboard", "creation_ts",
100
"groupset", "delta_ts", "votes")
102
$value = shift(@row);
103
$bug{$field} = defined($value) ? $value : "";
106
# General arrays of info about the database state
109
# Fiddle the product list.
113
foreach my $product (@::enterable_products) {
114
if ($product eq $bug{'product'}) {
115
# if it's the product the bug is already in, it's ALWAYS in
116
# the popup, period, whether the user can see it or not, and
117
# regardless of the disallownew setting.
119
push(@prodlist, $product);
123
if (Param("usebuggroupsentry")
124
&& GroupExists($product)
125
&& !UserInGroup($product))
127
# If we're using bug groups to restrict entry on products, and
128
# this product has a bug group, and the user is not in that
129
# group, we don't want to include that product in this list.
133
push(@prodlist, $product);
136
# The current product is part of the popup, even if new bugs are no longer
137
# allowed for that product
138
if (!$seen_curr_prod) {
139
push (@prodlist, $bug{'product'});
140
@prodlist = sort @prodlist;
143
$vars->{'product'} = \@prodlist;
144
$vars->{'rep_platform'} = \@::legal_platform;
145
$vars->{'priority'} = \@::legal_priority;
146
$vars->{'bug_severity'} = \@::legal_severity;
147
$vars->{'op_sys'} = \@::legal_opsys;
148
$vars->{'bug_status'} = \@::legal_bug_status;
150
# Hack - this array contains "" for some reason. See bug 106589.
151
shift @::settable_resolution;
152
$vars->{'resolution'} = \@::settable_resolution;
154
$vars->{'component_'} = $::components{$bug{'product'}};
155
$vars->{'version'} = $::versions{$bug{'product'}};
156
$vars->{'target_milestone'} = $::target_milestone{$bug{'product'}};
157
$bug{'milestoneurl'} = $::milestoneurl{$bug{'product'}} ||
158
"notargetmilestone.html";
160
$vars->{'use_votes'} = Param('usevotes')
161
&& $::prodmaxvotes{$bug{'product'}} > 0;
163
# Add additional, calculated fields to the bug hash
164
if (@::legal_keywords) {
165
$vars->{'use_keywords'} = 1;
167
SendSQL("SELECT keyworddefs.name
168
FROM keyworddefs, keywords
169
WHERE keywords.bug_id = $id
170
AND keyworddefs.id = keywords.keywordid
171
ORDER BY keyworddefs.name");
173
while (MoreSQLData()) {
174
push(@keywords, FetchOneColumn());
177
$bug{'keywords'} = \@keywords;
181
$bug{'attachments'} = Attachment::query($id);
185
SendSQL("SELECT dependson FROM dependencies WHERE
186
blocked = $id ORDER BY dependson");
187
while (MoreSQLData()) {
188
my ($i) = FetchSQLData();
192
$bug{'dependson'} = \@list;
195
SendSQL("SELECT blocked FROM dependencies WHERE
196
dependson = $id ORDER BY blocked");
197
while (MoreSQLData()) {
198
my ($i) = FetchSQLData();
202
$bug{'blocked'} = \@list2;
206
if ($::usergroupset ne '0' || $bug{'groupset'} ne '0') {
207
my $bug_groupset = $bug{'groupset'};
209
SendSQL("SELECT bit, name, description, (bit & $bug_groupset != 0),
210
(bit & $::usergroupset != 0) FROM groups
211
WHERE isbuggroup != 0 " .
212
# Include active groups as well as inactive groups to which
213
# the bug already belongs. This way the bug can be removed
214
# from an inactive group but can only be added to active ones.
215
"AND ((isactive = 1 AND (bit & $::usergroupset != 0)) OR
216
(bit & $bug_groupset != 0))");
218
$user{'inallgroups'} = 1;
220
while (MoreSQLData()) {
221
my ($bit, $name, $description, $ison, $ingroup) = FetchSQLData();
222
# For product groups, we only want to display the checkbox if either
223
# (1) The bit is already set, or
224
# (2) The user is in the group, but either:
225
# (a) The group is a product group for the current product, or
226
# (b) The group name isn't a product name
227
# This means that all product groups will be skipped, but
228
# non-product bug groups will still be displayed.
230
($ingroup && (($name eq $bug{'product'}) ||
231
(!defined $::proddesc{$name}))))
233
$user{'inallgroups'} &= $ingroup;
235
push (@groups, { "bit" => $bit,
237
"ingroup" => $ingroup,
238
"description" => $description });
242
# If the bug is restricted to a group, display checkboxes that allow
243
# the user to set whether or not the reporter
244
# and cc list can see the bug even if they are not members of all
245
# groups to which the bug is restricted.
246
if ($bug{'groupset'} != 0) {
247
$bug{'inagroup'} = 1;
249
# Determine whether or not the bug is always accessible by the
250
# reporter, QA contact, and/or users on the cc: list.
251
SendSQL("SELECT reporter_accessible, cclist_accessible
255
($bug{'reporter_accessible'},
256
$bug{'cclist_accessible'}) = FetchSQLData();
259
$vars->{'groups'} = \@groups;
261
my $movers = Param("movers");
262
$user{'canmove'} = Param("move-enabled")
263
&& (defined $::COOKIE{"Bugzilla_login"})
264
&& ($::COOKIE{"Bugzilla_login"} =~ /\Q$movers\E/);
268
# In the below, if the person hasn't logged in ($::userid == 0), then
269
# we treat them as if they can do anything. That's because we don't
270
# know why they haven't logged in; it may just be because they don't
271
# use cookies. Display everything as if they have all the permissions
272
# in the world; their permissions will get checked when they log in
273
# and actually try to make the change.
274
$user{'canedit'} = $::userid == 0
275
|| $::userid == $bug{'reporter'}
276
|| $::userid == $bug{'qa_contact'}
277
|| $::userid == $bug{'assigned_to'}
278
|| UserInGroup("editbugs");
279
$user{'canconfirm'} = ($::userid == 0)
280
|| UserInGroup("canconfirm")
281
|| UserInGroup("editbugs");
284
$bug{'isunconfirmed'} = ($bug{'bug_status'} eq $::unconfirmedstate);
285
$bug{'isopened'} = IsOpenedState($bug{'bug_status'});
287
# People involved with the bug
288
$bug{'assigned_to_email'} = DBID_to_name($bug{'assigned_to'});
289
$bug{'assigned_to'} = DBID_to_real_or_loginname($bug{'assigned_to'});
290
$bug{'reporter'} = DBID_to_real_or_loginname($bug{'reporter'});
291
$bug{'qa_contact'} = $bug{'qa_contact'} > 0 ?
292
DBID_to_name($bug{'qa_contact'}) : "";
294
my $ccset = new RelationSet;
295
$ccset->mergeFromDB("SELECT who FROM cc WHERE bug_id=$id");
297
my @cc = $ccset->toArrayOfStrings();
298
$bug{'cc'} = \@cc if $cc[0];
300
# Next bug in list (if there is one)
302
if ($::COOKIE{"BUGLIST"} && $id)
304
@bug_list = split(/:/, $::COOKIE{"BUGLIST"});
306
$vars->{'bug_list'} = \@bug_list;
308
$bug{'comments'} = GetComments($bug{'bug_id'});
310
# This is length in number of comments
311
$bug{'longdesclength'} = scalar(@{$bug{'comments'}});
313
# Add the bug and user hashes to the variables
314
$vars->{'bug'} = \%bug;
315
$vars->{'user'} = \%user;
317
# Create the <link> elements for browsing bug lists
318
$vars->{'navigation_links'} = navigation_links(join(':',@bug_list));
320
# Generate and return the UI (HTML page) from the appropriate template.
321
$template->process("bug/edit.html.tmpl", $vars)
322
|| ThrowTemplateError($template->error());