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.Forum; 51 import net.jforum.entities.Topic; 52 import net.jforum.entities.User; 53 import net.jforum.util.preferences.ConfigKeys; 54 import net.jforum.util.preferences.SystemGlobals; 55 import net.jforum.view.forum.common.ViewCommon; 56 import freemarker.template.SimpleHash; 57 58 62 public class ForumSpammer extends Spammer 63 { 64 public ForumSpammer(Forum forum, Topic topic, List users) 65 { 66 List recipients = new ArrayList (); 69 for (Iterator iter = users.iterator(); iter.hasNext(); ) { 70 User u = (User)iter.next(); 71 72 recipients.add(u.getEmail()); 73 } 74 75 String page = ""; 77 int postsPerPage = SystemGlobals.getIntValue(ConfigKeys.POST_PER_PAGE); 78 if (topic.getTotalReplies() > postsPerPage) { 79 page += (((topic.getTotalReplies() / postsPerPage)) * postsPerPage) + "/"; 80 } 81 82 String forumLink = ViewCommon.getForumLink(); 83 84 String path = forumLink + "posts/list/" + page + topic.getId() 85 + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION) + "#" + topic.getLastPostId(); 86 87 String unwatch = forumLink + "forums/unwatchForum/" + forum.getId() 88 + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION); 89 90 SimpleHash params = new SimpleHash(); 91 params.put("topic", topic); 92 params.put("path", path); 93 params.put("forumLink", forumLink); 94 params.put("unwatch", unwatch); 95 96 super.prepareMessage(recipients, params, 97 MessageFormat.format(SystemGlobals.getValue(ConfigKeys.MAIL_NEW_TOPIC_SUBJECT), new Object [] { topic.getTitle() }), 98 SystemGlobals.getValue(ConfigKeys.MAIL_NEW_TOPIC_MESSAGE_FILE)); 99 } 100 } 101 | Popular Tags |