Skip to content

Commit

Permalink
Fixes #16850: Add config folder for customization files
Browse files Browse the repository at this point in the history
Fixes #16446: Merge MantisConnect configs into MantisBT standard configs.

This change adds a config folder that includes all custom_*_inc.php files and config_inc.php file.

The SOAP API configs are now also merged into the standard configs. The fact that the separate configs was from the days where MantisConnect web service was separate from MantisBT. Now it is just confusing.

This change includes the addition of a configurable config path that can be set via an environment variable (MANTIS_CONFIG_FOLDER) or defaulted to MantisBT config subfolder. The change also includes all the necessary validation in admin/check/ and admin/install.php.

Conflicts:
	api/soap/mc_config_defaults_inc.php
  • Loading branch information
vboctor committed Apr 23, 2014
2 parents b1877a6 + 7dc0424 commit 4b17346
Show file tree
Hide file tree
Showing 26 changed files with 247 additions and 236 deletions.
7 changes: 5 additions & 2 deletions .gitignore
@@ -1,12 +1,15 @@
# Config files
# Config files - v1.2.x config files - keep for convenience for dev machines switching branches
config_inc.php
custom_constants_inc.php
custom_functions_inc.php
custom_relationships_inc.php
custom_strings_inc.php
mantis_offline.php
api/soap/mc_config_inc.php

# Config files
config/
mantis_offline.php

# Docbook builds
docbook/*/*/builddate
docbook/*/*/build
Expand Down
32 changes: 31 additions & 1 deletion admin/check/check_config_inc.php
Expand Up @@ -37,10 +37,40 @@
check_print_section_header_row( 'Configuration' );

check_print_test_row( 'config_inc.php configuration file exists',
file_exists( dirname( dirname( dirname( __FILE__ ) ) ) . '/config_inc.php' ),
file_exists( $g_config_path . 'config_inc.php' ),
array( false => 'Please use <a href="install.php">install.php</a> to perform the initial installation of MantisBT.' )
);

check_print_test_row( 'config_inc.php must not be in MantisBT root folder',
!file_exists( $g_absolute_path . 'config_inc.php' ),
array( false => 'Move from MantisBT root folder to config folder.' )
);

check_print_test_row( 'custom_strings_inc.php must not be in MantisBT root folder',
!file_exists( $g_absolute_path . 'custom_strings_inc.php' ),
array( false => 'Move from MantisBT root folder to config folder.' )
);

check_print_test_row( 'custom_functions_inc.php must not be in MantisBT root folder',
!file_exists( $g_absolute_path . 'custom_functions_inc.php' ),
array( false => 'Move from MantisBT root folder to config folder.' )
);

check_print_test_row( 'custom_constants_inc.php must not be in MantisBT root folder',
!file_exists( $g_absolute_path . 'custom_constants_inc.php' ),
array( false => 'Move from MantisBT root folder to config folder.' )
);

check_print_test_row( 'custom_relationships_inc.php must not be in MantisBT root folder',
!file_exists( $g_absolute_path . 'custom_relationships_inc.php' ),
array( false => 'Move from MantisBT root folder to config folder.' )
);

check_print_test_row( 'api/soap/mc_config_inc.php is no longer supported',
!file_exists( $g_absolute_path . 'api/soap/mc_config_inc.php' ),
array( false => 'Move contents of api/soap/mc_config_inc.php into config/config_inc.php.' )
);

# Debugging / Developer Settings
check_print_test_warn_row( 'Check whether diagnostic logging is enabled',
$g_log_level == LOG_NONE,
Expand Down
10 changes: 5 additions & 5 deletions admin/check/check_integrity_inc.php
Expand Up @@ -177,11 +177,11 @@ function check_file_integrity_recursive( $p_directory, $p_base_directory, $p_rel
'lang/',
'library/',
'plugins/',
'config_inc.php',
'custom_constants_inc.php',
'custom_functions_inc.php',
'custom_relationships_inc.php',
'custom_strings_inc.php',
'config/config_inc.php',
'config/custom_constants_inc.php',
'config/custom_functions_inc.php',
'config/custom_relationships_inc.php',
'config/custom_strings_inc.php',
'mantis_offline.php'
);
check_file_integrity_recursive( $t_absolute_base_dir, $t_absolute_base_dir, '', $t_ignore_files );
Expand Down
2 changes: 2 additions & 0 deletions admin/check/check_paths_inc.php
Expand Up @@ -43,6 +43,7 @@
'core_path',
'class_path',
'library_path',
'config_path',
'language_path'
);

Expand Down Expand Up @@ -117,6 +118,7 @@
'core_path',
'class_path',
'library_path',
'config_path',
'language_path'
);

Expand Down
11 changes: 0 additions & 11 deletions admin/check/check_webservice_inc.php
Expand Up @@ -36,17 +36,6 @@

check_print_section_header_row( 'Webservice' );

$t_library_path = config_get_global( 'library_path' );
$t_library_path = realpath( $t_library_path );
if ( $t_library_path[strlen( $t_library_path )-1] != '/' ) {
$t_library_path .= '/';
}

check_print_test_warn_row(
"Legacy <em>library/nusoap</em> folder must be deleted.",
!is_dir( $t_library_path . 'nusoap' )
);

check_print_test_warn_row(
'SOAP Extension Enabled',
extension_loaded( 'soap' ),
Expand Down
22 changes: 16 additions & 6 deletions admin/install.php
Expand Up @@ -27,7 +27,7 @@
@set_time_limit( 0 );

# Load the MantisDB core in maintenance mode. This mode will assume that
# config_inc.php hasn't been specified. Thus the database will not be opened
# config/config_inc.php hasn't been specified. Thus the database will not be opened
# and plugins will not be loaded.
define( 'MANTIS_MAINTENANCE_MODE', true );

Expand Down Expand Up @@ -153,7 +153,7 @@ function print_test( $p_test_description, $p_result, $p_hard_fail = true, $p_mes
<?php
}

$t_config_filename = $g_absolute_path . 'config_inc.php';
$t_config_filename = $g_config_path . 'config_inc.php';
$t_config_exists = file_exists( $t_config_filename );

# Initialize Oracle-specific values for prefix and suffix, and set
Expand Down Expand Up @@ -286,6 +286,16 @@ function print_test( $p_test_description, $p_result, $p_hard_fail = true, $p_mes
true,
'Disable safe_mode in php.ini before proceeding' ) ?>

<?php
print_test( 'Checking there is no config_inc.php in 1.2.x location.', !file_exists( dirname( dirname( __FILE__ ) ) . '/config_inc.php' ), true, 'Move config_inc.php to config/config_inc.php.' );
print_test( 'Checking there is no custom_constants_inc.php in 1.2.x location.', !file_exists( dirname( dirname( __FILE__ ) ) . '/custom_constants_inc.php' ), true, 'Move custom_constants_inc.php to config/custom_constants_inc.php.' );
print_test( 'Checking there is no custom_strings_inc.php in 1.2.x location.', !file_exists( dirname( dirname( __FILE__ ) ) . '/custom_strings_inc.php' ), true, 'Move custom_strings_inc.php to config/custom_strings_inc.php.' );
print_test( 'Checking there is no custom_functions_inc.php in 1.2.x location.', !file_exists( dirname( dirname( __FILE__ ) ) . '/custom_functions_inc.php' ), true, 'Move custom_functions_inc.php to config/custom_functions_inc.php.' );
print_test( 'Checking there is no custom_relationships_inc.php in 1.2.x location.', !file_exists( dirname( dirname( __FILE__ ) ) . '/custom_relationships_inc.php' ), true, 'Move custom_relationships_inc.php to config/custom_relationships_inc.php.' );
print_test( 'Checking there is no mc_config_defaults_inc.php in 1.2.x location.', !file_exists( dirname( dirname( __FILE__ ) ) . '/api/soap/mc_config_defaults_inc.php' ), true, 'Delete this file.' );
print_test( 'Checking there is no mc_config_inc.php in 1.2.x location.', !file_exists( dirname( dirname( __FILE__ ) ) . '/api/soap/mc_config_inc.php' ), true, 'Move contents to config_inc.php file.' );
?>

</table>
<?php
if( false == $g_failed ) {
Expand Down Expand Up @@ -1023,7 +1033,7 @@ function print_test( $p_test_description, $p_result, $p_hard_fail = true, $p_mes

# all checks have passed, install the database
if( 5 == $t_install_state ) {
$t_config_filename = $g_absolute_path . 'config_inc.php';
$t_config_filename = $g_config_path . 'config_inc.php';
$t_config_exists = file_exists( $t_config_filename );
?>
<table width="100%" cellpadding="10" cellspacing="1">
Expand All @@ -1038,14 +1048,14 @@ function print_test( $p_test_description, $p_result, $p_hard_fail = true, $p_mes
<?php
if( !$t_config_exists ) {
?>
Creating Configuration File (config_inc.php)<br />
Creating Configuration File (config/config_inc.php)<br />
<span class="error-msg">
(if this file is not created, create it manually with the contents below)
</span>
<?php
} else {
?>
Updating Configuration File (config_inc.php)<br />
Updating Configuration File (config/config_inc.php)<br />
<?php
}
?>
Expand Down Expand Up @@ -1109,7 +1119,7 @@ function print_test( $p_test_description, $p_result, $p_hard_fail = true, $p_mes
( $f_db_schema != config_get( 'db_schema', '') ) ||
( $f_db_username != config_get( 'db_username', '' ) ) ||
( $f_db_password != config_get( 'db_password', '' ) ) ) {
print_test_result( BAD, false, 'file ' . $g_absolute_path . 'config_inc.php' . ' already exists and has different settings' );
print_test_result( BAD, false, 'file ' . $g_config_path . 'config_inc.php' . ' already exists and has different settings' );
} else {
print_test_result( GOOD, false );
$t_write_failed = false;
Expand Down
2 changes: 1 addition & 1 deletion admin/test_email.php
Expand Up @@ -38,7 +38,7 @@
<tr>
<td bgcolor="#f4f4f4">
<span class="title">Testing Email</span>
<p>You can test the ability for MantisBT to send email notifications with this form. Just click "Send Mail". If the page takes a very long time to reappear or results in an error then you will need to investigate your php/mail server settings (see PHPMailer related settings in your config_inc.php, if they don't exist, copy from config_defaults_inc.php). Note that errors can also appear in the server error log. More help can be found at the <a href="http://www.php.net/manual/en/ref.mail.php">PHP website</a> if you are using the mail() PHPMailer sending mode.</p>
<p>You can test the ability for MantisBT to send email notifications with this form. Just click "Send Mail". If the page takes a very long time to reappear or results in an error then you will need to investigate your php/mail server settings (see PHPMailer related settings in your config/config_inc.php, if they don't exist, copy from config_defaults_inc.php). Note that errors can also appear in the server error log. More help can be found at the <a href="http://www.php.net/manual/en/ref.mail.php">PHP website</a> if you are using the mail() PHPMailer sending mode.</p>
<?php
if( $f_mail_test ) {
echo '<strong>Testing Mail</strong> - ';
Expand Down
9 changes: 0 additions & 9 deletions api/soap/mantisconnect.php
Expand Up @@ -34,15 +34,6 @@
$g_bypass_headers = true;
require_once( $t_mantis_dir . 'core.php' );

# constants and configurations
$t_current_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
require_once( $t_current_dir . 'mc_config_defaults_inc.php' );

$t_user_configs = $t_current_dir . 'mc_config_inc.php';
if( file_exists( $t_user_configs ) ) {
require_once( $t_user_configs );
}

/**
* Checks if the request for the webservice is a documentation request (eg:
* WSDL) or an actual webservice call.
Expand Down
6 changes: 3 additions & 3 deletions api/soap/mc_api.php
Expand Up @@ -188,12 +188,12 @@ function mci_check_login( $p_username, $p_password ) {

function mci_has_readonly_access( $p_user_id, $p_project_id = ALL_PROJECTS ) {
$t_access_level = user_get_access_level( $p_user_id, $p_project_id );
return( $t_access_level >= config_get( 'mc_readonly_access_level_threshold' ) );
return( $t_access_level >= config_get( 'webservice_readonly_access_level_threshold' ) );
}

function mci_has_readwrite_access( $p_user_id, $p_project_id = ALL_PROJECTS ) {
$t_access_level = user_get_access_level( $p_user_id, $p_project_id );
return( $t_access_level >= config_get( 'mc_readwrite_access_level_threshold' ) );
return( $t_access_level >= config_get( 'webservice_readwrite_access_level_threshold' ) );
}

function mci_has_access( $p_access_level, $p_user_id, $p_project_id = ALL_PROJECTS ) {
Expand All @@ -203,7 +203,7 @@ function mci_has_access( $p_access_level, $p_user_id, $p_project_id = ALL_PROJEC

function mci_has_administrator_access( $p_user_id, $p_project_id = ALL_PROJECTS ) {
$t_access_level = user_get_access_level( $p_user_id, $p_project_id );
return( $t_access_level >= config_get( 'mc_admin_access_level_threshold' ) );
return( $t_access_level >= config_get( 'webservice_admin_access_level_threshold' ) );
}

function mci_get_project_id( $p_project ) {
Expand Down
64 changes: 0 additions & 64 deletions api/soap/mc_config_defaults_inc.php

This file was deleted.

5 changes: 5 additions & 0 deletions api/soap/mc_core.php
Expand Up @@ -23,6 +23,9 @@
* @link http://www.mantisbt.org
*/

# constants and configurations
$t_current_dir = dirname( __FILE__ ) . '/';

# MantisConnect APIs
# mc_* = public methods
# mci_* = internal methods
Expand All @@ -40,3 +43,5 @@
require_once( $t_current_dir . 'mc_user_pref_api.php' );
require_once( $t_current_dir . 'mc_tag_api.php' );
require_once( $t_current_dir . 'mc_user_profile_api.php' );

unset( $t_current_dir );
2 changes: 1 addition & 1 deletion api/soap/mc_enum_api.php
Expand Up @@ -325,7 +325,7 @@ function mci_get_enum_id_from_objectref( $p_enum, $p_object_ref ) {
if( !is_null( $p_object_ref ) && isset( $p_object_ref['name'] ) && !is_blank( $p_object_ref['name'] ) ) {
$t_id = mci_get_enum_value_from_label( $t_enum, $p_object_ref['name'] );
if( $t_id == 0 ) {
$t_id = config_get( 'mc_' . $p_enum . '_enum_default_when_not_found' );
$t_id = config_get( 'webservice_' . $p_enum . '_enum_default_when_not_found' );
}
} else {
$t_default_id = config_get( 'default_bug_' . $p_enum, 0 );
Expand Down
14 changes: 7 additions & 7 deletions api/soap/mc_issue_api.php
Expand Up @@ -338,7 +338,7 @@ function mci_issue_get_relationships( $p_issue_id, $p_user_id ) {

$t_src_relationships = relationship_get_all_src( $p_issue_id );
foreach( $t_src_relationships as $t_relship_row ) {
if( access_has_bug_level( config_get( 'mc_readonly_access_level_threshold' ), $t_relship_row->dest_bug_id, $p_user_id ) ) {
if( access_has_bug_level( config_get( 'webservice_readonly_access_level_threshold' ), $t_relship_row->dest_bug_id, $p_user_id ) ) {
$t_relationship = array();
$t_reltype = array();
$t_relationship['id'] = $t_relship_row->id;
Expand All @@ -352,7 +352,7 @@ function mci_issue_get_relationships( $p_issue_id, $p_user_id ) {

$t_dest_relationships = relationship_get_all_dest( $p_issue_id );
foreach( $t_dest_relationships as $t_relship_row ) {
if( access_has_bug_level( config_get( 'mc_readonly_access_level_threshold' ), $t_relship_row->src_bug_id, $p_user_id ) ) {
if( access_has_bug_level( config_get( 'webservice_readonly_access_level_threshold' ), $t_relship_row->src_bug_id, $p_user_id ) ) {
$t_relationship = array();
$t_relationship['id'] = $t_relship_row->id;
$t_reltype = array();
Expand Down Expand Up @@ -633,7 +633,7 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) {
if( $t_reporter_id != $t_user_id ) {

# Make sure that active user has access level required to specify a different reporter.
$t_specify_reporter_access_level = config_get( 'mc_specify_reporter_on_add_access_level_threshold' );
$t_specify_reporter_access_level = config_get( 'webservice_specify_reporter_on_add_access_level_threshold' );
if( !access_has_project_level( $t_specify_reporter_access_level, $t_project_id, $t_user_id ) ) {
return mci_soap_fault_access_denied( $t_user_id, "Active user does not have access level required to specify a different issue reporter" );
}
Expand Down Expand Up @@ -675,12 +675,12 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) {
if ( isset( $p_issue['version'] ) && !is_blank( $p_issue['version'] ) && !version_get_id( $p_issue['version'], $t_project_id ) ) {
$t_version = $p_issue['version'];

$t_error_when_version_not_found = config_get( 'mc_error_when_version_not_found' );
$t_error_when_version_not_found = config_get( 'webservice_error_when_version_not_found' );
if( $t_error_when_version_not_found == ON ) {
$t_project_name = project_get_name( $t_project_id );
return SoapObjectsFactory::newSoapFault('Client', "Version '$t_version' does not exist in project '$t_project_name'.");
} else {
$t_version_when_not_found = config_get( 'mc_version_when_not_found' );
$t_version_when_not_found = config_get( 'webservice_version_when_not_found' );
$t_version = $t_version_when_not_found;
}
}
Expand Down Expand Up @@ -866,12 +866,12 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {
}

if ( isset( $p_issue['version'] ) && !is_blank( $p_issue['version'] ) && !version_get_id( $p_issue['version'], $t_project_id ) ) {
$t_error_when_version_not_found = config_get( 'mc_error_when_version_not_found' );
$t_error_when_version_not_found = config_get( 'webservice_error_when_version_not_found' );
if( $t_error_when_version_not_found == ON ) {
$t_project_name = project_get_name( $t_project_id );
return SoapObjectsFactory::newSoapFault( 'Client', "Version '" . $p_issue['version'] . "' does not exist in project '$t_project_name'." );
} else {
$t_version_when_not_found = config_get( 'mc_version_when_not_found' );
$t_version_when_not_found = config_get( 'webservice_version_when_not_found' );
$p_issue['version'] = $t_version_when_not_found;
}
}
Expand Down
3 changes: 3 additions & 0 deletions config/.htaccess
@@ -0,0 +1,3 @@
## no access to this folder
order allow,deny
deny from all
File renamed without changes.

0 comments on commit 4b17346

Please sign in to comment.