Skip to content

Commit

Permalink
Rearrange core.php to load plugins much sooner.
Browse files Browse the repository at this point in the history
First step toward authentication and wiki integration plugins.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4972 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
amyreese committed Feb 8, 2008
1 parent 1477f1d commit 1623ce6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
46 changes: 25 additions & 21 deletions core.php
Expand Up @@ -118,10 +118,34 @@ function microtime_float() {
require_once( $t_core_path.'lang_api.php' );

# error functions should be loaded to allow database to print errors
require_once( $t_core_path.'error_api.php' );
require_once( $t_core_path.'helper_api.php' );

# DATABASE WILL BE OPENED HERE!! THE DATABASE SHOULDN'T BE EXPLICITLY
# OPENED ANYWHERE ELSE.
require_once( $t_core_path.'database_api.php' );

# Initialize Event System
require_once( $t_core_path.'event_api.php' );
require_once( $t_core_path.'events_inc.php' );

# Plugin initialization
require_once( $t_core_path.'plugin_api.php' );
if ( !defined( 'PLUGINS_DISABLED' ) ) {
plugin_init_installed();
}

# Authentication and user setup
require_once( $t_core_path.'authentication_api.php' );
require_once( $t_core_path.'project_api.php' );
require_once( $t_core_path.'project_hierarchy_api.php' );
require_once( $t_core_path.'user_api.php' );
require_once( $t_core_path.'access_api.php' );

# Display API's
require_once( $t_core_path.'html_api.php' );
require_once( $t_core_path.'error_api.php' );
require_once( $t_core_path.'gpc_api.php' );
require_once( $t_core_path.'print_api.php' );

# custom functions (in main directory)
# @@@ Move all such files to core/
Expand All @@ -138,10 +162,6 @@ function microtime_float() {
list( $usec, $sec ) = explode( ' ', microtime() );
mt_srand( $sec*$usec );

# DATABASE WILL BE OPENED HERE!! THE DATABASE SHOULDN'T BE EXPLICITLY
# OPENED ANYWHERE ELSE.
require_once( $t_core_path.'database_api.php' );

# Headers to prevent caching
# with option to bypass if running from script
global $g_bypass_headers, $g_allow_browser_cache;
Expand All @@ -159,27 +179,11 @@ function microtime_float() {
}
}

# Initialize Event System
require_once( $t_core_path.'event_api.php' );
require_once( $t_core_path.'events_inc.php' );

require_once( $t_core_path.'project_api.php' );
require_once( $t_core_path.'project_hierarchy_api.php' );
require_once( $t_core_path.'access_api.php' );
require_once( $t_core_path.'print_api.php' );
require_once( $t_core_path.'helper_api.php' );
require_once( $t_core_path.'user_api.php' );

# push push default language to speed calls to lang_get
lang_push( lang_get_default() );

if ( !isset( $g_bypass_headers ) && !headers_sent() ) {
header( 'Content-type: text/html;charset=' . lang_get( 'charset' ) );
}

# Plugin initialization
require_once( $t_core_path.'plugin_api.php' );
if ( !defined( 'PLUGINS_DISABLED' ) ) {
plugin_init_installed();
}
?>
4 changes: 2 additions & 2 deletions core/lang_api.php
Expand Up @@ -81,13 +81,13 @@ function lang_get_default() {
$t_lang = false;

# Confirm that the user's language can be determined
if ( auth_is_user_authenticated() ) {
if ( function_exists('auth_is_user_authenticated' ) && auth_is_user_authenticated() ) {
$t_lang = user_pref_get_language( auth_get_current_user_id() );
}

# Otherwise fall back to default
if ( false === $t_lang ) {
$t_lang = config_get( 'default_language' );
$t_lang = config_get_global( 'default_language' );
}

if ( 'auto' == $t_lang ) {
Expand Down

0 comments on commit 1623ce6

Please sign in to comment.