Adding learning path documents in a folder learning_path see BT#3542

skala
Julio Montoya 15 years ago
parent 460a9b9ad0
commit 54b0b3adea
  1. 4
      main/document/document.php
  2. 43
      main/newscorm/learnpath.class.php
  3. 2
      main/newscorm/lp_add_item.php
  4. 5
      main/newscorm/lp_controller.php

@ -355,6 +355,9 @@ for ($i = 0; $i < $array_len; $i++) {
if( $i == $array_len - 1 && !isset($_GET['createdir']) ) {
$url_dir = '#';
}
if ($url_to_who == 'learning_path') {
$url_to_who = get_lang('LearningPaths');
}
$interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
}
//does not repeat the name group in the url
@ -1182,6 +1185,7 @@ $table->display();
if (count($docs_and_folders) > 1) {
if ($is_allowed_to_edit || $group_member_with_upload_rights) {
// Getting the course quota
$course_quota = DocumentManager::get_course_quota();

@ -4827,11 +4827,45 @@ class learnpath {
$dir = '/' . $dir;
if ($dir[strlen($dir) - 1] != '/')
$dir .= '/';
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
if (empty($_POST['dir']) && empty($_GET['dir'])) {
//Creating learning_path folder
$dir = '/learning_path';
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
$folder = null;
if (!is_dir($filepath.'/'.$dir)) {
$folder = create_unexisting_directory($_course, api_get_user_id(), api_get_session_id(), 0, 0, $filepath, $dir , get_lang('LearningPaths'));
} else {
$folder = true;
}
$dir = '/learning_path/';
//Creating LP folder
if ($folder) {
$title = replace_dangerous_char($this->name);
$dir = $dir.$title;
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
if (!is_dir($filepath.'/'.$dir)) {
$folder = create_unexisting_directory($_course, api_get_user_id(), api_get_session_id(), 0, 0, $filepath, $dir , $this->name);
} else {
$folder = true;
}
$dir = $dir.'/';
if ($folder) {
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document'.$dir;
}
}
}
if (!is_dir($filepath)) {
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
$dir = '/';
}
// stripslashes() before calling replace_dangerous_char() because $_POST['title']
// is already escaped twice when it gets here.
$title = replace_dangerous_char(stripslashes($_POST['title']));
@ -4885,14 +4919,10 @@ class learnpath {
if ($new_title)
$ct .= ", title='" . Database :: escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset)) . ".html '";
$sql_update = "
UPDATE " . $tbl_doc . "
SET " . substr($ct, 1) . "
WHERE id = " . $document_id;
$sql_update = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)." WHERE id = " . $document_id;
Database::query($sql_update);
}
}
return $document_id;
}
}
@ -6309,8 +6339,7 @@ class learnpath {
if ($action == 'add') {
$return .= get_lang('CreateTheDocument');
}
elseif ($action == 'move') {
} elseif ($action == 'move') {
$return .= get_lang('MoveTheCurrentDocument');
} else {
$return .= get_lang('EditTheCurrentDocument');

@ -328,7 +328,7 @@ echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang('EnterDataNewModule'));
break;
case 'document':
if(isset($_GET['file']) && is_numeric($_GET['file'])) {
if (isset($_GET['file']) && is_numeric($_GET['file'])) {
echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']);
} else {
echo $_SESSION['oLP']->display_document_form('add', 0);

@ -212,7 +212,6 @@ switch ($action) {
if ($debug > 0) error_log('New LP - add item action triggered', 0);
if (!$lp_found) {
//check if the learnpath ID was defined, otherwise send back to list
if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
@ -227,13 +226,11 @@ switch ($action) {
$_SESSION['oLP']->set_modified_on();
if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time']) {
// Check post_time to ensure ??? (counter-hacking measure?)
require 'lp_add_item.php';
} else {
$_SESSION['post_time'] = $_POST['post_time'];
if ($_POST['type'] == TOOL_DOCUMENT) {
if (isset($_POST['path']) && $_GET['edit'] != 'true') {
$document_id = $_POST['path'];

Loading…
Cancel
Save