Main Page | Directories | File List | File Members

include/trackers_run/admin/field_values_transition-ofields-update.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_values_transition-ofields-update.php 5429 2006-02-17 22:59:20Z toddy $
00006 #
00007 #  Copyright      2004 (c) Mathieu Roy <yeupou--at--gnu.org>
00008 #                          Yves Perrin <yves.perrin--at--cern.ch>
00009 #
00010 # The Savane project is free software; you can redistribute it and/or
00011 # modify it under the terms of the GNU General Public License
00012 # as published by the Free Software Foundation; either version 2
00013 # of the License, or (at your option) any later version.
00014 #
00015 # The Savane project is distributed in the hope that it will be useful,
00016 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 # GNU General Public License for more details.
00019 #
00020 # You should have received a copy of the GNU General Public License
00021 # along with the Savane project; if not, write to the Free Software
00022 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023 
00024 $is_admin_page='y';
00025 
00026 
00027 if ($group_id && member_check(0,$group_id,'A')) 
00028 {
00029 # Initialize global bug structures
00030   trackers_init($group_id);
00031 
00032   if (!$transition_id) 
00033     { exit_missing_param(); }
00034   $result = db_query("SELECT field_id,from_value_id,to_value_id ".
00035                      "FROM trackers_field_transition ".
00036                      "WHERE group_id='".addslashes($group_id)."' AND artifact='".ARTIFACT."' AND transition_id='".addslashes($transition_id)."'");
00037   if (!db_numrows($result)) 
00038     { exit_error(_("Transition not found")); }
00039   
00040   $field_id = db_result($result, 0, 'field_id');
00041   $field = trackers_data_get_field_name($field_id);
00042 
00043   $registered = array();
00044   $sql = trackers_transition_get_other_field_update($transition_id);
00045   while ($entry = db_fetch_array($sql))
00046       {
00047         $registered[$entry['update_field_name']] = $entry['update_value_id'];
00048       }
00049   
00050 # ################################ Update the database
00051   if ($update)
00052     { 
00053 
00054       while ($field_name = trackers_list_all_fields())
00055         {
00056           
00057           if (trackers_data_is_select_box($field_name)
00058               && ($field_name != 'submitted_by')
00059               && trackers_data_is_used($field_name)
00060               && ($field_name != $field))
00061             {
00062               $form_field="form_$field_name";
00063               if ($form_field && isset($$form_field))
00064                 {
00065                   # If there is no entry in the database, set the registered array entry
00066                   # to 0 so it looks like the form entry "no update"
00067                   if (!$registered[$field_name])
00068                     { $registered[$field_name] = 0; }
00069 
00070                   # If we get here, we found a field that could need to be updated.
00071                   # We first check if there is already an entry in the database for
00072                   # this transition and field.
00073                   # If what we have on database differs to the form, update.
00074                   if ($registered[$field_name] != $$form_field)
00075                     {
00076                       trackers_transition_update_other_field($transition_id,
00077                                                              $field_name,
00078                                                              $$form_field);
00079                       $registered[$field_name] = $$form_field;
00080                     }
00081                 }
00082               
00083               
00084             }
00085         }
00086       # After update
00087       session_redirect($GLOBALS['sys_home'].ARTIFACT.'/admin/field_values.php?group='.$group_name.'&list_value=1&field='.$field.'#registered');
00088     }
00089 
00090 # ################################  Display the UI form
00091     
00092   if (db_result($result, 0, 'from_value_id') == '100')
00093     { $from = _("None"); }
00094   elseif (db_result($result, 0, 'from_value_id') == '0')
00095     { $from = _("Any"); }
00096   else 
00097     { $from = trackers_data_get_value($field, $group_id, db_result($result, 0, 'from_value_id')); }
00098   $to = trackers_data_get_value($field, $group_id, db_result($result, 0, 'to_value_id'));
00099   
00100 
00101   trackers_header_admin(array('title'=>_("Field Values Transitions: Others Fields Update")));
00102   print '<h3>'.sprintf(_("Others Fields to update when '%s' change from '%s' to '%s':"), trackers_data_get_label($field),$from,$to).'</h3>';
00103   
00104   print '<p class="warn">'.sprintf(_("Note that if you set an automatic update of the field %s, technicians will be able to close items by changing the value of the field %s."),trackers_data_get_label('status_id'),trackers_data_get_label($field)).'</p>';
00105   print '<p>'._("Note also the automatic update process will not override field values specifically filled in forms. It means that if someone was able (depending on his role in the project) to modify/set a specific field value, any automatic update supposed to apply to this field will be disregarded.").'</p>';
00106 
00107 # here begin the form  
00108 print '<form action="'.$PHP_SELF.'" method="post">
00109 <input type="hidden" name="group" value="'.$group_name.'" />
00110 <input type="hidden" name="transition_id" value="'.$transition_id.'" />
00111 ';
00112   
00113   $title_arr=array();
00114   $title_arr[]=_("Field Label");
00115   $title_arr[]=_("New Value");
00116  
00117   print html_build_list_table_top($title_arr);
00118 
00119   while ($field_name = trackers_list_all_fields())
00120     {
00121       
00122       if (trackers_data_is_select_box($field_name)
00123           && ($field_name != 'submitted_by')
00124           && trackers_data_is_used($field_name)
00125           && ($field_name != $field))
00126         {         
00127 
00128           print "\n".'<tr class="'. utils_get_alt_row_color($i) .'"><td width="25%"><span title="'.trackers_data_get_description($field_name).'" class="help">'.trackers_data_get_label($field_name).'</span></td>';
00129 
00130           # checked to set!
00131           # Here, we about "show any" possibility of trackers_field_box to set the "No Update"
00132           # possibility. It sounded more sensible to abuse the 'show none', but "none" is a
00133           # legitimate entry here -one could want to change the field to none, if the field value
00134           # exists, while "any" does never make sense here.
00135           print '<td>'.$registered['update_value_id'].
00136             trackers_field_box($field_name,"form_".$field_name,$group_id,$registered[$field_name],false,false,true,_("No automatic update")).
00137             '</td></tr>';
00138           $i++;
00139         }
00140     }
00141   print '</table>
00142 <p align="center"><input type="submit" name="update" value="'._("Update").'" /></p>
00143 ';
00144 
00145   trackers_footer(array());
00146   
00147 }
00148 else
00149 {
00150   if (!$group_id)
00151     { exit_no_group(); }
00152   else
00153     { exit_permission_denied(); }
00154 
00155 }
00156 
00157 ?>

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