Skip to content

Commit

Permalink
Fix empty document list when cloud link document is set to invisible
Browse files Browse the repository at this point in the history
BT#17003
  • Loading branch information
jmontoyaa committed Apr 7, 2020
1 parent de66083 commit 72b397f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions main/inc/lib/document.lib.php
Expand Up @@ -715,9 +715,9 @@ public static function getAllDocumentData(
}

return $finalDocumentData;
} else {
return [];
}

return [];
}

/**
Expand Down Expand Up @@ -1367,7 +1367,7 @@ public static function delete_document_from_search_engine($course_id, $document_
*
* @return int id of document / false if no doc found
*/
public static function get_document_id($courseInfo, $path, $sessionId = null)
public static function get_document_id($courseInfo, $path, $sessionId = null, $forceFileTypeFolder = false)
{
$table = Database::get_course_table(TABLE_DOCUMENT);
$courseId = $courseInfo['real_id'];
Expand All @@ -1380,11 +1380,16 @@ public static function get_document_id($courseInfo, $path, $sessionId = null)

$path = Database::escape_string($path);
if (!empty($courseId) && !empty($path)) {
$folderCondition = '';
if ($forceFileTypeFolder) {
$folderCondition = ' AND filetype = "folder" ';
}
$sql = "SELECT id FROM $table
WHERE
c_id = $courseId AND
path LIKE BINARY '$path' AND
session_id = $sessionId
$folderCondition
LIMIT 1";

$result = Database::query($sql);
Expand Down Expand Up @@ -1459,10 +1464,10 @@ public static function get_document_data_by_id(
if (dirname($row['path']) == '.') {
$row['parent_id'] = '0';
} else {
$row['parent_id'] = self::get_document_id($course_info, dirname($row['path']), $session_id);
$row['parent_id'] = self::get_document_id($course_info, dirname($row['path']), $session_id, true);
if (empty($row['parent_id'])) {
// Try one more with session id = 0
$row['parent_id'] = self::get_document_id($course_info, dirname($row['path']), 0);
$row['parent_id'] = self::get_document_id($course_info, dirname($row['path']), 0, true);
}
}
$parents = [];
Expand Down

0 comments on commit 72b397f

Please sign in to comment.