From 980102cf50373b4e60eba9e5fea2a54cf1c68e0c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 24 May 2012 16:09:55 +0200 Subject: [PATCH] Adding blocking or unblocking settings when using multiple URLs see BT#4201 --- main/admin/settings.lib.php | 15 +++++-- main/admin/settings.php | 42 ++++++++++++++++++- main/inc/ajax/admin.ajax.php | 14 +++++-- .../lib/formvalidator/FormValidator.class.php | 19 +++++++-- main/inc/lib/main_api.lib.php | 36 ++++++++++++++++ main/install/install.lib.php | 34 +-------------- 6 files changed, 113 insertions(+), 47 deletions(-) diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index 320a04c5b6..1ef5349d4f 100644 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -1052,8 +1052,16 @@ function generate_settings_form($settings, $settings_by_access_list) { global $_configuration, $settings_to_avoid, $convert_byte_to_mega_list; $form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category'])); + $form->addElement('hidden', 'search_field', Security::remove_XSS($_GET['search_field'])); + if ( $_configuration['multiple_access_urls'] && api_is_global_platform_admin()) { + $group = array(); + $group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll')); + $group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll')); + $form->addGroup($group, 'buttons_in_action_right'); + } + $default_values = array(); $i = 0; @@ -1064,14 +1072,13 @@ function generate_settings_form($settings, $settings_by_access_list) { if (api_is_global_platform_admin()) { if ($row['access_url_locked'] == 0) { if ($row['access_url_changeable'] == '1') { - $form->addElement('html', '
'); } else { - $form->addElement('html', '
'); } - } - + } } } diff --git a/main/admin/settings.php b/main/admin/settings.php index de2533414d..f685080a54 100644 --- a/main/admin/settings.php +++ b/main/admin/settings.php @@ -133,8 +133,46 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' $message = array(); if ($form->validate()) { - $values = $form->exportValues(); + $values = $form->exportValues(); + $mark_all = false; + $un_mark_all = false; + + if ( $_configuration['multiple_access_urls']) { + if (isset($values['buttons_in_action_right']) && isset($values['buttons_in_action_right']['mark_all'])) { + $mark_all = true; + } + + if (isset($values['buttons_in_action_right']) && isset($values['buttons_in_action_right']['unmark_all'])) { + $un_mark_all = true; + } + } + + if ($mark_all || $un_mark_all) { + if (api_is_global_platform_admin()) { + $locked_settings = api_get_locked_settings(); + foreach ($values as $key => $value) { + if (!in_array($key, $locked_settings)) { + + $changeable = 0; + if ($mark_all) { + $changeable = 1; + } + + $params = array('variable = ?' => array($key)); + $data = api_get_settings_params($params); + + if (!empty($data)) { + foreach ($data as $item) { + $params = array('id' =>$item['id'], 'access_url_changeable' => $changeable); + api_set_setting_simple($params); + } + } + } + } + } + } + $pdf_export_watermark_path = $_FILES['pdf_export_watermark_path']; if (isset($pdf_export_watermark_path) && !empty($pdf_export_watermark_path['name'])) { @@ -273,7 +311,7 @@ $htmlHeadXtra[] = '