Feature #347 - Some quick tricks for better performance.

skala
Ivan Tcholakov 15 years ago
parent 694a8d3e9b
commit 521918e122
  1. 24
      main/inc/global.inc.php
  2. 11
      main/inc/lib/main_api.lib.php

@ -163,7 +163,7 @@ if (!empty($_configuration['multiple_access_urls'])) {
$request_url1 = $protocol.$_SERVER['SERVER_NAME'].'/';
$request_url2 = $protocol.$_SERVER['HTTP_HOST'].'/';
foreach ($access_urls as $details) {
foreach ($access_urls as & $details) {
if ($request_url1 == $details['url'] or $request_url2 == $details['url']) {
$_configuration['access_url'] = $details['id'];
}
@ -176,8 +176,8 @@ if (!empty($_configuration['multiple_access_urls'])) {
if ($_configuration['access_url'] != 1) {
$url_info = api_get_access_url($_configuration['access_url']);
if ($url_info['active'] == 1) {
$settings_by_access = api_get_settings(null, 'list', $_configuration['access_url'], 1);
foreach ($settings_by_access as $row) {
$settings_by_access = & api_get_settings(null, 'list', $_configuration['access_url'], 1);
foreach ($settings_by_access as & $row) {
if (empty($row['variable'])) {
$row['variable'] = 0;
}
@ -192,8 +192,8 @@ if ($_configuration['access_url'] != 1) {
}
}
$result = api_get_settings(null, 'list', 1);
foreach ($result as $row) {
$result = & api_get_settings(null, 'list', 1);
foreach ($result as & $row) {
if ($_configuration['access_url'] != 1) {
if ($url_info['active'] == 1) {
$var = empty($row['variable']) ? 0 : $row['variable'];
@ -204,7 +204,7 @@ foreach ($result as $row) {
if ($row['access_url_changeable'] == 1 && $url_info['active'] == 1) {
if ($settings_by_access_list[$var][$subkey][$category]['selected_value'] != '') {
if ($row['subkey'] == null) {
$_setting[$row['variable']]= $settings_by_access_list[$var][$subkey][$category]['selected_value'];
$_setting[$row['variable']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
} else {
$_setting[$row['variable']][$row['subkey']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
}
@ -231,10 +231,10 @@ foreach ($result as $row) {
}
}
$result = api_get_settings('Plugins', 'list', $_configuration['access_url']);
$result = & api_get_settings('Plugins', 'list', $_configuration['access_url']);
$_plugins = array();
foreach ($result as $row) {
$key = $row['variable'];
foreach ($result as & $row) {
$key = & $row['variable'];
if (is_string($_setting[$key])) {
$_setting[$key] = array();
}
@ -350,8 +350,8 @@ if (!empty($_POST['language_list'])) {
}
// Include all files (first english and then current interface language)
$langpath = api_get_path(SYS_CODE_PATH).'lang/';
$langpath = api_get_path(SYS_LANG_PATH);
/* This will only work if we are in the page to edit a sub_language */
if (api_get_self() == api_get_path(REL_PATH).'main/admin/sub_language.php' || api_get_self() == api_get_path(REL_PATH).'main/admin/sub_language_ajax.inc.php') {
@ -407,9 +407,10 @@ if (api_get_self() == api_get_path(REL_PATH).'main/admin/sub_language.php' || ap
}
// Checking if we have a valid language. If not we set it to the platform language.
$valid_languages = api_get_languages();
if(!empty($valid_languages)) {
if (!empty($valid_languages)) {
if (!in_array($user_language, $valid_languages['folder'])) {
$user_language = api_get_setting('platformLanguage');
@ -437,6 +438,7 @@ if(!empty($valid_languages)) {
$language_interface = $_course['language'];
}
}
// Sometimes the variable $language_interface is changed
// temporarily for achieving translation in different language.
// We need to save the genuine value of this variable and

@ -3344,10 +3344,9 @@ function api_add_access_url($u, $d = '', $a = 1) {
* @param int Access URL's ID. Optional. Uses 1 by default, which is the unique URL
* @return array Array of database results for the current settings of the current access URL
*/
function api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url_changeable = 0) {
function & api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url_changeable = 0) {
$t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$access_url = (int) $access_url;
$url_changeable_where = '';
if ($url_changeable == 1) {
$url_changeable_where= " AND access_url_changeable= '1' ";
@ -3364,8 +3363,7 @@ function api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url
} else {
$sql .= " ORDER BY 1,2 ASC";
}
$res = Database::query($sql, __FILE__, __LINE__);
return Database::store_result($res);
return Database::store_result(Database::query($sql, __FILE__, __LINE__));
}
/**
@ -3374,7 +3372,7 @@ function api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $url
* @param int Access URL. Optional. Defaults to 1
* @return array A list of categories
*/
function api_get_settings_categories($exceptions = array(), $access_url = 1) {
function & api_get_settings_categories($exceptions = array(), $access_url = 1) {
$access_url = (int) $access_url;
$t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$list = "'".implode("','",$exceptions)."'";
@ -3382,8 +3380,7 @@ function api_get_settings_categories($exceptions = array(), $access_url = 1) {
if ($list != "'',''" and $list != "''" and !empty($list)) {
$sql .= " WHERE category NOT IN ($list)";
}
$r = Database::query($sql, __FILE__, __LINE__);
return Database::store_result($r);
return Database::store_result(Database::query($sql, __FILE__, __LINE__));
}
/**

Loading…
Cancel
Save