Skip to content

Commit

Permalink
Fix #11495: Cannot move core, library and language directories
Browse files Browse the repository at this point in the history
The options $g_core_path, $g_class_path, $g_library_path and
$g_language_path could not be used properly because in various parts of
Mantis' codebase, include/require calls do not make use of these
configuration options (instead it is assumed that the default directory
structure is used).
  • Loading branch information
davidhicks committed Feb 12, 2010
1 parent 0acc410 commit 8696c44
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 27 deletions.
18 changes: 12 additions & 6 deletions config_defaults_inc.php
Expand Up @@ -177,39 +177,45 @@
* requires trailing /
* @global string $g_icon_path
*/
$g_icon_path = '%path%images/';
$g_icon_path = '%path%images/';

/**
* Short web path without the domain name
* requires trailing /
* @global string $g_short_path
*/
$g_short_path = $t_path . '/';
$g_short_path = $t_path . '/';

/**
* absolute path to your installation. Requires trailing / or \
* @global string $g_absolute_path
*/
$g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
$g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;

/**
* absolute patch to your core files. The default is usually OK,
* unless you moved the 'core' directory out of your webroot (recommended).
* @global string $g_core_path
*/
$g_core_path = $g_absolute_path . 'core' . DIRECTORY_SEPARATOR;
$g_core_path = $g_absolute_path . 'core' . DIRECTORY_SEPARATOR;

/**
* absolute path to class files. Requires trailing / or \
* @global string $g_class_path
*/
$g_class_path = $g_core_path . 'classes' . DIRECTORY_SEPARATOR;
$g_class_path = $g_core_path . 'classes' . DIRECTORY_SEPARATOR;

/**
* absolute path to library files. Requires trailing / or \
* @global string $g_library_path
*/
$g_library_path = $g_absolute_path . 'library' . DIRECTORY_SEPARATOR;
$g_library_path = $g_absolute_path . 'library' . DIRECTORY_SEPARATOR;

/**
* absolute path to language files. Requires trailing / or \
* @global string $g_language_path
*/
$g_language_path = $g_absolute_path . 'lang' . DIRECTORY_SEPARATOR;

/**
* Used to link to manual for User Documentation.
Expand Down
1 change: 1 addition & 0 deletions core.php
Expand Up @@ -156,6 +156,7 @@ function __autoload( $className ) {
spl_autoload_register( '__autoload' );

# Load UTF8-capable string functions
define( 'UTF8', $g_library_path . 'utf8' );
require_lib( 'utf8/utf8.php' );
require_lib( 'utf8/str_pad.php' );

Expand Down
2 changes: 2 additions & 0 deletions core/config_api.php
Expand Up @@ -599,6 +599,8 @@ function config_is_private( $p_config_var ) {
case 'absolute_path':
case 'core_path':
case 'class_path':
case 'library_path':
case 'language_path':
case 'use_iis':
case 'session_save_path':
case 'session_handler':
Expand Down
2 changes: 1 addition & 1 deletion core/custom_field_api.php
Expand Up @@ -70,7 +70,7 @@
$g_custom_field_types[CUSTOM_FIELD_TYPE_DATE] = 'standard';

foreach( $g_custom_field_types as $type ) {
require_once( 'cfdefs' . DIRECTORY_SEPARATOR . 'cfdef_' . $type . '.php' );
require_once( config_get_global( 'core_path' ) . 'cfdefs' . DIRECTORY_SEPARATOR . 'cfdef_' . $type . '.php' );
}

function custom_field_allow_manage_display( $p_type, $p_display ) {
Expand Down
2 changes: 2 additions & 0 deletions core/database_api.php
Expand Up @@ -36,6 +36,8 @@
require_api( 'error_api.php' );
require_api( 'logging_api.php' );
require_api( 'utility_api.php' );

define( 'ADODB_DIR', config_get( 'library_path' ) . 'adodb' );
require_lib( 'adodb' . DIRECTORY_SEPARATOR . 'adodb.inc.php' );

/**
Expand Down
13 changes: 5 additions & 8 deletions core/lang_api.php
Expand Up @@ -66,20 +66,17 @@ function lang_load( $p_lang, $p_dir = null ) {
return;
}

$t_lang_dir = $p_dir;

if( is_null( $t_lang_dir ) ) {
$t_lang_dir = dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR;
include_once( $t_lang_dir . 'strings_' . $p_lang . '.txt' );
if( $p_dir === null ) {
include_once( config_get( 'language_path' ) . 'strings_' . $p_lang . '.txt' );
} else {
if( is_file( $t_lang_dir . 'strings_' . $p_lang . '.txt' ) ) {
include_once( $t_lang_dir . 'strings_' . $p_lang . '.txt' );
if( is_file( $p_dir . 'strings_' . $p_lang . '.txt' ) ) {
include_once( $p_dir . 'strings_' . $p_lang . '.txt' );
}
}

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

Expand Down
4 changes: 2 additions & 2 deletions core/relationship_api.php
Expand Up @@ -160,8 +160,8 @@ class BugRelationshipData {
'#notify_deleted' => 'email_notification_title_for_action_related_to_relationship_deleted',
);

if( file_exists( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'custom_relationships_inc.php' ) ) {
require_once( dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'custom_relationships_inc.php' );
if( file_exists( config_get_global( 'absolute_path' ) . 'custom_relationships_inc.php' ) ) {
require_once( config_get_global( 'absolute_path' ) . 'custom_relationships_inc.php' );
}

/**
Expand Down
26 changes: 23 additions & 3 deletions docbook/adminguide/en/configuration.sgml
Expand Up @@ -109,9 +109,9 @@
<term>$g_core_path</term>
<listitem>
<para>This is the path to the core directory of your installation.
The default value is usually OK, unless you move the 'core'
directory out of your webroot. Requires trailing DIRECTORY_SEPARATOR.
character.
The default value is usually OK but it is recommended
that you move the 'core' directory out of your webroot.
Requires trailing DIRECTORY_SEPARATOR character.
</para>
</listitem>
</varlistentry>
Expand All @@ -124,6 +124,26 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_library_path</term>
<listitem>
<para>This is the path to the library directory of your installation.
The default value is usually OK but it is recommended
that you move the 'library' directory out of your webroot.
Requires trailing DIRECTORY_SEPARATOR character.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_language_path</term>
<listitem>
<para>This is the path to the language directory of your installation.
The default value is usually OK but it is recommended
that you move the 'language' directory out of your webroot.
Requires trailing DIRECTORY_SEPARATOR character.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_manual_url</term>
<listitem>
Expand Down
14 changes: 7 additions & 7 deletions plugins/MantisGraph/core/graph_api.php
Expand Up @@ -39,15 +39,15 @@
require_once( 'jpgraph_pie3d.php' );
require_once( 'jpgraph_canvas.php' );
} else {
require_once( 'jpgraph/jpgraph.php' );
require_once( 'jpgraph/jpgraph_line.php' );
require_once( 'jpgraph/jpgraph_bar.php' );
require_once( 'jpgraph/jpgraph_pie.php' );
require_once( 'jpgraph/jpgraph_pie3d.php' );
require_once( 'jpgraph/jpgraph_canvas.php' );
require_lib( 'jpgraph/jpgraph.php' );
require_lib( 'jpgraph/jpgraph_line.php' );
require_lib( 'jpgraph/jpgraph_bar.php' );
require_lib( 'jpgraph/jpgraph_pie.php' );
require_lib( 'jpgraph/jpgraph_pie3d.php' );
require_lib( 'jpgraph/jpgraph_canvas.php' );
}
} else {
require_once( 'ezc/Base/src/base.php' );
require_lib( 'ezc/Base/src/base.php' );
}

function graph_get_font() {
Expand Down

0 comments on commit 8696c44

Please sign in to comment.