Skip to content

Commit

Permalink
General BUG cleanup to decrease time to save globals: (openemr#212)
Browse files Browse the repository at this point in the history
* General BUG cleanup to decrease time to save globals:

- Added missing $ to variables
- Added array_key_exists to check arrays prior to attempted access
- Removed trailing whitespace

* Simplified boolean conditionals.
  • Loading branch information
samlikins authored and bradymiller committed Sep 3, 2016
1 parent f096997 commit 6ce645a
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 118 deletions.
34 changes: 17 additions & 17 deletions interface/globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function undoMagicQuotes($array, $topLevel=true) {
$webserver_root = dirname(dirname(__FILE__));
if (IS_WINDOWS) {
//convert windows path separators
$webserver_root = str_replace("\\","/",$webserver_root);
$webserver_root = str_replace("\\","/",$webserver_root);
}
// Collect the apache server document root (and convert to windows slashes, if needed)
$server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
Expand Down Expand Up @@ -121,7 +121,7 @@ function undoMagicQuotes($array, $topLevel=true) {
// to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
// then set to iso-8859-1.
require_once(dirname(__FILE__) . "/../library/sqlconf.php");
if (!$disable_utf8_flag) {
if (!$disable_utf8_flag) {
ini_set('default_charset', 'utf-8');
$HTML_CHARSET = "UTF-8";
mb_internal_encoding('UTF-8');
Expand Down Expand Up @@ -155,7 +155,7 @@ function undoMagicQuotes($array, $topLevel=true) {
// Location of the login screen file
$GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";

// Variable set for Eligibility Verification [EDI-271] path
// Variable set for Eligibility Verification [EDI-271] path
$GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";

// Include the translation engine. This will also call sql.inc to
Expand Down Expand Up @@ -226,7 +226,7 @@ function undoMagicQuotes($array, $topLevel=true) {
$GLOBALS['language_menu_show'] = array();
$glres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals " .
"ORDER BY gl_name, gl_index");
while ($glrow = sqlFetchArray($glres)) {
while ($glrow = sqlFetchArray($glres)) {
$gl_name = $glrow['gl_name'];
$gl_value = $glrow['gl_value'];
// Adjust for user specific settings
Expand All @@ -237,7 +237,7 @@ function undoMagicQuotes($array, $topLevel=true) {
}
}
}
if ($gl_name == 'language_menu_other') {
if ($gl_name == 'language_menu_other') {
$GLOBALS['language_menu_show'][] = $gl_value;
}
else if ($gl_name == 'css_header') {
Expand Down Expand Up @@ -265,36 +265,36 @@ function undoMagicQuotes($array, $topLevel=true) {
if ((count($GLOBALS['language_menu_show']) >= 1) || $GLOBALS['language_menu_showall']) {
$GLOBALS['language_menu_login'] = true;
}


// Additional logic to override theme name.
// For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
$rtl_override = false;
if( isset( $_SESSION['language_direction'] )) {
if( $_SESSION['language_direction'] == 'rtl' &&
if( $_SESSION['language_direction'] == 'rtl' &&
!strpos($GLOBALS['css_header'], 'rtl') ) {

// the $css_header_value is set above
$rtl_override = true;
}
}
else {
}

else {
//$_SESSION['language_direction'] is not set, so will use the default language
$default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?',array($GLOBALS['language_default']));

if ( getLanguageDir( $default_lang_id['lang_id'] ) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) { // @todo eliminate 1 SQL query
$rtl_override = true;
}
}


// change theme name, if the override file exists.
if( $rtl_override ) {
// the $css_header_value is set above
$new_theme = 'rtl_' . $temp_css_theme_name;

// Check file existance
// Check file existance
if( file_exists( $include_root.'/themes/'.$new_theme ) ) {
$GLOBALS['css_header'] = $rootdir.'/themes/'.$new_theme;
} else {
Expand All @@ -304,7 +304,7 @@ function undoMagicQuotes($array, $topLevel=true) {
}
unset( $temp_css_theme_name, $new_theme,$rtl_override);
// end of RTL section

//
// End of globals table processing.
}
Expand Down Expand Up @@ -408,10 +408,10 @@ function undoMagicQuotes($array, $topLevel=true) {

// 1 = send email message to given id for Emergency Login user activation,
// else 0.
$GLOBALS['Emergency_Login_email'] = $GLOBALS['Emergency_Login_email_id'] ? 1 : 0;
$GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;

//set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
//Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
//Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
//functions, tables for de-identification(Mysql root user and password is required for successful
//execution of the de-identification upgrade script)
$GLOBALS['include_de_identification']=0;
Expand Down
Loading

0 comments on commit 6ce645a

Please sign in to comment.