use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class GoToMeetingCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller controller;
Roles roles = ureq.getUserSession().getRoles();
if (roles.isGuestOnly()) {
Translator trans = Util.createPackageTranslator(GoToMeetingEditController.class, ureq.getLocale());
String title = trans.translate("guestnoaccess.title");
String message = trans.translate("guestnoaccess.message");
controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
} else {
// check if user is moderator of the virtual classroom
boolean admin = roles.isOLATAdmin();
boolean moderator = admin;
RepositoryEntry re = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (!admin) {
RepositoryManager rm = RepositoryManager.getInstance();
if (re != null) {
admin = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re) || rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), roles, re);
moderator = admin || rm.isIdentityInTutorSecurityGroup(ureq.getIdentity(), re) || isCoach(re, ureq.getIdentity());
}
}
// create run controller
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
controller = new GoToMeetingRunController(ureq, wControl, courseEntry, getIdent(), null, admin, moderator, userCourseEnv.isCourseReadOnly());
}
Controller ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_gotomeeting_icon");
return new NodeRunConstructionResult(ctrl);
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class CourseSiteContextEntryControllerCreator method getRepositoryEntry.
private RepositoryEntry getRepositoryEntry(UserRequest ureq, ContextEntry ce) {
if (repoEntry == null) {
if (ce.getOLATResourceable() instanceof RepositoryEntry) {
repoEntry = (RepositoryEntry) ce.getOLATResourceable();
} else {
OLATResourceable ores = ce.getOLATResourceable();
if ("CourseSite".equals(ores.getResourceableTypeName())) {
int id = ores.getResourceableId().intValue();
CourseSiteDef courseSiteDef = null;
List<SiteDefinition> siteDefList = getSitesDefinitions().getSiteDefList();
if (id == 2) {
for (SiteDefinition siteDef : siteDefList) {
if (siteDef instanceof CourseSiteDef2) {
courseSiteDef = (CourseSiteDef) siteDef;
}
}
} else if (id == 1) {
for (SiteDefinition siteDef : siteDefList) {
if (siteDef instanceof CourseSiteDef) {
courseSiteDef = (CourseSiteDef) siteDef;
}
}
}
if (courseSiteDef != null) {
CourseSiteConfiguration config = courseSiteDef.getCourseSiteconfiguration();
LanguageConfiguration langConfig = courseSiteDef.getLanguageConfiguration(ureq, config);
if (langConfig != null) {
String softKey = langConfig.getRepoSoftKey();
RepositoryManager rm = RepositoryManager.getInstance();
repoEntry = rm.lookupRepositoryEntryBySoftkey(softKey, false);
}
}
} else {
RepositoryManager rm = RepositoryManager.getInstance();
repoEntry = rm.lookupRepositoryEntry(ores.getResourceableId());
}
}
}
return repoEntry;
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class CourseSiteContextEntryControllerCreator method createLaunchController.
/**
* Create a launch controller used to launch the given repo entry.
* @param re
* @param initialViewIdentifier if null the default view will be started, otherwise a controllerfactory type dependant view will be activated (subscription subtype)
* @param ureq
* @param wControl
* @return null if no entry was found, a no access message controller if not allowed to launch or the launch
* controller if successful.
*/
private Controller createLaunchController(RepositoryEntry re, UserRequest ureq, WindowControl wControl) {
if (re == null) {
return messageController(ureq, wControl, "repositoryentry.not.existing");
}
UserSession usess = ureq.getUserSession();
if (re.getAccess() == RepositoryEntry.DELETED) {
Roles roles = usess.getRoles();
if (!roles.isInstitutionalResourceManager() && !roles.isOLATAdmin()) {
return messageController(ureq, wControl, "repositoryentry.deleted");
}
}
if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(re.getOlatResource())) {
return null;
}
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, re);
if (!reSecurity.canLaunch()) {
return messageController(ureq, wControl, "launch.noaccess");
}
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
rs.incrementLaunchCounter(re);
RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(re);
WindowControl bwControl;
OLATResourceable businessOres = re;
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(businessOres);
if (ce.equals(wControl.getBusinessControl().getCurrentContextEntry())) {
bwControl = wControl;
} else {
bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
}
MainLayoutController ctrl = handler.createLaunchController(re, reSecurity, ureq, bwControl);
if (ctrl == null) {
throw new AssertException("could not create controller for repositoryEntry " + re);
}
return ctrl;
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class CourseSite method createController.
@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
if (entry == null) {
return getAlternativeController(ureq, wControl, config);
}
MainLayoutController c;
ICourse course = CourseFactory.loadCourse(entry);
UserSession usess = ureq.getUserSession();
// course-launch-state depending course-settings
RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, entry);
boolean isAllowedToLaunch = reSecurity.canLaunch();
boolean hasAccess = false;
if (isAllowedToLaunch) {
// either check with securityCallback or use access-settings from course-nodes
if (siteSecCallback != null) {
hasAccess = siteSecCallback.isAllowedToLaunchSite(ureq);
} else if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(course)) {
hasAccess = false;
} else {
// check within course: accessibility of course root node
CourseNode rootNode = course.getRunStructure().getRootNode();
UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
hasAccess = mayAccessWholeTreeUp && nodeEval.isVisible();
}
}
// load course (admins always see content) or alternative controller if course is not launchable
if (hasAccess || usess.getRoles().isOLATAdmin()) {
rs.incrementLaunchCounter(entry);
// build up the context path for linked course
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, entry, new StateSite(this), wControl, true);
CourseRuntimeController runCtr = new CourseRuntimeController(ureq, bwControl, entry, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry re, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
return new RunMainController(uureq, wwControl, toolbarPanel, CourseFactory.loadCourse(re), re, security, assessmentMode);
}
}, false, true);
// Configure run controller
// a: don't show close link, is opened as site not tab
runCtr.setCourseCloseEnabled(false);
// b: don't show toolbar
if (!showToolController) {
runCtr.setToolControllerEnabled(false);
}
c = runCtr;
} else {
// access restricted (not in group / author) -> show controller
// defined in olat_extensions (type autoCreator)
c = getAlternativeController(ureq, wControl, config);
}
return c;
}
use of org.olat.repository.RepositoryManager in project openolat by klemens.
the class WikiEditController method getWikiReference.
/**
* @param config the moduleConfig
* @param strict an assertion exception is thrown if no entry is found when
* strict is set to true, otherwise, null is returned
* @return the repositoryentry or null if not in strict mode and no entry
* found
* @throws AssertException when in strict mode and no entry is found
*/
public static RepositoryEntry getWikiReference(ModuleConfiguration config, boolean strict) {
if (config == null) {
if (strict)
throw new AssertException("missing config in Wiki");
else
return null;
}
String repoSoftkey = (String) config.get(WikiEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
if (repoSoftkey == null) {
if (strict)
throw new AssertException("invalid config when being asked for references");
else
return null;
}
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repoSoftkey, strict);
// entry can be null only if !strict
return entry;
}
Aggregations