Search in sources :

Example 41 with OfferAccess

use of org.olat.resource.accesscontrol.OfferAccess 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 42 with OfferAccess

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

the class PublishStep01AccessForm method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (newMethodCtrl == source) {
        if (event.equals(Event.DONE_EVENT)) {
            OfferAccess newLink = newMethodCtrl.commitChanges();
            button_id++;
            if (!offerAccess.contains(newLink)) {
                offerAccess.add(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();
            if (!offerAccess.contains(newLink)) {
                offerAccess.add(newLink);
            }
            replace(newLink);
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
        cmc.deactivate();
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    } else {
        super.event(ureq, source, event);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess)

Example 43 with OfferAccess

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

the class PublishStep01AccessForm method loadConfigurations.

protected void loadConfigurations() {
    List<Offer> offers = acService.findOfferByResource(resource, true, null);
    for (Offer offer : offers) {
        List<OfferAccess> offerAccessList = acService.getOfferAccess(offer, true);
        for (OfferAccess access : offerAccessList) {
            button_id++;
            addConfiguration(access);
        }
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) Offer(org.olat.resource.accesscontrol.Offer)

Example 44 with OfferAccess

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

the class PublishStep01AccessForm method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    super.formInnerEvent(ureq, source, event);
    if (source == authorsSwitch) {
        if (authorsSwitch.getSelectedKey().equals(YES_KEY)) {
            authorConfigLayout.setVisible(true);
        } else {
            authorConfigLayout.setVisible(false);
            if (!publishedForUsers.getSelectedKey().equals(MEMBERSONLY_KEY)) {
                usersSwitch.select(NO_KEY, false);
                userConfigLayout.setVisible(false);
            }
        }
    } else if (source == usersSwitch || source == publishedForUsers) {
        if (usersSwitch.getSelectedKey().equals(YES_KEY)) {
            userConfigLayout.setVisible(true);
            accessLayout.setVisible(true);
            if (publishedForUsers.getSelectedKey().equals(MEMBERSONLY_KEY)) {
                authorConfigLayout.setVisible(false);
                authorsSwitch.select(NO_KEY, false);
                authorsSwitch.setEnabled(false);
            } else {
                authorsSwitch.select(YES_KEY, false);
                authorsSwitch.setEnabled(true);
                authorConfigLayout.setVisible(true);
            }
        } else {
            userConfigLayout.setVisible(false);
            accessLayout.setVisible(false);
            authorsSwitch.setEnabled(true);
        }
    } else if (addMethods.contains(source)) {
        AccessMethod method = (AccessMethod) source.getUserObject();
        addMethod(ureq, method);
    } else if (confirmationEmailEl == source) {
        for (AccessInfo info : confControllers) {
            if (!offerAccess.contains(info.getLink())) {
                offerAccess.add(info.getLink());
            }
        }
    } else if (source instanceof FormLink) {
        FormLink button = (FormLink) source;
        String cmd = button.getCmd();
        if ("delete".equals(cmd)) {
            AccessInfo infos = (AccessInfo) source.getUserObject();
            OfferAccess deleteOffer = infos.getLink();
            offerAccess.remove(deleteOffer);
            if (deleteOffer.getKey() != null) {
                deletedOfferAccess.add(deleteOffer);
            }
            confControllers.remove(infos);
            updateConfirmationEmail();
            fireEvent(ureq, Event.CHANGED_EVENT);
        } else if ("edit".equals(cmd)) {
            AccessInfo infos = (AccessInfo) source.getUserObject();
            editMethod(ureq, infos);
        }
    }
}
Also used : AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) OfferAccess(org.olat.resource.accesscontrol.OfferAccess) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

OfferAccess (org.olat.resource.accesscontrol.OfferAccess)44 Offer (org.olat.resource.accesscontrol.Offer)18 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)16 OLATResource (org.olat.resource.OLATResource)14 Test (org.junit.Test)12 AccessMethodHandler (org.olat.resource.accesscontrol.method.AccessMethodHandler)12 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 BusinessGroup (org.olat.group.BusinessGroup)8 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)6 Identity (org.olat.core.id.Identity)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 ACService (org.olat.resource.accesscontrol.ACService)6 IdentifierKey (org.olat.resource.accesscontrol.provider.auto.IdentifierKey)6 AutoAccessMethod (org.olat.resource.accesscontrol.provider.auto.model.AutoAccessMethod)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)4 OpenBusinessGroupRow (org.olat.group.model.OpenBusinessGroupRow)4 CatalogEntry (org.olat.repository.CatalogEntry)4