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

skala
Julio Montoya 12 years ago
parent c993416949
commit 2c914efbb6
  1. 4
      main/admin/configure_plugin.php
  2. 30
      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');
@ -66,4 +66,4 @@ $tpl = $app['template'];
$tpl->assign('actions', $actions);
$tpl->assign('message', $message);
$tpl->assign('content', $content);
$tpl->display_one_col_template();
$tpl->display_one_col_template();

@ -32,7 +32,7 @@ api_protect_admin_script();
//Ajax request
if (isset($_POST['sent_http_request'])) {
if (isset($_POST['visibility']) && $_POST['visibility'] == strval(intval($_POST['visibility'])) && $_POST['visibility'] == 0) {
if (isset($_POST['id']) && $_POST['id'] == strval(intval($_POST['id']))) {
if (isset($_POST['id']) && $_POST['id'] == strval(intval($_POST['id']))) {
if (SubLanguageManager::check_if_language_is_used($_POST['id']) == false) {
SubLanguageManager::make_unavailable_language($_POST['id']);
echo 'set_hidden';
@ -88,9 +88,9 @@ $htmlHeadXtra[] = '<script>
url: "../admin/languages.php",
data: "id="+link_id+"&visibility="+my_visibility+"&sent_http_request=1",
success: function(datos) {
if (datos=="set_visible" || datos=="set_hidden") {
$("#"+id_img_link_tool).attr("src",path_name_of_imglinktool);
$("#"+id_img_link_tool).attr("src",path_name_of_imglinktool);
if (my_image_tool=="visible.png") {
$("#"+id_img_link_tool).attr("alt","' . get_lang('MakeAvailable', '') . '");
@ -108,8 +108,8 @@ $htmlHeadXtra[] = '<script>
$("#id_content_message").html("<div class=\"confirmation-message\">' . get_lang('LanguageIsNowHidden', '') . '</div>");
}
}
var action = datos.split(":")[0];
var action = datos.split(":")[0];
if (action && action == "confirm") {
var id = datos.split(":")[1];
var sure = "<div class=\"warning-message\">'.get_lang('ThereAreUsersUsingThisLanguageYouWantToDisableThisLanguageAndSetUsersWithTheDefaultPortalLanguage').'</div><a href=\"languages.php?action=make_unavailable_confirmed&id="+id+"\" class=\"btn\">' . get_lang('MakeUnavailable') . '</a>";
@ -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']) {
@ -197,11 +197,11 @@ $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdm
// including the header file (which includes the banner itself)
Display :: display_header($tool_name);
if (isset($_GET['action']) && $_GET['action'] == 'make_unavailable_confirmed') {
if (isset($_GET['action']) && $_GET['action'] == 'make_unavailable_confirmed') {
$language_info = SubLanguageManager::get_all_information_of_language($_GET['id']);
if ($language_info['available'] == 1) {
SubLanguageManager::make_unavailable_language($_GET['id']);
SubLanguageManager::make_unavailable_language($_GET['id']);
$platform_language = api_get_setting('platformLanguage');
UserManager::update_all_user_languages($language_info['english_name'], $platform_language);
Display::display_confirmation_message(get_lang('LanguageIsNowHidden'));
@ -242,19 +242,19 @@ while ($row = Database::fetch_array($result_select)) {
} else {
$row_td[] = $row['original_name'];
}
// the second column
$row_td[] = $row['english_name'];
// the third column
$row_td[] = $row['dokeos_folder'];
if ($row['english_name'] == $row_lang['selected_value']) {
$setplatformlanguage = Display::return_icon('languages.png', get_lang('CurrentLanguagesPortal'), '', ICON_SIZE_SMALL);
} else {
$setplatformlanguage = "<a href=\"javascript:if (confirm('" . addslashes(get_lang('AreYouSureYouWantToSetThisLanguageAsThePortalDefault')) . "')) { location.href='" . api_get_self() . "?action=setplatformlanguage&id=" . $row['id'] . "'; }\">" . Display::return_icon('languages_na.png', get_lang('SetLanguageAsDefault'), '', ICON_SIZE_SMALL) . "</a>";
}
if (api_get_setting('allow_use_sub_language') == 'true') {
$verified_if_is_sub_language = SubLanguageManager::check_if_language_is_sub_language($row['id']);
@ -278,10 +278,10 @@ while ($row = Database::fetch_array($result_select)) {
$allow_use_sub_language = '';
$allow_add_term_sub_language = '';
}
if ($row['english_name'] == $row_lang['selected_value']) {
$row_td[] = Display::return_icon('visible.png', get_lang('Visible'))."<a href='" . api_get_self() . "?action=edit&id=" . $row['id'] . "#value'>" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>
&nbsp;" . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;
&nbsp;" . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;
} else {
if ($row['available'] == 1) {
$row_td[] = "<a class=\"make_visible_and_invisible\" id=\"linktool_" . $row['id'] . "\" href='" . api_get_self() . "?action=makeunavailable&id=" . $row['id'] . "'>" . Display::return_icon('visible.png', get_lang('MakeUnavailable'), array('id' => 'imglinktool_' . $row['id']), ICON_SIZE_SMALL) . "</a> <a href='" . api_get_self() . "?action=edit&id=" . $row['id'] . "#value'>" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>&nbsp;" . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language;

@ -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