From 0fc969f8b92ee913fb3f51fc8537657a14dafdbf Mon Sep 17 00:00:00 2001 From: Daryn Warriner Date: Tue, 29 Mar 2011 11:30:43 -0500 Subject: [PATCH] Allow config path to be set by the web server to enable multiple mantis sites with one code base. --- application/configs/config_defaults_inc.php | 2 +- application/core/relationship_api.php | 4 ++-- doc/CUSTOMIZATION | 2 +- doc/INSTALL | 8 ++++---- docbook/Admin_Guide/en-US/Customizing.xml | 10 +++++----- public/admin/check/check_config_inc.php | 2 +- public/admin/check/check_integrity_inc.php | 10 +++++----- public/core.php | 19 ++++++++++++------- 8 files changed, 31 insertions(+), 26 deletions(-) diff --git a/application/configs/config_defaults_inc.php b/application/configs/config_defaults_inc.php index 4dd97fc42e..5be910784a 100644 --- a/application/configs/config_defaults_inc.php +++ b/application/configs/config_defaults_inc.php @@ -186,7 +186,7 @@ * NOTE: you can not mix/merge old/new formats within this file. * @global string $g_custom_strings_file */ -$g_custom_strings_file = $g_absolute_path . 'custom_strings_inc.php'; +$g_custom_strings_file = CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_strings_inc.php'; /** * Used to link to manual for User Documentation. diff --git a/application/core/relationship_api.php b/application/core/relationship_api.php index 6c5dfcad2e..719fe99674 100644 --- a/application/core/relationship_api.php +++ b/application/core/relationship_api.php @@ -162,8 +162,8 @@ class BugRelationshipData { '#notify_deleted' => 'email_notification_title_for_action_related_to_relationship_deleted', ); -if( file_exists( config_get_global( 'absolute_path' ) . 'custom_relationships_inc.php' ) ) { - require_once( config_get_global( 'absolute_path' ) . 'custom_relationships_inc.php' ); +if( file_exists( CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_relationships_inc.php' ) ) { + require_once( CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_relationships_inc.php' ); } /** diff --git a/doc/CUSTOMIZATION b/doc/CUSTOMIZATION index 1928a518a5..b10b907ed3 100644 --- a/doc/CUSTOMIZATION +++ b/doc/CUSTOMIZATION @@ -18,7 +18,7 @@ http://docs.mantisbt.org/ will not be overwritten when you upgrade, but config_defaults_inc.php will. Look at config_inc.php.sample for an example. -* core/*_api.php - these files contains all the API library functions. +* application/core/*_api.php - these files contains all the API library functions. * global variables are prefixed by g_ * parameters in functions are prefixed with p_ -- parameters shouldn't be modified within the function. diff --git a/doc/INSTALL b/doc/INSTALL index 040eafd29b..4e05e53ad3 100644 --- a/doc/INSTALL +++ b/doc/INSTALL @@ -18,10 +18,10 @@ INSTALLATION * Extract the tarball into a location readable by your web server - * Point your browser to http://path/to/mantisbt/admin/check.php to ensure that + * Point your browser to http://path/to/mantisbt/public/admin/check.php to ensure that your webserver is compatible with MantisBT and configured correctly - * Point your browser to http://path/to/mantisbt/admin/install.php to begin the + * Point your browser to http://path/to/mantisbt/public/admin/install.php to begin the database installation process * Select the database type and enter the credentials to access the database @@ -29,7 +29,7 @@ INSTALLATION * Click install/upgrade * Installation is complete -- you may need to copy the default configuration - to mantisbt/config_inc.php if your web server does not have write access + to mantisbt/application/configs/config_inc.php if your web server does not have write access * Remove the admin/ directory from within the MantisBT installation path. The scripts within this directory should not be accessible on a live MantisBT @@ -49,7 +49,7 @@ UPGRADING * Point your browser to http://path/to/mantisbt/admin/check.php to ensure that your webserver is compatible with MantisBT and configured correctly - * Point your browser to http://path/to/mantisbt/admin/install.php to upgrade + * Point your browser to http://path/to/mantisbt/public/admin/install.php to upgrade the database schema * Click install/upgrade diff --git a/docbook/Admin_Guide/en-US/Customizing.xml b/docbook/Admin_Guide/en-US/Customizing.xml index 0df886e94e..cb23532b50 100644 --- a/docbook/Admin_Guide/en-US/Customizing.xml +++ b/docbook/Admin_Guide/en-US/Customizing.xml @@ -290,7 +290,7 @@ issue. Add the localized string for "my_start_date" - This can be done by creating custom_strings_inc.php in the - MantisBT root folder and adding the following code to it: + MantisBT configs folder and adding the following code to it: <?php if ( lang_get_current() == 'german' ) { @@ -684,14 +684,14 @@ functions section. Define a constant to map the new status to.In a new file - custom_constants_inc.php in the main mantisbt directory: + custom_constants_inc.php in the mantisbt configs directory: <?php define ( 'TEST', 60 ); ?> Define the language strings required. This may need to be defined in several languages.In a new file custom_strings_inc.php - in the main mantisbt directory: + in the mantisbt configs directory: <?php if ( lang_get_current() == 'german' ) { $s_status_enum_string = '10:neu,20:Rückmeldung,30:anerkannt,40:bestätigt,50:zugewiesen,60:zu testen,80:behoben,90:geschlossen'; } else { @@ -706,7 +706,7 @@ functions section. Define any configurations required.In the existing file - config_inc.php in the main mantisbt directory: + config_inc.php in the mantisbt configs directory: $g_status_enum_string = '10:new,20:feedback,30:acknowledged,40:confirmed,50:assigned, 60:to be tested,80:resolved,90:closed'; # Status color additions @@ -748,7 +748,7 @@ functions section. User versions of these functions are placed in a file called custom_functions_inc.php in the - root directory of MantisBT. This is the same place that the + configs directory of MantisBT. This is the same place that the "config_inc.php" file modifying MantisBT defaults is placed. In normal processing, MantisBT will look for override functions and execute them instead of the provided default functions. diff --git a/public/admin/check/check_config_inc.php b/public/admin/check/check_config_inc.php index 1db11c861b..063fb83f1d 100644 --- a/public/admin/check/check_config_inc.php +++ b/public/admin/check/check_config_inc.php @@ -35,7 +35,7 @@ check_print_section_header_row( 'Configuration' ); check_print_test_row( 'config_inc.php configuration file exists', - file_exists( dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR . 'config_inc.php' ), + file_exists( CONFIG_PATH . DIRECTORY_SEPARATOR . 'config_inc.php' ), array( false => 'Please use install.php to perform the initial installation of MantisBT.' ) ); diff --git a/public/admin/check/check_integrity_inc.php b/public/admin/check/check_integrity_inc.php index 795d23de0d..0afc49ba28 100644 --- a/public/admin/check/check_integrity_inc.php +++ b/public/admin/check/check_integrity_inc.php @@ -148,11 +148,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_PATH . DIRECTORY_SEPARATOR . 'config_inc.php', + CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_constants_inc.php', + CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_functions_inc.php', + CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_relationships_inc.php', + CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_strings_inc.php', 'mantis_offline.php' ); check_file_integrity_recursive( $t_absolute_base_dir, $t_absolute_base_dir, '', $t_ignore_files ); diff --git a/public/core.php b/public/core.php index 2582a2befe..cdb972761e 100644 --- a/public/core.php +++ b/public/core.php @@ -65,6 +65,10 @@ defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application') ); +// Define path to configs directory +defined('CONFIG_PATH') + || define('CONFIG_PATH', APPLICATION_PATH . DIRECTORY_SEPARATOR . 'configs' ); + // Define path to languages directory defined('LANGUAGES_PATH') || define('LANGUAGES_PATH', realpath(dirname(__FILE__) . '/../languages') ); @@ -95,18 +99,18 @@ require_once( APPLICATION_PATH . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'constant_inc.php' ); # Load user-defined constants (if required) -if ( file_exists( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'custom_constants_inc.php' ) ) { - require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'custom_constants_inc.php' ); +if ( file_exists( CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_constants_inc.php' ) ) { + require_once( CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_constants_inc.php' ); } $t_config_inc_found = false; # Include default configuration settings -require_once( APPLICATION_PATH . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'config_defaults_inc.php' ); +require_once( CONFIG_PATH . DIRECTORY_SEPARATOR . 'config_defaults_inc.php' ); # config_inc may not be present if this is a new install -if ( file_exists( APPLICATION_PATH . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'config_inc.php' ) ) { - require_once( APPLICATION_PATH . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'config_inc.php' ); +if ( file_exists( CONFIG_PATH . DIRECTORY_SEPARATOR . 'config_inc.php' ) ) { + require_once( CONFIG_PATH . DIRECTORY_SEPARATOR . 'config_inc.php' ); $t_config_inc_found = true; } @@ -203,6 +207,7 @@ function __autoload( $p_class_name ) { # Ensure that output is blank so far (output at this stage generally denotes # that an error has occurred) +# that an error has occurred) if ( ( $t_output = ob_get_contents() ) != '' ) { echo 'Possible Whitespace/Error in Configuration File - Aborting. Output so far follows:
'; echo var_dump( $t_output ); @@ -279,8 +284,8 @@ function __autoload( $p_class_name ) { # Load custom functions require_api( 'custom_function_api.php' ); -if ( file_exists( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'custom_functions_inc.php' ) ) { - require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'custom_functions_inc.php' ); +if ( file_exists( CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_functions_inc.php' ) ) { + require_once( CONFIG_PATH . DIRECTORY_SEPARATOR . 'custom_functions_inc.php' ); } # Set HTTP response headers