Skip to content

Commit

Permalink
Allow config path to be set by the web server to enable multiple mant…
Browse files Browse the repository at this point in the history
…is sites with

one code base.
  • Loading branch information
Daryn Warriner authored and davidhicks committed Jul 30, 2011
1 parent 2ff312f commit 6656a47
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion application/configs/config_defaults_inc.php
Expand Up @@ -175,7 +175,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.
Expand Down
4 changes: 2 additions & 2 deletions application/core/relationship_api.php
Expand Up @@ -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' );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion doc/CUSTOMIZATION
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions doc/INSTALL
Expand Up @@ -18,18 +18,18 @@ 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

* 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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions docbook/Admin_Guide/en-US/Customizing.xml
Expand Up @@ -290,7 +290,7 @@
issue.</para></listitem>
<listitem><para>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:
<programlisting>
&lt;?php
if ( lang_get_current() == 'german' ) {
Expand Down Expand Up @@ -684,14 +684,14 @@ functions section.</para>
<orderedlist>
<listitem>
<para>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:
<programlisting>&lt;?php define ( 'TEST', 60 ); ?&gt;</programlisting>
</para>
</listitem>
<listitem>
<para>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:
<programlisting language="PHP (HTML)">&lt;?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 {
Expand All @@ -706,7 +706,7 @@ functions section.</para>
</listitem>
<listitem>
<para>Define any configurations required.In the existing file
config_inc.php in the main mantisbt directory:
config_inc.php in the mantisbt configs directory:
<programlisting>$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
Expand Down Expand Up @@ -748,7 +748,7 @@ functions section.</para>
</para>
<para>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.</para>
Expand Down
4 changes: 2 additions & 2 deletions public/admin/check/check_config_inc.php
Expand Up @@ -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 <a href="install.php">install.php</a> to perform the initial installation of MantisBT.' )
);

Expand All @@ -47,4 +47,4 @@
check_print_test_warn_row( 'Check whether log output is sent to end user',
!($g_log_destination == 'firebug' || $g_log_destination == 'page'),
array( false => 'Diagnostic output destination is currently sent to end users browser' )
);
);
10 changes: 5 additions & 5 deletions public/admin/check/check_integrity_inc.php
Expand Up @@ -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 );
Expand Down
19 changes: 12 additions & 7 deletions public/core.php
Expand Up @@ -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') );
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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:<br />';
echo var_dump( $t_output );
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6656a47

Please sign in to comment.