Index: config_defaults_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/config_defaults_inc.php,v
retrieving revision 1.183
diff -u -r1.183 config_defaults_inc.php
--- config_defaults_inc.php	25 Jul 2004 21:09:39 -0000	1.183
+++ config_defaults_inc.php	30 Jul 2004 12:28:35 -0000
@@ -53,9 +53,14 @@
 			$t_protocol = 'https';
 		}
 
-		$t_port = ':' . $_SERVER['SERVER_PORT'];
-		if ( ( ':80' == $t_port && 'http' == $t_protocol )
-		  || ( ':443' == $t_port && 'https' == $t_protocol )) {
+		# $_SERVER['SERVER_PORT'] is not defined in case of php-cgi.exe
+		if ( isset( $_SERVER['SERVER_PORT'] ) ) {
+			$t_port = ':' . $_SERVER['SERVER_PORT'];
+			if ( ( ':80' == $t_port && 'http' == $t_protocol )
+			  || ( ':443' == $t_port && 'https' == $t_protocol )) {
+				$t_port = '';
+			}
+		} else {
 			$t_port = '';
 		}
 
@@ -99,7 +104,11 @@
 	#############################
 
 	# Using Microsoft Internet Information Server (IIS)
-	$g_use_iis = ( strstr( $_SERVER['SERVER_SOFTWARE'], 'IIS' ) !== false ) ? ON : OFF;
+	if ( isset( $_SERVER['SERVER_SOFTWARE'] ) ) { # SERVER_SOFTWARE not defined in case of php-cgi.exe
+		$g_use_iis = ( strstr( $_SERVER['SERVER_SOFTWARE'], 'IIS' ) !== false ) ? ON : OFF;
+	} else {
+		$g_use_iis = OFF;
+	}
 
 	#############################
 	# Mantis Email Settings
@@ -883,6 +892,26 @@
 	# insert the URL to your CVSweb or ViewCVS
 	# eg: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mantisbt/mantisbt/
 	$g_cvs_web				= '';
+	
+	# --- Source Control Integration ------
+	
+	# For open source projects it is expected that the notes be public, however,
+	# for non-open source it will probably be VS_PRIVATE.
+	$g_source_control_notes_view_status = VS_PRIVATE;
+
+	# Account to be used by the source control script.  The account must be enabled
+	# and must have the appropriate access level to add notes to all issues even
+	# private ones (DEVELOPER access recommended).
+	$g_source_control_account           = '';
+
+	# If set to a status, then after a checkin, the issue status is set to the 
+	# specified status, otherwise if set to OFF, the issue status is not affected.
+	$g_source_control_set_status_to     = OFF;
+
+	# Regular expression used to detect issue ids within checkin comments.
+	# see preg_match_all() documentation at
+	# http://www.php.net/manual/en/function.preg-match-all.php
+	$g_source_control_regexp = "/\bissue [#]{0,1}(\d+)\b/i";
 
 	# --- Bug Linking ---------------
 	# if a number follows this tag it will create a link to a bug.
Index: manage_user_delete.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/manage_user_delete.php,v
retrieving revision 1.27
diff -u -r1.27 manage_user_delete.php
--- manage_user_delete.php	11 Jan 2004 07:16:07 -0000	1.27
+++ manage_user_delete.php	27 Jul 2004 13:58:53 -0000
@@ -20,7 +20,7 @@
 
 	user_delete( $f_user_id );
 
-    $t_redirect_url = 'manage_user_page.php';
+	$t_redirect_url = 'manage_user_page.php';
 
 	html_page_top1();
 
Index: core/authentication_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/authentication_api.php,v
retrieving revision 1.42
diff -u -r1.42 authentication_api.php
--- core/authentication_api.php	27 Jul 2004 14:24:57 -0000	1.42
+++ core/authentication_api.php	29 Jul 2004 14:15:28 -0000
@@ -11,6 +11,8 @@
 
 	### Authentication API ###
 
+	$g_script_login_cookie = null;
+
 	#===================================
 	# Boolean queries and ensures
 	#===================================
@@ -49,11 +51,7 @@
 	# Return true if there is a currently logged in and authenticated user,
 	#  false otherwise
 	function auth_is_user_authenticated() {
-		if ( is_blank( auth_get_current_user_cookie() ) ) {
-			return false;
-		} else {
-			return true;
-		}
+		return ( !is_blank( auth_get_current_user_cookie() ) );
 	}
 
 
@@ -126,12 +124,45 @@
 	}
 
 	# --------------------
+	# Allows scripts to login using a login name or ( login name + password )
+	function auth_attempt_script_login( $p_username, $p_password = null ) {
+		global $g_script_login_cookie;
+
+		$t_user_id = user_get_id_by_name( $p_username );
+
+		$t_user = user_get_row( $t_user_id );
+
+		# check for disabled account
+		if ( OFF == $t_user['enabled'] ) {
+			return false;
+		}
+
+		# validate password if supplied	
+		if ( null !== $p_password ) {
+			if ( !auth_does_password_match( $t_user_id, $p_password ) ) {
+				return false;
+			}
+		}
+
+		# ok, we're good to login now
+
+		# increment login count
+		user_increment_login_count( $t_user_id );
+
+		# set the cookies
+		$g_script_login_cookie = $t_user['cookie_string'];
+
+		return true;
+	}
+
+	# --------------------
 	# Logout the current user and remove any remaining cookies from their browser
 	# Returns true on success, false otherwise
 	function auth_logout() {
 		auth_clear_cookies();
 		helper_clear_pref_cookies();
 		filter_db_delete_current_filters();
+
 		return true;
 	}
 
@@ -238,6 +269,10 @@
 	# --------------------
 	# Clear login cookies
 	function auth_clear_cookies() {
+		global $g_script_login_cookie;
+
+		$g_script_login_cookie = null;
+
 		$t_cookie_name =  config_get( 'string_cookie' );
 		$t_cookie_path = config_get( 'cookie_path' );
 
@@ -291,19 +326,25 @@
 	# if no user is logged in and anonymous login is enabled, returns cookie for anonymous user
 	# otherwise returns '' (an empty string)
 	function auth_get_current_user_cookie() {
+		global $g_script_login_cookie;
+
 		$t_cookie_name = config_get( 'string_cookie' );
 		$t_cookie = gpc_get_cookie( $t_cookie_name, '' );
 
 		# if cookie not found, and anonymous login enabled, use cookie of anonymous account.
 		if ( is_blank( $t_cookie ) ) {
-			if ( ON == config_get( 'allow_anonymous_login' ) ) {
-				$query = sprintf('SELECT id, cookie_string FROM %s WHERE username = "%s"',
-						config_get( 'mantis_user_table' ), config_get( 'anonymous_account' ) );
-				$result = db_query( $query );
-
-				if ( 1 == db_num_rows( $result ) ) {
-					$row		= db_fetch_array( $result );
-					$t_cookie	= $row['cookie_string'];
+			if ( $g_script_login_cookie !== null ) {
+				return $g_script_login_cookie;
+			} else {
+				if ( ON == config_get( 'allow_anonymous_login' ) ) {
+					$query = sprintf('SELECT id, cookie_string FROM %s WHERE username = "%s"',
+							config_get( 'mantis_user_table' ), config_get( 'anonymous_account' ) );
+					$result = db_query( $query );
+
+					if ( 1 == db_num_rows( $result ) ) {
+						$row		= db_fetch_array( $result );
+						$t_cookie	= $row['cookie_string'];
+					}
 				}
 			}
 		}
Index: core/constant_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/constant_inc.php,v
retrieving revision 1.24
diff -u -r1.24 constant_inc.php
--- core/constant_inc.php	25 Jul 2004 21:09:41 -0000	1.24
+++ core/constant_inc.php	30 Jul 2004 11:14:21 -0000
@@ -133,21 +133,18 @@
 	define( 'BUG_ADD_SPONSORSHIP',				15 );
 	define( 'BUG_UPDATE_SPONSORSHIP',			16 );
 	define( 'BUG_DELETE_SPONSORSHIP',			17 );
-	# MASC RELATIONSHIP
 	define( 'BUG_ADD_RELATIONSHIP', 		18 );
 	define( 'BUG_DEL_RELATIONSHIP', 		19 );
 	define( 'BUG_CLONED_TO', 				20 );
 	define( 'BUG_CREATED_FROM', 			21 );
-	# MASC RELATIONSHIP
+	define( 'CHECKIN',				22 );
 
 	# bug relationship constants
 	define( 'BUG_DUPLICATE',	0 );
 	define( 'BUG_RELATED',		1 );
 	define( 'BUG_DEPENDANT',	2 );
-	# MASC RELATIONSHIP
 	define( 'BUG_BLOCKS', 3 );
 	define( 'BUG_HAS_DUPLICATE', 4 );
-	# MASC RELATIONSHIP
 
 	# error messages
 	define( 'ERROR_GENERIC',						0 );
Index: core/custom_function_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/custom_function_api.php,v
retrieving revision 1.4
diff -u -r1.4 custom_function_api.php
--- core/custom_function_api.php	10 Jul 2004 23:29:49 -0000	1.4
+++ core/custom_function_api.php	30 Jul 2004 11:51:15 -0000
@@ -29,4 +29,20 @@
 		$t_bug = bug_get( $p_issue_id );
 		echo '- ', string_get_bug_view_link( $p_issue_id ), ': <b>[', $t_bug->category, ']</b> ', string_display( $t_bug->summary ), ' (', user_get_name( $t_bug->handler_id ), ')<br />';
 	}
+	
+	# --------------------
+	# Register a checkin in source control by adding a history entry and a note
+	# This can be overriden to do extra work like changing the issue status to 
+	# config_get( 'bug_readonly_status_threshold' );
+	function custom_function_default_checkin( $p_issue_id, $p_comment, $p_file, $p_new_version ) {
+		if ( bug_exists( $p_issue_id ) ) {
+			history_log_event_special( $p_issue_id, CHECKIN, $p_file, $p_new_version );
+			bugnote_add( $p_issue_id, $p_comment, VS_PRIVATE == config_get( 'source_control_notes_view_status' ) );
+
+			$t_status = config_get( 'source_control_set_status_to' );
+			if ( OFF != $t_status ) {
+				bug_set_field( $p_issue_id, 'status', $t_status );
+			}
+		}
+	}
 ?>
\ No newline at end of file
Index: core/history_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/history_api.php,v
retrieving revision 1.25
diff -u -r1.25 history_api.php
--- core/history_api.php	18 Jul 2004 09:58:29 -0000	1.25
+++ core/history_api.php	30 Jul 2004 12:14:12 -0000
@@ -302,7 +302,6 @@
 					$t_note = lang_get( 'sponsorship_deleted' );
 					$t_change = user_get_name( $p_old_value ) . ': ' . sponsorship_format_amount( $p_new_value );
 					break;
-				# MASC RELATIONSHIP
 				case BUG_ADD_RELATIONSHIP:
 					$t_note = lang_get( 'relationship_added' ) . ': ' . lang_get( 'bug' ) . ' ' . bug_format_id( $p_new_value );
 					break;
@@ -315,8 +314,9 @@
 				case BUG_CREATED_FROM:
 					$t_note = lang_get( 'bug_created_from' ) . ': ' . bug_format_id( $p_new_value );
 					break;
-				# MASC RELATIONSHIP
-
+				case CHECKIN:
+					$t_note = lang_get( 'checkin' );
+					break;
 			}
 		}
 
Index: core/html_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/html_api.php,v
retrieving revision 1.113
diff -u -r1.113 html_api.php
--- core/html_api.php	24 Jul 2004 15:20:45 -0000	1.113
+++ core/html_api.php	24 Jul 2004 15:37:27 -0000
@@ -375,7 +375,7 @@
 
 		foreach( $t_custom_menu_options as $t_custom_option ) {
 			$t_access_level = $t_custom_option[1];
-			if ( access_has_project_level( $t_access_level ) ) {
+			if ( access_has_global_level( $t_access_level ) ) {
 				$t_caption = lang_get_defaulted( $t_custom_option[0] );
 				$t_link = $t_custom_option[2];
 				$t_options[] = "<a href=\"$t_link\">$t_caption</a>";
Index: doc/ChangeLog
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/doc/ChangeLog,v
retrieving revision 1.716
diff -u -r1.716 ChangeLog
--- doc/ChangeLog	27 Jul 2004 11:44:26 -0000	1.716
+++ doc/ChangeLog	30 Jul 2004 12:34:34 -0000
@@ -2,6 +2,7 @@
 
 2004.08.xx  -  0.19.0xx
 
+- 0003371: [feature] CVS Integration - general source control integration implemented (vboctor)
 - 0004137: [feature] Support a simple "view" URL (vboctor)
 - 0004145: [feature] Mantis pages should have descriptive titles (vboctor)
 - 0004185: [customization] Support custom menu options (vboctor)
Index: lang/strings_english.txt
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/lang/strings_english.txt,v
retrieving revision 1.189
diff -u -r1.189 strings_english.txt
--- lang/strings_english.txt	22 Jul 2004 15:05:13 -0000	1.189
+++ lang/strings_english.txt	30 Jul 2004 12:06:27 -0000
@@ -1000,4 +1000,7 @@
 $s_create_child_bug_button = "Create Child";
 $s_bug_cloned_to = "Issue cloned";
 $s_bug_created_from = "Issue generated from";
+
+# Source Control Integration
+$s_checkin = 'Checkin';
 ?>
\ No newline at end of file
