Skip to content

Commit 54b0b3a

Browse files
committed
Adding learning path documents in a folder learning_path see BT#3542
1 parent 460a9b9 commit 54b0b3a

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

main/document/document.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ function confirmation (name) {
355355
if( $i == $array_len - 1 && !isset($_GET['createdir']) ) {
356356
$url_dir = '#';
357357
}
358+
if ($url_to_who == 'learning_path') {
359+
$url_to_who = get_lang('LearningPaths');
360+
}
358361
$interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who);
359362
}
360363
//does not repeat the name group in the url
@@ -1182,6 +1185,7 @@ function confirmation (name) {
11821185

11831186
if (count($docs_and_folders) > 1) {
11841187
if ($is_allowed_to_edit || $group_member_with_upload_rights) {
1188+
11851189
// Getting the course quota
11861190
$course_quota = DocumentManager::get_course_quota();
11871191

main/newscorm/learnpath.class.php

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4827,11 +4827,45 @@ public function create_document($_course) {
48274827
$dir = '/' . $dir;
48284828
if ($dir[strlen($dir) - 1] != '/')
48294829
$dir .= '/';
4830+
48304831
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
4832+
4833+
if (empty($_POST['dir']) && empty($_GET['dir'])) {
4834+
4835+
//Creating learning_path folder
4836+
$dir = '/learning_path';
4837+
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
4838+
$folder = null;
4839+
if (!is_dir($filepath.'/'.$dir)) {
4840+
$folder = create_unexisting_directory($_course, api_get_user_id(), api_get_session_id(), 0, 0, $filepath, $dir , get_lang('LearningPaths'));
4841+
} else {
4842+
$folder = true;
4843+
}
4844+
4845+
$dir = '/learning_path/';
4846+
//Creating LP folder
4847+
if ($folder) {
4848+
$title = replace_dangerous_char($this->name);
4849+
$dir = $dir.$title;
4850+
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
4851+
if (!is_dir($filepath.'/'.$dir)) {
4852+
$folder = create_unexisting_directory($_course, api_get_user_id(), api_get_session_id(), 0, 0, $filepath, $dir , $this->name);
4853+
} else {
4854+
$folder = true;
4855+
}
4856+
$dir = $dir.'/';
4857+
if ($folder) {
4858+
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document'.$dir;
4859+
}
4860+
}
4861+
}
4862+
48314863
if (!is_dir($filepath)) {
48324864
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
48334865
$dir = '/';
48344866
}
4867+
4868+
48354869
// stripslashes() before calling replace_dangerous_char() because $_POST['title']
48364870
// is already escaped twice when it gets here.
48374871
$title = replace_dangerous_char(stripslashes($_POST['title']));
@@ -4885,14 +4919,10 @@ public function create_document($_course) {
48854919
if ($new_title)
48864920
$ct .= ", title='" . Database :: escape_string(htmlspecialchars($new_title, ENT_QUOTES, $charset)) . ".html '";
48874921

4888-
$sql_update = "
4889-
UPDATE " . $tbl_doc . "
4890-
SET " . substr($ct, 1) . "
4891-
WHERE id = " . $document_id;
4922+
$sql_update = "UPDATE " . $tbl_doc ." SET " . substr($ct, 1)." WHERE id = " . $document_id;
48924923
Database::query($sql_update);
48934924
}
48944925
}
4895-
48964926
return $document_id;
48974927
}
48984928
}
@@ -6309,8 +6339,7 @@ public function display_document_form($action = 'add', $id = 0, $extra_info = 'n
63096339

63106340
if ($action == 'add') {
63116341
$return .= get_lang('CreateTheDocument');
6312-
}
6313-
elseif ($action == 'move') {
6342+
} elseif ($action == 'move') {
63146343
$return .= get_lang('MoveTheCurrentDocument');
63156344
} else {
63166345
$return .= get_lang('EditTheCurrentDocument');

main/newscorm/lp_add_item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ function confirmation(name) {
328328
echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang('EnterDataNewModule'));
329329
break;
330330
case 'document':
331-
if(isset($_GET['file']) && is_numeric($_GET['file'])) {
331+
if (isset($_GET['file']) && is_numeric($_GET['file'])) {
332332
echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']);
333333
} else {
334334
echo $_SESSION['oLP']->display_document_form('add', 0);

main/newscorm/lp_controller.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ function setFocus(){
212212

213213
if ($debug > 0) error_log('New LP - add item action triggered', 0);
214214

215-
216215
if (!$lp_found) {
217216
//check if the learnpath ID was defined, otherwise send back to list
218217
if ($debug > 0) error_log('New LP - No learnpath given for add item', 0);
@@ -227,13 +226,11 @@ function setFocus(){
227226
$_SESSION['oLP']->set_modified_on();
228227

229228
if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time']) {
230-
231229
// Check post_time to ensure ??? (counter-hacking measure?)
232230
require 'lp_add_item.php';
233231
} else {
234-
232+
235233
$_SESSION['post_time'] = $_POST['post_time'];
236-
237234
if ($_POST['type'] == TOOL_DOCUMENT) {
238235
if (isset($_POST['path']) && $_GET['edit'] != 'true') {
239236
$document_id = $_POST['path'];

0 commit comments

Comments
 (0)