00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: add.php 5441 2006-02-19 13:53:40Z toddy $
00006 #
00007 # Copyright 1999-2000 (c) The SourceForge Crew
00008 # Copyright 2001-2002 (c) Laurent Julliard, CodeX Team, Xerox
00009 #
00010 # Copyright 2003-2005 (c) Mathieu Roy <yeupou--gnu.org>
00011 # Yves Perrin <yves.perrin--cern.ch>
00012 #
00013 #
00014 # The Savane project is free software; you can redistribute it and/or
00015 # modify it under the terms of the GNU General Public License
00016 # as published by the Free Software Foundation; either version 2
00017 # of the License, or (at your option) any later version.
00018 #
00019 # The Savane project is distributed in the hope that it will be useful,
00020 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00022 # GNU General Public License for more details.
00023 #
00024 # You should have received a copy of the GNU General Public License
00025 # along with the Savane project; if not, write to the Free Software
00026 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00027
00028
00029 if (!group_restrictions_check($group_id, ARTIFACT))
00030 {
00031 exit_error(sprintf(_("Action Unavailable: %s"), group_getrestrictions_explained($group_id, ARTIFACT)));
00032 }
00033
00034 trackers_header(array('title'=>_("Submit Item")));
00035 $fields_per_line=2;
00036 $max_size=40;
00037
00038 # First display the message preamble
00039 $res_preamble = db_query("SELECT ".ARTIFACT."_preamble FROM groups WHERE group_id=$group_id");
00040
00041 print utils_unconvert_htmlspecialchars(db_result($res_preamble,0,ARTIFACT.'_preamble'));
00042 print '<h3>'._("Details").'</h3>';
00043
00044 # Beginning of the submission form with fixed fields
00045 print form_header($PHP_SELF, $form_id, "post", 'enctype="multipart/form-data" name="trackers_form"');
00046 print form_input("hidden", "func", "postadditem");
00047 print form_input("hidden", "group_id", $group_id);
00048 print '
00049 <table cellpadding="0" width="100%">';
00050
00051
00052 # Now display the variable part of the field list (depend on the project)
00053
00054 $i=0;
00055 $j=0;
00056 $is_trackeradmin = member_check(0,$group_id,member_create_tracker_flag(ARTIFACT).'2');
00057
00058 while ($field_name = trackers_list_all_fields())
00059 {
00060
00061 # if the field is a special field (except summary and original description)
00062 # or if not used by this project then skip it.
00063 # Plus only show fields allowed on the bug submit_form
00064 if ((!trackers_data_is_special($field_name) || $field_name=='summary' || $field_name=='details') &&
00065 trackers_data_is_used($field_name))
00066 {
00067
00068 if (($is_trackeradmin && trackers_data_is_showed_on_add_members($field_name)) ||
00069 (!$is_trackeradmin && trackers_data_is_showed_on_add($field_name)) ||
00070 (!user_isloggedin() && trackers_data_is_showed_on_add_nologin($field_name)) )
00071 {
00072
00073 # display the bug field with its default value
00074 # if field size is greatest than max_size chars then force it to
00075 # appear alone on a new line or it wont fit in the page
00076
00077 # We allow people to make urls with predefined values,
00078 # if the values are in the url, we override the default value.
00079 if (!$$field_name)
00080 { $field_value = trackers_data_get_default_value($field_name); }
00081 else
00082 { $field_value = htmlspecialchars(stripslashes($$field_name)); }
00083
00084 list($sz,) = trackers_data_get_display_size($field_name);
00085 $label = trackers_field_label_display($field_name,
00086 $group_id,
00087 false,
00088 false);
00089 # check if the field is mandatory
00090 unset($star);
00091 $mandatory_flag = trackers_data_mandatory_flag($field_name);
00092 if ($mandatory_flag == 3 || $mandatory_flag == 0)
00093 {
00094 $star = '<span class="warn"> *</span>';
00095 $mandatory_flag = 0;
00096 }
00097
00098 # Field display with special Unknown option, only for fields that
00099 # are no mandatory
00100 $value = trackers_field_display($field_name,
00101 $group_id,
00102 $field_value,
00103 false, #4
00104 false,
00105 false, #6
00106 false,
00107 false, #8
00108 false,
00109 false, #10
00110 false,
00111 true, #12
00112 $mandatory_flag);
00113
00114 # Fields colors
00115 unset($field_class, $row_class);
00116 if ($j % 2 && $field_name != 'details')
00117 {
00118 # We keep the original submission with the default
00119 # background color, for lisibility sake
00120 #
00121 # We also use the boxitem background color only one time
00122 # out of two, to keep the page light
00123 $row_class = ' class="'.utils_altrow($j+1).'"';
00124 }
00125
00126 # If we are working on the cookbook, present checkboxes to
00127 # defines context before the summary line;
00128 if (CONTEXT == 'cookbook' && $field_name == 'summary' && $is_trackeradmin)
00129 {
00130 cookbook_print_form();
00131 }
00132
00133 # We highlight fields that were not properly/completely
00134 # filled.
00135 if ($previous_form_bad_fields && array_key_exists($field_name, $previous_form_bad_fields))
00136 {
00137 $field_class = ' class="highlight"';
00138 }
00139
00140 if ($sz > $max_size)
00141 {
00142 # Field getting one line for itself
00143
00144 # Each time prepare the background color change
00145 $j++;
00146
00147 print "\n<tr".$row_class.">".
00148 '<td valign="middle"'.$field_class.' width="15%">'.$label.'</td>'.
00149 '<td valign="middle"'.$field_class.' colspan="'.(2*$fields_per_line-1).'" width="75%">'.
00150 $value.$star.'</TD>'.
00151 "\n</tr>";
00152 $i=0;
00153 }
00154 else
00155 {
00156 # Field getting half of a line for itself
00157
00158 if (!($i % $fields_per_line))
00159 {
00160 # Every one out of two, prepare the background color change.
00161 # We do that at this moment because we cannot be sure
00162 # there will be another field on this line.
00163 $j++;
00164 }
00165
00166 print ($i % $fields_per_line ? "\n":"\n<tr".$row_class.">");
00167 print '<td valign="middle"'.$field_class.' width="15%">'.$label.'</td>'.
00168 '<td valign="middle"'.$field_class.' width="35%">'.$value.$star.'</td>';
00169 $i++;
00170 print ($i % $fields_per_line ? "\n":"\n</tr>");
00171 }
00172 }
00173 }
00174 }
00175
00176
00177 print '</table>';
00178 print '<p class="warn"><span class="smaller">* '._("Mandatory Fields").'</span></p>';
00179
00180 # possibility of attachment
00181
00182
00183 print '<p> </p>';
00184 print '<h3>'._("Attached Files").'</h3>';
00185 print '<span class="preinput"> '._("Attach File:").'</span><br />
00186 <input type="file" name="input_file" size="40" />
00187 <br />
00188 <span class="preinput">'._("File Description:").'</span><br />
00189 <input type="text" name="file_description" size="60" maxlength="255" />
00190 </p><p>';
00191
00192
00193 # Cc addresses
00194 if (user_isloggedin())
00195 {
00196
00197 print '<p> </p>';
00198 print '<h3>'._("Mail Notification CC").'</h3>';
00199
00200 printf (_("(Note: for %s users, you can use their login name rather than their email addresses.)"), $GLOBALS['sys_name']);
00201
00202 print '<p><span class="preinput">'
00203 ._("Add CC:").'</span><br /> <input type="text" name="add_cc" size="40" />
00204 <br />
00205 <span class="preinput">'
00206 ._("Comment:").'</span><br /> <input type="text" name="cc_comment" size="40" maxlength="255" />';
00207 print '<p></p>';
00208 }
00209
00210
00211 print '<p> </p>';
00212 print '<p><span class="warn">'._("Did you check to see if this item has already been submitted?").'</span></p>';
00213 print '<div align="center">';
00214 print '<input type="submit" name="submit" class="bold" value="'._("Submit").'" />';
00215 print '</div>';
00216 print '</form>';
00217
00218
00219 trackers_footer(array());
00220
00221 ?>