コード例 #1
0
  /**
   * assumes that the user seeing this controller has full access rights to the group (add/remove
   * users)
   */
  public UsersToGroupWizardController(
      final UserRequest ureq,
      final WindowControl wControl,
      final SecurityGroup aSecurityGroup,
      final MailTemplate mailTemplate) {
    // wizard has two or there steps depending whether the mail template should
    // be configured or not
    super(ureq, wControl, (mailTemplate == null ? 2 : 3));
    setBasePackage(UsersToGroupWizardController.class);

    this.securityGroup = aSecurityGroup;
    this.securityManager = (BaseSecurity) CoreSpringFactory.getBean(BaseSecurity.class);
    this.mailTemplate = mailTemplate;

    mainVc = createVelocityContainer("index");

    nextButton =
        LinkFactory.createButtonSmall((mailTemplate == null ? "finish" : "next"), mainVc, this);
    backButton = LinkFactory.createButtonSmall("back", mainVc, this);

    usersForm = new UserIdsForm(ureq, wControl);
    listenTo(usersForm);

    // init wizard title and set step 1
    setWizardTitle(translate("import.title"));
    setNextWizardStep(translate("import.title.select"), usersForm.getInitialComponent());
  }
コード例 #2
0
  @Override
  protected void event(final UserRequest ureq, final Component source, final Event event) {
    // default wizard will lissen to cancel wizard event
    super.event(ureq, source, event);

    if (source == nextButton) {
      if (mailTemplate == null) {
        // wizard stops here - no mail template to fill out
        fireEvent(ureq, new MultiIdentityChosenEvent(this.oks));
      } else {
        // next step is the notification mail form
        removeAsListenerAndDispose(mailCtr);
        mailCtr = new MailNotificationEditController(getWindowControl(), ureq, mailTemplate, false);
        listenTo(mailCtr);

        setNextWizardStep(translate("import.title.email"), mailCtr.getInitialComponent());
      }
    } else if (source == backButton) {
      // go back one step in wizard
      setBackWizardStep(translate("import.title.select"), usersForm.getInitialComponent());
    }
  }
コード例 #3
0
  @Override
  protected void event(final UserRequest ureq, final Controller source, final Event event) {
    if (source == usersForm) {
      if (event == Event.DONE_EVENT) {
        // calc stuff, preview

        final List existIdents = securityManager.getIdentitiesOfSecurityGroup(securityGroup);
        oks = new ArrayList<Identity>();
        final List<String> anonymous = new ArrayList<String>();
        final List<String> notFounds = new ArrayList<String>();
        final List<String> alreadyIn = new ArrayList<String>();

        // get the logins
        final String inp = usersForm.getLoginsString();
        final String[] lines = inp.split("\r?\n");
        for (int i = 0; i < lines.length; i++) {
          final String username = lines[i].trim();
          if (!username.equals("")) { // skip empty lines
            final Identity ident = securityManager.findIdentityByName(username);
            if (ident == null) { // not found, add to not-found-list
              notFounds.add(username);
            } else if (getBaseSecurityEBL().isAnonymous(ident)) {
              anonymous.add(username);
            } else {
              // check if already in group
              final boolean inGroup = containsIdentity(existIdents, ident);
              if (inGroup) {
                // added to warning: already in group
                alreadyIn.add(ident.getName());
              } else {
                // ok to add -> preview (but filter duplicate entries)
                if (!containsIdentity(oks, ident)) {
                  oks.add(ident);
                }
              }
            }
          }
        }
        // push table and other infos to velocity
        removeAsListenerAndDispose(newTableC);
        newTableC =
            UserControllerFactory.createTableControllerFor(
                null, oks, ureq, getWindowControl(), null);
        listenTo(newTableC);

        mainVc.put("table", newTableC.getInitialComponent());
        mainVc.contextPut("isanonymous", listNames(anonymous));
        mainVc.contextPut("notfound", listNames(notFounds));
        mainVc.contextPut("alreadyin", listNames(alreadyIn));
        mainVc.contextPut("usercount", new Integer(oks.size()));
        // set table page as next wizard step
        setNextWizardStep(translate("import.title.finish"), mainVc);
      }

    } else if (source == mailCtr) {
      if (event == Event.DONE_EVENT) {
        final MultiIdentityChosenEvent multiEvent = new MultiIdentityChosenEvent(this.oks);
        multiEvent.setMailTemplate(mailCtr.getMailTemplate());
        fireEvent(ureq, multiEvent);
      }
    }
  }