diff --git a/core_API.php b/core_API.php
index 51143c9ca9..5631e60414 100644
--- a/core_API.php
+++ b/core_API.php
@@ -27,6 +27,12 @@ function db_connect($p_hostname="localhost", $p_username="root",
$t_result = mysql_connect( $p_hostname.":".$p_port,
$p_username, $p_password );
$t_result = mysql_select_db( $p_database );
+
+ ### Temproary error handling
+ if ( !$t_result ) {
+ echo "ERROR: FAILED CONNECTION TO DATABASE";
+ exit;
+ }
}
### --------------------
# persistent connect to database
@@ -37,6 +43,12 @@ function db_pconnect($p_hostname="localhost", $p_username="root",
$t_result = mysql_pconnect( $p_hostname.":".$p_port,
$p_username, $p_password );
$t_result = mysql_select_db( $p_database );
+
+ ### Temproary error handling
+ if ( !$t_result ) {
+ echo "ERROR: FAILED CONNECTION TO DATABASE";
+ exit;
+ }
}
### --------------------
# execute query, requires connection to be opened,
@@ -68,7 +80,12 @@ function db_fetch_array( $p_result ) {
}
### --------------------
function db_result( $p_result, $p_index1=0, $p_index2=0 ) {
- return mysql_result( $p_result, $p_index1, $p_index2 );
+ if ( $p_result ) {
+ return mysql_result( $p_result, $p_index1, $p_index2 );
+ }
+ else {
+ return false;
+ }
}
### --------------------
function db_close() {
@@ -120,7 +137,7 @@ function print_footer( $p_file ) {
PRINT "
";
print_mantis_version();
- PRINT "Copyright (c) 2000";
+ PRINT "Copyright (c) 2000, 2001";
PRINT "$g_webmaster_email";
}
### --------------------
@@ -129,7 +146,7 @@ function print_body_bottom() {
}
### --------------------
function print_html_bottom() {
- PRINT "";
+ PRINT "";
}
### --------------------
###########################################################################
@@ -138,22 +155,25 @@ function print_html_bottom() {
### --------------------
# prints the user that is logged in and the date/time
function print_login_info() {
- global $g_mantis_user_table, $g_string_cookie_val;
-
- $query = "SELECT username
- FROM $g_mantis_user_table
- WHERE cookie_string='$g_string_cookie_val'";
- $result = db_query( $query );
- $t_username = db_result( $result, 0 );
+ global $g_mantis_user_table, $g_string_cookie_val, $g_complete_date_format;
- $t_now = date("d-m-y h:m T");
+ $t_username = get_current_user_field( "username" );
+ $t_now = date($g_complete_date_format);
PRINT "";
- PRINT "";
+ PRINT " | ";
PRINT "Logged in as: $t_username";
PRINT " | ";
- PRINT "";
+ PRINT " | ";
PRINT "$t_now";
PRINT " | ";
+ PRINT "";
+ PRINT " | ";
+ PRINT "";
PRINT "
";
}
### --------------------
@@ -204,6 +224,56 @@ function print_mantis_version() {
}
### --------------------
###########################################################################
+ # Basic Print API
+ ###########################################################################
+ ### --------------------
+ function print_user( $p_user_id ) {
+ global $g_mantis_user_table;
+
+ if ( $p_user_id=="0000000" ) {
+ return;
+ }
+ $query = "SELECT username, email
+ FROM $g_mantis_user_table
+ WHERE id='$p_user_id'";
+ $result = db_query( $query );
+ if ( db_num_rows( $result )>0 ) {
+ $t_handler_username = db_result( $result, 0, 0 );
+ $t_handler_email = db_result( $result, 0, 1 );
+
+ PRINT "".$t_handler_username."";
+ }
+ else {
+ PRINT "user no longer exists";
+ }
+ }
+ ### --------------------
+ function print_duplicate_id( $p_duplicate_id ) {
+ global $g_view_bug_page, $g_view_bug_advanced_page,
+ $g_mantis_user_pref_table;
+
+ if ( $p_duplicate_id!='0000000' ) {
+ if ( get_user_value( $g_mantis_user_pref_table, "advanced_view" )=="on" ) {
+ PRINT "".$p_duplicate_id."";
+ }
+ else {
+ PRINT "".$p_duplicate_id."";
+ }
+ }
+ }
+ ### --------------------
+ ### Returns the number of bugntoes for the given bug_id
+ function get_bugnote_count( $p_id ) {
+ global $g_mantis_bugnote_table;
+
+ $query = "SELECT COUNT(id)
+ FROM $g_mantis_bugnote_table
+ WHERE bug_id ='$p_id'";
+ $result = db_query( $query );
+ return db_result( $result, 0 );
+ }
+ ### --------------------
+ ###########################################################################
# Option List Printing API
###########################################################################
### --------------------
@@ -212,7 +282,8 @@ function print_handler_option_list( $p_handler_id ) {
$query = "SELECT id, username
FROM $g_mantis_user_table
- WHERE access_level='administrator' OR access_level='developer'";
+ WHERE access_level='administrator' OR access_level='developer'
+ ORDER BY username";
$result = db_query( $query );
$user_count = db_num_rows( $result );
for ($i=0;$i<$user_count;$i++) {
@@ -229,6 +300,28 @@ function print_handler_option_list( $p_handler_id ) {
}
}
### --------------------
+ function print_user_option_list( $p_user_id ) {
+ global $g_mantis_user_table;
+
+ $query = "SELECT id, username
+ FROM $g_mantis_user_table
+ ORDER BY username";
+ $result = db_query( $query );
+ $user_count = db_num_rows( $result );
+ for ($i=0;$i<$user_count;$i++) {
+ $row = db_fetch_array( $result );
+ $t_user_id = $row["id"];
+ $t_user_name = $row["username"];
+
+ if ( $t_user_id==$p_user_id ) {
+ PRINT "