Upload ajax by default rename see #7244

1.9.x
Julio Montoya 11 years ago
parent 202440754a
commit 56f891ee1b
  1. 10
      main/inc/ajax/document.ajax.php
  2. 21
      main/inc/lib/document.lib.php

@ -24,7 +24,7 @@ switch($action) {
exit;
}
$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : null;
$ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : 'rename';
if (!empty($_FILES)) {
require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
@ -39,8 +39,14 @@ switch($action) {
false,
false
);
$json = array();
$json['name'] = Display::url(api_htmlentities($file['name']), api_htmlentities($result['url']), array('target'=>'_blank'));
$json['name'] = Display::url(
api_htmlentities($result['title']),
api_htmlentities($result['url']),
array('target'=>'_blank')
);
$json['type'] = api_htmlentities($file['type']);
$json['size'] = format_file_size($file['size']);
if (!empty($result) && is_array($result)) {

@ -2641,12 +2641,12 @@ class DocumentManager
$table_document = Database::get_course_table(TABLE_DOCUMENT);
$params = array();
if (!empty($title)) {
$params['title'] = get_document_title($title);
if ($if_exists == 'rename') {
$new_path = basename($new_path);
$params['title'] = get_document_title($new_path);
} else {
if ($if_exists == 'rename') {
$new_path = basename($new_path);
$params['title'] = get_document_title($new_path);
if (!empty($title)) {
$params['title'] = get_document_title($title);
} else {
$params['title'] = get_document_title($files['file']['name']);
}
@ -2655,7 +2655,16 @@ class DocumentManager
if (!empty($comment)) {
$params['comment'] = trim($comment);
}
Database::update($table_document, $params, array('id = ? AND c_id = ? ' => array($docid, $course_info['real_id'])));
Database::update(
$table_document,
$params,
array(
'id = ? AND c_id = ? ' => array(
$docid,
$course_info['real_id']
)
)
);
}
// Showing message when sending zip files

Loading…
Cancel
Save