aboutsummaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2025-01-20 17:08:01 +0100
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2025-01-20 17:08:01 +0100
commit1257022fb3baa2ab6674437bb86422615f590160 (patch)
tree1f5700e0b2aa4209aaf1e5931a03e2f559f9c3fe /app/controllers
parentc8b6c7ae16126c1c918e4e78635f1e1b1b6ca627 (diff)
use objects instead of idstic-4946
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/file.php11
-rw-r--r--app/controllers/files_dashboard/helpers.php14
-rw-r--r--app/controllers/profile.php2
3 files changed, 15 insertions, 12 deletions
diff --git a/app/controllers/file.php b/app/controllers/file.php
index c21fb89..982ef41 100644
--- a/app/controllers/file.php
+++ b/app/controllers/file.php
@@ -387,8 +387,8 @@ class FileController extends AuthenticatedController
}
$this->file = $plugin->getPreparedFile($file_id);
+ $this->file_ref = $this->file->getFileRef();
$this->from_plugin = Request::get("from_plugin");
-
} else {
$this->file_ref = FileRef::find($file_ref_id);
$this->file = $this->file_ref->getFileType();
@@ -396,7 +396,10 @@ class FileController extends AuthenticatedController
$this->folder = $this->file->getFoldertype();
- if (!$this->folder || !$this->folder->isFileEditable($this->file->getId(), $GLOBALS['user']->id)) {
+ if (
+ !$this->folder
+ || !$this->folder->isFileEditable($this->file_ref, $GLOBALS['user']->id)
+ ) {
throw new AccessDeniedException();
}
@@ -538,7 +541,7 @@ class FileController extends AuthenticatedController
if (
!$this->folder
- || !$this->folder->isFileEditable($this->file->getId(), $GLOBALS['user']->id)
+ || !$this->folder->isFileEditable($this->file_ref, $GLOBALS['user']->id)
|| !$GLOBALS['perm']->have_perm(Config::get()->OER_PUBLIC_STATUS)
) {
throw new AccessDeniedException();
@@ -626,7 +629,7 @@ class FileController extends AuthenticatedController
$this->file = $this->file_ref->getFileType();
$this->folder = $this->file_ref->foldertype;
- if (!$this->folder || !$this->folder->isFileEditable($this->file_ref->id, $GLOBALS['user']->id)) {
+ if (!$this->folder || !$this->folder->isFileEditable($this->file_ref, $GLOBALS['user']->id)) {
throw new AccessDeniedException();
}
diff --git a/app/controllers/files_dashboard/helpers.php b/app/controllers/files_dashboard/helpers.php
index 4489e04..dc759a1 100644
--- a/app/controllers/files_dashboard/helpers.php
+++ b/app/controllers/files_dashboard/helpers.php
@@ -10,9 +10,9 @@ trait Helpers
/**
* Create an action menu for a file. This method is used by the template.
*
- * @param FileRef $fileRef the file whose action shall be created
- * @param FolderType $folder the file's folder
- * @param User $user the user for whom the actions shall be created
+ * @param \FileRef $fileRef the file whose action shall be created
+ * @param \FolderType $folder the file's folder
+ * @param \User $user the user for whom the actions shall be created
*
* @return string the HTML fragment of the action menu
*/
@@ -37,7 +37,7 @@ trait Helpers
);
}
- if ($folder->isFileEditable($fileRef->id, $user->id)) {
+ if ($folder->isFileEditable($fileRef, $user->id)) {
$actionMenu->addLink(
URLHelper::getURL('dispatch.php/file/edit/'.$fileRef->id),
_('Datei bearbeiten'),
@@ -52,7 +52,7 @@ trait Helpers
);
}
- if ($folder->isFileWritable($fileRef->id, $user->id)) {
+ if ($folder->isFileWritable($fileRef, $user->id)) {
$actionMenu->addLink(
URLHelper::getURL('dispatch.php/file/choose_destination/move/'.$fileRef->id),
_('Datei verschieben'),
@@ -61,7 +61,7 @@ trait Helpers
);
}
- if ($folder->isFileDownloadable($fileRef->id, $user->id)) {
+ if ($folder->isFileDownloadable($fileRef, $user->id)) {
$actionMenu->addLink(
URLHelper::getURL('dispatch.php/file/choose_destination/copy/'.$fileRef->id),
_('Datei kopieren'),
@@ -70,7 +70,7 @@ trait Helpers
);
}
- if ($folder->isFileWritable($fileRef->id, $user->id)) {
+ if ($folder->isFileWritable($fileRef, $user->id)) {
$actionMenu->addLink(
URLHelper::getURL('dispatch.php/file/delete/'.$fileRef->id),
_('Datei löschen'),
diff --git a/app/controllers/profile.php b/app/controllers/profile.php
index b00c2b2..a656685 100644
--- a/app/controllers/profile.php
+++ b/app/controllers/profile.php
@@ -186,7 +186,7 @@ class ProfileController extends AuthenticatedController
//since we have collected all public folders above already.
$folder_file_refs = $one_public_folder->getFiles();
foreach ($folder_file_refs as $file_ref) {
- if ($one_public_folder->isFileDownloadable($file_ref->id, $GLOBALS['user']->id)) {
+ if ($one_public_folder->isFileDownloadable($file_ref, $GLOBALS['user']->id)) {
$public_files[$file_ref->id] = $file_ref;
}
}