From bd89825de4764a3b8a9fab76eedfcfb0f08d5f8f Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 27 Mar 2014 14:09:14 +0100 Subject: [PATCH] Fixing document creation inside a group. --- main/document/create_document.php | 53 ++++++++++++++++--------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/main/document/create_document.php b/main/document/create_document.php index 2956c26576..7344fb6806 100644 --- a/main/document/create_document.php +++ b/main/document/create_document.php @@ -46,11 +46,6 @@ $(document).ready(function() { }); function InnerDialogLoaded() { - /* - var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates); - return B.ClickFrame(); - */ - var isIE = (navigator.appVersion.indexOf(\'MSIE\') != -1) ? true : false ; var EditorFrame = null ; @@ -100,15 +95,13 @@ function InnerDialogLoaded() { var bestandsnaamNieuw = ""; var bestandsnaamOud = ""; - // The are two diffent ways to get the text (without HTML markups). + // The are two different ways to get the text (without HTML markups). // It is browser specific. - - if( document.all ) // If Internet Explorer. - { + // If Internet Explorer. + if( document.all ) { contentText = oDOM.body.innerText ; - } - else // If Gecko. - { + } else { + // If Gecko. var r = oDOM.createRange() ; r.selectNodeContents( oDOM.body ) ; contentText = r.toString() ; @@ -120,14 +113,10 @@ function InnerDialogLoaded() { // Compose title if there is none contentTextArray = contentText.split(\' \') ; var x=0; - for(x=0; (x<5 && xsetDefaults($defaults); if ($form->validate()) { $values = $form->exportValues(); $readonly = isset($values['readonly']) ? 1 : 0; - $values['title'] = trim($values['title']); - if (!empty($values['curdirpath'])) { + /*if (!empty($values['curdirpath'])) { $dir = $values['curdirpath']; - } + }*/ - if ($dir[strlen($dir) - 1] != '/') { + if ($dir[strlen($dir) - 1] != '/') { $dir .= '/'; } - //Setting the filename + // Setting the filename $filename = $values['title']; $filename = addslashes(trim($filename)); $filename = Security::remove_XSS($filename); @@ -494,7 +483,7 @@ if ($form->validate()) { $extension = 'html'; $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); - + if (strpos($content, '/css/frames.css') == false) { $content = str_replace('', '', $content); } @@ -530,8 +519,20 @@ if ($form->validate()) { $save_file_path = $dir.$filename.'.'.$extension; $document_id = add_document($_course, $save_file_path, 'file', $file_size, $title, null, $readonly); + if ($document_id) { - api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'DocumentAdded', $_user['user_id'], $to_group_id, null, null, null, $current_session_id); + api_item_property_update( + $_course, + TOOL_DOCUMENT, + $document_id, + 'DocumentAdded', + $_user['user_id'], + $to_group_id, + null, + null, + null, + $current_session_id + ); // Update parent folders item_property_update_on_folder($_course, $dir, $_user['user_id']); $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : '';