Index: lams_monitoring/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r3399163940c61c9132223c758d274486e57ff9b7 -r2e52631e8d9ec49424ba74b3a003226e2d4302fb --- lams_monitoring/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 3399163940c61c9132223c758d274486e57ff9b7) +++ lams_monitoring/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 2e52631e8d9ec49424ba74b3a003226e2d4302fb) @@ -306,6 +306,9 @@ learner.group.forward.10 =10 pages forward learner.group.backward.1 =Previous page learner.group.backward.10 =10 pages back +email.notify.students.that=Notify students that +email.notifications.delete=Delete Notification +email.notification.delete.alert1=About to delete the scheduled notification: {0} +email.notification.delete.alert2=This cannot be undone. Do you want to delete? - #======= End labels: Exported 310 labels for en AU ===== Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/dto/EmailScheduleMessageJobDTO.java =================================================================== diff -u -r3399163940c61c9132223c758d274486e57ff9b7 -r2e52631e8d9ec49424ba74b3a003226e2d4302fb --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/dto/EmailScheduleMessageJobDTO.java (.../EmailScheduleMessageJobDTO.java) (revision 3399163940c61c9132223c758d274486e57ff9b7) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/dto/EmailScheduleMessageJobDTO.java (.../EmailScheduleMessageJobDTO.java) (revision 2e52631e8d9ec49424ba74b3a003226e2d4302fb) @@ -31,6 +31,7 @@ public class EmailScheduleMessageJobDTO implements Serializable, Comparable { + private String triggerName; private Date triggerDate; private String emailBody; private int searchType; @@ -59,17 +60,25 @@ this.searchType = searchType; } + public String getTriggerName() { + return triggerName; + } + + public void setTriggerName(String triggerName) { + this.triggerName = triggerName; + } + @Override public String toString() { - return new ToStringBuilder(this).append("emailBody", emailBody).append("triggerDate", triggerDate) + return new ToStringBuilder(this).append("triggerName", triggerName).append("emailBody", emailBody).append("triggerDate", triggerDate) .append("searchType", searchType).toString(); } @Override public int compareTo(Object other) { EmailScheduleMessageJobDTO otherDto = (EmailScheduleMessageJobDTO) other; return new CompareToBuilder().append(triggerDate, otherDto.triggerDate).append(emailBody, otherDto.emailBody) - .append(searchType, otherDto.searchType).toComparison(); + .append(searchType, otherDto.searchType).append("triggerName", triggerName).toComparison(); } } Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/EmailNotificationsAction.java =================================================================== diff -u -r3399163940c61c9132223c758d274486e57ff9b7 -r2e52631e8d9ec49424ba74b3a003226e2d4302fb --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/EmailNotificationsAction.java (.../EmailNotificationsAction.java) (revision 3399163940c61c9132223c758d274486e57ff9b7) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/EmailNotificationsAction.java (.../EmailNotificationsAction.java) (revision 2e52631e8d9ec49424ba74b3a003226e2d4302fb) @@ -69,6 +69,7 @@ import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobDetail; +import org.quartz.JobKey; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.Trigger; @@ -232,6 +233,7 @@ String emailBody = WebUtil.convertNewlines((String) jobDataMap.get("emailBody")); int searchType = (Integer) jobDataMap.get("searchType"); EmailScheduleMessageJobDTO emailScheduleJobDTO = new EmailScheduleMessageJobDTO(); + emailScheduleJobDTO.setTriggerName(triggerName); emailScheduleJobDTO.setTriggerDate(triggerDate); emailScheduleJobDTO.setEmailBody(emailBody); emailScheduleJobDTO.setSearchType(searchType); @@ -247,6 +249,76 @@ } /** + * Delete a scheduled emails. + * @throws JSONException + */ + public ActionForward deleteNotification(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, SchedulerException, JSONException { + + String inputTriggerName = WebUtil.readStrParam(request, "triggerName"); + Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true); + Integer userId = getUser().getUserID(); + boolean isLessonNotifications = (lessonId != null); + Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true); + + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() + .getServletContext()); + getUserManagementService(); + Scheduler scheduler = getScheduler(); + + JSONObject jsonObject = new JSONObject(); + String error = null; + + try { + // if this method throws an Exception, there will be no deleteNotification=true in the JSON reply + if (isLessonNotifications) { + if (!getSecurityService().isLessonMonitor(lessonId, userId, + "show scheduled lesson email notifications", false)) { + error = "Unable to delete notification: the user is not a monitor in the lesson"; + } + } else { + if (!getSecurityService().isGroupMonitor(organisationId, userId, + "show scheduled course course email notifications", false)) { + error = "Unable to delete notification: the user is not a monitor in the organisation"; + } + } + + if ( error == null ) { + Set triggerKeys = scheduler.getTriggerKeys(GroupMatcher + .triggerGroupEquals(Scheduler.DEFAULT_GROUP)); + for (TriggerKey triggerKey : triggerKeys) { + String triggerName = triggerKey.getName(); + if (triggerName.equals(inputTriggerName)) { + Trigger trigger = scheduler.getTrigger(triggerKey); + + JobKey jobKey = trigger.getJobKey(); + + JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey()); + JobDataMap jobDataMap = jobDetail.getJobDataMap(); + getAuditService().log(MonitoringConstants.MONITORING_MODULE_NAME, + "Deleting unsent scheduled notification " + jobKey + " " + jobDataMap.getString("emailBody")); + + scheduler.deleteJob(jobKey); + + } + } + + } + + } catch (Exception e) { + String[] msg = new String[1]; + msg[0] = e.getMessage(); + error = monitoringService.getMessageService().getMessage("error.system.error", msg); + } + + jsonObject.put("deleteNotification", error == null ? "true" : error); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(jsonObject); + return null; + + } + + /** * Method called via Ajax. It either emails selected users or schedules these emails to be sent on specified date. */ public ActionForward emailUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, Index: lams_monitoring/web/emailnotifications/courseNotifications.jsp =================================================================== diff -u -r0c9ec89b9e6a51870b94ebc331be46d706c99d69 -r2e52631e8d9ec49424ba74b3a003226e2d4302fb --- lams_monitoring/web/emailnotifications/courseNotifications.jsp (.../courseNotifications.jsp) (revision 0c9ec89b9e6a51870b94ebc331be46d706c99d69) +++ lams_monitoring/web/emailnotifications/courseNotifications.jsp (.../courseNotifications.jsp) (revision 2e52631e8d9ec49424ba74b3a003226e2d4302fb) @@ -76,13 +76,11 @@ //initialize datetimepicker $("#datePicker").datetimepicker(); - debugger; //initialize accordion $( "#accordion" ).accordion({ create: function(event, ui) { // accordion probably sets its height based on empty grid // once it is loaded, it needs to be adjusted - debugger; $('div.ui-accordion-content').css('height', '100%'); }, activate: function(event, ui) { @@ -121,7 +119,6 @@ $('#emailButton').click(function() { - debugger; var isInstantEmailing = ($('#accordion').accordion('option', 'active') == 0); var ids = jQuery("#list3").getGridParam('selarrrow'); var params = ""; Index: lams_monitoring/web/emailnotifications/scheduledEmailList.jsp =================================================================== diff -u -r0c9ec89b9e6a51870b94ebc331be46d706c99d69 -r2e52631e8d9ec49424ba74b3a003226e2d4302fb --- lams_monitoring/web/emailnotifications/scheduledEmailList.jsp (.../scheduledEmailList.jsp) (revision 0c9ec89b9e6a51870b94ebc331be46d706c99d69) +++ lams_monitoring/web/emailnotifications/scheduledEmailList.jsp (.../scheduledEmailList.jsp) (revision 2e52631e8d9ec49424ba74b3a003226e2d4302fb) @@ -17,21 +17,60 @@ + + + +

+ + + ?method=getLessonView&lessonID=${lessonID} + method=deleteNotification&lessonID=${lessonID} + + + ?method=getCourseView&organisationID=${organisationID} + method=deleteNotification&organisationID=${organisationID} + + + -
+ - Notify students that + @@ -41,7 +80,13 @@
- + + ${tDate}
+ + + +
@@ -65,14 +110,6 @@
- - - ?method=getLessonView&lessonID=${lessonID} - - - ?method=getCourseView&organisationID=${organisationID} - -