diff --git a/public/main/inc/lib/document.lib.php b/public/main/inc/lib/document.lib.php index de936ef442..bd546b2269 100644 --- a/public/main/inc/lib/document.lib.php +++ b/public/main/inc/lib/document.lib.php @@ -513,8 +513,6 @@ class DocumentManager if ('/chat_files' == $path) { $condition .= " AND (docs.session_id = '$sessionId') "; } - // share_folder filter - $condition .= " AND docs.path != '/shared_folder' "; } return $condition; @@ -567,10 +565,6 @@ class DocumentManager } $show_users_condition = ''; - if ('false' === api_get_setting('show_users_folders')) { - $show_users_condition = " AND docs.path NOT LIKE '%shared_folder%'"; - } - if ($can_see_invisible) { $sessionId = $sessionId ?: api_get_session_id(); $condition_session = " AND (l.session_id = '$sessionId' OR (l.session_id = '0' OR l.session_id IS NULL) )"; @@ -638,7 +632,7 @@ class DocumentManager } //get visible folders - $sql = "SELECT DISTINCT docs.id, docs.path + $sql = "SELECT DISTINCT docs.id FROM resource_node AS n INNER JOIN $TABLE_DOCUMENT AS docs ON (docs.resource_node_id = n.id) @@ -685,7 +679,6 @@ class DocumentManager INNER JOIN resource_link l ON (l.resource_node_id = n.id) WHERE - docs.path LIKE '".Database::escape_string($row['path'].'/%')."' AND docs.filetype = 'folder' AND $groupCondition AND l.visibility NOT IN ('".ResourceLink::VISIBILITY_DELETED."') diff --git a/public/main/lp/learnpath.class.php b/public/main/lp/learnpath.class.php index 77f5c0bc33..c986e1de83 100644 --- a/public/main/lp/learnpath.class.php +++ b/public/main/lp/learnpath.class.php @@ -2143,8 +2143,17 @@ class learnpath */ public function get_lp_session_id() { - if (!empty($this->lp_session_id)) { - return (int) $this->lp_session_id; + $lp = Container::getLpRepository()->find($this->lp_id); + if ($lp) { + /* @var ResourceNode $resourceNode */ + $resourceNode = $lp->getResourceNode(); + if ($resourceNode) { + $link = $resourceNode->getResourceLinks()->first(); + if ($link && $link->getSession()) { + + return (int) $link->getSession()->getId(); + } + } } return 0; diff --git a/public/main/lp/learnpathList.class.php b/public/main/lp/learnpathList.class.php index 8bf31396e5..38e34ac988 100644 --- a/public/main/lp/learnpathList.class.php +++ b/public/main/lp/learnpathList.class.php @@ -137,9 +137,10 @@ class LearnpathList } } + $link = $lp->getFirstResourceLink(); $this->list[$lp->getIid()] = [ 'lp_type' => $lp->getLpType(), - 'lp_session' => 0, + 'lp_session' => $link && $link->getSession() ? (int) $link->getSession()->getId() : 0, 'lp_name' => stripslashes($lp->getTitle()), 'lp_desc' => stripslashes($lp->getDescription()), 'lp_path' => $lp->getPath(), diff --git a/public/main/lp/lp_add_item.php b/public/main/lp/lp_add_item.php index 7f76bd0ce9..64beeb2e6f 100644 --- a/public/main/lp/lp_add_item.php +++ b/public/main/lp/lp_add_item.php @@ -20,11 +20,12 @@ $lpId = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0; $submit = $_POST['submit_button'] ?? null; $type = $_GET['type'] ?? null; $action = $_GET['action'] ?? null; -$is_allowed_to_edit = api_is_allowed_to_edit(null, false); +$checkStudentView = 'true' === $isStudentView; +$is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, $checkStudentView); $listUrl = api_get_path(WEB_CODE_PATH). 'lp/lp_controller.php?action=view&lp_id='.$lpId.'&'.api_get_cidreq().'&isStudentView=true'; -if (!$is_allowed_to_edit) { +if ((!$is_allowed_to_edit) || $checkStudentView) { header("Location: $listUrl"); exit; } diff --git a/src/CourseBundle/Entity/CQuiz.php b/src/CourseBundle/Entity/CQuiz.php index 94e65d69d6..21500ae2a0 100644 --- a/src/CourseBundle/Entity/CQuiz.php +++ b/src/CourseBundle/Entity/CQuiz.php @@ -454,7 +454,7 @@ class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowC /** * Set text to display to user when they fail to the test (when pass percentage has been set). */ - public function setTextWhenFinishedFailure(string $textWhenFinished): self + public function setTextWhenFinishedFailure(?string $textWhenFinished): self { $this->textWhenFinishedFailure = $textWhenFinished;