Fixing document creation inside a group.

1.9.x
Julio Montoya 11 years ago
parent 087efa3833
commit bd89825de4
  1. 53
      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 && x<contentTextArray.length); x++)
{
if(x < 4)
{
for(x=0; (x<5 && x<contentTextArray.length); x++) {
if(x < 4) {
bestandsnaamNieuw += contentTextArray[x] + \' \';
}
else
{
} else {
bestandsnaamNieuw += contentTextArray[x];
}
}
@ -192,6 +181,7 @@ if (empty($document_data)) {
$dir = $document_data['path'];
}
/* MAIN CODE */
// Please, do not modify this dirname formatting
@ -469,18 +459,17 @@ $form->setDefaults($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('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $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']) : '';

Loading…
Cancel
Save