Package org.olat.core.util.mail

Examples of org.olat.core.util.mail.MailerWithTemplate


        identitiesMoveEvent.setMovedIdentities(response.getAddedIdentities());
        // Participant and waiting-list were changed => reload both
        partipGrpCntrllr.reloadData();
        waitingGruppeController.reloadData();
        // send mail for all of them
        MailerWithTemplate mailer = MailerWithTemplate.getInstance();
        MailTemplate mailTemplate = identitiesMoveEvent.getMailTemplate();
        if (mailTemplate != null) {
          MailerResult mailerResult = mailer.sendMailAsSeparateMails(identitiesMoveEvent.getMovedIdentities(), null, null, mailTemplate, null);
          MailHelper.printErrorsAndWarnings(mailerResult, getWindowControl(), ureq.getLocale());
        }
        fireEvent(ureq, Event.CHANGED_EVENT );   
      }
    } else if (source == this.modifyBusinessGroupController) {
View Full Code Here


   */
  public String sendUserDeleteEmailTo(List<Identity> selectedIdentities, MailTemplate template,
      boolean isTemplateChanged, String keyEmailSubject, String keyEmailBody, Identity sender, Translator pT ) {
    StringBuilder buf = new StringBuilder();
    if (template != null) {
      MailerWithTemplate mailer = MailerWithTemplate.getInstance();
      template.addToContext("responseTo", emailResponseTo);
      for (Iterator iter = selectedIdentities.iterator(); iter.hasNext();) {
        Identity identity = (Identity)iter.next();
        if (!isTemplateChanged) {
          // Email template has NOT changed => take translated version of subject and body text
          Translator identityTranslator = Util.createPackageTranslator(SelectionController.class, I18nManager.getInstance().getLocaleOrDefault(identity.getUser().getPreferences().getLanguage()));
          template.setSubjectTemplate(identityTranslator.translate(keyEmailSubject));
          template.setBodyTemplate(identityTranslator.translate(keyEmailBody));
        }
        template.putVariablesInMailContext(template.getContext(), identity);
        Tracing.logDebug(" Try to send Delete-email to identity=" + identity.getName() + " with email=" + identity.getUser().getProperty(UserConstants.EMAIL, null), this.getClass());
        List<Identity> ccIdentities = new ArrayList<Identity>();
        if(template.getCpfrom()) {
          ccIdentities.add(sender);
        } else {
          ccIdentities = null
        }
        MailerResult mailerResult = mailer.sendMailUsingTemplateContext(identity, ccIdentities, null, template, sender);
        if (mailerResult.getReturnCode() != MailerResult.OK) {
          buf.append(pT.translate("email.error.send.failed", new String[] {identity.getUser().getProperty(UserConstants.EMAIL, null), identity.getName()} )).append("\n");
        }
        Tracing.logAudit("User-Deletion: Delete-email send to identity=" + identity.getName() + " with email=" + identity.getUser().getProperty(UserConstants.EMAIL, null), this.getClass());
        markSendEmailEvent(identity);
View Full Code Here

      tableCtr.modelChanged();
    }

    // send the notification mail
    if (mailTemplate != null) {
      MailerWithTemplate mailer = MailerWithTemplate.getInstance();
      Identity sender = ureq.getIdentity();
      List<Identity> ccIdentities = new ArrayList<Identity>();
      if(mailTemplate.getCpfrom()) {
        ccIdentities.add(sender);
      } else {
        ccIdentities = null
      }
      MailerResult mailerResult = mailer.sendMailAsSeparateMails(toBeRemoved, ccIdentities, null, mailTemplate, sender);
      MailHelper.printErrorsAndWarnings(mailerResult, getWindowControl(), ureq.getLocale());
    }
  }
View Full Code Here

      infoMessage.append(translate("msg.subjectalreadyingroup", identity.getName())).append("<br />");
    }
    // send the notification mail fro added users
    StringBuilder errorMessage = new StringBuilder();
    if (mailTemplate != null) {
      MailerWithTemplate mailer = MailerWithTemplate.getInstance();
      Identity sender = ureq.getIdentity();
      List<Identity> ccIdentities = new ArrayList<Identity>();
      if(mailTemplate.getCpfrom()) {
        ccIdentities.add(sender);
      } else {
        ccIdentities = null
      }
      MailerResult mailerResult = mailer.sendMailAsSeparateMails(identitiesAddedEvent.getAddedIdentities(), ccIdentities, null, mailTemplate, sender);
      MailHelper.appendErrorsAndWarnings(mailerResult, errorMessage, infoMessage, ureq.getLocale());
    }
    // report any errors on screen
    if (infoMessage.length() > 0) getWindowControl().setWarning(infoMessage.toString());
    if (errorMessage.length() > 0) getWindowControl().setError(errorMessage.toString());
View Full Code Here

      StepRunnerCallback finishCallback = new StepRunnerCallback() {
        @SuppressWarnings({"synthetic-access","unused"})
        public Step execute(UserRequest ureq2, WindowControl control, StepsRunContext runContext) {
          MailTemplate mailtemplate = (MailTemplate)runContext.get("mailtemplate");
          //fetch data from runContext and send eMail with it
          MailerWithTemplate mailer = MailerWithTemplate.getInstance();
          Identity replyto = (Identity)runContext.get("replyto");
          MailerResult mr = mailer.sendMail(ureq2.getIdentity(), null, null, mailtemplate, replyto);
          logAudit("DRUCKEREI-TEMPLATE-ERSTELLT", null);
          if(mr.getReturnCode() == MailerResult.OK){
            return StepsMainRunController.DONE_UNCHANGED;
          }else{
            return Step.NOSTEP;
View Full Code Here

      users.addAll(waiting);
    }
    // now delete the group first
    deleteBusinessGroup(businessGroupTodelete);
    // finally send email
    MailerWithTemplate mailer = MailerWithTemplate.getInstance();
    MailTemplate mailTemplate = BGMailHelper.createDeleteGroupMailTemplate(businessGroupTodelete, ureq.getIdentity());
    if (mailTemplate != null) {
      MailerResult mailerResult = mailer.sendMailAsSeparateMails(users, null, null, mailTemplate, null);
      MailHelper.printErrorsAndWarnings(mailerResult, wControl, ureq.getLocale());
    }
   
  }
View Full Code Here

              ThreadLocalUserActivityLogger.setStickyActionType(formerStickyActionType);
            }
            // send a notification mail if available
            MailTemplate mailTemplate = BGMailHelper.createWaitinglistTransferMailTemplate(group, ureqIdentity);
            if (mailTemplate != null) {
              MailerWithTemplate mailer = MailerWithTemplate.getInstance();
              MailerResult mailerResult = mailer.sendMail(firstWaitingListIdentity, null, null, mailTemplate, null);
              // Does not report errors to current screen because this is the identity who triggered the transfer
              Tracing.logWarn("Could not send WaitinglistTransferMail for identity=" + firstWaitingListIdentity.getName() , BusinessGroupManagerImpl.class);
            }           
            transferNotDone = false;
          }
View Full Code Here

        ProjectBrokerManagerFactory.getProjectGroupManager().acceptCandidates(identitiesMoveEvent.getChosenIdentities(), project, urequest.getIdentity(),
                                    projectBrokerModuleConfiguration.isAutoSignOut(), projectBrokerModuleConfiguration.isAcceptSelectionManually());
        identitiesMoveEvent.setMovedIdentities(identitiesMoveEvent.getChosenIdentities());
        identitiesMoveEvent.setNotMovedIdentities(new ArrayList());
        // send mail for all of them
        MailerWithTemplate mailer = MailerWithTemplate.getInstance();
        MailTemplate mailTemplate = identitiesMoveEvent.getMailTemplate();
        if (mailTemplate != null) {
          List<Identity> ccIdentities = new ArrayList<Identity>();
          if(mailTemplate.getCpfrom()) {
            // add sender as CC
            ccIdentities.add(urequest.getIdentity());
          } else {
            ccIdentities = null
          }
          MailerResult mailerResult = mailer.sendMailAsSeparateMails(identitiesMoveEvent.getMovedIdentities(), ccIdentities, null, mailTemplate, null);
          MailHelper.printErrorsAndWarnings(mailerResult, getWindowControl(), urequest.getLocale());
        }
        fireEvent(urequest, Event.CHANGED_EVENT );   
        // Participant and waiting-list were changed => reload both
        projectMemberController.reloadData();
View Full Code Here

  public String sendDeleteEmailTo(List selectedGroups, MailTemplate mailTemplate, boolean isTemplateChanged, String keyEmailSubject,
      String keyEmailBody, Identity sender, PackageTranslator pT) {
    StringBuffer warningMessage = new StringBuffer();
    if (mailTemplate != null) {
      MailerWithTemplate mailer = MailerWithTemplate.getInstance();
      HashMap identityGroupList = new HashMap();
      for (Iterator iter = selectedGroups.iterator(); iter.hasNext();) {
        BusinessGroup group = (BusinessGroup)iter.next();
     
        // Build owner group, list of identities
        SecurityGroup ownerGroup = group.getOwnerGroup();
        List ownerIdentities = ManagerFactory.getManager().getIdentitiesOfSecurityGroup(ownerGroup);
        // loop over this list and send email
        for (Iterator iterator = ownerIdentities.iterator(); iterator.hasNext();) {
          Identity identity = (Identity) iterator.next();
          if (identityGroupList.containsKey(identity) ) {
            List groupsOfIdentity = (List)identityGroupList.get(identity);
            groupsOfIdentity.add(group);
          } else {
            List groupsOfIdentity = new ArrayList();
            groupsOfIdentity.add(group);
            identityGroupList.put(identity, groupsOfIdentity);
          }       
        }
      }
      //   loop over identity list and send email
      for (Iterator iterator = identityGroupList.keySet().iterator(); iterator.hasNext();) {
        Identity identity = (Identity) iterator.next();
           
        mailTemplate.addToContext("responseTo", emailResponseTo);
        if (!isTemplateChanged) {
          // Email template has NOT changed => take translated version of subject and body text
          Translator identityTranslator = new PackageTranslator(PACKAGE, I18nManager.getInstance().getLocaleOrDefault(identity.getUser().getPreferences().getLanguage()));
          mailTemplate.setSubjectTemplate(identityTranslator.translate(keyEmailSubject));
          mailTemplate.setBodyTemplate(identityTranslator.translate(keyEmailBody));
        }
        // loop over all repositoriesOfIdentity to build email message
        StringBuilder buf = new StringBuilder();
        for (Iterator groupIterator = ((List)identityGroupList.get(identity)).iterator(); groupIterator.hasNext();) {
          BusinessGroup group = (BusinessGroup) groupIterator.next();
          buf.append("\n  ").append( group.getName() ).append(" / ").append(FilterFactory.getHtmlTagsFilter().filter(group.getDescription()));
        }
        mailTemplate.addToContext("groupList", buf.toString());
        mailTemplate.putVariablesInMailContext(mailTemplate.getContext(), identity);
        Tracing.logDebug(" Try to send Delete-email to identity=" + identity.getName() + " with email=" + identity.getUser().getProperty(UserConstants.EMAIL, null), this.getClass());
        List<Identity> ccIdentities = new ArrayList<Identity>();
        if(mailTemplate.getCpfrom()) {
          ccIdentities.add(sender);
        } else {
          ccIdentities = null
        }
        MailerResult mailerResult = mailer.sendMailUsingTemplateContext(identity, ccIdentities, null, mailTemplate, sender);
        if (mailerResult.getReturnCode() == MailerResult.OK) {
          // Email sended ok => set deleteEmailDate
          for (Iterator groupIterator = ((List)identityGroupList.get(identity)).iterator(); groupIterator.hasNext();) {
            BusinessGroup group = (BusinessGroup) groupIterator.next();
            Tracing.logAudit("Group-Deletion: Delete-email send to identity=" + identity.getName() + " with email=" + identity.getUser().getProperty(UserConstants.EMAIL, null) + " for group=" + group, this.getClass());
View Full Code Here

      }});
   

    // 3. Send notification mail
    MailTemplate mailTemplate = BGMailHelper.createRemoveMyselfMailTemplate(enrolledGroup, identity);
    MailerWithTemplate mailer = MailerWithTemplate.getInstance();
    MailerResult mailerResult = mailer.sendMail(identity, null, null, mailTemplate, null);
    MailHelper.printErrorsAndWarnings(mailerResult, wControl, trans.getLocale());
  }
View Full Code Here

TOP

Related Classes of org.olat.core.util.mail.MailerWithTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.