|
|
|
|
@ -64,7 +64,6 @@ if (api_is_in_group()) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$dir = '/'; |
|
|
|
|
|
|
|
|
|
$currentDirPath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null; |
|
|
|
|
$readonly = false; |
|
|
|
|
if (isset($_GET['id'])) { |
|
|
|
|
@ -239,85 +238,70 @@ if (isset($_POST['comment'])) { |
|
|
|
|
|
|
|
|
|
/* WYSIWYG HTML EDITOR - Program Logic */ |
|
|
|
|
if ($is_allowed_to_edit) { |
|
|
|
|
if (isset($_POST['formSent']) && $_POST['formSent'] == 1) { |
|
|
|
|
$filename = stripslashes($_POST['filename']); |
|
|
|
|
$extension = $_POST['extension']; |
|
|
|
|
if (isset($_POST['formSent']) && $_POST['formSent'] == 1 && !empty($document_id)) { |
|
|
|
|
$content = isset($_POST['content']) ? trim(str_replace(["\r", "\n"], '', stripslashes($_POST['content']))) : null; |
|
|
|
|
$content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY); |
|
|
|
|
|
|
|
|
|
if ($dir == '/') { |
|
|
|
|
$dir = ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$file = $dir.'/'.$filename.'.'.$extension; |
|
|
|
|
$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; |
|
|
|
|
$read_only_flag = empty($read_only_flag) ? 0 : 1; |
|
|
|
|
|
|
|
|
|
if (empty($filename)) { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('NoFileName'), 'warning')); |
|
|
|
|
} else { |
|
|
|
|
if ($file_type != 'link') { |
|
|
|
|
$file_size = filesize($document_data['absolute_path']); |
|
|
|
|
} |
|
|
|
|
if ($file_type != 'link') { |
|
|
|
|
$file_size = filesize($document_data['absolute_path']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($read_only_flag == 0) { |
|
|
|
|
if (!empty($content)) { |
|
|
|
|
if ($fp = @fopen($document_data['absolute_path'], 'w')) { |
|
|
|
|
// For flv player, change absolute path temporarily to prevent |
|
|
|
|
// from erasing it in the following lines |
|
|
|
|
$content = str_replace(['flv=h', 'flv=/'], ['flv=h|', 'flv=/|'], $content); |
|
|
|
|
fputs($fp, $content); |
|
|
|
|
fclose($fp); |
|
|
|
|
$filepath = $document_data['absolute_parent_path']; |
|
|
|
|
|
|
|
|
|
// "WHAT'S NEW" notification: update table item_property |
|
|
|
|
$document_id = DocumentManager::get_document_id($_course, $file); |
|
|
|
|
|
|
|
|
|
if ($document_id) { |
|
|
|
|
update_existing_document( |
|
|
|
|
$_course, |
|
|
|
|
$document_id, |
|
|
|
|
$file_size, |
|
|
|
|
$read_only_flag |
|
|
|
|
); |
|
|
|
|
api_item_property_update( |
|
|
|
|
$_course, |
|
|
|
|
TOOL_DOCUMENT, |
|
|
|
|
$document_id, |
|
|
|
|
'DocumentUpdated', |
|
|
|
|
api_get_user_id(), |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
$sessionId |
|
|
|
|
); |
|
|
|
|
// Update parent folders |
|
|
|
|
item_property_update_on_folder( |
|
|
|
|
$_course, |
|
|
|
|
$dir, |
|
|
|
|
api_get_user_id() |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning')); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning')); |
|
|
|
|
} |
|
|
|
|
if ($read_only_flag == 0) { |
|
|
|
|
if (!empty($content)) { |
|
|
|
|
if ($fp = @fopen($document_data['absolute_path'], 'w')) { |
|
|
|
|
// For flv player, change absolute path temporarily to prevent |
|
|
|
|
// from erasing it in the following lines |
|
|
|
|
$content = str_replace(['flv=h', 'flv=/'], ['flv=h|', 'flv=/|'], $content); |
|
|
|
|
fputs($fp, $content); |
|
|
|
|
fclose($fp); |
|
|
|
|
$filepath = $document_data['absolute_parent_path']; |
|
|
|
|
|
|
|
|
|
update_existing_document( |
|
|
|
|
$_course, |
|
|
|
|
$document_id, |
|
|
|
|
$file_size, |
|
|
|
|
$read_only_flag |
|
|
|
|
); |
|
|
|
|
api_item_property_update( |
|
|
|
|
$_course, |
|
|
|
|
TOOL_DOCUMENT, |
|
|
|
|
$document_id, |
|
|
|
|
'DocumentUpdated', |
|
|
|
|
api_get_user_id(), |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
$sessionId |
|
|
|
|
); |
|
|
|
|
// Update parent folders |
|
|
|
|
item_property_update_on_folder( |
|
|
|
|
$_course, |
|
|
|
|
$dir, |
|
|
|
|
api_get_user_id() |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
if ($document_id) { |
|
|
|
|
update_existing_document($_course, $document_id, $file_size, $read_only_flag); |
|
|
|
|
} |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning')); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($document_id) { |
|
|
|
|
update_existing_document($_course, $document_id, $file_size, $read_only_flag); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
header('Location: document.php?id='.$document_data['parent_id'].'&'.api_get_cidreq().($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : '')); |
|
|
|
|
exit; |
|
|
|
|
} else { |
|
|
|
|
if ($document_id) { |
|
|
|
|
update_existing_document($_course, $document_id, $file_size, $read_only_flag); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
header('Location: document.php?id='.$document_data['parent_id'].'&'.api_get_cidreq().($is_certificate_mode ? '&curdirpath=/certificates&selectcat=1' : '')); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -395,7 +379,6 @@ if ($owner_id == api_get_user_id() || |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$defaults['title'] = $document_data['title']; |
|
|
|
|
$defaults['formSent'] = 1; |
|
|
|
|
$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; |
|
|
|
|
|
|
|
|
|
// Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor. |
|
|
|
|
@ -479,8 +462,9 @@ if ($owner_id == api_get_user_id() || |
|
|
|
|
} else { |
|
|
|
|
$form->addButtonUpdate(get_lang('SaveDocument')); |
|
|
|
|
} |
|
|
|
|
$form->addHidden('formSent', 1); |
|
|
|
|
$form->addHidden('filename', $filename); |
|
|
|
|
|
|
|
|
|
$defaults['filename'] = $filename; |
|
|
|
|
$defaults['extension'] = $extension; |
|
|
|
|
$defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null; |
|
|
|
|
$defaults['commentPath'] = $file; |
|
|
|
|
|