Addin warning messages when adding a watermark + adding a new return_message

skala
Julio Montoya 14 years ago
parent 0bb437937d
commit 9255453703
  1. 4
      main/admin/settings.lib.php
  2. 65
      main/admin/settings.php
  3. 21
      main/inc/lib/display.lib.php
  4. 6
      main/inc/lib/pdf.lib.php

@ -290,7 +290,6 @@ function handle_stylesheets() {
//echo '</select><br />';
echo '</select>&nbsp;&nbsp;';
//var_dump($list_of_names);
if ($is_style_changeable){
echo '<button class="save" type="submit" name="submit_stylesheets"> '.get_lang('SaveSettings').' </button></form>';
}
@ -564,7 +563,6 @@ function handle_search() {
if ($form->validate()) {
$formvalues = $form->exportValues();
var_dump($formvalues);
$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 '</div>';
}
}
/**

@ -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.
@ -388,21 +388,21 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
$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'])) {
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') {
$values['allow_message_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<div class=\"actions\">";
echo "<div class=\"actions\">";
//while ($row = Database::fetch_array($resultcategories))
foreach ($resultcategories as $row) {
echo "\n\t<a href=\"".api_get_self()."?category=".$row['category']."\">".Display::return_icon($action_images[strtolower($row['category'])], api_ucfirst(get_lang($row['category'])),'','32')."</a>";
echo "<a href=\"".api_get_self()."?category=".$row['category']."\">".Display::return_icon($action_images[strtolower($row['category'])], api_ucfirst(get_lang($row['category'])),'','32')."</a>";
}
echo "\n\t<a href=\"".api_get_self()."?category=Search\">".Display::return_icon($action_images['search'], api_ucfirst(get_lang('Search')),'','32')."</a>";
echo "\n\t<a href=\"".api_get_self()."?category=stylesheets\">".Display::return_icon($action_images['stylesheets'], api_ucfirst(get_lang('Stylesheets')),'','32')."</a>";
echo "\n\t<a href=\"".api_get_self()."?category=Templates\">".Display::return_icon($action_images['templates'], api_ucfirst(get_lang('Templates')),'','32')."</a>";
echo "\n\t<a href=\"".api_get_self()."?category=Plugins\">".Display::return_icon($action_images['plugins'], api_ucfirst(get_lang('Plugins')),'','32')."</a>";
echo "\n</div>";
echo "<a href=\"".api_get_self()."?category=Search\">".Display::return_icon($action_images['search'], api_ucfirst(get_lang('Search')),'','32')."</a>";
echo "<a href=\"".api_get_self()."?category=stylesheets\">".Display::return_icon($action_images['stylesheets'], api_ucfirst(get_lang('Stylesheets')),'','32')."</a>";
echo "<a href=\"".api_get_self()."?category=Templates\">".Display::return_icon($action_images['templates'], api_ucfirst(get_lang('Templates')),'','32')."</a>";
echo "<a href=\"".api_get_self()."?category=Plugins\">".Display::return_icon($action_images['plugins'], api_ucfirst(get_lang('Plugins')),'','32')."</a>";
echo "</div>";
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);
}
}
}
}
if (!empty($_GET['category'])) {
switch ($_GET['category']) {

@ -454,6 +454,27 @@ class Display {
*/
echo $message.'</div>';
}
/**
* 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

@ -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') {

Loading…
Cancel
Save