Merge pull request #884 from jloguercio/createdocument

Minor bugs fixed in create documents - Refs #7897
1.10.x
Yannick Warnier 10 years ago
commit 1aba3d2cbe
  1. 14
      main/document/create_document.php
  2. 2
      main/inc/ajax/document.ajax.php

@ -58,7 +58,10 @@ $(document).on("click", ".dropdown-menu li a", function () {
contentType: "application/x-www-form-urlencoded", contentType: "application/x-www-form-urlencoded",
data: "textValue="+textValue, data: "textValue="+textValue,
url: "' . api_get_path(WEB_AJAX_PATH) . 'document.ajax.php?a=documentDestination", url: "' . api_get_path(WEB_AJAX_PATH) . 'document.ajax.php?a=documentDestination",
type: "POST" type: "POST",
success: function(response) {
$("[name=\'textValue\']").val(response)
}
}); });
}); });
@ -199,7 +202,7 @@ if ($is_certificate_mode) {
$editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir; $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir;
} }
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
if (!is_dir($filepath)) { if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
@ -429,6 +432,8 @@ if (!$is_certificate_mode &&
} }
} }
$form->addHidden('textValue', '');
if ($is_certificate_mode) { if ($is_certificate_mode) {
$form->addButtonCreate(get_lang('CreateCertificate')); $form->addButtonCreate(get_lang('CreateCertificate'));
} else { } else {
@ -443,11 +448,11 @@ if ($form->validate()) {
$readonly = isset($values['readonly']) ? 1 : 0; $readonly = isset($values['readonly']) ? 1 : 0;
$values['title'] = trim($values['title']); $values['title'] = trim($values['title']);
$textValue = $_SESSION['textValue']; $textValue = $values['textValue'];
$homeDirectory = get_lang('HomeDirectory'); $homeDirectory = get_lang('HomeDirectory');
if ($textValue === $homeDirectory){ if ($textValue === $homeDirectory){
$dir = "/"; $dir = "/";
} else if ($dir != "/") { } else {
$posTextValue = strpos($textValue, '—'); $posTextValue = strpos($textValue, '—');
$textValue = substr($textValue, ($posTextValue + 4)); $textValue = substr($textValue, ($posTextValue + 4));
foreach ($folder_titles as $dirValue => $dirText) { foreach ($folder_titles as $dirValue => $dirText) {
@ -460,6 +465,7 @@ if ($form->validate()) {
if ($dir[strlen($dir) - 1] != '/') { if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/'; $dir .= '/';
} }
$filepath = $filepath.$dir;
// Setting the filename // Setting the filename
$filename = $values['title']; $filename = $values['title'];

@ -76,7 +76,7 @@ switch ($action) {
case 'documentDestination': case 'documentDestination':
//obtained the bootstrap-select selected value via ajax //obtained the bootstrap-select selected value via ajax
$textValue = isset($_POST['textValue']) ? $_POST['textValue'] : null; $textValue = isset($_POST['textValue']) ? $_POST['textValue'] : null;
$_SESSION['textValue'] = $textValue; echo $textValue;
break; break;
} }
exit; exit;

Loading…
Cancel
Save