1 43 package net.jforum.util.mail; 44 45 import java.text.MessageFormat ; 46 import java.util.ArrayList ; 47 import java.util.Iterator ; 48 import java.util.List ; 49 50 import net.jforum.entities.Topic; 51 import net.jforum.entities.User; 52 import net.jforum.util.preferences.ConfigKeys; 53 import net.jforum.util.preferences.SystemGlobals; 54 import net.jforum.view.forum.common.ViewCommon; 55 import freemarker.template.SimpleHash; 56 57 61 public class TopicSpammer extends Spammer 62 { 63 public TopicSpammer(Topic topic, List users) 64 { 65 List recipients = new ArrayList (); 68 for (Iterator iter = users.iterator(); iter.hasNext(); ) { 69 User u = (User)iter.next(); 70 71 recipients.add(u.getEmail()); 72 } 73 74 String page = ""; 76 int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE); 77 if (topic.getTotalReplies() > postsPerPage) { 78 page += (((topic.getTotalReplies() / postsPerPage)) * postsPerPage) + '/'; 79 } 80 81 String forumLink = ViewCommon.getForumLink(); 82 83 String path = forumLink + "posts/list/" + page + topic.getId() 84 + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION) + "#" + topic.getLastPostId(); 85 86 String unwatch = forumLink + "posts/unwatch/" + topic.getId() 87 + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION); 88 89 SimpleHash params = new SimpleHash(); 90 params.put("topic", topic); 91 params.put("path", path); 92 params.put("forumLink", forumLink); 93 params.put("unwatch", unwatch); 94 95 super.prepareMessage(recipients, params, 96 MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_SUBJECT), new Object [] { topic.getTitle() }), 97 SystemGlobals.getValue(ConfigKeys.MAIL_NEW_ANSWER_MESSAGE_FILE)); 98 } 99 } 100 | Popular Tags |