Skip to content

Commit

Permalink
add an ALL_PROJECTS constant and use it instead of 0 every time that'…
Browse files Browse the repository at this point in the history
…s what we actually mean

this should help with code readability and make it easier if we ever have to change the value for some reason


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2076 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Julian Fitzell committed Mar 9, 2003
1 parent 75a5971 commit 7a2dca4
Show file tree
Hide file tree
Showing 31 changed files with 100 additions and 99 deletions.
4 changes: 2 additions & 2 deletions bug_report.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_report.php,v 1.22 2003-03-05 11:51:14 vboctor Exp $
# $Id: bug_report.php,v 1.23 2003-03-09 03:08:57 jfitzell Exp $
# --------------------------------------------------------
?>
<?php
Expand All @@ -24,7 +24,7 @@
?>
<?php
# this page is invalid for the 'All Project' selection
if ( 0 == helper_get_current_project() ) {
if ( ALL_PROJECTS == helper_get_current_project() ) {
print_header_redirect( 'login_select_proj_page.php?ref=' . string_get_bug_report_url() );
}

Expand Down
4 changes: 2 additions & 2 deletions bug_report_advanced_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_report_advanced_page.php,v 1.27 2003-03-03 23:29:28 int2str Exp $
# $Id: bug_report_advanced_page.php,v 1.28 2003-03-09 03:08:57 jfitzell Exp $
# --------------------------------------------------------
?>
<?php
Expand All @@ -22,7 +22,7 @@
?>
<?php
# this page is invalid for the 'All Project' selection
if ( 0 == helper_get_current_project() ) {
if ( ALL_PROJECTS == helper_get_current_project() ) {
print_header_redirect( 'login_select_proj_page.php?ref=bug_report_advanced_page.php' );
}

Expand Down
4 changes: 2 additions & 2 deletions bug_report_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_report_page.php,v 1.25 2003-03-03 23:29:28 int2str Exp $
# $Id: bug_report_page.php,v 1.26 2003-03-09 03:08:57 jfitzell Exp $
# --------------------------------------------------------
?>
<?php
Expand All @@ -22,7 +22,7 @@
?>
<?php
# this page is invalid for the 'All Project' selection
if ( 0 == helper_get_current_project() ) {
if ( ALL_PROJECTS == helper_get_current_project() ) {
print_header_redirect( 'login_select_proj_page.php?ref=bug_report_page.php' );
}

Expand Down
6 changes: 3 additions & 3 deletions core/access_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: access_api.php,v 1.20 2003-03-03 23:29:29 int2str Exp $
# $Id: access_api.php,v 1.21 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -60,7 +60,7 @@ function access_cache_matrix_project( $p_project_id ) {

$c_project_id = db_prepare_int( $p_project_id );

if ( 0 == $c_project_id ) {
if ( ALL_PROJECTS == $c_project_id ) {
return array();
}

Expand Down Expand Up @@ -193,7 +193,7 @@ function access_has_project_level( $p_access_level, $p_project_id=null ) {
$p_project_id = helper_get_current_project();
}

if ( 0 == $p_project_id ) {
if ( ALL_PROJECTS == $p_project_id ) {
return access_has_global_level( $p_access_level );
}

Expand Down
4 changes: 2 additions & 2 deletions core/bug_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_api.php,v 1.39 2003-03-03 23:29:29 int2str Exp $
# $Id: bug_api.php,v 1.40 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand All @@ -25,7 +25,7 @@
# Bug Data Structure Definition
#===================================
class BugData {
var $project_id = 0;
var $project_id = null;
var $reporter_id = 0;
var $handler_id = 0;
var $duplicate_id = 0;
Expand Down
5 changes: 4 additions & 1 deletion core/constant_inc.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: constant_inc.php,v 1.4 2003-03-03 23:29:30 int2str Exp $
# $Id: constant_inc.php,v 1.5 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -111,6 +111,9 @@
define( 'BY_LIMIT', 0 );
define( 'BY_DATE', 1 );

# all projects
define( 'ALL_PROJECTS', 0 );

# history constants
define( 'NORMAL_TYPE', 0 );
define( 'NEW_BUG', 1 );
Expand Down
6 changes: 3 additions & 3 deletions core/custom_field_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: custom_field_api.php,v 1.19 2003-02-23 14:18:00 vboctor Exp $
# $Id: custom_field_api.php,v 1.20 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -757,10 +757,10 @@ function custom_field_set_sequence( $p_field_id, $p_project_id, $p_sequence ) {
# away, it'll default to 0 and thus belongs to a new (i.e.
# non-existant) bug
# NOTE: This probably belongs in the print_api.php
function print_custom_field_input( $p_field_def, $p_bug_id = 0) {
function print_custom_field_input( $p_field_def, $p_bug_id = null ) {
$t_id = $p_field_def['id'];

if( 0 == $p_bug_id ) {
if( null == $p_bug_id ) {
$t_custom_field_value = $p_field_def['default_value'];
} else {
$t_custom_field_value = custom_field_get_value( $t_id, $p_bug_id );
Expand Down
4 changes: 2 additions & 2 deletions core/filter_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: filter_api.php,v 1.11 2003-03-03 23:29:30 int2str Exp $
# $Id: filter_api.php,v 1.12 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -57,7 +57,7 @@ function filter_get_bug_rows( &$p_page_number, &$p_per_page, &$p_page_count, &$p
$t_from_clauses = array( $t_bug_table, $t_project_table );
$t_join_clauses = array();

if ( 0 == $t_project_id ) { # all projects
if ( ALL_PROJECTS == $t_project_id ) {
if ( ! current_user_is_administrator() ) {
$t_projects = current_user_get_accessible_projects();

Expand Down
20 changes: 10 additions & 10 deletions core/graph_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: graph_api.php,v 1.9 2003-02-24 10:32:31 jfitzell Exp $
# $Id: graph_api.php,v 1.10 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

if ( ON == config_get( 'use_jpgraph' ) ) {
Expand Down Expand Up @@ -40,7 +40,7 @@ function enum_bug_group( $p_enum_string, $p_enum ) {
$t_s = explode( ':', $t_arr[$i] );
$enum_name[] = get_enum_to_string( $p_enum_string, $t_s[0] );

if ($t_project_id==0) $specific_where = '';
if ($t_project_id==ALL_PROJECTS) $specific_where = '';
else $specific_where = " AND project_id='$t_project_id'";

# Calculates the number of bugs with $p_enum and puts the results in a table
Expand Down Expand Up @@ -148,7 +148,7 @@ function enum_bug_group_pct( $p_enum_string, $p_enum ) {
$t_res_val = RESOLVED;
$t_clo_val = CLOSED;

if ($t_project_id==0) $specific_where = '';
if ($t_project_id==ALL_PROJECTS) $specific_where = '';
else $specific_where = " AND project_id='$t_project_id'";

$query = "SELECT COUNT(*)
Expand Down Expand Up @@ -258,7 +258,7 @@ function create_bug_enum_summary_pct( $p_enum_string, $p_enum ) {

$t_project_id = helper_get_current_project();

if ($t_project_id==0) $specific_where = '1=1';
if ($t_project_id==ALL_PROJECTS) $specific_where = '1=1';
else $specific_where = " project_id='$t_project_id'";

$query = "SELECT COUNT(*)
Expand Down Expand Up @@ -322,7 +322,7 @@ function create_category_summary_pct() {

$t_project_id = helper_get_current_project();

if ($t_project_id==0) $specific_where = '1=1';
if ( ALL_PROJECTS == $t_project_id ) $specific_where = '1=1';
else $specific_where = " project_id='$t_project_id'";

$query = "SELECT COUNT(*)
Expand Down Expand Up @@ -397,7 +397,7 @@ function create_bug_enum_summary( $p_enum_string, $p_enum ) {
$c_s[0] = addslashes($t_s[0]);
$enum_name[] = get_enum_to_string( $p_enum_string, $t_s[0] );

if ($t_project_id==0) $specific_where = '';
if ($t_project_id==ALL_PROJECTS) $specific_where = '';
else $specific_where = " AND project_id='$t_project_id'";

$query = "SELECT COUNT(*)
Expand Down Expand Up @@ -452,7 +452,7 @@ function create_developer_summary() {
$row = db_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, 'v' );

if ($t_project_id==0) $specific_where = '';
if ($t_project_id==ALL_PROJECTS) $specific_where = '';
else $specific_where = " AND project_id='$t_project_id'";
$query = "SELECT COUNT(*)
FROM $g_mantis_bug_table
Expand Down Expand Up @@ -541,7 +541,7 @@ function create_reporter_summary() {
$row = db_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, 'v' );

if ($t_project_id==0) $specific_where = '';
if ($t_project_id==ALL_PROJECTS) $specific_where = '';
else $specific_where = " AND project_id='$t_project_id'";
$query = "SELECT COUNT(*)
FROM $g_mantis_bug_table
Expand Down Expand Up @@ -586,7 +586,7 @@ function create_category_summary() {

$t_project_id = helper_get_current_project();

if ($t_project_id==0) $specific_where = ' 1=1 ';
if ($t_project_id==ALL_PROJECTS) $specific_where = ' 1=1 ';
else $specific_where = " project_id='$t_project_id'";
$query = "SELECT DISTINCT category
FROM $g_mantis_project_category_table
Expand Down Expand Up @@ -657,7 +657,7 @@ function create_cumulative_bydate(){

$t_project_id = helper_get_current_project();

if ($t_project_id==0) $specific_where = ' 1=1 ';
if ($t_project_id==ALL_PROJECTS) $specific_where = ' 1=1 ';
else $specific_where = " project_id='$t_project_id' ";

### Get all the submitted dates
Expand Down
4 changes: 2 additions & 2 deletions core/helper_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: helper_api.php,v 1.40 2003-02-20 16:48:23 jlatour Exp $
# $Id: helper_api.php,v 1.41 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -153,7 +153,7 @@ function helper_get_current_project() {
if ( ! project_exists( $t_project_id ) ||
0 == project_get_field( $t_project_id, 'enabled' ) ||
! access_has_project_level( VIEWER, $t_project_id ) ) {
$t_project_id = 0;
$t_project_id = ALL_PROJECTS;
}

return (int)$t_project_id;
Expand Down
6 changes: 3 additions & 3 deletions core/html_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: html_api.php,v 1.66 2003-03-05 21:37:30 jfitzell Exp $
# $Id: html_api.php,v 1.67 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -371,7 +371,7 @@ function print_menu() {
}
if ( access_has_project_level( MANAGER ) ) {
# Admin can edit news for All Projects (site-wide)
if ( ( 0 != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) {
if ( ( ALL_PROJECTS != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) {
echo '<a href="news_menu_page.php">' . lang_get( 'edit_news_link' ) . '</a> | ';
} else {
echo '<a href="login_select_proj_page.php">' . lang_get( 'edit_news_link' ) . '</a> | ';
Expand Down Expand Up @@ -429,7 +429,7 @@ function print_project_menu_bar() {
echo '<table class="width100" cellspacing="0">';
echo '<tr>';
echo '<td class="menu">';
echo '<a href="set_project.php?project_id=0">' . lang_get( 'all_projects' ) . '</a>';
echo '<a href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</a>';
for ( $i=0 ; $i < $project_count ; $i++ ) {
$row = db_fetch_array( $result );
extract( $row, EXTR_PREFIX_ALL, 'v' );
Expand Down
6 changes: 3 additions & 3 deletions core/news_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: news_api.php,v 1.10 2003-02-24 10:32:32 jfitzell Exp $
# $Id: news_api.php,v 1.11 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -119,7 +119,7 @@ function news_get_count( $p_project_id, $p_sitewide=true ) {
WHERE project_id='$c_project_id'";

if ( $p_sitewide ) {
$query .= " OR project_id=0";
$query .= ' OR project_id=' . ALL_PROJECTS;
}

$result = db_query( $query );
Expand All @@ -138,7 +138,7 @@ function news_get_rows( $p_project_id, $p_sitewide=true ) {
WHERE project_id='$c_project_id'";

if ( $p_sitewide ) {
$query .= " OR project_id=0";
$query .= ' OR project_id=' . ALL_PROJECTS;
}

$query .= " ORDER BY date_posted DESC";
Expand Down
18 changes: 8 additions & 10 deletions core/print_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: print_api.php,v 1.59 2003-03-05 21:37:30 jfitzell Exp $
# $Id: print_api.php,v 1.60 2003-03-09 03:08:58 jfitzell Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -181,8 +181,7 @@ function print_reporter_option_list( $p_user_id ) {
$t_users = array();

# checking if it's per project or all projects
# 0 is all projects
if ( 0 == helper_get_current_project() ) {
if ( ALL_PROJECTS == helper_get_current_project() ) {
$t_adm = ADMINISTRATOR;
$t_rep = config_get( 'report_bug_threshold' );
$t_pub = VS_PUBLIC;
Expand Down Expand Up @@ -295,8 +294,7 @@ function print_assign_to_option_list( $p_user_id='' ) {
$t_users = array();

# checking if it's per project or all projects
# 0 is all projects
if ( 0 == helper_get_current_project() ) {
if ( ALL_PROJECTS == helper_get_current_project() ) {
$t_adm = ADMINISTRATOR;
$t_dev = config_get( 'handle_bug_threshold' );
$t_pub = VS_PUBLIC;
Expand Down Expand Up @@ -367,8 +365,8 @@ function print_project_option_list( $p_project_id = null, $p_include_all_project
$project_count = db_num_rows( $result );

if ( $p_include_all_projects ) {
echo '<option value="0"';
check_selected( $p_project_id, 0 );
echo '<option value="' . ALL_PROJECTS . '"';
check_selected( $p_project_id, ALL_PROJECTS );
echo '>' . lang_get( 'all_projects' ) . '</option>';
}

Expand Down Expand Up @@ -523,7 +521,7 @@ function print_category_option_listOLD( $p_category='' ) {
$t_project_id = helper_get_current_project();

# @@@ not implemented yet
if ( 0 == $t_project_id ) {
if ( ALL_PROJECTS == $t_project_id ) {
$query = "SELECT category
FROM $g_mantis_project_category_table
WHERE project_id='$t_project_id'
Expand Down Expand Up @@ -651,10 +649,10 @@ function print_all_bug_action_option_list() {
# --------------------
# list of users that are NOT in the specified project and that are enabled
# if no project is specified use the current project
function print_project_user_list_option_list( $p_project_id=0 ) {
function print_project_user_list_option_list( $p_project_id=null ) {
global $g_mantis_project_user_list_table, $g_mantis_user_table;

if ( 0 == $p_project_id ) {
if ( null == $p_project_id ) {
$p_project_id = helper_get_current_project();
}
$c_project_id = (integer)$p_project_id;
Expand Down

0 comments on commit 7a2dca4

Please sign in to comment.