Search in sources :

Example 21 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project openolat by klemens.

the class DENManageParticipantsController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == tableListParticipants) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent tableEvent = (TableEvent) event;
            // open window for choosen date to manage the enrolled users or manually add
            if (tableEvent.getActionId().equals(DENListTableDataModel.CHANGE_ACTION)) {
                selectedEvent = listTableData.getObject(tableEvent.getRowId());
                List<Identity> participants = denManager.getEventParticipants(selectedEvent);
                participantsTableData = new DENParticipantsTableDataModel(participants);
                removeAsListenerAndDispose(tableManageParticipants);
                tableManageParticipants = denManager.createParticipantsTable(ureq, getWindowControl(), getTranslator(), participantsTableData);
                listenTo(tableManageParticipants);
                participantsVC = createVelocityContainer("participants");
                DateFormat df = new SimpleDateFormat();
                participantsVC.contextPut("dateTitle", selectedEvent.getSubject());
                participantsVC.contextPut("dateTimeframe", df.format(selectedEvent.getBegin()) + " - " + df.format(selectedEvent.getEnd()));
                participantsVC.put("participantsTable", tableManageParticipants.getInitialComponent());
                addParticipantButton = LinkFactory.createButton("participants.add", participantsVC, this);
                removeAsListenerAndDispose(manageParticipantsModalCntrl);
                manageParticipantsModalCntrl = new CloseableModalController(getWindowControl(), "close", participantsVC, true, translate("dates.table.participant.manage"));
                listenTo(manageParticipantsModalCntrl);
                manageParticipantsModalCntrl.activate();
            }
        } else {
            TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
            BitSet selection = tmse.getSelection();
            // delete all users from the selected dates
            if (tmse.getAction().equals(DENListTableDataModel.DELETE_ACTION) && selection.cardinality() > 0) {
                selectedIds = denManager.getSelectedEventParticipants(dateList, selection);
                dateList = denManager.deleteParticipants(ores, courseNode, denManager.getSelectedEventIDs(dateList, selection));
                listTableData.setObjects(dateList);
                // send notification mail
                createNotificationMail(ureq, courseNode.getShortTitle(), REMOVE_ACTION);
            } else if (tmse.getAction().equals(DENListTableDataModel.MAIL_ACTION) && selection.cardinality() > 0) {
                // send email to all users from the selected dates
                List<Identity> participants = denManager.getSelectedEventParticipants(dateList, selection);
                createParticipantsMail(ureq, participants);
            } else if (selection.cardinality() == 0) {
                showWarning("participants.message.empty");
            }
        }
    } else if (source == userSearchCntrl) {
        if (event == Event.CANCELLED_EVENT) {
            userSearchCMC.deactivate();
        } else {
            List<Identity> toAdd = null;
            selectedIds = new ArrayList<Identity>();
            if (event instanceof SingleIdentityChosenEvent) {
                SingleIdentityChosenEvent singleEvent = (SingleIdentityChosenEvent) event;
                Identity choosenIdentity = singleEvent.getChosenIdentity();
                toAdd = new ArrayList<Identity>();
                toAdd.add(choosenIdentity);
            } else if (event instanceof MultiIdentityChosenEvent) {
                MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
                toAdd = multiEvent.getChosenIdentities();
            }
            boolean showMessage = false;
            if (toAdd != null && toAdd.size() > 0) {
                for (Identity identity : toAdd) {
                    status = denManager.doEnroll(identity, selectedEvent, ores, courseNode, true);
                    if (!status.isEnrolled() && status.getErrorMessage().equals(DENStatus.ERROR_ALREADY_ENROLLED))
                        showMessage = true;
                    else
                        selectedIds.add(identity);
                }
                if (showMessage)
                    showWarning("enrollment.warning.manual");
                refreshTables();
            }
            userSearchCMC.deactivate();
            if (selectedIds.size() > 0) {
                // write notification mail
                createNotificationMail(ureq, selectedEvent.getSubject(), ADD_ACTION);
            }
        }
    } else if (source == tableManageParticipants) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent tableEvent = (TableEvent) event;
            // delete single user from event
            if (tableEvent.getActionId().equals(DENParticipantsTableDataModel.REMOVE_ACTION)) {
                Identity identity = participantsTableData.getEntryAt(tableEvent.getRowId());
                status = denManager.cancelEnroll(identity, selectedEvent, ores);
                if (!status.isCancelled())
                    showError();
                else // send notification mail
                {
                    selectedIds.clear();
                    selectedIds.add(identity);
                    createNotificationMail(ureq, selectedEvent.getSubject(), REMOVE_ACTION);
                }
                refreshTables();
            // write email to single user
            } else if (tableEvent.getActionId().equals(DENParticipantsTableDataModel.MAIL_ACTION)) {
                List<Identity> participants = new ArrayList<Identity>();
                participants.add(participantsTableData.getEntryAt(tableEvent.getRowId()));
                createParticipantsMail(ureq, participants);
            }
        }
    } else if (source == notificationCtr && event == Event.DONE_EVENT) {
        if (notificationCtr.getMailTemplate() != null) {
            Identity sender = ureq.getIdentity();
            MailerResult result = new MailerResult();
            String metaId = UUID.randomUUID().toString().replace("-", "");
            MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
            MailBundle[] bundles = mailManager.makeMailBundles(context, selectedIds, notificationCtr.getMailTemplate(), sender, metaId, result);
            result.append(mailManager.sendMessage(bundles));
            if (notificationCtr.getMailTemplate().getCpfrom()) {
                MailBundle ccBundles = mailManager.makeMailBundle(context, sender, notificationCtr.getMailTemplate(), sender, metaId, result);
                result.append(mailManager.sendMessage(ccBundles));
            }
            MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), ureq.getLocale());
        }
        notificationCmc.deactivate();
        selectedIds.clear();
    } else if (source == contactCtr) {
        notificationCmc.deactivate();
    }
}
Also used : MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailerResult(org.olat.core.util.mail.MailerResult) MailContext(org.olat.core.util.mail.MailContext) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TableMultiSelectEvent(org.olat.core.gui.components.table.TableMultiSelectEvent) BitSet(java.util.BitSet) ArrayList(java.util.ArrayList) TableEvent(org.olat.core.gui.components.table.TableEvent) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) ArrayList(java.util.ArrayList) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) Identity(org.olat.core.id.Identity) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent) MailBundle(org.olat.core.util.mail.MailBundle) SimpleDateFormat(java.text.SimpleDateFormat)

Example 22 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project openolat by klemens.

the class UserAdminMainController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == contentCtr) {
        if (event instanceof SingleIdentityChosenEvent) {
            SingleIdentityChosenEvent userChoosenEvent = (SingleIdentityChosenEvent) event;
            Identity identity = userChoosenEvent.getChosenIdentity();
            // cleanup old userAdminCtr controller
            removeAsListenerAndDispose(userAdminCtr);
            OLATResourceable ores = OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey());
            ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
            WindowControl bwControl;
            if (contentCtr instanceof UsermanagerUserSearchController) {
                UsermanagerUserSearchController ctrl = (UsermanagerUserSearchController) contentCtr;
                WindowControl tableControl = ctrl.getTableControl();
                if (tableControl == null) {
                    tableControl = ctrl.getWindowControlForDebug();
                }
                bwControl = addToHistory(ureq, ores, null, tableControl, true);
            } else {
                bwControl = addToHistory(ureq, ores, null, contentCtr.getWindowControlForDebug(), true);
            }
            userAdminCtr = new UserAdminController(ureq, bwControl, identity);
            listenTo(userAdminCtr);
            // activate a special pane in the tabbed pane when set
            if (activatePaneInDetailView != null) {
                List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(activatePaneInDetailView);
                userAdminCtr.activate(ureq, entries, null);
            }
            content.setContent(userAdminCtr.getInitialComponent());
            // deactivate back button for user create controller, kames no sense there
            if (contentCtr instanceof UserCreateController) {
                userAdminCtr.setBackButtonEnabled(false);
            } else {
                userAdminCtr.setBackButtonEnabled(true);
            }
        }
    } else if (source == userAdminCtr) {
        if (event == Event.BACK_EVENT) {
            Identity editedIdentity = userAdminCtr.getEditedIdentity();
            removeAsListenerAndDispose(userAdminCtr);
            userAdminCtr = null;
            // to display correct values of identity
            if (contentCtr instanceof UsermanagerUserSearchController) {
                UsermanagerUserSearchController userSearchCtr = (UsermanagerUserSearchController) contentCtr;
                userSearchCtr.reloadFoundIdentity(editedIdentity);
                addToHistory(ureq, userSearchCtr);
            }
            content.setContent(contentCtr.getInitialComponent());
        }
    }
}
Also used : UsermanagerUserSearchController(org.olat.admin.user.UsermanagerUserSearchController) OLATResourceable(org.olat.core.id.OLATResourceable) UserAdminController(org.olat.admin.user.UserAdminController) UserCreateController(org.olat.admin.user.UserCreateController) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 23 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.

the class EPShareListController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == selectGroupCtrl) {
        cmc.deactivate();
        secureListBox();
        if (event instanceof BusinessGroupSelectionEvent) {
            BusinessGroupSelectionEvent bge = (BusinessGroupSelectionEvent) event;
            List<BusinessGroup> groups = bge.getGroups();
            if (groups.size() > 0) {
                EPSharePolicyWrapper policyWrapper = (EPSharePolicyWrapper) selectGroupCtrl.getUserObject();
                policyWrapper.getGroups().addAll(groups);
                initPolicyUI();
            }
        }
    } else if (source.equals(selectUserCtrl)) {
        cmc.deactivate();
        secureListBox();
        EPSharePolicyWrapper policyWrapper = (EPSharePolicyWrapper) selectUserCtrl.getUserObject();
        if (event instanceof SingleIdentityChosenEvent) {
            SingleIdentityChosenEvent foundEvent = (SingleIdentityChosenEvent) event;
            Identity chosenIdentity = foundEvent.getChosenIdentity();
            if (chosenIdentity != null) {
                policyWrapper.getIdentities().add(chosenIdentity);
            }
        } else if (event instanceof MultiIdentityChosenEvent) {
            MultiIdentityChosenEvent foundEvent = (MultiIdentityChosenEvent) event;
            List<Identity> chosenIdentities = foundEvent.getChosenIdentities();
            if (chosenIdentities != null && !chosenIdentities.isEmpty()) {
                policyWrapper.getIdentities().addAll(chosenIdentities);
            }
        }
        initPolicyUI();
    } else if (source == cmc) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) BusinessGroupSelectionEvent(org.olat.group.model.BusinessGroupSelectionEvent) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent)

Example 24 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.

the class BGUserManagementController method extractIdentities.

private List<Identity> extractIdentities(Event event) {
    if (event instanceof SingleIdentityChosenEvent) {
        SingleIdentityChosenEvent chosenEvent = (SingleIdentityChosenEvent) event;
        Identity identity = chosenEvent.getChosenIdentity();
        return Collections.singletonList(identity);
    }
    if (event instanceof MultiIdentityChosenEvent) {
        MultiIdentityChosenEvent chosenEvent = (MultiIdentityChosenEvent) event;
        List<Identity> identities = chosenEvent.getChosenIdentities();
        return identities;
    }
    return Collections.emptyList();
}
Also used : SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent)

Example 25 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.

the class LDAPAdminController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.controller.Controller,
 *      org.olat.core.gui.control.Event)
 */
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == deleteStepController) {
        if (event == Event.CANCELLED_EVENT || event == Event.FAILED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(deleteStepController);
            showInfo("delete.step.cancel");
            ldapLoginManager.freeSyncLock();
            deletStartLink.setEnabled(true);
        } else if (event == Event.CHANGED_EVENT || event == Event.DONE_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(deleteStepController);
            if (hasIdentitiesToDeleteAfterRun) {
                showInfo("delete.step.finish.users", amountUsersToDelete.toString());
            } else {
                showInfo("delete.step.finish.noUsers");
            }
            ldapLoginManager.freeSyncLock();
            deletStartLink.setEnabled(true);
        } else if (source == userSearchCtrl) {
            calloutCtr.deactivate();
            Identity choosenIdent = ((SingleIdentityChosenEvent) event).getChosenIdentity();
            ldapLoginManager.doSyncSingleUser(choosenIdent);
        }
    }
}
Also used : SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity)

Aggregations

SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)46 Identity (org.olat.core.id.Identity)40 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)24 ArrayList (java.util.ArrayList)16 List (java.util.List)14 TableEvent (org.olat.core.gui.components.table.TableEvent)10 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)10 WindowControl (org.olat.core.gui.control.WindowControl)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 UserRequest (org.olat.core.gui.UserRequest)6 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)6 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)6 AssertException (org.olat.core.logging.AssertException)6 UserInfoMainController (org.olat.user.UserInfoMainController)6 Collection (java.util.Collection)4 ContextEntry (org.olat.core.id.context.ContextEntry)4 ContactList (org.olat.core.util.mail.ContactList)4 MailNotificationEditController (org.olat.core.util.mail.MailNotificationEditController)4 MailTemplate (org.olat.core.util.mail.MailTemplate)4 DateFormat (java.text.DateFormat)2