|
|
|
@ -601,7 +601,7 @@ class DocumentManager |
|
|
|
foreach ($documentData as $row) { |
|
|
|
foreach ($documentData as $row) { |
|
|
|
$isVisible = self::check_visibility_tree( |
|
|
|
$isVisible = self::check_visibility_tree( |
|
|
|
$row['id'], |
|
|
|
$row['id'], |
|
|
|
$courseInfo['code'], |
|
|
|
$courseInfo, |
|
|
|
$sessionId, |
|
|
|
$sessionId, |
|
|
|
api_get_user_id(), |
|
|
|
api_get_user_id(), |
|
|
|
$toGroupId |
|
|
|
$toGroupId |
|
|
|
@ -3508,8 +3508,8 @@ class DocumentManager |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param int $doc_id |
|
|
|
* @param int $doc_id |
|
|
|
* @param string $course_code |
|
|
|
* @param array $courseInfo |
|
|
|
* @param int $session_id |
|
|
|
* @param int $sessionId |
|
|
|
* @param int $user_id |
|
|
|
* @param int $user_id |
|
|
|
* @param int $groupId iid |
|
|
|
* @param int $groupId iid |
|
|
|
* |
|
|
|
* |
|
|
|
@ -3517,21 +3517,32 @@ class DocumentManager |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function check_visibility_tree( |
|
|
|
public static function check_visibility_tree( |
|
|
|
$doc_id, |
|
|
|
$doc_id, |
|
|
|
$course_code, |
|
|
|
$courseInfo, |
|
|
|
$session_id, |
|
|
|
$sessionId, |
|
|
|
$user_id, |
|
|
|
$user_id, |
|
|
|
$groupId = 0 |
|
|
|
$groupId = 0 |
|
|
|
) { |
|
|
|
) { |
|
|
|
|
|
|
|
if (empty($courseInfo)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$courseCode = $courseInfo['code']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($courseCode)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$document_data = self::get_document_data_by_id( |
|
|
|
$document_data = self::get_document_data_by_id( |
|
|
|
$doc_id, |
|
|
|
$doc_id, |
|
|
|
$course_code, |
|
|
|
$courseCode, |
|
|
|
null, |
|
|
|
null, |
|
|
|
$session_id |
|
|
|
$sessionId |
|
|
|
); |
|
|
|
); |
|
|
|
if ($session_id != 0 && !$document_data) { |
|
|
|
|
|
|
|
|
|
|
|
if ($sessionId != 0 && !$document_data) { |
|
|
|
$document_data = self::get_document_data_by_id( |
|
|
|
$document_data = self::get_document_data_by_id( |
|
|
|
$doc_id, |
|
|
|
$doc_id, |
|
|
|
$course_code, |
|
|
|
$courseCode, |
|
|
|
null, |
|
|
|
null, |
|
|
|
0 |
|
|
|
0 |
|
|
|
); |
|
|
|
); |
|
|
|
@ -3539,27 +3550,27 @@ class DocumentManager |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($document_data)) { |
|
|
|
if (!empty($document_data)) { |
|
|
|
// If admin or course teacher, allow anyway |
|
|
|
// If admin or course teacher, allow anyway |
|
|
|
if (api_is_platform_admin() || CourseManager::is_course_teacher($user_id, $course_code)) { |
|
|
|
if (api_is_platform_admin() || CourseManager::is_course_teacher($user_id, $courseCode)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
|
|
|
if ($document_data['parent_id'] == false || empty($document_data['parent_id'])) { |
|
|
|
if ($document_data['parent_id'] == false || empty($document_data['parent_id'])) { |
|
|
|
if (!empty($groupId)) { |
|
|
|
if (!empty($groupId)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
$visible = self::is_visible_by_id($doc_id, $course_info, $session_id, $user_id); |
|
|
|
$visible = self::is_visible_by_id($doc_id, $courseInfo, $sessionId, $user_id); |
|
|
|
|
|
|
|
|
|
|
|
return $visible; |
|
|
|
return $visible; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$visible = self::is_visible_by_id($doc_id, $course_info, $session_id, $user_id); |
|
|
|
$visible = self::is_visible_by_id($doc_id, $courseInfo, $sessionId, $user_id); |
|
|
|
|
|
|
|
|
|
|
|
if (!$visible) { |
|
|
|
if (!$visible) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return self::check_visibility_tree( |
|
|
|
return self::check_visibility_tree( |
|
|
|
$document_data['parent_id'], |
|
|
|
$document_data['parent_id'], |
|
|
|
$course_code, |
|
|
|
$courseInfo, |
|
|
|
$session_id, |
|
|
|
$sessionId, |
|
|
|
$user_id, |
|
|
|
$user_id, |
|
|
|
$groupId |
|
|
|
$groupId |
|
|
|
); |
|
|
|
); |
|
|
|
|