Search in sources :

Example 1 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, AccessTransaction transaction, Set<String> uniqueType, Locale locale) {
    String type = transaction.getMethod().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(transaction.getMethod().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 2 with AccessMethodHandler

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

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 3 with AccessMethodHandler

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

the class ACFrontendManager method accessResource.

@Override
public AccessResult accessResource(Identity identity, OfferAccess link, Object argument) {
    if (link == null || link.getOffer() == null || link.getMethod() == null) {
        log.audit("Access refused (no offer) to: " + link + " for " + identity);
        return new AccessResult(false);
    }
    AccessMethodHandler handler = accessModule.getAccessMethodHandler(link.getMethod().getType());
    if (handler == null) {
        log.audit("Access refused (no handler method) to: " + link + " for " + identity);
        return new AccessResult(false);
    }
    if (handler.checkArgument(link, argument)) {
        if (allowAccesToResource(identity, link.getOffer())) {
            Order order = orderManager.saveOneClick(identity, link);
            AccessTransaction transaction = transactionManager.createTransaction(order, order.getParts().get(0), link.getMethod());
            transactionManager.save(transaction);
            dbInstance.commit();
            log.audit("Access granted to: " + link + " for " + identity);
            return new AccessResult(true);
        } else {
            log.audit("Access error to: " + link + " for " + identity);
        }
    } else {
        log.audit("Access refused to: " + link + " for " + identity);
    }
    return new AccessResult(false);
}
Also used : Order(org.olat.resource.accesscontrol.Order) AccessTransaction(org.olat.resource.accesscontrol.AccessTransaction) AccessResult(org.olat.resource.accesscontrol.AccessResult) AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Example 4 with AccessMethodHandler

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

the class AccessConfigurationController method addConfiguration.

protected void addConfiguration(OfferAccess link) {
    AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType());
    AccessInfo infos = new AccessInfo(handler.getMethodName(getLocale()), handler.isPaymentMethod(), null, link);
    confControllers.add(infos);
    if (editable) {
        FormLink editLink = uifactory.addFormLink("edit_" + link.getKey(), "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_" + link.getKey(), "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 5 with AccessMethodHandler

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

the class AccessConfigurationController method editMethod.

private void editMethod(UserRequest ureq, AccessInfo infos) {
    OfferAccess link = infos.getLink();
    removeAsListenerAndDispose(editMethodCtrl);
    AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType());
    if (handler != null) {
        editMethodCtrl = handler.editConfigurationController(ureq, getWindowControl(), link);
    }
    if (editMethodCtrl != null) {
        listenTo(editMethodCtrl);
        String title = handler.getMethodName(getLocale());
        cmc = new CloseableModalController(getWindowControl(), translate("close"), editMethodCtrl.getInitialComponent(), true, title);
        cmc.activate();
        listenTo(cmc);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) 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