aboutsummaryrefslogtreecommitdiff
path: root/lib
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 /lib
parentc8b6c7ae16126c1c918e4e78635f1e1b1b6ca627 (diff)
use objects instead of idstic-4946
Diffstat (limited to 'lib')
-rw-r--r--lib/activities/DocumentsProvider.php2
-rw-r--r--lib/classes/exportdocument/ExportPDF.php4
-rw-r--r--lib/filesystem/CoursePublicFolder.php6
-rw-r--r--lib/filesystem/ExerciseFolder.php6
-rw-r--r--lib/filesystem/FeedbackFolder.php6
-rw-r--r--lib/filesystem/FileManager.php6
-rw-r--r--lib/filesystem/FolderType.php18
-rw-r--r--lib/filesystem/HiddenFolder.php14
-rw-r--r--lib/filesystem/HomeworkFolder.php12
-rw-r--r--lib/filesystem/InboxOutboxFolder.php6
-rw-r--r--lib/filesystem/MVVFolder.php2
-rw-r--r--lib/filesystem/MessageFolder.php6
-rw-r--r--lib/filesystem/PermissionEnabledFolder.php8
-rw-r--r--lib/filesystem/PublicFolder.php18
-rw-r--r--lib/filesystem/ResourceFolder.php6
-rw-r--r--lib/filesystem/ResponseFolder.php6
-rw-r--r--lib/filesystem/StandardFile.php6
-rw-r--r--lib/filesystem/StandardFolder.php42
-rw-r--r--lib/filesystem/TimedFolder.php35
-rw-r--r--lib/filesystem/UnknownFolderType.php18
-rw-r--r--lib/filesystem/VirtualFolderType.php18
-rw-r--r--lib/models/Courseware/Filesystem/PublicFolder.php8
-rw-r--r--lib/models/vips/Exercise.php2
-rw-r--r--lib/modules/CoreDocuments.php2
24 files changed, 129 insertions, 128 deletions
diff --git a/lib/activities/DocumentsProvider.php b/lib/activities/DocumentsProvider.php
index 0275c3f..bee3e22 100644
--- a/lib/activities/DocumentsProvider.php
+++ b/lib/activities/DocumentsProvider.php
@@ -26,7 +26,7 @@ class DocumentsProvider implements ActivityProvider
if (
!$document
|| !$activity->getContextObject()
- || !$document->folder->getTypedFolder()->isFileDownloadable($document->id, $activity->getContextObject()->getObserver()->id)
+ || !$document->folder->getTypedFolder()->isFileDownloadable($document, $activity->getContextObject()->getObserver()->id)
) {
return false;
}
diff --git a/lib/classes/exportdocument/ExportPDF.php b/lib/classes/exportdocument/ExportPDF.php
index 1b2ec77..1519ba5 100644
--- a/lib/classes/exportdocument/ExportPDF.php
+++ b/lib/classes/exportdocument/ExportPDF.php
@@ -329,8 +329,8 @@ class ExportPDF extends TCPDF implements ExportDocument
$file_ref = FileRef::find($matches[1]);
$folder = isset($file_ref->folder) ? $file_ref->folder->getTypedFolder() : null;
if (
- isset($folder)
- && $folder->isFileDownloadable($file_ref->id, $GLOBALS['user']->id)
+ isset($folder, $file_ref)
+ && $folder->isFileDownloadable($file_ref, $GLOBALS['user']->id)
) {
$convurl = $file_ref->file->getPath();
} else {
diff --git a/lib/filesystem/CoursePublicFolder.php b/lib/filesystem/CoursePublicFolder.php
index 0aabac4..5432709 100644
--- a/lib/filesystem/CoursePublicFolder.php
+++ b/lib/filesystem/CoursePublicFolder.php
@@ -138,12 +138,12 @@ class CoursePublicFolder extends StandardFolder
/**
* Files in CoursePublicFolders are downloadable for all logged in users.
*
- * @param string $file_ref_id The ID to a FileRef.
- * @param string $user_id The user who wishes to downlaod the file.
+ * @param FileRef $file_ref The ID to a FileRef.
+ * @param string $user_id The user who wishes to downlaod the file.
*
* @return bool
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return $this->isVisible($user_id);
}
diff --git a/lib/filesystem/ExerciseFolder.php b/lib/filesystem/ExerciseFolder.php
index e882de8..a2f5bec 100644
--- a/lib/filesystem/ExerciseFolder.php
+++ b/lib/filesystem/ExerciseFolder.php
@@ -58,17 +58,17 @@ class ExerciseFolder extends StandardFolder
return false;
}
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return $this->isReadable($user_id);
}
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
return $this->isWritable($user_id);
}
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
return $this->isWritable($user_id);
}
diff --git a/lib/filesystem/FeedbackFolder.php b/lib/filesystem/FeedbackFolder.php
index db82a38..2a23101 100644
--- a/lib/filesystem/FeedbackFolder.php
+++ b/lib/filesystem/FeedbackFolder.php
@@ -43,17 +43,17 @@ class FeedbackFolder extends StandardFolder
return false;
}
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return $this->isReadable($user_id);
}
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
return $this->isWritable($user_id);
}
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
return $this->isWritable($user_id);
}
diff --git a/lib/filesystem/FileManager.php b/lib/filesystem/FileManager.php
index 4328fcf..4ca5621 100644
--- a/lib/filesystem/FileManager.php
+++ b/lib/filesystem/FileManager.php
@@ -1250,7 +1250,7 @@ class FileManager
// loop through all files and copy them to the folder path:
foreach ($folder->getFiles() as $file_ref) {
- if ($folder->isFileDownloadable($file_ref->id, $user_id) || $ignore_perms) {
+ if ($folder->isFileDownloadable($file_ref, $user_id) || $ignore_perms) {
//The user (given by user_id) has the required permissions
//to download the file or the permission checks are
//ignored.
@@ -1302,7 +1302,7 @@ class FileManager
//specified by $user_id:
if ($folder->isReadable($user_id)) {
foreach ($folder_files as $folder_file) {
- if ($folder->isFileDownloadable($folder_file->id, $user_id)) {
+ if ($folder->isFileDownloadable($folder_file, $user_id)) {
$num_files++;
}
}
@@ -1316,7 +1316,7 @@ class FileManager
if ($user_id) {
//user-ID is set: only if the file is downloadable
//it will be counted!
- if ($folder->isFileDownloadable($file->id, $user_id)) {
+ if ($folder->isFileDownloadable($file, $user_id)) {
$num_files++;
}
} else {
diff --git a/lib/filesystem/FolderType.php b/lib/filesystem/FolderType.php
index ef98af1..5eba268 100644
--- a/lib/filesystem/FolderType.php
+++ b/lib/filesystem/FolderType.php
@@ -225,29 +225,29 @@ interface FolderType
/**
* Determines if a user may download the file.
*
- * @param string $file_ref_id The ID of the FileRef object of a file that shall be downloaded.
- * @param string $user_id The user who wishes to download the file.
+ * @param FileRef $file_ref The FileRef object of a file that shall be downloaded.
+ * @param string $user_id The user who wishes to download the file.
* @return boolean True, if the user is permitted to download the file, false otherwise.
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool;
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool;
/**
* Determines if a user may edit the file.
*
- * @param string $file_ref_id The ID of the FileRef object of a file that shall be edited.
- * @param string $user_id The user who wishes to edit the file.
+ * @param FileRef $file_ref The FileRef object of a file that shall be edited.
+ * @param string $user_id The user who wishes to edit the file.
* @return boolean True, if the user is permitted to edit the file, false otherwise.
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool;
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool;
/**
* Determines if a user may write to the file.
*
- * @param string $file_ref_id The FileRef object of a file that shall be written.
- * @param string $user_id The user who wishes to write to the file.
+ * @param FileRef $file_ref The FileRef object of a file that shall be written.
+ * @param string $user_id The user who wishes to write to the file.
* @return boolean True, if the user is permitted to write to the file, false otherwise.
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool;
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool;
/**
* Returns an associative array of additional colums with the index the id of the column
diff --git a/lib/filesystem/HiddenFolder.php b/lib/filesystem/HiddenFolder.php
index df93517..c503e93 100644
--- a/lib/filesystem/HiddenFolder.php
+++ b/lib/filesystem/HiddenFolder.php
@@ -126,18 +126,14 @@ class HiddenFolder extends PermissionEnabledFolder
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
- $fileref = FileRef::find($file_ref_id);
-
- if ($fileref) {
- if ($this->download_allowed || Seminar_Perm::get()->have_studip_perm('tutor', $this->range_id, $user_id)) {
- return $fileref->terms_of_use->isDownloadable($this->range_id, $this->range_type, true, $user_id);
- }
+ if ($this->download_allowed || Seminar_Perm::get()->have_studip_perm('tutor', $this->range_id, $user_id)) {
+ return $file_ref->terms_of_use->isDownloadable($this->range_id, $this->range_type, true, $user_id);
}
return false;
diff --git a/lib/filesystem/HomeworkFolder.php b/lib/filesystem/HomeworkFolder.php
index 46b9f20..11f585c 100644
--- a/lib/filesystem/HomeworkFolder.php
+++ b/lib/filesystem/HomeworkFolder.php
@@ -109,11 +109,11 @@ class HomeworkFolder extends PermissionEnabledFolder
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
return $GLOBALS['perm']->have_studip_perm('tutor', $this->range_id, $user_id);
}
@@ -126,11 +126,11 @@ class HomeworkFolder extends PermissionEnabledFolder
* tutor permissions on the Stud.IP object specified by range_id
* (such objects may be courses or institutes for example).
*
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
return $GLOBALS['perm']->have_studip_perm('tutor', $this->range_id, $user_id);
}
diff --git a/lib/filesystem/InboxOutboxFolder.php b/lib/filesystem/InboxOutboxFolder.php
index bab9253..fe61573 100644
--- a/lib/filesystem/InboxOutboxFolder.php
+++ b/lib/filesystem/InboxOutboxFolder.php
@@ -235,7 +235,7 @@ class InboxOutboxFolder implements FolderType
/**
* Files are only downloadable for the owner.
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return $this->user
&& $user_id === $this->user->id;
@@ -244,7 +244,7 @@ class InboxOutboxFolder implements FolderType
/**
* InboxOutboxFolders do not allow editing files.
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
//files shall be unchanged in here
return false;
@@ -253,7 +253,7 @@ class InboxOutboxFolder implements FolderType
/**
* InboxOutboxFolders do not allow writing files.
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
//files shall be unchanged in here
return false;
diff --git a/lib/filesystem/MVVFolder.php b/lib/filesystem/MVVFolder.php
index 73f237a..b75372f 100644
--- a/lib/filesystem/MVVFolder.php
+++ b/lib/filesystem/MVVFolder.php
@@ -32,7 +32,7 @@ class MVVFolder extends StandardFolder
/**
* See method MVVFolder::isReadable
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return $this->isReadable($user_id);
}
diff --git a/lib/filesystem/MessageFolder.php b/lib/filesystem/MessageFolder.php
index f0d5cf6..9f2d301 100644
--- a/lib/filesystem/MessageFolder.php
+++ b/lib/filesystem/MessageFolder.php
@@ -317,7 +317,7 @@ class MessageFolder extends StandardFolder
/**
* See method MessageFolder::isReadable
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return $this->isReadable($user_id);
}
@@ -325,7 +325,7 @@ class MessageFolder extends StandardFolder
/**
* Files inside MessageFolders are not editable.
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
//message attachments are never editable!
return false;
@@ -334,7 +334,7 @@ class MessageFolder extends StandardFolder
/**
* Files inside MessageFolders are not writable.
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
//message attachments are never writable!
return false;
diff --git a/lib/filesystem/PermissionEnabledFolder.php b/lib/filesystem/PermissionEnabledFolder.php
index 29acb65..36f98f6 100644
--- a/lib/filesystem/PermissionEnabledFolder.php
+++ b/lib/filesystem/PermissionEnabledFolder.php
@@ -134,13 +134,13 @@ class PermissionEnabledFolder extends StandardFolder
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
- $fileref = FileRef::find($file_ref_id);
+ $fileref = FileRef::find($file_ref);
if ($fileref) {
if ($this->isVisible($user_id) && $this->isFileVisible($fileref, $user_id)) {
diff --git a/lib/filesystem/PublicFolder.php b/lib/filesystem/PublicFolder.php
index 285a0df..439ab04 100644
--- a/lib/filesystem/PublicFolder.php
+++ b/lib/filesystem/PublicFolder.php
@@ -118,12 +118,12 @@ class PublicFolder extends StandardFolder
/**
* Files in PublicFolders are always downloadable.
*
- * @param string $file_ref_id The ID to a FileRef.
- * @param string $user_id The user who wishes to downlaod the file.
+ * @param FileRef $file_ref The ID to a FileRef.
+ * @param string $user_id The user who wishes to downlaod the file.
*
* @return bool True
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
//public folder => everyone can download a file
return true;
@@ -132,12 +132,12 @@ class PublicFolder extends StandardFolder
/**
* Files in PublicFolders are editable for the owner only.
*
- * @param string $file_ref_id The ID to a FileRef.
- * @param string $user_id The user who wishes to edit the file.
+ * @param FileRef $file_ref The ID to a FileRef.
+ * @param string $user_id The user who wishes to edit the file.
*
* @return bool True, if the user is the owner of the file, false otherwise.
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
//only the owner may edit files
return $this->range_id === $user_id;
@@ -146,12 +146,12 @@ class PublicFolder extends StandardFolder
/**
* Files in PublicFolders are writable for the owner only.
*
- * @param string $file_ref_id The ID to a FileRef.
- * @param string $user_id The user who wishes to write to the file.
+ * @param FileRef $file_ref The ID to a FileRef.
+ * @param string $user_id The user who wishes to write to the file.
*
* @return bool True, if the user is the owner of the file, false otherwise.
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
//only the owner may delete files
return $this->range_id === $user_id;
diff --git a/lib/filesystem/ResourceFolder.php b/lib/filesystem/ResourceFolder.php
index edb7a48..1319040 100644
--- a/lib/filesystem/ResourceFolder.php
+++ b/lib/filesystem/ResourceFolder.php
@@ -127,17 +127,17 @@ class ResourceFolder extends StandardFolder
return false;
}
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return $this->isReadable($user_id);
}
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
return $this->isWritable($user_id);
}
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
return $this->isWritable($user_id);
}
diff --git a/lib/filesystem/ResponseFolder.php b/lib/filesystem/ResponseFolder.php
index 169405e..cf2cf67 100644
--- a/lib/filesystem/ResponseFolder.php
+++ b/lib/filesystem/ResponseFolder.php
@@ -54,17 +54,17 @@ class ResponseFolder extends StandardFolder
return false;
}
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return $this->isReadable($user_id);
}
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
return $this->isWritable($user_id);
}
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
return $this->isWritable($user_id);
}
diff --git a/lib/filesystem/StandardFile.php b/lib/filesystem/StandardFile.php
index f357b47..ad16023 100644
--- a/lib/filesystem/StandardFile.php
+++ b/lib/filesystem/StandardFile.php
@@ -379,7 +379,7 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface
{
$user_id || $user_id = $GLOBALS['user']->id;
return $this->getFolderType()->isFileDownloadable(
- $this->fileref->getId(),
+ $this->fileref,
$user_id
);
}
@@ -393,7 +393,7 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface
{
$user_id || $user_id = $GLOBALS['user']->id;
return $this->getFolderType()->isFileEditable(
- $this->fileref->getId(),
+ $this->fileref,
$user_id
);
}
@@ -407,7 +407,7 @@ class StandardFile implements FileType, ArrayAccess, StandardFileInterface
{
$user_id || $user_id = $GLOBALS['user']->id;
return $this->getFolderType()->isFileWritable(
- $this->fileref->getId(),
+ $this->fileref,
$user_id
);
}
diff --git a/lib/filesystem/StandardFolder.php b/lib/filesystem/StandardFolder.php
index 6404dd8..524d68a 100644
--- a/lib/filesystem/StandardFolder.php
+++ b/lib/filesystem/StandardFolder.php
@@ -347,7 +347,11 @@ class StandardFolder implements FolderType
{
$file_ref = $this->folderdata->file_refs->find($file_ref_id);
- if (!$this->isFileWritable($file_ref->id, $GLOBALS['user']->id)) {
+ if (!$file_ref) {
+ return 0;
+ }
+
+ if (!$this->isFileWritable($file_ref, $GLOBALS['user']->id)) {
return [sprintf(
_('Ungenügende Berechtigungen zum Löschen der Datei %s in Ordner %s!'),
$file_ref->name,
@@ -355,11 +359,7 @@ class StandardFolder implements FolderType
)];
}
- if ($file_ref) {
- return $file_ref->delete();
- }
-
- return 0;
+ return $file_ref->delete();
}
/**
@@ -417,23 +417,21 @@ class StandardFolder implements FolderType
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
if ($this->range_type === 'user') {
return $user_id === $this->range_id;
}
if (in_array($this->range_type, ['course', 'institute'])) {
- $fileref = FileRef::find($file_ref_id);
-
- if (is_object($fileref->terms_of_use)) {
+ if (is_object($file_ref->terms_of_use)) {
//terms of use are defined for this file!
return $this->isReadable($user_id)
- && $fileref->terms_of_use->isDownloadable($this->range_id, $this->range_type,true, $user_id);
+ && $file_ref->terms_of_use->isDownloadable($this->range_id, $this->range_type,true, $user_id);
} else {
return $this->isReadable($user_id)
&& $GLOBALS['perm']->have_studip_perm('user', $this->range_id, $user_id);
@@ -444,19 +442,17 @@ class StandardFolder implements FolderType
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
if ($this->range_type === 'user') {
return $user_id === $this->range_id;
}
- $fileref = FileRef::find($file_ref_id);
-
- return $fileref->user_id === $user_id
+ return $file_ref->user_id === $user_id
|| $GLOBALS['perm']->have_studip_perm('tutor', $this->range_id, $user_id);
}
@@ -468,13 +464,13 @@ class StandardFolder implements FolderType
* tutor permissions on the Stud.IP object specified by range_id
* (such objects may be courses or institutes for example).
*
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
- return $this->isFileEditable($file_ref_id, $user_id);
+ return $this->isFileEditable($file_ref, $user_id);
}
/**
diff --git a/lib/filesystem/TimedFolder.php b/lib/filesystem/TimedFolder.php
index b331f0d..9e04b44 100644
--- a/lib/filesystem/TimedFolder.php
+++ b/lib/filesystem/TimedFolder.php
@@ -211,36 +211,43 @@ class TimedFolder extends PermissionEnabledFolder
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
- //HomeworkFolder Style
- if (!Seminar_Perm::get()->have_studip_perm('tutor', $this->range_id) &&
- $this->isWritable($user_id) && !$this->isReadable($user_id)) {
+ // HomeworkFolder Style
+ if (
+ !Seminar_Perm::get()->have_studip_perm('tutor', $this->range_id)
+ && $this->isWritable($user_id)
+ && !$this->isReadable($user_id)
+ ) {
return false;
}
- return parent::isFileEditable($file_ref_id, $user_id);
+ return parent::isFileEditable($file_ref, $user_id);
}
/**
* Checks if a user has write permissions to a file.
*
*
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
- //HomeworkFolder Style
- if (!Seminar_Perm::get()->have_studip_perm('tutor', $this->range_id) &&
- $this->isWritable($user_id) && !$this->isReadable($user_id)) {
+ // HomeworkFolder Style
+ if (
+ !Seminar_Perm::get()->have_studip_perm('tutor', $this->range_id)
+ && $this->isWritable($user_id)
+ && !$this->isReadable($user_id)
+ ) {
return false;
}
- return parent::isFileWritable($file_ref_id, $user_id);
+
+ return parent::isFileWritable($file_ref, $user_id);
}
}
diff --git a/lib/filesystem/UnknownFolderType.php b/lib/filesystem/UnknownFolderType.php
index 2cd7fd2..4eba3bf 100644
--- a/lib/filesystem/UnknownFolderType.php
+++ b/lib/filesystem/UnknownFolderType.php
@@ -239,32 +239,32 @@ class UnknownFolderType implements FolderType
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return false;
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
return false;
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
return false;
}
diff --git a/lib/filesystem/VirtualFolderType.php b/lib/filesystem/VirtualFolderType.php
index 0e2c2b4..a83ec0a 100644
--- a/lib/filesystem/VirtualFolderType.php
+++ b/lib/filesystem/VirtualFolderType.php
@@ -266,31 +266,31 @@ class VirtualFolderType implements FolderType
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return true;
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
return false;
}
/**
- * @param string $file_ref_id
- * @param string $user_id
+ * @param FileRef $file_ref
+ * @param string $user_id
* @return bool
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
return false;
}
diff --git a/lib/models/Courseware/Filesystem/PublicFolder.php b/lib/models/Courseware/Filesystem/PublicFolder.php
index 10af85c..535b5f3 100644
--- a/lib/models/Courseware/Filesystem/PublicFolder.php
+++ b/lib/models/Courseware/Filesystem/PublicFolder.php
@@ -4,6 +4,8 @@ namespace Courseware\Filesystem;
use ArrayAccess;
use Courseware\Instance;
+use File;
+use FileRef;
use FileType;
use Flexi\Template;
use Folder;
@@ -216,7 +218,7 @@ class PublicFolder extends StandardFolder
/**
* {@inheritdoc}
*/
- public function isFileDownloadable(string $file_ref_id, string $user_id): bool
+ public function isFileDownloadable(FileRef $file_ref, string $user_id): bool
{
return true;
}
@@ -224,7 +226,7 @@ class PublicFolder extends StandardFolder
/**
* {@inheritdoc}
*/
- public function isFileEditable(string $file_ref_id, string $user_id): bool
+ public function isFileEditable(FileRef $file_ref, string $user_id): bool
{
return false;
}
@@ -232,7 +234,7 @@ class PublicFolder extends StandardFolder
/**
* {@inheritdoc}
*/
- public function isFileWritable(string $file_ref_id, string $user_id): bool
+ public function isFileWritable(FileRef $file_ref, string $user_id): bool
{
return false;
}
diff --git a/lib/models/vips/Exercise.php b/lib/models/vips/Exercise.php
index bb142cc..9a5f5c1 100644
--- a/lib/models/vips/Exercise.php
+++ b/lib/models/vips/Exercise.php
@@ -814,7 +814,7 @@ abstract class Exercise extends SimpleORMap
if ($file_ref) {
$folder = $file_ref->folder->getTypedFolder();
- if ($folder->isFileDownloadable($file_ref->id, $GLOBALS['user']->id)) {
+ if ($folder->isFileDownloadable($file_ref, $GLOBALS['user']->id)) {
if (!$this->folder->file_refs->find($file_id)) {
$file = $file_ref->file;
// $this->files->append($file);
diff --git a/lib/modules/CoreDocuments.php b/lib/modules/CoreDocuments.php
index 3accbbe..985db40 100644
--- a/lib/modules/CoreDocuments.php
+++ b/lib/modules/CoreDocuments.php
@@ -129,7 +129,7 @@ class CoreDocuments extends CorePlugin implements StudipModule, OERModule
]);
foreach ($file_refs as $fileref) {
$foldertype = $fileref->folder->getTypedFolder();
- if ($foldertype->isFileDownloadable($fileref->getId(), $user_id)) {
+ if ($foldertype->isFileDownloadable($fileref, $user_id)) {
$navigation->setImage(Icon::create('files', Icon::ROLE_ATTENTION), [
'title' => _('Es gibt neue Dateien.'),
]);