use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentTestStatisticsController method printPages.
private void printPages(UserRequest ureq) {
ControllerCreator printControllerCreator = new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
return new QTI21PrintController(lureq, lwControl, resourceResult);
}
};
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createPrintPopupLayout(printControllerCreator);
openInNewBrowserWindow(ureq, layoutCtrlr);
}
use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class SPRunController method doInlineIntegration.
private void doInlineIntegration(UserRequest ureq, boolean hasEditRightsTo) {
boolean allowRelativeLinks = config.getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
// create the possibility to float
OLATResourceable ores = OresHelper.createOLATResourceableInstance(ICourse.class, userCourseEnv.getCourseEnvironment().getCourseResourceableId());
DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS);
spCtr = new SinglePageController(ureq, getWindowControl(), courseFolderContainer, fileName, allowRelativeLinks, null, ores, deliveryOptions, userCourseEnv.getCourseEnvironment().isPreview());
spCtr.setAllowDownload(true);
// only for inline integration: register for controller event to forward a olatcmd to the course,
// and also to remember latest position in the script
listenTo(spCtr);
// enable edit mode if user has the according rights
if (hasEditRightsTo) {
spCtr.allowPageEditing();
// set the link tree model to internal for the HTML editor
if (linkTreeModel != null) {
spCtr.setInternalLinkTreeModel(linkTreeModel);
}
}
// create clone wrapper layout
CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {
public ControllerCreator createLayoutControllerCreator(UserRequest uureq, final ControllerCreator contentControllerCreator) {
return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
// Wrap in column layout, popup window needs a layout controller
Controller ctr = contentControllerCreator.createController(lureq, lwControl);
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), userCourseEnv.getCourseEnvironment()));
// Controller titledCtrl = TitledWrapperHelper.getWrapper(lureq, lwControl, ctr, courseNode, "o_sp_icon");
layoutCtr.addDisposableChildController(ctr);
return layoutCtr;
}
});
}
};
Controller ctrl = TitledWrapperHelper.getWrapper(ureq, getWindowControl(), spCtr, courseNode, "o_sp_icon");
if (ctrl instanceof CloneableController) {
cloneC = new CloneController(ureq, getWindowControl(), (CloneableController) ctrl, clccc);
listenTo(cloneC);
main.setContent(cloneC.getInitialComponent());
} else {
throw new AssertException("Controller must be cloneable");
}
}
use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class ForumCourseNodeWebService method getForumContent.
@Path("{nodeId}/forum")
public ForumWebService getForumContent(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest request) {
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
} else if (!CourseWebService.isCourseAccessible(course, false, request)) {
throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
}
CourseNode courseNode = course.getRunStructure().getNode(nodeId);
if (courseNode == null || !(courseNode instanceof FOCourseNode)) {
throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
}
UserRequest ureq = getUserRequest(request);
CourseTreeVisitor courseVisitor = new CourseTreeVisitor(course, ureq.getUserSession().getIdentityEnvironment());
if (courseVisitor.isAccessible(courseNode, new VisibleTreeFilter())) {
FOCourseNode forumNode = (FOCourseNode) courseNode;
Forum forum = forumNode.loadOrCreateForum(course.getCourseEnvironment());
return new ForumWebService(forum);
} else {
throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
}
}
use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class ForumCourseNodeWebService method getForums.
/**
* Retrieves metadata of the published course node
* @response.representation.200.qname {http://www.example.com}forumVOes
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The course node metadatas
* @response.representation.200.example {@link org.olat.modules.fo.restapi.Examples#SAMPLE_FORUMVOes}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or parentNode not found
* @param courseId The course resourceable's id
* @param httpRequest The HTTP request
* @return The persisted structure element (fully populated)
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getForums(@PathParam("courseId") Long courseId, @Context HttpServletRequest httpRequest) {
final ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
} else if (!CourseWebService.isCourseAccessible(course, false, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
UserRequest ureq = getUserRequest(httpRequest);
final Set<Long> subcribedForums = new HashSet<Long>();
NotificationsManager man = NotificationsManager.getInstance();
List<String> notiTypes = Collections.singletonList("Forum");
List<Subscriber> subs = man.getSubscribers(ureq.getIdentity(), notiTypes);
for (Subscriber sub : subs) {
Long forumKey = Long.parseLong(sub.getPublisher().getData());
subcribedForums.add(forumKey);
}
final List<ForumVO> forumVOs = new ArrayList<ForumVO>();
new CourseTreeVisitor(course, ureq.getUserSession().getIdentityEnvironment()).visit(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof FOCourseNode) {
FOCourseNode forumNode = (FOCourseNode) node;
ForumVO forum = createForumVO(course, forumNode, subcribedForums);
forumVOs.add(forum);
}
}
}, new VisibleTreeFilter());
ForumVOes voes = new ForumVOes();
voes.setForums(forumVOs.toArray(new ForumVO[forumVOs.size()]));
voes.setTotalCount(forumVOs.size());
return Response.ok(voes).build();
}
use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class MediaDetailsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("title", StringHelper.escapeHtml(media.getTitle()));
layoutCont.contextPut("description", StringHelper.xssScan(media.getDescription()));
layoutCont.contextPut("iconCssClass", handler.getIconCssClass(media));
mediaCtrl = handler.getMediaController(ureq, getWindowControl(), media, new StandardMediaRenderingHints());
if (mediaCtrl != null) {
listenTo(mediaCtrl);
layoutCont.put("media", mediaCtrl.getInitialComponent());
}
String metaPage = velocity_root + "/media_details_metadata.html";
FormLayoutContainer metaCont = FormLayoutContainer.createCustomFormLayout("meta", getTranslator(), metaPage);
layoutCont.add("meta", metaCont);
metaCont.setRootForm(mainForm);
metaCont.contextPut("media", media);
String author = userManager.getUserDisplayName(media.getAuthor());
metaCont.contextPut("author", author);
if (media.getCollectionDate() != null) {
String collectionDate = Formatter.getInstance(getLocale()).formatDate(media.getCollectionDate());
metaCont.contextPut("collectionDate", collectionDate);
}
if (media.getBusinessPath() != null) {
gotoOriginalLink = LinkFactory.createLink("goto.original", metaCont.getFormItemComponent(), this);
}
if (StringHelper.containsNonWhitespace(media.getMetadataXml())) {
Object metadata = MetadataXStream.get().fromXML(media.getMetadataXml());
metaCont.contextPut("metadata", metadata);
}
List<Category> categories = portfolioService.getCategories(media);
if (categories != null && categories.size() > 0) {
Map<String, String> categoriesMap = categories.stream().collect(Collectors.toMap(c -> c.getName(), c -> c.getName()));
TextBoxListElement categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categoriesMap, metaCont, getTranslator());
categoriesEl.setHelpText(translate("categories.hint"));
categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
categoriesEl.setEnabled(false);
}
List<FormLink> binderLinks = new ArrayList<>(usedInList.size());
Set<Long> binderUniqueKeys = new HashSet<>();
for (BinderPageUsage binder : usedInList) {
if (binderUniqueKeys.contains(binder.getBinderKey()))
continue;
FormLink link;
if (binder.getBinderKey() == null) {
link = uifactory.addFormLink("binder_" + (++counter), "page", binder.getPageTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
binderUniqueKeys.add(binder.getPageKey());
} else {
link = uifactory.addFormLink("binder_" + (++counter), "binder", binder.getBinderTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
binderUniqueKeys.add(binder.getBinderKey());
}
link.setUserObject(binder);
binderLinks.add(link);
}
metaCont.contextPut("binderLinks", binderLinks);
}
}
Aggregations