Search in sources :

Example 16 with AccessMethodHandler

use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project openolat by klemens.

the class MainAccessController method methodChoosed.

protected void methodChoosed(UserRequest ureq, OfferAccess link) {
    if (link.getMethod().isNeedUserInteraction()) {
        AccessControlModule module = (AccessControlModule) CoreSpringFactory.getBean("acModule");
        AccessMethodHandler handler = module.getAccessMethodHandler(link.getMethod().getType());
        if (handler != null) {
            accessCtrl = handler.createAccessController(ureq, getWindowControl(), link, mainForm);
            listenTo(accessCtrl);
            flc.add("accessCmp", accessCtrl.getInitialFormItem());
        }
    } else {
        doAccessResource(ureq, link);
    }
}
Also used : AccessControlModule(org.olat.resource.accesscontrol.AccessControlModule) AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Example 17 with AccessMethodHandler

use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project openolat by klemens.

the class PublishStep01AccessForm method addConfiguration.

protected void addConfiguration(OfferAccess link) {
    AccessMethodHandler methodHandler = acModule.getAccessMethodHandler(link.getMethod().getType());
    AccessInfo infos = new AccessInfo(methodHandler.getMethodName(getLocale()), methodHandler.isPaymentMethod(), null, link);
    infos.setButtonId(button_id);
    confControllers.add(infos);
    if (editable) {
        FormLink editLink = uifactory.addFormLink("edit_" + infos.getButtonId(), "edit", "edit", null, confControllerContainer, Link.BUTTON_SMALL);
        editLink.setUserObject(infos);
        editLink.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
        confControllerContainer.add(editLink.getName(), editLink);
        FormLink delLink = uifactory.addFormLink("del_" + infos.getButtonId(), "delete", "delete", null, confControllerContainer, Link.BUTTON_SMALL);
        delLink.setUserObject(infos);
        delLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
        confControllerContainer.add(delLink.getName(), delLink);
    }
    updateConfirmationEmail();
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Example 18 with AccessMethodHandler

use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project OpenOLAT by OpenOLAT.

the class ACFrontendManager method getAvailableMethods.

@Override
public List<AccessMethod> getAvailableMethods(Identity identity, Roles roles) {
    List<AccessMethod> methods = methodManager.getAvailableMethods();
    List<AccessMethod> allowedMethods = new ArrayList<>();
    for (AccessMethod method : methods) {
        AccessMethodHandler handler = accessModule.getAccessMethodHandler(method.getType());
        AccessMethodSecurityCallback secCallback = handler.getSecurityCallback(identity, roles);
        if (secCallback.canUse()) {
            allowedMethods.add(method);
        }
    }
    return methods;
}
Also used : AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) AccessMethodSecurityCallback(org.olat.resource.accesscontrol.model.AccessMethodSecurityCallback) ArrayList(java.util.ArrayList) AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Example 19 with AccessMethodHandler

use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project OpenOLAT by OpenOLAT.

the class AccessMethodRenderer method render.

private void render(StringOutput sb, AccessMethod method, Set<String> uniqueType, Locale locale) {
    String type = method.getType();
    if (uniqueType.contains(type))
        return;
    uniqueType.add(type);
    AccessMethodHandler handler = acModule.getAccessMethodHandler(type);
    sb.append("<span class='o_nowrap'><i class='o_icon ");
    sb.append(method.getMethodCssClass());
    sb.append("_icon o_icon-lg'> </i> ");
    sb.append(handler.getMethodName(locale));
    sb.append("</span>");
}
Also used : AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Example 20 with AccessMethodHandler

use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project OpenOLAT by OpenOLAT.

the class MainAccessController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    backLink = uifactory.addFormLink("back", formLayout, Link.LINK_BACK);
    FormLayoutContainer methodChooseContainer = FormLayoutContainer.createDefaultFormLayout("methodChooser", getTranslator());
    methodChooseContainer.setRootForm(mainForm);
    formLayout.add("methodChooser", methodChooseContainer);
    for (OfferAccess link : links) {
        AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType());
        String methodName = handler.getMethodName(getLocale());
        FormLink accessButton = uifactory.addFormLink("m_" + link.getKey(), methodName, null, methodChooseContainer, Link.BUTTON + Link.NONTRANSLATED);
        accessButton.setUserObject(link);
        accessButtons.add(accessButton);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Aggregations

AccessMethodHandler (org.olat.resource.accesscontrol.method.AccessMethodHandler)38 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 OfferAccess (org.olat.resource.accesscontrol.OfferAccess)12 ArrayList (java.util.ArrayList)10 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)10 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)10 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 PriceMethod (org.olat.repository.ui.PriceMethod)8 OLATResource (org.olat.resource.OLATResource)8 Offer (org.olat.resource.accesscontrol.Offer)6 OLATResourceAccess (org.olat.resource.accesscontrol.model.OLATResourceAccess)6 PriceMethodBundle (org.olat.resource.accesscontrol.model.PriceMethodBundle)6 Date (java.util.Date)4 HelpTooltip (org.olat.core.gui.components.helpTooltip.HelpTooltip)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 AccessResult (org.olat.resource.accesscontrol.AccessResult)4 AccessTransaction (org.olat.resource.accesscontrol.AccessTransaction)4 HashSet (java.util.HashSet)2