Replacing $_configuration['access_url'] with api_get_current_access_url_id()

skala
Julio Montoya 12 years ago
parent c993416949
commit 2c914efbb6
  1. 2
      main/admin/configure_plugin.php
  2. 2
      main/admin/languages.php
  3. 15
      main/admin/settings.lib.php
  4. 20
      main/admin/settings.php
  5. 9
      main/inc/lib/api.lib.php

@ -55,7 +55,7 @@ if (isset($form)) {
array('Plugins', $access_url_id, $plugin_name, 'setting', "status")));
foreach ($values as $key => $value) {
$key = Database::escape_string($plugin_name.'_'.$key);
api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, $_configuration['access_url'], 1);
api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, api_get_current_access_url_id(), 1);
}
$message = Display::return_message(get_lang('Updated'), 'success');

@ -156,7 +156,7 @@ if ($_POST['Submit']) {
if ($_POST['platformlanguage'] && $_POST['platformlanguage'] <> '') {
//$sql_update_2 = "UPDATE $tbl_settings_current SET selected_value='{$_POST['platformlanguage']}' WHERE variable='platformLanguage'";
//$result_2 = Database::query($sql_update_2);
api_set_setting('platformLanguage', $_POST['platformlanguage'], null, null, $_configuration['access_url']);
api_set_setting('platformLanguage', $_POST['platformlanguage'], null, null, api_get_current_access_url_id());
}
} elseif (isset($_POST['action'])) {
switch ($_POST['action']) {

@ -195,10 +195,10 @@ function handle_stylesheets()
$currentStyle = api_get_setting('stylesheets');
$is_style_changeable = false;
if ($_configuration['access_url'] != 1) {
$urlId = api_get_current_access_url_id();
if ($urlId != 1) {
$style_info = api_get_settings('stylesheets', '', 1, 0);
$url_info = api_get_access_url($_configuration['access_url']);
$url_info = api_get_access_url($urlId);
if ($style_info[0]['access_url_changeable'] == 1 && $url_info['active'] == 1) {
$is_style_changeable = true;
}
@ -223,7 +223,7 @@ function handle_stylesheets()
Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable'));
} else {
// Uploading a new stylesheet.
if ($_configuration['access_url'] == 1) {
if ($urlId == 1) {
$show_upload_form = true;
} else {
if ($is_style_changeable) {
@ -573,7 +573,7 @@ function handle_search()
if ($form->validate()) {
$formvalues = $form->exportValues();
$r = api_set_settings_category('Search', 'false', $_configuration['access_url']);
$r = api_set_settings_category('Search', 'false', api_get_current_access_url_id());
// Save the settings.
foreach ($formvalues as $key => $value) {
$result = api_set_setting($key, $value, null, null);
@ -1072,6 +1072,7 @@ function update_gradebook_score_display_custom_values($values) {
function generate_settings_form($settings, $settings_by_access_list, $settings_to_avoid, $convert_byte_to_mega_list)
{
global $_configuration;
$urlId = api_get_current_access_url_id();
$table_settings_current = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category']));
@ -1123,7 +1124,7 @@ function generate_settings_form($settings, $settings_by_access_list, $settings_t
$hideme = array();
$hide_element = false;
if ($_configuration['access_url'] != 1) {
if ($urlId != 1) {
if ($row['access_url_changeable'] == 0) {
// We hide the element in other cases (checkbox, radiobutton) we 'freeze' the element.
$hide_element = true;
@ -1223,7 +1224,7 @@ function generate_settings_form($settings, $settings_by_access_list, $settings_t
$element = & $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext']));
if ($row['access_url_changeable'] == 1) {
// 2. We look into the DB if there is a setting for a specific access_url.
$access_url = $_configuration['access_url'];
$access_url = $urlId;
if (empty($access_url )) $access_url = 1;
$sql = "SELECT selected_value FROM $table_settings_current WHERE variable='".$rowkeys['variable']."' AND subkey='".$rowkeys['subkey']."' AND subkeytext='".$rowkeys['subkeytext']."' AND access_url = $access_url";
$result_access = Database::query($sql);

@ -228,26 +228,6 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
$values['allow_message_tool'] = 'true';
}
// The first step is to set all the variables that have type=checkbox of the category
// to false as the checkbox that is unchecked is not in the $_POST data and can
// therefore not be set to false.
// This, however, also means that if the process breaks on the third of five checkboxes, the others
// will be set to false.
//$r = api_set_settings_category($my_category, 'false', $_configuration['access_url'], array('checkbox', 'radio'));
//This is a more accurate way of updating to false the checkboxes and radios the settings
/*
foreach ($values as $key => $value) {
if (in_array($key, $settings_to_avoid)) { continue; }
if ($key == 'search_field' or $key == 'submit_fixed_in_bottom') { continue; }
$key = Database::escape_string($key);
$sql = "UPDATE $table_settings_current SET selected_value = 'false' WHERE variable = '".$key."' AND access_url = ".intval($url_id)." AND type IN ('checkbox', 'radio') ";
$res = Database::query($sql);
}*/
foreach ($settings as $item) {
$key = $item['variable'];
if (in_array($key, $settings_to_avoid)) {

@ -583,7 +583,8 @@ function api_get_path($path_type, $path = null) {
// To avoid that the api_get_access_url() function fails since global.inc.php also calls the api.lib.php
if ($path_type == WEB_PATH) {
if (isset($_configuration['access_url']) && $_configuration['access_url'] != 1) {
$urlId = api_get_current_access_url_id();
if (isset($urlId) && $urlId != 1) {
//we look into the DB the function api_get_access_url
$url_info = api_get_current_access_url_info();
$root_web = $url_info['active'] == 1 ? $url_info['url'] : $_configuration['root_web'];
@ -5103,7 +5104,7 @@ function api_request_uri() {
* To be used in global.inc.php only.
* @author Ivan Tcholakov, 06-NOV-2008.
*/
function api_create_include_path_setting() {
function api_create_include_path_setting($includePath) {
$include_path = ini_get('include_path');
if (!empty($include_path)) {
$include_path_array = explode(PATH_SEPARATOR, $include_path);
@ -5120,10 +5121,10 @@ function api_create_include_path_setting() {
return implode(PATH_SEPARATOR, $result);
}
// Current directory is not listed in the include_path setting, low probability is here.
return api_get_path(LIBRARY_PATH).'pear'.PATH_SEPARATOR.$include_path;
return $includePath.'/lib/pear'.PATH_SEPARATOR.$include_path;
}
// The include_path setting is empty, low probability is here.
return api_get_path(LIBRARY_PATH).'pear';
return $includePath.'/lib/pear';
}
/**

Loading…
Cancel
Save