Skip to content

Commit

Permalink
hold on to your hats folks, this is a big one
Browse files Browse the repository at this point in the history
Major work on cleaning up and filling out the project API and touching most of the files that use it.  None of the PHP files are necessarily complete - just better than they were.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@1360 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Julian Fitzell committed Aug 27, 2002
1 parent cca7b97 commit a57a04a
Show file tree
Hide file tree
Showing 27 changed files with 442 additions and 302 deletions.
2 changes: 2 additions & 0 deletions constant_inc.php
Expand Up @@ -158,6 +158,8 @@
define( 'ERROR_PROJECT_NOT_FOUND', 22 );
define( 'ERROR_DB_FIELD_NOT_FOUND', 23 );
define( 'ERROR_FTP_CONNECT_ERROR', 24 );
define( 'ERROR_PROJECT_NAME_NOT_UNIQUE', 25 );
define( 'ERROR_PROJECT_NAME_INVALID', 25 );

# Status Legend Position
define( 'STATUS_LEGEND_POSITION_TOP', 1);
Expand Down
28 changes: 27 additions & 1 deletion core/bug_api.php
Expand Up @@ -6,7 +6,7 @@
# See the files README and LICENSE for details

# --------------------------------------------------------
# $Id: bug_api.php,v 1.3 2002-08-25 09:32:44 jfitzell Exp $
# $Id: bug_api.php,v 1.4 2002-08-27 04:26:42 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -115,6 +115,32 @@ function bug_delete( $p_id, $p_bug_text_id ) {
return ($retval);
}
# --------------------
# Delete all bugs associated with a project
function bug_delete_all( $p_project_id ) {
$c_project_id = db_prepare_int( $p_project_id );

$t_bug_table = config_get( 'mantis_bug_table' );

$query = "SELECT id, bug_text_id
FROM $t_bug_table
WHERE project_id='$c_project_id'";
$result = db_query( $query );

$bug_count = db_num_rows( $result );

for ( $i=0 ; $i < $bug_count ; $i++ ) {
$row = db_fetch_array( $result );

bug_delete( $row['id'], $row['bug_text_id']);
}

# @@@ should we check the return value of each bug_delete() and
# return false if any of them return false? Presumable bug_delete()
# will eventually trigger an error on failure so it won't matter...

return true;
}
# --------------------
# This function assigns the bug to the current user
function bug_assign( $p_bug_id ) {
global $g_mantis_bug_table, $g_auto_set_status_to_assigned;
Expand Down
17 changes: 16 additions & 1 deletion core/category_api.php
Expand Up @@ -6,7 +6,7 @@
# See the files README and LICENSE for details

# --------------------------------------------------------
# $Id: category_api.php,v 1.2 2002-08-25 08:14:59 jfitzell Exp $
# $Id: category_api.php,v 1.3 2002-08-27 04:26:42 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -96,4 +96,19 @@ function category_get_all( $p_project_id ) {
return db_query( $query );
}
# --------------------
# delete all categories associated with a project
function category_delete_all( $p_project_id ) {
$c_project_id = db_prepare_int( $p_project_id );

$t_project_category_table = config_get( 'mantis_project_category_table' );

$query = "DELETE
FROM $t_project_category_table
WHERE project_id='$c_project_id'";

db_query( $query );

# db_query() errors on failure so:
return true;
}
?>
12 changes: 3 additions & 9 deletions core/database_api.php
Expand Up @@ -6,7 +6,7 @@
# See the files README and LICENSE for details

# --------------------------------------------------------
# $Id: database_api.php,v 1.4 2002-08-26 00:40:23 jfitzell Exp $
# $Id: database_api.php,v 1.5 2002-08-27 04:26:42 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -91,18 +91,12 @@ function db_affected_rows() {
}
# --------------------
function db_fetch_array( $p_result ) {
$row = mysql_fetch_array( $p_result );

if ( false == $row ) {
return false;
} else {
return db_unprepare_row( $row );
}
return mysql_fetch_array( $p_result );
}
# --------------------
function db_result( $p_result, $p_index1=0, $p_index2=0 ) {
if ( $p_result && ( db_num_rows( $p_result ) > 0 ) ) {
return db_unprepare( mysql_result( $p_result, $p_index1, $p_index2 ) );
return mysql_result( $p_result, $p_index1, $p_index2 );
} else {
return false;
}
Expand Down
17 changes: 16 additions & 1 deletion core/helper_api.php
Expand Up @@ -6,7 +6,7 @@
# See the files README and LICENSE for details

# --------------------------------------------------------
# $Id: helper_api.php,v 1.5 2002-08-26 00:40:23 jfitzell Exp $
# $Id: helper_api.php,v 1.6 2002-08-27 04:26:43 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -347,4 +347,19 @@ function check_checked( $p_var, $p_val ) {
}
}
# --------------------
# Return the current project id as stored in a cookie
function helper_get_current_project() {
global $g_project_cookie_val;

return $g_project_cookie_val;
}
# --------------------
# Add a trailing DIRECTORY_SEPARATOR to a string if it isn't present
function helper_terminate_directory_path( $p_path ) {
if ( $p_path && $p_path[strlen($p_path)-1] != DIRECTORY_SEPARATOR ) {
$p_path = $p_path.DIRECTORY_SEPARATOR;
}

return $p_path;
}
?>

0 comments on commit a57a04a

Please sign in to comment.