Search in sources :

Example 36 with AccessMethodHandler

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

the class PublishStep01AccessForm method addMethod.

protected void addMethod(UserRequest ureq, AccessMethod method) {
    Offer offer = acService.createOffer(resource, displayName);
    OfferAccess link = acService.createOfferAccess(offer, method);
    removeAsListenerAndDispose(newMethodCtrl);
    AccessMethodHandler methodHandler = acModule.getAccessMethodHandler(link.getMethod().getType());
    if (methodHandler != null) {
        newMethodCtrl = methodHandler.createConfigurationController(ureq, getWindowControl(), link);
    }
    if (newMethodCtrl != null) {
        listenTo(newMethodCtrl);
        String title = methodHandler.getMethodName(getLocale());
        cmc = new CloseableModalController(getWindowControl(), translate("close"), newMethodCtrl.getInitialComponent(), true, title);
        cmc.activate();
        listenTo(cmc);
    } else {
        if (!offerAccess.contains(link)) {
            offerAccess.add(link);
        }
        addConfiguration(link);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) Offer(org.olat.resource.accesscontrol.Offer) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) AccessMethodHandler(org.olat.resource.accesscontrol.method.AccessMethodHandler)

Example 37 with AccessMethodHandler

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

the class PublishStep01AccessForm method editMethod.

private void editMethod(UserRequest ureq, AccessInfo infos) {
    OfferAccess link = infos.getLink();
    removeAsListenerAndDispose(editMethodCtrl);
    AccessMethodHandler methodHandler = acModule.getAccessMethodHandler(link.getMethod().getType());
    if (methodHandler != null) {
        editMethodCtrl = methodHandler.editConfigurationController(ureq, getWindowControl(), link);
    }
    if (editMethodCtrl != null) {
        listenTo(editMethodCtrl);
        String title = methodHandler.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)

Example 38 with AccessMethodHandler

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

the class PublishStep01AccessForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer headersLayout = FormLayoutContainer.createCustomFormLayout("access", getTranslator(), velocity_root + "/publish_courseaccess.html");
    formLayout.add(headersLayout);
    headersLayout.contextPut("catalogEnabled", repositoryModule.isCatalogEnabled());
    FormLayoutContainer publishLayout = FormLayoutContainer.createDefaultFormLayout("publish", getTranslator());
    formLayout.add(publishLayout);
    publishLayout.setFormTitle(translate("rentry.publish"));
    publishLayout.setFormContextHelp("Course Settings#_zugriff");
    publishLayout.setElementCssClass("o_sel_repositoryentry_access");
    if (loginModule.isGuestLoginLinksEnabled()) {
        publishedKeys = new String[] { OAU_KEY, OAUG_KEY, MEMBERSONLY_KEY };
    } else {
        publishedKeys = new String[] { OAU_KEY, MEMBERSONLY_KEY };
    }
    String resourceType = entry.getOlatResource().getResourceableTypeName();
    if (TestFileResource.TYPE_NAME.equals(resourceType) || SurveyFileResource.TYPE_NAME.equals(resourceType) || ScormCPFileResource.TYPE_NAME.equals(resourceType)) {
        String warning = translate("warn.resource.need.course");
        flc.contextPut("off_warn", warning);
    }
    if (CourseModule.ORES_TYPE_COURSE.equals(resourceType)) {
        publishLayout.setFormDescription(translate("rentry.publish.course.desc"));
    } else {
        publishLayout.setFormDescription(translate("rentry.publish.other.desc"));
    }
    if (resourceType != null) {
        handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(resourceType);
    }
    // make configuration read only when managed by external system
    final boolean managedSettings = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.settings);
    final boolean managedAccess = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.access);
    String[] yesNoValues = new String[] { translate("yes"), translate("no") };
    authorsSwitch = uifactory.addRadiosHorizontal("authorsSwitch", "rentry.publish.authors", publishLayout, yesNoKeys, yesNoValues);
    authorsSwitch.setEnabled(!managedAccess);
    authorsSwitch.addActionListener(FormEvent.ONCHANGE);
    authorConfigLayout = FormLayoutContainer.createBareBoneFormLayout("authorConfigLayout", getTranslator());
    publishLayout.add(authorConfigLayout);
    canReference = uifactory.addCheckboxesVertical("cif_canReference", null, authorConfigLayout, new String[] { YES_KEY }, new String[] { translate("cif.canReference") }, 1);
    canReference.setEnabled(!managedSettings);
    canCopy = uifactory.addCheckboxesVertical("cif_canCopy", null, authorConfigLayout, new String[] { YES_KEY }, new String[] { translate("cif.canCopy") }, 1);
    canCopy.setEnabled(!managedSettings);
    canDownload = uifactory.addCheckboxesVertical("cif_canDownload", null, authorConfigLayout, new String[] { YES_KEY }, new String[] { translate("cif.canDownload") }, 1);
    canDownload.setEnabled(!managedSettings);
    canDownload.setVisible(handler.supportsDownload());
    uifactory.addSpacerElement("authorSpacer", authorConfigLayout, true);
    String[] publishedValues;
    if (loginModule.isGuestLoginLinksEnabled()) {
        publishedValues = new String[] { translate("cif.access.users"), translate("cif.access.users_guests"), translate("cif.access.membersonly") };
    } else {
        publishedValues = new String[] { translate("cif.access.users"), translate("cif.access.membersonly") };
    }
    usersSwitch = uifactory.addRadiosHorizontal("usersSwitch", "rentry.publish.users", publishLayout, yesNoKeys, yesNoValues);
    usersSwitch.addActionListener(FormEvent.ONCHANGE);
    usersSwitch.setEnabled(!managedAccess);
    userConfigLayout = FormLayoutContainer.createBareBoneFormLayout("userConfigLayout", getTranslator());
    publishLayout.add(userConfigLayout);
    publishedForUsers = uifactory.addDropdownSingleselect("publishedForUsers", null, userConfigLayout, publishedKeys, publishedValues, null);
    publishedForUsers.setEnabled(!managedAccess);
    publishedForUsers.addActionListener(FormEvent.ONCHANGE);
    uifactory.addSpacerElement("userSpacer", userConfigLayout, true);
    // Part 2
    FormLayoutContainer membershipLayout = FormLayoutContainer.createDefaultFormLayout("membership", getTranslator());
    formLayout.add(membershipLayout);
    membershipLayout.setFormTitle(translate("rentry.leaving.title"));
    String[] leaveValues = new String[] { translate("rentry.leave.atanytime"), translate("rentry.leave.afterenddate"), translate("rentry.leave.never") };
    final boolean managedLeaving = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.membersmanagement);
    leaveEl = uifactory.addDropdownSingleselect("entry.leave", "rentry.leave.option", membershipLayout, leaveKeys, leaveValues, null);
    boolean found = false;
    for (String leaveKey : leaveKeys) {
        if (leaveKey.equals(entry.getAllowToLeaveOption().name())) {
            leaveEl.select(leaveKey, true);
            found = true;
        }
    }
    if (!found) {
        if (managedLeaving) {
            leaveEl.select(RepositoryEntryAllowToLeaveOptions.never.name(), true);
        } else {
            RepositoryEntryAllowToLeaveOptions defaultOption = repositoryModule.getAllowToLeaveDefaultOption();
            leaveEl.select(defaultOption.name(), true);
        }
    }
    leaveEl.setEnabled(!managedLeaving);
    // Part 3
    accessLayout = FormLayoutContainer.createCustomFormLayout("accessConfig", getTranslator(), velocity_root + "/access_configuration.html");
    formLayout.add(accessLayout);
    accessLayout.setVisible(entry.getAccess() == RepositoryEntry.ACC_USERS || loginModule.isGuestLoginLinksEnabled() && entry.getAccess() == RepositoryEntry.ACC_USERS_GUESTS || entry.isMembersOnly());
    accessLayout.setFormTitle(translate("accesscontrol.title"));
    HelpTooltip acMethodsLabelHelp = new HelpTooltip("acMethodsLabelHelp", "Legen Sie fest unter welchen Bedingungen Benutzer diese Ressource buchen können.", "Course Settings#_buchungsmethode", getLocale());
    accessLayout.put("acMethodsLabelHelp", acMethodsLabelHelp);
    if (editable) {
        List<AccessMethod> methods = acService.getAvailableMethods(getIdentity(), ureq.getUserSession().getRoles());
        for (AccessMethod method : methods) {
            AccessMethodHandler methodHandler = acModule.getAccessMethodHandler(method.getType());
            if (methodHandler.isPaymentMethod() && !allowPaymentMethod) {
                continue;
            }
            String title = methodHandler.getMethodName(getLocale());
            FormLink add = uifactory.addFormLink("create." + methodHandler.getType(), title, null, accessLayout, Link.LINK | Link.NONTRANSLATED);
            add.setUserObject(method);
            add.setIconLeftCSS(("o_icon " + method.getMethodCssClass() + "_icon o_icon-lg").intern());
            addMethods.add(add);
            accessLayout.add(add.getName(), add);
        }
        accessLayout.contextPut("methods", addMethods);
    }
    String[] onValues = new String[] { "" };
    confirmationEmailEl = uifactory.addCheckboxesHorizontal("confirmation.email", accessLayout, onKeys, onValues);
    confirmationEmailEl.addActionListener(FormEvent.ONCHANGE);
    confirmationEmailEl.setVisible(false);
    String confPage = velocity_root + "/configuration_list.html";
    confControllerContainer = FormLayoutContainer.createCustomFormLayout("conf-controllers", getTranslator(), confPage);
    accessLayout.add(confControllerContainer);
    loadConfigurations();
    boolean confirmationEmail = false;
    for (AccessInfo info : confControllers) {
        confirmationEmail |= info.getLink().getOffer().isConfirmationEmail();
    }
    if (confirmationEmail) {
        confirmationEmailEl.select(onKeys[0], true);
    }
    confControllerContainer.contextPut("confControllers", confControllers);
    confControllerContainer.contextPut("emptyConfigGrantsFullAccess", Boolean.valueOf(emptyConfigGrantsFullAccess));
    initFormData();
}
Also used : HelpTooltip(org.olat.core.gui.components.helpTooltip.HelpTooltip) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions) 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