19 package org.turro.commentit;
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import org.amic.util.date.CheckDate;
26 import org.turro.string.Strings;
27 import org.apache.commons.mail.EmailException;
28 import org.turro.assistant.AssistantConstants;
29 import org.turro.contacts.CommentIt;
30 import org.turro.contacts.Contact;
31 import org.turro.contacts.db.ContactsPU;
32 import org.turro.elephant.context.ElephantContext;
33 import org.turro.entities.Entities;
34 import org.turro.entities.IElephantEntity;
35 import org.turro.html.HTMLEntities;
36 import org.turro.i18n.I_;
37 import org.turro.jpa.Dao;
38 import org.turro.mail.queue.GenericElephantNotification;
39 import org.turro.mail.sender.MailQueue;
40 import org.turro.plugin.contacts.SoftContact;
56 if(!Strings.isBlank(path) && contact !=
null && contact.
isValid()) {
67 dao.saveObject(commentIt);
73 .addByRole(
"PublicationAdmin")
74 .setReason(
I_.
get(
"Pending revision"))
76 .put(
"commentIt", commentIt)
77 .sendTemplate(
"new-comment",
I_.
get(
"New comment"));
78 }
catch (EmailException ex) {
93 .setReason(
I_.
get(
"Comments"))
95 .put(
"commentIt", comment)
97 .sendTemplate(
"comment",
I_.
get(
"Comment"));
98 }
catch (EmailException ex) {
103 public static void remove(String id) {
106 " delete from CommentIt c " +
107 " where c.id = '" +
id +
"'"
122 return dao.getResultList(
123 " select c from CommentIt c " +
125 " and (accepted = TRUE or creator = ?) " +
126 " order by dateCreation ",
130 return dao.getResultList(
131 " select c from CommentIt c " +
133 " and (accepted = TRUE or author_ip = ?) " +
134 " order by dateCreation ",
150 return dao.getResultList(
151 " select c from CommentIt c " +
153 " order by dateCreation ",
154 new Object[] { path }
158 public static Collection<CommentIt>
pending() {
160 return dao.getResultList(
161 " select c from CommentIt c " +
162 " where accepted = FALSE " +
163 " order by dateCreation "
170 " select count(c) from CommentIt c " +
171 " where accepted = FALSE "
178 " select count(c) from CommentIt c "
185 return count(path, contact);
195 " select count(c) from CommentIt c " +
197 " and (accepted = TRUE or creator = ?) " +
198 " order by dateCreation desc ",
202 count = (Long) dao.getSingleResultOrNull(
203 " select count(c) from CommentIt c " +
205 " and (accepted = TRUE or author_ip = ?) " +
206 " order by dateCreation desc ",
207 new Object[] { path, contact.author_ip }
216 public static Collection<String>
paths(String path,
int fromDays) {
218 return dao.getResultList(
219 " select g.path from CommentIt g " +
220 " where g.path like ? " +
221 " and g.dateCreation >= ?",
222 new Object[] { path +
"/%",
new CheckDate().addDays(-fromDays).getDate() }
static String participants()
static String logMsg(String msg)
static IElephantEntity getController(String path)
static String escape(String html)
static String get(String msg)
int executeUpdate(String query)
Object getSingleResultOrNull(SqlClause sc)
static final String GENERIC_NOTIFICATION
IMailSender setRoot(String root)