Main Page | Directories | File List | File Members

include/trackers_run/admin/field_usage.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: field_usage.php 5375 2006-02-14 23:14:03Z toddy $
00006 #
00007 #  Copyright 2001-2002 (c) Laurent Julliard, CodeX Team, Xerox
00008 #
00009 #  Copyright 2003-2005 (c) Mathieu Roy <yeupou--gnu.org>
00010 #
00011 # The Savane project is free software; you can redistribute it and/or
00012 # modify it under the terms of the GNU General Public License
00013 # as published by the Free Software Foundation; either version 2
00014 # of the License, or (at your option) any later version.
00015 #
00016 # The Savane project is distributed in the hope that it will be useful,
00017 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 # GNU General Public License for more details.
00020 #
00021 # You should have received a copy of the GNU General Public License
00022 # along with the Savane project; if not, write to the Free Software
00023 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00024 
00025 
00026 $is_admin_page='y';
00027 
00028 if ($group_id && user_ismember($group_id,'A')) {
00029 
00030   # Initialize global bug structures
00031   trackers_init($group_id);
00032 
00033 
00034   if ($post_changes)
00035     {
00036 ###########################################################################
00037       # A form was posted to update a field
00038 
00039       if ($submit)
00040         {
00041           if (isset($n1) && isset($n2))
00042             { $display_size = "$n1/$n2"; }
00043 
00044 
00045           if (!trackers_data_is_required($field))
00046             {
00047                # Vote must be possible for members
00048                # Vote cannot be possible for non logged in
00049               if ($field == "vote") 
00050                 {
00051                   $show_on_add_nologin = 0;
00052                   $show_on_add_members = 1;
00053                 }
00054             }
00055           else
00056             {
00057               # Do not let the user change these field settings
00058               # if the field is required
00059               $show_on_add_members = trackers_data_is_showed_on_add_members($field);
00060               $show_on_add = trackers_data_is_showed_on_add($field);
00061               $show_on_add_nologin = trackers_data_is_showed_on_add_nologin($field);
00062               
00063             }
00064 
00065           # the additional possibility of differently treating non project
00066           # members who have a savannah account and users without a
00067           # savannah account demanded a new handling of the values of
00068           # the show_on_add field:
00069           # bit 1 set: show for logged in non project members
00070           # bit 2 set: show for non logged in users
00071           $show_on_add = $show_on_add | $show_on_add_nologin;
00072 
00073           trackers_data_update_usage($field,
00074                                      $group_id,
00075                                      $label,
00076                                      $description,
00077                                      $status,
00078                                      $place,
00079                                      $display_size,
00080                                      $mandatory_flag,
00081                                      $keep_history,
00082                                      $show_on_add_members,
00083                                      $show_on_add,
00084                                      $form_transition_default_auth);
00085         }
00086       else if ($reset)
00087         {
00088           trackers_data_reset_usage($field,$group_id);
00089         }
00090       # force a re-initialization of the global structure after
00091       # the update and before we redisplay the field list
00092       trackers_init($group_id);
00093     }
00094 
00095 
00096   if ($update_field)
00097     {
00098 
00099 ###########################################################################
00100       # Show the form to change a field setting
00101 
00102       # HELP:
00103       #   - "required" means the field must be used, no matter what
00104       #   - "special" means the field is not entered by the user but by the
00105       #   system
00106 
00107       trackers_header_admin(array ('title'=>_("Modify Field Usage")));
00108 
00109 
00110       ######
00111       ## General stuff
00112      
00113       print '<form action="'.$PHP_SELF.'" method="post">';
00114       print '<input type="hidden" name="post_changes" value="y" />
00115       <input type="hidden" name="field" value="'.$field.'" />
00116       <input type="hidden" name="group_id" value="'.$group_id.'" />
00117       <h2>'
00118         ._("Field Label:").' ';
00119 
00120       $closetag = ' &nbsp;&nbsp; <span class="smaller">('.utils_link($GLOBALS['sys_home'].ARTIFACT.'/admin/field_values.php?group='.$group_name.'&amp;list_value=1&amp;field='.$field, _("Jump to this field values")).")</span></h2>\n";
00121 
00122       # If it is a custom field let the user change the label and description
00123       if (trackers_data_is_custom($field))
00124         {
00125           print '<input type="text" name="label" value="'.trackers_data_get_label($field).
00126             '" size="20" maxlength="85">'.$closetag;
00127           print '<span class="preinput">'._("Description:").' </span>';
00128           print '<br />&nbsp;&nbsp;&nbsp;<input type="text" name="description" value="'.trackers_data_get_description($field).
00129             '" size="70" maxlength="255" /><br />';
00130         }
00131       else
00132         {
00133           print trackers_data_get_label($field).$closetag;
00134         }
00135 
00136       print '<span class="preinput">'._("Status:").' </span>&nbsp;&nbsp;';
00137 
00138       # Display the Usage box (Used, Unused select box  or hardcoded "required')
00139       if (trackers_data_is_required($field))
00140         {
00141           print '<br />&nbsp;&nbsp;&nbsp;'._("Required");
00142           print '<input type="hidden" name="status" value="1" />';
00143         }
00144       else
00145         {
00146           print '<br />&nbsp;&nbsp;&nbsp;
00147 <select name="status">
00148            <option value="1"'.(trackers_data_is_used($field)?' selected="selected"':'').'>'._("Used").'</option>
00149            <option value="0"'.(trackers_data_is_used($field)?'':' selected="selected"').'>'._("Unused").'</option>
00150 </select>';
00151         }
00152       
00153       # Ask they want to save the history of the item
00154       if (!trackers_data_is_special($field))
00155         {
00156           print '<br /><span class="preinput">'._("Item History:").' </span>
00157 <br />&nbsp;&nbsp;&nbsp;
00158 <select name="keep_history">
00159            <option value="1"'.(trackers_data_do_keep_history($field)?' selected="selected"':'').'>'._("Keep field value changes in history").'</option>
00160            <option value="0"'.(trackers_data_do_keep_history($field)?'':' selected="selected"').'>'._("Ignore field value changes in history").'</option>
00161 </select>';
00162 
00163         }
00164 
00165       ######
00166       ## Content control
00167 
00168       print "\n\n<p>&nbsp;</p><h3>"._("Access:").'</h3>';
00169  
00170       # Set mandatory bit: if the field is special, meaning it is entered
00171       # by the system, or if it is "priority", assume the 
00172       # admin is not entitled to modify this behavior
00173       if (!trackers_data_is_special($field))
00174         {
00175           # "Mandatory" is not really 100% mandatory, only if it is possible
00176           # for a user to fill the entry.
00177           # It is "Mandatory whenever possible".
00178           $mandatory_flag = trackers_data_mandatory_flag($field);
00179           print '<span class="preinput">'._("This field is:").' </span>
00180 <br />&nbsp;&nbsp;&nbsp;
00181 <select name="mandatory_flag">
00182            <option value="1"'.(($mandatory_flag == 1)?' selected="selected"':'').'>'._("Optional (empty values are accepted)").'</option> 
00183            <option value="3"'.(($mandatory_flag == 3)?' selected="selected"':'').'>'._("Mandatory").'</option>
00184            <option value="0"'.(($mandatory_flag == 0)?' selected="selected"':'').'>'._("Mandatory only if it was presented to the original submitter").'</option>
00185 </select><br />';
00186         }
00187 
00188       print '<span class="preinput">'._("On new item submission, present this field to:").' </span>';
00189       unset($checkbox_members, $checkbox_loggedin, $checkbox_anonymous);
00190       if (!trackers_data_is_required($field))
00191         {
00192           # Some fields require specific treatment
00193           if ($field != "vote" && $field != "originator_email") 
00194             {
00195               $checkbox_members = '<input type="checkbox" name="show_on_add_members" value="1"'.
00196                 (trackers_data_is_showed_on_add_members($field)?' checked="checked"':'').' />';
00197               $checkbox_anonymous = '<input type="checkbox" name="show_on_add_nologin" value="2"'.
00198                 (trackers_data_is_showed_on_add_nologin($field)?' checked="checked"':'').' />';   
00199               $checkbox_loggedin = '<input type="checkbox" name="show_on_add" value="1"'.
00200             (trackers_data_is_showed_on_add($field)?' checked="checked"':'').' />';
00201             }
00202           else
00203             {
00204               # Vote must be possible for members
00205               # Vote cannot be possible for non logged in
00206              if ($field != "vote") 
00207               {
00208                 $checkbox_members = '+';
00209                 $checkbox_anonymous = 0;
00210                 $checkbox_loggedin = '<input type="checkbox" name="show_on_add" value="1"'.
00211             (trackers_data_is_showed_on_add($field)?' checked="checked"':'').' />';
00212               }
00213 
00214               # Originator email is, by the code, available only to
00215               # anonymous
00216              if ($field != "vote") 
00217               { 
00218                 $checkbox_members = 0;
00219                 $checkbox_loggedin = 0;
00220                 $checkbox_anonymous = '<input type="checkbox" name="show_on_add_nologin" value="2"'.
00221                 (trackers_data_is_showed_on_add_nologin($field)?' checked="checked"':'').' />';   
00222 
00223               }
00224 
00225             }
00226 
00227         }
00228       else
00229         {
00230           # Do not let the user change these field settings
00231           if (trackers_data_is_showed_on_add_members($field))
00232             {
00233               $checkbox_members = '+';
00234             }
00235           if (trackers_data_is_showed_on_add($field))
00236             {
00237               $checkbox_loggedin = '+';
00238             }
00239           if (trackers_data_is_showed_on_add_nologin($field))
00240             {
00241               $checkbox_anonymous = '+';
00242             }
00243         }
00244       
00245       if ($checkbox_members) 
00246         {
00247           print '<br />&nbsp;&nbsp;&nbsp;'.$checkbox_members.' '._("Project Members");
00248         }
00249       if ($checkbox_loggedin) 
00250         {
00251           print '<br />&nbsp;&nbsp;&nbsp;'.$checkbox_loggedin.' '._("Logged-in Users");
00252         }      
00253       if ($checkbox_anonymous) 
00254         {
00255           print '<br />&nbsp;&nbsp;&nbsp;'.$checkbox_anonymous.' '._("Anonymous Users");
00256         }
00257 
00258 
00259 
00260       ######
00261       ## Display control
00262 
00263       print "\n\n<p>&nbsp;</p><h3>"._("Display:").'</h3>';
00264  
00265       # yeupou--gnu.org 2005-07-18
00266       # I suspect that the is_special affect the way the field shown, 
00267       # making useless the rank parameter.
00268       # Check the previous comments
00269       if (!trackers_data_is_special($field))
00270         {
00271           print '<span class="preinput">'._("Rank on screen:").' </span><br />&nbsp;&nbsp;&nbsp;';
00272           print '<input type="text" name="place" value="'.trackers_data_get_place($field).
00273             '" size="6" maxlength="6" /><br />'."\n";
00274         }
00275       else 
00276         {
00277            print '<input type="hidden" name="place" value="'.trackers_data_get_place($field).'" />';
00278         }
00279 
00280       # Customize field size only for text fields and text areas.
00281       if (trackers_data_is_text_field($field))
00282         {
00283           list($size,$maxlength) = trackers_data_get_display_size($field);
00284 
00285           print '<span class="preinput">'._("Visible size of the field:").' </span><br />&nbsp;&nbsp;&nbsp;';
00286           print '<input type="text" name="n1" value="'.$size.'" size="3" maxlength="3" /><br />';
00287           print '<span class="preinput">'._("Maximum size of the field content (up to 255):").' </span><br />&nbsp;&nbsp;&nbsp;';
00288           print '<input type="text" name="n2" value="'.$maxlength.'" size="3" maxlength="3" /><br />';
00289         }
00290       else if (trackers_data_is_text_area($field))
00291         {
00292           list($rows,$cols) = trackers_data_get_display_size($field);
00293 
00294           print '<span class="preinput">'._("Number of columns of the field:").' </span><br />&nbsp;&nbsp;&nbsp;';
00295           print '<input type="text" name="n1" value="'.$rows.'" size="3" maxlength="3" /><br />';
00296           print '<span class="preinput">'._("Number of rows  of the field:").' </span><br />&nbsp;&nbsp;&nbsp;';
00297           print '<input type="text" name="n2" value="'.$cols.'" size="3" maxlength="3" /><br />';
00298         }
00299 
00300       ######
00301       ## Transitions
00302      
00303       $transition_default_auth = 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');
00304 
00305       print "\n\n<p>&nbsp;</p><h3>"._("By default, transitions (from one value to another) are:").'</h3>';
00306       print '&nbsp;&nbsp;&nbsp;<input type="radio" name="form_transition_default_auth" value="A" '.(($transition_default_auth!='F')?' checked="checked"':'').' /> '._("Allowed").'<br />&nbsp;&nbsp;&nbsp;<input type="radio" name="form_transition_default_auth" value="F" '.(($transition_default_auth=='F')?'checked="checked"':'').' /> '._("Forbidden");
00307 
00308       print '
00309         <p align="center">
00310         <input type="submit" name="submit" value="'._("Update").'" />
00311         &nbsp;&nbsp;
00312         <input type="submit" name="reset" value="'
00313         ._("Reset to defaults").'" /></p>
00314         </form>';
00315 
00316 
00317 
00318       trackers_footer(array());
00319 
00320     }
00321   else
00322     {
00323       
00324 ###########################################################################
00325       ## Show main page
00326 
00327       trackers_header_admin(array ('title'=>_("Field Usage")));
00328 
00329 
00330       # Show all the fields currently available in the system
00331       $i=0;
00332       $title_arr=array();
00333       $title_arr[]=_("Field Label");
00334       $title_arr[]=_("Type");
00335       $title_arr[]=_("Description");
00336       $title_arr[]=_("Rank on screen");
00337       $title_arr[]=_("Scope");
00338       $title_arr[]=_("Status");
00339 
00340       $hdr = html_build_list_table_top ($title_arr);
00341 
00342       # Build HTML ouput for  Used fields first and Unused field second
00343       $iu=$in=$inc=0;
00344       while ( $field_name = trackers_list_all_fields() )
00345         {
00346 
00347           # Do not show some special fields any way in the list
00348           # because there is nothing to customize in them
00349           if (($field_name == 'group_id') ||
00350               ($field_name == 'comment_type_id') ||
00351               ($field_name == 'bug_id') ||
00352               ($field_name == 'date') ||
00353               ($field_name == 'close_date') ||
00354               ($field_name == 'submitted_by') )
00355             { continue; }
00356 
00357           # Show Used, Unused and Required fields on separate lists
00358           # SHow Unused Custom field in a separate list at the very end
00359           $is_required = trackers_data_is_required($field_name);
00360           $is_custom = trackers_data_is_custom($field_name);
00361 
00362           $is_used = trackers_data_is_used($field_name);
00363           $status_label = ($is_required?_("Required"):($is_used?_("Used"):_("Unused")));
00364 
00365           $scope_label  = (trackers_data_get_scope($field_name)=='S'?
00366                            _("System"):_("Project"));
00367           $place_label = ($is_used?trackers_data_get_place($field_name):'-');
00368 
00369           $html = '<td><a href="'.$PHP_SELF.'?group_id='.$group_id.
00370              '&update_field=1&field='.$field_name.'">'.
00371              trackers_data_get_label($field_name).'</a></td>'.
00372              "\n<td>".trackers_data_get_display_type_in_clear($field_name).'</td>'.
00373              "\n<td>".trackers_data_get_description($field_name).
00374              (($is_custom && $is_used) ? ' - <strong>['._("Custom Field").']</strong>':'').'</td>'.
00375              "\n<td align =\"center\">".$place_label.'</td>'.
00376              "\n<td align =\"center\">".$scope_label.'</td>'.
00377              "\n<td align =\"center\">".$status_label.'</td>';
00378 
00379           if ($is_used)
00380             {
00381               $html = '<tr class="'.
00382                  utils_get_alt_row_color($iu) .'">'.$html.'</tr>';
00383               $iu++;
00384               $hu .= $html;
00385             }
00386           else
00387             {
00388               if ($is_custom)
00389                 {
00390                   $html = '<tr class="'.
00391                      utils_get_alt_row_color($inc) .'">'.$html.'</tr>';
00392                   $inc++;
00393                   $hnc .= $html;
00394                 }
00395               else
00396                 {
00397                   $html = '<tr class="'.
00398                      utils_get_alt_row_color($in) .'">'.$html.'</tr>';
00399                   $in++;
00400                   $hn .= $html;
00401                 }
00402             }
00403 
00404         } /* end while all fields */
00405 
00406       # Now print the HTML table
00407       if ($iu == 0)
00408         {
00409           $html = '<p>'._("No extension field in use.").' '._("Choose one below.").'</p>'.$html;
00410         }
00411       else
00412         {
00413           $hu= '<tr><td colspan="5"><center><strong>---- '._("USED FIELDS").' ----</strong></center></tr>'.$hu;
00414           if ($in)
00415             {
00416               $hn = '<tr><td colspan="5"> &nbsp;</td></tr>'.
00417                  '<tr><td colspan="5"><center><strong>---- '._("UNUSED STANDARD FIELDS").' ----</strong></center></tr>'.$hn;
00418             }
00419 
00420           if ($inc)
00421             {
00422               $hnc = '<tr><td colspan="5"> &nbsp;</td></tr>'.
00423                  '<tr><td colspan="5"><center><strong>---- '._("UNUSED CUSTOM FIELDS").' ----</strong></center></tr>'.$hnc;
00424             }
00425         }
00426       print $hdr.$hu.$hn.$hnc.'</table>';
00427 
00428 
00429       trackers_footer(array());
00430     }
00431 
00432 
00433 } else {
00434 
00435 ###########################################################################
00436   #browse for group first message
00437 
00438   if (!$group_id)
00439     {
00440       exit_no_group();
00441     }
00442   else
00443     {
00444       exit_permission_denied();
00445     }
00446 
00447 }
00448 
00449 ?>

Generated on Sun Feb 26 13:23:03 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4