Skip to content
Snippets Groups Projects
Commit 12471d84 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by Jan-Hendrik Willms
Browse files

fix errors in filesystem, fixes #1231

Closes #1231

Merge request studip/studip!743
parent 6e650a50
No related branches found
No related tags found
No related merge requests found
Showing
with 47 additions and 25 deletions
...@@ -40,6 +40,8 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType ...@@ -40,6 +40,8 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType
return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id) return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id)
&& CourseDate::countBySql("range_id = ?" , [$course->id]); && CourseDate::countBySql("range_id = ?" , [$course->id]);
} }
return false;
} }
public function __construct($folderdata = null) public function __construct($folderdata = null)
...@@ -56,10 +58,7 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType ...@@ -56,10 +58,7 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType
); );
} }
/** public function getDate(): ?CourseDate
* @return CourseDate
*/
public function getDate()
{ {
if (isset($this->folderdata['data_content']['termin_id'])) { if (isset($this->folderdata['data_content']['termin_id'])) {
if ($this->date === null) { if ($this->date === null) {
...@@ -72,6 +71,8 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType ...@@ -72,6 +71,8 @@ class CourseDateFolder extends PermissionEnabledFolder implements FolderType
} }
return $this->date; return $this->date;
} }
return null;
} }
/** /**
......
...@@ -40,12 +40,14 @@ class CourseGroupFolder extends StandardFolder ...@@ -40,12 +40,14 @@ class CourseGroupFolder extends StandardFolder
if ($course && !$course->isNew()) { if ($course && !$course->isNew()) {
return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id) && Statusgruppen::countBySql("range_id = ?" , [$course->id]); return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id) && Statusgruppen::countBySql("range_id = ?" , [$course->id]);
} }
return false;
} }
/** /**
* This method check the permission (global and if he is in the group) for a given user * This method check the permission (global and if he is in the group) for a given user
* *
* @param $user_id The User-ID * @param string $user_id The User-ID
* @return bool True if user have permission, False otherwise * @return bool True if user have permission, False otherwise
*/ */
public function checkPermission($user_id) public function checkPermission($user_id)
...@@ -60,7 +62,7 @@ class CourseGroupFolder extends StandardFolder ...@@ -60,7 +62,7 @@ class CourseGroupFolder extends StandardFolder
/** /**
* Check if this GroupFolder instance is visible for this user or not. * Check if this GroupFolder instance is visible for this user or not.
* *
* @param user_id The User-ID * @param string $user_id The User-ID
* @return bool True, if the user is in this group or is the lecturer, false otherwise * @return bool True, if the user is in this group or is the lecturer, false otherwise
*/ */
public function isVisible($user_id) public function isVisible($user_id)
...@@ -71,7 +73,7 @@ class CourseGroupFolder extends StandardFolder ...@@ -71,7 +73,7 @@ class CourseGroupFolder extends StandardFolder
/** /**
* Check if this GroupFolder instance is readable for this user or not. * Check if this GroupFolder instance is readable for this user or not.
* *
* @param user_id The User-ID * @param string $user_id The User-ID
* @return bool True, if the user is in this group or is the lecturer, false otherwise * @return bool True, if the user is in this group or is the lecturer, false otherwise
*/ */
public function isReadable($user_id) public function isReadable($user_id)
...@@ -82,7 +84,7 @@ class CourseGroupFolder extends StandardFolder ...@@ -82,7 +84,7 @@ class CourseGroupFolder extends StandardFolder
/** /**
* Check if this GroupFolder instance is writable for this user or not. * Check if this GroupFolder instance is writable for this user or not.
* *
* @param user_id The User-ID * @param string $user_id The User-ID
* @return bool True, if the user is in this group or is the lecturer, false otherwise * @return bool True, if the user is in this group or is the lecturer, false otherwise
*/ */
public function isWritable($user_id) public function isWritable($user_id)
......
...@@ -38,6 +38,7 @@ class CoursePublicFolder extends StandardFolder ...@@ -38,6 +38,7 @@ class CoursePublicFolder extends StandardFolder
if ($course && !$course->isNew()) { if ($course && !$course->isNew()) {
return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id); return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id);
} }
return false;
} }
public function getIcon($role = Icon::DEFAULT_ROLE) public function getIcon($role = Icon::DEFAULT_ROLE)
......
...@@ -31,6 +31,7 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType ...@@ -31,6 +31,7 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType
if ($course && !$course->isNew()) { if ($course && !$course->isNew()) {
return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id) && CourseTopic::countBySql("seminar_id = ?" , [$course->id]); return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id) && CourseTopic::countBySql("seminar_id = ?" , [$course->id]);
} }
return false;
} }
public function __construct($folderdata = null) public function __construct($folderdata = null)
...@@ -47,10 +48,7 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType ...@@ -47,10 +48,7 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType
); );
} }
/** public function getTopic(): ?CourseTopic
* @return CourseTopic
*/
public function getTopic()
{ {
if (isset($this->folderdata['data_content']['topic_id'])) { if (isset($this->folderdata['data_content']['topic_id'])) {
if ($this->topic === null) { if ($this->topic === null) {
...@@ -64,13 +62,15 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType ...@@ -64,13 +62,15 @@ class CourseTopicFolder extends PermissionEnabledFolder implements FolderType
} }
return $this->topic; return $this->topic;
} }
return null;
} }
/** /**
* @param CourseTopic $topic * @param CourseTopic $topic
* @return CourseTopic * @return CourseTopic
*/ */
public function setTopic(CourseTopic $topic) public function setTopic(CourseTopic $topic): ?CourseTopic
{ {
$this->topic = $topic; $this->topic = $topic;
$this->folderdata['data_content']['topic_id'] = $this->topic->id; $this->folderdata['data_content']['topic_id'] = $this->topic->id;
......
...@@ -742,7 +742,7 @@ class FileManager ...@@ -742,7 +742,7 @@ class FileManager
return [_('Datei konnte nicht gespeichert werden.')]; return [_('Datei konnte nicht gespeichert werden.')];
} }
} else { } else {
return $error; return [$error];
} }
} else { } else {
...@@ -1081,7 +1081,7 @@ class FileManager ...@@ -1081,7 +1081,7 @@ class FileManager
$file_ref = FileRef::build((array) $file_ref, false); $file_ref = FileRef::build((array) $file_ref, false);
$file_ref->setFolderType('foldertype', $source_folder); $file_ref->setFolderType('foldertype', $source_folder);
} }
$result = self::moveFileRef($file_ref, $new_folder, $user); $result = self::moveFile($file_ref->getFileType(), $new_folder, $user);
if (!$result instanceof FileRef) { if (!$result instanceof FileRef) {
//error //error
return $result; return $result;
......
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
interface FileType interface FileType
{ {
/**
* StandardFile constructor.
* @param $fileref
* @param null $file : (optional) Is set if fileref and file are both new and not connected with
* each other in the database.
*/
public function __construct($fileref, $file = null);
/** /**
* Returns the name of the icon shape that shall be used with the FileType implementation. * Returns the name of the icon shape that shall be used with the FileType implementation.
* *
......
...@@ -37,6 +37,7 @@ class HomeworkFolder extends PermissionEnabledFolder ...@@ -37,6 +37,7 @@ class HomeworkFolder extends PermissionEnabledFolder
if ($course && !$course->isNew()) { if ($course && !$course->isNew()) {
return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id); return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id);
} }
return false;
} }
public function __construct($folderdata = null) public function __construct($folderdata = null)
......
...@@ -175,9 +175,10 @@ class InboxOutboxFolder implements FolderType ...@@ -175,9 +175,10 @@ class InboxOutboxFolder implements FolderType
_('InboxOutbox-Ordner können nicht bearbeitet werden!') _('InboxOutbox-Ordner können nicht bearbeitet werden!')
); );
} }
public function store() public function store()
{ {
return false;
} }
/** /**
......
...@@ -236,6 +236,7 @@ class MessageFolder extends StandardFolder implements FolderType ...@@ -236,6 +236,7 @@ class MessageFolder extends StandardFolder implements FolderType
*/ */
public function setDataFromEditTemplate($request) public function setDataFromEditTemplate($request)
{ {
return MessageBox::error('Not applicable for message folders');
} }
/** /**
...@@ -307,6 +308,7 @@ class MessageFolder extends StandardFolder implements FolderType ...@@ -307,6 +308,7 @@ class MessageFolder extends StandardFolder implements FolderType
*/ */
public function deleteSubfolder($subfolder_id) public function deleteSubfolder($subfolder_id)
{ {
return false;
} }
/** /**
......
...@@ -30,7 +30,7 @@ class StandardFile implements FileType, ArrayAccess ...@@ -30,7 +30,7 @@ class StandardFile implements FileType, ArrayAccess
* @param null|string $user_id : the id of the user that should own the new file * @param null|string $user_id : the id of the user that should own the new file
* @return FileType|array : FileType (of called class) on success or an array with errors if an error occurred. * @return FileType|array : FileType (of called class) on success or an array with errors if an error occurred.
*/ */
static public function create($data, $user_id = null) public static function create($data, $user_id = null)
{ {
$errors = []; $errors = [];
$user_id || $user_id = $GLOBALS['user']->id; $user_id || $user_id = $GLOBALS['user']->id;
......
...@@ -202,7 +202,7 @@ class StandardFolder implements FolderType ...@@ -202,7 +202,7 @@ class StandardFolder implements FolderType
} }
/** /**
* @param Request $request * @param array $request
* @return FolderType|MessageBox * @return FolderType|MessageBox
*/ */
public function setDataFromEditTemplate($request) public function setDataFromEditTemplate($request)
...@@ -357,6 +357,8 @@ class StandardFolder implements FolderType ...@@ -357,6 +357,8 @@ class StandardFolder implements FolderType
if ($file_ref) { if ($file_ref) {
return $file_ref->delete(); return $file_ref->delete();
} }
return 0;
} }
......
...@@ -42,6 +42,7 @@ class TimedFolder extends PermissionEnabledFolder ...@@ -42,6 +42,7 @@ class TimedFolder extends PermissionEnabledFolder
if ($course && !$course->isNew()) { if ($course && !$course->isNew()) {
return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id); return Seminar_Perm::get()->have_studip_perm('tutor', $course->id, $user_id);
} }
return false;
} }
/** /**
......
...@@ -20,7 +20,7 @@ class UnknownFileType implements FileType, ArrayAccess ...@@ -20,7 +20,7 @@ class UnknownFileType implements FileType, ArrayAccess
*/ */
protected $fileref = null; protected $fileref = null;
public function __construct($fileref = null) public function __construct($fileref = null, $file = null)
{ {
$this->fileref = $fileref; $this->fileref = $fileref;
} }
...@@ -151,6 +151,7 @@ class UnknownFileType implements FileType, ArrayAccess ...@@ -151,6 +151,7 @@ class UnknownFileType implements FileType, ArrayAccess
*/ */
public function getPath(): string public function getPath(): string
{ {
return '';
} }
/** /**
...@@ -210,6 +211,7 @@ class UnknownFileType implements FileType, ArrayAccess ...@@ -210,6 +211,7 @@ class UnknownFileType implements FileType, ArrayAccess
*/ */
public function delete() public function delete()
{ {
return 0;
} }
/** /**
...@@ -272,6 +274,7 @@ class UnknownFileType implements FileType, ArrayAccess ...@@ -272,6 +274,7 @@ class UnknownFileType implements FileType, ArrayAccess
*/ */
public function getAdditionalColumnOrderWeigh($column_index) public function getAdditionalColumnOrderWeigh($column_index)
{ {
return 0;
} }
/** /**
...@@ -279,5 +282,6 @@ class UnknownFileType implements FileType, ArrayAccess ...@@ -279,5 +282,6 @@ class UnknownFileType implements FileType, ArrayAccess
*/ */
public function getInfoTemplate(bool $include_downloadable_infos = false) public function getInfoTemplate(bool $include_downloadable_infos = false)
{ {
return '';
} }
} }
...@@ -136,7 +136,7 @@ class UnknownFolderType implements FolderType ...@@ -136,7 +136,7 @@ class UnknownFolderType implements FolderType
*/ */
public function getDescriptionTemplate() public function getDescriptionTemplate()
{ {
return '';
} }
...@@ -145,7 +145,7 @@ class UnknownFolderType implements FolderType ...@@ -145,7 +145,7 @@ class UnknownFolderType implements FolderType
*/ */
public function getEditTemplate() public function getEditTemplate()
{ {
return '';
} }
/** /**
...@@ -153,7 +153,7 @@ class UnknownFolderType implements FolderType ...@@ -153,7 +153,7 @@ class UnknownFolderType implements FolderType
*/ */
public function setDataFromEditTemplate($request) public function setDataFromEditTemplate($request)
{ {
return MessageBox::error('Not applicable for unknown folder type');
} }
/** /**
......
...@@ -165,6 +165,7 @@ class VirtualFolderType implements FolderType ...@@ -165,6 +165,7 @@ class VirtualFolderType implements FolderType
*/ */
public function setDataFromEditTemplate($request) public function setDataFromEditTemplate($request)
{ {
return MessageBox::error('Not applicable for virtual folder type');
} }
/** /**
...@@ -257,11 +258,9 @@ class VirtualFolderType implements FolderType ...@@ -257,11 +258,9 @@ class VirtualFolderType implements FolderType
return true; return true;
} }
/**
*
*/
public function store() public function store()
{ {
return 0;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment