Skip to content

Commit

Permalink
Fixes #16850: Add config folder for customization files
Browse files Browse the repository at this point in the history
  • Loading branch information
vboctor committed Apr 13, 2014
1 parent 3c23897 commit 9891792
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 115 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions admin/check/check_integrity_inc.php
Original file line number Diff line number Diff line change
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
12 changes: 6 additions & 6 deletions admin/install.php
Original file line number Diff line number Diff line change
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_absolute_path . 'config/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 @@ -1023,7 +1023,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_absolute_path . 'config/config_inc.php';
$t_config_exists = file_exists( $t_config_filename );
?>
<table width="100%" cellpadding="10" cellspacing="1">
Expand All @@ -1038,14 +1038,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 +1109,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_absolute_path . 'config/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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,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
55 changes: 0 additions & 55 deletions api/soap/mc_config_defaults_inc.php

This file was deleted.

5 changes: 5 additions & 0 deletions api/soap/mc_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* @link http://www.mantisbt.org
*/

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

# MantisConnect APIs
# mc_* = public methods
# mci_* = internal methods
Expand All @@ -31,3 +34,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 );
3 changes: 3 additions & 0 deletions config/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## no access to this folder
order allow,deny
deny from all
File renamed without changes.
56 changes: 51 additions & 5 deletions config_defaults_inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Default Configuration Variables
*
* This file should not be changed. If you want to override any of the values
* defined here, define them in a file called config_inc.php, which will
* defined here, define them in a file called config/config_inc.php, which will
* be loaded after this file.
*
* In general a value of OFF means the feature is disabled and ON means the
Expand Down Expand Up @@ -134,7 +134,7 @@
}

if ( !isset( $_SERVER['SCRIPT_NAME'] )) {
echo 'Invalid server configuration detected. Please set $g_path manually in config_inc.php.';
echo 'Invalid server configuration detected. Please set $g_path manually in config/config_inc.php.';
if ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ( stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false ) )
echo ' Please try to add "fastcgi_param SCRIPT_NAME $fastcgi_script_name;" to the nginx server configuration.';
die;
Expand All @@ -154,7 +154,7 @@
break;
}
if( strpos( $t_path, '&#' ) ) {
echo 'Can not safely determine $g_path. Please set $g_path manually in config_inc.php';
echo 'Can not safely determine $g_path. Please set $g_path manually in config/config_inc.php';
die;
}
} else {
Expand Down Expand Up @@ -2021,7 +2021,7 @@
* 2-dimensional matrix. For each existing status, you define which
* statuses you can go to from that status, e.g. from NEW_ you might list statuses
* '10:new,20:feedback,30:acknowledged' but not higher ones.
* The following example can be transferred to config_inc.php
* The following example can be transferred to config/config_inc.php
* $g_status_enum_workflow[NEW_]='20:feedback,30:acknowledged,40:confirmed,50:assigned,80:resolved';
* $g_status_enum_workflow[FEEDBACK] ='10:new,30:acknowledged,40:confirmed,50:assigned,80:resolved';
* $g_status_enum_workflow[ACKNOWLEDGED] ='20:feedback,40:confirmed,50:assigned,80:resolved';
Expand Down Expand Up @@ -4074,7 +4074,7 @@
* another value will cause program execution to continue, which may lead to
* data integrity issues and/or cause MantisBT to function incorrectly.
*
* A developer might set this in config_inc.php as:
* A developer might set this in config/config_inc.php as:
* $g_display_errors = array(
* E_WARNING => DISPLAY_ERROR_HALT,
* E_NOTICE => DISPLAY_ERROR_INLINE,
Expand Down Expand Up @@ -4210,3 +4210,49 @@

# Temporary variables should not remain defined in global scope
unset( $t_protocol, $t_host, $t_hosts, $t_port, $t_self, $t_path );


/************
* SOAP API *
************/

# Minimum global access level required to access webservice for readonly operations.
$g_mc_readonly_access_level_threshold = REPORTER;

# Minimum global access level required to access webservice for read/write operations.
$g_mc_readwrite_access_level_threshold = REPORTER;

# Minimum global access level required to access the administrator webservices
$g_mc_admin_access_level_threshold = MANAGER;

# Minimum project access level required to be able to specify a reporter name when
# adding an issue. Otherwise, the current user is used as the reporter. Users
# who don't have this access level can always do another step to modify the issue
# and specify a different name, but in this case it will be logged in the history
# who original reported the issue.
$g_mc_specify_reporter_on_add_access_level_threshold = DEVELOPER;

# The following enum ids are used when the webservices get enum labels that are not
# defined in the associated MantisBT installation. In this case, the enum id is set
# to the value specified by the corresponding configuration option.
$g_mc_priority_enum_default_when_not_found = 0;
$g_mc_severity_enum_default_when_not_found = 0;
$g_mc_status_enum_default_when_not_found = 0;
$g_mc_resolution_enum_default_when_not_found = 0;
$g_mc_projection_enum_default_when_not_found = 0;
$g_mc_eta_enum_default_when_not_found = 0;

# If ON and the supplied category is not found, then a SoapException will be raised.
# (at the moment this value does not depend on the project).
$g_mc_error_when_category_not_found = ON;

# Default category to be used if the specified category is not found and $g_mc_error_when_category_not_found == OFF.
$g_mc_category_when_not_found = '';

# If ON and the supplied version is not found, then a SoapException will be raised.
$g_mc_error_when_version_not_found = ON;

# Default version to be used if the specified version is not found and $g_mc_error_when_version_not_found == OFF.
# (at the moment this value does not depend on the project).
$g_mc_version_when_not_found = '';

34 changes: 21 additions & 13 deletions core.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,13 @@
require_once( dirname( __FILE__ ) . 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' );
}

$t_config_inc_found = false;
require_config( 'custom_constants_inc.php' );

# Include default configuration settings
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'config_defaults_inc.php' );

# config_inc may not be present if this is a new install
if ( file_exists( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'config_inc.php' ) ) {
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'config_inc.php' );
$t_config_inc_found = true;
}
$t_config_inc_found = require_config( 'config_inc.php' );

# Allow an environment variable (defined in an Apache vhost for example)
# to specify a config file to load to override other local settings
Expand Down Expand Up @@ -118,6 +111,23 @@ function require_api( $p_api_name ) {
}
}

/**
* Include the specific config file, if exists.
* @param $p_file_name The file name to include (e.g. custom_strings_inc.php).
* @return true found, false not found.
*/
function require_config( $p_file_name ) {
$t_config_folder = dirname( dirname( __FILE__ ) ) . '/config/';
$t_custom_inc = $t_config_folder . $p_file_name;

if ( file_exists( $t_custom_inc ) ) {
require_once( $t_custom_inc );
return true;
}

return false;
}

# Remember (globally) which library files have already been loaded
$g_libraries_included = array();

Expand Down Expand Up @@ -232,7 +242,7 @@ function __autoload( $className ) {
# they can complete installation and configuration of MantisBT
if ( false === $t_config_inc_found ) {
if( php_sapi_name() == 'cli' ) {
echo "Error: config_inc.php file not found; ensure MantisBT is properly setup.\n";
echo "Error: config/config_inc.php file not found; ensure MantisBT is properly setup.\n";
exit(1);
}

Expand Down Expand Up @@ -312,9 +322,7 @@ function __autoload( $className ) {

# 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' );
}
require_config( 'custom_functions_inc.php' );

# Set HTTP response headers
require_api( 'http_api.php' );
Expand Down
7 changes: 1 addition & 6 deletions core/lang_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,7 @@ function lang_load( $p_lang, $p_dir = null ) {

# Allow overriding strings declared in the language file.
# custom_strings_inc.php can use $g_active_language
$t_custom_strings = config_get( 'absolute_path' ) . 'custom_strings_inc.php';
if( file_exists( $t_custom_strings ) ) {
require( $t_custom_strings );

# this may be loaded multiple times, once per language
}
require_config( 'custom_strings_inc.php' );

$t_vars = get_defined_vars();

Expand Down
4 changes: 1 addition & 3 deletions core/relationship_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ 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' );
}
require_config( 'custom_relationships_inc.php' );

/**
* Return the complementary type of the provided relationship
Expand Down
4 changes: 2 additions & 2 deletions docbook/Admin_Guide/en-US/Configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3831,7 +3831,7 @@ LOG_ALL &amp; ~LOG_DATABASE
<para>MantisBT exposes a SOAP API which allows remote clients to interact with MantisBT and perform many of the usual tasks, such as reporting issues, running filtered searches and retrieving attachments. The SOAP API is enabled by default and available at <literal>/api/soap/mantisconnect.php</literal> below your installation root.</para>
<para>A WSDL file which describes the web service is available at <literal>/api/soap/mantisconnect.php?wsdl</literal> below your installation root.</para>

<para>The following options are used to control the behaviour of the MantisBT SOAP API and are usually configured in <literal>api/soap/mc_config_inc.php</literal>.</para>
<para>The following options are used to control the behaviour of the MantisBT SOAP API:</para>
<variablelist>
<varlistentry>
<term>$g_mc_readonly_access_level_threshold</term>
Expand All @@ -3855,7 +3855,7 @@ LOG_ALL &amp; ~LOG_DATABASE

<section id="admin.config.soap.disable">
<title>Disabling the SOAP API</title>
<para>If you wish to temporarily disable the SOAP API it is sufficient to set the specific access thresholds to NOBODY in <literal>api/soap/mc_config_inc.php</literal>:</para>
<para>If you wish to temporarily disable the SOAP API it is sufficient to set the specific access thresholds to NOBODY:</para>
<para><literal>$g_mc_readonly_access_level_threshold = $g_mc_readwrite_access_level_threshold = $g_mc_admin_access_level_threshold = NOBODY;</literal></para>
<para>While the SOAP API will still be accessible, it will not allow users to retrieve or modify data.</para>
</section>
Expand Down
Loading

0 comments on commit 9891792

Please sign in to comment.