Skip to content

Commit

Permalink
Modified to use core_version_API.php.
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@939 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Kenzaburo Ito committed May 11, 2002
1 parent 196935c commit ac937c0
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 120 deletions.
1 change: 1 addition & 0 deletions core_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
#require( "core_history_API.php" );
require( "core_proj_user_API.php" );
require( "core_category_API.php" );
require( "core_version_API.php" );
# --------------------
?>
19 changes: 0 additions & 19 deletions core_helper_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,6 @@ function get_bug_text_field( $p_bug_id, $p_field_name ) {
return db_result( $result, 0 );
}
# --------------------
# checks to see if the version is a duplicate
# we do it this way because each different project can have the same category names
function is_duplicate_version( $p_version, $p_project_id, $p_date_order='0' ) {
global $g_mantis_project_version_table;

$query = "SELECT COUNT(*)
FROM $g_mantis_project_version_table
WHERE project_id='$p_project_id' AND
version='$p_version' AND
date_order='$p_date_order'";
$result = db_query( $query );
$version_count = db_result( $result, 0, 0 );
if ( $version_count > 0 ) {
return true;
} else {
return false;
}
}
# --------------------
# converts a 1 value to X
# converts a 0 value to a space
function trans_bool( $p_num ) {
Expand Down
43 changes: 43 additions & 0 deletions core_print_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,50 @@ function print_news_project_option_list( $p_id ) {
} # end for
}
# --------------------
# Since categories can be orphaned we need to grab all unique instances of category
# We check in the project category table and in the bug table
# We put them all in one array and make sure the entries are unique
function print_category_option_list( $p_category="" ) {
global $g_mantis_bug_table, $g_mantis_project_category_table, $g_project_cookie_val;

# grab all categories in the project category table
$cat_arr = array();
$query = "SELECT DISTINCT( category ) as category
FROM $g_mantis_project_category_table
WHERE project_id='$g_project_cookie_val'
ORDER BY category";
$result = db_query( $query );
$category_count = db_num_rows( $result );
for ($i=0;$i<$category_count;$i++) {
$row = db_fetch_array( $result );
$cat_arr[] = $row["category"];
}

# grab all categories in the bug table
$query = "SELECT DISTINCT( category ) as category
FROM $g_mantis_bug_table
WHERE project_id='$g_project_cookie_val'
ORDER BY category";
$result = db_query( $query );
$category_count = db_num_rows( $result );

for ($i=0;$i<$category_count;$i++) {
$row = db_fetch_array( $result );
$cat_arr[] = $row["category"];
}
sort( $cat_arr );
$cat_arr = array_unique( $cat_arr );

foreach( $cat_arr as $t_category ) {
if ( $t_category == $p_category ) {
PRINT "<option value=\"$t_category\" SELECTED>$t_category</option>";
} else {
PRINT "<option value=\"$t_category\">$t_category</option>";
}
}
}
# --------------------
function print_category_option_listOLD( $p_category="" ) {
global $g_mantis_project_category_table, $g_project_cookie_val;

# @@@ not implemented yet
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Mantis
* Modified search to look in bugnotes.
* Modified is_duplicate_category(). Reversed the arguments.
* Modified to use core_project_API.php.
* Modified to use core_version_API.php.
* Added Hungarian translation.
* Added Japanese translation.
* Added Czech translation.
Expand Down
12 changes: 2 additions & 10 deletions manage_proj_edit_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@
<td width="100%">
<table width="100%" cellspacing="1">
<?php
$query = "SELECT category
FROM $g_mantis_project_category_table
WHERE project_id='$f_project_id'
ORDER BY category";
$result = db_query( $query );
$result = category_get_all( $f_project_id );
$category_count = db_num_rows( $result );
for ($i=0;$i<$category_count;$i++) {
$row = db_fetch_array( $result );
Expand Down Expand Up @@ -188,11 +184,7 @@
<td width="100%">
<table width="100%">
<?php
$query = "SELECT version, date_order
FROM $g_mantis_project_version_table
WHERE project_id='$f_project_id'
ORDER BY date_order DESC";
$result = db_query( $query );
$result = version_get_all( $f_project_id );
$version_count = db_num_rows( $result );
for ($i=0;$i<$version_count;$i++) {
$row = db_fetch_array( $result );
Expand Down
15 changes: 4 additions & 11 deletions manage_proj_ver_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@
check_access( MANAGER );

if ( empty( $f_version ) ) {
echo $MANTIS_ERROR[ERROR_EMPTY_FIELD];
exit;
print_mantis_error( ERROR_EMPTY_FIELD );
}

$result = 0;
# check for empty case or duplicate
if ( !empty( $f_version )&&( !is_duplicate_version( $f_version, $f_project_id ) ) ) {
# insert version
$query = "INSERT
INTO $g_mantis_project_version_table
( project_id, version, date_order )
VALUES
( '$f_project_id', '$f_version', NOW() )";
$result = db_query( $query );
if ( !empty( $f_version )&&( !is_duplicate_version( $f_project_id, $f_version ) ) ) {
$result = version_add( $f_project_id, $f_version );
}

$t_redirect_url = $g_manage_project_edit_page."?f_project_id=".$f_project_id;
Expand All @@ -42,7 +35,7 @@
<?php
if ( $result ) { # SUCCESS
PRINT "$s_operation_successful<p>";
} else if ( is_duplicate_version( $f_version, $f_project_id )) {
} else if ( is_duplicate_version( $f_project_id, $f_version )) {
PRINT $MANTIS_ERROR[ERROR_DUPLICATE_VERSION];
} else { # FAILURE
print_sql_error( $query );
Expand Down
53 changes: 1 addition & 52 deletions manage_proj_ver_delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,7 @@
$f_version = urldecode( $f_version );

# delete version
$query = "DELETE
FROM $g_mantis_project_version_table
WHERE project_id='$f_project_id' AND version='$f_version'";
$result = db_query( $query );

$query = "SELECT id, bug_text_id
FROM $g_mantis_bug_table
WHERE project_id='$f_project_id' AND version='$f_version'";
$result = db_query( $query );
$bug_count = db_num_rows( $result );

for ($i=0;$i<$bug_count;$i++) {
$row = db_fetch_array( $result );
$t_bug_id = $row["id"];
$t_bug_text_id = $row["bug_text_id"];

# Delete the bug text
$query2 = "DELETE
FROM $g_mantis_bug_text_table
WHERE id='$t_bug_text_id'";
$result2 = db_query( $query2 );

# select bugnotes to delete
$query3 = "SELECT id, bugnote_text_id
FROM $g_mantis_bugnote_table
WHERE bug_id='$t_bug_id'";
$result3 = db_query( $query3 );
$bugnote_count = db_num_rows( $result3 );

for ($j=0;$j<$bugnote_count;$j++) {
$row2 = db_fetch_array( $result3 );
$t_bugnote_id = $row2["id"];
$t_bugnote_text_id = $row2["bugnote_text_id"];

# Delete the bugnotes
$query = "DELETE
FROM $g_mantis_bugnote_table
WHERE id='$t_bugnote_id'";
$result = db_query( $query );

# Delete the bugnote texts
$query4 = "DELETE
FROM $g_mantis_bugnote_text_table
WHERE id='$t_bugnote_text_id'";
$result4 = db_query( $query4 );
}
}

$query = "DELETE
FROM $g_mantis_bug_table
WHERE project_id='$f_project_id' AND version='$f_version'";
$result = db_query( $query );
$result = version_delete( $f_project_id, $f_version );

$t_redirect_url = $g_manage_project_edit_page."?f_project_id=".$f_project_id;
if ( $result ) {
Expand Down
39 changes: 11 additions & 28 deletions manage_proj_ver_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,21 @@
check_access( MANAGER );
$f_version = urldecode( $f_version );
$f_orig_version = urldecode( $f_orig_version );
$f_date_order = urldecode( $f_date_order );
$f_date_order = urldecode( $f_date_order );

$result = 0;
$query = "";
# check for duplicate
if ( !is_duplicate_version( $f_version, $f_project_id, $f_date_order ) ) {
# update version
$query = "UPDATE $g_mantis_project_version_table
SET version='$f_version', date_order='$f_date_order'
WHERE version='$f_orig_version' AND project_id='$f_project_id'";
$result = db_query( $query );

$query = "SELECT id, date_submitted, last_updated
FROM $g_mantis_bug_table
WHERE version='$f_version'";
$result = db_query( $query );
$bug_count = db_num_rows( $result );

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

$t_bug_id = $row["id"];
$t_date_submitted = $row["date_submitted"];
$t_last_updated = $row["last_updated"];

$query2 = "UPDATE $g_mantis_bug_table
SET version='$f_version', date_submitted='$t_date_submitted',
last_updated='$t_last_updated'
WHERE id='$t_bug_id'";
$result2 = db_query( $query2 );
if ( !is_duplicate_version( $f_project_id, $f_version, $f_date_order ) ) {
$result = version_update( $f_project_id, $f_version, $f_date_order, $f_orig_version );
if ( !$result ) {
break;
}

$query2 = "UPDATE $g_mantis_bug_table
SET version='$f_version'
WHERE version='$f_orig_version'";
$result2 = db_query( $query2 );
}

$t_redirect_url = $g_manage_project_edit_page."?f_project_id=".$f_project_id;
Expand All @@ -60,7 +43,7 @@
<?php
if ( $result ) { # SUCCESS
PRINT "$s_operation_successful<p>";
} else if ( is_duplicate_version( $f_version, $f_project_id, $f_date_order )) {
} else if ( is_duplicate_version( $f_project_id, $f_version, $f_date_order )) {
PRINT $MANTIS_ERROR[ERROR_DUPLICATE_VERSION]."<p>";
} else { # FAILURE
print_sql_error( $query );
Expand Down

0 comments on commit ac937c0

Please sign in to comment.