Fixing "-1" value in the database when saving regions

skala
Julio Montoya 13 years ago
parent 45c67ac59a
commit 1d3a977e17
  1. 21
      main/admin/settings.lib.php
  2. 11
      main/inc/lib/display.lib.php
  3. 3
      main/inc/lib/main_api.lib.php

@ -70,15 +70,14 @@ function handle_regions() {
echo '<p>'.$plugin_info['comment'].'</p>';
echo '</td><td>';
$selected_plugins = $plugin_obj->get_areas_by_plugin($plugin);
echo Display::select('plugin_'.$plugin.'[]', $plugin_list, $selected_plugins, array('multiple' => 'multiple', 'style' => 'width:500px'));
echo Display::select('plugin_'.$plugin.'[]', $plugin_list, $selected_plugins, array('multiple' => 'multiple', 'style' => 'width:500px'), true, get_lang('None'));
echo '</td></tr>';
}
}
echo '</table>';
echo '<br />';
echo '<button class="save" type="submit" name="submit_plugins">'.get_lang('EnablePlugins').'</button></form>';
echo '<br />';
echo '<br />';
}
function handle_extensions() {
@ -420,10 +419,14 @@ function store_regions() {
foreach ($plugin_list as $plugin) {
if (isset($_POST['plugin_'.$plugin])) {
$areas_to_installed = $_POST['plugin_'.$plugin];
$plugin_obj->remove_all_regions($plugin);
foreach ($areas_to_installed as $region) {
$plugin_obj->add_to_region($plugin, $region);
$areas_to_installed = $_POST['plugin_'.$plugin];
if (!empty($areas_to_installed)) {
$plugin_obj->remove_all_regions($plugin);
foreach ($areas_to_installed as $region) {
if (!empty($region) && $region != '-1' ) {
$plugin_obj->add_to_region($plugin, $region);
}
}
}
}
}
@ -457,11 +460,9 @@ function store_plugins() {
}
foreach ($remove_plugins as $plugin) {
$plugin_obj->uninstall($plugin);
}
}
}
/**
* This function allows the platform admin to choose which should be the default stylesheet
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University

@ -698,7 +698,7 @@ class Display {
* Displays an HTML select tag
*
*/
public function select($name, $values, $default = -1, $extra_attributes = array(), $show_blank_item = true) {
public function select($name, $values, $default = -1, $extra_attributes = array(), $show_blank_item = true, $blank_item_text = null) {
$html = '';
$extra = '';
$default_id = 'id="'.$name.'" ';
@ -710,8 +710,13 @@ class Display {
}
$html .= '<select name="'.$name.'" '.$default_id.' '.$extra.'>';
if ($show_blank_item) {
$html .= self::tag('option', '-- '.get_lang('Select').' --', array('value'=>'-1'));
if ($show_blank_item) {
if (empty($blank_item_text)) {
$blank_item_text = get_lang('Select');
} else {
$blank_item_text = Security::remove_XSS($blank_item_text);
}
$html .= self::tag('option', '-- '.$blank_item_text.' --', array('value'=>'-1'));
}
if ($values) {
foreach ($values as $key => $value) {

@ -2633,8 +2633,7 @@ function api_not_allowed($print_headers = false) {
@import "'.api_get_path(WEB_CODE_PATH).'css/'.api_get_setting('stylesheets').'/default.css";
/*]]>*/
</style>';
}
}
$msg = Display::return_message(get_lang('NotAllowedClickBack'), 'error', false);
$msg = Display::div($msg, array('align'=>'center'));

Loading…
Cancel
Save