diff --git a/main/document/create_document.php b/main/document/create_document.php index 4443e6f3bb..f219d57ca4 100755 --- a/main/document/create_document.php +++ b/main/document/create_document.php @@ -58,7 +58,10 @@ $(document).on("click", ".dropdown-menu li a", function () { contentType: "application/x-www-form-urlencoded", data: "textValue="+textValue, 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; } -$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)) { $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) { $form->addButtonCreate(get_lang('CreateCertificate')); } else { @@ -443,11 +448,11 @@ if ($form->validate()) { $readonly = isset($values['readonly']) ? 1 : 0; $values['title'] = trim($values['title']); - $textValue = $_SESSION['textValue']; + $textValue = $values['textValue']; $homeDirectory = get_lang('HomeDirectory'); if ($textValue === $homeDirectory){ $dir = "/"; - } else if ($dir != "/") { + } else { $posTextValue = strpos($textValue, '—'); $textValue = substr($textValue, ($posTextValue + 4)); foreach ($folder_titles as $dirValue => $dirText) { @@ -460,6 +465,7 @@ if ($form->validate()) { if ($dir[strlen($dir) - 1] != '/') { $dir .= '/'; } + $filepath = $filepath.$dir; // Setting the filename $filename = $values['title']; diff --git a/main/inc/ajax/document.ajax.php b/main/inc/ajax/document.ajax.php index 697c52fa84..2ad1debf8c 100755 --- a/main/inc/ajax/document.ajax.php +++ b/main/inc/ajax/document.ajax.php @@ -76,7 +76,7 @@ switch ($action) { case 'documentDestination': //obtained the bootstrap-select selected value via ajax $textValue = isset($_POST['textValue']) ? $_POST['textValue'] : null; - $_SESSION['textValue'] = $textValue; + echo $textValue; break; } exit;