Package org.olat.core.util.mail

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


 
  private boolean hasAtLeastOneAddress(List recipList) {
    boolean hasAtLeastOneAddress = false;
    if (recipList != null && recipList.size() > 0 ) {
      for (Iterator iter = recipList.iterator(); iter.hasNext();) {
        ContactList cl = (ContactList) iter.next();
        if (!hasAtLeastOneAddress && cl != null && cl.getEmailsAsStrings().size() > 0) {
          hasAtLeastOneAddress = true;
        }
        if (cl.getEmailsAsStrings().size() > 0) cntctForm.addEmailTo(cl);
      }
    }
    return hasAtLeastOneAddress;
  }
View Full Code Here


        Emailer emailer = new Emailer(emailFrom, useInstitutionalEmail);
        //
        boolean success = false;
        try {
          if(cntctForm.getCheckBoxElement("tcpfrom").isChecked()) {
            ContactList contactList = new ContactList(translate("contact.list.sender"));
            contactList.add(emailFrom);                                            
             cntctForm.addEmailTo(contactList);
          }
          success = emailer.sendEmail(cntctForm.getEmailToContactLists(), cntctForm.getSubject(), cntctForm.getBody());
        } catch (AddressException e) {
          //error in recipient email address(es)
View Full Code Here

   * @param emailList
   */
  public void addEmailTo(ContactList emailList) {
    if (contactLists.containsKey(emailList.getName())) {
      //there is already a ContactList with this name...
      ContactList existing = (ContactList) contactLists.get(emailList.getName());
      //, merge their values.
      existing.add(emailList);
      //the form itself must not be updated, because it already displays
      // the name.
    } else {
      //a new ContactList, put it into contactLists
      contactLists.put(emailList.getName(), emailList);
View Full Code Here

    while (i > -1 && j > 0) {
      String contactListName = value.substring(i + 1, j);
      i = value.indexOf("<", j + 1);
      j = value.indexOf(">", j + 2);
      if (contactLists.containsKey(contactListName)) {
        ContactList found = (ContactList) contactLists.get(contactListName);
        retVal += sep + found.toString();
        sep = ", ";
      }
    }
    return retVal;
  }
View Full Code Here

    };
   
    String subject = translate("mail.subject");
    String body = getTranslator().translate("mail.body", bodyArgs);
   
    ContactList cl = new ContactList(WebappHelper.getMailConfig("mailSupport"));
    cl.add(WebappHelper.getMailConfig("mailSupport"));
    cl.add(ureq.getIdentity());
    List<ContactList> lstAddrTO = new ArrayList<ContactList>();
    lstAddrTO.add(cl);
   
    Emailer mailer = new Emailer(ureq.getLocale());
    try {
View Full Code Here

   * @param ureq
   */
  private void doBuddyGroupDelete(UserRequest ureq) {
    // 1) send notification mails to users
    Manager securityManager = ManagerFactory.getManager();
    ContactList owners = new ContactList(translate("userlist.owners.title"));
    List ow = securityManager.getIdentitiesOfSecurityGroup(currBusinessGroup.getOwnerGroup());
    owners.addAllIdentites(ow);
    ContactList participants = new ContactList(translate("userlist.participants.title"));
    participants.addAllIdentites(securityManager.getIdentitiesOfSecurityGroup(currBusinessGroup.getPartipiciantGroup()));
    // check if user is in owner group (could fake link in table)
    if (!PersistenceHelper.listContainsObjectByKey(ow, ureq.getIdentity())) {
      Tracing.logWarn("User tried to delete a group but he was not owner of the group", null, BGMainController.class);
      return;
    }
View Full Code Here

          removeAsListenerAndDispose(contactCtr);
          // create e-mail message
          ContactMessage cmsg = new ContactMessage(ureq.getIdentity());

          selectedIdentities = tdm.getIdentities(tmse.getSelection());
          ContactList contacts = new ContactList(translate("mailto.userlist"));
          contacts.addAllIdentites(selectedIdentities);
          cmsg.addEmailTo(contacts);

          // create contact form controller with ContactMessage
          contactCtr = new ContactFormController(ureq, getWindowControl(), false, true, false, false, cmsg);
          listenTo(contactCtr);
View Full Code Here

    Manager scrtMngr = ManagerFactory.getManager();

    ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
    // two named ContactLists, the new way using the contact form
    // the same name as in the checkboxes are taken as contactlist names
    ContactList ownerCntctLst;// = new ContactList(translate("sendtochooser.form.chckbx.owners"));
    ContactList partipCntctLst;// = new ContactList(translate("sendtochooser.form.chckbx.partip"));
    ContactList waitingListContactList;// = new ContactList(translate("sendtochooser.form.chckbx.waitingList"));
    if (flags.isEnabled(BGConfigFlags.GROUP_OWNERS)) {
      if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
        ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.all"));
        SecurityGroup owners = businessGroup.getOwnerGroup();
        List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
        ownerCntctLst.addAllIdentites(ownerList);
        cmsg.addEmailTo(ownerCntctLst);
      } else {
        if (sendToChooserForm.ownerChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
          ownerCntctLst = new ContactList(translate("sendtochooser.form.radio.owners.choose"));
          SecurityGroup owners = businessGroup.getOwnerGroup();
          List<Identity> ownerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
          List<Identity> changeableOwnerList = scrtMngr.getIdentitiesOfSecurityGroup(owners);
          for (Identity identity : ownerList) {
            boolean keyIsSelected = false;
            for (Long key : sendToChooserForm.getSelectedOwnerKeys()) {
              if (key.equals(identity.getKey())) {
                keyIsSelected = true;
                break;
              }
            }
            if (!keyIsSelected) {
              changeableOwnerList.remove(changeableOwnerList.indexOf(identity));
            }
          }
          ownerCntctLst.addAllIdentites(changeableOwnerList);
          cmsg.addEmailTo(ownerCntctLst);
        }
      }
    }
    if (sendToChooserForm != null) {
      if  (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
        partipCntctLst  = new ContactList(translate("sendtochooser.form.radio.partip.all"));
        SecurityGroup participants = businessGroup.getPartipiciantGroup();
        List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
        partipCntctLst.addAllIdentites(participantsList);
        cmsg.addEmailTo(partipCntctLst);
      } else {
        if (sendToChooserForm.participantChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
          partipCntctLst  = new ContactList(translate("sendtochooser.form.radio.partip.choose"));
          SecurityGroup participants = businessGroup.getPartipiciantGroup();
          List<Identity> participantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
          List<Identity> changeableParticipantsList = scrtMngr.getIdentitiesOfSecurityGroup(participants);
          for (Identity identity : participantsList) {
            boolean keyIsSelected = false;
            for (Long key : sendToChooserForm.getSelectedPartipKeys()) {
              if (key.equals(identity.getKey())) {
                keyIsSelected = true;
                break;
              }
            }
            if (!keyIsSelected) {
              changeableParticipantsList.remove(changeableParticipantsList.indexOf(identity));
            }
          }
          partipCntctLst.addAllIdentites(changeableParticipantsList);
          cmsg.addEmailTo(partipCntctLst);
        }
      }
     
    }
    if (sendToChooserForm != null && isAdmin && businessGroup.getWaitingListEnabled().booleanValue()) {
      if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_ALL)) {
        waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.all"));
        SecurityGroup waitingList = businessGroup.getWaitingGroup();
        List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
        waitingListContactList.addAllIdentites(waitingListIdentities);
        cmsg.addEmailTo(waitingListContactList);
      } else {
        if (sendToChooserForm.waitingListChecked().equals(BusinessGroupSendToChooserForm.NLS_RADIO_CHOOSE)) {
          waitingListContactList = new ContactList(translate("sendtochooser.form.radio.waitings.choose"));
          SecurityGroup waitingList = businessGroup.getWaitingGroup();
          List<Identity> waitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
          List<Identity> changeableWaitingListIdentities = scrtMngr.getIdentitiesOfSecurityGroup(waitingList);
          for (Identity indentity : waitingListIdentities) {
            boolean keyIsSelected = false;
            for (Long key : sendToChooserForm.getSelectedWaitingKeys()) {
              if (key.equals(indentity.getKey())) {
                keyIsSelected = true;
                break;
              }
            }
            if (!keyIsSelected) {
              changeableWaitingListIdentities.remove(changeableWaitingListIdentities.indexOf(indentity));
            }
          }
          waitingListContactList.addAllIdentites(changeableWaitingListIdentities);
          cmsg.addEmailTo(waitingListContactList);
        }
      }
    }
   
View Full Code Here

    boolean valid = false; // true if at least one email adress
    Stack<ContactList> contactLists = new Stack<ContactList>();
    Boolean partipsConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOPARTICIPANTS);
    if (partipsConfigured != null && partipsConfigured.booleanValue()) {
      ContactList participantsEmailList = retrieveParticipants();
      if (participantsEmailList != null && participantsEmailList.getEmailsAsStrings().size()>0) {
        contactLists.push(participantsEmailList);
        valid = true;
      }
    }
    Boolean coachesConfigured = moduleConfiguration.getBooleanEntry(COEditController.CONFIG_KEY_EMAILTOCOACHES);
    if (coachesConfigured!=null && coachesConfigured.booleanValue()) {
      ContactList coachesEmailList = retrieveCoaches();
      if (coachesEmailList != null && coachesEmailList.getEmailsAsStrings().size()>0){
        contactLists.push(coachesEmailList);
        valid = true;
      }
    }
    String groups = (String)moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOGROUPS);
    if (groups != null && !groups.equals("")) {
      ContactList[] groupsCL = retrieveGroups(groups);
      if (groupsCL.length > 0){
        for (int i = 0; i < groupsCL.length; i++) {
          if(groupsCL[i].getEmailsAsStrings().size() > 0){
            contactLists.push(groupsCL[i]);
            valid=true;
          }
        }
      }
    }
    String areas = (String) moduleConfiguration.get(COEditController.CONFIG_KEY_EMAILTOAREAS);
    if (areas != null && !areas.equals("")) {
      ContactList[] areasCL = retrieveAreas(areas);
      if (areasCL.length > 0){
        for (int i = 0; i < areasCL.length; i++) {
          if(areasCL[i].getEmailsAsStrings().size() > 0){
            contactLists.push(areasCL[i]);
            valid = true;
          }
        }
      }
    }

    // Adding contact form
    if (emailListConfig != null) {
      ContactList emailList = new ContactList(translate("recipients"));
      for (Iterator<String> iter = emailListConfig.iterator(); iter.hasNext();) {
        String email = iter.next();
        emailList.add(email);
      }
      contactLists.push(emailList);
      valid = true;
    }

    if (valid){ // at least one email adress
      ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
     
      while (!contactLists.empty()) {
        ContactList cl = contactLists.pop();
        cmsg.addEmailTo(cl);
      }
      cmsg.setBodyText(mBody);
      cmsg.setSubject(mSubject);
      coFoCtr = new ContactFormController(ureq, getWindowControl(), true,false,false,false, cmsg);
View Full Code Here

  private ContactList retrieveCoaches() {
    CourseGroupManager cgm = this.userCourseEnv.getCourseEnvironment().getCourseGroupManager();
    List<Identity> coaches = cgm.getCoachesFromLearningGroup(null);
    Set<Identity> coachesWithoutDuplicates = new HashSet<Identity>(coaches);
    coaches = new ArrayList<Identity>(coachesWithoutDuplicates);
    ContactList cl = new ContactList(translate("form.message.chckbx.coaches"));
    cl.addAllIdentites(coaches);
    return cl;
  }
View Full Code Here

TOP

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

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.