Skip to content

Commit

Permalink
[media] fixes permissions. Allows media_read to download, renames "De…
Browse files Browse the repository at this point in the history
…lete" to "Hide".
  • Loading branch information
lorisadmin committed Apr 25, 2024
1 parent bff9931 commit 81c6e3f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions SQL/0000-00-02-Permission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CREATE TABLE `permissions` (
'View/Create/Edit',
'Create/Edit',
'Edit/Upload',
'Edit/Upload/Delete'),
'Edit/Upload/Hide'),
`categoryID` int(10) NOT NULL DEFAULT '2',
PRIMARY KEY (`permID`),
UNIQUE KEY `code` (`code`),
Expand Down Expand Up @@ -102,7 +102,7 @@ INSERT INTO `permissions` VALUES
(31,'acknowledgements_edit','Acknowledgee List',(SELECT ID FROM modules WHERE Name='acknowledgements'),'Edit','2'),
(32,'dataquery_view','Cross-Modality Data',(SELECT ID FROM modules WHERE Name='dataquery'),'View/Download','2'),
(33,'genomic_data_manager','Genomic Files',(SELECT ID FROM modules WHERE Name='genomic_browser'),'Upload','2'),
(34,'media_write','Candidate Media Files',(SELECT ID FROM modules WHERE Name='media'),'Edit/Upload/Delete','2'),
(34,'media_write','Candidate Media Files',(SELECT ID FROM modules WHERE Name='media'),'Edit/Upload/Hide','2'),
(35,'media_read','Candidate Media Files',(SELECT ID FROM modules WHERE Name='media'),'View/Download','2'),
(36,'issue_tracker_reporter', 'Create/Edit Own Issues and Comment on All Issues',(SELECT ID FROM modules WHERE Name='issue_tracker'),NULL, 2),
(37,'issue_tracker_developer', 'Close/Edit/Re-assign/Comment on All Issues',(SELECT ID FROM modules WHERE Name='issue_tracker'),NULL, 2),
Expand Down
2 changes: 1 addition & 1 deletion modules/media/ajax/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function uploadFile()
$db = \NDB_Factory::singleton()->database();
$config = NDB_Config::singleton();
$user =& User::singleton();
if (!$user->hasPermission('media_write')) {
if (!$user->hasPermission('media_read')) {
showMediaError("Permission Denied", 403);
exit;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/media/jsx/mediaIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class MediaIndex extends Component {
let result = <td className={style}>{cell}</td>;
switch (column) {
case 'File Name':
if (this.props.hasPermission('media_write')) {
if (this.props.hasPermission('media_read')) {
const downloadURL = loris.BaseURL
+ '/media/files/'
+ encodeURIComponent(row['File Name']);
Expand Down
5 changes: 1 addition & 4 deletions modules/media/php/files.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ class Files extends \LORIS\Http\FilesPassthroughEndpoint
*/
function _hasAccess(\User $user): bool
{
//XXX: Should this be 'media_read' instead? It seems that downloading
// files should be a read permission, not write.. but this is the
// permission that the old ajax script was checking.
return $user->hasPermission('media_write');
return $user->hasPermission('media_read');
}

/**
Expand Down

0 comments on commit 81c6e3f

Please sign in to comment.