1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.suggest.web;
35
36 import java.math.BigDecimal;
37 import java.sql.Timestamp;
38 import java.util.ArrayList;
39 import java.util.Arrays;
40 import java.util.Collection;
41 import java.util.Date;
42 import java.util.HashMap;
43 import java.util.List;
44 import java.util.Locale;
45 import java.util.Map;
46
47 import javax.servlet.http.HttpServletRequest;
48 import javax.servlet.http.HttpServletResponse;
49
50 import org.apache.commons.fileupload.FileItem;
51 import org.apache.commons.lang3.StringUtils;
52 import org.apache.commons.lang3.math.NumberUtils;
53
54 import fr.paris.lutece.api.user.User;
55 import fr.paris.lutece.plugins.suggest.business.Category;
56 import fr.paris.lutece.plugins.suggest.business.CategoryHome;
57 import fr.paris.lutece.plugins.suggest.business.CommentSubmit;
58 import fr.paris.lutece.plugins.suggest.business.DefaultMessage;
59 import fr.paris.lutece.plugins.suggest.business.DefaultMessageHome;
60 import fr.paris.lutece.plugins.suggest.business.Suggest;
61 import fr.paris.lutece.plugins.suggest.business.SuggestAction;
62 import fr.paris.lutece.plugins.suggest.business.SuggestActionHome;
63 import fr.paris.lutece.plugins.suggest.business.SuggestFilter;
64 import fr.paris.lutece.plugins.suggest.business.SuggestHome;
65 import fr.paris.lutece.plugins.suggest.business.SuggestSubmit;
66 import fr.paris.lutece.plugins.suggest.business.SuggestSubmitState;
67 import fr.paris.lutece.plugins.suggest.business.SuggestSubmitStateHome;
68 import fr.paris.lutece.plugins.suggest.business.SuggestSubmitType;
69 import fr.paris.lutece.plugins.suggest.business.SuggestSubmitTypeHome;
70 import fr.paris.lutece.plugins.suggest.business.EntryAdditionalAttribute;
71 import fr.paris.lutece.plugins.suggest.business.EntryAdditionalAttributeHome;
72 import fr.paris.lutece.plugins.suggest.business.EntryFilter;
73 import fr.paris.lutece.plugins.suggest.business.EntryHome;
74 import fr.paris.lutece.plugins.suggest.business.EntryType;
75 import fr.paris.lutece.plugins.suggest.business.EntryTypeHome;
76 import fr.paris.lutece.plugins.suggest.business.ExportFormat;
77 import fr.paris.lutece.plugins.suggest.business.FormError;
78 import fr.paris.lutece.plugins.suggest.business.IEntry;
79 import fr.paris.lutece.plugins.suggest.business.ReportedMessageHome;
80 import fr.paris.lutece.plugins.suggest.business.Response;
81 import fr.paris.lutece.plugins.suggest.business.SubmitFilter;
82 import fr.paris.lutece.plugins.suggest.business.VoteType;
83 import fr.paris.lutece.plugins.suggest.business.VoteTypeHome;
84 import fr.paris.lutece.plugins.suggest.service.CategoryResourceIdService;
85 import fr.paris.lutece.plugins.suggest.service.CommentSubmitService;
86 import fr.paris.lutece.plugins.suggest.service.DefaultMessageResourceIdService;
87 import fr.paris.lutece.plugins.suggest.service.SuggestSubmitService;
88 import fr.paris.lutece.plugins.suggest.service.SuggestResourceIdService;
89 import fr.paris.lutece.plugins.suggest.service.SuggestService;
90 import fr.paris.lutece.plugins.suggest.service.ExportFormatResourceIdService;
91 import fr.paris.lutece.plugins.suggest.service.ICommentSubmitService;
92 import fr.paris.lutece.plugins.suggest.service.ISuggestSubmitService;
93 import fr.paris.lutece.plugins.suggest.service.suggestsearch.SuggestSearchService;
94 import fr.paris.lutece.plugins.suggest.service.search.SuggestIndexer;
95 import fr.paris.lutece.plugins.suggest.utils.SuggestIndexerUtils;
96 import fr.paris.lutece.plugins.suggest.utils.SuggestUtils;
97 import fr.paris.lutece.plugins.suggest.web.action.SuggestAdminSearchFields;
98 import fr.paris.lutece.plugins.suggest.web.action.ISuggestAction;
99 import fr.paris.lutece.plugins.workflowcore.business.state.State;
100 import fr.paris.lutece.plugins.workflowcore.service.state.StateService;
101 import fr.paris.lutece.portal.business.indexeraction.IndexerAction;
102 import fr.paris.lutece.portal.business.rbac.RBAC;
103 import fr.paris.lutece.portal.business.role.RoleHome;
104 import fr.paris.lutece.portal.business.style.Theme;
105 import fr.paris.lutece.portal.business.user.AdminUser;
106 import fr.paris.lutece.portal.service.admin.AccessDeniedException;
107 import fr.paris.lutece.portal.service.admin.AdminUserService;
108 import fr.paris.lutece.portal.service.fileupload.FileUploadService;
109 import fr.paris.lutece.portal.service.i18n.I18nService;
110 import fr.paris.lutece.portal.service.image.ImageResource;
111 import fr.paris.lutece.portal.service.mailinglist.AdminMailingListService;
112 import fr.paris.lutece.portal.service.message.AdminMessage;
113 import fr.paris.lutece.portal.service.message.AdminMessageService;
114 import fr.paris.lutece.portal.service.message.SiteMessage;
115 import fr.paris.lutece.portal.service.plugin.Plugin;
116 import fr.paris.lutece.portal.service.plugin.PluginService;
117 import fr.paris.lutece.portal.service.portal.ThemesService;
118 import fr.paris.lutece.portal.service.rbac.RBACService;
119 import fr.paris.lutece.portal.service.search.IndexationService;
120 import fr.paris.lutece.portal.service.security.LuteceUser;
121 import fr.paris.lutece.portal.service.security.SecurityService;
122 import fr.paris.lutece.portal.service.security.UserNotSignedException;
123 import fr.paris.lutece.portal.service.spring.SpringContextService;
124 import fr.paris.lutece.portal.service.template.AppTemplateService;
125 import fr.paris.lutece.portal.service.util.AppLogService;
126 import fr.paris.lutece.portal.service.util.AppPathService;
127 import fr.paris.lutece.portal.service.util.AppPropertiesService;
128 import fr.paris.lutece.portal.service.workflow.WorkflowService;
129 import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupService;
130 import fr.paris.lutece.portal.web.admin.PluginAdminPageJspBean;
131 import fr.paris.lutece.portal.web.pluginaction.DefaultPluginActionResult;
132 import fr.paris.lutece.portal.web.pluginaction.IPluginActionResult;
133 import fr.paris.lutece.portal.web.pluginaction.PluginActionManager;
134 import fr.paris.lutece.portal.web.upload.MultipartHttpServletRequest;
135 import fr.paris.lutece.util.ReferenceList;
136 import fr.paris.lutece.util.date.DateUtil;
137 import fr.paris.lutece.util.html.HtmlTemplate;
138 import fr.paris.lutece.util.html.Paginator;
139 import fr.paris.lutece.util.string.StringUtil;
140 import fr.paris.lutece.util.url.UrlItem;
141
142
143
144
145 public class SuggestJspBean extends PluginAdminPageJspBean
146 {
147 public static final String MARK_DISABLE_SUGGEST_SUBMIT_STATE_NUMBER = "disable_state_number";
148 public static final String MARK_WAITING_FOR_PUBLISH_SUGGEST_SUBMIT_STATE_NUMBER = "waiting_for_publish_state_number";
149 public static final String MARK_PUBLISH_SUGGEST_SUBMIT_STATE_NUMBER = "publish_state_number";
150 private static final long serialVersionUID = 8034293907026887250L;
151
152
153 private static final String TEMPLATE_MANAGE_SUGGEST = "admin/plugins/suggest/manage_suggest.html";
154 private static final String TEMPLATE_MANAGE_SUGGEST_SUBMIT = "admin/plugins/suggest/manage_suggest_submit.html";
155 private static final String TEMPLATE_CREATE_SUGGEST_SUBMIT = "admin/plugins/suggest/create_suggest_submit.html";
156 private static final String TEMPLATE_MANAGE_SUGGEST_SUBMIT_ORDER = "admin/plugins/suggest/manage_suggest_submit_order.html";
157 private static final String TEMPLATE_MANAGE_COMMENT_SUBMIT = "admin/plugins/suggest/manage_comment_submit.html";
158 private static final String TEMPLATE_CREATE_SUGGEST = "admin/plugins/suggest/create_suggest.html";
159 private static final String TEMPLATE_MODIFY_SUGGEST = "admin/plugins/suggest/modify_suggest.html";
160 private static final String TEMPLATE_STATISTICS_SUGGEST = "admin/plugins/suggest/statistics.html";
161 private static final String TEMPLATE_MANAGE_ADVANCED_PARAMETERS = "admin/plugins/suggest/manage_advanced_parameters.html";
162 private static final String TEMPLATE_TASK_FORM = "admin/plugins/suggest/task_form_workflow.html";
163
164
165 private static final String MESSAGE_ACTION_ERROR = "suggest.message.workflow.action.error";
166 private static final String MESSAGE_NEW_COMMENT_SUBMIT_INVALID = "suggest.message.newCommentSubmitInvalid";
167 private static final String MESSAGE_CONFIRM_REMOVE_SUGGEST = "suggest.message.confirmRemoveSuggest";
168 private static final String MESSAGE_CONFIRM_REMOVE_SUGGEST_SUBMIT = "suggest.message.confirmRemoveSuggestSubmit";
169 private static final String MESSAGE_CONFIRM_REMOVE_COMMENT_SUBMIT = "suggest.message.confirmRemoveCommentSubmit";
170 private static final String MESSAGE_CONFIRM_REMOVE_SUGGEST_WITH_SUGGEST_SUBMIT = "suggest.message.confirmRemoveSuggestWithSuggestSubmit";
171 private static final String MESSAGE_CONFIRM_DISABLE_SUGGEST = "suggest.message.confirmDisableSuggest";
172 private static final String MESSAGE_CONFIRM_REMOVE_ENTRY = "suggest.message.confirmRemoveEntry";
173 private static final String MESSAGE_CONFIRM_UPDATE_ALL_SUGGEST_SUBMIT = "suggest.message.confirmUpdateAllSuggestSubmit";
174 private static final String MESSAGE_MANDATORY_FIELD = "suggest.message.mandatory.field";
175 private static final String MESSAGE_ILLOGICAL_NUMBER_VOTE_REQUIRED = "suggest.message.illogicalNumberVoteRequired";
176 private static final String MESSAGE_ILLOGICAL_NUMBER_SUGGEST_SUBMIT_CARACTERS_SHOWN = "suggest.message.illogicalNumberSuggestSubmitCaractersShown";
177 private static final String MESSAGE_ILLOGICAL_NUMBER_SUGGEST_SUBMIT_IN_TOP_SCORE = "suggest.message.illogicalNumberSuggestSumitInTopScore";
178 private static final String MESSAGE_ILLOGICAL_NUMBER_SUGGEST_SUBMIT_IN_TOP_COMMENT = "suggest.message.illogicalNumberSuggestSumitInTopComment";
179 private static final String MESSAGE_ILLOGICAL_NUMBER_SUGGEST_SUBMIT_PER_PAGE = "suggest.message.illogicalNumberSuggestSumitPerPage";
180 private static final String MESSAGE_ILLOGICAL_NUMBER_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST = "suggest.message.illogicalNumberCommentDisplayInSuggestSubmitList";
181 private static final String MESSAGE_ILLOGICAL_NUMBER_CHAR_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST = "suggest.message.illogicalNumberCharCommentDisplayInSuggestSubmitList";
182 private static final String MESSAGE_ILLOGICAL_NUMBER_DAY_REQUIRED = "suggest.message.illogicalNumberDayRequired";
183 private static final String MESSAGE_CONFIRM_CHANGE_SUGGEST_SUBMIT_CATEGORY = "suggest.message.confirmChangeSuggestSubmitCategory";
184 private static final String MESSAGE_CONFIRM_REMOVE_SUGGEST_SUBMIT_CATEGORY = "suggest.message.confirmRemoveSuggestSubmitCategory";
185 private static final String MESSAGE_ERROR_NO_CATEGORY = "suggest.message.errorNoCategorySelected";
186 private static final String MESSAGE_ERROR_NO_SUGGEST_SUBMIT_TYPE_SELECTED = "suggest.message.errorNoSuggestSubmitTypeSelected";
187 private static final String MESSAGE_MANDATORY_QUESTION = "suggest.message.mandatory.question";
188 private static final String MESSAGE_FORM_ERROR = "suggest.message.formError";
189 private static final String FIELD_TITLE = "suggest.createSuggest.labelTitle";
190 private static final String FIELD_LIBELLE_CONTRIBUTION = "suggest.createSuggest.labelLibelleContribution";
191 private static final String FIELD_UNAVAILABILITY_MESSAGE = "suggest.createSuggest.labelUnavailabilityMessage";
192 private static final String FIELD_VOTE_TYPE = "suggest.createSuggest.labelVoteType";
193 private static final String FIELD_LIBELE_VALIDATE_BUTTON = "suggest.createSuggest.labelLibelleValidateButton";
194 private static final String FIELD_NUMBER_SUGGEST_SUBMIT_CARACTERS_SHOWN = "suggest.createSuggest.labelNumberSuggestSubmitCaractersShown";
195 private static final String FIELD_NUMBER_SUGGEST_SUBMIT_IN_TOP_SCORE = "suggest.createSuggest.labelNumberSuggestSubmitInTopScore";
196 private static final String FIELD_NUMBER_SUGGEST_SUBMIT_IN_TOP_COMMENT = "suggest.createSuggest.labelNumberSuggestSubmitInTopComment";
197 private static final String FIELD_NUMBER_SUGGEST_SUBMIT_PER_PAGE = "suggest.createSuggest.labelNumberSuggestSubmitPerPage";
198 private static final String FIELD_NUMBER_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST = "suggest.createSuggest.labelNumberCommentDisplayInSuggestSubmitList";
199 private static final String FIELD_NUMBER_CHAR_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST = "suggest.createSuggest.labelNumberCharCommentDisplayInSuggestSubmitList";
200
201 private static final String FIELD_NOTIFICATION_NEW_COMMENT_TITLE = "suggest.createSuggest.labelNotificationNewCommentTitle";
202 private static final String FIELD_NOTIFICATION_NEW_COMMENT_BODY = "suggest.createSuggest.labelNotificationNewCommentBody";
203 private static final String FIELD_NOTIFICATION_NEW_SUGGEST_DUBMIT_TITLE = "suggest.createSuggest.labelNotificationNewSuggestSubmitTitle";
204 private static final String FIELD_NOTIFICATION_NEW_SUGGEST_DUBMIT_BODY = "suggest.createSuggest.labelNotificationNewSuggestSubmitBody";
205
206
207 private static final String PROPERTY_ITEM_PER_PAGE = "suggest.itemsPerPage";
208 private static final String PROPERTY_ALL = "suggest.manageSuggest.select.all";
209 private static final String PROPERTY_YES = "suggest.manageSuggestSubmit.select.yes";
210 private static final String PROPERTY_NO = "suggest.manageSuggestSubmit.select.no";
211 private static final String PROPERTY_ENABLE = "suggest.manageSuggest.select.enable";
212 private static final String PROPERTY_DISABLE = "suggest.manageSuggest.select.disable";
213 private static final String PROPERTY_NOTHING = "suggest.createSuggest.select.nothing";
214 private static final String PROPERTY_MODIFY_SUGGEST_TITLE = "suggest.modifySuggest.title";
215 private static final String PROPERTY_COPY_SUGGEST_TITLE = "suggest.copySuggest.title";
216 private static final String PROPERTY_COPY_ENTRY_TITLE = "suggest.copyEntry.title";
217 private static final String PROPERTY_CREATE_SUGGEST_TITLE = "suggest.createSuggest.title";
218 private static final String PROPERTY_CREATE_QUESTION_TITLE = ".createEntry.titleQuestion";
219 private static final String PROPERTY_MODIFY_QUESTION_TITLE = "suggest.modifyEntry.titleQuestion";
220 private static final String PROPERTY_NUMBER_SUGGEST_SUBMIT_VALUE_SHOWN_CHARACTERS = "suggest.suggestSubmitValue.NumberShownCharacters";
221 private static final String PROPERTY_SUGGESTSUBMIT_HIGHSCORES = "suggest.highscores.suggestSubmit.number";
222 private static final String PROPERTY_MANAGE_SUGGEST_PAGE_TITLE = "suggest.manageSuggest.pageTitle";
223 private static final String PROPERTY_MANAGE_ADVANCED_PARAMETERS_PAGE_TITLE = "suggest.manageAdvancedParameters.pageTitle";
224 private static final String PROPERTY_MANAGE_SUGGEST_SUBMIT_PAGE_TITLE = "suggest.manageSuggestSubmit.pageTitle";
225 private static final String PROPERTY_MANAGE_SUGGEST_SUBMIT_ORDER_PAGE_TITLE = "suggest.manageSuggestSubmitOrder.pageTitle";
226 private static final String PROPERTY_CREATE_SUGGEST_SUBMIT_PAGE_TITLE = "suggest.createSuggestSubmit.pageTitle";
227 private static final String PROPERTY_MANAGE_COMMENT_SUBMIT_PAGE_TITLE = "suggest.manageCommentSubmit.pageTitle";
228 private static final String PROPERTY_DEFAULT_ROLE_CODE = "defaultRole.code";
229 private static final String PROPERTY_PAGE_TITLE_TASKS_FORM_WORKFLOW = "suggest.taskFormWorkflow.pageTitle";
230
231
232 private static final String MARK_WEBAPP_URL = "webapp_url";
233 private static final String MARK_LOCALE = "locale";
234 private static final String MARK_PAGINATOR = "paginator";
235 private static final String MARK_USER_WORKGROUP_REF_LIST = "user_workgroup_list";
236 private static final String MARK_USER_WORKGROUP_SELECTED = "user_workgroup_selected";
237 private static final String MARK_SUGGEST_STATE_REF_LIST = "suggest_state_list";
238 private static final String MARK_SUGGEST_STATE_SELECTED = "suggest_state_selected";
239 private static final String MARK_SUGGEST_SUBMIT_STATE_REF_LIST = "suggest_submit_state_list";
240 private static final String MARK_SUGGEST_SUBMIT_STATE_SELECTED = "suggest_submit_state_selected";
241 private static final String MARK_MAILING_REF_LIST = "mailing_list";
242 private static final String MARK_ENTRY_TYPE_REF_LIST = "entry_type_list";
243 private static final String MARK_REGULAR_EXPRESSION_LIST_REF_LIST = "regular_expression_list";
244 private static final String MARK_ENTRY = "entry";
245 private static final String MARK_ID_ENTRY_FIRST_IN_THE_LIST = "id_entry_first_in_the_list";
246 private static final String MARK_ID_ENTRY_LAST_IN_THE_LIST = "id_entry_last_in_the_list";
247 private static final String MARK_NB_ITEMS_PER_PAGE = "nb_items_per_page";
248 private static final String MARK_SUGGEST_LIST = "suggest_list";
249 private static final String MARK_SUGGEST_SUBMIT_LIST = "suggest_submit_list";
250 private static final String MARK_COMMENT_SUBMIT_LIST = "comment_submit_list";
251 private static final String MARK_VOTE_TYPE_LIST = "vote_type_list";
252 private static final String MARK_CATEGORY_LIST = "category_list";
253 private static final String MARK_SUGGEST_SUBMIT_TYPE_LIST = "suggest_submit_type_list";
254 private static final String MARK_SUGGEST = "suggest";
255 private static final String MARK_SUGGEST_SUBMIT = "suggest_submit";
256 private static final String MARK_ID_SUGGEST_SUBMIT_PREV = "suggest_submit_prev";
257 private static final String MARK_ID_SUGGEST_SUBMIT_NEXT = "suggest_submit_next";
258 private static final String MARK_PERMISSION_CREATE_SUGGEST = "permission_create_suggest";
259 private static final String MARK_PERMISSION_MANAGE_ADVANCED_PARAMETERS = "permission_manage_advanced_parameters";
260 private static final String MARK_ENTRY_TYPE_GROUP = "entry_type_group";
261 private static final String MARK_ENTRY_LIST = "entry_list";
262 private static final String MARK_LIST = "list";
263 private static final String MARK_NUMBER_QUESTION = "number_question";
264 private static final String MARK_NUMBER_ITEMS = "number_items";
265 private static final String MARK_DEFAULT_MESSAGE = "default_message";
266 private static final String MARK_IS_ACTIVE_CAPTCHA = "is_active_captcha";
267 private static final String MARK_YES_VALUE = "yes_value";
268 private static final String MARK_NO_VALUE = "no_value";
269 private static final String MARK_NUMBER_SHOWN_CHARACTERS = "number_shown_characters";
270 private static final String MARK_LIST_SUGGEST_SUBMIT_SORT = "suggest_submit_sort_list";
271 private static final String MARK_SUGGEST_SUBMIT_SORT_SELECTED = "suggest_submit_sort_selected";
272 private static final String MARK_SUGGEST_SUBMIT_CATEGORY_SELECTED = "suggest_submit_category_selected";
273 private static final String MARK_SUGGEST_SUBMIT_TYPE_SELECTED = "suggest_submit_type_selected";
274 private static final String MARK_CATEGORY_FILTER = "category_filter";
275 private static final String MARK_TYPE_FILTER = "type_filter";
276 private static final String MARK_REPORT_REF_LIST = "suggest_submit_report_list";
277 private static final String MARK_REPORT_SELECTED = "suggest_submit_report_selected";
278 private static final String MARK_CONTAINS_COMMENT_DISABLE_LIST = "suggest_submit_contains_comment_disable_list";
279 private static final String MARK_CONTAINS_COMMENT_DISABLE_SELECTED = "suggest_submit_contains_comment_disable_selected";
280 private static final String MARK_AUTHENTIFICATION_ENABLE = "authentification_enable";
281 private static final String MARK_ROLE_LIST = "role_list";
282 private static final String MARK_DEFAULT_VALUE_ROLE = "default_value_role";
283 private static final String MARK_COMMENT_SORT_LIST = "comment_sort_list";
284 private static final String MARK_COMMENT_SORT_SELECTED = "comment_sort_selected";
285 private static final String MARK_COMMENT_STATE_LIST = "comment_state_list";
286 private static final String MARK_COMMENT_STATE_SELECTED = "comment_state_selected";
287 private static final String MARK_CONTAINS_SUB_COMMENT_DISABLE_LIST = "comment_contains_sub_comment_disable_list";
288 private static final String MARK_CONTAINS_SUB_COMMENT_DISABLE_SELECTED = "comment_contains_sub_comment_disable_selected";
289 private static final String MARK_SUGGEST_SUBMIT_ORDER_LIST = "order_list";
290 private static final String MARK_SUGGEST_SUBMIT_ORDER_LIST_PINNED = "order_list_pinned";
291 private static final String MARK_FIRST_DATE_FILTER = "first_date_filter";
292 private static final String MARK_LAST_DATE_FILTER = "last_date_filter";
293 private static final String MARK_NUMBER_VOTES = "number_votes";
294 private static final String MARK_NUMBER_COMMENTS = "number_comments";
295 private static final String MARK_NUMBER_SUGGESTSUBMIT_DISABLED = "number_suggestsubmit_disabled";
296 private static final String MARK_NUMBER_SUGGESTSUBMIT_WAITING = "number_suggestsubmit_waiting";
297 private static final String MARK_NUMBER_SUGGESTSUBMIT_PUBLISHED = "number_suggestsubmit_published";
298 private static final String MARK_HIGH_SCORES = "high_scores";
299 private static final String MARK_NUMBER_USERS = "number_users";
300 private static final String MARK_URL = "url";
301 private static final String MARK_DEFAULT_THEME = "default_theme";
302 private static final String MARK_THEME_REF_LIST = "theme_list";
303 private static final String MARK_PERMISSION_MANAGE_DEFAULT_MESSAGE = "permission_manage_default_message";
304 private static final String MARK_PERMISSION_MANAGE_CATEGORY = "permission_manage_category";
305 private static final String MARK_PERMISSION_MANAGE_EXPORT_FORMAT = "permission_manage_export_format";
306 private static final String MARK_ID_DEFAULT_SUGGEST = "id_default_suggest";
307 private static final String MARK_QUERY = "query";
308 private static final String MARK_SUGGEST_ACTIONS = "suggest_actions";
309 private static final String MARK_ID_PARENT = "id_parent";
310 private static final String MARK_PANEL = "panel";
311 private static final String MARK_WORKFLOW_REF_LIST = "workflow_list";
312 private static final String MARK_ID_SUGGEST_SUBMIT = "id_suggest_submit";
313 private static final String MARK_ID_ACTION = "id_action";
314 private static final String MARK_TASK_FORM = "task_form";
315
316
317 private static final String JSP_DO_DISABLE_SUGGEST = "jsp/admin/plugins/suggest/DoDisableSuggest.jsp";
318 private static final String JSP_DO_REMOVE_SUGGEST = "jsp/admin/plugins/suggest/DoRemoveSuggest.jsp";
319 private static final String JSP_DO_REMOVE_SUGGEST_SUBMIT = "jsp/admin/plugins/suggest/DoRemoveSuggestSubmit.jsp";
320 private static final String JSP_DO_REMOVE_ENTRY = "jsp/admin/plugins/suggest/DoRemoveEntry.jsp";
321 private static final String JSP_MANAGE_SUGGEST = "jsp/admin/plugins/suggest/ManageSuggest.jsp";
322 private static final String JSP_DO_REMOVE_COMMENT_SUBMIT = "jsp/admin/plugins/suggest/DoRemoveCommentSubmit.jsp";
323
324 private static final String JSP_MODIFY_SUGGEST = "jsp/admin/plugins/suggest/ModifySuggest.jsp";
325 private static final String JSP_MODIFY_ENTRY = "jsp/admin/plugins/suggest/ModifyEntry.jsp";
326 private static final String JSP_MANAGE_SUGGEST_SUBMIT = "jsp/admin/plugins/suggest/ManageSuggestSubmit.jsp";
327 private static final String JSP_MANAGE_SUGGEST_SUBMIT_ORDER = "jsp/admin/plugins/suggest/ManageSuggestSubmitOrder.jsp";
328 private static final String JSP_MANAGE_COMMENT_SUBMIT = "jsp/admin/plugins/suggest/ManageCommentSubmit.jsp";
329 private static final String JSP_MANAGE_ADVANCED_PARAMETERS = "jsp/admin/plugins/suggest/ManageAdvancedParameters.jsp";
330 private static final String JSP_DO_UPDATE_ALL_SUGGEST_SUBMIT = "jsp/admin/plugins/suggest/DoUpdateAllSuggestSubmit.jsp";
331 private static final String JSP_DO_CHANGE_SUGGEST_SUBMIT_CATEGORY = "jsp/admin/plugins/suggest/DoMassChangeSuggestSubmitCategory.jsp";
332 private static final String JSP_WORKFLOW_TASK_FORM = "jsp/admin/plugins/suggest/DoGetWorkflowActionForm.jsp";
333
334
335 private static final String PARAMETER_ID_SUGGEST = "id_suggest";
336 private static final String PARAMETER_PANEL = "panel";
337
338 private static final String PARAMETER_ID_SUGGEST_SUBMIT = "id_suggest_submit";
339 private static final String PARAMETER_ID_COMMENT_SUBMIT = "id_comment_submit";
340 private static final String PARAMETER_ID_PARENT = "id_parent";
341 private static final String PARAMETER_STATE_NUMBER = "state_number";
342 private static final String PARAMETER_TITLE = "title";
343 private static final String PARAMETER_LIBELLE_CONTRIBUTION = "libelle_contribution";
344 private static final String PARAMETER_UNAVAILABILITY_MESSAGE = "unavailability_message";
345 private static final String PARAMETER_WORKGROUP = "workgroup";
346 private static final String PARAMETER_ID_VOTE_TYPE = "id_vote_type";
347 private static final String PARAMETER_ACTIVE_PROPOSITION_STATE = "active_suggest_proposition_state";
348 private static final String PARAMETER_NUMBER_VOTE_REQUIRED = "number_vote_required";
349 private static final String PARAMETER_NUMBER_DAY_REQUIRED = "number_day_required";
350 private static final String PARAMETER_ACTIVE_SUGGEST_SUBMIT_AUTHENTIFICATION = "active_suggest_submit_authentification";
351 private static final String PARAMETER_ACTIVE_VOTE_AUTHENTIFICATION = "active_vote_authentification";
352 private static final String PARAMETER_ACTIVE_COMMENT_AUTHENTIFICATION = "active_comment_authentification";
353 private static final String PARAMETER_DISABLE_NEW_SUGGEST_SUBMIT = "disable_new_suggest_submit";
354 private static final String PARAMETER_ENABLE_MAIL_NEW_SUGGEST_SUBMIT = "enable_mail_new_suggest_submit";
355 private static final String PARAMETER_ENABLE_MAIL_NEW_COMMENT_SUBMIT = "enable_mail_new_comment_submit";
356 private static final String PARAMETER_ENABLE_MAIL_NEW_REPORTED_SUBMIT = "enable_mail_new_reported_submit";
357 private static final String PARAMETER_ID_MAILING_LIST_SUGGEST_SUBMIT = "id_mailing_list_suggest_submit";
358 private static final String PARAMETER_AUTHORIZED_COMMENT = "authorized_comment";
359 private static final String PARAMETER_DISABLE_NEW_COMMENT = "disable_new_comment";
360 private static final String PARAMETER_ACTIVE_CAPTCHA = "active_captcha";
361 private static final String PARAMETER_LIBELLE_VALIDATE_BUTTON = "libelle_validate_button";
362 private static final String PARAMETER_ID_CATEGORY = "id_category";
363 private static final String PARAMETER_ID_CATEGORY_FILTER = "id_category_filter";
364 private static final String PARAMETER_ID_TYPE_SUGGEST = "id_type";
365 private static final String PARAMETER_ID_SUGGEST_SUBMIT_STATE = "id_suggest_submit_state";
366 private static final String PARAMETER_ID_SUGGEST_STATE = "id_suggest_state";
367 private static final String PARAMETER_ID_SUGGEST_SUBMIT_TYPE = "id_suggest_submit_type";
368 private static final String PARAMETER_ENABLE = "enable";
369 private static final String PARAMETER_DISABLE = "disable";
370 private static final String PARAMETER_COMMENT_VALUE = "comment_value";
371 private static final String PARAMETER_DELETE = "delete";
372 private static final String PARAMETER_PAGE_INDEX = "page_index";
373 private static final String PARAMETER_ID_ENTRY = "id_entry";
374 private static final String PARAMETER_ID_EXPRESSION = "id_expression";
375 private static final String PARAMETER_CANCEL = "cancel";
376 private static final String PARAMETER_APPLY = "apply";
377 private static final String PARAMETER_NUMBER_SUGGEST_SUBMIT_IN_TOP_SCORE = "number_suggest_submit_in_top_score";
378 private static final String PARAMETER_NUMBER_SUGGEST_SUBMIT_IN_TOP_COMMENT = "number_suggest_submit_in_top_comment";
379 private static final String PARAMETER_NUMBER_SUGGEST_SUBMIT_CARACTERS_SHOWN = "number_suggest_submit_caracters_shown";
380 private static final String PARAMETER_LIMIT_NUMBER_VOTE = "limit_number_vote";
381 private static final String PARAMETER_COMMENT = "comment";
382 private static final String PARAMETER_ID_SUGGEST_SUBMIT_SORT = "id_suggest_submit_sort";
383 private static final String PARAMETER_ID_SUGGEST_SUBMIT_REPORT = "id_suggest_submit_report";
384 private static final String PARAMETER_ID_COMMENT_SORT = "id_comment_sort";
385 private static final String PARAMETER_ID_COMMENT_STATE = "id_comment_state";
386 private static final String PARAMETER_ID_CONTAINS_SUB_COMMENT_DISABLE = "id_contains_sub_comment_disable";
387 private static final String PARAMETER_SHOW_CATEGORY_BLOCK = "show_category_block";
388 private static final String PARAMETER_SHOW_TOP_SCORE_BLOCK = "show_top_score_block";
389 private static final String PARAMETER_SHOW_TOP_COMMENT_BLOCK = "show_top_comment_block";
390 private static final String PARAMETER_ACTIVE_SUGGEST_SUBMIT_PAGINATOR = "active_suggest_submit_paginator";
391 private static final String PARAMETER_NUMBER_SUGGEST_SUBMIT_PER_PAGE = "number_suggest_submit_per_page";
392 private static final String PARAMETER_ROLE = "role";
393 private static final String PARAMETER_HEADER = "header";
394 private static final String CONSTANTE_YES_VALUE = "1";
395 private static final String CONSTANTE_NO_VALUE = "0";
396 private static final String PARAMETER_QUERY = "query";
397 private static final String PARAMETER_SUGGEST_SUBMIT_ORDER = "suggest_submit_order";
398 private static final String PARAMETER_FIRST_DATE_FILTER = "first_date_filter";
399 private static final String PARAMETER_LAST_DATE_FILTER = "last_date_filter";
400 private static final String PARAMETER_THEME_XPAGE = "id_theme_list";
401 private static final String PARAMETER_CONFIRMATION_MESSAGE = "confirmation_message";
402 private static final String PARAMETER_ACTIVE_EDITOR_BBCODE_ON_COMMENT = "active_editor_bbcode_on_comment";
403 private static final String PARAMETER_ID_DEFAULT_SORT = "id_default_sort";
404 private static final String PARAMETER_ID_DEFAULT_SUGGEST = "id_default_suggest";
405 private static final String PARAMETER_SELECTED_SUGGEST_SUBMIT = "selected_suggest_submit";
406 private static final String PARAMETER_DISABLE_VOTE = "disable_vote";
407 private static final String PARAMETER_DISABLE_COMMENT = "disable_comment";
408 private static final String PARAMETER_ENABLE_PIN = "enable_pin";
409 private static final String PARAMETER_ENABLE_REPORTS = "enable_reports";
410 private static final String PARAMETER_ENABLE_TERMS_OF_USE = "enable_terms_of_use";
411 private static final String PARAMETER_TERMS_OF_USE = "terms_of_use";
412 private static final String PARAMETER_DISPLAY_COMMENT_IN_SUGGEST_SUBMIT_LIST = "display_comment_in_suggest_submit_list";
413 private static final String PARAMETER_NUMBER_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST = "number_comment_display_in_suggest_submit_list";
414 private static final String PARAMETER_NUMBER_CHAR_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST = "number_char_comment_display_in_suggest_submit_list";
415 private static final String PARAMETER_UPDATE_FILE = "update_file";
416 private static final String PARAMETER_IMAGE_SOURCE = "image_source";
417 private static final String PARAMETER_DESCRIPTION = "description";
418 private static final String PARAMETER_ID_CONTAINS_COMMENT_DISABLE = "id_contains_comment_disable";
419 private static final String PARAMETER_NOTIFICATION_NEW_COMMENT_SENDER_NAME = "notification_new_comment_sender_name";
420 private static final String PARAMETER_NOTIFICATION_NEW_COMMENT_TITLE = "notification_new_comment_title";
421 private static final String PARAMETER_NOTIFICATION_NEW_COMMENT_BODY = "notification_new_comment_body";
422 private static final String PARAMETER_NOTIFICATION_NEW_SUGGEST_SUBMIT_SENDER_NAME = "notification_new_suggest_submit_sender_name";
423 private static final String PARAMETER_NOTIFICATION_NEW_SUGGEST_SUBMIT_TITLE = "notification_new_suggest_submit_title";
424 private static final String PARAMETER_NOTIFICATION_NEW_SUGGEST_SUBMIT_BODY = "notification_new_suggest_submit_body";
425 private static final String PARAMETER_ID_WORKFLOW = "id_workflow";
426 private static final String PARAMETER_ID_ACTION = "id_action";
427 private static final String PARAMETER_BACK = "back";
428 private static final String PARAMETER_SAVE = "save";
429
430
431 private static final String EMPTY_STRING = "";
432 private static final String JCAPTCHA_PLUGIN = "jcaptcha";
433
434
435 private SuggestAdminSearchFieldsestAdminSearchFields.html#SuggestAdminSearchFields">SuggestAdminSearchFields _searchFields = new SuggestAdminSearchFields( );
436 private int _nDefaultItemsPerPage = AppPropertiesService.getPropertyInt( PROPERTY_ITEM_PER_PAGE, 50 );
437 private String _strCurrentPageIndexSuggest;
438 private int _nItemsPerPageSuggest;
439 private String _strCurrentPageIndexSuggestSubmit;
440 private String _strCurrentPageIndexCommentSubmit;
441 private int _nItemsPerPageSuggestSubmit;
442 private String _strCurrentPageIndexSuggestSubmitOrder;
443 private int _nItemsPerPageSuggestSubmitOrder;
444 private int _nItemsPerPageCommentSubmit;
445 private String _strCurrentPageIndexEntry;
446 private int _nItemsPerPageEntry;
447 private String _strCurrentPageIndex;
448 private int _nItemsPerPage;
449 private int _nIdSuggestState = SuggestUtils.CONSTANT_ID_NULL;
450 private int _nIdSuggest = SuggestUtils.CONSTANT_ID_NULL;
451 private int _nIdSuggestSubmit = SuggestUtils.CONSTANT_ID_NULL;
452 private int _nIdCommentSort = SuggestUtils.CONSTANT_ID_NULL;
453 private int _nIdCommentState = SuggestUtils.CONSTANT_ID_NULL;
454 private int _nIdContainsSubCommentDisable = SuggestUtils.CONSTANT_ID_NULL;
455 private String _strWorkGroup = AdminWorkgroupService.ALL_GROUPS;
456 private ISuggestSubmitService _suggestSubmitService = SuggestSubmitService.getService( );
457 private ICommentSubmitService _commentSubmitService = CommentSubmitService.getService( );
458
459
460
461
462
463
464
465
466
467
468 public String getManageSuggest( HttpServletRequest request )
469 {
470 AdminUser adminUser = getUser( );
471 Plugin plugin = getPlugin( );
472 Locale locale = getLocale( );
473 ReferenceList refListWorkGroups;
474 ReferenceList refListSuggestState;
475 List<SuggestAction> listActionsForSuggestEnable;
476 List<SuggestAction> listActionsForSuggestDisable;
477 List<SuggestAction> listActions;
478
479 String strWorkGroup = request.getParameter( PARAMETER_WORKGROUP );
480 String strIdSuggestState = request.getParameter( PARAMETER_ID_SUGGEST_STATE );
481 _strCurrentPageIndexSuggest = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndexSuggest );
482 _nItemsPerPageSuggest = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPageSuggest, _nDefaultItemsPerPage );
483
484 if ( ( strIdSuggestState != null ) && !strIdSuggestState.equals( EMPTY_STRING ) )
485 {
486 _nIdSuggestState = SuggestUtils.getIntegerParameter( strIdSuggestState );
487 }
488
489 if ( ( strWorkGroup != null ) && !strWorkGroup.equals( EMPTY_STRING ) )
490 {
491 _strWorkGroup = strWorkGroup;
492 }
493
494
495 SuggestFilterst/business/SuggestFilter.html#SuggestFilter">SuggestFilter filter = new SuggestFilter( );
496 filter.setIdState( _nIdSuggestState );
497 filter.setWorkGroup( _strWorkGroup );
498
499 List<Suggest> listSuggest = SuggestHome.getSuggestList( filter, getPlugin( ) );
500 listSuggest = (List<Suggest>) AdminWorkgroupService.getAuthorizedCollection( listSuggest, adminUser );
501
502 refListWorkGroups = AdminWorkgroupService.getUserWorkgroups( adminUser, locale );
503 refListSuggestState = getRefListSuggestState( locale );
504
505 Map<String, Object> model = new HashMap<>( );
506 Paginator<Suggest> paginator = new Paginator<Suggest>( listSuggest, _nItemsPerPageSuggest, getJspManageSuggest( request ), PARAMETER_PAGE_INDEX,
507 _strCurrentPageIndexSuggest );
508
509 listActionsForSuggestEnable = SuggestActionHome.selectActionsBySuggestState( Suggest.STATE_ENABLE, plugin, locale );
510 listActionsForSuggestDisable = SuggestActionHome.selectActionsBySuggestState( Suggest.STATE_DISABLE, plugin, locale );
511
512 for ( Suggest suggest : paginator.getPageItems( ) )
513 {
514 if ( suggest.isActive( ) )
515 {
516 listActions = listActionsForSuggestEnable;
517 }
518 else
519 {
520 listActions = listActionsForSuggestDisable;
521 }
522
523 listActions = (List<SuggestAction>) RBACService.getAuthorizedActionsCollection( listActions, suggest, getUser( ) );
524 suggest.setActions( listActions );
525 }
526
527 model.put( MARK_PAGINATOR, paginator );
528 model.put( MARK_NB_ITEMS_PER_PAGE, EMPTY_STRING + _nItemsPerPageSuggest );
529 model.put( MARK_USER_WORKGROUP_REF_LIST, refListWorkGroups );
530 model.put( MARK_USER_WORKGROUP_SELECTED, _strWorkGroup );
531 model.put( MARK_SUGGEST_STATE_REF_LIST, refListSuggestState );
532 model.put( MARK_SUGGEST_STATE_SELECTED, _nIdSuggestState );
533
534 model.put( MARK_SUGGEST_LIST, paginator.getPageItems( ) );
535
536 boolean bPermissionAdvancedParameter = RBACService.isAuthorized( Suggest.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID,
537 SuggestResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS, getUser( ) );
538 boolean bPermissionCreateSuggest = RBACService.isAuthorized( Suggest.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID,
539 SuggestResourceIdService.PERMISSION_CREATE, getUser( ) );
540
541 model.put( MARK_PERMISSION_MANAGE_ADVANCED_PARAMETERS, bPermissionAdvancedParameter );
542 model.put( MARK_PERMISSION_CREATE_SUGGEST, bPermissionCreateSuggest );
543
544 setPageTitleProperty( PROPERTY_MANAGE_SUGGEST_PAGE_TITLE );
545
546 HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_MANAGE_SUGGEST, locale, model );
547
548
549
550 return getAdminPage( templateList.getHtml( ) );
551 }
552
553
554
555
556
557
558
559
560 public String getManageAdvancedParameters( HttpServletRequest request )
561 {
562 if ( !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, SuggestResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS,
563 getUser( ) ) )
564 {
565 return getManageSuggest( request );
566 }
567
568 Map<String, Object> model = new HashMap<>( );
569 List<Suggest> listSuggest = SuggestHome.getSuggestList( new SuggestFilter( ), getPlugin( ) );
570 int nIdDefaultSuggest = -1;
571
572 for ( Suggest suggest : listSuggest )
573 {
574 if ( suggest.isDefaultSuggest( ) )
575 {
576 nIdDefaultSuggest = suggest.getIdSuggest( );
577
578 break;
579 }
580 }
581
582 model.put( MARK_SUGGEST_LIST, SuggestUtils.getRefListSuggest( listSuggest, true ) );
583 model.put( MARK_ID_DEFAULT_SUGGEST, nIdDefaultSuggest );
584 model.put( MARK_PERMISSION_MANAGE_EXPORT_FORMAT,
585 RBACService.isAuthorized( ExportFormat.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, ExportFormatResourceIdService.PERMISSION_MANAGE, getUser( ) ) );
586 model.put( MARK_PERMISSION_MANAGE_CATEGORY,
587 RBACService.isAuthorized( Category.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, CategoryResourceIdService.PERMISSION_MANAGE, getUser( ) ) );
588 model.put( MARK_PERMISSION_MANAGE_DEFAULT_MESSAGE, RBACService.isAuthorized( DefaultMessage.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID,
589 DefaultMessageResourceIdService.PERMISSION_MANAGE, getUser( ) ) );
590
591 HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_MANAGE_ADVANCED_PARAMETERS, getLocale( ), model );
592
593 setPageTitleProperty( PROPERTY_MANAGE_ADVANCED_PARAMETERS_PAGE_TITLE );
594
595 return getAdminPage( templateList.getHtml( ) );
596 }
597
598
599
600
601
602
603
604
605
606
607
608
609 public IPluginActionResult getManageSuggestSubmit( HttpServletRequest request, HttpServletResponse response ) throws AccessDeniedException
610 {
611 ReferenceList refListSuggestSumitState = initRefListSuggestSubmitState( getPlugin( ), getLocale( ) );
612 ReferenceList refListAllYesNo;
613 int nNumberShownCharacters = AppPropertiesService.getPropertyInt( PROPERTY_NUMBER_SUGGEST_SUBMIT_VALUE_SHOWN_CHARACTERS, 100 );
614
615 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
616 List<SuggestSubmit> listSuggestSubmitDisplay = new ArrayList<SuggestSubmit>( );
617
618 _strCurrentPageIndexSuggestSubmit = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndexSuggestSubmit );
619 _nItemsPerPageSuggestSubmit = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPageSuggestSubmit,
620 _nDefaultItemsPerPage );
621
622 if ( ( strIdSuggest != null ) && !strIdSuggest.equals( EMPTY_STRING ) )
623 {
624 _nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
625 }
626
627 updateSearchFieldsData( request );
628
629 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, getPlugin( ) );
630
631 if ( ( suggest == null )
632 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggest.getIdSuggest( ),
633 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
634 {
635 throw new AccessDeniedException( "Access denied" );
636 }
637
638
639 String [ ] selectedSuggestSubmit = request.getParameterValues( PARAMETER_SELECTED_SUGGEST_SUBMIT );
640 List<String> listSelectedSuggestSubmit;
641
642 if ( selectedSuggestSubmit != null )
643 {
644 listSelectedSuggestSubmit = Arrays.asList( selectedSuggestSubmit );
645
646 if ( AppLogService.isDebugEnabled( ) )
647 {
648 AppLogService.debug( "List selected suggestSubmit : " + listSelectedSuggestSubmit );
649 }
650 }
651 else
652 {
653 listSelectedSuggestSubmit = new ArrayList<>( );
654 }
655
656 _searchFields.setSelectedSuggestSubmit( listSelectedSuggestSubmit );
657
658
659 ISuggestAction action = PluginActionManager.getPluginAction( request, ISuggestAction.class );
660
661 if ( action != null )
662 {
663 if ( AppLogService.isDebugEnabled( ) )
664 {
665 AppLogService.debug( "Processing directory action " + action.getName( ) );
666 }
667
668 return action.process( request, response, getUser( ), _searchFields );
669 }
670
671 DefaultPluginActionResult result = new DefaultPluginActionResult( );
672
673
674 SubmitFilter filter = SuggestUtils.getSuggestSubmitFilter( getSearchFields( ), suggest.getIdDefaultSort( ) );
675
676 List<Integer> listIdSuggestSubmitResult;
677
678 if ( ( getSearchFields( ).getQuery( ) != null ) && ( !getSearchFields( ).getQuery( ).trim( ).equals( SuggestUtils.EMPTY_STRING ) ) )
679 {
680 int nId;
681
682 try
683 {
684 nId = Integer.parseInt( getSearchFields( ).getQuery( ) );
685 filter.setIdSuggestSubmit( nId );
686 listIdSuggestSubmitResult = _suggestSubmitService.getSuggestSubmitListId( filter, getPlugin( ) );
687 }
688 catch( NumberFormatException e )
689 {
690
691 listIdSuggestSubmitResult = SuggestSearchService.getInstance( ).getSearchResults( getSearchFields( ).getQuery( ), filter, getPlugin( ) );
692 }
693 }
694 else
695 {
696 listIdSuggestSubmitResult = _suggestSubmitService.getSuggestSubmitListId( filter, getPlugin( ) );
697 }
698
699 ReferenceList refListSuggestSort = SuggestUtils.getRefListSuggestSort( getLocale( ) );
700 refListAllYesNo = getRefListAllYesNo( getLocale( ) );
701
702 Map<String, Object> model = new HashMap<>( );
703 Paginator<Integer> paginator = new Paginator<Integer>( listIdSuggestSubmitResult, _nItemsPerPageSuggestSubmit, getJspManageSuggestSubmit( request ),
704 PARAMETER_PAGE_INDEX, _strCurrentPageIndexSuggestSubmit );
705 SuggestSubmit suggestSubmit;
706
707 for ( Object idSuggestSubmitDisplay : paginator.getPageItems( ) )
708 {
709 suggestSubmit = _suggestSubmitService.findByPrimaryKey( (Integer) idSuggestSubmitDisplay, false, getPlugin( ) );
710 listSuggestSubmitDisplay.add( suggestSubmit );
711 }
712
713 if ( ( suggest.getCategories( ) != null ) && !suggest.getCategories( ).isEmpty( ) )
714 {
715 ReferenceList refCategoryList = SuggestUtils.getRefListCategory( suggest.getCategories( ) );
716 SuggestUtils.addEmptyItem( refCategoryList );
717 model.put( MARK_CATEGORY_LIST, refCategoryList );
718 model.put( MARK_SUGGEST_SUBMIT_CATEGORY_SELECTED, getSearchFields( ).getIdCategory( ) );
719 }
720
721 if ( ( suggest.getSuggestSubmitTypes( ) != null ) && !suggest.getSuggestSubmitTypes( ).isEmpty( ) )
722 {
723 ReferenceList refSuggestSubmitTypes = SuggestUtils.getRefListType( suggest.getSuggestSubmitTypes( ) );
724 SuggestUtils.addEmptyItem( refSuggestSubmitTypes );
725 model.put( MARK_SUGGEST_SUBMIT_TYPE_LIST, refSuggestSubmitTypes );
726 model.put( MARK_SUGGEST_SUBMIT_TYPE_SELECTED, getSearchFields( ).getIdType( ) );
727 }
728
729
730 if ( ( suggest.getIdWorkflow( ) > 0 ) && WorkflowService.getInstance( ).isAvailable( ) )
731 {
732 StateService stateService = SpringContextService.getBean( StateService.BEAN_SERVICE );
733 int nIdWorkflow = suggest.getIdWorkflow( );
734
735 for ( SuggestSubmit submit : listSuggestSubmitDisplay )
736 {
737
738 State stateSuggestSubmit = stateService.findByResource( submit.getIdSuggestSubmit( ), SuggestSubmit.RESOURCE_TYPE, nIdWorkflow );
739 if ( stateSuggestSubmit != null )
740 {
741
742 submit.setState( stateSuggestSubmit );
743 }
744 else
745 {
746
747 submit.setState( WorkflowService.getInstance( ).getState( submit.getIdSuggestSubmit( ), SuggestSubmit.RESOURCE_TYPE, nIdWorkflow,
748 suggest.getIdSuggest( ) ) );
749 }
750
751 submit.setListWorkflowActions( WorkflowService.getInstance( ).getActions( submit.getIdSuggestSubmit( ), SuggestSubmit.RESOURCE_TYPE,
752 suggest.getIdWorkflow( ), (User) getUser( ) ) );
753 }
754 }
755
756 model.put( MARK_PAGINATOR, paginator );
757 model.put( MARK_NB_ITEMS_PER_PAGE, EMPTY_STRING + _nItemsPerPageSuggestSubmit );
758 model.put( MARK_SUGGEST_SUBMIT_STATE_REF_LIST, refListSuggestSumitState );
759 model.put( MARK_SUGGEST_SUBMIT_STATE_SELECTED, getSearchFields( ).getIdSuggestSumitState( ) );
760 model.put( MARK_SUGGEST_SUBMIT_LIST, listSuggestSubmitDisplay );
761 model.put( MARK_SUGGEST, suggest );
762 model.put( MARK_DISABLE_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_DISABLE );
763 model.put( MARK_PUBLISH_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_PUBLISH );
764 model.put( MARK_WAITING_FOR_PUBLISH_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_WAITING_FOR_PUBLISH );
765 model.put( MARK_NUMBER_SHOWN_CHARACTERS, nNumberShownCharacters );
766 model.put( MARK_LIST_SUGGEST_SUBMIT_SORT, refListSuggestSort );
767 model.put( MARK_SUGGEST_SUBMIT_SORT_SELECTED, getSearchFields( ).getIdSuggestSubmitSort( ) );
768 model.put( MARK_REPORT_REF_LIST, refListAllYesNo );
769 model.put( MARK_REPORT_SELECTED, getSearchFields( ).getIdSuggestSubmitReport( ) );
770 model.put( MARK_CONTAINS_COMMENT_DISABLE_LIST, refListAllYesNo );
771 model.put( MARK_CONTAINS_COMMENT_DISABLE_SELECTED, getSearchFields( ).getIdSuggestSubmitContainsCommentDisable( ) );
772 model.put( MARK_QUERY, getSearchFields( ).getQuery( ) );
773
774 PluginActionManager.fillModel( request, getUser( ), model, ISuggestAction.class, MARK_SUGGEST_ACTIONS );
775
776 setPageTitleProperty( PROPERTY_MANAGE_SUGGEST_SUBMIT_PAGE_TITLE );
777
778 HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_MANAGE_SUGGEST_SUBMIT, getLocale( ), model );
779
780
781
782 result.setHtmlContent( getAdminPage( templateList.getHtml( ) ) );
783
784 return result;
785 }
786
787
788
789
790
791
792
793
794
795
796 public String getManageSuggestSubmitOrder( HttpServletRequest request ) throws AccessDeniedException
797 {
798 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
799 int nNumberShownCharacters = AppPropertiesService.getPropertyInt( PROPERTY_NUMBER_SUGGEST_SUBMIT_VALUE_SHOWN_CHARACTERS, 100 );
800
801 _strCurrentPageIndexSuggestSubmitOrder = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndexSuggestSubmitOrder );
802 _nItemsPerPageSuggestSubmitOrder = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPageSuggestSubmitOrder,
803 _nDefaultItemsPerPage );
804
805 List<SuggestSubmit> listSuggestSubmitDisplay = new ArrayList<SuggestSubmit>( );
806
807 if ( ( strIdSuggest != null ) && !strIdSuggest.equals( EMPTY_STRING ) )
808 {
809 _nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
810 }
811
812 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, getPlugin( ) );
813
814 if ( ( suggest == null )
815 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggest.getIdSuggest( ),
816 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
817 {
818 throw new AccessDeniedException( "Access denied" );
819 }
820
821
822 SubmitFilter filter = SuggestUtils.getSuggestSubmitFilter( getSearchFields( ) );
823
824 filter.setSortBy( new ArrayList<>( ) );
825 SuggestUtils.initSubmitFilterBySort( filter, SubmitFilter.SORT_MANUALLY );
826 SuggestUtils.initSubmitFilterBySort( filter, SubmitFilter.SORT_BY_PINNED_FIRST );
827
828 List<Integer> listIdSuggestSubmitResult = _suggestSubmitService.getSuggestSubmitListId( filter, getPlugin( ) );
829
830 Map<String, Object> model = new HashMap<>( );
831 Paginator<Integer> paginator = new Paginator<Integer>( listIdSuggestSubmitResult, _nItemsPerPageSuggestSubmitOrder,
832 getJspManageSuggestSubmitOrder( request ), PARAMETER_PAGE_INDEX, _strCurrentPageIndexSuggestSubmitOrder );
833 SuggestSubmit suggestSubmit;
834
835 for ( Object idSuggestSubmitDisplay : paginator.getPageItems( ) )
836 {
837 suggestSubmit = _suggestSubmitService.findByPrimaryKey( (Integer) idSuggestSubmitDisplay, false, getPlugin( ) );
838 listSuggestSubmitDisplay.add( suggestSubmit );
839 }
840
841 model.put( MARK_SUGGEST_SUBMIT_ORDER_LIST_PINNED, getSuggestSubmitOrderList( _nIdSuggest, true ) );
842 model.put( MARK_SUGGEST_SUBMIT_ORDER_LIST, getSuggestSubmitOrderList( _nIdSuggest, false ) );
843 model.put( MARK_DISABLE_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_DISABLE );
844 model.put( MARK_PUBLISH_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_PUBLISH );
845 model.put( MARK_WAITING_FOR_PUBLISH_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_WAITING_FOR_PUBLISH );
846
847 model.put( MARK_PAGINATOR, paginator );
848 model.put( MARK_NB_ITEMS_PER_PAGE, EMPTY_STRING + _nItemsPerPageSuggestSubmit );
849
850 model.put( MARK_SUGGEST_SUBMIT_LIST, listSuggestSubmitDisplay );
851 model.put( MARK_SUGGEST, suggest );
852 model.put( MARK_NUMBER_SHOWN_CHARACTERS, nNumberShownCharacters );
853
854 HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_MANAGE_SUGGEST_SUBMIT_ORDER, getLocale( ), model );
855
856 setPageTitleProperty( PROPERTY_MANAGE_SUGGEST_SUBMIT_ORDER_PAGE_TITLE );
857
858 return getAdminPage( templateList.getHtml( ) );
859 }
860
861
862
863
864
865
866
867
868
869
870 public String getCreateSuggestSubmit( HttpServletRequest request ) throws AccessDeniedException
871 {
872 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
873
874 if ( ( strIdSuggest != null ) && !strIdSuggest.equals( EMPTY_STRING ) )
875 {
876 _nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
877 }
878
879 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, getPlugin( ) );
880
881 if ( ( suggest == null )
882 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggest.getIdSuggest( ),
883 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
884 {
885 throw new AccessDeniedException( "Access denied" );
886 }
887
888 Map<String, Object> model = SuggestUtils.getModelHtmlForm( suggest, getPlugin( ), getLocale( ), SuggestUtils.CONSTANT_ID_NULL, true );
889
890 HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_CREATE_SUGGEST_SUBMIT, getLocale( ), model );
891
892 setPageTitleProperty( PROPERTY_CREATE_SUGGEST_SUBMIT_PAGE_TITLE );
893
894 return getAdminPage( templateList.getHtml( ) );
895 }
896
897
898
899
900
901
902
903
904 public String doCreateSuggestSubmit( HttpServletRequest request )
905 {
906 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
907
908 if ( ( strIdSuggest != null ) && !strIdSuggest.equals( EMPTY_STRING ) )
909 {
910 _nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
911 }
912
913 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, getPlugin( ) );
914
915 if ( ( request.getParameter( PARAMETER_CANCEL ) == null )
916 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggest.getIdSuggest( ),
917 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
918 {
919 List<Response> listResponse = new ArrayList<Response>( );
920 String strIdCategory = request.getParameter( PARAMETER_ID_CATEGORY );
921 String strIdType = request.getParameter( PARAMETER_ID_TYPE_SUGGEST );
922 String strDisableVote = request.getParameter( PARAMETER_DISABLE_VOTE );
923 String strDisableComment = request.getParameter( PARAMETER_DISABLE_COMMENT );
924 String strEnablePin = request.getParameter( PARAMETER_ENABLE_PIN );
925 int nIdCategory = SuggestUtils.getIntegerParameter( strIdCategory );
926 int nIdType = SuggestUtils.getIntegerParameter( strIdType );
927
928
929 if ( !suggest.getCategories( ).isEmpty( ) )
930 {
931 if ( ( strIdCategory == null ) || strIdCategory.equals( Integer.toString( SuggestUtils.CONSTANT_ID_NULL ) ) )
932 {
933 return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_NO_CATEGORY, AdminMessage.TYPE_STOP );
934 }
935 }
936
937
938 if ( !suggest.getSuggestSubmitTypes( ).isEmpty( ) )
939 {
940 if ( ( strIdType == null ) || strIdType.equals( Integer.toString( SuggestUtils.CONSTANT_ID_NULL ) ) )
941 {
942 return AdminMessageService.getMessageUrl( request, MESSAGE_ERROR_NO_SUGGEST_SUBMIT_TYPE_SELECTED, AdminMessage.TYPE_STOP );
943 }
944 }
945
946 SuggestSubmitness/SuggestSubmit.html#SuggestSubmit">SuggestSubmit suggestSubmit = new SuggestSubmit( );
947 suggestSubmit.setSuggest( suggest );
948 suggestSubmit.setResponses( listResponse );
949
950 FormError formError = SuggestUtils.getAllResponsesData( request, suggestSubmit, getPlugin( ), getLocale( ) );
951
952 if ( formError != null )
953 {
954 if ( formError.isMandatoryError( ) )
955 {
956 Object [ ] tabRequiredFields = {
957 formError.getTitleQuestion( )
958 };
959
960 return AdminMessageService.getMessageUrl( request, MESSAGE_MANDATORY_QUESTION, tabRequiredFields, AdminMessage.TYPE_STOP );
961 }
962
963 Object [ ] tabFormError = {
964 formError.getTitleQuestion( ), formError.getErrorMessage( )
965 };
966
967 return AdminMessageService.getMessageUrl( request, MESSAGE_FORM_ERROR, tabFormError, AdminMessage.TYPE_STOP );
968 }
969
970
971 if ( nIdCategory != SuggestUtils.CONSTANT_ID_NULL )
972 {
973 Category category = CategoryHome.findByPrimaryKey( nIdCategory, getPlugin( ) );
974 suggestSubmit.setCategory( category );
975 }
976
977 if ( nIdType != SuggestUtils.CONSTANT_ID_NULL )
978 {
979 SuggestSubmitType type = SuggestSubmitTypeHome.findByPrimaryKey( nIdType, getPlugin( ) );
980 suggestSubmit.setSuggestSubmitType( type );
981 }
982
983 suggestSubmit.setDisableComment( strDisableComment != null );
984 suggestSubmit.setDisableVote( strDisableVote != null );
985 suggestSubmit.setPinned( strEnablePin != null );
986 _suggestSubmitService.create( suggestSubmit, getPlugin( ), getLocale( ), getUser( ) );
987 }
988
989 return getJspManageSuggestSubmit( request );
990 }
991
992
993
994
995
996
997
998
999
1000
1001 public String getManageCommentSubmit( HttpServletRequest request ) throws AccessDeniedException
1002 {
1003 Plugin plugin = getPlugin( );
1004 Locale locale = getLocale( );
1005
1006 String strIdCommentSort = request.getParameter( PARAMETER_ID_COMMENT_SORT );
1007 String strIdCommentState = request.getParameter( PARAMETER_ID_COMMENT_STATE );
1008 String strIdContainsSubCommentDisable = request.getParameter( PARAMETER_ID_CONTAINS_SUB_COMMENT_DISABLE );
1009
1010 String strCommentIdParent = request.getParameter( PARAMETER_ID_PARENT );
1011
1012 if ( ( strIdCommentSort != null ) && !strIdCommentSort.equals( EMPTY_STRING ) )
1013 {
1014 _nIdCommentSort = SuggestUtils.getIntegerParameter( strIdCommentSort );
1015 }
1016
1017 if ( ( strIdCommentState != null ) && !strIdCommentState.equals( EMPTY_STRING ) )
1018 {
1019 _nIdCommentState = SuggestUtils.getIntegerParameter( strIdCommentState );
1020 }
1021
1022 if ( ( strIdContainsSubCommentDisable != null ) && !strIdContainsSubCommentDisable.equals( EMPTY_STRING ) )
1023 {
1024 _nIdContainsSubCommentDisable = SuggestUtils.getIntegerParameter( strIdContainsSubCommentDisable );
1025 }
1026
1027 int nNumberShownCharacters = AppPropertiesService.getPropertyInt( PROPERTY_NUMBER_SUGGEST_SUBMIT_VALUE_SHOWN_CHARACTERS, 100 );
1028 String strIdSuggestSubmit = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT );
1029 _strCurrentPageIndexCommentSubmit = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndexCommentSubmit );
1030 _nItemsPerPageCommentSubmit = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPageCommentSubmit,
1031 _nDefaultItemsPerPage );
1032
1033 if ( ( strIdSuggestSubmit != null ) && !strIdSuggestSubmit.equals( EMPTY_STRING ) )
1034 {
1035 _nIdSuggestSubmit = SuggestUtils.getIntegerParameter( strIdSuggestSubmit );
1036 }
1037
1038 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( _nIdSuggestSubmit, false, plugin );
1039 Suggest suggest = SuggestHome.findByPrimaryKey( suggestSubmit.getSuggest( ).getIdSuggest( ), plugin );
1040
1041 if ( !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1042 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1043 {
1044 throw new AccessDeniedException( "Access denied" );
1045 }
1046
1047
1048 if ( suggestSubmit.isReported( ) )
1049 {
1050 suggestSubmit.setReportedMessages( ReportedMessageHome.getReportedMessageBySuggestSubmit( suggestSubmit.getIdSuggestSubmit( ), getPlugin( ) ) );
1051 }
1052
1053
1054 SubmitFilter filter = SuggestUtils.getSuggestSubmitFilter( getSearchFields( ) );
1055
1056 SubmitFilteriness/SubmitFilter.html#SubmitFilter">SubmitFilter commentFilter = new SubmitFilter( );
1057 commentFilter.setIdSuggestSubmit( _nIdSuggestSubmit );
1058 commentFilter.setIdSuggest( _nIdSuggest );
1059 commentFilter.setIdContainsCommentDisable( _nIdContainsSubCommentDisable );
1060 commentFilter.setIdCommentSubmitState( _nIdCommentState );
1061
1062 SuggestUtils.initCommentFilterBySort( commentFilter, _nIdCommentSort );
1063
1064 List<CommentSubmit> listCommentSubmit = _commentSubmitService.getCommentSubmitList( commentFilter, getPlugin( ) );
1065
1066 ReferenceList refListCommentSort = SuggestUtils.getRefListCommentSort( locale );
1067
1068 ReferenceList refCategoryList = SuggestUtils.getRefListCategory( suggest.getCategories( ) );
1069 SuggestUtils.addEmptyItem( refCategoryList );
1070
1071 Map<String, Object> model = new HashMap<>( );
1072 Paginator<CommentSubmit> paginator = new Paginator<CommentSubmit>( listCommentSubmit, _nItemsPerPageCommentSubmit,
1073 getJspManageCommentSubmit( request ), PARAMETER_PAGE_INDEX, _strCurrentPageIndexCommentSubmit );
1074 ReferenceList refListAllYesNo = getRefListAllYesNo( getLocale( ) );
1075
1076 model.put( MARK_COMMENT_SORT_SELECTED, _nIdCommentSort );
1077 model.put( MARK_COMMENT_SORT_LIST, refListCommentSort );
1078 model.put( MARK_COMMENT_STATE_SELECTED, _nIdCommentState );
1079 model.put( MARK_COMMENT_STATE_LIST, SuggestUtils.getRefListCommentState( locale ) );
1080 model.put( MARK_CONTAINS_SUB_COMMENT_DISABLE_SELECTED, _nIdContainsSubCommentDisable );
1081 model.put( MARK_CONTAINS_SUB_COMMENT_DISABLE_LIST, refListAllYesNo );
1082 model.put( MARK_PAGINATOR, paginator );
1083 model.put( MARK_NB_ITEMS_PER_PAGE, EMPTY_STRING + _nItemsPerPageCommentSubmit );
1084 model.put( MARK_COMMENT_SUBMIT_LIST, paginator.getPageItems( ) );
1085 model.put( MARK_SUGGEST_SUBMIT, suggestSubmit );
1086 model.put( MARK_ID_SUGGEST_SUBMIT_PREV, _suggestSubmitService.findPrevIdSuggestSubmitInTheList( _nIdSuggestSubmit, filter, plugin ) );
1087 model.put( MARK_ID_SUGGEST_SUBMIT_NEXT, _suggestSubmitService.findNextIdSuggestSubmitInTheList( _nIdSuggestSubmit, filter, plugin ) );
1088 model.put( MARK_DISABLE_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_DISABLE );
1089 model.put( MARK_PUBLISH_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_PUBLISH );
1090 model.put( MARK_WAITING_FOR_PUBLISH_SUGGEST_SUBMIT_STATE_NUMBER, SuggestSubmit.STATE_WAITING_FOR_PUBLISH );
1091 model.put( MARK_NUMBER_SHOWN_CHARACTERS, nNumberShownCharacters );
1092 model.put( MARK_CATEGORY_LIST, refCategoryList );
1093
1094 model.put( MARK_SUGGEST, suggest );
1095 model.put( MARK_ID_PARENT, strCommentIdParent );
1096
1097 setPageTitleProperty( PROPERTY_MANAGE_COMMENT_SUBMIT_PAGE_TITLE );
1098
1099 HtmlTemplate templateList = AppTemplateService.getTemplate( TEMPLATE_MANAGE_COMMENT_SUBMIT, locale, model );
1100
1101
1102
1103 return getAdminPage( templateList.getHtml( ) );
1104 }
1105
1106
1107
1108
1109
1110
1111
1112
1113 public String getConfirmRemoveSuggestSubmit( HttpServletRequest request )
1114 {
1115 String strIdSuggestSubmit = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT );
1116 String strComment = request.getParameter( PARAMETER_COMMENT );
1117
1118 String strMessage;
1119 int nIdSuggestSubmit = SuggestUtils.getIntegerParameter( strIdSuggestSubmit );
1120
1121 if ( nIdSuggestSubmit == -1 )
1122 {
1123 return getHomeUrl( request );
1124 }
1125
1126 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( nIdSuggestSubmit, false, getPlugin( ) );
1127
1128 if ( ( suggestSubmit == null )
1129 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1130 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1131 {
1132 return getJspManageSuggest( request );
1133 }
1134
1135 strMessage = MESSAGE_CONFIRM_REMOVE_SUGGEST_SUBMIT;
1136
1137 UrlItem url = new UrlItem( JSP_DO_REMOVE_SUGGEST_SUBMIT );
1138
1139 if ( strComment != null )
1140 {
1141 url.addParameter( strComment, strComment );
1142 }
1143
1144 url.addParameter( PARAMETER_ID_SUGGEST_SUBMIT, nIdSuggestSubmit );
1145
1146 return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
1147 }
1148
1149
1150
1151
1152
1153
1154
1155
1156 public String doRemoveSuggestSubmit( HttpServletRequest request )
1157 {
1158 String strIdSuggestSubmit = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT );
1159 String strComment = request.getParameter( PARAMETER_COMMENT );
1160 Plugin plugin = getPlugin( );
1161 int nIdSuggestSubmit = SuggestUtils.getIntegerParameter( strIdSuggestSubmit );
1162
1163 if ( nIdSuggestSubmit == -1 )
1164 {
1165 return getHomeUrl( request );
1166 }
1167
1168 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( nIdSuggestSubmit, false, getPlugin( ) );
1169
1170 if ( ( suggestSubmit == null )
1171 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1172 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1173 {
1174 return getJspManageSuggest( request );
1175 }
1176
1177 String strUrlBack;
1178
1179 if ( strComment != null )
1180 {
1181
1182 strUrlBack = doFindNextSuggestSubmit( request );
1183 }
1184 else
1185 {
1186 strUrlBack = getJspManageSuggestSubmit( request );
1187 }
1188
1189 _suggestSubmitService.remove( nIdSuggestSubmit, plugin, getUser( ) );
1190
1191 return strUrlBack;
1192 }
1193
1194
1195
1196
1197
1198
1199
1200
1201 public String doChangeSuggestSubmitState( HttpServletRequest request )
1202 {
1203 String strIdSuggestSubmit = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT );
1204 String strStateNumber = request.getParameter( PARAMETER_STATE_NUMBER );
1205 String strComment = request.getParameter( PARAMETER_COMMENT );
1206
1207 Plugin plugin = getPlugin( );
1208 int nIdSuggestSubmit = SuggestUtils.getIntegerParameter( strIdSuggestSubmit );
1209 int nStateNumber = SuggestUtils.getIntegerParameter( strStateNumber );
1210
1211 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( nIdSuggestSubmit, false, plugin );
1212 SuggestSubmitState suggestSubmitState = SuggestSubmitStateHome.findByNumero( nStateNumber, plugin );
1213
1214 if ( ( suggestSubmit == null )
1215 || ( suggestSubmitState == null )
1216 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1217 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1218 {
1219 return getJspManageSuggest( request );
1220 }
1221
1222 suggestSubmit.setSuggestSubmitState( suggestSubmitState );
1223 _suggestSubmitService.update( suggestSubmit, plugin );
1224
1225 if ( strComment != null )
1226 {
1227 return getJspManageCommentSubmit( request );
1228 }
1229
1230 return getJspManageSuggestSubmit( request );
1231 }
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242 public String getConfirmMassChangeSuggestSubmitCategory( HttpServletRequest request ) throws AccessDeniedException
1243 {
1244
1245 String [ ] selectedSuggestSubmit = request.getParameterValues( PARAMETER_SELECTED_SUGGEST_SUBMIT );
1246 int nIdSuggestSubmit;
1247 String strIdCategory = request.getParameter( PARAMETER_ID_CATEGORY );
1248 int nIdCategory = SuggestUtils.getIntegerParameter( strIdCategory );
1249 UrlItem url = new UrlItem( JSP_DO_CHANGE_SUGGEST_SUBMIT_CATEGORY );
1250 url.addParameter( PARAMETER_ID_CATEGORY, nIdCategory );
1251
1252
1253 for ( String strIdSuggestSubmit : selectedSuggestSubmit )
1254 {
1255 if ( StringUtils.isNotBlank( strIdSuggestSubmit ) && StringUtils.isNumeric( strIdSuggestSubmit ) )
1256 {
1257 nIdSuggestSubmit = SuggestUtils.getIntegerParameter( strIdSuggestSubmit );
1258
1259 SuggestSubmit suggestSubmit = SuggestSubmitService.getService( ).findByPrimaryKey( nIdSuggestSubmit, false, getPlugin( ) );
1260
1261 if ( ( suggestSubmit == null )
1262 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, SuggestUtils.EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1263 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1264 {
1265 throw new AccessDeniedException( "Access denied" );
1266 }
1267
1268 url.addParameter( PARAMETER_SELECTED_SUGGEST_SUBMIT, nIdSuggestSubmit );
1269 }
1270 }
1271
1272 if ( nIdCategory != SuggestUtils.CONSTANT_ID_NULL )
1273 {
1274 Category category = CategoryHome.findByPrimaryKey( nIdCategory, getPlugin( ) );
1275 Object [ ] args = {
1276 ( ( category == null ) || ( category.getTitle( ) == null ) ) ? "" : category.getTitle( )
1277 };
1278
1279 return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_CHANGE_SUGGEST_SUBMIT_CATEGORY, args, url.getUrl( ),
1280 AdminMessage.TYPE_CONFIRMATION );
1281 }
1282
1283 return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_REMOVE_SUGGEST_SUBMIT_CATEGORY, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
1284 }
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295 public String doMassChangeSuggestSubmitCategory( HttpServletRequest request ) throws AccessDeniedException
1296 {
1297
1298 String [ ] selectedSuggestSubmit = request.getParameterValues( PARAMETER_SELECTED_SUGGEST_SUBMIT );
1299 int nIdSuggestSubmit;
1300 String strIdCategory = request.getParameter( PARAMETER_ID_CATEGORY );
1301 int nIdCategory = SuggestUtils.getIntegerParameter( strIdCategory );
1302 Category categorySelected = null;
1303
1304
1305 for ( String strIdSuggestSubmit : selectedSuggestSubmit )
1306 {
1307 if ( StringUtils.isNotBlank( strIdSuggestSubmit ) && StringUtils.isNumeric( strIdSuggestSubmit ) )
1308 {
1309 nIdSuggestSubmit = SuggestUtils.getIntegerParameter( strIdSuggestSubmit );
1310
1311 SuggestSubmit suggestSubmit = SuggestSubmitService.getService( ).findByPrimaryKey( nIdSuggestSubmit, false, getPlugin( ) );
1312
1313 if ( ( suggestSubmit == null )
1314 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, SuggestUtils.EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1315 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1316 {
1317 throw new AccessDeniedException( "Access denied" );
1318 }
1319 }
1320 }
1321
1322 if ( nIdCategory != SuggestUtils.CONSTANT_ID_NULL )
1323 {
1324 categorySelected = CategoryHome.findByPrimaryKey( nIdCategory, getPlugin( ) );
1325 }
1326
1327
1328 for ( String strIdSuggestSubmittoUpdate : selectedSuggestSubmit )
1329 {
1330 if ( StringUtils.isNotBlank( strIdSuggestSubmittoUpdate ) && StringUtils.isNumeric( strIdSuggestSubmittoUpdate ) )
1331 {
1332 nIdSuggestSubmit = SuggestUtils.getIntegerParameter( strIdSuggestSubmittoUpdate );
1333
1334 SuggestSubmit suggestSubmit = SuggestSubmitService.getService( ).findByPrimaryKey( nIdSuggestSubmit, false, getPlugin( ) );
1335 suggestSubmit.setCategory( categorySelected );
1336 SuggestSubmitService.getService( ).update( suggestSubmit, getPlugin( ) );
1337 }
1338 }
1339
1340 return getJspManageSuggestSubmit( request );
1341 }
1342
1343
1344
1345
1346
1347
1348
1349
1350 public String doChangeSuggestSubmitCategory( HttpServletRequest request )
1351 {
1352 String strIdSuggestSubmit = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT );
1353 String strIdCategory = request.getParameter( PARAMETER_ID_CATEGORY );
1354 String strComment = request.getParameter( PARAMETER_COMMENT );
1355
1356 Plugin plugin = getPlugin( );
1357 int nIdSuggestSubmit = SuggestUtils.getIntegerParameter( strIdSuggestSubmit );
1358 int nIdCategory = SuggestUtils.getIntegerParameter( strIdCategory );
1359
1360 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( nIdSuggestSubmit, false, plugin );
1361 Category category = CategoryHome.findByPrimaryKey( nIdCategory, plugin );
1362
1363 if ( ( suggestSubmit == null )
1364 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1365 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1366 {
1367 return getJspManageSuggest( request );
1368 }
1369
1370 suggestSubmit.setCategory( category );
1371
1372 _suggestSubmitService.update( suggestSubmit, plugin );
1373
1374 if ( strComment != null )
1375 {
1376 return getJspManageCommentSubmit( request );
1377 }
1378
1379 return getJspManageSuggestSubmit( request );
1380 }
1381
1382
1383
1384
1385
1386
1387
1388
1389 public String doChangeCommentSubmit( HttpServletRequest request )
1390 {
1391 String strIdParentCommentSubmit = request.getParameter( PARAMETER_ID_PARENT );
1392
1393 if ( request.getParameter( PARAMETER_DELETE ) != null )
1394 {
1395 String strIdCommentSubmit = request.getParameter( PARAMETER_ID_COMMENT_SUBMIT );
1396
1397 String strMessage;
1398 int nIdCommentSubmit = SuggestUtils.getIntegerParameter( strIdCommentSubmit );
1399
1400 if ( nIdCommentSubmit == -1 )
1401 {
1402 return getHomeUrl( request );
1403 }
1404
1405 strMessage = MESSAGE_CONFIRM_REMOVE_COMMENT_SUBMIT;
1406
1407 UrlItem url = new UrlItem( JSP_DO_REMOVE_COMMENT_SUBMIT );
1408 url.addParameter( PARAMETER_ID_COMMENT_SUBMIT, nIdCommentSubmit );
1409 url.addParameter( PARAMETER_ID_PARENT, strIdParentCommentSubmit );
1410
1411 return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
1412 }
1413 else
1414 if ( request.getParameter( PARAMETER_ENABLE ) != null )
1415 {
1416 doEnableCommentSubmit( request );
1417 }
1418 else
1419 if ( request.getParameter( PARAMETER_DISABLE ) != null )
1420 {
1421 doDisableCommentSubmit( request );
1422 }
1423
1424 return getJspManageCommentSubmit( request, strIdParentCommentSubmit );
1425 }
1426
1427
1428
1429
1430
1431
1432
1433
1434 public String doSubmitOfficialAnswer( HttpServletRequest request )
1435 {
1436 String strCommentValueSuggest = request.getParameter( PARAMETER_COMMENT_VALUE );
1437 int nIdSubmitSuggest = Integer.valueOf( request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT ) );
1438 CommentSubmitness/CommentSubmit.html#CommentSubmit">CommentSubmit commentSubmit = new CommentSubmit( );
1439 Plugin plugin = getPlugin( );
1440
1441 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( nIdSubmitSuggest, false, plugin );
1442
1443
1444 if ( StringUtil.containsXssCharacters( strCommentValueSuggest ) )
1445 {
1446 return AdminMessageService.getMessageUrl( request, MESSAGE_NEW_COMMENT_SUBMIT_INVALID, SiteMessage.TYPE_STOP );
1447 }
1448
1449 commentSubmit.setActive( true );
1450 suggestSubmit.setNumberCommentEnable( suggestSubmit.getNumberCommentEnable( ) + 1 );
1451 suggestSubmit.setNumberComment( suggestSubmit.getNumberComment( ) + 1 );
1452 _suggestSubmitService.update( suggestSubmit, plugin );
1453
1454 commentSubmit.setDateComment( SuggestUtils.getCurrentDate( ) );
1455 commentSubmit.setSuggestSubmit( suggestSubmit );
1456 commentSubmit.setValue( strCommentValueSuggest );
1457 commentSubmit.setOfficialAnswer( true );
1458
1459 LuteceUser user = null;
1460
1461 try
1462 {
1463 user = SecurityService.getInstance( ).getRemoteUser( request );
1464 }
1465 catch( UserNotSignedException e )
1466 {
1467 AppLogService.error( "User not identified", e );
1468 }
1469
1470 if ( user != null )
1471 {
1472 commentSubmit.setLuteceUserKey( user.getName( ) );
1473 }
1474
1475 _commentSubmitService.create( commentSubmit, plugin );
1476
1477 return getJspManageCommentSubmit( request );
1478 }
1479
1480
1481
1482
1483
1484
1485
1486
1487 public String doRemoveCommentSubmit( HttpServletRequest request )
1488 {
1489 String strIdCommentSubmit = request.getParameter( PARAMETER_ID_COMMENT_SUBMIT );
1490 Plugin plugin = getPlugin( );
1491 int nIdCommentSubmit = SuggestUtils.getIntegerParameter( strIdCommentSubmit );
1492 CommentSubmit commentSubmit = _commentSubmitService.findByPrimaryKey( nIdCommentSubmit, plugin );
1493
1494 if ( commentSubmit == null )
1495 {
1496 return getJspManageSuggest( request );
1497 }
1498
1499 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( commentSubmit.getSuggestSubmit( ).getIdSuggestSubmit( ), false, plugin );
1500
1501 if ( !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1502 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1503 {
1504 return getJspManageSuggest( request );
1505 }
1506
1507 _commentSubmitService.remove( nIdCommentSubmit, plugin );
1508
1509 if ( commentSubmit.isActive( ) )
1510 {
1511 suggestSubmit.setNumberCommentEnable( suggestSubmit.getNumberCommentEnable( ) - 1 );
1512 }
1513
1514 suggestSubmit.setNumberComment( suggestSubmit.getNumberComment( ) - 1 );
1515 _suggestSubmitService.update( suggestSubmit, plugin );
1516
1517 return getJspManageCommentSubmit( request );
1518 }
1519
1520
1521
1522
1523
1524
1525
1526
1527 public String doDisableCommentSubmit( HttpServletRequest request )
1528 {
1529 String strIdCommentSubmit = request.getParameter( PARAMETER_ID_COMMENT_SUBMIT );
1530 Plugin plugin = getPlugin( );
1531 int nIdCommentSubmit = SuggestUtils.getIntegerParameter( strIdCommentSubmit );
1532 CommentSubmit commentSubmit = _commentSubmitService.findByPrimaryKey( nIdCommentSubmit, plugin );
1533
1534 if ( commentSubmit != null )
1535 {
1536 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( commentSubmit.getSuggestSubmit( ).getIdSuggestSubmit( ), false, plugin );
1537
1538 if ( !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1539 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1540 {
1541 return getJspManageSuggest( request );
1542 }
1543
1544 commentSubmit.setActive( false );
1545 _commentSubmitService.update( commentSubmit, plugin );
1546 suggestSubmit.setNumberCommentEnable( suggestSubmit.getNumberCommentEnable( ) - 1 );
1547 _suggestSubmitService.update( suggestSubmit, plugin );
1548 }
1549
1550 return null;
1551 }
1552
1553
1554
1555
1556
1557
1558
1559
1560 public String doEnableCommentSubmit( HttpServletRequest request )
1561 {
1562 String strIdCommentSubmit = request.getParameter( PARAMETER_ID_COMMENT_SUBMIT );
1563 Plugin plugin = getPlugin( );
1564 int nIdCommentSubmit = SuggestUtils.getIntegerParameter( strIdCommentSubmit );
1565 CommentSubmit commentSubmit = _commentSubmitService.findByPrimaryKey( nIdCommentSubmit, plugin );
1566
1567 if ( commentSubmit != null )
1568 {
1569 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( commentSubmit.getSuggestSubmit( ).getIdSuggestSubmit( ), false, plugin );
1570
1571 if ( !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + suggestSubmit.getSuggest( ).getIdSuggest( ),
1572 SuggestResourceIdService.PERMISSION_MANAGE_SUGGEST_SUBMIT, getUser( ) ) )
1573 {
1574 return getJspManageSuggest( request );
1575 }
1576
1577 commentSubmit.setActive( true );
1578 _commentSubmitService.update( commentSubmit, plugin );
1579 suggestSubmit.setNumberCommentEnable( suggestSubmit.getNumberCommentEnable( ) + 1 );
1580 _suggestSubmitService.update( suggestSubmit, plugin );
1581 }
1582
1583 return null;
1584 }
1585
1586
1587
1588
1589
1590
1591
1592
1593 public String doFindNextSuggestSubmit( HttpServletRequest request )
1594 {
1595 Plugin plugin = getPlugin( );
1596 SubmitFilter filter = SuggestUtils.getSuggestSubmitFilter( getSearchFields( ) );
1597 _nIdSuggestSubmit = _suggestSubmitService.findNextIdSuggestSubmitInTheList( _nIdSuggestSubmit, filter, plugin );
1598
1599 return getJspManageCommentSubmit( request );
1600 }
1601
1602
1603
1604
1605
1606
1607
1608
1609 public String doFindPrevSuggestSubmit( HttpServletRequest request )
1610 {
1611 Plugin plugin = getPlugin( );
1612 SubmitFilter filter = SuggestUtils.getSuggestSubmitFilter( getSearchFields( ) );
1613 _nIdSuggestSubmit = _suggestSubmitService.findPrevIdSuggestSubmitInTheList( _nIdSuggestSubmit, filter, plugin );
1614
1615 return getJspManageCommentSubmit( request );
1616 }
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629 private String getSuggestData( MultipartHttpServletRequest request, Suggest suggest )
1630 {
1631
1632 String strDefaultRole = AppPropertiesService.getProperty( PROPERTY_DEFAULT_ROLE_CODE );
1633 String strUpdateFile = request.getParameter( PARAMETER_UPDATE_FILE );
1634 String strTitle = request.getParameter( PARAMETER_TITLE );
1635 String strLibelleContribution = request.getParameter( PARAMETER_LIBELLE_CONTRIBUTION );
1636 String strUnavailabilityMessage = request.getParameter( PARAMETER_UNAVAILABILITY_MESSAGE );
1637 String strWorkgroup = request.getParameter( PARAMETER_WORKGROUP );
1638 String strIdVoteType = request.getParameter( PARAMETER_ID_VOTE_TYPE );
1639 String strActivePropositionState = request.getParameter( PARAMETER_ACTIVE_PROPOSITION_STATE );
1640 String strNumberVoteRequired = request.getParameter( PARAMETER_NUMBER_VOTE_REQUIRED );
1641 String strNumberDayRequired = request.getParameter( PARAMETER_NUMBER_DAY_REQUIRED );
1642 String strNumberSuggestSubmitInTopScore = request.getParameter( PARAMETER_NUMBER_SUGGEST_SUBMIT_IN_TOP_SCORE );
1643 String strNumberSuggestSubmitCaractersShown = request.getParameter( PARAMETER_NUMBER_SUGGEST_SUBMIT_CARACTERS_SHOWN );
1644 String strNumberSuggestSubmitInTopComment = request.getParameter( PARAMETER_NUMBER_SUGGEST_SUBMIT_IN_TOP_COMMENT );
1645 String strThemeXpage = request.getParameter( PARAMETER_THEME_XPAGE );
1646
1647 String strActiveSuggestSubmitAuthentification = request.getParameter( PARAMETER_ACTIVE_SUGGEST_SUBMIT_AUTHENTIFICATION );
1648 String strActiveVoteAuthentification = request.getParameter( PARAMETER_ACTIVE_VOTE_AUTHENTIFICATION );
1649 String strActiveCommentAuthentification = request.getParameter( PARAMETER_ACTIVE_COMMENT_AUTHENTIFICATION );
1650
1651 String strDisableNewSuggestSubmit = request.getParameter( PARAMETER_DISABLE_NEW_SUGGEST_SUBMIT );
1652 String strEnableMailNewSuggestSubmit = request.getParameter( PARAMETER_ENABLE_MAIL_NEW_SUGGEST_SUBMIT );
1653 String strIdMailingListSuggestSubmit = request.getParameter( PARAMETER_ID_MAILING_LIST_SUGGEST_SUBMIT );
1654
1655 String strAuthorizedComment = request.getParameter( PARAMETER_AUTHORIZED_COMMENT );
1656 String strActiveEditorBbcode = request.getParameter( PARAMETER_ACTIVE_EDITOR_BBCODE_ON_COMMENT );
1657 String strDisableNewComment = request.getParameter( PARAMETER_DISABLE_NEW_COMMENT );
1658 String strLimitNumberVote = request.getParameter( PARAMETER_LIMIT_NUMBER_VOTE );
1659 String strActiveCaptcha = request.getParameter( PARAMETER_ACTIVE_CAPTCHA );
1660 String strLibelleValidateButton = request.getParameter( PARAMETER_LIBELLE_VALIDATE_BUTTON );
1661 String strShowCategoryBlock = request.getParameter( PARAMETER_SHOW_CATEGORY_BLOCK );
1662 String strShowTopScoreBlock = request.getParameter( PARAMETER_SHOW_TOP_SCORE_BLOCK );
1663 String strShowTopCommentBlock = request.getParameter( PARAMETER_SHOW_TOP_COMMENT_BLOCK );
1664 String strActiveSuggestSubmitPaginator = request.getParameter( PARAMETER_ACTIVE_SUGGEST_SUBMIT_PAGINATOR );
1665 String strNumberSuggestSubmitPerPage = request.getParameter( PARAMETER_NUMBER_SUGGEST_SUBMIT_PER_PAGE );
1666 String strRole = request.getParameter( PARAMETER_ROLE );
1667 String strHeader = request.getParameter( PARAMETER_HEADER );
1668 String strConfirmationMessage = request.getParameter( PARAMETER_CONFIRMATION_MESSAGE );
1669 String strIdDefaultSort = request.getParameter( PARAMETER_ID_DEFAULT_SORT );
1670 String strDisableVote = request.getParameter( PARAMETER_DISABLE_VOTE );
1671 String strDisplayCommentInSuggestSubmitList = request.getParameter( PARAMETER_DISPLAY_COMMENT_IN_SUGGEST_SUBMIT_LIST );
1672 String strNumberCommentDisplayInSuggestSubmitList = request.getParameter( PARAMETER_NUMBER_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST );
1673 String strNumberCharCommentDisplayInSuggestSubmitList = request.getParameter( PARAMETER_NUMBER_CHAR_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST );
1674 String strEnableMailNewCommentSubmit = request.getParameter( PARAMETER_ENABLE_MAIL_NEW_COMMENT_SUBMIT );
1675 String strEnableMailNewReportedSubmit = request.getParameter( PARAMETER_ENABLE_MAIL_NEW_REPORTED_SUBMIT );
1676 String strEnableTermsOfUse = request.getParameter( PARAMETER_ENABLE_TERMS_OF_USE );
1677 String strTermsOfUse = request.getParameter( PARAMETER_TERMS_OF_USE );
1678 String strEnableReports = request.getParameter( PARAMETER_ENABLE_REPORTS );
1679 String strDescription = request.getParameter( PARAMETER_DESCRIPTION );
1680 String strNotificationNewCommentSenderName = request.getParameter( PARAMETER_NOTIFICATION_NEW_COMMENT_SENDER_NAME );
1681 String strNotificationNewCommentTitle = request.getParameter( PARAMETER_NOTIFICATION_NEW_COMMENT_TITLE );
1682 String strNotificationNewCommentBody = request.getParameter( PARAMETER_NOTIFICATION_NEW_COMMENT_BODY );
1683 String strNotificationNewSuggestSubmitSenderName = request.getParameter( PARAMETER_NOTIFICATION_NEW_SUGGEST_SUBMIT_SENDER_NAME );
1684 String strNotificationNewSuggestSubmitTitle = request.getParameter( PARAMETER_NOTIFICATION_NEW_SUGGEST_SUBMIT_TITLE );
1685 String strNotificationNewSuggestSubmitBody = request.getParameter( PARAMETER_NOTIFICATION_NEW_SUGGEST_SUBMIT_BODY );
1686
1687 int nIdVoteType = SuggestUtils.getIntegerParameter( strIdVoteType );
1688 int nIdMailingListSuggestSubmit = SuggestUtils.getIntegerParameter( strIdMailingListSuggestSubmit );
1689 int nNumberDayRequired = SuggestUtils.getIntegerParameter( strNumberDayRequired );
1690 int nNumberVoteRequired = SuggestUtils.getIntegerParameter( strNumberVoteRequired );
1691 int nNumberSuggestSubmitInTopScore = SuggestUtils.getIntegerParameter( strNumberSuggestSubmitInTopScore );
1692 int nNumberSuggestSubmitCaractersShown = SuggestUtils.getIntegerParameter( strNumberSuggestSubmitCaractersShown );
1693 int nNumberSuggestSubmitInTopComment = SuggestUtils.getIntegerParameter( strNumberSuggestSubmitInTopComment );
1694 int nNumberSuggestSubmitPerPage = SuggestUtils.getIntegerParameter( strNumberSuggestSubmitPerPage );
1695 int nIdDefaultSort = SuggestUtils.getIntegerParameter( strIdDefaultSort );
1696 int nNumberCommentDisplayInSuggestSubmitList = SuggestUtils.getIntegerParameter( strNumberCommentDisplayInSuggestSubmitList );
1697 int nNumberCharCommentDisplayInSuggestSubmitList = SuggestUtils.getIntegerParameter( strNumberCharCommentDisplayInSuggestSubmitList );
1698
1699
1700 String strIdWorkflow = request.getParameter( PARAMETER_ID_WORKFLOW );
1701 int nIdWorkflow = SuggestUtils.getIntegerParameter( strIdWorkflow );
1702
1703 String strFieldError = EMPTY_STRING;
1704
1705 if ( StringUtils.isEmpty( strTitle ) )
1706 {
1707 strFieldError = FIELD_TITLE;
1708 }
1709
1710 else
1711 if ( StringUtils.isEmpty( strLibelleContribution ) )
1712 {
1713 strFieldError = FIELD_LIBELLE_CONTRIBUTION;
1714 }
1715
1716 else
1717 if ( StringUtils.isEmpty( strUnavailabilityMessage ) )
1718 {
1719 strFieldError = FIELD_UNAVAILABILITY_MESSAGE;
1720 }
1721 else
1722 if ( nIdVoteType == -1 )
1723 {
1724 strFieldError = FIELD_VOTE_TYPE;
1725 }
1726 else
1727 if ( StringUtils.isEmpty( strNumberSuggestSubmitCaractersShown ) )
1728 {
1729 strFieldError = FIELD_NUMBER_SUGGEST_SUBMIT_CARACTERS_SHOWN;
1730 }
1731 else
1732 if ( ( ( ( strShowTopScoreBlock != null ) && strShowTopScoreBlock.trim( ).equals( CONSTANTE_YES_VALUE ) ) && ( strNumberSuggestSubmitInTopScore == null ) )
1733 || strNumberSuggestSubmitInTopScore.trim( ).equals( EMPTY_STRING ) )
1734 {
1735 strFieldError = FIELD_NUMBER_SUGGEST_SUBMIT_IN_TOP_SCORE;
1736 }
1737
1738 else
1739 if ( ( ( strAuthorizedComment != null ) && strAuthorizedComment.trim( ).equals( CONSTANTE_YES_VALUE ) )
1740 && ( ( strNumberSuggestSubmitInTopComment == null ) || strNumberSuggestSubmitInTopComment.trim( ).equals( EMPTY_STRING ) ) )
1741 {
1742 strFieldError = FIELD_NUMBER_SUGGEST_SUBMIT_IN_TOP_COMMENT;
1743 }
1744
1745 else
1746 if ( ( ( strActiveSuggestSubmitPaginator != null ) && strActiveSuggestSubmitPaginator.trim( ).equals( CONSTANTE_YES_VALUE ) )
1747 && ( ( strNumberSuggestSubmitPerPage == null ) || strNumberSuggestSubmitPerPage.trim( ).equals( EMPTY_STRING ) ) )
1748 {
1749 strFieldError = FIELD_NUMBER_SUGGEST_SUBMIT_PER_PAGE;
1750 }
1751
1752 else
1753 if ( ( strLibelleValidateButton == null ) || strLibelleValidateButton.trim( ).equals( EMPTY_STRING ) )
1754 {
1755 strFieldError = FIELD_LIBELE_VALIDATE_BUTTON;
1756 }
1757 else
1758 if ( ( ( strDisplayCommentInSuggestSubmitList != null ) && ( ( strNumberCommentDisplayInSuggestSubmitList == null ) || strNumberCommentDisplayInSuggestSubmitList
1759 .trim( ).equals( EMPTY_STRING ) ) ) )
1760 {
1761 strFieldError = FIELD_NUMBER_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST;
1762 }
1763 else
1764 if ( ( ( strDisplayCommentInSuggestSubmitList != null ) && ( ( strNumberCharCommentDisplayInSuggestSubmitList == null ) || strNumberCharCommentDisplayInSuggestSubmitList
1765 .trim( ).equals( EMPTY_STRING ) ) ) )
1766 {
1767 strFieldError = FIELD_NUMBER_CHAR_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST;
1768 }
1769
1770 else
1771 if ( StringUtils.isEmpty( strNotificationNewCommentTitle ) )
1772 {
1773 strFieldError = FIELD_NOTIFICATION_NEW_COMMENT_TITLE;
1774
1775 }
1776 else
1777 if ( StringUtils.isEmpty( strNotificationNewCommentBody ) )
1778 {
1779 strFieldError = FIELD_NOTIFICATION_NEW_COMMENT_BODY;
1780
1781 }
1782
1783 else
1784 if ( StringUtils.isEmpty( strNotificationNewSuggestSubmitTitle ) )
1785 {
1786
1787 strFieldError = FIELD_NOTIFICATION_NEW_SUGGEST_DUBMIT_TITLE;
1788 }
1789 else
1790 if ( StringUtils.isEmpty( strNotificationNewSuggestSubmitBody ) )
1791 {
1792
1793 strFieldError = FIELD_NOTIFICATION_NEW_SUGGEST_DUBMIT_BODY;
1794 }
1795
1796 if ( !strFieldError.equals( EMPTY_STRING ) )
1797 {
1798 Object [ ] tabRequiredFields = {
1799 I18nService.getLocalizedString( strFieldError, getLocale( ) )
1800 };
1801
1802 return AdminMessageService.getMessageUrl( request, MESSAGE_MANDATORY_FIELD, tabRequiredFields, AdminMessage.TYPE_STOP );
1803 }
1804
1805 if ( nNumberSuggestSubmitCaractersShown < 0 )
1806 {
1807 return AdminMessageService.getMessageUrl( request, MESSAGE_ILLOGICAL_NUMBER_SUGGEST_SUBMIT_CARACTERS_SHOWN, AdminMessage.TYPE_STOP );
1808 }
1809
1810 if ( ( strNumberSuggestSubmitInTopScore != null ) && !strNumberSuggestSubmitInTopScore.trim( ).equals( EMPTY_STRING )
1811 && ( nNumberSuggestSubmitInTopScore < 0 ) )
1812 {
1813 return AdminMessageService.getMessageUrl( request, MESSAGE_ILLOGICAL_NUMBER_SUGGEST_SUBMIT_IN_TOP_SCORE, AdminMessage.TYPE_STOP );
1814 }
1815
1816 if ( ( strActivePropositionState != null ) && strActivePropositionState.trim( ).equals( CONSTANTE_YES_VALUE ) && ( strNumberVoteRequired != null )
1817 && !strNumberVoteRequired.trim( ).equals( EMPTY_STRING ) && ( nNumberVoteRequired < 0 ) )
1818 {
1819 return AdminMessageService.getMessageUrl( request, MESSAGE_ILLOGICAL_NUMBER_VOTE_REQUIRED, AdminMessage.TYPE_STOP );
1820 }
1821
1822 if ( ( strNumberDayRequired != null ) && !strNumberDayRequired.trim( ).equals( EMPTY_STRING ) && ( nNumberDayRequired < 0 ) )
1823 {
1824 return AdminMessageService.getMessageUrl( request, MESSAGE_ILLOGICAL_NUMBER_DAY_REQUIRED, AdminMessage.TYPE_STOP );
1825 }
1826
1827 if ( ( strNumberSuggestSubmitInTopComment != null ) && !strNumberSuggestSubmitInTopComment.trim( ).equals( EMPTY_STRING )
1828 && ( nNumberSuggestSubmitInTopComment < 0 ) )
1829 {
1830 return AdminMessageService.getMessageUrl( request, MESSAGE_ILLOGICAL_NUMBER_SUGGEST_SUBMIT_IN_TOP_COMMENT, AdminMessage.TYPE_STOP );
1831 }
1832
1833 if ( ( strNumberSuggestSubmitPerPage != null ) && !strNumberSuggestSubmitPerPage.trim( ).equals( EMPTY_STRING ) && ( nNumberSuggestSubmitPerPage < 0 ) )
1834 {
1835 return AdminMessageService.getMessageUrl( request, MESSAGE_ILLOGICAL_NUMBER_SUGGEST_SUBMIT_PER_PAGE, AdminMessage.TYPE_STOP );
1836 }
1837
1838 if ( ( strDisplayCommentInSuggestSubmitList != null ) && ( strNumberCommentDisplayInSuggestSubmitList != null )
1839 && !strNumberCommentDisplayInSuggestSubmitList.trim( ).equals( EMPTY_STRING ) && ( nNumberCommentDisplayInSuggestSubmitList < 0 ) )
1840 {
1841 return AdminMessageService.getMessageUrl( request, MESSAGE_ILLOGICAL_NUMBER_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST, AdminMessage.TYPE_STOP );
1842 }
1843
1844 if ( ( strDisplayCommentInSuggestSubmitList != null ) && ( strNumberCharCommentDisplayInSuggestSubmitList != null )
1845 && !strNumberCharCommentDisplayInSuggestSubmitList.trim( ).equals( EMPTY_STRING ) && ( nNumberCommentDisplayInSuggestSubmitList < 0 ) )
1846 {
1847 return AdminMessageService.getMessageUrl( request, MESSAGE_ILLOGICAL_NUMBER_CHAR_COMMENT_DISPLAY_IN_SUGGEST_SUBMIT_LIST, AdminMessage.TYPE_STOP );
1848 }
1849
1850 suggest.setTitle( strTitle );
1851 suggest.setLibelleContribution( strLibelleContribution );
1852 suggest.setUnavailabilityMessage( strUnavailabilityMessage );
1853 suggest.setWorkgroup( strWorkgroup );
1854
1855 if ( suggest.getVoteType( ) == null )
1856 {
1857 suggest.setVoteType( new VoteType( ) );
1858 }
1859
1860 suggest.getVoteType( ).setIdVoteType( nIdVoteType );
1861
1862 if ( ( strActivePropositionState != null ) && strActivePropositionState.trim( ).equals( CONSTANTE_YES_VALUE ) )
1863 {
1864 suggest.setActiveSuggestPropositionState( true );
1865 suggest.setNumberVoteRequired( nNumberVoteRequired );
1866 }
1867 else
1868 {
1869 suggest.setActiveSuggestPropositionState( false );
1870 suggest.setNumberVoteRequired( -1 );
1871 }
1872
1873 suggest.setNumberDayRequired( nNumberDayRequired );
1874 suggest.setActiveSuggestSubmitAuthentification( strActiveSuggestSubmitAuthentification != null );
1875 suggest.setActiveVoteAuthentification( strActiveVoteAuthentification != null );
1876 suggest.setActiveCommentAuthentification( strActiveCommentAuthentification != null );
1877 suggest.setActiveCaptcha( strActiveCaptcha != null );
1878 suggest.setDisableNewSuggestSubmit( strDisableNewSuggestSubmit != null );
1879 suggest.setEnableMailNewSuggestSubmit( strEnableMailNewSuggestSubmit != null );
1880 suggest.setEnableMailNewCommentSubmit( strEnableMailNewCommentSubmit != null );
1881 suggest.setEnableMailNewReportedSubmit( strEnableMailNewReportedSubmit != null );
1882 suggest.setIdMailingListSuggestSubmit( nIdMailingListSuggestSubmit );
1883 suggest.setAuthorizedComment( strAuthorizedComment != null );
1884 suggest.setDisableNewComment( strDisableNewComment != null );
1885 suggest.setActiveEditorBbcode( strActiveEditorBbcode != null );
1886 suggest.setLimitNumberVote( strLimitNumberVote != null );
1887 suggest.setShowCategoryBlock( strShowCategoryBlock != null );
1888 suggest.setShowTopScoreBlock( strShowTopScoreBlock != null );
1889 suggest.setShowTopCommentBlock( strShowTopCommentBlock != null );
1890 suggest.setActiveSuggestSubmitPaginator( strActiveSuggestSubmitPaginator != null );
1891
1892 if ( strThemeXpage != null )
1893 {
1894 suggest.setCodeTheme( strThemeXpage );
1895 }
1896
1897 suggest.setLibelleValidateButton( strLibelleValidateButton );
1898 suggest.setNumberSuggestSubmitInTopScore( nNumberSuggestSubmitInTopScore );
1899 suggest.setNumberSuggestSubmitInTopComment( nNumberSuggestSubmitInTopComment );
1900 suggest.setNumberSuggestSubmitCaractersShown( nNumberSuggestSubmitCaractersShown );
1901 suggest.setNumberSuggestSubmitPerPage( nNumberSuggestSubmitPerPage );
1902 if ( strDefaultRole != null && !strRole.equals( strDefaultRole ) )
1903 {
1904 suggest.setRole( strRole );
1905 }
1906 else
1907 {
1908 suggest.setRole( null );
1909 }
1910 suggest.setHeader( strHeader );
1911 suggest.setConfirmationMessage( strConfirmationMessage );
1912 suggest.setIdDefaultSort( nIdDefaultSort );
1913 suggest.setDisableVote( strDisableVote != null );
1914 suggest.setDisplayCommentInSuggestSubmitList( strDisplayCommentInSuggestSubmitList != null );
1915 suggest.setNumberCommentDisplayInSuggestSubmitList( nNumberCommentDisplayInSuggestSubmitList );
1916 suggest.setNumberCharCommentDisplayInSuggestSubmitList( nNumberCharCommentDisplayInSuggestSubmitList );
1917 suggest.setEnableReports( strEnableReports != null );
1918 suggest.setEnableTermsOfUse( strEnableTermsOfUse != null );
1919 suggest.setTermsOfUse( strTermsOfUse );
1920 suggest.setDescription( strDescription );
1921 suggest.setNotificationNewCommentSenderName( strNotificationNewCommentSenderName );
1922 suggest.setNotificationNewCommentTitle( strNotificationNewCommentTitle );
1923 suggest.setNotificationNewCommentBody( strNotificationNewCommentBody );
1924 suggest.setNotificationNewSuggestSubmitSenderName( strNotificationNewSuggestSubmitSenderName );
1925 suggest.setNotificationNewSuggestSubmitTitle( strNotificationNewSuggestSubmitTitle );
1926 suggest.setNotificationNewSuggestSubmitBody( strNotificationNewSuggestSubmitBody );
1927
1928
1929 suggest.setIdWorkflow( nIdWorkflow );
1930
1931 if ( ( suggest.getIdSuggest( ) == SuggestUtils.CONSTANT_ID_NULL ) || ( strUpdateFile != null ) )
1932 {
1933 FileItem imageSource = request.getFile( PARAMETER_IMAGE_SOURCE );
1934 String strImageName = FileUploadService.getFileNameOnly( imageSource );
1935
1936 ImageResource image = new ImageResource( );
1937 byte [ ] baImageSource = imageSource.get( );
1938
1939 if ( ( strImageName != null ) && !strImageName.equals( "" ) )
1940 {
1941 image.setImage( baImageSource );
1942 image.setMimeType( imageSource.getContentType( ) );
1943 }
1944
1945 suggest.setImage( image );
1946 }
1947
1948 return null;
1949 }
1950
1951
1952
1953
1954
1955
1956
1957
1958 public String getCreateSuggest( HttpServletRequest request )
1959 {
1960 if ( !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, SuggestResourceIdService.PERMISSION_CREATE, getUser( ) ) )
1961 {
1962 return getManageSuggest( request );
1963 }
1964
1965 Plugin plugin = getPlugin( );
1966 AdminUser adminUser = getUser( );
1967 Locale locale = getLocale( );
1968 ReferenceList refListWorkGroups;
1969 ReferenceList refMailingList;
1970 refListWorkGroups = AdminWorkgroupService.getUserWorkgroups( adminUser, locale );
1971 refMailingList = new ReferenceList( );
1972
1973 String strNothing = I18nService.getLocalizedString( PROPERTY_NOTHING, locale );
1974 refMailingList.addItem( -1, strNothing );
1975 refMailingList.addAll( AdminMailingListService.getMailingLists( adminUser ) );
1976
1977
1978 String defaultTheme = ThemesService.getGlobalTheme( );
1979 Collection<Theme> themes = ThemesService.getThemesList( );
1980 ReferenceList themesRefList = new ReferenceList( );
1981
1982 for ( Theme theme : themes )
1983 {
1984 themesRefList.addItem( theme.getCodeTheme( ), theme.getThemeDescription( ) );
1985 }
1986
1987 ReferenceList refListSuggestSort = SuggestUtils.getRefListSuggestSort( locale );
1988 ReferenceList refVoteTypeList = initRefListVoteType( plugin, locale );
1989 DefaultMessage defaultMessage = DefaultMessageHome.find( plugin );
1990 Map<String, Object> model = new HashMap<>( );
1991
1992
1993 if ( WorkflowService.getInstance( ).isAvailable( ) )
1994 {
1995 ReferenceList referenceList = WorkflowService.getInstance( ).getWorkflowsEnabled( (User) adminUser, getLocale( ) );
1996 model.put( MARK_WORKFLOW_REF_LIST, referenceList );
1997 }
1998 model.put( MARK_USER_WORKGROUP_REF_LIST, refListWorkGroups );
1999 model.put( MARK_MAILING_REF_LIST, refMailingList );
2000 model.put( MARK_DEFAULT_MESSAGE, defaultMessage );
2001 model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
2002 model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) );
2003 model.put( MARK_IS_ACTIVE_CAPTCHA, PluginService.isPluginEnable( JCAPTCHA_PLUGIN ) );
2004 model.put( MARK_YES_VALUE, CONSTANTE_YES_VALUE );
2005 model.put( MARK_NO_VALUE, CONSTANTE_NO_VALUE );
2006 model.put( MARK_VOTE_TYPE_LIST, refVoteTypeList );
2007 model.put( MARK_AUTHENTIFICATION_ENABLE, SecurityService.isAuthenticationEnable( ) );
2008 model.put( MARK_ROLE_LIST, RoleHome.getRolesList( ) );
2009 model.put( MARK_DEFAULT_VALUE_ROLE, Suggest.ROLE_NONE );
2010 model.put( MARK_THEME_REF_LIST, themesRefList );
2011 model.put( MARK_DEFAULT_THEME, defaultTheme );
2012 model.put( MARK_LIST_SUGGEST_SUBMIT_SORT, refListSuggestSort );
2013
2014 setPageTitleProperty( PROPERTY_CREATE_SUGGEST_TITLE );
2015
2016 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_CREATE_SUGGEST, locale, model );
2017
2018 return getAdminPage( template.getHtml( ) );
2019 }
2020
2021
2022
2023
2024
2025
2026
2027
2028 public String doCreateSuggest( HttpServletRequest request )
2029 {
2030 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
2031
2032 if ( ( multipartRequest.getParameter( PARAMETER_CANCEL ) == null )
2033 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, SuggestResourceIdService.PERMISSION_CREATE, getUser( ) ) )
2034 {
2035 Plugin plugin = getPlugin( );
2036 Suggestsuggest/business/Suggest.html#Suggest">Suggest suggest = new Suggest( );
2037 String strError = getSuggestData( multipartRequest, suggest );
2038
2039 if ( strError != null )
2040 {
2041 return strError;
2042 }
2043
2044 suggest.setIdSuggest( SuggestHome.create( suggest, plugin ) );
2045
2046 if ( request.getParameter( PARAMETER_APPLY ) != null )
2047 {
2048 return getJspModifySuggest( request, suggest.getIdSuggest( ) );
2049 }
2050
2051 }
2052
2053 return getJspManageSuggest( request );
2054 }
2055
2056
2057
2058
2059
2060
2061
2062
2063 public String getModifySuggest( HttpServletRequest request )
2064 {
2065 Plugin plugin = getPlugin( );
2066 List<IEntry> listEntry;
2067 int nNumberQuestion;
2068 EntryFilter filter;
2069 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
2070 int nIdSuggest = -1;
2071 int nIdEntryFistInTheList = -1;
2072 int nIdEntryLastInTheList = -1;
2073 Suggest suggest = null;
2074 String strPanel = request.getParameter( PARAMETER_PANEL );
2075
2076 if ( ( strIdSuggest != null ) && !strIdSuggest.equals( EMPTY_STRING ) )
2077 {
2078 nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
2079 suggest = SuggestHome.findByPrimaryKey( nIdSuggest, plugin );
2080 }
2081
2082 if ( ( suggest == null )
2083 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2084 {
2085 return getManageSuggest( request );
2086 }
2087
2088
2089 _nIdSuggest = nIdSuggest;
2090 filter = new EntryFilter( );
2091 filter.setIdSuggest( suggest.getIdSuggest( ) );
2092 listEntry = EntryHome.getEntryList( filter, plugin );
2093
2094 if ( listEntry.size( ) > 0 )
2095 {
2096 nIdEntryFistInTheList = listEntry.get( 0 ).getIdEntry( );
2097 nIdEntryLastInTheList = listEntry.get( listEntry.size( ) - 1 ).getIdEntry( );
2098 }
2099
2100 nNumberQuestion = EntryHome.getNumberEntryByFilter( filter, plugin );
2101
2102 _strCurrentPageIndexEntry = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndexEntry );
2103 _nItemsPerPageEntry = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPageEntry, _nDefaultItemsPerPage );
2104
2105 Paginator<IEntry> paginator = new Paginator<IEntry>( listEntry, _nItemsPerPageEntry, AppPathService.getBaseUrl( request ) + JSP_MODIFY_SUGGEST
2106 + "?id_suggest=" + suggest.getIdSuggest( ), PARAMETER_PAGE_INDEX, _strCurrentPageIndexEntry );
2107
2108 AdminUser adminUser = getUser( );
2109
2110 Locale locale = getLocale( );
2111 ReferenceList refListWorkGroups;
2112 ReferenceList refMailingList;
2113 ReferenceList refEntryType;
2114
2115 refListWorkGroups = AdminWorkgroupService.getUserWorkgroups( adminUser, locale );
2116
2117 refMailingList = new ReferenceList( );
2118
2119 String strNothing = I18nService.getLocalizedString( PROPERTY_NOTHING, locale );
2120 refMailingList.addItem( -1, strNothing );
2121 refMailingList.addAll( AdminMailingListService.getMailingLists( adminUser ) );
2122
2123 List<Category> listCategoriesView = CategoryHome.getList( plugin );
2124 List<SuggestSubmitType> listSuggestSubmitTypeView = SuggestSubmitTypeHome.getList( plugin );
2125
2126 listCategoriesView.removeAll( suggest.getCategories( ) );
2127 listSuggestSubmitTypeView.removeAll( suggest.getSuggestSubmitTypes( ) );
2128
2129 ReferenceList refCategoryList = SuggestUtils.getRefListCategory( listCategoriesView );
2130 ReferenceList refVoteTypeList = initRefListVoteType( plugin, locale );
2131 ReferenceList refListSuggestSort = SuggestUtils.getRefListSuggestSort( locale );
2132 ReferenceList refListSuggestSubmitType = SuggestUtils.getRefListType( listSuggestSubmitTypeView );
2133
2134 EntryTypeusiness/EntryType.html#EntryType">EntryType entryTypeGroup = new EntryType( );
2135 refEntryType = initRefListEntryType( plugin, locale );
2136
2137
2138 Collection<Theme> themes = ThemesService.getThemesList( );
2139 ReferenceList themesRefList = new ReferenceList( );
2140
2141 for ( Theme theme : themes )
2142 {
2143 themesRefList.addItem( theme.getCodeTheme( ), theme.getThemeDescription( ) );
2144 }
2145
2146 if ( suggest.getCodeTheme( ) == null )
2147 {
2148 suggest.setCodeTheme( ThemesService.getGlobalTheme( ) );
2149 }
2150
2151 Map<String, Object> model = new HashMap<>( );
2152
2153
2154 if ( WorkflowService.getInstance( ).isAvailable( ) )
2155 {
2156 ReferenceList referenceList = WorkflowService.getInstance( ).getWorkflowsEnabled( (User) adminUser, getLocale( ) );
2157 model.put( MARK_WORKFLOW_REF_LIST, referenceList );
2158 }
2159 model.put( MARK_PAGINATOR, paginator );
2160 model.put( MARK_NB_ITEMS_PER_PAGE, EMPTY_STRING + _nItemsPerPageEntry );
2161 model.put( MARK_USER_WORKGROUP_REF_LIST, refListWorkGroups );
2162 model.put( MARK_MAILING_REF_LIST, refMailingList );
2163 model.put( MARK_ENTRY_TYPE_REF_LIST, refEntryType );
2164 model.put( MARK_ENTRY_TYPE_GROUP, entryTypeGroup );
2165 model.put( MARK_SUGGEST, suggest );
2166 model.put( MARK_ENTRY_LIST, paginator.getPageItems( ) );
2167 model.put( MARK_NUMBER_QUESTION, nNumberQuestion );
2168 model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
2169 model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) );
2170 model.put( MARK_IS_ACTIVE_CAPTCHA, PluginService.isPluginEnable( JCAPTCHA_PLUGIN ) );
2171 model.put( MARK_YES_VALUE, CONSTANTE_YES_VALUE );
2172 model.put( MARK_NO_VALUE, CONSTANTE_NO_VALUE );
2173 model.put( MARK_CATEGORY_LIST, refCategoryList );
2174 model.put( MARK_VOTE_TYPE_LIST, refVoteTypeList );
2175 model.put( MARK_SUGGEST_SUBMIT_TYPE_LIST, refListSuggestSubmitType );
2176 model.put( MARK_ID_ENTRY_FIRST_IN_THE_LIST, nIdEntryFistInTheList );
2177 model.put( MARK_ID_ENTRY_LAST_IN_THE_LIST, nIdEntryLastInTheList );
2178 model.put( MARK_AUTHENTIFICATION_ENABLE, SecurityService.isAuthenticationEnable( ) );
2179 model.put( MARK_ROLE_LIST, RoleHome.getRolesList( ) );
2180 model.put( MARK_DEFAULT_VALUE_ROLE, Suggest.ROLE_NONE );
2181 model.put( MARK_THEME_REF_LIST, themesRefList );
2182 model.put( MARK_LIST_SUGGEST_SUBMIT_SORT, refListSuggestSort );
2183 model.put( MARK_PANEL, strPanel );
2184 setPageTitleProperty( PROPERTY_MODIFY_SUGGEST_TITLE );
2185
2186 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_SUGGEST, locale, model );
2187
2188 return getAdminPage( template.getHtml( ) );
2189 }
2190
2191
2192
2193
2194
2195
2196
2197
2198 public String doModifySuggest( HttpServletRequest request )
2199 {
2200 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
2201 String strIdSuggest = multipartRequest.getParameter( PARAMETER_ID_SUGGEST );
2202 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
2203
2204 if ( ( multipartRequest.getParameter( PARAMETER_CANCEL ) == null ) && ( nIdSuggest != -1 )
2205 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2206 {
2207 Plugin plugin = getPlugin( );
2208 Suggest suggest = SuggestHome.findByPrimaryKey( nIdSuggest, plugin );
2209 String strError = getSuggestData( multipartRequest, suggest );
2210
2211 if ( strError != null )
2212 {
2213 return strError;
2214 }
2215
2216 SuggestHome.update( suggest, plugin );
2217
2218 if ( request.getParameter( PARAMETER_APPLY ) != null )
2219 {
2220 String strPanel = request.getParameter( PARAMETER_PANEL );
2221
2222 return getJspModifySuggest( request, suggest.getIdSuggest( ), strPanel );
2223 }
2224 }
2225
2226 return getJspManageSuggest( request );
2227 }
2228
2229
2230
2231
2232
2233
2234
2235
2236 public String doInsertSuggestSubmitType( HttpServletRequest request )
2237 {
2238 Plugin plugin = getPlugin( );
2239 Suggest suggest;
2240 String strIdSuggestSubmitType = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT_TYPE );
2241 int nISuggestSubmitType = SuggestUtils.getIntegerParameter( strIdSuggestSubmitType );
2242 SuggestSubmitType suggestSubmitType = SuggestSubmitTypeHome.findByPrimaryKey( nISuggestSubmitType, plugin );
2243
2244 suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2245
2246 if ( ( suggestSubmitType != null ) && ( suggest != null ) && ( suggest.getSuggestSubmitTypes( ) != null )
2247 && !suggest.getSuggestSubmitTypes( ).contains( suggestSubmitType )
2248 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2249 {
2250 SuggestSubmitTypeHome.createSuggestAssociation( _nIdSuggest, nISuggestSubmitType, plugin );
2251 }
2252
2253 if ( _nIdSuggest != -1 )
2254 {
2255 return getJspModifySuggest( request, _nIdSuggest );
2256 }
2257
2258 return getJspManageSuggest( request );
2259 }
2260
2261
2262
2263
2264
2265
2266
2267
2268 public String doRemoveSuggestSubmitType( HttpServletRequest request )
2269 {
2270 Plugin plugin = getPlugin( );
2271 Suggest suggest;
2272 String strIdSuggestSubmitType = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT_TYPE );
2273 int nISuggestSubmitType = SuggestUtils.getIntegerParameter( strIdSuggestSubmitType );
2274 SuggestSubmitType suggestSubmitType = SuggestSubmitTypeHome.findByPrimaryKey( nISuggestSubmitType, plugin );
2275
2276 suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2277
2278 if ( ( suggestSubmitType != null ) && ( suggest != null )
2279 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2280 {
2281 SuggestSubmitTypeHome.removeSuggestAssociation( _nIdSuggest, nISuggestSubmitType, plugin );
2282 }
2283
2284 if ( _nIdSuggest != -1 )
2285 {
2286 return getJspModifySuggest( request, _nIdSuggest );
2287 }
2288
2289 return getJspManageSuggest( request );
2290 }
2291
2292
2293
2294
2295
2296
2297
2298
2299 public String doInsertCategory( HttpServletRequest request )
2300 {
2301 Plugin plugin = getPlugin( );
2302 Category category;
2303 Suggest suggest;
2304 String strCategory = request.getParameter( PARAMETER_ID_CATEGORY );
2305 int nIdCategory = SuggestUtils.getIntegerParameter( strCategory );
2306 category = CategoryHome.findByPrimaryKey( nIdCategory, plugin );
2307
2308 suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2309
2310 if ( ( category != null ) && ( suggest != null ) && ( suggest.getCategories( ) != null ) && !suggest.getCategories( ).contains( category )
2311 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2312 {
2313 CategoryHome.createSuggestAssociation( _nIdSuggest, nIdCategory, plugin );
2314 }
2315
2316 if ( _nIdSuggest != -1 )
2317 {
2318 return getJspModifySuggest( request, _nIdSuggest );
2319 }
2320
2321 return getJspManageSuggest( request );
2322 }
2323
2324
2325
2326
2327
2328
2329
2330
2331 public String doRemoveCategory( HttpServletRequest request )
2332 {
2333 Plugin plugin = getPlugin( );
2334 Category category;
2335 Suggest suggest;
2336 String strCategory = request.getParameter( PARAMETER_ID_CATEGORY );
2337 int nIdCategory = SuggestUtils.getIntegerParameter( strCategory );
2338 category = CategoryHome.findByPrimaryKey( nIdCategory, plugin );
2339 suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2340
2341 if ( ( category != null ) && ( suggest != null ) && ( suggest.getCategories( ) != null )
2342 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2343 {
2344 CategoryHome.removeSuggestAssociation( _nIdSuggest, nIdCategory, plugin );
2345 }
2346
2347 if ( _nIdSuggest != -1 )
2348 {
2349 return getJspModifySuggest( request, _nIdSuggest );
2350 }
2351
2352 return getJspManageSuggest( request );
2353 }
2354
2355
2356
2357
2358
2359
2360
2361
2362 public String getConfirmRemoveSuggest( HttpServletRequest request )
2363 {
2364 Plugin plugin = getPlugin( );
2365 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
2366 String strMessage;
2367 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
2368
2369 if ( ( nIdSuggest == -1 )
2370 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_DELETE, getUser( ) ) )
2371 {
2372 return getJspManageSuggest( request );
2373 }
2374
2375 SubmitFilterness/SubmitFilter.html#SubmitFilter">SubmitFilter responseFilter = new SubmitFilter( );
2376 responseFilter.setIdSuggest( nIdSuggest );
2377
2378 int nNumbersuggestSubmit = _suggestSubmitService.getCountSuggestSubmit( responseFilter, plugin );
2379
2380 if ( nNumbersuggestSubmit == 0 )
2381 {
2382 strMessage = MESSAGE_CONFIRM_REMOVE_SUGGEST;
2383 }
2384 else
2385 {
2386 strMessage = MESSAGE_CONFIRM_REMOVE_SUGGEST_WITH_SUGGEST_SUBMIT;
2387 }
2388
2389 UrlItem url = new UrlItem( JSP_DO_REMOVE_SUGGEST );
2390 url.addParameter( PARAMETER_ID_SUGGEST, strIdSuggest );
2391
2392 return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
2393 }
2394
2395
2396
2397
2398
2399
2400
2401
2402 public String doRemoveSuggest( HttpServletRequest request )
2403 {
2404 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
2405 Plugin plugin = getPlugin( );
2406 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
2407
2408 if ( ( nIdSuggest != -1 )
2409 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_DELETE, getUser( ) ) )
2410 {
2411
2412 SuggestService.removeSuggest( nIdSuggest, getUser( ) );
2413 }
2414
2415 return getJspManageSuggest( request );
2416 }
2417
2418
2419
2420
2421
2422
2423
2424
2425 public String doCopySuggest( HttpServletRequest request )
2426 {
2427 Plugin plugin = getPlugin( );
2428 Suggest suggest;
2429 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
2430 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
2431
2432 if ( ( nIdSuggest == -1 )
2433 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_COPY, getUser( ) ) )
2434 {
2435 return getJspManageSuggest( request );
2436 }
2437
2438 suggest = SuggestHome.findByPrimaryKey( nIdSuggest, plugin );
2439
2440 Object [ ] tabSuggestTileCopy = {
2441 suggest.getTitle( )
2442 };
2443 String strTitleCopySuggest = I18nService.getLocalizedString( PROPERTY_COPY_SUGGEST_TITLE, tabSuggestTileCopy, getLocale( ) );
2444
2445 if ( strTitleCopySuggest != null )
2446 {
2447 suggest.setTitle( strTitleCopySuggest );
2448 }
2449
2450 SuggestHome.copy( suggest, plugin );
2451
2452 return getJspManageSuggest( request );
2453 }
2454
2455
2456
2457
2458
2459
2460
2461
2462 public String getCreateEntry( HttpServletRequest request )
2463 {
2464 Plugin plugin = getPlugin( );
2465 IEntry entry;
2466 Suggest suggest;
2467
2468 entry = SuggestUtils.createEntryByType( request, plugin );
2469 suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2470
2471 if ( ( entry == null ) || ( suggest == null )
2472 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2473 {
2474 return getManageSuggest( request );
2475 }
2476
2477 entry.setSuggest( suggest );
2478
2479 Map<String, Object> model = new HashMap<>( );
2480 model.put( MARK_ENTRY, entry );
2481 model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
2482 model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) );
2483 setPageTitleProperty( PROPERTY_CREATE_QUESTION_TITLE );
2484
2485 HtmlTemplate template = AppTemplateService.getTemplate( entry.getTemplateCreate( ), getLocale( ), model );
2486
2487 return getAdminPage( template.getHtml( ) );
2488 }
2489
2490
2491
2492
2493
2494
2495
2496
2497 public String doCreateEntry( HttpServletRequest request )
2498 {
2499 Plugin plugin = getPlugin( );
2500 IEntry entry;
2501
2502 if ( request.getParameter( PARAMETER_CANCEL ) == null )
2503 {
2504 entry = SuggestUtils.createEntryByType( request, plugin );
2505
2506 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2507
2508 if ( ( entry == null ) || ( suggest == null )
2509 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2510 {
2511 return getJspManageSuggest( request );
2512 }
2513
2514 String strError = entry.getRequestData( request, getLocale( ) );
2515
2516 if ( strError != null )
2517 {
2518 return strError;
2519 }
2520
2521 entry.setSuggest( suggest );
2522 entry.setIdEntry( EntryHome.create( entry, plugin ) );
2523
2524 if ( request.getParameter( PARAMETER_APPLY ) != null )
2525 {
2526 return getJspModifyEntry( request, entry.getIdEntry( ) );
2527 }
2528 }
2529
2530 return getJspModifySuggest( request, _nIdSuggest );
2531 }
2532
2533
2534
2535
2536
2537
2538
2539
2540 public String getModifyEntry( HttpServletRequest request )
2541 {
2542 Plugin plugin = getPlugin( );
2543 IEntry entry;
2544 ReferenceList refListRegularExpression;
2545 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
2546 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
2547 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2548 entry = EntryHome.findByPrimaryKey( nIdEntry, plugin );
2549 List<EntryAdditionalAttribute> entryAdditionalAttributeList = EntryAdditionalAttributeHome.getList( nIdEntry, plugin );
2550
2551 if ( ( entry == null ) || ( suggest == null )
2552 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2553 {
2554 return getManageSuggest( request );
2555 }
2556
2557 Map<String, Object> model = new HashMap<>( );
2558
2559 for ( EntryAdditionalAttribute entryAdditionalAttribute : entryAdditionalAttributeList )
2560 {
2561 model.put( entryAdditionalAttribute.getName( ), entryAdditionalAttribute.getValue( ) );
2562 }
2563
2564 model.put( MARK_ENTRY, entry );
2565 _strCurrentPageIndex = Paginator.getPageIndex( request, Paginator.PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
2566 _nItemsPerPage = Paginator.getItemsPerPage( request, Paginator.PARAMETER_ITEMS_PER_PAGE, _nItemsPerPage, _nDefaultItemsPerPage );
2567
2568 Paginator paginator = entry.getPaginator( _nItemsPerPage, AppPathService.getBaseUrl( request ) + JSP_MODIFY_ENTRY + "?id_entry=" + nIdEntry,
2569 PARAMETER_PAGE_INDEX, _strCurrentPageIndex );
2570
2571 if ( paginator != null )
2572 {
2573 model.put( MARK_NB_ITEMS_PER_PAGE, EMPTY_STRING + _nItemsPerPage );
2574 model.put( MARK_NUMBER_ITEMS, paginator.getItemsCount( ) );
2575 model.put( MARK_LIST, paginator.getPageItems( ) );
2576 model.put( MARK_PAGINATOR, paginator );
2577 }
2578
2579 refListRegularExpression = entry.getReferenceListRegularExpression( entry, plugin );
2580
2581 if ( refListRegularExpression != null )
2582 {
2583 model.put( MARK_REGULAR_EXPRESSION_LIST_REF_LIST, refListRegularExpression );
2584 }
2585
2586 model.put( MARK_WEBAPP_URL, AppPathService.getBaseUrl( request ) );
2587 model.put( MARK_LOCALE, AdminUserService.getLocale( request ).getLanguage( ) );
2588 setPageTitleProperty( PROPERTY_MODIFY_QUESTION_TITLE );
2589
2590 HtmlTemplate template = AppTemplateService.getTemplate( entry.getTemplateModify( ), getLocale( ), model );
2591
2592 return getAdminPage( template.getHtml( ) );
2593 }
2594
2595
2596
2597
2598
2599
2600
2601
2602 public String doModifyEntry( HttpServletRequest request )
2603 {
2604 Plugin plugin = getPlugin( );
2605 IEntry entry;
2606 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
2607 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
2608
2609 entry = EntryHome.findByPrimaryKey( nIdEntry, plugin );
2610
2611 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2612
2613 if ( ( entry == null ) || ( suggest == null )
2614 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2615 {
2616 return getJspManageSuggest( request );
2617 }
2618
2619 if ( request.getParameter( PARAMETER_CANCEL ) == null )
2620 {
2621 String strError = entry.getRequestData( request, getLocale( ) );
2622
2623 if ( strError != null )
2624 {
2625 return strError;
2626 }
2627
2628 EntryHome.update( entry, plugin );
2629 }
2630
2631 if ( request.getParameter( PARAMETER_APPLY ) != null )
2632 {
2633 return getJspModifyEntry( request, nIdEntry );
2634 }
2635
2636 return getJspModifySuggest( request, suggest.getIdSuggest( ) );
2637 }
2638
2639
2640
2641
2642
2643
2644
2645
2646 public String getConfirmRemoveEntry( HttpServletRequest request )
2647 {
2648 String strMessage;
2649 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
2650 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
2651
2652 if ( nIdEntry == -1 )
2653 {
2654 return getHomeUrl( request );
2655 }
2656
2657 strMessage = MESSAGE_CONFIRM_REMOVE_ENTRY;
2658
2659 UrlItem url = new UrlItem( JSP_DO_REMOVE_ENTRY );
2660 url.addParameter( PARAMETER_ID_ENTRY, strIdEntry + "#list" );
2661
2662 return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
2663 }
2664
2665
2666
2667
2668
2669
2670
2671
2672 public String doRemoveEntry( HttpServletRequest request )
2673 {
2674 Plugin plugin = getPlugin( );
2675 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
2676 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
2677 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2678
2679 if ( ( nIdEntry == -1 ) || ( suggest == null )
2680 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2681 {
2682 return getJspManageSuggest( request );
2683 }
2684
2685 EntryHome.remove( nIdEntry, plugin );
2686
2687 return getJspModifySuggest( request, suggest.getIdSuggest( ) );
2688 }
2689
2690
2691
2692
2693
2694
2695
2696
2697 public String doCopyEntry( HttpServletRequest request )
2698 {
2699 Plugin plugin = getPlugin( );
2700 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
2701 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
2702 IEntry entry;
2703 entry = EntryHome.findByPrimaryKey( nIdEntry, plugin );
2704
2705 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2706
2707 if ( ( entry == null ) || ( suggest == null )
2708 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2709 {
2710 return getJspManageSuggest( request );
2711 }
2712
2713 Object [ ] tabEntryTileCopy = {
2714 entry.getTitle( )
2715 };
2716 String strTitleCopyEntry = I18nService.getLocalizedString( PROPERTY_COPY_ENTRY_TITLE, tabEntryTileCopy, getLocale( ) );
2717
2718 if ( strTitleCopyEntry != null )
2719 {
2720 entry.setTitle( strTitleCopyEntry );
2721 }
2722
2723 EntryHome.copy( entry, plugin );
2724
2725 return getJspModifySuggest( request, suggest.getIdSuggest( ) );
2726 }
2727
2728
2729
2730
2731
2732
2733
2734
2735 public String doMoveUpEntry( HttpServletRequest request )
2736 {
2737 Plugin plugin = getPlugin( );
2738 IEntry entry;
2739 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
2740 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
2741
2742 entry = EntryHome.findByPrimaryKey( nIdEntry, plugin );
2743
2744 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2745
2746 if ( ( entry == null ) || ( suggest == null )
2747 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2748 {
2749 return getJspManageSuggest( request );
2750 }
2751
2752 List<IEntry> listEntry;
2753 EntryFiltergest/business/EntryFilter.html#EntryFilter">EntryFilter filter = new EntryFilter( );
2754 filter.setIdSuggest( entry.getSuggest( ).getIdSuggest( ) );
2755 listEntry = EntryHome.getEntryList( filter, plugin );
2756
2757 int nIndexEntry = SuggestUtils.getIndexEntryInTheEntryList( nIdEntry, listEntry );
2758
2759 if ( nIndexEntry != 0 )
2760 {
2761 int nNewPosition;
2762 IEntry entryToInversePosition;
2763 entryToInversePosition = listEntry.get( nIndexEntry - 1 );
2764 entryToInversePosition = EntryHome.findByPrimaryKey( entryToInversePosition.getIdEntry( ), plugin );
2765 nNewPosition = entryToInversePosition.getPosition( );
2766 entryToInversePosition.setPosition( entry.getPosition( ) );
2767 entry.setPosition( nNewPosition );
2768 EntryHome.update( entry, plugin );
2769 EntryHome.update( entryToInversePosition, plugin );
2770 }
2771
2772 return getJspModifySuggest( request, suggest.getIdSuggest( ) );
2773 }
2774
2775
2776
2777
2778
2779
2780
2781
2782 public String doMoveDownEntry( HttpServletRequest request )
2783 {
2784 Plugin plugin = getPlugin( );
2785 IEntry entry;
2786
2787 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
2788 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
2789
2790 entry = EntryHome.findByPrimaryKey( nIdEntry, plugin );
2791
2792 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
2793
2794 if ( ( entry == null ) || ( suggest == null )
2795 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + _nIdSuggest, SuggestResourceIdService.PERMISSION_MODIFY, getUser( ) ) )
2796 {
2797 return getJspManageSuggest( request );
2798 }
2799
2800 List<IEntry> listEntry;
2801 EntryFiltergest/business/EntryFilter.html#EntryFilter">EntryFilter filter = new EntryFilter( );
2802 filter.setIdSuggest( entry.getSuggest( ).getIdSuggest( ) );
2803 listEntry = EntryHome.getEntryList( filter, plugin );
2804
2805 int nIndexEntry = SuggestUtils.getIndexEntryInTheEntryList( nIdEntry, listEntry );
2806
2807 if ( nIndexEntry != ( listEntry.size( ) - 1 ) )
2808 {
2809 int nNewPosition;
2810 IEntry entryToInversePosition;
2811 entryToInversePosition = listEntry.get( nIndexEntry + 1 );
2812 entryToInversePosition = EntryHome.findByPrimaryKey( entryToInversePosition.getIdEntry( ), plugin );
2813 nNewPosition = entryToInversePosition.getPosition( );
2814 entryToInversePosition.setPosition( entry.getPosition( ) );
2815 entry.setPosition( nNewPosition );
2816 EntryHome.update( entry, plugin );
2817 EntryHome.update( entryToInversePosition, plugin );
2818 }
2819
2820 return getJspModifySuggest( request, suggest.getIdSuggest( ) );
2821 }
2822
2823
2824
2825
2826
2827
2828
2829
2830 public String getConfirmDisableSuggest( HttpServletRequest request )
2831 {
2832 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
2833 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
2834
2835 if ( nIdSuggest == -1 )
2836 {
2837 return getHomeUrl( request );
2838 }
2839
2840 String strMessage;
2841 strMessage = MESSAGE_CONFIRM_DISABLE_SUGGEST;
2842
2843 UrlItem url = new UrlItem( JSP_DO_DISABLE_SUGGEST );
2844 url.addParameter( PARAMETER_ID_SUGGEST, strIdSuggest );
2845
2846 return AdminMessageService.getMessageUrl( request, strMessage, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
2847 }
2848
2849
2850
2851
2852
2853
2854
2855
2856 public String doDisableSuggest( HttpServletRequest request )
2857 {
2858 Suggest suggest;
2859 Plugin plugin = getPlugin( );
2860 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
2861 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
2862 suggest = SuggestHome.findByPrimaryKey( nIdSuggest, plugin );
2863
2864 if ( ( suggest != null )
2865 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_CHANGE_STATE, getUser( ) ) )
2866 {
2867 suggest.setActive( false );
2868 SuggestHome.update( suggest, getPlugin( ) );
2869
2870 if ( suggest.getSuggestsSubmit( ) != null )
2871 {
2872 for ( SuggestSubmit submit : suggest.getSuggestsSubmit( ) )
2873 {
2874 String strIdSuggestSubmit = Integer.toString( submit.getIdSuggestSubmit( ) );
2875 IndexationService.addIndexerAction( strIdSuggestSubmit + "_" + SuggestIndexer.SHORT_NAME,
2876 AppPropertiesService.getProperty( SuggestIndexer.PROPERTY_INDEXER_NAME ), IndexerAction.TASK_DELETE );
2877
2878 SuggestIndexerUtils.addIndexerAction( strIdSuggestSubmit, IndexerAction.TASK_DELETE );
2879 }
2880 }
2881 }
2882
2883 return getJspManageSuggest( request );
2884 }
2885
2886
2887
2888
2889
2890
2891
2892
2893 public String doEnableSuggest( HttpServletRequest request )
2894 {
2895 Suggest suggest;
2896 Plugin plugin = getPlugin( );
2897 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
2898 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
2899 suggest = SuggestHome.findByPrimaryKey( nIdSuggest, plugin );
2900
2901 if ( ( suggest != null )
2902 && RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_CHANGE_STATE, getUser( ) ) )
2903 {
2904 suggest.setActive( true );
2905 SuggestHome.update( suggest, getPlugin( ) );
2906
2907 if ( suggest.getSuggestsSubmit( ) != null )
2908 {
2909 for ( SuggestSubmit submit : suggest.getSuggestsSubmit( ) )
2910 {
2911 String strIdSuggestSubmit = Integer.toString( submit.getIdSuggestSubmit( ) );
2912 IndexationService.addIndexerAction( strIdSuggestSubmit, AppPropertiesService.getProperty( SuggestIndexer.PROPERTY_INDEXER_NAME ),
2913 IndexerAction.TASK_CREATE );
2914
2915 SuggestIndexerUtils.addIndexerAction( strIdSuggestSubmit, IndexerAction.TASK_CREATE );
2916 }
2917 }
2918 }
2919
2920 return getJspManageSuggest( request );
2921 }
2922
2923
2924
2925
2926
2927
2928
2929
2930 private String getJspManageSuggest( HttpServletRequest request )
2931 {
2932 return AppPathService.getBaseUrl( request ) + JSP_MANAGE_SUGGEST;
2933 }
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954 public static String getJspManageSuggestSubmit( HttpServletRequest request )
2955 {
2956 return AppPathService.getBaseUrl( request ) + JSP_MANAGE_SUGGEST_SUBMIT;
2957 }
2958
2959
2960
2961
2962
2963
2964
2965
2966 public static String getJspManageSuggestSubmitOrder( HttpServletRequest request )
2967 {
2968 return AppPathService.getBaseUrl( request ) + JSP_MANAGE_SUGGEST_SUBMIT_ORDER;
2969 }
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980 private String getJspManageCommentSubmit( HttpServletRequest request, String strIdParentCommentSubmit )
2981 {
2982 String strUrlReturn = ( strIdParentCommentSubmit == null ) ? JSP_MANAGE_COMMENT_SUBMIT
2983 : ( JSP_MANAGE_COMMENT_SUBMIT + "?" + PARAMETER_ID_PARENT + "=" + strIdParentCommentSubmit );
2984
2985 return AppPathService.getBaseUrl( request ) + strUrlReturn;
2986 }
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997 private String getJspManageCommentSubmit( HttpServletRequest request )
2998 {
2999 return getJspManageCommentSubmit( request, null );
3000 }
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011 private String getJspModifySuggest( HttpServletRequest request, int nIdSuggest )
3012 {
3013 return AppPathService.getBaseUrl( request ) + JSP_MODIFY_SUGGEST + "?id_suggest=" + nIdSuggest;
3014 }
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028 private String getJspModifySuggest( HttpServletRequest request, int nIdSuggest, String strPanel )
3029 {
3030 return !StringUtils.isEmpty( strPanel ) ? getJspModifySuggest( request, nIdSuggest ) + "&panel=" + strPanel : getJspModifySuggest( request, nIdSuggest );
3031 }
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042 private String getJspModifyEntry( HttpServletRequest request, int nIdEntry )
3043 {
3044 return AppPathService.getBaseUrl( request ) + JSP_MODIFY_ENTRY + "?id_entry=" + nIdEntry;
3045 }
3046
3047
3048
3049
3050
3051
3052
3053
3054 private String getJspManageAdvancedParameters( HttpServletRequest request )
3055 {
3056 return AppPathService.getBaseUrl( request ) + JSP_MANAGE_ADVANCED_PARAMETERS;
3057 }
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068 private ReferenceList initRefListEntryType( Plugin plugin, Locale locale )
3069 {
3070 ReferenceList refListEntryType = new ReferenceList( );
3071 List<EntryType> listEntryType = EntryTypeHome.getList( plugin );
3072
3073 for ( EntryType entryType : listEntryType )
3074 {
3075 refListEntryType.addItem( entryType.getIdType( ), entryType.getTitle( ) );
3076 }
3077
3078 return refListEntryType;
3079 }
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090 private ReferenceList initRefListVoteType( Plugin plugin, Locale locale )
3091 {
3092 ReferenceList refListVoteType = new ReferenceList( );
3093 List<VoteType> listVoteType = VoteTypeHome.getList( plugin );
3094
3095 for ( VoteType voteType : listVoteType )
3096 {
3097 refListVoteType.addItem( voteType.getIdVoteType( ), voteType.getTitle( ) );
3098 }
3099
3100 return refListVoteType;
3101 }
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112 private ReferenceList initRefListSuggestSubmitState( Plugin plugin, Locale locale )
3113 {
3114 ReferenceList refListSuggestSubmitState = new ReferenceList( );
3115 String strAll = I18nService.getLocalizedString( PROPERTY_ALL, locale );
3116 List<SuggestSubmitState> listSuggestSubmitState = SuggestSubmitStateHome.getList( plugin );
3117 refListSuggestSubmitState.addItem( -1, strAll );
3118
3119 for ( SuggestSubmitState suggestSubmitState : listSuggestSubmitState )
3120 {
3121 refListSuggestSubmitState.addItem( suggestSubmitState.getIdSuggestSubmitState( ), suggestSubmitState.getTitle( ) );
3122 }
3123
3124 return refListSuggestSubmitState;
3125 }
3126
3127
3128
3129
3130
3131
3132
3133
3134 public String doRemoveRegularExpression( HttpServletRequest request )
3135 {
3136 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
3137 String strIdExpression = request.getParameter( PARAMETER_ID_EXPRESSION );
3138
3139 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
3140 int nIdExpression = SuggestUtils.getIntegerParameter( strIdExpression );
3141
3142 if ( ( nIdEntry != -1 ) && ( nIdExpression != -1 ) )
3143 {
3144 EntryHome.deleteVerifyBy( nIdEntry, nIdExpression, getPlugin( ) );
3145 }
3146
3147 if ( nIdEntry != -1 )
3148 {
3149 return getJspModifyEntry( request, nIdEntry );
3150 }
3151
3152 return getHomeUrl( request );
3153 }
3154
3155
3156
3157
3158
3159
3160
3161
3162 public String doInsertRegularExpression( HttpServletRequest request )
3163 {
3164 String strIdEntry = request.getParameter( PARAMETER_ID_ENTRY );
3165 String strIdExpression = request.getParameter( PARAMETER_ID_EXPRESSION );
3166
3167 int nIdEntry = SuggestUtils.getIntegerParameter( strIdEntry );
3168 int nIdExpression = SuggestUtils.getIntegerParameter( strIdExpression );
3169
3170 if ( ( nIdEntry != -1 ) && ( nIdExpression != -1 ) )
3171 {
3172 EntryHome.insertVerifyBy( nIdEntry, nIdExpression, getPlugin( ) );
3173 }
3174
3175 if ( nIdEntry != -1 )
3176 {
3177 return getJspModifyEntry( request, nIdEntry );
3178 }
3179
3180 return getHomeUrl( request );
3181 }
3182
3183
3184
3185
3186
3187
3188
3189
3190 private ReferenceList getRefListSuggestState( Locale locale )
3191 {
3192 ReferenceList refListState = new ReferenceList( );
3193 String strAll = I18nService.getLocalizedString( PROPERTY_ALL, locale );
3194 String strEnable = I18nService.getLocalizedString( PROPERTY_ENABLE, locale );
3195 String strDisable = I18nService.getLocalizedString( PROPERTY_DISABLE, locale );
3196
3197 refListState.addItem( -1, strAll );
3198 refListState.addItem( 1, strEnable );
3199 refListState.addItem( 0, strDisable );
3200
3201 return refListState;
3202 }
3203
3204
3205
3206
3207
3208
3209
3210
3211 private ReferenceList getRefListAllYesNo( Locale locale )
3212 {
3213 ReferenceList refList = new ReferenceList( );
3214 String strAll = I18nService.getLocalizedString( PROPERTY_ALL, locale );
3215 String strYes = I18nService.getLocalizedString( PROPERTY_YES, locale );
3216 String strNo = I18nService.getLocalizedString( PROPERTY_NO, locale );
3217
3218 refList.addItem( -1, strAll );
3219 refList.addItem( 1, strYes );
3220 refList.addItem( 0, strNo );
3221
3222 return refList;
3223 }
3224
3225
3226
3227
3228
3229
3230
3231
3232 public String doModifySuggestSubmitOrder( HttpServletRequest request )
3233 {
3234 int nIdSuggestSubmit = Integer.parseInt( request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT ) );
3235
3236 SuggestSubmit suggestSubmit = _suggestSubmitService.findByPrimaryKey( nIdSuggestSubmit, false, getPlugin( ) );
3237 int nIdSuggest = Integer.parseInt( request.getParameter( PARAMETER_ID_SUGGEST ) );
3238
3239 if ( suggestSubmit != null )
3240 {
3241 int nNewOrder = Integer.parseInt( request.getParameter( PARAMETER_SUGGEST_SUBMIT_ORDER ) );
3242
3243 _suggestSubmitService.updateSuggestSubmitOrder( suggestSubmit.getSuggestSubmitOrder( ), nNewOrder, suggestSubmit.getSuggest( ).getIdSuggest( ),
3244 suggestSubmit.isPinned( ), getPlugin( ) );
3245 }
3246
3247 return getJspManageSuggestSubmitOrder( request ) + "?" + PARAMETER_ID_SUGGEST + "=" + nIdSuggest;
3248 }
3249
3250
3251
3252
3253
3254
3255
3256
3257 private ReferenceList getSuggestSubmitOrderList( int nIdSuggest, boolean bListPinned )
3258 {
3259 int nMax = _suggestSubmitService.getMaxOrderList( nIdSuggest, bListPinned, getPlugin( ) );
3260 ReferenceList list = new ReferenceList( );
3261
3262 for ( int i = 1; i < ( nMax + 1 ); i++ )
3263 {
3264 list.addItem( i, Integer.toString( i ) );
3265 }
3266
3267 return list;
3268 }
3269
3270
3271
3272
3273
3274
3275
3276
3277 public String getStatistics( HttpServletRequest request )
3278 {
3279 Plugin plugin = getPlugin( );
3280 Locale locale = getLocale( );
3281 Timestamp tFirstDateFilter = null;
3282 Timestamp tLastDateFilter = null;
3283 SuggestFilterness/SuggestFilter.html#SuggestFilter">SuggestFilter suggestFilter = new SuggestFilter( );
3284 suggestFilter.setIdState( Suggest.STATE_ENABLE );
3285
3286 List<Suggest> listSuggest = SuggestHome.getSuggestList( suggestFilter, plugin );
3287
3288 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
3289 String strFirstDateFilter = request.getParameter( PARAMETER_FIRST_DATE_FILTER );
3290 String strLastDateFilter = request.getParameter( PARAMETER_LAST_DATE_FILTER );
3291 String strIdCategory = request.getParameter( PARAMETER_ID_CATEGORY_FILTER );
3292 String strIdType = request.getParameter( PARAMETER_ID_TYPE_SUGGEST );
3293
3294 int nIdCategory = SuggestUtils.getIntegerParameter( strIdCategory );
3295 int nIdType = SuggestUtils.getIntegerParameter( strIdType );
3296
3297 if ( ( strIdSuggest != null ) && !strIdSuggest.equals( EMPTY_STRING ) )
3298 {
3299 _nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
3300 }
3301 else
3302 if ( listSuggest.size( ) > 0 )
3303 {
3304 _nIdSuggest = listSuggest.get( 0 ).getIdSuggest( );
3305 }
3306
3307 Suggest suggest = SuggestHome.findByPrimaryKey( _nIdSuggest, plugin );
3308
3309 if ( ( strFirstDateFilter != null ) && !strFirstDateFilter.equals( "" ) )
3310 {
3311 try
3312 {
3313 tFirstDateFilter = new Timestamp( DateUtil.formatDate( strFirstDateFilter, locale ).getTime( ) );
3314 }
3315 catch( Exception e )
3316 {
3317 tFirstDateFilter = null;
3318 }
3319 }
3320
3321 if ( ( strLastDateFilter != null ) && !strLastDateFilter.equals( "" ) )
3322 {
3323 try
3324 {
3325 tLastDateFilter = new Timestamp( DateUtil.formatDate( strLastDateFilter, locale ).getTime( ) );
3326 }
3327 catch( Exception e )
3328 {
3329 tLastDateFilter = null;
3330 }
3331 }
3332
3333
3334 SubmitFilterest/business/SubmitFilter.html#SubmitFilter">SubmitFilter filter = new SubmitFilter( );
3335 filter.setIdSuggest( _nIdSuggest );
3336 filter.setDateFirst( tFirstDateFilter );
3337 filter.setDateLast( tLastDateFilter );
3338 filter.setIdCategory( nIdCategory );
3339 filter.setIdType( nIdType );
3340
3341
3342 filter.setIdSuggestSubmitState( SuggestSubmit.STATE_PUBLISH );
3343
3344 int nNbComments = _commentSubmitService.getCountCommentSubmit( filter, plugin );
3345
3346
3347 filter.setIdSuggestSubmitState( SuggestSubmit.STATE_PUBLISH );
3348
3349 int nNbVotes = 0;
3350
3351 List<SuggestSubmit> listSuggestSubmit = _suggestSubmitService.getSuggestSubmitList( filter, plugin );
3352 List<String> listUsersKey = new ArrayList<>( );
3353
3354 for ( SuggestSubmit d : listSuggestSubmit )
3355 {
3356 nNbVotes += d.getNumberVote( );
3357
3358 if ( !listUsersKey.contains( d.getLuteceUserKey( ) ) )
3359 {
3360 listUsersKey.add( d.getLuteceUserKey( ) );
3361 }
3362 }
3363
3364
3365 filter.setIdSuggestSubmitState( SuggestSubmit.STATE_DISABLE );
3366
3367 int nNbSuggestSubmitDisabled = _suggestSubmitService.getCountSuggestSubmit( filter, plugin );
3368 filter.setIdSuggestSubmitState( SuggestSubmit.STATE_WAITING_FOR_PUBLISH );
3369
3370 int nNbSuggestSubmitWaiting = _suggestSubmitService.getCountSuggestSubmit( filter, plugin );
3371 filter.setIdSuggestSubmitState( SuggestSubmit.STATE_PUBLISH );
3372
3373 int nNbSuggestSubmitPublished = _suggestSubmitService.getCountSuggestSubmit( filter, plugin );
3374
3375
3376 SuggestUtils.initSubmitFilterBySort( filter, SubmitFilter.SORT_BY_SCORE_DESC );
3377
3378 int nNumberMaxSuggestSubmit = AppPropertiesService.getPropertyInt( PROPERTY_SUGGESTSUBMIT_HIGHSCORES, 10 );
3379 listSuggestSubmit = _suggestSubmitService.getSuggestSubmitList( filter, plugin, nNumberMaxSuggestSubmit );
3380
3381 ReferenceList refSuggestList = SuggestUtils.getRefListSuggest( listSuggest, false );
3382
3383 Map<String, Object> model = new HashMap<>( );
3384
3385 model.put( MARK_FIRST_DATE_FILTER, ( tFirstDateFilter == null ) ? null : new Date( tFirstDateFilter.getTime( ) ) );
3386 model.put( MARK_LAST_DATE_FILTER, ( tLastDateFilter == null ) ? null : new Date( tLastDateFilter.getTime( ) ) );
3387 model.put( MARK_SUGGEST, suggest );
3388
3389 if ( nNbSuggestSubmitPublished != 0 )
3390 {
3391 float fV = (float) nNbVotes / nNbSuggestSubmitPublished;
3392 float fC = (float) nNbComments / nNbSuggestSubmitPublished;
3393
3394 BigDecimal bd = new BigDecimal( fV );
3395 bd = bd.setScale( 2, BigDecimal.ROUND_HALF_UP );
3396
3397 BigDecimal bd2 = new BigDecimal( fC );
3398 bd2 = bd2.setScale( 2, BigDecimal.ROUND_HALF_UP );
3399
3400 model.put( MARK_NUMBER_VOTES, bd.toString( ) );
3401 model.put( MARK_NUMBER_COMMENTS, bd2.toString( ) );
3402 }
3403
3404 if ( ( suggest.getCategories( ) != null ) && !suggest.getCategories( ).isEmpty( ) )
3405 {
3406 ReferenceList refCategoryList = SuggestUtils.getRefListCategory( suggest.getCategories( ) );
3407 SuggestUtils.addEmptyItem( refCategoryList );
3408 model.put( MARK_CATEGORY_LIST, refCategoryList );
3409 model.put( MARK_SUGGEST_SUBMIT_CATEGORY_SELECTED, nIdCategory );
3410
3411 if ( nIdCategory != SuggestUtils.CONSTANT_ID_NULL )
3412 {
3413 model.put( MARK_CATEGORY_FILTER, CategoryHome.findByPrimaryKey( nIdCategory, plugin ) );
3414 }
3415 }
3416
3417 if ( ( suggest.getSuggestSubmitTypes( ) != null ) && !suggest.getSuggestSubmitTypes( ).isEmpty( ) )
3418 {
3419 ReferenceList refSuggestSubmitTypes = SuggestUtils.getRefListType( suggest.getSuggestSubmitTypes( ) );
3420 SuggestUtils.addEmptyItem( refSuggestSubmitTypes );
3421 model.put( MARK_SUGGEST_SUBMIT_TYPE_LIST, refSuggestSubmitTypes );
3422 model.put( MARK_SUGGEST_SUBMIT_TYPE_SELECTED, nIdType );
3423
3424 if ( nIdType != SuggestUtils.CONSTANT_ID_NULL )
3425 {
3426 model.put( MARK_TYPE_FILTER, SuggestSubmitTypeHome.findByPrimaryKey( nIdType, plugin ) );
3427 }
3428 }
3429
3430 model.put( MARK_NUMBER_SUGGESTSUBMIT_DISABLED, nNbSuggestSubmitDisabled );
3431 model.put( MARK_NUMBER_SUGGESTSUBMIT_WAITING, nNbSuggestSubmitWaiting );
3432 model.put( MARK_NUMBER_SUGGESTSUBMIT_PUBLISHED, nNbSuggestSubmitPublished );
3433 model.put( MARK_NUMBER_USERS, listUsersKey.size( ) );
3434 model.put( MARK_HIGH_SCORES, listSuggestSubmit );
3435 model.put( MARK_SUGGEST_LIST, refSuggestList );
3436 model.put( MARK_URL, AppPathService.getBaseUrl( request ) + JSP_MANAGE_COMMENT_SUBMIT + "?id_suggest_submit=" );
3437
3438 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_STATISTICS_SUGGEST, locale, model );
3439
3440 return getAdminPage( template.getHtml( ) );
3441 }
3442
3443
3444
3445
3446
3447
3448
3449
3450 public String getConfirmUpdateAllDisplayOfSuggestSubmit( HttpServletRequest request )
3451 {
3452 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
3453 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
3454
3455 if ( ( nIdSuggest == -1 )
3456 || !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_UPDATE_ALL_SUGGEST_SUBMIT,
3457 getUser( ) ) )
3458 {
3459 return getJspManageSuggest( request );
3460 }
3461
3462 UrlItem url = new UrlItem( JSP_DO_UPDATE_ALL_SUGGEST_SUBMIT );
3463 url.addParameter( PARAMETER_ID_SUGGEST, strIdSuggest );
3464
3465 return AdminMessageService.getMessageUrl( request, MESSAGE_CONFIRM_UPDATE_ALL_SUGGEST_SUBMIT, url.getUrl( ), AdminMessage.TYPE_CONFIRMATION );
3466 }
3467
3468
3469
3470
3471
3472
3473
3474
3475 public String doUpdateAllDisplayOfSuggestSubmit( HttpServletRequest request )
3476 {
3477 Plugin plugin = getPlugin( );
3478 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
3479 int nIdSuggest = SuggestUtils.getIntegerParameter( strIdSuggest );
3480
3481 if ( RBACService.isAuthorized( Suggest.RESOURCE_TYPE, EMPTY_STRING + nIdSuggest, SuggestResourceIdService.PERMISSION_UPDATE_ALL_SUGGEST_SUBMIT,
3482 getUser( ) ) )
3483 {
3484 _suggestSubmitService.updateAllDisplayOfSuggestSubmit( nIdSuggest, plugin, getLocale( ) );
3485 }
3486
3487 return getJspManageSuggest( request );
3488 }
3489
3490
3491
3492
3493
3494
3495
3496
3497 public String doModifyAdvancedParameters( HttpServletRequest request )
3498 {
3499 Suggest suggest;
3500 Plugin plugin = getPlugin( );
3501 String strIdDefaultSuggest = request.getParameter( PARAMETER_ID_DEFAULT_SUGGEST );
3502 int nIdDefaultSuggest = SuggestUtils.getIntegerParameter( strIdDefaultSuggest );
3503
3504 if ( !RBACService.isAuthorized( Suggest.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID, SuggestResourceIdService.PERMISSION_MANAGE_ADVANCED_PARAMETERS,
3505 getUser( ) ) )
3506 {
3507 return getManageSuggest( request );
3508 }
3509
3510
3511 SuggestFilterst/business/SuggestFilter.html#SuggestFilter">SuggestFilter filter = new SuggestFilter( );
3512 filter.setIdDefaultSuggest( SuggestFilter.ID_TRUE );
3513
3514 List<Suggest> listDefaultSuggest = SuggestHome.getSuggestList( filter, plugin );
3515
3516
3517 for ( Suggest defaultSuggest : listDefaultSuggest )
3518 {
3519 suggest = SuggestHome.findByPrimaryKey( defaultSuggest.getIdSuggest( ), plugin );
3520 suggest.setDefaultSuggest( false );
3521 SuggestHome.update( suggest, plugin );
3522 }
3523
3524 if ( nIdDefaultSuggest != SuggestUtils.CONSTANT_ID_NULL )
3525 {
3526 Suggest suggestDefault = SuggestHome.findByPrimaryKey( nIdDefaultSuggest, plugin );
3527
3528 if ( suggestDefault != null )
3529 {
3530 suggestDefault.setDefaultSuggest( true );
3531 SuggestHome.update( suggestDefault, plugin );
3532 }
3533 }
3534
3535 return getJspManageAdvancedParameters( request );
3536 }
3537
3538 private void updateSearchFieldsData( HttpServletRequest request )
3539 {
3540 String strIdSuggest = request.getParameter( PARAMETER_ID_SUGGEST );
3541 String strIdSuggestSumitState = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT_STATE );
3542 String strIdSuggestSubmitSort = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT_SORT );
3543 String strIdSuggestSubmitReport = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT_REPORT );
3544 String strIdCategory = request.getParameter( PARAMETER_ID_CATEGORY_FILTER );
3545 String strIdType = request.getParameter( PARAMETER_ID_TYPE_SUGGEST );
3546 String strIdContainsCommentDisable = request.getParameter( PARAMETER_ID_CONTAINS_COMMENT_DISABLE );
3547
3548 String strQuery = request.getParameter( PARAMETER_QUERY );
3549
3550 if ( ( strIdSuggest != null ) && !strIdSuggest.equals( EMPTY_STRING ) )
3551 {
3552 getSearchFields( ).setIdSuggest( SuggestUtils.getIntegerParameter( strIdSuggest ) );
3553 }
3554
3555 if ( ( strIdSuggestSubmitSort != null ) && !strIdSuggestSubmitSort.equals( EMPTY_STRING ) )
3556 {
3557 getSearchFields( ).setIdSuggestSubmitSort( SuggestUtils.getIntegerParameter( strIdSuggestSubmitSort ) );
3558 }
3559
3560 if ( ( strIdSuggestSubmitReport != null ) && !strIdSuggestSubmitReport.equals( EMPTY_STRING ) )
3561 {
3562 getSearchFields( ).setIdSuggestSubmitReport( SuggestUtils.getIntegerParameter( strIdSuggestSubmitReport ) );
3563 }
3564
3565 if ( ( strIdSuggestSumitState != null ) && !strIdSuggestSumitState.equals( EMPTY_STRING ) )
3566 {
3567 getSearchFields( ).setIdSuggestSumitState( SuggestUtils.getIntegerParameter( strIdSuggestSumitState ) );
3568 }
3569
3570 if ( ( strIdCategory != null ) && !strIdCategory.equals( EMPTY_STRING ) )
3571 {
3572 getSearchFields( ).setIdCategory( SuggestUtils.getIntegerParameter( strIdCategory ) );
3573 }
3574
3575 if ( ( strIdType != null ) && !strIdType.equals( EMPTY_STRING ) )
3576 {
3577 getSearchFields( ).setIdType( SuggestUtils.getIntegerParameter( strIdType ) );
3578 }
3579
3580 if ( ( strIdContainsCommentDisable != null ) && !strIdContainsCommentDisable.equals( EMPTY_STRING ) )
3581 {
3582 getSearchFields( ).setIdSuggestSubmitContainsCommentDisable( SuggestUtils.getIntegerParameter( strIdContainsCommentDisable ) );
3583 }
3584
3585 if ( strQuery != null )
3586 {
3587 getSearchFields( ).setQuery( strQuery );
3588 }
3589 }
3590
3591 private SuggestAdminSearchFields getSearchFields( )
3592 {
3593 return _searchFields;
3594 }
3595
3596
3597
3598
3599
3600
3601
3602
3603 public String doProcessAction( HttpServletRequest request )
3604 {
3605 String strIdAction = request.getParameter( PARAMETER_ID_ACTION );
3606 String strIdSuggestSubmit = request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT );
3607
3608 if ( StringUtils.isNumeric( strIdAction ) && StringUtils.isNumeric( strIdSuggestSubmit ) )
3609 {
3610 int nIdAction = Integer.parseInt( strIdAction );
3611 int nIdSuggestSubmit = Integer.parseInt( strIdSuggestSubmit );
3612
3613 SuggestSubmit submit = _suggestSubmitService.findByPrimaryKey( nIdSuggestSubmit, false, getPlugin( ) );
3614
3615
3616 if ( WorkflowService.getInstance( ).isDisplayTasksForm( nIdAction, getLocale( ) ) )
3617 {
3618
3619 return getTaskFormJsp( request, nIdAction, nIdSuggestSubmit );
3620 }
3621
3622 WorkflowService.getInstance( ).doProcessAction( nIdSuggestSubmit, SuggestSubmit.RESOURCE_TYPE, nIdAction, submit.getSuggest( ).getIdSuggest( ),
3623 request, getLocale( ), false, getUser( ) );
3624 }
3625 return getJspManageSuggestSubmit( request );
3626 }
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639 public String getTaskFormJsp( HttpServletRequest request, int nIdAction, int nIdSuggestSubmit )
3640 {
3641 UrlItem url = new UrlItem( AppPathService.getBaseUrl( request ) + JSP_WORKFLOW_TASK_FORM );
3642 url.addParameter( PARAMETER_ID_ACTION, nIdAction );
3643 url.addParameter( PARAMETER_ID_SUGGEST_SUBMIT, nIdSuggestSubmit );
3644
3645 return url.getUrl( );
3646 }
3647
3648
3649
3650
3651
3652
3653
3654
3655 public String getWorkflowTaskForm( HttpServletRequest request )
3656 {
3657
3658 int nIdSuggestSubmit = NumberUtils.toInt( request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT ), NumberUtils.INTEGER_MINUS_ONE );
3659 int nIdAction = NumberUtils.toInt( request.getParameter( PARAMETER_ID_ACTION ), NumberUtils.INTEGER_MINUS_ONE );
3660
3661 if ( nIdAction == NumberUtils.INTEGER_MINUS_ONE || nIdSuggestSubmit == NumberUtils.INTEGER_MINUS_ONE )
3662 {
3663
3664 AppLogService.error( "Can't get workflow task's form: action ID is {} & SuggestSubmit ID is {}", nIdAction, nIdSuggestSubmit );
3665 return AdminMessageService.getMessageUrl( request, MESSAGE_ACTION_ERROR, getJspManageSuggestSubmit( request ), AdminMessage.TYPE_ERROR );
3666 }
3667
3668
3669 String strHtmlTaskForm = WorkflowService.getInstance( ).getDisplayTasksForm( nIdSuggestSubmit, SuggestSubmit.RESOURCE_TYPE, nIdAction, request,
3670 getLocale( ), getUser( ) );
3671
3672 Map<String, Object> model = new HashMap<>( );
3673 model.put( MARK_ID_SUGGEST_SUBMIT, nIdSuggestSubmit );
3674 model.put( MARK_ID_ACTION, nIdAction );
3675 model.put( MARK_TASK_FORM, strHtmlTaskForm );
3676
3677 setPageTitleProperty( PROPERTY_PAGE_TITLE_TASKS_FORM_WORKFLOW );
3678
3679
3680 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_TASK_FORM, getLocale( ), model );
3681 return getAdminPage( template.getHtml( ) );
3682 }
3683
3684
3685
3686
3687
3688
3689
3690
3691 public String doSaveTaskForm( HttpServletRequest request )
3692 {
3693 int nIdSuggestSubmit = NumberUtils.toInt( request.getParameter( PARAMETER_ID_SUGGEST_SUBMIT ), NumberUtils.INTEGER_MINUS_ONE );
3694 int nIdAction = NumberUtils.toInt( request.getParameter( PARAMETER_ID_ACTION ), NumberUtils.INTEGER_MINUS_ONE );
3695
3696 SuggestSubmit submit = _suggestSubmitService.findByPrimaryKey( nIdSuggestSubmit, false, getPlugin( ) );
3697
3698 if ( request.getParameter( PARAMETER_BACK ) == null )
3699 {
3700
3701 if ( WorkflowService.getInstance( ).isDisplayTasksForm( nIdAction, getLocale( ) ) && request.getParameter( PARAMETER_SAVE ) != null )
3702 {
3703
3704 String strError = WorkflowService.getInstance( ).doSaveTasksForm( nIdSuggestSubmit, SuggestSubmit.RESOURCE_TYPE, nIdAction,
3705 submit.getSuggest( ).getIdSuggest( ), request, getLocale( ), getUser( ) );
3706
3707
3708 if ( strError != null )
3709 {
3710
3711 AppLogService.error( "Can't process Suggest workflow action: {}", strError );
3712 return AdminMessageService.getMessageUrl( request, MESSAGE_ACTION_ERROR, getJspManageSuggestSubmit( request ), AdminMessage.TYPE_ERROR );
3713 }
3714 }
3715 return getJspManageSuggestSubmit( request );
3716 }
3717
3718 return getJspManageSuggestSubmit( request );
3719 }
3720 }