00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: field_values.php 5494 2006-02-24 17:38:57Z yeupou $
00006 #
00007 # Copyright 2001-2002 (c) Laurent Julliard, CodeX Team, Xerox
00008 #
00009 # Copyright 2003-2006 (c) Mathieu Roy <yeupou--gnu.org>
00010 # Yves Perrin <yves.perrin--cern.ch>
00011 #
00012 #
00013 # The Savane project is free software; you can redistribute it and/or
00014 # modify it under the terms of the GNU General Public License
00015 # as published by the Free Software Foundation; either version 2
00016 # of the License, or (at your option) any later version.
00017 #
00018 # The Savane project is distributed in the hope that it will be useful,
00019 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021 # GNU General Public License for more details.
00022 #
00023 # You should have received a copy of the GNU General Public License
00024 # along with the Savane project; if not, write to the Free Software
00025 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00026
00027 $is_admin_page='y';
00028
00029 if ($group_id && user_ismember($group_id,'A'))
00030 {
00031 # Initialize global bug structures
00032 trackers_init($group_id);
00033
00034
00035 # ################################ Update the database
00036
00037 if ($func == "deltransition")
00038 {
00039 $sql="DELETE FROM trackers_field_transition WHERE transition_id = '".addslashes($transition_id)."' LIMIT 1";
00040 $result=db_query($sql);
00041 if (!$result)
00042 {
00043 fb(_("Error deleting transition"),1);
00044 }
00045 else
00046 {
00047 fb(_("Transition deleted"));
00048 }
00049 }
00050 elseif ($post_changes || $delete_canned)
00051 {
00052 # A form of some sort was posted to update or create
00053 # an existing value
00054
00055 # Deleted Canned doesnt need a forum, so let switch
00056 # into this code
00057
00058 if ($create_value)
00059 {
00060 # A form was posted to update a field value
00061 if ($value)
00062 {
00063 trackers_data_create_value($field,$group_id,
00064 htmlspecialchars($value),
00065 htmlspecialchars($description),
00066 $order_id,'A');
00067 }
00068 else
00069 {
00070 fb(_("Empty field value not allowed"), 1);
00071 }
00072
00073 }
00074 else if ($update_value)
00075 {
00076 # A form was posted to update a field value
00077 if ($value)
00078 {
00079 trackers_data_update_value($fv_id, $field, $group_id,
00080 htmlspecialchars($value),
00081 htmlspecialchars($description),
00082 $order_id,$status);
00083 }
00084 else
00085 {
00086 fb(_("Empty field value not allowed"), 1);
00087 }
00088
00089 }
00090 else if ($create_canned)
00091 {
00092
00093 # A form was posted to create a canned response
00094 $sql="INSERT INTO ".ARTIFACT."_canned_responses (group_id,title,body,order_id) ".
00095 " VALUES ('$group_id','". htmlspecialchars($title) .
00096 "','". htmlspecialchars($body) ."','".addslashes($order_id)."')";
00097 $result=db_query($sql);
00098 if (!$result)
00099 {
00100 fb(_("Error inserting canned bug response"),1);
00101 }
00102 else
00103 {
00104 fb(_("Canned bug response inserted"));
00105 }
00106
00107 }
00108 else if ($update_canned)
00109 {
00110 # A form was posted to update a canned response
00111 $sql="UPDATE ".ARTIFACT."_canned_responses ".
00112 "SET title='". htmlspecialchars($title) ."', body='". htmlspecialchars($body)."', order_id='".addslashes($order_id)."'".
00113 " WHERE group_id='$group_id' AND bug_canned_id='$item_canned_id'";
00114 $result=db_query($sql);
00115 if (!$result)
00116 {
00117 fb(_("Error updating canned bug response"),1);
00118 }
00119 else
00120 {
00121 fb(_("Canned bug response updated"));
00122 }
00123 }
00124 # Delete Response
00125 else if ($_GET['delete_canned'] == '1')
00126 {
00127 $sql="DELETE FROM ".ARTIFACT."_canned_responses ".
00128 "WHERE group_id='".addslashes($group_id)."' AND bug_canned_id='".addslashes($item_canned_id)."'";
00129 $result=db_query($sql);
00130 if (!$result) {
00131 fb(_("Error deleting canned bug response"),1);
00132 }
00133 else
00134 {
00135 fb(_("Canned bug response deleted"));
00136 }
00137 }
00138 }
00139
00140 $field_id = ($by_field_id ? $field : trackers_data_get_field_id($field));
00141
00142
00143 if ($to != $from) {
00144 # A form was posted to update or create a transition
00145 $sql="SELECT from_value_id,to_value_id,is_allowed,notification_list ".
00146 "FROM trackers_field_transition ".
00147 "WHERE group_id='$group_id' AND artifact='".ARTIFACT."' AND field_id='$field_id' AND from_value_id='$from' AND to_value_id='$to' ";
00148 $res_value = db_query($sql);
00149 $rows=db_numrows($res_value);
00150
00151 # If no entry for this transition, create one
00152 if ($rows == 0)
00153 {
00154
00155 $sql = "INSERT INTO trackers_field_transition ".
00156 "(group_id,artifact,field_id,from_value_id,to_value_id,is_allowed,notification_list) ".
00157 "VALUES ('$group_id','".ARTIFACT."','$field_id','$from','$to','$allowed','$mail_list')";
00158 $result = db_query($sql);
00159
00160 if (db_affected_rows($result) < 1)
00161 { fb(_("Insert failed."), 1); }
00162 else
00163 { fb(_("New transition inserted.")); }
00164 }
00165 else
00166 {
00167 # update the existing entry for this transition
00168 $sql = "UPDATE trackers_field_transition ".
00169 "SET is_allowed='$allowed',notification_list='$mail_list' ".
00170 "WHERE group_id='$group_id' AND artifact='".ARTIFACT."' AND field_id='$field_id' AND from_value_id='$from' AND to_value_id='$to' ";
00171 $result = db_query($sql);
00172
00173 if (db_affected_rows($result) < 1)
00174 {
00175 fb(_("Update of transition failed."), 1);
00176 }
00177 else
00178 {
00179 fb(_("Transition updated."));
00180 }
00181 }
00182 }
00183
00184
00185 # ################################ Display the UI form
00186
00187 if ($list_value)
00188 {
00189
00190 # Display the List of values for a given bug field
00191
00192 $hdr = sprintf(_("Manage Field Values for '%s'"),trackers_data_get_label($field));
00193
00194 trackers_header_admin(array ('title'=>$hdr));
00195
00196 print '<h2>'._("Field Label:").' '.trackers_data_get_label($field).' <span class="smaller">('.utils_link($GLOBALS['sys_home'].ARTIFACT.'/admin/field_usage.php?group='.$group_name.'&update_field=1&field='.$field, _("Jump to this field usage")).")</span></h2>\n";
00197
00198
00199
00200 # First check that this field is used by the project and
00201 # it is in the project scope
00202
00203 $is_project_scope = trackers_data_is_project_scope($field);
00204
00205 if ( trackers_data_get_field_id($field) &&
00206 trackers_data_is_select_box($field))
00207 {
00208
00209 $result = trackers_data_get_field_predefined_values($field, $group_id,false,false,false);
00210 $rows = db_numrows($result);
00211
00212 if ($result && $rows > 0)
00213 {
00214 print "\n<h3>".html_anchor(_("Existing Values"),"existing").'</h3>';
00215
00216 $title_arr=array();
00217 if (!$is_project_scope)
00218 { $title_arr[]='ID'; }
00219 $title_arr[]=_("Value label");
00220 $title_arr[]=_("Description");
00221 $title_arr[]=_("Rank");
00222 $title_arr[]=_("Status");
00223 $title_arr[]=_("Occurences");
00224
00225
00226 $hdr = html_build_list_table_top ($title_arr);
00227
00228 $ia = $ih = 0;
00229 $status_stg = array('A' => _("Active"), 'P' => _("Permanent"), 'H' => _("Hidden"));
00230
00231 # Display the list of values in 2 blocks : active first
00232 # Hidden second
00233 while ( $fld_val = db_fetch_array($result) )
00234 {
00235
00236 $item_fv_id = $fld_val['bug_fv_id'];
00237 $status = $fld_val['status'];
00238 $value_id = $fld_val['value_id'];
00239 $value = $fld_val['value'];
00240 $description = $fld_val['description'];
00241 $order_id = $fld_val['order_id'];
00242 $usage = trackers_data_count_field_value_usage($group_id, $field, $value_id);
00243
00244 $html = '';
00245
00246 # keep the rank of the 'None' value in mind if any (see below)
00247 if ($value == 100)
00248 { $none_rk = $order_id; }
00249
00250 # Show the value ID only for system wide fields which
00251 # value id are fixed and serve as a guide.
00252 if (!$is_project_scope)
00253 !$html .='<td>'.$value_id.'</td>';
00254
00255 # The permanent values cant be modified (No link)
00256 if ($status == 'P')
00257 {
00258 $html .= '<td>'.$value.'</td>';
00259 }
00260 else
00261 {
00262 $html .= '<td><a href="'.$PHP_SELF.'?update_value=1'.
00263 '&fv_id='.$item_fv_id.'&field='.$field.
00264 '&group_id='.$group_id.'">'.$value.'</A></td>';
00265 }
00266
00267 $html .= '<td>'.$description.' </td>'.
00268 '<td align="center">'.$order_id.'</td>'.
00269 '<td align="center">'.$status_stg[$status].'</td>';
00270
00271 if ($status == 'H' && $usage > 0)
00272 {
00273 $html .= '<td align="center"><strong class="warn">'.$usage.'</strong></td>';
00274 }
00275 else
00276 {
00277 $html .= '<td align="center">'.$usage.'</td>';
00278 }
00279
00280 if ($status == 'A' || $status == 'P')
00281 {
00282 $html = '<tr class="'.
00283 utils_get_alt_row_color($ia) .'">'.$html.'</tr>';
00284 $ia++;
00285 $ha .= $html;
00286 }
00287 else
00288 {
00289 $html = '<tr class="'.
00290 utils_get_alt_row_color($ih) .'">'.$html.'</tr>';
00291 $ih++;
00292 $hh .= $html;
00293 }
00294
00295 }
00296
00297 # Display the list of values now
00298 if ($ia == 0)
00299 {
00300 $hdr = '<p>'._("No Active value for this field. Create one or reactivate a hidden value (if any)").'</p>'.$hdr;
00301 }
00302 else
00303 {
00304 $ha = '<tr><td colspan="4" class="center"><strong>'._("---- ACTIVE VALUES ----").'</strong></tr>'.$ha;
00305 }
00306 if ($ih)
00307 {
00308 $hh = '<tr><td colspan="4"> </td></tr>'.
00309 '<tr><td colspan="4"><center><strong>'._("---- HIDDEN VALUES ----").'</strong></center></tr>'.$hh;
00310 }
00311
00312 print $hdr.$ha.$hh.'</table>';
00313
00314 }
00315 else
00316 {
00317 printf ("\n<h2>"._("No values defined yet for %s").'</h2>',trackers_data_get_label($field));
00318 }
00319
00320
00321 # Only show the add value form if this is a project scope field
00322 if ($is_project_scope)
00323 {
00324
00325 print '<br />';
00326 print '<h3>'.html_anchor(_("Create a new field value"),"create").'</h3>';
00327
00328 if ($ih)
00329 {
00330 print '<p>'._("Before you create a new value make sure there isn't one in the hidden list that suits your needs.").'</p>';
00331 }
00332
00333 # yeupou--gnu.org 2004-09-12: a red star should mention with fields
00334 # are mandatory
00335
00336 print '
00337 <form action="'.$PHP_SELF.'" method="post">
00338 <input type="hidden" name="post_changes" value="y" />
00339 <input type="hidden" name="create_value" value="y" />
00340 <input type="hidden" name="list_value" value="y" />
00341 <input type="hidden" name="field" value="'.$field.'" />
00342 <input type="hidden" name="group_id" value="'.$group_id.'" />
00343 <span class="preinput">'._("Value:").' </span>
00344 <input type="text" name="value" value="" size="30" maxlength="60"/>
00345
00346 <span class="preinput">'._("Rank:").' </span>
00347 <input type="text" name="order_id" value="" size="6" maxlength="6" />';
00348
00349 if (isset($none_rk))
00350 {
00351 print " <strong> (must be > $none_rk)</strong><br /></p>";
00352 }
00353
00354 print '
00355 <p>
00356 <span class="preinput">'._("Description (optional):").'</span><br />
00357 <textarea name="description" rows="4" cols="65" wrap="hard"></textarea></p>
00358 <div class="center">
00359 <input type="submit" name="submit" value="'._("Update").'" />
00360 </div>
00361 </form>';
00362
00363 }
00364
00365 # If the project use custom values, propose to reset to the default
00366 if (trackers_data_use_field_predefined_values($field,$group_id)) {
00367
00368 print '<h3>'._("Reset values").'</h3>';
00369 print '<p>'._("You are currently using custom values. If you want to reset values to the default ones, use the following form:").'</p>';
00370
00371 print '<form action="field_values_reset.php" method="post" class="center">';
00372 print '<input type="hidden" name="group_id" value="'.$group_id.'" />';
00373 print '<input type="hidden" name="field" value="'.$field.'" />';
00374 print '<input type="submit" name="submit" value="'._("Reset Values").'" /> ';
00375 print '</form>';
00376
00377
00378
00379 print '<p>'._("For your information, the default active values are:").'</p>';
00380
00381 $default_result = trackers_data_get_field_predefined_values($field, '100',false,false,false);
00382 $default_rows = db_numrows($default_result);
00383 if ($default_result && $default_rows > 0)
00384 {
00385 while ($fld_val = db_fetch_array($default_result))
00386 {
00387 $status = $fld_val['status'];
00388 $value = $fld_val['value'];
00389 $description = $fld_val['description'];
00390 $order = $fld_val['order_id'];
00391
00392 # non-active value are not important here
00393 if ($status != "A")
00394 { continue; }
00395
00396 if ($previous)
00397 { print ", "; }
00398
00399 print '<strong>'.$value.'</strong> <span class="smaller">('.$order.', "'.$description.'")</span>';
00400 $previous = 1;
00401 }
00402
00403 }
00404 else
00405 {
00406 print '<p class="error">'._("No default values found. You should report this problem to administrators.").'</p>';
00407 }
00408
00409
00410 }
00411
00412 }
00413 else
00414 {
00415
00416 print '<h2>';
00417 printf (_("The field you requested '%s' is not used by your project or you are not allowed to customize it"),$field);
00418 print '</h2>';
00419 }
00420
00421
00422 # Transitions
00423 # yeupou--gnu.org 2004-09-12: where the hell is by_field_id set?
00424 $field_id = ($by_field_id ? $field : trackers_data_get_field_id($field));
00425 if ( trackers_data_get_field_id($field) &&
00426 trackers_data_is_select_box($field))
00427 {
00428
00429 # First get all the value_id - value pairs
00430 $sql="SELECT value_id,value ".
00431 "FROM ".ARTIFACT."_field_value ".
00432 "WHERE group_id='".addslashes($group_id)."' AND bug_field_id='".addslashes($field_id)."'";
00433 $res_value = db_query($sql);
00434 $rows=db_numrows($res_value);
00435
00436 if ($rows > 0)
00437 {
00438 $val_label = array();
00439 while ($val_row = db_fetch_array($res_value))
00440 {
00441 $value_id = $val_row['value_id'];
00442 $value = $val_row['value'];
00443 $val_label[$value_id] = $value;
00444 }
00445 }
00446 else
00447 {
00448 $sql="SELECT value_id,value ".
00449 "FROM ".ARTIFACT."_field_value ".
00450 "WHERE group_id=100 AND bug_field_id='".addslashes($field_id)."'";
00451 $res_value = db_query($sql);
00452 $rows=db_numrows($res_value);
00453
00454 if ($rows > 0)
00455 {
00456 $val_label = array();
00457 while ($val_row = db_fetch_array($res_value))
00458 {
00459 $value_id = $val_row['value_id'];
00460 $value = $val_row['value'];
00461 $val_label[$value_id] = $value;
00462 }
00463 }
00464 }
00465
00466 $sql="SELECT transition_id,from_value_id,to_value_id,is_allowed,notification_list ".
00467 "FROM trackers_field_transition ".
00468 "WHERE group_id='".addslashes($group_id)."' AND artifact='".ARTIFACT."' AND field_id='".addslashes($field_id)."' ";
00469
00470 $result = db_query($sql);
00471 $rows = db_numrows($result);
00472
00473 if ($result && $rows > 0)
00474 {
00475 print "\n\n<p> </p><h3>".html_anchor(_("Registered Transitions"),"registered").'</h3>';
00476
00477 $title_arr=array();
00478 $title_arr[]=_("From");
00479 $title_arr[]=_("To");
00480 $title_arr[]=_("Is Allowed");
00481 $title_arr[]=_("Others Fields Update");
00482 $title_arr[]=_("Carbon-Copy List");
00483 $title_arr[]=_("Delete?");
00484
00485
00486 $hdr = html_build_list_table_top ($title_arr);
00487 print $hdr;
00488
00489 $reg_default_auth = '';
00490 $z = 1;
00491 while ($transition = db_fetch_array($result))
00492 {
00493 $z++;
00494 if ($transition['is_allowed'] == 'A') {
00495 $allowed = _("Yes");
00496 } else {
00497 $allowed = _("No");
00498 }
00499
00500 print '<tr class="'.utils_altrow($z).'">';
00501 if ($val_label[$transition['from_value_id']])
00502 {
00503 print '<td align="center">'.$val_label[$transition['from_value_id']].'</td>';
00504 }
00505 else
00506 {
00507 print '<td align="center">'._("* - Any").'</td>';
00508 }
00509
00510 print '<td align="center">'.$val_label[$transition['to_value_id']].'</td>'
00511 .'<td align="center">'.$allowed.'</td>';
00512
00513 if ($transition['is_allowed'] == 'A')
00514 {
00515 print '<td align="center">';
00516 # Get list of registered field updates
00517 $registered = trackers_transition_get_other_field_update($transition['transition_id']);
00518 # Make sure $content is clean
00519 unset($content);
00520 # No result? Print only a link
00521 if ($registered)
00522 {
00523 while ($entry = db_fetch_array($registered))
00524 {
00525 # Add one entry per registered other field update
00526 $content .= trackers_data_get_label($entry['update_field_name']).":".trackers_data_get_value($entry['update_field_name'], $group_id, $entry['update_value_id']).", ";
00527 }
00528 # Remove extra comma
00529 $content = trim($content, ", ");
00530 }
00531 else
00532 {
00533 $content = _("Edit others fields update");
00534 }
00535
00536 print utils_link($GLOBALS['sys_home'].ARTIFACT."/admin/field_values_transition-ofields-update.php?group=".$group_name."&transition_id=".$transition['transition_id'], $content);
00537 print '</td><td align="center">'.$transition['notification_list'].'</td>';
00538 }
00539 else
00540 {
00541 print '<td align="center">---------</td>'
00542 .'<td align="center">--------</td>';
00543 }
00544 print '<td align="center">'.utils_link($PHP_SELF.'?group='.$group_name.'&func=deltransition&transition_id='.$transition['transition_id'].'&list_value=1&field='.$field, '<img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/trash.png" border="0" alt="'._("Delete this transition?").'" />').'</td>';
00545 print '</tr>';
00546 }
00547
00548 print '</table>';
00549 }
00550 else
00551 {
00552 $reg_default_auth = '';
00553 printf ("\n\n<p> </p><h3>"._("No transition defined yet for %s").'</h3>',trackers_data_get_label($field));
00554 }
00555
00556
00557 print '
00558 <form action="'.$PHP_SELF.'#registered" method="post">
00559 <input type="hidden" name="post_transition_changes" value="y" />
00560 <input type="hidden" name="list_value" value="y" />
00561 <input type="hidden" name="tracker_name" value="'.ARTIFACT.'" />
00562 <input type="hidden" name="field" value="'.$field.'" />
00563 <input type="hidden" name="group_id" value="'.$group_id.'" />';
00564
00565 if (db_result(db_query("SELECT transition_default_auth FROM ".ARTIFACT."_field_usage WHERE group_id='$group_id' AND bug_field_id='".trackers_data_get_field_id($field)."'"), 0, 'transition_default_auth') == "F")
00566 {
00567 $transition_for_field = _("By default, for this field, the transitions not registered are forbidden. This setting can be changed when managing this field usage.");
00568 }
00569 else
00570 {
00571 $transition_for_field = _("By default, for this field, the transitions not registered are allowed. This setting can be changed when managing this field usage.");
00572 }
00573 print "\n\n<p> </p><h3>".html_anchor(_("Create / Edit a transition"),"create").'</h3>';
00574
00575 print "<p>$transition_for_field</p>\n";
00576 print '<p>'._("Once a transition created, it will be possible to set \"Others Fields Update\" for this transition.").'</p>';
00577
00578 $title_arr=array();
00579 $title_arr[]=_("From");
00580 $title_arr[]=_("To");
00581 $title_arr[]=_("Is Allowed");
00582 $title_arr[]=_("Carbon-Copy List");
00583
00584 $auth_label = array();
00585 $auth_label[] = 'allowed';
00586 $auth_label[] = 'forbidden';
00587 $auth_val = array();
00588 $auth_val[] = 'A';
00589 $auth_val[] = 'F';
00590
00591 $hdr = html_build_list_table_top ($title_arr);
00592
00593 $from = '<td>'.trackers_field_box($field,'from',$group_id,false,false, false, 1, _("* - Any")).'</td>';
00594 $to = '<td>'.trackers_field_box($field,'to',$group_id,false,false).'</td>';
00595 print $hdr.'<tr>'.$from.$to;
00596
00597 print '<td>'.html_build_select_box_from_arrays ($auth_val,$auth_label,'allowed', 'allowed',false).'</td>';
00598
00599 $mlist = '<td>'.'
00600 <input type="text" name="mail_list" value="" size="30" maxlength="60" />
00601 </td>';
00602
00603 print $mlist.'</tr></table>';
00604
00605 print '<div align="center"><input type="submit" name="submit" value="'._("Update Transition").'" /></div>
00606 </form>';
00607 }
00608 else
00609 {
00610
00611 print "\n\n<p> </p><h3>";
00612 printf (_("The Bug field you requested '%s' is not used by your project or you are not allowed to customize it"),$field);
00613 print '</h3>';
00614 }
00615
00616 }
00617 else if ($update_value)
00618 {
00619 # Show the form to update an existing field_value
00620 # Display the List of values for a given bug field
00621
00622 trackers_header_admin(array ('title'=>_("Update Field Values")));
00623
00624 # Get all attributes of this value
00625 $res = trackers_data_get_field_value($fv_id);
00626
00627 print '<form action="'.$PHP_SELF.'" method="post">
00628 <input type="hidden" name="post_changes" value="y" />
00629 <input type="hidden" name="update_value" value="y" />
00630 <input type="hidden" name="list_value" value="y" />
00631 <input type="hidden" name="fv_id" value="'.$fv_id.'" />
00632 <input type="hidden" name="field" value="'.$field.'" />
00633 <input type="hidden" name="group_id" value="'.$group_id.'" />
00634 <p><span class="preinput">'
00635 ._("Value:").' </span><br />
00636 <input type="text" name="value" value="'.db_result($res,0,'value').'" size="30" maxlength="60" />
00637
00638 <span class="preinput">'
00639 ._("Rank:").' </span>
00640 <input type="text" name="order_id" value="'.db_result($res,0,'order_id').'" size="6" maxlength="6"/>
00641
00642 <span class="preinput">'
00643 ._("Status:").' </span>
00644 <select name="status">
00645 <option value="A">'
00646 ._("Active").'</option>
00647 <option value="H"'.((db_result($res,0,'status') == 'H') ? ' selected="selected"':'').'>'
00648 ._("Hidden").'</option>
00649 </select>
00650 <p>
00651 <span class="preinput">'._("Description: (optional)").'</span><br />
00652 <textarea name="description" rows="4" cols="65" wrap="soft">'.db_result($res,0,'description').'</textarea></p>';
00653
00654 $count = trackers_data_count_field_value_usage($group_id, $field, db_result($res,0,'value_id'));
00655 if ($count > 0)
00656 {
00657 print '<p class="warn">';
00658 printf(ngettext("This field value applies to %s item of your tracker.", "This field value applies to %s items of your tracker.", $count)." ", $count);
00659 printf(_("If you hide this field value, the related items will have no value in the field '%s'."), $field).'</p>';
00660 }
00661 print '
00662 <div class="center">
00663 <input type="submit" name="submit" value="'._("Submit").'" />
00664 </p>';
00665
00666
00667 }
00668 else if ($create_canned || $delete_canned)
00669 {
00670
00671
00672
00673 trackers_header_admin(array ('title'=>_("Create/Modify Canned Responses")));
00674
00675 $sql="SELECT * FROM ".ARTIFACT."_canned_responses WHERE group_id='$group_id' ORDER BY order_id ASC";
00676 $result=db_query($sql);
00677 $rows=db_numrows($result);
00678
00679 if($result && $rows > 0)
00680 {
00681
00682
00683
00684 print "\n<h3>"._("Existing Responses:").'</h3><p>';
00685
00686 $title_arr=array();
00687 $title_arr[]=_("Title");
00688 $title_arr[]=_("Body (abstract)");
00689 $title_arr[]=_("Rank");
00690 $title_arr[]=_("Delete?");
00691
00692 print html_build_list_table_top ($title_arr);
00693
00694 for ($i=0; $i < $rows; $i++)
00695 {
00696 # FIXME: delete should use the basket, like it is done in many
00697 # other places
00698 print '<tr class="'. utils_get_alt_row_color($i) .'">'.
00699 '<td><a href="'.$PHP_SELF.'?update_canned=1&item_canned_id='.
00700 db_result($result, $i, 'bug_canned_id').'&group_id='.$group_id.'">'.
00701 db_result($result, $i, 'title').'</A></TD>'.
00702 '<td>'.substr(db_result($result, $i, 'body'),0,360).'...'.
00703 '<td>'.db_result($result, $i, 'order_id').'<td class="center"><a href="'.$PHP_SELF.'?delete_canned=1&item_canned_id='.
00704 db_result($result, $i, 'bug_canned_id').'&group_id='.$group_id.'"><img src="'.$GLOBALS['sys_home'].'images/'.SV_THEME.'.theme/trash.png" border="0" alt="'._("Delete this canned answer?").'" />
00705 </a></td></tr>';
00706 }
00707 print '</table>';
00708
00709 }
00710 else
00711 {
00712 print "\n<h3>"._("No canned bug responses set up yet").'</h3>';
00713 }
00714
00715
00716
00717
00718 print '<h3>'._("Create a new response").'</h3>
00719 <p>
00720 '._("Creating generic quick responses can save a lot of time when giving common responses.").'</p>
00721 <form action="'.$PHP_SELF.'" method="post">
00722 <input type="hidden" name="create_canned" value="y" />
00723 <input type="hidden" name="group_id" value="'.$group_id.'" />
00724 <input type="hidden" name="post_changes" value="y" />
00725 <span class="preinput">'._("Title:").'</span><br />
00726 <input type="text" name="title" value="" size="50" maxlength="50" /><br />
00727 <span class="preinput">'._("Rank (useful in multiple canned responses):").'</span><br />
00728 <input type="text" name="order_id" value="" maxlength="50" /><br />
00729 <span class="preinput">'._("Message Body:").'</span><br />
00730 <textarea name="body" rows="20" cols="65" wrap="hard"></textarea>
00731 <div class="center">
00732 <input type="submit" name="submit" value="'._("Submit").'" />
00733 </div>
00734 </form>';
00735
00736
00737
00738 }
00739 else if ($update_canned)
00740 {
00741 # Allow change of canned responses
00742 trackers_header_admin(array ('title'=>_("Modify Canned Response")));
00743
00744 $sql="SELECT bug_canned_id,title,body,order_id FROM ".ARTIFACT."_canned_responses WHERE ".
00745 "group_id='".addslashes($group_id)."' AND bug_canned_id='".addslashes($item_canned_id)."'";
00746
00747 $result=db_query($sql);
00748
00749 if (!$result || db_numrows($result) < 1)
00750 {
00751 fb(_("No such response!"),1);
00752 }
00753 else
00754 {
00755 # Escape to print update form
00756
00757 print '<p>'
00758 ._("Creating generic messages can save you a lot of time when giving common responses.").'</p>
00759 <p>
00760 <form action="'.$PHP_SELF.'" method="post">
00761 <input type="hidden" name="update_canned" value="y" />
00762 <input type="hidden" name="group_id" value="'.$group_id.'" />
00763 <input type="hidden" name="item_canned_id" value="'.$item_canned_id.'" />
00764 <input type="hidden" name="post_changes" value="y" />
00765 <span class="preinput">'._("Title").':</span><br />
00766 <input type="text" name="title" value="'.db_result($result,0,'title').'" size="50" maxlength="50" /></p>
00767 <p>
00768 <span class="preinput">'._("Rank").':</span><br />
00769 <input type="text" name="order_id" value="'.db_result($result,0,'order_id').'" /></p>
00770 <p>
00771 <span class="preinput">'._("Message Body:").'</span><br />
00772 <textarea name="body" rows="20" cols="65" wrap="hard">'.db_result($result,0,'body').'</textarea></p>
00773 <div class="center">
00774 <input type="submit" name="submit" value="Submit" />
00775 </div>
00776 </form>';
00777
00778 }
00779
00780 }
00781 else
00782 {
00783
00784 ######## Complete list of fields
00785
00786 trackers_header_admin(array ('title'=>_("Field Values Management")));
00787
00788 # Loop through the list of all used fields that are project manageable
00789 $i=0;
00790 $title_arr=array();
00791 $title_arr[]=_("Field Label");
00792 $title_arr[]=_("Description");
00793 $title_arr[]=_("Scope");
00794 print html_build_list_table_top ($title_arr);
00795 while ( $field_name = trackers_list_all_fields() )
00796 {
00797
00798 if ( trackers_data_is_select_box($field_name)
00799 && ($field_name != 'submitted_by')
00800 && ($field_name != 'assigned_to')
00801 && trackers_data_is_used($field_name) )
00802 {
00803
00804 $scope_label = (trackers_data_is_project_scope($field_name)?
00805 _("Project"):_("System"));
00806
00807 print '<tr class="'. utils_get_alt_row_color($i) .'">'.
00808 '<td><a href="'.$PHP_SELF.'?group_id='.$group_id.'&list_value=1&field='.$field_name.'">'.trackers_data_get_label($field_name).'</a></td>'.
00809 "\n<td>".trackers_data_get_description($field_name).'</td>'.
00810 "\n<td>".$scope_label.'</td>'.
00811 '</tr>';
00812 $i++;
00813 }
00814 }
00815
00816 # Now the special canned response field
00817 print '<tr class="'. utils_get_alt_row_color($i) .'">';
00818 print "<td><a href=\"$PHP_SELF?group_id=$group_id&create_canned=1\">"._("Canned Responses").'</a></td>';
00819 print "\n<td>"._("Create or Change generic quick response messages for this issue tracker. Theses pre-written messages can then be used to quickly reply to item submission.").' </td>';
00820 print "\n<td>"._("Project").'</td></tr>';
00821 print '</table>';
00822 }
00823
00824 trackers_footer(array());
00825
00826 }
00827 else
00828 {
00829 #browse for group first message
00830 if (!$group_id)
00831 {
00832 exit_no_group();
00833 }
00834 else
00835 {
00836 exit_permission_denied();
00837 }
00838
00839 }
00840
00841 ?>