diff --git a/main/inc/lib/fileUpload.lib.php b/main/inc/lib/fileUpload.lib.php index 922575a98b..56b197ac53 100755 --- a/main/inc/lib/fileUpload.lib.php +++ b/main/inc/lib/fileUpload.lib.php @@ -412,7 +412,7 @@ function handle_uploaded_document( ); // Redo visibility - api_set_default_visibility(TOOL_DOCUMENT, $documentId); + api_set_default_visibility(TOOL_DOCUMENT, $documentId, null, $courseInfo); } else { // There might be cases where the file exists on disk but there is no registration of that in the database // In this case, and if we are in overwrite mode, overwrite and create the db record @@ -445,7 +445,7 @@ function handle_uploaded_document( ); // Redo visibility - api_set_default_visibility(TOOL_DOCUMENT, $documentId); + api_set_default_visibility(TOOL_DOCUMENT, $documentId, null, $courseInfo); } } @@ -492,7 +492,7 @@ function handle_uploaded_document( ); // Redo visibility - api_set_default_visibility(TOOL_DOCUMENT, $documentId); + api_set_default_visibility(TOOL_DOCUMENT, $documentId, null, $courseInfo); } // If the file is in a folder, we need to update all parent folders item_property_update_on_folder($courseInfo, $uploadPath, $userId); @@ -569,7 +569,7 @@ function handle_uploaded_document( ); // Redo visibility - api_set_default_visibility(TOOL_DOCUMENT, $documentId); + api_set_default_visibility(TOOL_DOCUMENT, $documentId, null, $courseInfo); } // If the file is in a folder, we need to update all parent folders @@ -631,7 +631,7 @@ function handle_uploaded_document( $sessionId ); // Redo visibility - api_set_default_visibility(TOOL_DOCUMENT, $documentId); + api_set_default_visibility(TOOL_DOCUMENT, $documentId, null, $courseInfo); } // If the file is in a folder, we need to update all parent folders @@ -1237,7 +1237,7 @@ function add_document( Database::query($sql); if ($save_visibility) { - api_set_default_visibility($documentId, TOOL_DOCUMENT, $group_id); + api_set_default_visibility($documentId, TOOL_DOCUMENT, $group_id, $_course); } return $documentId; diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index aaca56f572..a667ddeca9 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -488,12 +488,12 @@ class learnpath $prerequisites = 0, $max_time_allowed = 0 ) { - $course_id = api_get_course_int_id(); + $course_id = $this->course_info['real_id']; if ($this->debug > 0) { error_log('New LP - In learnpath::add_item(' . $parent . ',' . $previous . ',' . $type . ',' . $id . ',' . $title . ')', 0); } $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); - $_course = api_get_course_info(); + $_course = $this->course_info; $parent = intval($parent); $previous = intval($previous); $id = intval($id); @@ -567,7 +567,7 @@ class learnpath $max_score = Database :: result($rsQuiz, 0, 0); // Disabling the exercise if we add it inside a LP - $exercise = new Exercise(); + $exercise = new Exercise($course_id); $exercise->read($id); $exercise->disable(); $exercise->save(); @@ -710,7 +710,7 @@ class learnpath * @return integer The new learnpath ID on success, 0 on failure */ public static function add_lp( - $course, + $courseCode, $name, $description = '', $learnpath = 'guess', @@ -721,7 +721,15 @@ class learnpath $categoryId = 0 ) { global $charset; - $course_id = api_get_course_int_id(); + + if (!empty($courseCode)) { + $courseInfo = api_get_course_info($courseCode); + $course_id = $courseInfo['real_id']; + } else { + $course_id = api_get_course_int_id(); + $courseInfo = api_get_course_info(); + } + $tbl_lp = Database :: get_course_table(TABLE_LP_MAIN); // Check course code exists. // Check lp_name doesn't exist, otherwise append something. @@ -819,16 +827,15 @@ class learnpath $sql = "UPDATE $tbl_lp SET id = iid WHERE iid = $id"; Database::query($sql); - $course_info = api_get_course_info(); // Insert into item_property. api_item_property_update( - $course_info, + $courseInfo, TOOL_LEARNPATH, $id, 'LearnpathAdded', api_get_user_id() ); - api_set_default_visibility($id, TOOL_LEARNPATH); + api_set_default_visibility($id, TOOL_LEARNPATH, 0, $courseInfo); return $id; } break; @@ -985,14 +992,17 @@ class learnpath /** * Static admin function allowing removal of a learnpath - * @param string Course code + * @param array $courseInfo * @param integer Learnpath ID * @param string Whether to delete data or keep it (default: 'keep', others: 'remove') * @return boolean True on success, false on failure (might change that to return number of elements deleted) */ - public function delete($course = null, $id = null, $delete = 'keep') + public function delete($courseInfo = null, $id = null, $delete = 'keep') { $course_id = api_get_course_int_id(); + if (!empty($courseInfo)) { + $course_id = isset($courseInfo['real_id']) ? $courseInfo['real_id'] : $course_id; + } // TODO: Implement a way of getting this to work when the current object is not set. // In clear: implement this in the item class as well (abstract class) and use the given ID in queries. @@ -3219,7 +3229,7 @@ class learnpath return $html; } - /** + /** * Returns an HTML-formatted string ready to display with teacher buttons * in LP view menu * @return string HTML TOC ready to display @@ -5623,13 +5633,13 @@ class learnpath $edit_icon .= ''; if ( - !in_array($arrLP[$i]['item_type'], ['forum', 'thread']) + !in_array($arrLP[$i]['item_type'], ['forum', 'thread']) ) { if ( - $this->items[$arrLP[$i]['id']]->getForumThread( - $this->course_int_id, - $this->lp_session_id - ) + $this->items[$arrLP[$i]['id']]->getForumThread( + $this->course_int_id, + $this->lp_session_id + ) ) { $forumIcon = Display::url( Display::return_icon('forum.png', get_lang('CreateForum'), [], ICON_SIZE_TINY), @@ -5638,10 +5648,10 @@ class learnpath ); } else { $forumIconUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query([ - 'action' => 'create_forum', - 'id' => $arrLP[$i]['id'], - 'lp_id' => $this->lp_id - ]); + 'action' => 'create_forum', + 'id' => $arrLP[$i]['id'], + 'lp_id' => $this->lp_id + ]); $forumIcon = Display::url( Display::return_icon('forum.png', get_lang('CreateForum'), [], ICON_SIZE_TINY), $forumIconUrl, @@ -5670,7 +5680,7 @@ class learnpath } if ($update_audio != 'true') { $row = $move_icon . ' ' . $icon . - Display::span($title_cut) . + Display::span($title_cut) . Display::tag( 'div', "