Search in sources :

Example 11 with IdentitiesRemoveEvent

use of org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent in project OpenOLAT by OpenOLAT.

the class CatalogNodeManagerController method doAddRemoveOwners.

private void doAddRemoveOwners(Event event) {
    if (event instanceof IdentitiesAddEvent) {
        IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
        List<Identity> list = identitiesAddedEvent.getAddIdentities();
        for (Identity identity : list) {
            if (!securityManager.isIdentityInSecurityGroup(identity, catalogEntry.getOwnerGroup())) {
                securityManager.addIdentityToSecurityGroup(identity, catalogEntry.getOwnerGroup());
                identitiesAddedEvent.getAddedIdentities().add(identity);
            }
        }
    } else if (event instanceof IdentitiesRemoveEvent) {
        IdentitiesRemoveEvent identitiesRemoveEvent = (IdentitiesRemoveEvent) event;
        List<Identity> list = identitiesRemoveEvent.getRemovedIdentities();
        for (Identity identity : list) {
            securityManager.removeIdentityFromSecurityGroup(identity, catalogEntry.getOwnerGroup());
        }
    }
}
Also used : IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 12 with IdentitiesRemoveEvent

use of org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent in project OpenOLAT by OpenOLAT.

the class CatalogNodeManagerController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (addEntryCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            loadNodesChildren();
        }
        cmc.deactivate();
        cleanUp();
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (editEntryCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            catalogEntry = editEntryCtrl.getEditedCatalogEntry();
            loadEntryInfos();
        }
        cmc.deactivate();
        cleanUp();
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (categoryMoveCtrl == source) {
        cmc.deactivate();
        CatalogEntry moveMe = null;
        if (event.equals(Event.DONE_EVENT)) {
            showInfo("tools.move.catalog.entry.success", catalogEntry.getName());
            moveMe = categoryMoveCtrl.getMoveMe();
        } else if (event.equals(Event.FAILED_EVENT)) {
            showError("tools.move.catalog.entry.failed");
            loadNodesChildren();
        }
        cleanUp();
        // in any case, remove the lock
        if (catModificationLock != null && catModificationLock.isSuccess()) {
            CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(catModificationLock);
            catModificationLock = null;
        }
        // only after jump to the moved entry
        if (moveMe != null) {
            launchCatalogEntry(ureq, moveMe);
        }
    } else if (dialogDeleteSubtree == source) {
        // from remove subtree dialog -> yes or no
        if (DialogBoxUIFactory.isYesEvent(event)) {
            catalogManager.deleteCatalogEntry(catalogEntry);
            fireEvent(ureq, Event.BACK_EVENT);
        }
        // in any case, remove the lock
        if (catModificationLock != null && catModificationLock.isSuccess()) {
            CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(catModificationLock);
            catModificationLock = null;
        }
    } else if (childNodeCtrl == source) {
        if (event == Event.BACK_EVENT) {
            toolbarPanel.popUpToController(this);
            removeAsListenerAndDispose(childNodeCtrl);
            childNodeCtrl = null;
            loadNodesChildren();
        }
    } else if (entrySearchCtrl == source) {
        if (event.getCommand().equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
            // successfully selected a repository entry which will be a link within
            // the current Category
            RepositoryEntry selectedEntry = entrySearchCtrl.getSelectedEntry();
            doAddResource(ureq, selectedEntry);
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
        cmc.deactivate();
        cleanUp();
    } else if (groupCtrl == source) {
        if (event instanceof IdentitiesAddEvent || event instanceof IdentitiesRemoveEvent) {
            doAddRemoveOwners(event);
        }
    } else if (contactCtrl == source) {
        cmc.deactivate();
        cleanUp();
    } else if (dialogDeleteLink == source) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            CatalogEntryRow row = (CatalogEntryRow) dialogDeleteLink.getUserObject();
            catalogManager.deleteCatalogEntry(row, catalogEntry);
            loadResources(ureq);
        }
    } else if (entryResourceMoveCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            CatalogEntry moveMe = entryResourceMoveCtrl.getMoveMe();
            showInfo("tools.move.catalog.entry.success", moveMe.getName());
            loadResources(ureq);
        }
        cmc.deactivate();
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) CatalogEntry(org.olat.repository.CatalogEntry) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 13 with IdentitiesRemoveEvent

use of org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent in project OpenOLAT by OpenOLAT.

the class GroupController method doRemoveIdentitiesFromGroup.

private void doRemoveIdentitiesFromGroup(UserRequest ureq, List<Identity> toBeRemoved, MailTemplate mailTemplate) {
    fireEvent(ureq, new IdentitiesRemoveEvent(toBeRemoved));
    identitiesTableModel.remove(toBeRemoved);
    if (tableCtr != null) {
        // can be null in the follwoing case.
        // the user which does the removal is also in the list of toBeRemoved
        // hence the fireEvent does trigger a disposal of a GroupController, which
        // in turn nullifies the tableCtr... see also OLAT-3331
        tableCtr.modelChanged();
    }
    // send the notification mail
    if (mailTemplate != null) {
        // means no sender in footer
        Identity sender = null;
        if (showSenderInRemovMailFooter) {
            sender = ureq.getIdentity();
        }
        String metaId = UUID.randomUUID().toString();
        MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
        MailerResult result = new MailerResult();
        MailBundle[] bundles = mailManager.makeMailBundles(context, toBeRemoved, mailTemplate, sender, metaId, result);
        result.append(mailManager.sendMessage(bundles));
        if (mailTemplate.getCpfrom()) {
            MailBundle ccBundle = mailManager.makeMailBundle(context, ureq.getIdentity(), mailTemplate, sender, metaId, result);
            result.append(mailManager.sendMessage(ccBundle));
        }
        MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), ureq.getLocale());
    }
}
Also used : IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) MailerResult(org.olat.core.util.mail.MailerResult) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle)

Example 14 with IdentitiesRemoveEvent

use of org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent in project openolat by klemens.

the class CatalogNodeManagerController method doAddRemoveOwners.

private void doAddRemoveOwners(Event event) {
    if (event instanceof IdentitiesAddEvent) {
        IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
        List<Identity> list = identitiesAddedEvent.getAddIdentities();
        for (Identity identity : list) {
            if (!securityManager.isIdentityInSecurityGroup(identity, catalogEntry.getOwnerGroup())) {
                securityManager.addIdentityToSecurityGroup(identity, catalogEntry.getOwnerGroup());
                identitiesAddedEvent.getAddedIdentities().add(identity);
            }
        }
    } else if (event instanceof IdentitiesRemoveEvent) {
        IdentitiesRemoveEvent identitiesRemoveEvent = (IdentitiesRemoveEvent) event;
        List<Identity> list = identitiesRemoveEvent.getRemovedIdentities();
        for (Identity identity : list) {
            securityManager.removeIdentityFromSecurityGroup(identity, catalogEntry.getOwnerGroup());
        }
    }
}
Also used : IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 15 with IdentitiesRemoveEvent

use of org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent in project openolat by klemens.

the class RightsMetadataEditController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == groupController) {
        if (event instanceof IdentitiesAddEvent) {
            IdentitiesAddEvent identitiesAddedEvent = (IdentitiesAddEvent) event;
            List<Identity> list = identitiesAddedEvent.getAddIdentities();
            qpoolService.addAuthors(list, Collections.<QuestionItemShort>singletonList(item));
            identitiesAddedEvent.getAddedIdentities().addAll(list);
        } else if (event instanceof IdentitiesRemoveEvent) {
            IdentitiesRemoveEvent identitiesRemoveEvent = (IdentitiesRemoveEvent) event;
            List<Identity> list = identitiesRemoveEvent.getRemovedIdentities();
            qpoolService.removeAuthors(list, Collections.<QuestionItemShort>singletonList(item));
        }
        reloadAuthors();
    // cmc.deactivate();
    // cleanUp();
    } else if (source == cmc) {
        fireEvent(ureq, new QItemEdited(item));
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : QItemEdited(org.olat.modules.qpool.ui.events.QItemEdited) IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) QuestionItemShort(org.olat.modules.qpool.QuestionItemShort) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity)

Aggregations

IdentitiesRemoveEvent (org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent)18 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)16 Identity (org.olat.core.id.Identity)10 BusinessGroupAddResponse (org.olat.group.BusinessGroupAddResponse)8 List (java.util.List)6 ArrayList (java.util.ArrayList)4 MailBundle (org.olat.core.util.mail.MailBundle)4 MailContext (org.olat.core.util.mail.MailContext)4 MailContextImpl (org.olat.core.util.mail.MailContextImpl)4 MailerResult (org.olat.core.util.mail.MailerResult)4 IdentitiesMoveEvent (org.olat.admin.securitygroup.gui.IdentitiesMoveEvent)2 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)2 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)2 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 ContactList (org.olat.core.util.mail.ContactList)2 MailTemplate (org.olat.core.util.mail.MailTemplate)2 Pool (org.olat.modules.qpool.Pool)2 QuestionItemShort (org.olat.modules.qpool.QuestionItemShort)2 QItemEdited (org.olat.modules.qpool.ui.events.QItemEdited)2