% /****************************************************************************** * Copyright (c) 2000-2004 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. * * ******************************************************************************/ %><%@page session="true"%> <%@ page import="com.edeal.frontline.navigation.FlRequest" %> <%@ page import="com.edeal.frontline.FlContext" %> <%@ page import="com.edeal.frontline.Utils" %> <%@ page import="com.edeal.frontline.FieldNotInitializedException" %> <%@ page import="com.edeal.frontline.AccessDeniedException" %> <%@ page import="com.edeal.frontline.DataDictionary" %> <%@ page import="com.edeal.frontline.EMailingBean" %> <%@ page import="com.edeal.frontline.MessagesBean" %> <%@ page import="com.edeal.frontline.PopulationBean" %> <%@ page import="com.edeal.frontline.BasicBean" %> <%@ page import="com.edeal.frontline.FlLocale" %> <%@ page import="java.util.Date" %> <%@ page import="java.util.Hashtable" %> <%@ page import="com.edeal.frontline.FrontlineException" %> <%@ page import="java.util.Vector" %> <%@ page import="com.edeal.frontline.FlLocale" %> <%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %> <% //CONSTANTES DE LIMITES //LIMITE DE TAILLE DU MESSAGE EN KILOOCTETS AU-DELA DE LAQUELLE L'ENVOI DOIT ETRE REGULE int MAX_MSG_SIZE = 50; //LIMITE DE NOMBRE D'INDIVIDUS DE LA POPULATION OU D'ABONNES AUX NEWSLETTERS AU-DELA DE LAQUELLE L'ENVOI DOIT ETRE REGULE int MAX_POP_SIZE = 2000; final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); DataDictionary dico = context.getDataDictionary(); String SfwID = flRequest.getRequestParameterOrAttribute("SfwID"); String strActID = (String)session.getAttribute("actorID"); String emaID = flRequest.getRequestParameterOrAttribute("emaID"); String ctl = flRequest.getRequestParameterOrAttribute("ctl"); boolean hasToBeQueued = false; EMailingBean ema = null; String date = ""; String time = ""; try { ema = new EMailingBean(emaID, context); Date sendDate = ema.getEmaDate(); //SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); java.text.SimpleDateFormat sdf = FlLocale.getInstance(session).getTimeFormat(false); time = Utils.formatToWeb(sdf.format((Date) sendDate), true); sdf = new java.text.SimpleDateFormat("dd/MM/yyyy"); date = Utils.formatToWeb(sdf.format((Date) sendDate), true); } catch (FrontlineException e) { } catch (AccessDeniedException e) { } //check size of html msg if (!"1".equals(ctl) && !hasToBeQueued) { MessagesBean message = null; try { message = new MessagesBean(ema.getEmaHtmlMsgID(), context); int size = message.getMailSize(); if(size > MAX_MSG_SIZE * 1000) hasToBeQueued = true; } catch (FrontlineException e) { } catch (AccessDeniedException e) { } } //check size of text msg if (!"1".equals(ctl) && !hasToBeQueued) { MessagesBean message = null; try { message = new MessagesBean(ema.getEmaTextMsgID(), context); int size = message.getMailSize(); if(size > MAX_MSG_SIZE * 1000) hasToBeQueued = true; } catch (FrontlineException e) { } catch (AccessDeniedException e) { } } //check size of population if (!"1".equals(ctl) && !hasToBeQueued && ema.getEmaPopTypID().equals(dico.getRefIdByCode("EmaPopTypID", "POPULATION"))) { PopulationBean population = null; try { population = new PopulationBean(ema.getEmaPopID(), context); int size = population.getPopTotNbr() + population.getPopAddNbr() - population.getPopRmvNbr(); //logger.debug("population size " + size); if(size > MAX_POP_SIZE) hasToBeQueued = true; } catch (FrontlineException e) { } catch (AccessDeniedException e) { } } //check number of individuals to send to if (!"1".equals(ctl) && !hasToBeQueued && ema.getEmaPopTypID().equals(dico.getRefIdByCode("EmaPopTypID", "NEWSLETTER"))) { // 20021203 : RaF : nouvelle gestion des multival int total = 0; String[] countFields = {"count"}; StringBuffer countQuery = new StringBuffer(); countQuery.append("SELECT count(DISTINCT m1.MvaColID) FROM MvaPerNltID m1, EMailing, MvaEmaNltID m2 WHERE m1.MvaText = m2.MvaText AND EmaID = m2.MvaColID "); countQuery.append("UNION "); countQuery.append("SELECT count(DISTINCT m1.MvaColID) FROM MvaSilNltID m1, EMailing, MvaEmaNltID m2 WHERE m1.MvaText = m2.MvaText AND EmaID = m2.MvaColID "); Vector vCount = BasicBean.listSQL(context, countFields, countQuery.toString()); if (vCount != null && vCount.size() > 0) { for (int i = 0; i < vCount.size(); i++) { Hashtable row = (Hashtable)vCount.elementAt(i); total += ((Number)row.get("count")).intValue(); } } if (total > MAX_POP_SIZE) hasToBeQueued = true; } //depending on the size of the population and the size of the message, we could have two or three radio buttons, //which complicates the javascript a little... String indexImmediat1 = hasToBeQueued ? "-1" : "0"; String indexImmediat2 = hasToBeQueued ? "0" : "1"; String indexDiffere = hasToBeQueued ? "1" : "2"; %>