diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index d5633013a2..00b2c470e4 100755 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -290,7 +290,6 @@ function handle_stylesheets() { //echo '
'; echo '  '; - //var_dump($list_of_names); if ($is_style_changeable){ echo ''; } @@ -563,8 +562,7 @@ function handle_search() { if ($form->validate()) { - $formvalues = $form->exportValues(); - var_dump($formvalues); + $formvalues = $form->exportValues(); $r = api_set_settings_category('Search', 'false', $_configuration['access_url']); // Save the settings. foreach ($formvalues as $key => $value) { @@ -576,8 +574,6 @@ function handle_search() { $form->display(); echo ''; } - - } /** diff --git a/main/admin/settings.php b/main/admin/settings.php index 8ae909e0a6..f622771bc2 100755 --- a/main/admin/settings.php +++ b/main/admin/settings.php @@ -18,7 +18,7 @@ if (isset($_GET['category']) && $_GET['category'] == 'Templates') { } else if(isset($_GET['category']) && $_GET['category'] == 'Gradebook') { $language_file = array('admin', 'gradebook'); } else { - $language_file = 'admin'; + $language_file = array('admin', 'document'); } // Resetting the course id. @@ -386,22 +386,22 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"'); $form->addElement('html', ''); - $form->setDefaults($default_values); - - + $form->setDefaults($default_values); + $message = array(); if ($form->validate()) { $values = $form->exportValues(); - - $pdf_export_watermark_path = $_FILES['pdf_export_watermark_path']; - - if (!empty($pdf_export_watermark_path['name'])) { - $pdf_export_watermark_path_result = PDF::upload_watermark($pdf_export_watermark_path['name'], $pdf_export_watermark_path['tmp_name']); + + if (isset($pdf_export_watermark_path) && !empty($pdf_export_watermark_path['name'])) { + $pdf_export_watermark_path_result = PDF::upload_watermark($pdf_export_watermark_path['name'], $pdf_export_watermark_path['tmp_name']); + if ($pdf_export_watermark_path_result) { + $message['confirmation'][] = get_lang('UplUploadSucceeded'); + } else { + $message['warning'][] = get_lang('UplUnableToSaveFile').' '.get_lang('Folder').': '.api_get_path(SYS_CODE_PATH).'default_course_document'; + } unset($update_values['pdf_export_watermark_path']); } - - // Set true for allow_message_tool variable if social tool is actived. if ($values['allow_social_tool'] == 'true') { @@ -519,25 +519,15 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', ' event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_VARIABLE, $variable, $time, $user_id); } } - - header('Location: settings.php?action=stored&category='.Security::remove_XSS($_GET['category'])); - exit; + //header('Location: settings.php?action=stored&category='.Security::remove_XSS($_GET['category']).'&message='.$message); + //exit; } } // Including the header (banner). Display :: display_header($tool_name); -if ($watermark_deleted) { - Display :: display_normal_message(get_lang('FileDeleted')); -} - -//api_display_tool_title($tool_name); -// Displaying the message that the settings have been stored. -if (!empty($_GET['action']) && $_GET['action'] == 'stored') { - Display :: display_confirmation_message(get_lang('SettingsStored')); -} // The action images. $action_images['platform'] = 'platform.png'; @@ -561,16 +551,37 @@ $action_images['extra'] = 'wizard.png'; //$selectcategories = "SELECT DISTINCT category FROM ".$table_settings_current." WHERE category NOT IN ('stylesheets','Plugins')"; //$resultcategories = Database::query($selectcategories); $resultcategories = api_get_settings_categories(array('stylesheets', 'Plugins', 'Templates', 'Search')); -echo "\n
"; +echo "
"; //while ($row = Database::fetch_array($resultcategories)) foreach ($resultcategories as $row) { - echo "\n\t".Display::return_icon($action_images[strtolower($row['category'])], api_ucfirst(get_lang($row['category'])),'','32').""; + echo "".Display::return_icon($action_images[strtolower($row['category'])], api_ucfirst(get_lang($row['category'])),'','32').""; +} +echo "".Display::return_icon($action_images['search'], api_ucfirst(get_lang('Search')),'','32').""; +echo "".Display::return_icon($action_images['stylesheets'], api_ucfirst(get_lang('Stylesheets')),'','32').""; +echo "".Display::return_icon($action_images['templates'], api_ucfirst(get_lang('Templates')),'','32').""; +echo "".Display::return_icon($action_images['plugins'], api_ucfirst(get_lang('Plugins')),'','32').""; +echo "
"; + + +if ($watermark_deleted) { + Display :: display_normal_message(get_lang('FileDeleted')); +} + +//api_display_tool_title($tool_name); + +// Displaying the message that the settings have been stored. +if (isset($form) && $form->validate()) { + + Display::display_confirmation_message(get_lang('SettingsStored')); + if (is_array($message)) { + foreach($message as $type => $content) { + foreach($content as $msg) { + echo Display::return_message($msg, $type); + } + } + } } -echo "\n\t".Display::return_icon($action_images['search'], api_ucfirst(get_lang('Search')),'','32').""; -echo "\n\t".Display::return_icon($action_images['stylesheets'], api_ucfirst(get_lang('Stylesheets')),'','32').""; -echo "\n\t".Display::return_icon($action_images['templates'], api_ucfirst(get_lang('Templates')),'','32').""; -echo "\n\t".Display::return_icon($action_images['plugins'], api_ucfirst(get_lang('Plugins')),'','32').""; -echo "\n
"; + if (!empty($_GET['category'])) { switch ($_GET['category']) { diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 596390a966..9d997911d6 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -454,6 +454,27 @@ class Display { */ echo $message.''; } + /** + * Returns a div html string with + */ + public function return_message($message, $type='normal', $filter = true) { + if ($filter) { + $message = Security::remove_XSS($message); + } + switch($type) { + case 'warning': + $class = 'warning-message'; + case 'error': + $class = 'error-message'; + case 'normal': + $class = ''; + case 'confirmation-message': + $class = ''; + default: + $class = 'normal-message'; + return self::div($message, array('class'=>$class)); + } + } /** * Returns an encrypted mailto hyperlink diff --git a/main/inc/lib/pdf.lib.php b/main/inc/lib/pdf.lib.php index 91530aa1e6..48a29b62c2 100644 --- a/main/inc/lib/pdf.lib.php +++ b/main/inc/lib/pdf.lib.php @@ -305,7 +305,11 @@ class PDF { } /** - * Uploads the pdf watermark + * Uploads the pdf watermark in the main/default_course_document directory or in the course directory + * @param string filename + * @param string path of the file + * @param string course code + * @return mixed web path of the file if sucess, false otherwise */ public function upload_watermark($filename, $source_file, $course_code = null) { if (!empty($course_code) && api_get_setting('pdf_export_watermark_by_course') == 'true') {