Commit 05fe02cd authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 5179: Need to be able to put attachment on new bug - Patch by Marc Schumann…

Bug 5179: Need to be able to put attachment on new bug - Patch by Marc Schumann <wurblzap@gmail.com> r=LpSolit a=justdave
parent 0d2869cd
/* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Bugzilla Bug Tracking System.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s): Myk Melez <myk@mozilla.org>
* Joel Peshkin <bugreport@peshkin.net>
* Erik Stambaugh <erik@dasbistro.com>
* Marc Schumann <wurblzap@gmail.com>
*/
function updateCommentPrivacy(checkbox) {
var text_elem = document.getElementById('comment');
if (checkbox.checked) {
text_elem.className='bz_private';
} else {
text_elem.className='';
}
}
function setContentTypeDisabledState(form)
{
var isdisabled = false;
if (form.ispatch.checked)
isdisabled = true;
for (var i=0 ; i<form.contenttypemethod.length ; i++)
form.contenttypemethod[i].disabled = isdisabled;
form.contenttypeselection.disabled = isdisabled;
form.contenttypeentry.disabled = isdisabled;
}
function URLFieldHandler() {
var field_attachurl = document.getElementById("attachurl");
var greyfields = new Array("data", "ispatch", "autodetect",
"list", "manual", "bigfile",
"contenttypeselection",
"contenttypeentry");
var i;
if (field_attachurl.value.match(/^\s*$/)) {
for (i = 0; i < greyfields.length; i++) {
thisfield = document.getElementById(greyfields[i]);
if (thisfield) {
thisfield.removeAttribute("disabled");
}
}
} else {
for (i = 0; i < greyfields.length; i++) {
thisfield = document.getElementById(greyfields[i]);
if (thisfield) {
thisfield.setAttribute("disabled", "disabled");
}
}
}
}
function DataFieldHandler() {
var field_data = document.getElementById("data");
var greyfields = new Array("attachurl");
if (field_data.value.match(/^\s*$/)) {
var i;
for (i = 0; i < greyfields.length; i++) {
thisfield = document.getElementById(greyfields[i]);
if (thisfield) {
thisfield.removeAttribute("disabled");
}
}
} else {
for (i = 0; i < greyfields.length; i++) {
thisfield = document.getElementById(greyfields[i]);
if (thisfield) {
thisfield.setAttribute("disabled", "disabled");
}
}
}
}
function clearAttachmentFields() {
var element;
document.getElementById('data').value = '';
DataFieldHandler();
if (element = document.getElementById('bigfile'))
element.checked = '';
if (element = document.getElementById('attachurl')) {
element.value = '';
URLFieldHandler();
}
document.getElementById('description').value = '';
document.getElementById('ispatch').checked = '';
if (element = document.getElementById('isprivate'))
element.checked = '';
}
......@@ -22,12 +22,14 @@
# Dan Mosedale <dmose@mozilla.org>
# Joe Robins <jmrobins@tgix.com>
# Gervase Markham <gerv@gerv.net>
# Marc Schumann <wurblzap@gmail.com>
use strict;
use lib qw(.);
require "globals.pl";
use Bugzilla;
use Bugzilla::Attachment;
use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Bug;
......@@ -546,6 +548,21 @@ $dbh->do("UPDATE bugs SET creation_ts = ? WHERE bug_id = ?",
$dbh->bz_unlock_tables();
# Add an attachment if requested.
if (defined($cgi->upload('data')) || $cgi->param('attachurl')) {
$cgi->param('isprivate', $cgi->param('commentprivacy'));
Bugzilla::Attachment->insert_attachment_for_bug(!THROW_ERROR,
$id, $user, $timestamp,
\$vars)
|| ($vars->{'message'} = 'attachment_creation_failed');
# Determine if Patch Viewer is installed, for Diff link
eval {
require PatchReader;
$vars->{'patchviewerinstalled'} = 1;
};
}
# Email everyone the details of the new bug
$vars->{'mailrecipients'} = {'changer' => $user->login};
......
/* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is the Bugzilla Bug Tracking System.
*
* Contributor(s): Myk Melez <myk@mozilla.org>
* Joel Peshkin <bugreport@peshkin.net>
* Erik Stambaugh <erik@dasbistro.com>
* Marc Schumann <wurblzap@gmail.com>
*/
table.attachment_entry th {
text-align: right;
vertical-align: baseline;
white-space: nowrap;
}
table.attachment_entry td {
text-align: left;
vertical-align: baseline;
padding-bottom: 5px;
}
table#flags th,
table#flags td {
text-align: left;
vertical-align: baseline;
font-size: small;
}
......@@ -19,6 +19,7 @@
# Contributor(s): Myk Melez <myk@mozilla.org>
# Joel Peshkin <bugreport@peshkin.net>
# Erik Stambaugh <erik@dasbistro.com>
# Marc Schumann <wurblzap@gmail.com>
#%]
[% PROCESS global/variables.none.tmpl %]
......@@ -33,180 +34,19 @@
title = title
h1 = h1
h2 = h2
style = "
table.attachment_entry th {
text-align: right;
vertical-align: baseline;
white-space: nowrap;
}
table.attachment_entry td {
text-align: left;
vertical-align: baseline;
padding-bottom: 5px;
}
table#flags th, table#flags td {
text-align: left;
vertical-align: baseline;
font-size: small;
}
"
onload="setContentTypeDisabledState();"
onload="setContentTypeDisabledState(document.entryform);"
style_urls = [ 'skins/standard/create_attachment.css' ]
javascript_urls = [ "js/attachment.js" ]
%]
[% IF Param("allow_attach_url") %]
<script type="text/javascript">
function URLFieldHandler() {
var field_attachurl = document.getElementById("attachurl");
var greyfields = new Array("data", "ispatch", "autodetect",
"list", "manual", "bigfile",
"contenttypeselection",
"contenttypeentry");
var i;
if (field_attachurl.value.match(/^\s*$/)) {
for (i = 0; i < greyfields.length; i++) {
thisfield = document.getElementById(greyfields[i]);
if (thisfield) {
thisfield.removeAttribute("disabled");
}
}
} else {
for (i = 0; i < greyfields.length; i++) {
thisfield = document.getElementById(greyfields[i]);
if (thisfield) {
thisfield.setAttribute("disabled", "disabled");
}
}
}
}
function DataFieldHandler() {
var field_data = document.getElementById("data");
var greyfields = new Array("attachurl");
if (field_data.value.match(/^\s*$/)) {
var i;
for (i = 0; i < greyfields.length; i++) {
thisfield = document.getElementById(greyfields[i]);
if (thisfield) {
thisfield.removeAttribute("disabled");
}
}
} else {
for (i = 0; i < greyfields.length; i++) {
thisfield = document.getElementById(greyfields[i]);
if (thisfield) {
thisfield.setAttribute("disabled", "disabled");
}
}
}
}
</script>
[% END %]
<script type="text/javascript">
function updateCommentPrivacy(checkbox) {
var text_elem = document.getElementById('comment');
if (checkbox.checked) {
text_elem.className='bz_private';
} else {
text_elem.className='';
}
}
</script>
<form name="entryform" method="post" action="attachment.cgi" enctype="multipart/form-data">
<input type="hidden" name="bugid" value="[% bugid %]">
<input type="hidden" name="action" value="insert">
<table class="attachment_entry">
<tr>
<th><label for="data">File:</label></th>
<td>
<em>Enter the path to the file on your computer.</em><br>
<input type="file" id="data" name="data" size="50"
[% IF Param("allow_attach_url") %]
onchange="DataFieldHandler()"
[% END %]
>
</td>
</tr>
[% IF Param("maxlocalattachment") %]
<tr>
<th>BigFile:</th>
<td>
<input type="checkbox" id="bigfile"
name="bigfile" value="bigfile">
<label for="bigfile">
Big File - Stored locally and may be purged
</label>
</td>
</tr>
[% END %]
[% IF Param("allow_attach_url") %]
<tr>
<th><label for="attachurl">AttachURL:</label></th>
<td>
<em>URL to be attached instead.</em><br>
<input type="text" id="attachurl" name="attachurl" size="60"
maxlength="2000"
onkeyup="URLFieldHandler()" onblur="URLFieldHandler()">
</td>
</tr>
[% END %]
<tr>
<th><label for="description">Description:</label></th>
<td>
<em>Describe the attachment briefly.</em><br>
<input type="text" id="description" name="description" size="60" maxlength="200">
</td>
</tr>
<tr>
<th></th>
<td>
</td>
</tr>
<tr>
<th>Content Type:</th>
<td>
<em>If the attachment is a patch, check the box below.</em><br>
<input type="checkbox" id="ispatch" name="ispatch" value="1"
onchange="setContentTypeDisabledState();">
<label for="ispatch">patch</label><br><br>
[% PROCESS attachment/createformcontents.html.tmpl %]
<em>Otherwise, choose a method for determining the content type.</em><br>
<input type="radio" id="autodetect"
name="contenttypemethod" value="autodetect" checked="checked">
<label for="autodetect">auto-detect</label><br>
<input type="radio" id="list"
name="contenttypemethod" value="list">
<label for="list">select from list:</label>
<select name="contenttypeselection" id="contenttypeselection"
onchange="this.form.contenttypemethod[1].checked = true;">
[% PROCESS "attachment/content-types.html.tmpl" %]
</select><br>
<input type="radio" id="manual"
name="contenttypemethod" value="manual">
<label for="manual">enter manually:</label>
<input type="text" name="contenttypeentry" id="contenttypeentry"
size="30" maxlength="200"
onchange="if (this.value) this.form.contenttypemethod[2].checked = true;">
</td>
</tr>
[% IF (Param("insidergroup") && UserInGroup(Param("insidergroup"))) %]
<tr>
<th>Privacy:</th>
<td>
<em>If the attachment is private, check the box below.</em><br>
<input type="checkbox" name="isprivate" id="isprivate"
value="1" onClick="updateCommentPrivacy(this)">
<label for="isprivate">Private</label>
</td>
</tr>
[% END %]
[%# Additional fields for attachments on existing bugs: %]
<tr>
<th>Obsoletes:</th>
<td>
......@@ -238,14 +78,6 @@
</tr>
[% END %]
<tr>
<td> </td>
<td>
[% IF flag_types.size > 0 %]
[% PROCESS "flag/list.html.tmpl" bug_id=bugid attach_id=attachid %]<br>
[% END %]
</td>
</tr>
<tr>
<th><label for="comment">Comment:</label></th>
<td>
<em>(optional) Add a comment about this attachment to the [% terms.bug %].</em><br>
......@@ -259,6 +91,17 @@
%]
</td>
</tr>
[% IF (Param("insidergroup") && UserInGroup(Param("insidergroup"))) %]
<tr>
<th>Privacy:</th>
<td>
<em>If the attachment is private, check the box below.</em><br>
<input type="checkbox" name="isprivate" id="isprivate"
value="1" onClick="updateCommentPrivacy(this)">
<label for="isprivate">Private</label>
</td>
</tr>
[% END %]
<tr>
<th>&nbsp;</th>
<td><input type="submit" value="Submit"></td>
......@@ -267,23 +110,4 @@
</form>
<script type="text/javascript">
<!--
function setContentTypeDisabledState()
{
var entryform = document.entryform;
var isdisabled = false;
if (entryform.ispatch.checked)
isdisabled = true;
for (var i=0 ; i<entryform.contenttypemethod.length ; i++)
entryform.contenttypemethod[i].disabled = isdisabled;
entryform.contenttypeselection.disabled = isdisabled;
entryform.contenttypeentry.disabled = isdisabled;
}
//-->
</script>
[% PROCESS global/footer.html.tmpl %]
[%# 1.0@bugzilla.org %]
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Myk Melez <myk@mozilla.org>
# Joel Peshkin <bugreport@peshkin.net>
# Erik Stambaugh <erik@dasbistro.com>
# Marc Schumann <wurblzap@gmail.com>
#%]
<tr>
<th><label for="data">File</label>:</th>
<td>
<em>Enter the path to the file on your computer.</em><br>
<input type="file" id="data" name="data" size="50"
[% IF Param("allow_attach_url") %]
onchange="DataFieldHandler()"
[% END %]
>
</td>
</tr>
[% IF Param("maxlocalattachment") %]
<tr>
<th>BigFile:</th>
<td>
<input type="checkbox" id="bigfile"
name="bigfile" value="bigfile">
<label for="bigfile">
Big File - Stored locally and may be purged
</label>
</td>
</tr>
[% END %]
[% IF Param("allow_attach_url") %]
<tr>
<th><label for="attachurl">AttachURL</label>:</th>
<td>
<em>URL to be attached instead.</em><br>
<input type="text" id="attachurl" name="attachurl" size="60"
maxlength="2000"
onkeyup="URLFieldHandler()" onblur="URLFieldHandler()">
</td>
</tr>
[% END %]
<tr>
<th><label for="description">Description</label>:</th>
<td>
<em>Describe the attachment briefly.</em><br>
<input type="text" id="description" name="description" size="60" maxlength="200">
</td>
</tr>
<tr>
<th>Content Type:</th>
<td>
<em>If the attachment is a patch, check the box below.</em><br>
<input type="checkbox" id="ispatch" name="ispatch" value="1"
onchange="setContentTypeDisabledState(this.form);">
<label for="ispatch">patch</label><br><br>
<em>Otherwise, choose a method for determining the content type.</em><br>
<input type="radio" id="autodetect"
name="contenttypemethod" value="autodetect" checked="checked">
<label for="autodetect">auto-detect</label><br>
<input type="radio" id="list"
name="contenttypemethod" value="list">
<label for="list">select from list</label>:
<select name="contenttypeselection" id="contenttypeselection"
onchange="this.form.contenttypemethod[1].checked = true;">
[% PROCESS "attachment/content-types.html.tmpl" %]
</select><br>
<input type="radio" id="manual"
name="contenttypemethod" value="manual">
<label for="manual">enter manually</label>:
<input type="text" name="contenttypeentry" id="contenttypeentry"
size="30" maxlength="200"
onchange="if (this.value) this.form.contenttypemethod[2].checked = true;">
</td>
</tr>
<tr>
<td> </td>
<td>
[% IF flag_types && flag_types.size > 0 %]
[% PROCESS "flag/list.html.tmpl" bug_id=bugid attach_id=attachid %]<br>
[% END %]
</td>
</tr>
......@@ -19,12 +19,15 @@
# Contributor(s): Gervase Markham <gerv@gerv.net>
# Ville Skyttä <ville.skytta@iki.fi>
# Shane H. W. Travis <travis@sedsystems.ca>
# Marc Schumann <wurblzap@gmail.com>
#%]
[% PROCESS "global/field-descs.none.tmpl" %]
[% PROCESS global/header.html.tmpl
title = "Enter $terms.Bug: $product.name"
style_urls = [ 'skins/standard/create_attachment.css' ]
javascript_urls = [ "js/attachment.js" ]
onload="set_assign_to();"
%]
......@@ -86,10 +89,24 @@ function set_assign_to() {
[% END %]
}
}
function handleWantsAttachment(wants_attachment) {
if (wants_attachment) {
document.getElementById('attachment_false').style.display = 'none';
document.getElementById('attachment_true').style.display = 'block';
}
else {
document.getElementById('attachment_false').style.display = 'block';
document.getElementById('attachment_true').style.display = 'none';
clearAttachmentFields();
}
}
-->
</script>
<form name="Create" id="Create" method="post" action="post_bug.cgi">
<form name="Create" id="Create" method="post" action="post_bug.cgi"
enctype="multipart/form-data">
<input type="hidden" name="product" value="[% product.name FILTER html %]">
<input type="hidden" name="token" value="[% token FILTER html %]">
......@@ -316,6 +333,7 @@ function set_assign_to() {
[%- END %]
[% INCLUDE global/textarea.html.tmpl
name = 'comment'
id = 'comment'
minrows = 10
maxrows = 25
cols = constants.COMMENT_COLS
......@@ -341,6 +359,38 @@ function set_assign_to() {
<input type="hidden" name="commentprivacy" value="0">
[% END %]
<tr>
<th align="right" valign="top">Attachment:</th>
<td colspan="3">
<script type="text/javascript">
<!--
document.write( '<div id="attachment_false">'
+ '<input type="button" value="Add an attachment" '
+ 'onClick="handleWantsAttachment(true)"> '
+ '<em style="display: none">This button has no '
+ 'functionality for you because your browser does '
+ 'not support CSS or does not use it.</em>'
+ '</div>'
+ '<div id="attachment_true" style="display: none">'
+ '<input type="button" '
+ 'value="Don\'t add an attachment " '
+ 'onClick="handleWantsAttachment(false)">');
//-->
</script>
<fieldset>
<legend>Add an attachment</legend>
<table class="attachment_entry">
[% PROCESS attachment/createformcontents.html.tmpl %]
</table>
</fieldset>
<script type="text/javascript">
<!--
document.write('</div>');
//-->
</script>
</td>
</tr>
[% IF UserInGroup('editbugs') %]
[% IF use_keywords %]
<tr>
......
......@@ -100,6 +100,12 @@
The user account [% otheruser.login FILTER html %] has been deleted
successfully.
[% ELSIF message_tag == "attachment_creation_failed" %]
The [% terms.bug %] was created successfully, but attachment creation
failed.
Please add your attachment by clicking the "Create a New Attachment" link
below.
[% ELSIF message_tag == "buglist_adding_field" %]
[% title = "Adding field to search page..." %]
[% link = "Click here if the page does not redisplay automatically." %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment