Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[document_repository] Fix download path to correct user #8378

Merged
merged 5 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/document_repository/jsx/docIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ class DocIndex extends React.Component {
case 'File Name':
let downloadURL = loris.BaseURL
+ '/document_repository/Files/'
+ encodeURIComponent(row['Uploaded By'])
+ '/'
+ encodeURIComponent(row['File Name']);
result = <td>
<a
Expand Down
14 changes: 10 additions & 4 deletions modules/document_repository/php/files.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,26 @@ class Files extends \NDB_Page
['message' => 'File deleted.']
));
case "GET":
$filename = urldecode(basename($request->getUri()->getPath()));
$route = explode('/', $request->getUri()->getPath());
$route = explode('/', $request->getUri()->getPath());
if ($route[2] == 'meta') {
$id = urldecode(basename($request->getUri()->getPath()));
return (new \LORIS\Http\Response())
->withHeader("Content-Type", "text/plain")
->withBody(
new \LORIS\Http\StringStream(
json_encode($this->getUploadDocFields($filename))
json_encode($this->getUploadDocFields($id))
)
);
}

zaliqarosli marked this conversation as resolved.
Show resolved Hide resolved
$filename = explode(
'Files',
urldecode($request->getUri()->getPath())
)[1];

$downloader = new \LORIS\FilesDownloadHandler(
new \SPLFileInfo(
$downloadpath . $request->getAttribute('user')->getUsername()
$downloadpath
)
);
return $downloader->handle(
Expand Down
5 changes: 4 additions & 1 deletion modules/document_repository/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ class Module extends \Module
$last_login = $user->getLastLogin($DB);

$docs = $DB->pselect(
"SELECT File_name, Date_uploaded, Data_dir FROM document_repository
"SELECT File_name,
Date_uploaded,
CONCAT(uploaded_by, '/', File_name) AS Data_dir
FROM document_repository
ORDER BY Date_uploaded DESC LIMIT 4",
[]
);
Expand Down