Main Page | Directories | File List | File Members

data.php File Reference

Go to the source code of this file.

Functions

 trackers_data_get_all_fields ($group_id=false, $reload=false)
 trackers_data_get_item_group ($item_id)
trackers_data_get_notification_settings ($group_id, $tracker_name)
 trackers_data_show_notification_settings ($group_id, $tracker_name, $show_intro_msg)
 trackers_data_post_notification_settings ($group_id, $tracker_name)
 trackers_data_get_item_notification_info ($item_id, $artifact, $updated)
 cmp_place ($ar1, $ar2)
 cmp_place_query ($ar1, $ar2)
 cmp_place_result ($ar1, $ar2)
 trackers_data_get_all_report_fields ($group_id=false, $report_id=100)
 trackers_data_get_field_predefined_values ($field, $group_id=false, $checked=false, $by_field_id=false, $active_only=true)
 trackers_data_use_field_predefined_values ($field, $group_id)
 trackers_data_is_custom ($field, $by_field_id=false)
 trackers_data_is_special ($field, $by_field_id=false)
 trackers_data_is_empty_ok ($field, $by_field_id=false)
 trackers_data_mandatory_flag ($field, $by_field_id=false)
 trackers_data_do_keep_history ($field, $by_field_id=false)
 trackers_data_is_required ($field, $by_field_id=false)
 trackers_data_is_used ($field, $by_field_id=false)
 trackers_data_is_showed_on_query ($field)
 trackers_data_is_showed_on_result ($field)
 trackers_data_is_showed_on_add ($field, $by_field_id=false)
 trackers_data_is_showed_on_add_nologin ($field, $by_field_id=false)
 trackers_data_is_showed_on_add_members ($field, $by_field_id=false)
 trackers_data_is_date_field ($field, $by_field_id=false)
 trackers_data_is_text_field ($field, $by_field_id=false)
 trackers_data_is_text_area ($field, $by_field_id=false)
 trackers_data_is_select_box ($field, $by_field_id=false)
 trackers_data_is_username_field ($field, $by_field_id=false)
 trackers_data_is_project_scope ($field, $by_field_id=false)
 trackers_data_is_status_closed ($status)
 trackers_data_get_field_name ($field_id)
 trackers_data_get_field_id ($field_name)
 trackers_data_get_group_id ($field, $by_field_id=false)
 trackers_data_get_label ($field, $by_field_id=false)
 trackers_data_get_description ($field, $by_field_id=false)
 trackers_data_get_display_type ($field, $by_field_id=false)
 trackers_data_get_display_type_in_clear ($field, $by_field_id=false)
 trackers_data_get_keep_history ($field, $by_field_id=false)
 trackers_data_get_place ($field, $by_field_id=false)
 trackers_data_get_scope ($field, $by_field_id=false)
 trackers_data_get_col_width ($field, $by_field_id=false)
 trackers_data_get_display_size ($field, $by_field_id=false)
 trackers_data_get_default_value ($field, $by_field_id=false)
 trackers_data_get_max_value_id ($field, $group_id, $by_field_id=false)
 trackers_data_get_cached_field_value ($field, $group_id, $value_id)
 trackers_data_get_field_value ($item_fv_id)
 trackers_data_is_default_value ($item_fv_id)
 trackers_data_create_value ($field, $group_id, $value, $description, $order_id, $status='A', $by_field_id=false)
 trackers_data_update_value ($item_fv_id, $field, $group_id, $value, $description, $order_id, $status='A')
 trackers_data_reset_usage ($field_name, $group_id)
 trackers_data_update_usage ($field_name, $group_id, $label, $description, $use_it, $rank, $display_size, $empty_ok, $keep_history, $show_on_add_members=0, $show_on_add=0, $transition_default_auth='A')
 trackers_data_get_technicians ($group_id)
 trackers_data_get_transition ($group_id)
 trackers_data_get_submitters ($group_id=false)
 trackers_data_get_items ($group_id=false, $artifact)
 trackers_data_get_dependent_items ($item_id=false, $artifact, $notin=false)
 trackers_data_get_valid_bugs ($group_id=false, $item_id='')
 trackers_data_get_followups ($item_id=false, $rorder=true)
 trackers_data_get_commenters ($item_id)
 trackers_data_get_history ($item_id=false)
 trackers_data_get_attached_files ($item_id=false, $order='DESC')
 trackers_data_get_cc_list ($item_id=false)
 trackers_data_add_history ($field_name, $old_value, $new_value, $item_id, $type=false, $artifact=0, $force=0)
 trackers_data_handle_update ($group_id, $item_id, $dependent_on_task, $dependent_on_bugs, $dependent_on_support, $dependent_on_patch, $canned_response, $vfl, &$changes, &$extra_addresses)


Function Documentation

cmp_place ar1,
ar2
 

Definition at line 360 of file data.php.

00361 {
00362   if ($ar1['place']< $ar2['place'])
00363     return -1;
00364   else if ($ar1['place']>$ar2['place'])
00365     return 1;
00366   return 0;
00367 }

cmp_place_query ar1,
ar2
 

Definition at line 369 of file data.php.

00370 {
00371   if ($ar1['place_query']< $ar2['place_query'])
00372     return -1;
00373   else if ($ar1['place_query']>$ar2['place_query'])
00374     return 1;
00375   return 0;
00376 }

cmp_place_result ar1,
ar2
 

Definition at line 378 of file data.php.

00379 {
00380   if ($ar1['place_result']< $ar2['place_result'])
00381     return -1;
00382   else if ($ar1['place_result']>$ar2['place_result'])
00383     return 1;
00384   return 0;
00385 }

trackers_data_add_history field_name,
old_value,
new_value,
item_id,
type = false,
artifact = 0,
force = 0
 

Definition at line 1332 of file data.php.

Referenced by cookbook_handle_update(), trackers_data_handle_update(), and trackers_transition_update_item().

01340 {
01341 
01342   # If no artifact is defined, get the default one
01343   if (!$artifact)
01344     {
01345       $artifact = ARTIFACT;
01346     }
01347 
01348   # If field is not to be kept in bug change history then do nothing
01349   if (!$force && !trackers_data_get_keep_history($field_name))
01350     { return; }
01351 
01352   if (!user_isloggedin())
01353     {
01354       $user=100;
01355     }
01356   else
01357     {
01358       $user=user_getid();
01359     }
01360 
01361   # If type has a value add it into the sql statement (this is only for
01362   # the follow up comments (details field))
01363   if ($type)
01364     {
01365       $fld_type = ',type'; $val_type = ",'$type'";
01366     }
01367   else
01368     {
01369         # No comment type specified for a followup comment
01370         # so force it to None (100)
01371       if ($field_name == 'details')
01372         {
01373           $fld_type = ',type'; $val_type = ",'100'";
01374         }
01375     }
01376 
01377 
01378   $sql="INSERT INTO ".$artifact."_history (bug_id,field_name,old_value,new_value,mod_by,date $fld_type) ".
01379      "VALUES ('$item_id','$field_name','$old_value','$new_value','$user','".time()."' $val_type)";
01380   return db_query($sql);
01381 }

trackers_data_create_value field,
group_id,
value,
description,
order_id,
status = 'A',
by_field_id = false
 

Definition at line 975 of file data.php.

References $feedback, $field_id, $sql, db_affected_rows(), db_query(), group_id, trackers_data_get_field_id(), and trackers_data_get_max_value_id().

00976 {
00977 
00978   global $feedback,$ffeedback;
00979 
00980   /*
00981       Insert a new value for a given field for a given group
00982   */
00983 
00984   # An empty field value is not allowed
00985   if (preg_match ("/^\s*$/", $value))
00986     {
00987       fb(_("Empty field value not allowed"), 0);
00988       return;
00989     }
00990 
00991   if (!$by_field_id)
00992     {
00993       $field_id = trackers_data_get_field_id($field);
00994     }
00995 
00996   # if group_id=100 (None) then do nothing
00997   # because no real project should have the group number '100'
00998   if ($group_id != 100)
00999     {
01000 
01001       # if the current value set for this project is empty
01002       # then copy the default values first (if any)
01003       if (trackers_data_is_value_set_empty($field,$group_id))
01004         {
01005           trackers_data_copy_default_values($field,$group_id);
01006         }
01007 
01008       # Find the next value_id to give to this new value. (Start arbitrarily
01009       # at 200 if no value exists (and therefore max is undefined)
01010       $max_value_id = trackers_data_get_max_value_id($field, $group_id);
01011 
01012       if ($max_value_id < 0)
01013         {
01014           $value_id = 200;
01015         }
01016       else
01017         {
01018           $value_id = $max_value_id +1;
01019         }
01020 
01021 
01022       $sql = "INSERT INTO ".ARTIFACT."_field_value ".
01023          "(bug_field_id,group_id,value_id,value,description,order_id,status) ".
01024          "VALUES ('$field_id','$group_id','$value_id','$value','$description','$order_id','$status')";
01025       db_query($sql);
01026 
01027       if (db_affected_rows($result) < 1)
01028         {
01029           fb(_("Insert failed."), 0);
01030           ' - '.db_error();
01031         }
01032       else
01033 
01034         {
01035           fb(_("New field value inserted."));
01036         }
01037     }
01038 }

trackers_data_do_keep_history field,
by_field_id = false
 

Definition at line 554 of file data.php.

References $field.

00555 {
00556   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00557   if ($by_field_id)
00558     {
00559       $val = $BF_USAGE_BY_ID[$field]['custom_keep_history'];
00560       if (!isset($val))
00561         { $val = $BF_USAGE_BY_ID[$field]['empty_keep_history']; }
00562     }  else
00563       {
00564         $val = $BF_USAGE_BY_NAME[$field]['custom_keep_history'];
00565         if (!isset($val))
00566           { $val = $BF_USAGE_BY_NAME[$field]['keep_history']; }
00567       }
00568   return($val);
00569 }

trackers_data_get_all_fields group_id = false,
reload = false
 

Definition at line 37 of file data.php.

References $sql, db_fetch_array(), db_query(), and group_id.

00038 {
00039 
00040   /*
00041            Get all the possible bug fields for this project both used and unused. If
00042            used then show the project specific information about field usage
00043            otherwise show the default usage parameter
00044            Make sure array element are sorted by ascending place
00045   */
00046 
00047   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME, $AT_START;
00048 
00049   # Do nothing if already set and reload not forced
00050   if (isset($BF_USAGE_BY_ID) && !$reload)
00051     {
00052       return;
00053     }
00054 
00055   # Clean up the array
00056   $BF_USAGE_BY_ID=array();
00057   $BF_USAGE_BY_NAME=array();
00058 
00059   # First get the all the defaults.
00060   $sql='SELECT '.ARTIFACT.'_field.bug_field_id, field_name, display_type, '.
00061      'display_size,label, description,scope,required,empty_ok,keep_history,special, custom, '.
00062      'group_id, use_it,show_on_add,show_on_add_members, place, custom_label,'.
00063      'custom_description,custom_display_size,custom_empty_ok,custom_keep_history '.
00064      'FROM '.ARTIFACT.'_field, '.ARTIFACT.'_field_usage '.
00065      'WHERE group_id=100  '.
00066      'AND  '.ARTIFACT.'_field.bug_field_id='.ARTIFACT.'_field_usage.bug_field_id ';
00067 
00068   $res_defaults = db_query($sql);
00069 
00070   # Now put all used fields in a global array for faster access
00071   # Index both by field_name and bug_field_id
00072   while ($field_array = db_fetch_array($res_defaults))
00073     {
00074       $BF_USAGE_BY_ID[$field_array['bug_field_id'] ] = $field_array;
00075       $BF_USAGE_BY_NAME[$field_array['field_name'] ] = $field_array;
00076     }
00077 
00078   # Then select  all project specific entries
00079   $sql='SELECT  '.ARTIFACT.'_field.bug_field_id, field_name, display_type, '.
00080      'display_size,label, description,scope,required,empty_ok,keep_history,special, custom, '.
00081      'group_id, use_it, show_on_add, show_on_add_members, place, custom_label,'.
00082      'custom_description,custom_display_size,custom_empty_ok,custom_keep_history '.
00083      'FROM '.ARTIFACT.'_field,  '.ARTIFACT.'_field_usage '.
00084      'WHERE group_id='.$group_id.
00085      ' AND  '.ARTIFACT.'_field.bug_field_id= '.ARTIFACT.'_field_usage.bug_field_id ';
00086 
00087 
00088   $res_project = db_query($sql);
00089 
00090   # And override entries in the default array
00091   while ($field_array = db_fetch_array($res_project))
00092     {
00093       $BF_USAGE_BY_ID[$field_array['bug_field_id'] ] = $field_array;
00094       $BF_USAGE_BY_NAME[$field_array['field_name'] ] = $field_array;
00095     }
00096 
00097   #Debug code
00098   #print "<br />DBG - At end of bug_get_all_fields: $rows";
00099   #reset($BF_USAGE_BY_NAME);
00100   #while (list($key, $val) = each($BF_USAGE_BY_NAME))
00101   #{
00102   #print "<br />DBG - $key -> use_it: $val[use_it], $val[place]";
00103   #}
00104 
00105   # rewind internal pointer of global arrays
00106   reset($BF_USAGE_BY_ID);
00107   reset($BF_USAGE_BY_NAME);
00108   $AT_START = true;
00109 }

trackers_data_get_all_report_fields group_id = false,
report_id = 100
 

Definition at line 387 of file data.php.

References $field, $field_id, $res, $sql, db_fetch_array(), db_query(), safeinput(), and trackers_data_get_field_id().

00388 {
00389   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00390 
00391   /*
00392            Get all the bug fields involved in the bug report.
00393            WARNING: This function ust only be called after bug_init()
00394   */
00395 
00396   # Build the list of fields involved in this report
00397   $sql = "SELECT * FROM ".ARTIFACT."_report_field WHERE report_id='".safeinput($report_id)."'";
00398   $res = db_query($sql);
00399 
00400   while ($arr = db_fetch_array($res))
00401     {
00402       $field = $arr['field_name'];
00403       $field_id = trackers_data_get_field_id($field);
00404       $BF_USAGE_BY_NAME[$field]['show_on_query'] =
00405          $BF_USAGE_BY_ID[$field_id]['show_on_query'] = $arr['show_on_query'];
00406 
00407       $BF_USAGE_BY_NAME[$field]['show_on_result'] =
00408          $BF_USAGE_BY_ID[$field_id]['show_on_result'] = $arr['show_on_result'];
00409 
00410       $BF_USAGE_BY_NAME[$field]['place_query'] =
00411          $BF_USAGE_BY_ID[$field_id]['place_query'] = $arr['place_query'];
00412 
00413       $BF_USAGE_BY_NAME[$field]['place_result'] =
00414          $BF_USAGE_BY_ID[$field_id]['place_result'] = $arr['place_result'];
00415 
00416       $BF_USAGE_BY_NAME[$field]['col_width'] =
00417          $BF_USAGE_BY_ID[$field_id]['col_width'] = $arr['col_width'];
00418     }
00419 }

trackers_data_get_attached_files item_id = false,
order = 'DESC'
 

Definition at line 1313 of file data.php.

Referenced by format_item_attached_files().

01314 {
01315   $sql="SELECT file_id,filename,filesize,filetype,description,date,user.user_name ".
01316      "FROM trackers_file,user ".
01317      "WHERE submitted_by=user.user_id ".
01318      "AND artifact='".ARTIFACT."' ".
01319      "AND item_id='$item_id' ORDER BY date $order";
01320   return db_query($sql);
01321 }

trackers_data_get_cached_field_value field,
group_id,
value_id
 

Definition at line 933 of file data.php.

References $field, $res, db_fetch_array(), group_id, and trackers_data_get_field_predefined_values().

Referenced by show_item_list(), and show_item_list_sober().

00934 {
00935   global $BF_VALUE_BY_NAME;
00936 
00937   if (!isset($BF_VALUE_BY_NAME[$field][$value_id]))
00938     {
00939       $res = trackers_data_get_field_predefined_values ($field, $group_id,false,false,false);
00940 
00941       while ($fv_array = db_fetch_array($res))
00942         {
00943           # $fv_array[0] has the value_id and [1] is the value
00944           $BF_VALUE_BY_NAME[$field][$fv_array['value_id']] = $fv_array[1];
00945         }
00946     }
00947 
00948   return $BF_VALUE_BY_NAME[$field][$value_id];
00949 }

trackers_data_get_cc_list item_id = false  ) 
 

Definition at line 1323 of file data.php.

Referenced by format_item_cc_list().

01324 {
01325   $sql="SELECT bug_cc_id,".ARTIFACT."_cc.email,".ARTIFACT."_cc.added_by,".ARTIFACT."_cc.comment,".ARTIFACT."_cc.date,user.user_name ".
01326      "FROM ".ARTIFACT."_cc,user ".
01327      "WHERE added_by=user.user_id ".
01328      "AND bug_id='$item_id' ORDER BY date DESC";
01329   return db_query($sql);
01330 }

trackers_data_get_col_width field,
by_field_id = false
 

Definition at line 783 of file data.php.

References $field.

00784 {
00785   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00786   return($by_field_id ? $BF_USAGE_BY_ID[$field]['col_width'] : $BF_USAGE_BY_NAME[$field]['col_width']);
00787 }

trackers_data_get_commenters item_id  ) 
 

Definition at line 1295 of file data.php.

01296 {
01297   $sql="SELECT DISTINCT mod_by FROM ".ARTIFACT."_history ".
01298      "WHERE ".ARTIFACT."_history.bug_id='$item_id' ".
01299      "AND ".ARTIFACT."_history.field_name = 'details' ";
01300   return db_query($sql);
01301 }

trackers_data_get_default_value field,
by_field_id = false
 

Definition at line 806 of file data.php.

References $field, $result, bug, db_query(), db_result, and trackers_data_get_field_name().

00807 {
00808   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00809   /*
00810       Return the default value associated to a field_name as defined in the
00811       bug table (SQL definition)
00812   */
00813   if ($by_field_id)
00814     {
00815       $field = trackers_data_get_field_name($field);
00816     }
00817 
00818   $result = db_query('describe bug '.$field);
00819   return (db_result($result,0,'Default'));
00820 
00821 }

trackers_data_get_dependent_items item_id = false,
artifact,
notin = false
 

Definition at line 1250 of file data.php.

References $sql, db_query(), and print.

01251 {
01252   /*
01253                 Get the list of ids this is dependent on
01254   */
01255   $sql="SELECT is_dependent_on_item_id FROM ".ARTIFACT."_dependencies WHERE item_id='$item_id' AND is_dependent_on_item_id_artifact='".$artifact."' ";
01256   if ($notin)
01257     {
01258       $sql .= ' AND is_dependent_on_item_id NOT IN ('. join(',',$notin).')';
01259     }
01260   #  print $sql; #DBG
01261   return db_query($sql);
01262 }

trackers_data_get_description field,
by_field_id = false
 

Definition at line 706 of file data.php.

References $field.

00707 {
00708   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00709   if ($by_field_id)
00710     {
00711       $desc = $BF_USAGE_BY_ID[$field]['custom_description'];
00712       if (!isset($desc))
00713         { $desc = $BF_USAGE_BY_ID[$field]['description']; }
00714     }  else
00715       {
00716         $desc = $BF_USAGE_BY_NAME[$field]['custom_description'];
00717         if (!isset($desc))
00718           { $desc = $BF_USAGE_BY_NAME[$field]['description']; }
00719       }
00720   return($desc);
00721 }

trackers_data_get_display_size field,
by_field_id = false
 

Definition at line 789 of file data.php.

References $field.

00790 {
00791   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00792   if ($by_field_id)
00793     {
00794       $val = $BF_USAGE_BY_ID[$field]['custom_display_size'];
00795       if (!isset($val))
00796         { $val = $BF_USAGE_BY_ID[$field]['display_size']; }
00797     }  else
00798       {
00799         $val = $BF_USAGE_BY_NAME[$field]['custom_display_size'];
00800         if (!isset($val))
00801           { $val = $BF_USAGE_BY_NAME[$field]['display_size']; }
00802       }
00803   return(explode('/',$val));
00804 }

trackers_data_get_display_type field,
by_field_id = false
 

Definition at line 723 of file data.php.

References $field.

Referenced by trackers_data_is_date_field(), trackers_data_is_select_box(), trackers_data_is_text_area(), and trackers_data_is_text_field().

00724 {
00725   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00726   return($by_field_id ? $BF_USAGE_BY_ID[$field]['display_type'] : $BF_USAGE_BY_NAME[$field]['display_type']);
00727 }

trackers_data_get_display_type_in_clear field,
by_field_id = false
 

Definition at line 729 of file data.php.

References trackers_data_is_date_field(), trackers_data_is_select_box(), trackers_data_is_text_area(), and trackers_data_is_text_field().

00730 {
00731   if (trackers_data_is_select_box($field, $by_field_id))
00732     {
00733       return 'Select Box';
00734     }
00735   else if (trackers_data_is_text_field($field, $by_field_id))
00736     {
00737       return 'Text Field';
00738     }
00739   else if (trackers_data_is_text_area($field, $by_field_id))
00740     {
00741       return 'Text Area';
00742     }
00743   else if (trackers_data_is_date_field($field, $by_field_id))
00744     {
00745       return 'Date Field';
00746     }
00747   else
00748     {
00749       return '?';
00750     }
00751 }

trackers_data_get_field_id field_name  ) 
 

Definition at line 677 of file data.php.

Referenced by trackers_data_create_value(), trackers_data_get_all_report_fields(), trackers_data_get_field_predefined_values(), trackers_data_get_max_value_id(), trackers_data_handle_update(), trackers_data_reset_usage(), trackers_data_update_usage(), and trackers_data_use_field_predefined_values().

00678 {
00679   global $BF_USAGE_BY_NAME;
00680   return($BF_USAGE_BY_NAME[$field_name]['bug_field_id']);
00681 }

trackers_data_get_field_name field_id  ) 
 

Definition at line 671 of file data.php.

References $field_id.

Referenced by trackers_data_get_default_value(), trackers_data_get_field_predefined_values(), and trackers_data_is_username_field().

00672 {
00673   global $BF_USAGE_BY_ID;
00674   return($BF_USAGE_BY_ID[$field_id]['field_name']);
00675 }

trackers_data_get_field_predefined_values field,
group_id = false,
checked = false,
by_field_id = false,
active_only = true
 

Definition at line 421 of file data.php.

References $field, $field_id, $rows, $sql, db_numrows(), db_query(), group_id, trackers_data_get_field_id(), trackers_data_get_field_name(), trackers_data_get_submitters(), and trackers_data_get_technicians().

Referenced by trackers_data_get_cached_field_value().

00422 {
00423 
00424   /*
00425              Return all possible values for a select box field
00426              Rk: if the checked value is given then it means that we want this value
00427                   in the list in any case (even if it is hidden and active_only is requested)
00428   */
00429   $field_id = ($by_field_id ? $field : trackers_data_get_field_id($field));
00430   $field_name = ($by_field_id ? trackers_data_get_field_name($field) : $field);
00431 
00432   # The "Assigned_to" box requires some special processing
00433   # because possible values  are project members) and they are
00434   # not stored in the trackers_field_value table but in the user_group table
00435   if ($field_name == 'assigned_to')
00436     {
00437       $res_value = trackers_data_get_technicians($group_id);
00438     }
00439   else if ($field_name == 'submitted_by')
00440     {
00441       $res_value = trackers_data_get_submitters($group_id);
00442     }
00443   else
00444     {
00445 
00446       # If only active field
00447       if ($active_only)
00448         {
00449           if ($checked)
00450             {
00451               $status_cond = "AND  (status IN ('A','P') OR value_id='$checked') ";
00452             }
00453           else
00454             {
00455               $status_cond = "AND  status IN ('A','P') ";
00456             }
00457         }
00458 
00459       # CAUTION !! the fields value_id and value must be first in the
00460       # select statement because the output is used in the html_build_select_box
00461       # function
00462 
00463       # yeupou@gnu.org 2003-11-24
00464       # FIXME!!!!! WHAT IS THIS CRAP!
00465       # It _on purpose_ ignores the permanent values for the
00466       # system when a group have his own values.
00467       # And  when creating group specific values, it insert the permanent
00468       # system values in the group specific values.
00469       #
00470       # Can someone bring a reasonnable explanation for such a behavior?
00471       #   - permanent field must by nature be permanent, in any case!
00472       #   - database must never duplicates information without good reason
00473       #
00474       # When improving this code, please change that so it uses the permanent
00475       # values in any case, whatever the group specific values may be.
00476 
00477       # Look for project specific values first
00478       $sql="SELECT value_id,value,bug_fv_id,bug_field_id,group_id,description,order_id,status ".
00479          "FROM ".ARTIFACT."_field_value ".
00480          "WHERE group_id=$group_id AND bug_field_id=$field_id ".
00481          $status_cond." ORDER BY order_id,value ASC";
00482       $res_value = db_query($sql);
00483       $rows=db_numrows($res_value);
00484 
00485       # If no specific value for this group then look for default values
00486       if ($rows == 0)
00487         {
00488           $sql="SELECT value_id,value,bug_fv_id,bug_field_id,group_id,description,order_id,status ".
00489              "FROM ".ARTIFACT."_field_value ".
00490              "WHERE group_id=100 AND bug_field_id=$field_id ".
00491              $status_cond." ORDER BY order_id,value ASC";
00492           $res_value = db_query($sql);
00493           $rows=db_numrows($res_value);
00494         }
00495     }
00496 
00497   return($res_value);
00498 
00499 }

trackers_data_get_field_value item_fv_id  ) 
 

Definition at line 951 of file data.php.

References $res, $sql, and db_query().

00952 {
00953   /*
00954       Get all the columns associated to a given field value
00955   */
00956 
00957   $sql = "SELECT * FROM ".ARTIFACT."_field_value WHERE bug_fv_id='$item_fv_id'";
00958   $res = db_query($sql);
00959   return($res);
00960 }

trackers_data_get_followups item_id = false,
rorder = true
 

Definition at line 1273 of file data.php.

Referenced by format_item_changes(), and format_item_details().

01274 {
01275   if ($rorder == "true")
01276     { $rorder = "DESC"; }
01277   else
01278     { $rorder = "ASC"; }
01279 
01280   $sql="SELECT DISTINCT ".ARTIFACT."_history.bug_history_id,".ARTIFACT."_history.field_name,".ARTIFACT."_history.old_value,".ARTIFACT."_history.date,user.user_name,user.realname,".ARTIFACT."_field_value.value AS comment_type ".
01281      "FROM ".ARTIFACT."_history,".ARTIFACT."_field_value,".ARTIFACT."_field,".ARTIFACT.",user ".
01282      "WHERE ".ARTIFACT."_history.bug_id='$item_id' ".
01283      "AND ".ARTIFACT."_history.field_name = 'details' ".
01284      "AND ".ARTIFACT."_history.mod_by=user.user_id ".
01285      "AND ".ARTIFACT."_history.bug_id=".ARTIFACT.".bug_id ".
01286      "AND ".ARTIFACT."_history.type = ".ARTIFACT."_field_value.value_id ".
01287      "AND ".ARTIFACT."_field_value.bug_field_id = ".ARTIFACT."_field.bug_field_id ".
01288      "AND (".ARTIFACT."_field_value.group_id = ".ARTIFACT.".group_id OR ".ARTIFACT."_field_value.group_id = '100') ".
01289      "AND  ".ARTIFACT."_field.field_name = 'comment_type_id' ".
01290      "ORDER BY ".ARTIFACT."_history.date $rorder";
01291 
01292   return db_query($sql);
01293 }

trackers_data_get_group_id field,
by_field_id = false
 

Definition at line 683 of file data.php.

References $field, and group_id.

00684 {
00685   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00686   return($by_field_id ? $BF_USAGE_BY_ID[$field]['group_id'] : $BF_USAGE_BY_NAME[$field]['group_id']);
00687 }

trackers_data_get_history item_id = false  ) 
 

Definition at line 1303 of file data.php.

Referenced by show_item_history().

01304 {
01305   $sql="select ".ARTIFACT."_history.field_name,".ARTIFACT."_history.old_value,".ARTIFACT."_history.date,".ARTIFACT."_history.type,user.user_name,".ARTIFACT."_history.new_value ".
01306      "FROM ".ARTIFACT."_history,user ".
01307      "WHERE ".ARTIFACT."_history.mod_by=user.user_id ".
01308      "AND ".ARTIFACT."_history.field_name <> 'details' ".
01309      "AND bug_id='$item_id' ORDER BY ".ARTIFACT."_history.date DESC";
01310   return db_query($sql);
01311 }

trackers_data_get_item_group item_id  ) 
 

Definition at line 112 of file data.php.

References db_query(), db_result, and group_id.

00113 {
00114   return  db_result(
00115                     db_query("SELECT group_id FROM ".ARTIFACT." WHERE bug_id='$item_id'"),
00116                     0,
00117                     'group_id');
00118 }

trackers_data_get_item_notification_info item_id,
artifact,
updated
 

Definition at line 303 of file data.php.

References $result, $rows, $sql, db_numrows(), db_query(), and db_result.

Referenced by trackers_data_handle_update().

00304 {
00305   $emailad = "";
00306   $sendemail = 0;
00307   # Get group information bur new entity notification settings
00308   $sql="SELECT groups.$artifact"."_glnotif, groups.send_all_"."$artifact, groups.new_"."$artifact"."_address ".
00309      "FROM "."$artifact, groups ".
00310      "WHERE "."$artifact.bug_id='$item_id' ".
00311      "AND groups.group_id="."$artifact.group_id";
00312   $result=db_query($sql);
00313 
00314   $glnotif = db_result($result,0,$artifact."_glnotif");
00315   $glsendall = db_result($result,0,"send_all_".$artifact);
00316   $glnewad = db_result($result,0,"new_".$artifact."_address");
00317   if ($glnotif != 1) {   # if not 'global only'
00318     $cat_field_name = "category_id";
00319 
00320     $sql="SELECT "."$artifact"."_field_value.email_ad, "."$artifact"."_field_value.send_all_flag ".
00321        "FROM "."$artifact"."_field_value, "."$artifact"."_field, $artifact ".
00322        "WHERE "."$artifact.bug_id='$item_id' ".
00323        "AND "."$artifact"."_field.field_name='$cat_field_name' ".
00324        "AND "."$artifact"."_field_value.bug_field_id="."$artifact"."_field.bug_field_id ".
00325        "AND "."$artifact"."_field_value.group_id="."$artifact.group_id ".
00326        "AND "."$artifact"."_field_value.value_id="."$artifact.category_id";
00327 
00328     $result=db_query($sql);
00329     $rows=db_numrows($result);
00330     if ($rows > 0) {
00331       $sendallflag = db_result($result, 0, 'send_all_flag');
00332       if (($updated == 0) || (($updated == 1) && ($sendallflag == 1))) {
00333         $emailad .= db_result($result, 0, 'email_ad');
00334       }
00335     } else {
00336       # could be that administrator closes category notification and forgot
00337       # to define categories BUT in most cases it means the submitter selected
00338       # the 'NONE' category for this bug
00339       if (($updated == 0) || (($updated == 1) && ($glsendall == 1))) {
00340         $emailad .= $glnewad;
00341       }
00342     }
00343   }
00344   if ($glnotif > 0) {   # if not 'category only'
00345     if (($updated == 0) || (($updated == 1) && ($glsendall == 1))) {
00346       if ($emailad != "") {
00347         $emailad .= ',';
00348       }
00349       $emailad .= $glnewad;
00350     }
00351   }
00352   if (trim($emailad) != "") {
00353     $sendemail = 1;
00354   }
00355   #  print "EMAILAD=$emailad SENDEMAIL=$sendemail";
00356   return array($emailad, $sendemail);
00357 }

trackers_data_get_items group_id = false,
artifact
 

Definition at line 1237 of file data.php.

References $sql, and db_query().

01238 {
01239   /*
01240                 Get the items for this project
01241   */
01242   $sql="SELECT bug_id,summary ".
01243      "FROM ".$artifact." ".
01244      "WHERE group_id='".$group_id."'".
01245      " AND status_id <> '3' ".
01246      " ORDER BY bug_id DESC LIMIT 100";
01247   return db_query($sql);
01248 }

trackers_data_get_keep_history field,
by_field_id = false
 

Definition at line 754 of file data.php.

References $field.

00755 {
00756   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00757   if ($by_field_id)
00758     {
00759       $val = $BF_USAGE_BY_ID[$field]['custom_keep_history'];
00760       if (!isset($val))
00761         { $val = $BF_USAGE_BY_ID[$field]['keep_history']; }
00762     }  else
00763       {
00764         $val = $BF_USAGE_BY_NAME[$field]['custom_keep_history'];
00765         if (!isset($val))
00766           { $val = $BF_USAGE_BY_NAME[$field]['keep_history']; }
00767       }
00768   return($val);
00769 }

trackers_data_get_label field,
by_field_id = false
 

Definition at line 689 of file data.php.

References $field.

Referenced by format_item_changes(), show_item_history(), and trackers_transition_update_item().

00690 {
00691   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00692   if ($by_field_id)
00693     {
00694       $lbl = $BF_USAGE_BY_ID[$field]['custom_label'];
00695       if (!isset($lbl))
00696         { $lbl = $BF_USAGE_BY_ID[$field]['label']; }
00697     }  else
00698       {
00699         $lbl = $BF_USAGE_BY_NAME[$field]['custom_label'];
00700         if (!isset($lbl))
00701           { $lbl = $BF_USAGE_BY_NAME[$field]['label']; }
00702       }
00703   return($lbl);
00704 }

trackers_data_get_max_value_id field,
group_id,
by_field_id = false
 

Definition at line 823 of file data.php.

References $field_id, $res, $rows, $sql, db_numrows(), db_query(), db_result, and trackers_data_get_field_id().

Referenced by trackers_data_create_value().

00824 {
00825 
00826   /*
00827       Find the maximum value for the value_id of a field for a given group
00828       Return -1 if  no value exist yet
00829   */
00830 
00831   if (!$by_field_id)
00832     {
00833       $field_id = trackers_data_get_field_id($field);
00834     }
00835 
00836   $sql="SELECT max(value_id) as max FROM ".ARTIFACT."_field_value ".
00837      "WHERE bug_field_id='$field_id' AND group_id='$group_id' ";
00838   $res = db_query($sql);
00839   $rows = db_numrows($res);
00840 
00841   # If no max value found then it means it's the first value for this field
00842   # in this group. Return -1 in this case
00843   if ($rows == 0)
00844     {
00845       return(-1);
00846     }  else
00847       {
00848         return(db_result($res,0,'max'));
00849       }
00850 
00851 }
00852 
00853 function trackers_data_is_value_set_empty($field, $group_id, $by_field_id=false)
00854 {
00855 
00856   /*
00857       Return true if there is an existing set of values for given field for a
00858       given group and false if it is empty
00859   */
00860 
00861   if (!$by_field_id)
00862     {
00863       $field_id = trackers_data_get_field_id($field);
00864     }
00865   $sql="SELECT value_id FROM ".ARTIFACT."_field_value ".
00866      "WHERE bug_field_id='$field_id' AND group_id='$group_id' ";
00867   $res = db_query($sql);
00868   $rows=db_numrows($res);
00869 
00870   return (($rows<=0));
00871 }
00872 
00873 
00874 function trackers_data_copy_default_values($field, $group_id, $by_field_id=false)
00875 {
00876   /*
00877       Initialize the set of values for a given field for a given group by using
00878       the system default (default values belong to group_id 'None' =100)
00879   */
00880 
00881   if (!$by_field_id)
00882     {
00883       $field_id = trackers_data_get_field_id($field);
00884     }
00885 
00886   # if group_id=100 (None) it is a null operation
00887   # because default values belong to group_id 100 by definition
00888   if ($group_id != 100)
00889     {
00890 
00891       # First delete the exisiting value if any
00892       $sql="DELETE FROM ".ARTIFACT."_field_value ".
00893          "WHERE bug_field_id='$field_id' AND group_id='$group_id' ";
00894       $res = db_query($sql);
00895 
00896       # Second insert default values (if any) from group 'None'
00897       # Rk: The target table of the INSERT statement cannot appear in
00898       # the FROM clause of the SELECT part of the query because it's forbidden
00899       # in ANSI SQL to SELECT . So do it by hand !
00900       #
00901 
00902       $sql = "SELECT value_id,value,description,order_id,status ".
00903          "FROM ".ARTIFACT."_field_value ".
00904          "WHERE bug_field_id='$field_id' AND group_id='100'";
00905       $res = db_query($sql);
00906       $rows = db_numrows($res);
00907 
00908       for ($i=0; $i<$rows; $i++)
00909         {
00910 
00911           $value_id = addslashes(db_result($res,$i,'value_id'));
00912           $value = db_result($res,$i,'value');
00913           $description = addslashes(db_result($res,$i,'description'));
00914           $order_id = db_result($res,$i,'order_id');
00915           $status  = db_result($res,$i,'status');
00916 
00917 
00918           $sql="INSERT INTO ".ARTIFACT."_field_value ".
00919              "(bug_field_id,group_id,value_id,value,description,order_id,status) ".
00920              "VALUES ('$field_id','$group_id','$value_id','$value','$description','$order_id','$status')";
00921           #print "<BR>DBG - $sql";
00922           $res_insert = db_query($sql);
00923 
00924           if (db_affected_rows($res_insert) < 1)
00925             {
00926               fb(_("Insert of default value failed."), 0);
00927               db_error();
00928             }
00929         }
00930     }

& trackers_data_get_notification_settings group_id,
tracker_name
 

Definition at line 120 of file data.php.

References $i, $result, $sql, db_numrows(), db_query(), db_result, and exit_no_group().

Referenced by trackers_data_show_notification_settings().

00121 {
00122   $result = db_query("SELECT * FROM groups WHERE group_id=$group_id");
00123   if (db_numrows($result) < 1)
00124     {
00125       exit_no_group();
00126     }
00127 
00128   $settings = array();
00129 
00130   $settings['glnotif'] = db_result($result,0,$tracker_name."_glnotif");
00131   $settings['glsendall'] = db_result($result,0,"send_all_".$tracker_name);
00132   $settings['glnewad'] = db_result($result,0,"new_".$tracker_name."_address");
00133   $settings['private_exclude'] = db_result($result,0,$tracker_name."_private_exclude_address");
00134 
00135   $cat_field_name = "category_id";
00136   # Warning: The hardcoded fiels names: bug_fv_id and bug_field_id will need to be changed
00137   #          one day to generic names since they apply to bugs but also to suuports,tasks,
00138   #          and patch related tables. For now these fileds are called bug_xxx whatever
00139   #          the service related tables. Too much work to make all the changes in the code.
00140   $sql="SELECT ".$tracker_name."_field_value.bug_fv_id,".$tracker_name."_field_value.value,".$tracker_name."_field_value.email_ad,".$tracker_name."_field_value.send_all_flag ".
00141     "FROM ".$tracker_name."_field, ".$tracker_name."_field_value ".
00142     "WHERE ".$tracker_name."_field_value.group_id='$group_id' ".
00143     "AND ".$tracker_name."_field.field_name='$cat_field_name' ".
00144     "AND ".$tracker_name."_field_value.bug_field_id=".$tracker_name."_field.bug_field_id ".
00145     "AND ".$tracker_name."_field_value.status!='H'";
00146 
00147   $result=db_query($sql);
00148   $settings['nb_categories']=db_numrows($result);
00149   $settings['category'] = array();
00150   for ($i=0; $i < $settings['nb_categories'] ; $i++) {
00151 
00152     $settings['category'][$i] = array();
00153     $settings['category'][$i]['name'] = db_result($result, $i, 'value');
00154     $settings['category'][$i]['fv_id'] = db_result($result, $i, 'bug_fv_id');
00155     $email = db_result($result, $i, 'email_ad');
00156     if ($email == '100')
00157       { $email = ""; }
00158     $settings['category'][$i]['email'] = $email;
00159     $settings['category'][$i]['send_all_flag'] = db_result($result, $i, 'send_all_flag');
00160   }
00161   return $settings;
00162 }

trackers_data_get_place field,
by_field_id = false
 

Definition at line 771 of file data.php.

References $field.

00772 {
00773   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00774   return($by_field_id ? $BF_USAGE_BY_ID[$field]['place'] : $BF_USAGE_BY_NAME[$field]['place']);
00775 }

trackers_data_get_scope field,
by_field_id = false
 

Definition at line 777 of file data.php.

References $field.

00778 {
00779   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00780   return($by_field_id ? $BF_USAGE_BY_ID[$field]['scope'] : $BF_USAGE_BY_NAME[$field]['scope']);
00781 }

trackers_data_get_submitters group_id = false  ) 
 

Definition at line 1227 of file data.php.

References $sql, and db_query().

Referenced by trackers_data_get_field_predefined_values().

01228 {
01229   $sql="SELECT DISTINCT user.user_id,user.user_name ".
01230      "FROM user,".ARTIFACT." ".
01231      "WHERE user.user_id=".ARTIFACT.".submitted_by ".
01232      "AND ".ARTIFACT.".group_id='$group_id' ".
01233      "ORDER BY user.user_name";
01234   return db_query($sql);
01235 }

trackers_data_get_technicians group_id  ) 
 

Definition at line 1186 of file data.php.

References $sql, db_fetch_array(), db_query(), group_id, member_check(), and member_create_tracker_flag().

Referenced by trackers_data_get_field_predefined_values().

01187 {
01188   # FIXME: The cleanest thing would be to issue one SQL command.
01189   # But we have to handle the fact that "no setting" = get back
01190   # to the group, or even group type, setting.
01191 
01192   # In fact, this is terrible, we cannot return something else than
01193   # a mysql result if we do not want to rewrite 25 functions.
01194   # So we get the appropriate list of users... and finally issue a
01195   # mysql command only to be able to return a mysql result.
01196   # Please, propose something better at savannah-dev@gnu.org
01197 
01198 
01199   # Get list of members
01200   $members_sql =  "SELECT user.user_id AS user_id "
01201      . "FROM user,user_group "
01202      . "WHERE user.user_id=user_group.user_id AND user_group.group_id=$group_id ";
01203   $members_res = db_query($members_sql);
01204   # Build the sql command
01205   $sql = "SELECT user_id,user_name FROM user WHERE ";
01206   while ($member = db_fetch_array($members_res))
01207     {
01208       if (member_check($member['user_id'], $group_id, member_create_tracker_flag(ARTIFACT).'1'))
01209         {
01210           if ($notfirst)
01211             { $sql .= " OR "; }
01212           $sql .= " user_id='".$member['user_id']."'";
01213           $notfirst = 1;
01214         }
01215     }
01216   $sql .= " ORDER BY user_name";
01217   return db_query($sql);
01218 }

trackers_data_get_transition group_id  ) 
 

Definition at line 1222 of file data.php.

References group_id, and trackers_transition_get_update().

Referenced by trackers_data_handle_update().

01223 {
01224   return trackers_transition_get_update($group_id);
01225 }

trackers_data_get_valid_bugs group_id = false,
item_id = ''
 

Definition at line 1264 of file data.php.

01265 {
01266   $sql="SELECT bug_id,summary ".
01267      "FROM ".ARTIFACT." ".
01268      "WHERE group_id='$group_id' ".
01269      "AND bug_id <> '$item_id' AND ".ARTIFACT.".resolution_id <> '2' ORDER BY bug_id DESC LIMIT 200";
01270   return db_query($sql);
01271 }

trackers_data_handle_update group_id,
item_id,
dependent_on_task,
dependent_on_bugs,
dependent_on_support,
dependent_on_patch,
canned_response,
vfl,
&$  changes,
&$  extra_addresses
 

Definition at line 1385 of file data.php.

References $address, $changes, $field, $field_id, $now, $result, $sql, $upd_list, $value, $vfl, cookbook_handle_update(), db_affected_rows(), db_numrows(), db_query(), db_result, exit_error(), exit_missing_param(), exit_permission_denied(), group_id, member_check(), member_create_tracker_flag(), summary, trackers_data_add_history(), trackers_data_get_field_id(), trackers_data_get_item_notification_info(), trackers_data_get_transition(), trackers_data_is_date_field(), trackers_data_is_special(), trackers_data_is_status_closed(), trackers_data_is_text_area(), trackers_data_is_text_field(), trackers_transition_update_item(), utils_cutstring(), utils_date_to_unixtime(), and utils_unconvert_htmlspecialchars().

trackers_data_is_custom field,
by_field_id = false
 

Definition at line 515 of file data.php.

References $field.

00516 {
00517   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00518   return($by_field_id ? $BF_USAGE_BY_ID[$field]['custom']: $BF_USAGE_BY_NAME[$field]['custom']);
00519 }

trackers_data_is_date_field field,
by_field_id = false
 

Definition at line 621 of file data.php.

References trackers_data_get_display_type().

Referenced by show_item_history(), show_item_list(), show_item_list_sober(), trackers_data_get_display_type_in_clear(), and trackers_data_handle_update().

00622 {
00623   return(trackers_data_get_display_type($field, $by_field_id) == 'DF');
00624 }

trackers_data_is_default_value item_fv_id  ) 
 

Definition at line 962 of file data.php.

References $res, $sql, db_numrows(), and db_query().

Referenced by trackers_data_update_value().

00963 {
00964   /*
00965       See if this field value belongs to group None (100). In this case
00966       it is a so called default value.
00967   */
00968 
00969   $sql = "SELECT bug_field_id,value_id FROM ".ARTIFACT."_field_value WHERE bug_fv_id='$item_fv_id' AND group_id='100'";
00970   $res = db_query($sql);
00971 
00972   return ( (db_numrows($res) >= 1) ? $res : false);
00973 }

trackers_data_is_empty_ok field,
by_field_id = false
 

Definition at line 528 of file data.php.

References trackers_data_mandatory_flag().

00529 {
00530   return trackers_data_mandatory_flag($field, $by_field_id);
00531 }

trackers_data_is_project_scope field,
by_field_id = false
 

Definition at line 651 of file data.php.

References $field.

00652 {
00653   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00654   if ($by_field_id)
00655     {
00656       return($BF_USAGE_BY_ID[$field]['scope'] == 'P');
00657     }
00658   else
00659     {
00660       return($BF_USAGE_BY_NAME[$field]['scope'] == 'P');
00661     }
00662 }

trackers_data_is_required field,
by_field_id = false
 

Definition at line 571 of file data.php.

References $field.

Referenced by trackers_data_update_usage().

00572 {
00573   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00574   return($by_field_id ? $BF_USAGE_BY_ID[$field]['required']: $BF_USAGE_BY_NAME[$field]['required']);
00575 }

trackers_data_is_select_box field,
by_field_id = false
 

Definition at line 636 of file data.php.

References trackers_data_get_display_type().

Referenced by show_item_history(), show_item_list(), show_item_list_sober(), and trackers_data_get_display_type_in_clear().

00637 {
00638   return(trackers_data_get_display_type($field, $by_field_id) == 'SB');
00639 }

trackers_data_is_showed_on_add field,
by_field_id = false
 

Definition at line 599 of file data.php.

References $field.

00600 {
00601   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00602   return($by_field_id ? $BF_USAGE_BY_ID[$field]['show_on_add'] & 1: $BF_USAGE_BY_NAME[$field]['show_on_add'] & 1);
00603 }

trackers_data_is_showed_on_add_members field,
by_field_id = false
 

Definition at line 615 of file data.php.

References $field.

00616 {
00617   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00618   return($by_field_id ? $BF_USAGE_BY_ID[$field]['show_on_add_members']: $BF_USAGE_BY_NAME[$field]['show_on_add_members']);
00619 }

trackers_data_is_showed_on_add_nologin field,
by_field_id = false
 

Definition at line 607 of file data.php.

References $field.

00608 {
00609   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00610   return($by_field_id ? $BF_USAGE_BY_ID[$field]['show_on_add'] & 2: $BF_USAGE_BY_NAME[$field]['show_on_add'] & 2);
00611 }

trackers_data_is_showed_on_query field  ) 
 

Definition at line 583 of file data.php.

References $field.

00584 {
00585   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00586   return($by_field_id ? $BF_USAGE_BY_ID[$field]['show_on_query']: $BF_USAGE_BY_NAME[$field]['show_on_query']);
00587 
00588 }

trackers_data_is_showed_on_result field  ) 
 

Definition at line 590 of file data.php.

References $field.

00591 {
00592   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00593   return($by_field_id ? $BF_USAGE_BY_ID[$field]['show_on_result']: $BF_USAGE_BY_NAME[$field]['show_on_result']);
00594 }

trackers_data_is_special field,
by_field_id = false
 

Definition at line 521 of file data.php.

References $field.

Referenced by trackers_data_handle_update().

00522 {
00523   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00524   return($by_field_id ? $BF_USAGE_BY_ID[$field]['special']: $BF_USAGE_BY_NAME[$field]['special']);
00525 }

trackers_data_is_status_closed status  ) 
 

Definition at line 664 of file data.php.

Referenced by trackers_data_handle_update().

00665 {
00666   if ($status == '3')
00667     { return 1; }
00668   return 0;
00669 }

trackers_data_is_text_area field,
by_field_id = false
 

Definition at line 631 of file data.php.

References trackers_data_get_display_type().

Referenced by trackers_data_get_display_type_in_clear(), and trackers_data_handle_update().

00632 {
00633   return(trackers_data_get_display_type($field, $by_field_id) == 'TA');
00634 }

trackers_data_is_text_field field,
by_field_id = false
 

Definition at line 626 of file data.php.

References trackers_data_get_display_type().

Referenced by trackers_data_get_display_type_in_clear(), and trackers_data_handle_update().

00627 {
00628   return(trackers_data_get_display_type($field, $by_field_id) == 'TF');
00629 }

trackers_data_is_used field,
by_field_id = false
 

Definition at line 577 of file data.php.

References $field.

00578 {
00579   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00580   return($by_field_id ? $BF_USAGE_BY_ID[$field]['use_it']: $BF_USAGE_BY_NAME[$field]['use_it']);
00581 }

trackers_data_is_username_field field,
by_field_id = false
 

Definition at line 641 of file data.php.

References $field, and trackers_data_get_field_name().

Referenced by show_item_list(), and show_item_list_sober().

00642 {
00643   global $BF_USAGE_BY_ID;
00644   if ($by_field_id)
00645     {
00646       $field = trackers_data_get_field_name($field);
00647     }
00648   return(($field == 'assigned_to') || ($field == 'submitted_by'));
00649 }

trackers_data_mandatory_flag field,
by_field_id = false
 

Definition at line 533 of file data.php.

References $field.

Referenced by trackers_data_is_empty_ok().

00534 {
00535   # 1 = not mandatory
00536   # 0 = relaxed mandatory (mandatory if it was to the submitter)
00537   # 3 = mandatory whenever possible
00538   global $BF_USAGE_BY_ID,$BF_USAGE_BY_NAME;
00539   if ($by_field_id)
00540     {
00541       $val = $BF_USAGE_BY_ID[$field]['custom_empty_ok'];
00542       if (!isset($val))
00543         { $val = $BF_USAGE_BY_ID[$field]['empty_ok']; }
00544     }  else
00545       {
00546         $val = $BF_USAGE_BY_NAME[$field]['custom_empty_ok'];
00547         if (!isset($val))
00548           { $val = $BF_USAGE_BY_NAME[$field]['empty_ok']; }
00549       }
00550   return($val);
00551 }

trackers_data_post_notification_settings group_id,
tracker_name
 

Definition at line 228 of file data.php.

References $feedback, $GLOBALS, $i, $res_cat, db_error(), and db_query().

00229 {
00230 
00231   global $feedback;
00232 
00233   $local_feedback = "";
00234   # build the variable names related to elements always present in the form
00235   # and get their values
00236 
00237   $notif_scope_name = $tracker_name."_notif_scope";
00238   $notif_scope = $GLOBALS[$notif_scope_name];
00239   $new_item_address_name = $tracker_name."_new_item_address";
00240   $new_item_address = $GLOBALS[$new_item_address_name];
00241   $send_all_changes_name = $tracker_name."_send_all_changes";
00242   $send_all_changes = $GLOBALS[$send_all_changes_name];
00243   $nb_categories_name = $tracker_name."_nb_categories";
00244   $nb_categories = $GLOBALS[$nb_categories_name];
00245   $private_exclude_address_name = $tracker_name."_private_exclude_address";
00246   $private_exclude_address = $GLOBALS[$private_exclude_address_name];
00247 
00248   if ($notif_scope != "global") {
00249     if ($notif_scope == "category") {
00250       $notif_value = 0;
00251     }
00252     if ($notif_scope == "both") {
00253       $notif_value = 2;
00254     }
00255   } else {
00256     $notif_value = 1;
00257   }
00258 
00259   # set global notification info for this group
00260   $res_gl=db_query("UPDATE groups SET "
00261         .$tracker_name."_glnotif='$notif_value', "
00262         ."send_all_".$tracker_name."='$send_all_changes', "
00263         ."new_".$tracker_name."_address=".($new_item_address? "'$new_item_address' " : "''").", "
00264         .$private_exclude_address_name.'='.($private_exclude_address? "'$private_exclude_address' " : "''")
00265         . " WHERE group_id=$group_id");
00266   if (!$res_gl)
00267     { $local_feedback .= _("groups table Update failed.").' '.db_error(); }
00268 
00269   $ok = 0;
00270   if ($nb_categories > 0) {
00271     for ($i=0; $i<$nb_categories; $i++) {
00272       $current_fv_name = $tracker_name."_cat_".$i."_bug_fv_id";
00273       $current_fv_id = $GLOBALS[$current_fv_name];
00274       $current_email_name = $tracker_name."_cat_".$i."_email";
00275       $current_email = $GLOBALS[$current_email_name];
00276 #      if ($current_email && !validate_email($current_email))
00277 #        {
00278 #          $local_feedback .= _("[".$tracker_name."]  notification address: ".$current_email." appeared Invalid");
00279 #          $current_email='';
00280 #        }
00281       $current_send_all_name = $tracker_name."_cat_".$i."_send_all_flag";
00282       $current_send_all_flag = $GLOBALS[$current_send_all_name];
00283 
00284       $res_cat=db_query("UPDATE ".$tracker_name."_field_value SET "
00285              ."email_ad='$current_email', "
00286              ."send_all_flag='$current_send_all_flag' "
00287              ." WHERE bug_fv_id=$current_fv_id");
00288       if ($res_cat) {
00289         $ok++;
00290       } else {
00291         $local_feedback .= _($tracker_name."_field_value table Update failed.").' '.db_error();
00292       }
00293     }
00294   }
00295   if (($res_gl) && ($ok == $nb_categories) && ($local_feedback == ""))  {
00296     return 1;
00297   } else {
00298     if ($local_feedback != "") { fb($local_feedback); }
00299     return 0;
00300   }
00301 }

trackers_data_reset_usage field_name,
group_id
 

Definition at line 1091 of file data.php.

References $feedback, $field_id, $sql, db_query(), group_id, and trackers_data_get_field_id().

01092 {
01093   global $feedback;
01094   /*
01095       Reset a field settings to its defaults usage (values are untouched). The defaults
01096       always belong to group_id 100 (None) so make sure we don;t delete entries for
01097       group 100
01098   */
01099   $field_id = trackers_data_get_field_id($field_name);
01100   if ($group_id != 100)
01101     {
01102       $sql = "DELETE FROM ".ARTIFACT."_field_usage ".
01103          "WHERE group_id='$group_id' AND bug_field_id='$field_id'";
01104       db_query($sql);
01105       fb(_("Field value successfully reset to defaults."));
01106 
01107     }
01108 }

trackers_data_show_notification_settings group_id,
tracker_name,
show_intro_msg
 

Definition at line 164 of file data.php.

References $i, group_id, nbsp, print, and trackers_data_get_notification_settings().

00165 {
00166   $grtrsettings = &trackers_data_get_notification_settings($group_id, $tracker_name);
00167 
00168   if (user_ismember($group_id,'A'))
00169     {
00170       if ($grtrsettings['glnotif'] == 0) {
00171         $categoryradio = "CHECKED";
00172         $globalradio = "";
00173         $bothradio = "";
00174       }
00175       if ($grtrsettings['glnotif'] == 1) {
00176         $categoryradio = "";
00177         $globalradio = "CHECKED";
00178         $bothradio = "";
00179       }
00180       if ($grtrsettings['glnotif'] == 2) {
00181         $categoryradio = "";
00182         $globalradio = "";
00183         $bothradio = "CHECKED";
00184       }
00185       if ($grtrsettings['nb_categories'] > 0) {
00186         if ($show_intro_msg != 0) {
00187           print '<p>'.sprintf(_("As a project administrator you must decide if the list of persons to be systematically notified on new %s submissions (and possibly updates) depend on the categories or not and you must provide the corresponding email addresses (comma separated list)."), $tracker_name).'</p>';
00188 
00189         }
00190         print '
00191            <INPUT TYPE="RADIO" NAME="'.$tracker_name.'_notif_scope" VALUE="global" '.$globalradio.' />&nbsp;&nbsp;<span class="preinput">'._("Notify persons in the global list only").'</span><br />
00192           <INPUT TYPE="RADIO" NAME="'.$tracker_name.'_notif_scope" VALUE="category" '.$categoryradio.' />&nbsp;&nbsp;<span class="preinput">'._("Notify persons in the category related list instead of the global list").'</span><br />
00193           <INPUT TYPE="RADIO" NAME="'.$tracker_name.'_notif_scope" VALUE="both" '.$bothradio.' />&nbsp;&nbsp;<span class="preinput">'._("Notify persons in the category related list in addition to the global list").'</span><br />
00194 
00195 
00196           <h4>'._("Category related lists").'</h4>';
00197         print '<INPUT TYPE="HIDDEN" NAME="'.$tracker_name.'_nb_categories" VALUE="'.$grtrsettings['nb_categories'].'" />';
00198 
00199         for ($i=0; $i < $grtrsettings['nb_categories'] ; $i++)
00200           {
00201             print '<INPUT TYPE="HIDDEN" NAME="'.$tracker_name.'_cat_'.$i.'_bug_fv_id" VALUE="'.$grtrsettings['category'][$i]['fv_id'].'" />';
00202             print '<span class="preinput">'.$grtrsettings['category'][$i]['name'].'</span><br />&nbsp;&nbsp;<INPUT TYPE="TEXT" NAME="'.$tracker_name.'_cat_'.$i.'_email" VALUE="'.$grtrsettings['category'][$i]['email'].'" SIZE="50" MAXLENGTH="255" />
00203           &nbsp;&nbsp;<span class="preinput">(
00204           <INPUT TYPE="CHECKBOX" NAME="'.$tracker_name.'_cat_'.$i.'_send_all_flag" VALUE="1" '. (($grtrsettings['category'][$i]['send_all_flag'])?'checked="checked"':'') .' />'._("Send on all updates").')</span><br />
00205 ';
00206           }
00207 
00208         print '<h4>'._("Global list").'</h4>';
00209 
00210       } else {
00211         if ($show_intro_msg != 0) {
00212           print '<p>'.sprintf(_("As a project administrator you must decide if the list of persons to be systematically notified on new %s submissions (and possibly updates) depend on the categories or not and you must provide the corresponding email addresses (comma separated list)."), $tracker_name).'</p>';
00213         }
00214       }
00215       print '<span class="preinput">'._("Global List:").'</span><br />&nbsp;&nbsp;<INPUT TYPE="TEXT" NAME="'.$tracker_name.'_new_item_address" VALUE="'.$grtrsettings['glnewad'].'" SIZE="50" MAXLENGTH="255" />
00216       &nbsp;&nbsp;<span class="preinput">(<INPUT TYPE="CHECKBOX" NAME="'.$tracker_name.'_send_all_changes" VALUE="1" '. (($grtrsettings['glsendall'])?'CHECKED':'') .'>'._("Send on all updates").')</span>';
00217 
00218         print '<h4>'._("Private items exclude list").'</h4>';
00219         if ($show_intro_msg != 0) {
00220           print '<p>'._("Addresses registered in this list will be excluded from default mail notification for private items.").'</p>';
00221         }
00222 
00223         print '<span class="preinput">'._("Exclude List:").'</span><br />&nbsp;&nbsp;<INPUT TYPE="TEXT" NAME="'.$tracker_name.'_private_exclude_address" VALUE="'.$grtrsettings['private_exclude'].'" SIZE="50" MAXLENGTH="255" /><br />';
00224 
00225     }
00226 }

trackers_data_update_usage field_name,
group_id,
label,
description,
use_it,
rank,
display_size,
empty_ok,
keep_history,
show_on_add_members = 0,
show_on_add = 0,
transition_default_auth = 'A'
 

Definition at line 1110 of file data.php.

References $field_id, $result, $rows, $sql, db_affected_rows(), db_numrows(), db_query(), trackers_data_get_field_id(), and trackers_data_is_required().

01123 {
01124 
01125   /*
01126       Update a field settings in the trackers_usage_table
01127       Rk: All the show_on_xxx boolean parameters are set to 0 by default because their
01128            values come from checkboxes and if not checked the form variable
01129            is not set at all. It must be 0 to be ok with the SQL statement
01130   */
01131 
01132   # if it's a required field then make sure the use_it flag is true
01133   if (trackers_data_is_required($field_name))
01134     {
01135       $use_it = 1;
01136     }
01137 
01138   $field_id = trackers_data_get_field_id($field_name);
01139 
01140   # if it's a custom field then take label into account else store NULL
01141   #    if (trackers_data_is_custom($field_name))  {
01142   $lbl = isset($label) ? "'$label'" : 'NULL';
01143   $desc = isset($description) ? "'$description'" : 'NULL';
01144   $disp_size = isset($display_size) ? "'$display_size'" : 'NULL';
01145   $empty = isset($empty_ok) ? "'$empty_ok'" : 'NULL';
01146   $keep_hist = isset($keep_history) ? "'$keep_history'" : 'NULL';
01147   #    }  else    {
01148   #     $lbl = $desc = $disp_size = $empty = $keep_hist = "NULL";
01149   #    }
01150 
01151   # See if this field usage exists in the table for this project
01152   $sql = 'SELECT bug_field_id FROM '.ARTIFACT.'_field_usage '.
01153      "WHERE bug_field_id='$field_id' AND group_id='$group_id'";
01154   $result = db_query($sql);
01155   $rows = db_numrows($result);
01156 
01157   # if it does exist then update it else insert a new usage entry for this field.
01158   if ($rows)
01159     {
01160       $sql = 'UPDATE '.ARTIFACT.'_field_usage '.
01161          "SET use_it='$use_it',show_on_add='$show_on_add',".
01162          "show_on_add_members='$show_on_add_members',place='$rank', ".
01163          "custom_label=$lbl,  custom_description=$desc,".
01164          "custom_display_size=$disp_size,  custom_empty_ok=$empty,".
01165          "custom_keep_history=$keep_hist, ".
01166          "transition_default_auth='$transition_default_auth' ".
01167          "WHERE bug_field_id='$field_id' AND group_id='$group_id'";
01168       $result = db_query($sql);
01169     }
01170   else
01171     {
01172       $sql = 'INSERT INTO '.ARTIFACT.'_field_usage '.
01173          "VALUES ('$field_id','$group_id','$use_it','$show_on_add',".
01174          "'$show_on_add_members','$rank',$lbl,$desc,$disp_size,$empty,$keep_hist,'$transition_default_auth')";
01175       $result = db_query($sql);
01176     }
01177 
01178   if (db_affected_rows($result) < 1)
01179     { fb(_("Update of field usage failed."), 1); }
01180   else
01181     { fb(_("Field usage updated.")); }
01182 
01183 }

trackers_data_update_value item_fv_id,
field,
group_id,
value,
description,
order_id,
status = 'A'
 

Definition at line 1041 of file data.php.

References $feedback, $result, $sql, db_affected_rows(), db_fetch_array(), db_query(), group_id, and trackers_data_is_default_value().

01042 {
01043 
01044   global $feedback,$ffeedback;
01045   /*
01046       Insert a new value for a given field for a given group
01047   */
01048 
01049   # An empty field value is not allowed
01050   if (preg_match ("/^\s*$/", $value))
01051     {
01052       fb(_("Empty field value not allowed"), 0);
01053       return;
01054     }
01055 
01056   # Updating a bug field value that belong to group 100 (None) is
01057   # forbidden. These are default values that cannot be changed so
01058   # make sure to copy the default values first in the project context first
01059 
01060   if ($res = trackers_data_is_default_value($item_fv_id))
01061     {
01062       trackers_data_copy_default_values($field,$group_id);
01063 
01064       $arr = db_fetch_array($res);
01065       $where_cond = 'bug_field_id='.$arr['bug_field_id'].
01066          ' AND value_id='.$arr['value_id']." AND group_id='$group_id' ";
01067     }
01068   else
01069     {
01070       $where_cond = "bug_fv_id='$item_fv_id' AND group_id<>'100'";
01071     }
01072 
01073   # Now perform the value update
01074   $sql = "UPDATE ".ARTIFACT."_field_value ".
01075      "SET value='$value',description='$description',order_id='$order_id',status='$status' ".
01076      "WHERE $where_cond";
01077   $result = db_query($sql);
01078 
01079   #print "<BR>DBG - $sql";
01080 
01081   if (db_affected_rows($result) < 1)
01082     {
01083       fb(_("Update of field value failed."));
01084     }
01085   else
01086     {
01087       fb(_("New field value updated."));
01088     }
01089 }

trackers_data_use_field_predefined_values field,
group_id
 

Definition at line 501 of file data.php.

References $field_id, $result, $sql, db_numrows(), db_query(), and trackers_data_get_field_id().

00502 {
00503   # Check whether a group field values are the default one or not.
00504   # If no entry in the database for the relevant field value belong to the
00505   # group, then it uses default values (fallback)
00506   $field_id = trackers_data_get_field_id($field);
00507   $sql="SELECT bug_fv_id FROM ".ARTIFACT."_field_value ".
00508              "WHERE group_id=".$group_id." AND bug_field_id=$field_id";
00509 
00510   $result = db_query($sql);
00511   return db_numrows($result);
00512 }


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