diff --git a/app/controllers/course/files.php b/app/controllers/course/files.php index 91d191840666f265bfe6b65c0c79838eef3e2aac..19f3e70c171bdb344136b92c748085911cfab0e9 100644 --- a/app/controllers/course/files.php +++ b/app/controllers/course/files.php @@ -50,7 +50,7 @@ class Course_FilesController extends AuthenticatedController $actions = new ActionsWidget(); - if ($this->topFolder->isEditable($GLOBALS['user']->id) && $this->topFolder->parent_id) { + if ($this->topFolder->isEditable($GLOBALS['user']->id)) { $actions->addLink( _("Ordner bearbeiten"), $this->url_for("file/edit_folder/".$this->topFolder->getId()), diff --git a/app/controllers/file.php b/app/controllers/file.php index 4895eabc4a01ef30b9cf39722562a2ecad4da57e..400126204304a644505c5713099c4b26f28638f1 100644 --- a/app/controllers/file.php +++ b/app/controllers/file.php @@ -1933,7 +1933,10 @@ class FileController extends AuthenticatedController throw new AccessDeniedException(); } $parent_folder = $folder->getParent(); - $folder_types = FileManager::getAvailableFolderTypes($parent_folder->range_id, $GLOBALS['user']->id); + $folder_types = FileManager::getAvailableFolderTypes( + $parent_folder ? $parent_folder->range_id : null, + $GLOBALS['user']->id + ); $this->name = Request::get('name', $folder->name); $this->description = Request::get('description', $folder->description); @@ -1942,7 +1945,7 @@ class FileController extends AuthenticatedController $this->folder_types = []; - if (!is_a($folder, 'VirtualFolderType')) { + if (!is_a($folder, 'VirtualFolderType') && $parent_folder) { foreach ($folder_types as $folder_type) { $folder_type_instance = new $folder_type( [ @@ -1952,15 +1955,21 @@ class FileController extends AuthenticatedController ] ); $this->folder_types[] = [ - 'class' => $folder_type, + 'class' => $folder_type, 'instance' => $folder_type_instance, - 'name' => $folder_type::getTypeName(), - 'icon' => $folder_type_instance->getIcon('clickable') + 'name' => $folder_type::getTypeName(), + 'icon' => $folder_type_instance->getIcon('clickable') ]; } + } elseif (!$parent_folder) { + $this->folder_types[] = [ + 'class' => get_class($folder), + 'instance' => $folder, + 'name' => $folder::getTypeName(), + 'icon' => $folder->getIcon('clickable') + ]; } - if (Request::submitted('edit')) { CSRFProtection::verifyUnsafeRequest(); if (!is_a($folder, 'VirtualFolderType')) { @@ -1973,7 +1982,9 @@ class FileController extends AuthenticatedController } } $request = Request::getInstance(); - $request->offsetSet('parent_id', $folder->getParent()->getId()); + if ($folder->getParent()) { + $request->offsetSet('parent_id', $folder->getParent()->getId()); + } $result = $folder->setDataFromEditTemplate($request); if ($result instanceof FolderType) { if ($folder->store()) { diff --git a/app/views/file/new_edit_folder_form.php b/app/views/file/new_edit_folder_form.php index 2c7a80188b8ef4cc169472a1bbfe676892280b5e..c1301d42fe0adf471b7d7398152489b7d6d8702d 100644 --- a/app/views/file/new_edit_folder_form.php +++ b/app/views/file/new_edit_folder_form.php @@ -1,3 +1,4 @@ +<? if (!is_a($folder, 'RootFolder')) : ?> <fieldset> <legend> <?= _('Ordnereigenschaften') ?> @@ -11,12 +12,15 @@ <textarea name="description" class="wysiwyg" placeholder="<?= _('Optionale Beschreibung') ?>"><?= htmlReady($description); ?></textarea> </label> </fieldset> +<? endif ?> -<? if (!is_a($folder, 'VirtualFolderType')): ?> +<? if (!is_a($folder, 'VirtualFolderType') && $folder_types && count($folder_types) > 0): ?> <fieldset class="select_terms_of_use"> + <? if (count($folder_types) > 1) : ?> <legend> <?= _('Ordnertyp auswählen') ?> </legend> + <? endif ?> <? foreach ($folder_types as $folder_type) : ?> <input type="radio" name="folder_type" value="<?= htmlReady($folder_type['class']) ?>" diff --git a/lib/filesystem/RootFolder.php b/lib/filesystem/RootFolder.php index 6c01e82f7f0d592843e0735f71d7b589b00cb711..dbdbc8b0d08b652483d90564884cc39dc4ff66af 100644 --- a/lib/filesystem/RootFolder.php +++ b/lib/filesystem/RootFolder.php @@ -48,7 +48,14 @@ class RootFolder extends StandardFolder public function isWritable($user_id) { return ($this->range_type === 'user' && $this->range_id === $user_id) - || Seminar_Perm::get()->have_studip_perm('autor', $this->range_id, $user_id); + || $this->isEditable($user_id) + || ( + Seminar_Perm::get()->have_studip_perm('autor', $this->range_id, $user_id) + && ( + !$this->folderdata['data_content'] + || !$this->folderdata['data_content']['locked'] + ) + ); } /** @@ -57,7 +64,7 @@ class RootFolder extends StandardFolder */ public function isEditable($user_id) { - return false; + return Seminar_Perm::get()->have_studip_perm('tutor', $this->range_id, $user_id); } /** @@ -77,4 +84,26 @@ class RootFolder extends StandardFolder $this->folderdata['parent_id'] = ''; return $this->folderdata->store(); } -} \ No newline at end of file + + /** + * @return Flexi_Template + */ + public function getEditTemplate() + { + $template = $GLOBALS['template_factory']->open('filesystem/root_folder/edit'); + $template->folder = $this; + return $template; + } + + /** + * @param array $request + * @return FolderType|MessageBox + */ + public function setDataFromEditTemplate($request) + { + $this->folderdata['data_content'] = [ + 'locked' => $request['locked'] ? 1 : 0 + ]; + return parent::setDataFromEditTemplate($request); + } +} diff --git a/templates/filesystem/root_folder/edit.php b/templates/filesystem/root_folder/edit.php new file mode 100644 index 0000000000000000000000000000000000000000..c22803b3bfcdc8521f9c1b5628d0ce79f11bf8db --- /dev/null +++ b/templates/filesystem/root_folder/edit.php @@ -0,0 +1,8 @@ +<label> + <input type="checkbox" + name="locked" + <?= $folder->data_content && $folder->data_content['locked'] ? 'checked' : '' ?> + value="1"> + <?= _('Upload für Studierende sperren') ?> +</label> +<?= _('Uploads sind weiterhin in entsprechenden Unterordnern möglich') ?>