Skip to content
Snippets Groups Projects
Commit cb5e6a9a authored by gnaegi's avatar gnaegi
Browse files

OO-1988 don't show course resource folders to learners

parent 37781e11
No related branches found
No related tags found
No related merge requests found
...@@ -85,9 +85,10 @@ public interface ICourse extends OLATResourceable { ...@@ -85,9 +85,10 @@ public interface ICourse extends OLATResourceable {
public OlatRootFolderImpl getCourseBaseContainer(); public OlatRootFolderImpl getCourseBaseContainer();
/** /**
* Return the container to the coursefolder of this course. * Return the container to the coursefolder of this course. (E.g.
* (E.g. "COURSEBASEPATH/coursefolder/"). This is for administration * "COURSEBASEPATH/coursefolder/"). !! This is for administration or
* use. There is no permission check. * internal use!! There is no permission check, make sure your controller
* does check if user is allowed to see stuff, e.g. shared folder
* *
* @return the container to the coursefolder of this course * @return the container to the coursefolder of this course
*/ */
...@@ -95,7 +96,7 @@ public interface ICourse extends OLATResourceable { ...@@ -95,7 +96,7 @@ public interface ICourse extends OLATResourceable {
/** /**
* The course folder that the user specified by its identity environment * The course folder that the user specified by its identity environment
* can see and use. * can see and use. Used by WebDAV access.
* *
* @param identityEnv * @param identityEnv
* @return The aggreagted course folder * @return The aggreagted course folder
......
...@@ -81,11 +81,12 @@ public class MergedCourseContainer extends MergeSource { ...@@ -81,11 +81,12 @@ public class MergedCourseContainer extends MergeSource {
protected void init(PersistingCourseImpl persistingCourse) { protected void init(PersistingCourseImpl persistingCourse) {
super.init(); super.init();
RepositoryEntry re = null;
if(identityEnv == null || identityEnv.getRoles().isOLATAdmin()) { if(identityEnv == null || identityEnv.getRoles().isOLATAdmin()) {
addContainersChildren(persistingCourse.getIsolatedCourseFolder(), true); addContainersChildren(persistingCourse.getIsolatedCourseFolder(), true);
} else { } else {
RepositoryEntry re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry(); re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
RepositoryEntrySecurity reSecurity = RepositoryManager.getInstance() RepositoryEntrySecurity reSecurity = RepositoryManager.getInstance()
.isAllowed(identityEnv.getIdentity(), identityEnv.getRoles(), re); .isAllowed(identityEnv.getIdentity(), identityEnv.getRoles(), re);
if(reSecurity.isEntryAdmin()) { if(reSecurity.isEntryAdmin()) {
...@@ -93,18 +94,25 @@ public class MergedCourseContainer extends MergeSource { ...@@ -93,18 +94,25 @@ public class MergedCourseContainer extends MergeSource {
} }
} }
// grab any shared folder that is configured // grab any shared folder that is configured, but only when in unchecked
// security mode (no identity environment) or when the user has course
// admin rights
OlatRootFolderImpl sharedFolder = null; OlatRootFolderImpl sharedFolder = null;
String sfSoftkey = persistingCourse.getCourseConfig().getSharedFolderSoftkey(); String sfSoftkey = persistingCourse.getCourseConfig().getSharedFolderSoftkey();
if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) { if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) {
OLATResource sharedResource = CoreSpringFactory.getImpl(RepositoryService.class) if (re == null) {
.loadRepositoryEntryResourceBySoftKey(sfSoftkey); // reuse if already loaded, else load
if (sharedResource != null) { re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
sharedFolder = SharedFolderManager.getInstance().getSharedFolder(sharedResource); }
if (sharedFolder != null) { if(identityEnv == null || identityEnv.getRoles().isOLATAdmin() || RepositoryManager.getInstance().isOwnerOfRepositoryEntry(identityEnv.getIdentity(), re)) {
sharedFolder.setLocalSecurityCallback(new ReadOnlyCallback()); OLATResource sharedResource = CoreSpringFactory.getImpl(RepositoryService.class).loadRepositoryEntryResourceBySoftKey(sfSoftkey);
//add local course folder's children as read/write source and any sharedfolder as subfolder if (sharedResource != null) {
addContainer(new NamedContainerImpl("_sharedfolder", sharedFolder)); sharedFolder = SharedFolderManager.getInstance().getSharedFolder(sharedResource);
if (sharedFolder != null) {
sharedFolder.setLocalSecurityCallback(new ReadOnlyCallback());
//add local course folder's children as read/write source and any sharedfolder as subfolder
addContainer(new NamedContainerImpl("_sharedfolder", sharedFolder));
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment