Search in sources :

Example 36 with OfferAccess

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

the class AccessConfigurationController 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();
            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);
    }
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess)

Example 37 with OfferAccess

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

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)

Example 38 with OfferAccess

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

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)

Example 39 with OfferAccess

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

the class PublishProcess method changeAccessAndProperties.

public void changeAccessAndProperties(Identity author, CourseAccessAndProperties accessAndProps) {
    RepositoryManager manager = RepositoryManager.getInstance();
    manager.setAccessAndProperties(accessAndProps.getRepositoryEntry(), accessAndProps.getAccess(), accessAndProps.isMembersOnly(), accessAndProps.isCanCopy(), accessAndProps.isCanReference(), accessAndProps.isCanDownload());
    manager.setLeaveSetting(accessAndProps.getRepositoryEntry(), accessAndProps.getSetting());
    List<OfferAccess> offerAccess = accessAndProps.getOfferAccess();
    // 1: add new and update existing offerings
    ACService acService = CoreSpringFactory.getImpl(ACService.class);
    for (OfferAccess newLink : offerAccess) {
        if (accessAndProps.getConfirmationEmail() != null) {
            Offer offer = newLink.getOffer();
            boolean confirmation = accessAndProps.getConfirmationEmail().booleanValue();
            if (offer.isConfirmationEmail() != confirmation) {
                offer.setConfirmationEmail(confirmation);
                if (offer.getKey() != null) {
                    offer = acService.save(offer);
                }
            }
        }
        acService.saveOfferAccess(newLink);
    }
    // 2: remove offerings not available anymore
    List<OfferAccess> deletedOfferAccess = accessAndProps.getDeletedOfferAccess();
    for (OfferAccess deletedLink : deletedOfferAccess) {
        acService.deletedLinkToMethod(deletedLink);
    }
    MultiUserEvent modifiedEvent = new EntryChangedEvent(repositoryEntry, author, Change.modifiedAtPublish, "publish");
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, repositoryEntry);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
}
Also used : OfferAccess(org.olat.resource.accesscontrol.OfferAccess) Offer(org.olat.resource.accesscontrol.Offer) EntryChangedEvent(org.olat.repository.controllers.EntryChangedEvent) ACService(org.olat.resource.accesscontrol.ACService) RepositoryManager(org.olat.repository.RepositoryManager) MultiUserEvent(org.olat.core.util.event.MultiUserEvent)

Example 40 with OfferAccess

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

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