use of org.olat.core.commons.modules.glossary.GlossaryMainController in project OpenOLAT by OpenOLAT.
the class CourseGlossaryFactory method createCourseGlossaryMainRunController.
/**
* The glossarymaincontroller allows browsing in the glossary. A flag enables
* the edit mode.
*
* @param windowControl
* @param ureq
* @param courseConfig use the glossary configuration from the given course
* configuration
* @param hasGlossaryEditRights
* @return
*/
public static GlossaryMainController createCourseGlossaryMainRunController(WindowControl lwControl, UserRequest lureq, CourseConfig cc, boolean hasGlossaryRights) {
if (cc.hasGlossary()) {
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
if (repoEntry == null) {
// seems to be removed
return null;
}
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
boolean owner = repositoryService.hasRole(lureq.getIdentity(), repoEntry, GroupRoles.owner.name());
VFSContainer glossaryFolder = GlossaryManager.getInstance().getGlossaryRootFolder(repoEntry.getOlatResource());
Properties glossProps = GlossaryItemManager.getInstance().getGlossaryConfig(glossaryFolder);
boolean editUsersEnabled = "true".equals(glossProps.getProperty(GlossaryItemManager.EDIT_USERS));
GlossarySecurityCallback secCallback;
if (lureq.getUserSession().getRoles().isGuestOnly()) {
secCallback = new GlossarySecurityCallbackImpl();
} else {
secCallback = new GlossarySecurityCallbackImpl(hasGlossaryRights, owner, editUsersEnabled, lureq.getIdentity().getKey());
}
return new GlossaryMainController(lwControl, lureq, glossaryFolder, repoEntry.getOlatResource(), secCallback, true);
}
return null;
}
use of org.olat.core.commons.modules.glossary.GlossaryMainController in project openolat by klemens.
the class CourseRuntimeController method launchGlossary.
private void launchGlossary(UserRequest ureq) {
// start glossary in window
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
// do not cache cc, not save
final CourseConfig cc = course.getCourseConfig();
final boolean allowGlossaryEditing = reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GLOSSARY);
// if glossary had been opened from LR as Tab before, warn user:
DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
DTab dt = dts.getDTab(repoEntry.getOlatResource());
if (dt != null) {
List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
dts.activate(ureq, dt, entries);
} else {
ControllerCreator ctrlCreator = new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController(lwControl, lureq, cc, allowGlossaryEditing);
listenTo(glossaryController);
if (glossaryController == null) {
// happens in the unlikely event of a user who is in a course and
// now
// tries to access the glossary
String text = translate("error.noglossary");
return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
} else {
// use a one-column main layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController);
// dispose glossary on layout dispose
layoutCtr.addDisposableChildController(glossaryController);
return layoutCtr;
}
}
};
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
// open in new browser window
openInNewBrowserWindow(ureq, layoutCtrlr);
// immediate return after opening new browser window!
return;
}
}
use of org.olat.core.commons.modules.glossary.GlossaryMainController in project openolat by klemens.
the class CourseGlossaryFactory method createCourseGlossaryMainRunController.
/**
* The glossarymaincontroller allows browsing in the glossary. A flag enables
* the edit mode.
*
* @param windowControl
* @param ureq
* @param courseConfig use the glossary configuration from the given course
* configuration
* @param hasGlossaryEditRights
* @return
*/
public static GlossaryMainController createCourseGlossaryMainRunController(WindowControl lwControl, UserRequest lureq, CourseConfig cc, boolean hasGlossaryRights) {
if (cc.hasGlossary()) {
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
if (repoEntry == null) {
// seems to be removed
return null;
}
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
boolean owner = repositoryService.hasRole(lureq.getIdentity(), repoEntry, GroupRoles.owner.name());
VFSContainer glossaryFolder = GlossaryManager.getInstance().getGlossaryRootFolder(repoEntry.getOlatResource());
Properties glossProps = GlossaryItemManager.getInstance().getGlossaryConfig(glossaryFolder);
boolean editUsersEnabled = "true".equals(glossProps.getProperty(GlossaryItemManager.EDIT_USERS));
GlossarySecurityCallback secCallback;
if (lureq.getUserSession().getRoles().isGuestOnly()) {
secCallback = new GlossarySecurityCallbackImpl();
} else {
secCallback = new GlossarySecurityCallbackImpl(hasGlossaryRights, owner, editUsersEnabled, lureq.getIdentity().getKey());
}
return new GlossaryMainController(lwControl, lureq, glossaryFolder, repoEntry.getOlatResource(), secCallback, true);
}
return null;
}
use of org.olat.core.commons.modules.glossary.GlossaryMainController in project OpenOLAT by OpenOLAT.
the class GlossaryHandler method createEditorController.
@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl wControl, TooledStackedPanel toolbar) {
VFSContainer glossaryFolder = GlossaryManager.getInstance().getGlossaryRootFolder(re.getOlatResource());
Properties glossProps = GlossaryItemManager.getInstance().getGlossaryConfig(glossaryFolder);
boolean editableByUser = "true".equals(glossProps.getProperty(GlossaryItemManager.EDIT_USERS));
GlossarySecurityCallback secCallback;
if (ureq.getUserSession().getRoles().isGuestOnly()) {
secCallback = new GlossarySecurityCallbackImpl();
} else {
secCallback = new GlossarySecurityCallbackImpl(true, true, editableByUser, ureq.getIdentity().getKey());
}
GlossaryMainController gctr = new GlossaryMainController(wControl, ureq, glossaryFolder, re.getOlatResource(), secCallback, false);
// use on column layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(ureq, wControl, gctr);
// dispose content on layout dispose
layoutCtr.addDisposableChildController(gctr);
return layoutCtr;
}
use of org.olat.core.commons.modules.glossary.GlossaryMainController in project OpenOLAT by OpenOLAT.
the class CourseRuntimeController method launchGlossary.
private void launchGlossary(UserRequest ureq) {
// start glossary in window
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
// do not cache cc, not save
final CourseConfig cc = course.getCourseConfig();
final boolean allowGlossaryEditing = reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GLOSSARY);
// if glossary had been opened from LR as Tab before, warn user:
DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
DTab dt = dts.getDTab(repoEntry.getOlatResource());
if (dt != null) {
List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
dts.activate(ureq, dt, entries);
} else {
ControllerCreator ctrlCreator = new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController(lwControl, lureq, cc, allowGlossaryEditing);
listenTo(glossaryController);
if (glossaryController == null) {
// happens in the unlikely event of a user who is in a course and
// now
// tries to access the glossary
String text = translate("error.noglossary");
return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
} else {
// use a one-column main layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController);
// dispose glossary on layout dispose
layoutCtr.addDisposableChildController(glossaryController);
return layoutCtr;
}
}
};
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
// open in new browser window
openInNewBrowserWindow(ureq, layoutCtrlr);
// immediate return after opening new browser window!
return;
}
}
Aggregations