protected void addMethod(UserRequest ureq, AccessMethod method) { Offer offer = acService.createOffer(resource, displayName); OfferAccess link = acService.createOfferAccess(offer, method); removeAsListenerAndDispose(newMethodCtrl); AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType()); if (handler != null) { newMethodCtrl = handler.createConfigurationController(ureq, getWindowControl(), link); } if (newMethodCtrl != null) { listenTo(newMethodCtrl); String title = handler.getMethodName(getLocale()); cmc = new CloseableModalController( getWindowControl(), translate("close"), newMethodCtrl.getInitialComponent(), true, title); cmc.activate(); listenTo(cmc); } else { OfferAccess newLink = acService.saveOfferAccess(link); addConfiguration(newLink); } }
@Override protected void event(UserRequest ureq, Controller source, Event event) { if (newMethodCtrl == source) { if (event.equals(Event.DONE_EVENT)) { OfferAccess newLink = newMethodCtrl.commitChanges(); newLink = acService.saveOfferAccess(newLink); addConfiguration(newLink); fireEvent(ureq, Event.CHANGED_EVENT); } cmc.deactivate(); cleanUp(); } else if (editMethodCtrl == source) { if (event.equals(Event.DONE_EVENT)) { OfferAccess newLink = editMethodCtrl.commitChanges(); newLink = acService.saveOfferAccess(newLink); replace(newLink); fireEvent(ureq, Event.CHANGED_EVENT); } cmc.deactivate(); cleanUp(); } else if (cmc == source) { cleanUp(); } else { super.event(ureq, source, event); } }
protected void loadConfigurations() { List<Offer> offers = acService.findOfferByResource(resource, true, null); for (Offer offer : offers) { List<OfferAccess> offerAccess = acService.getOfferAccess(offer, true); for (OfferAccess access : offerAccess) { addConfiguration(access); } } }
private GenericTreeModel buildTreeModel() { GenericTreeModel gtm = new GenericTreeModel(); GenericTreeNode root = new GenericTreeNode(); root.setTitle(translate("menu.members")); root.setAltText(translate("menu.members.alt")); gtm.setRootNode(root); GenericTreeNode node = new GenericTreeNode(translate("menu.members"), CMD_MEMBERS); node.setAltText(translate("menu.members.alt")); root.addChild(node); node = new GenericTreeNode(translate("menu.groups"), CMD_GROUPS); node.setAltText(translate("menu.groups.alt")); root.addChild(node); if (acModule.isEnabled()) { // check if the course is managed and/or has offers if (!RepositoryEntryManagedFlag.isManaged(repoEntry, RepositoryEntryManagedFlag.bookings) || acService.isResourceAccessControled(repoEntry.getOlatResource(), null)) { node = new GenericTreeNode(translate("menu.orders"), CMD_BOOKING); node.setAltText(translate("menu.orders.alt")); root.addChild(node); } } node = new GenericTreeNode(translate("menu.rights"), CMD_RIGHTS); node.setAltText(translate("menu.rights.alt")); root.addChild(node); return gtm; }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { if (editable) { List<AccessMethod> methods = acService.getAvailableMethods(getIdentity(), ureq.getUserSession().getRoles()); for (AccessMethod method : methods) { AccessMethodHandler handler = acModule.getAccessMethodHandler(method.getType()); if (handler.isPaymentMethod() && !allowPaymentMethod) { continue; } String title = handler.getMethodName(getLocale()); FormLink add = uifactory.addFormLink( "create." + handler.getType(), title, null, formLayout, Link.LINK | Link.NONTRANSLATED); add.setUserObject(method); add.setIconLeftCSS(("o_icon " + method.getMethodCssClass() + "_icon o_icon-lg").intern()); addMethods.add(add); formLayout.add(add.getName(), add); } ((FormLayoutContainer) formLayout).contextPut("methods", addMethods); } String confPage = velocity_root + "/configuration_list.html"; confControllerContainer = FormLayoutContainer.createCustomFormLayout("conf-controllers", getTranslator(), confPage); confControllerContainer.setRootForm(mainForm); formLayout.add(confControllerContainer); loadConfigurations(); confControllerContainer.contextPut("confControllers", confControllers); if (!embbed) { setFormTitle("accesscontrol.title"); setFormContextHelp( AccessConfigurationController.class.getPackage().getName(), "accesscontrol.html", "chelp.accesscontrol.hover"); if (editable) { final FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator()); buttonGroupLayout.setRootForm(mainForm); formLayout.add(buttonGroupLayout); formLayout.add("buttonLayout", buttonGroupLayout); uifactory.addFormSubmitButton("save", buttonGroupLayout); } } confControllerContainer.contextPut( "emptyConfigGrantsFullAccess", Boolean.valueOf(emptyConfigGrantsFullAccess)); }
@Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if (addMethods.contains(source)) { AccessMethod method = (AccessMethod) source.getUserObject(); addMethod(ureq, method); } else if (source instanceof FormLink) { FormLink button = (FormLink) source; String cmd = button.getCmd(); if ("delete".equals(cmd)) { AccessInfo infos = (AccessInfo) source.getUserObject(); acService.deleteOffer(infos.getLink().getOffer()); confControllers.remove(infos); } else if ("edit".equals(cmd)) { AccessInfo infos = (AccessInfo) source.getUserObject(); editMethod(ureq, infos); } } super.formInnerEvent(ureq, source, event); }