public ActionForward process(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws SystemException {
MessageResources messages = getResources(request);
HttpSession session = request.getSession();
SendAdminMailForm samForm = (SendAdminMailForm) form;
User user = (User) session.getAttribute(IConst.SESSION.USER_KEY);
UserDAO dao = UserDAO.getInstance();
MessageProcessor mp = MessageProcessor.getInstance();
String mess = mp.prepareMessage(HtmlCodec.encode(samForm.getText()), 0,
messages);
StringBuffer siteUrl = new StringBuffer();
siteUrl.append(request.getServerName());
siteUrl.append(":");
siteUrl.append(request.getServerPort());
siteUrl.append(request.getContextPath());
siteUrl.append(Configurator.getInstance().get(
IConst.CONFIG.MODULE_PREFIX));
siteUrl.append("/");
/*
* {0} - login {1} - message text {2} - site url {3} - site name
*/
Object[] messArgs = new Object[] { "", mp.nl2br(mess),
siteUrl.toString(),
Configurator.getInstance().get(IConst.CONFIG.SITE_NAME) };
MailQueue queue = (MailQueue) session.getServletContext().getAttribute(
IConst.CONTEXT.MAIL_QUEUE);
try {
ArrayList userMails = dao.getUserEmails();
Iterator it = userMails.iterator();
BanGuard guard = BanGuard.getInstance();
while (it.hasNext()) {
NamedValue nv = (NamedValue) it.next();
if (!guard.checkBan(nv.getValue(), BanType.EMAIL)
&& !user.getName().equals(nv.getName())) {
messArgs[0] = nv.getName();
queue.push(new MailMessage(messages.getMessage(
"mails.ADMIN_MAIL", messArgs),
samForm.getSubject(), Configurator.getInstance()
.get(IConst.CONFIG.ADMINMAIL), user
.getName(), nv.getValue(), nv.getName()));
}
}
request.removeAttribute("sendAdminMailForm");