Exemplo n.º 1
0
 public void event(UserRequest ureq, Controller source, Event event) {
   if (source == tableCtr) {
     if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
       TableEvent te = (TableEvent) event;
       if (te.getActionId().equals(ACTION_SINGLESELECT_CHOOSE)) {
         int rowid = te.getRowId();
         Identity foundIdentity = tdm.getObject(rowid);
         UserDeletionManager.getInstance().setIdentityAsActiv(foundIdentity);
         updateUserList();
       }
     } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
       TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
       if (tmse.getAction().equals(ACTION_MULTISELECT_CHOOSE)) {
         handleDeleteButtonEvent(ureq, tmse);
       }
     }
   } else if (source == deleteConfirmController) {
     if (DialogBoxUIFactory.isOkEvent(event)) {
       List<String> errors = new ArrayList<String>();
       deleteIdentities(readyToDeleteIdentities, errors);
       if (errors.isEmpty()) {
         showInfo("deleted.feedback.msg");
       } else {
         StringBuilder sb = new StringBuilder();
         for (String error : errors) {
           if (sb.length() > 0) sb.append(", ");
           sb.append(error);
         }
         showWarning("error.delete", sb.toString());
       }
       initializeContent();
     }
   }
 }
Exemplo n.º 2
0
 private void handleDeleteButtonEvent(UserRequest ureq, TableMultiSelectEvent tmse) {
   if (tdm.getObjects(tmse.getSelection()).size() != 0) {
     readyToDeleteIdentities = tdm.getObjects(tmse.getSelection());
     deleteConfirmController =
         activateOkCancelDialog(
             ureq,
             null,
             translate(
                 "readyToDelete.delete.confirm", getUserlistAsString(readyToDeleteIdentities)),
             deleteConfirmController);
   } else {
     showWarning("nothing.selected.msg");
   }
 }
 @Override
 protected void event(UserRequest ureq, Controller source, Event event) {
   if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
     TableMultiSelectEvent multiselectionEvent = (TableMultiSelectEvent) event;
     if (multiselectionEvent.getAction().equals(ACTION_MULTISELECT_CHOOSE)) {
       // sortedItems = tableDataModel.getObjects(multiselectionEvent.getSelection());
       sortedItems =
           tableController.getSelectedSortedObjects(
               multiselectionEvent.getSelection(), tableDataModel);
       if (sortedItems.size() == 0) {
         showWarning("portlet.sorting.manual.empty_sel");
       } else {
         fireEvent(ureq, event);
       }
     } else if (multiselectionEvent.getAction().equals(ACTION_MULTISELECT_CANCEL)) {
       fireEvent(ureq, Event.CANCELLED_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 = (KalendarEvent) 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);

          removeAsListenerAndDispose(formManageParticipants);
          formManageParticipants = new DENManageParticipantsForm(ureq, getWindowControl());
          listenTo(formManageParticipants);

          participantsVC = createVelocityContainer("participants");
          SimpleText dateTitle =
              new SimpleText(
                  "dateTitle",
                  translate("dates.table.subject") + ": " + selectedEvent.getSubject());
          DateFormat df = new SimpleDateFormat();
          SimpleText dateTimeframe =
              new SimpleText(
                  "dateTimeframe",
                  translate("dates.table.date")
                      + ": "
                      + df.format(selectedEvent.getBegin())
                      + " - "
                      + df.format(selectedEvent.getEnd()));
          participantsVC.put("dateTitle", dateTitle);
          participantsVC.put("dateTimeframe", dateTimeframe);
          participantsVC.put("participantsTable", tableManageParticipants.getInitialComponent());
          participantsVC.put("addParticipants", formManageParticipants.getInitialComponent());

          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) {
          removed = denManager.getSelectedEventParticipants(dateList, selection);
          dateList =
              denManager.deleteParticipants(
                  ores, courseNode, denManager.getSelectedEventIDs(dateList, selection));
          listTableData.setObjects(dateList);
          // send notification mail
          createRemovedNotificationMail(ureq, dateList.get(0).getSubject());
        } 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 == formManageParticipants
        && event == DENManageParticipantsForm.ADD_PARTICIPANTS) {
      // open user search controller to manually add users in date
      removeAsListenerAndDispose(userSearchCntrl);
      userSearchCntrl = new UserSearchController(ureq, getWindowControl(), true, true);
      listenTo(userSearchCntrl);

      removeAsListenerAndDispose(userSearchCMC);
      userSearchCMC =
          new CloseableModalController(
              getWindowControl(), "close", userSearchCntrl.getInitialComponent());
      listenTo(userSearchCMC);

      userSearchCMC.activate();
    } else if (source == userSearchCntrl) {
      if (event == Event.CANCELLED_EVENT) {
        userSearchCMC.deactivate();
      } else {
        List<Identity> toAdd = null;
        added = 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 added.add(identity);
          }
          if (showMessage) showWarning("enrollment.warning.manual");
          refreshTables();
        }
        userSearchCMC.deactivate();
        if (added.size() > 0) {
          // write notification mail
          createAddedNotificationMail(ureq, dateList.get(0).getSubject());
        }
      }

    } 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, courseNode);
          if (!status.isCancelled()) showError();
          // send notification mail
          else {
            removed.clear();
            removed.add(identity);
            createRemovedNotificationMail(ureq, dateList.get(0).getSubject());
          }
          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 == addedNotificationCtr && event == Event.DONE_EVENT) {
      if (addedNotificationCtr.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, added, addedNotificationCtr.getMailTemplate(), sender, metaId, result);
        result.append(mailManager.sendMessage(bundles));
        if (addedNotificationCtr.getMailTemplate().getCpfrom()) {
          MailBundle ccBundles =
              mailManager.makeMailBundle(
                  context, sender, addedNotificationCtr.getMailTemplate(), sender, metaId, result);
          result.append(mailManager.sendMessage(ccBundles));
        }
        MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getLocale());
      }
      notificationCmc.deactivate();
      added.clear();
    } else if (source == removedNotificationCtr && event == Event.DONE_EVENT) {
      if (removedNotificationCtr.getMailTemplate() != null) {

        // fxdiff VCRP-16: intern mail system
        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, added, addedNotificationCtr.getMailTemplate(), sender, metaId, result);
        result.append(mailManager.sendMessage(bundles));
        if (addedNotificationCtr.getMailTemplate().getCpfrom()) {
          MailBundle ccBundle =
              mailManager.makeMailBundle(
                  context, sender, addedNotificationCtr.getMailTemplate(), sender, metaId, result);
          result.append(mailManager.sendMessage(ccBundle));
        }
        MailHelper.printErrorsAndWarnings(result, getWindowControl(), ureq.getLocale());
      }
      notificationCmc.deactivate();
      removed.clear();
    } else if (source == contactCtr) {
      notificationCmc.deactivate();
    }
  }