Index: lams_monitoring/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r4a83c347cf1a9d2577082a823353d7da42b2e3a5 -r41771fed1bd0652923d05a84de584769dcfe0ef7 --- lams_monitoring/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4a83c347cf1a9d2577082a823353d7da42b2e3a5) +++ lams_monitoring/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 41771fed1bd0652923d05a84de584769dcfe0ef7) @@ -137,6 +137,7 @@ email.notifications.user.name =User name [login] email.notifications.lesson.name =Lesson name email.notifications.send =Send +email.notifications.message.header =Message: email.notifications.user.search.property.0 =Are assigned to this lesson email.notifications.user.search.property.1 =Haven't finished this lesson email.notifications.user.search.property.2 =Have finished this lesson @@ -158,11 +159,17 @@ advanced.tab.enable.lesson.notifications =Enable lesson notifications email.notifications.by.this.date =By this date: email.notifications.emails.successfully.scheduled =Emails have been successfully scheduled to be sent on specified date. -email.notifications.scheduled.messages.list =List of scheduled emails +email.notifications.scheduled.messages.button =Scheduled +email.notifications.scheduled.messages.list =List of sheduled emails email.notifications.scheduled.messages.list.scheduled.date =Scheduled date email.notifications.scheduled.messages.list.email.body =Email body email.notifications.scheduled.messages.list.notify.sudents.that =Notify learners that email.notifications.scheduled.messages.list.back =Back to notifications +email.notifications.archived.messages.button =Archived +email.notifications.archived.messages.list =List of archived emails +email.notifications.archived.messages.list.sent.date =Sent on +email.notifications.archived.messages.list.sent.count =Sent to +email.notifications.archived.messages.list.learners =learners email.notifications.table.now =Now email.notifications.table.schedule =Schedule email.notifications.button.schedule =Schedule Index: lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r4a83c347cf1a9d2577082a823353d7da42b2e3a5 -r41771fed1bd0652923d05a84de584769dcfe0ef7 --- lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 4a83c347cf1a9d2577082a823353d7da42b2e3a5) +++ lams_monitoring/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 41771fed1bd0652923d05a84de584769dcfe0ef7) @@ -137,6 +137,7 @@ email.notifications.user.name =User name [login] email.notifications.lesson.name =Lesson name email.notifications.send =Send +email.notifications.message.header =Message: email.notifications.user.search.property.0 =Are assigned to this lesson email.notifications.user.search.property.1 =Haven't finished this lesson email.notifications.user.search.property.2 =Have finished this lesson @@ -158,11 +159,14 @@ advanced.tab.enable.lesson.notifications =Enable lesson notifications email.notifications.by.this.date =By this date: email.notifications.emails.successfully.scheduled =Emails have been successfully scheduled to be sent on specified date. -email.notifications.scheduled.messages.list =List of scheduled emails +email.notifications.scheduled.messages.button =Scheduled +email.notifications.scheduled.messages.list =List of sheduled emails email.notifications.scheduled.messages.list.scheduled.date =Scheduled date email.notifications.scheduled.messages.list.email.body =Email body email.notifications.scheduled.messages.list.notify.sudents.that =Notify learners that email.notifications.scheduled.messages.list.back =Back to notifications +email.notifications.archived.messages.button =Archived +email.notifications.archived.messages.list =List of archived emails email.notifications.table.now =Now email.notifications.table.schedule =Schedule email.notifications.button.schedule =Schedule Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/EmailNotificationsAction.java =================================================================== diff -u -r5ee97544d5ad1e51d4c80b3e1d3beccd97dcf322 -r41771fed1bd0652923d05a84de584769dcfe0ef7 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/EmailNotificationsAction.java (.../EmailNotificationsAction.java) (revision 5ee97544d5ad1e51d4c80b3e1d3beccd97dcf322) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/EmailNotificationsAction.java (.../EmailNotificationsAction.java) (revision 41771fed1bd0652923d05a84de584769dcfe0ef7) @@ -20,7 +20,6 @@ * **************************************************************** */ - package org.lamsfoundation.lams.monitoring.web; import java.io.IOException; @@ -49,6 +48,7 @@ import org.apache.tomcat.util.json.JSONObject; import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; +import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.lesson.util.LessonComparator; import org.lamsfoundation.lams.monitoring.MonitoringConstants; @@ -109,11 +109,12 @@ /** * Shows "Email notification" page for particular lesson. */ + @SuppressWarnings("unchecked") public ActionForward getLessonView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), "show lesson email notifications", - false)) { + if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), + "show lesson email notifications", false)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson"); return null; } @@ -127,7 +128,7 @@ return null; } - Set activities = lesson.getLearningDesign().getActivities(); + Set activities = lesson.getLearningDesign().getActivities(); request.setAttribute("lesson", lesson); request.setAttribute("activities", activities); @@ -137,6 +138,7 @@ /** * Shows "Email notification" page for particular course. */ + @SuppressWarnings("unchecked") public ActionForward getCourseView(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { int orgId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID); @@ -240,20 +242,50 @@ } /** + * Renders a page listing all archived emails. + */ + public ActionForward showArchivedEmails(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, SchedulerException { + getUserManagementService(); + Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true); + boolean isLessonNotifications = (lessonId != null); + Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true); + if (isLessonNotifications) { + if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), + "show scheduled lesson email notifications", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the lesson"); + return null; + } + } else { + if (!getSecurityService().isGroupMonitor(organisationId, getCurrentUser().getUserID(), + "show scheduled course course email notifications", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "The user is not a monitor in the organisation"); + return null; + } + } + + request.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId); + request.setAttribute(AttributeNames.PARAM_ORGANISATION_ID, organisationId); + + return mapping.findForward("archivedEmailList"); + } + + /** * Delete a scheduled emails. - * @throws JSONException + * + * @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 = getCurrentUser().getUserID(); boolean isLessonNotifications = (lessonId != null); Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true); - IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() - .getServletContext()); + IMonitoringService monitoringService = MonitoringServiceProxy + .getMonitoringService(getServlet().getServletContext()); getUserManagementService(); Scheduler scheduler = getScheduler(); @@ -263,8 +295,8 @@ 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)) { + 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 { @@ -274,9 +306,9 @@ } } - if ( error == null ) { - Set triggerKeys = scheduler.getTriggerKeys(GroupMatcher - .triggerGroupEquals(Scheduler.DEFAULT_GROUP)); + if (error == null) { + Set triggerKeys = scheduler + .getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP)); for (TriggerKey triggerKey : triggerKeys) { String triggerName = triggerKey.getName(); if (triggerName.equals(inputTriggerName)) { @@ -287,15 +319,16 @@ JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey()); JobDataMap jobDataMap = jobDetail.getJobDataMap(); getAuditService().log(MonitoringConstants.MONITORING_MODULE_NAME, - "Deleting unsent scheduled notification " + jobKey + " " + jobDataMap.getString("emailBody")); + "Deleting unsent scheduled notification " + jobKey + " " + + jobDataMap.getString("emailBody")); scheduler.deleteJob(jobKey); } } } - + } catch (Exception e) { String[] msg = new String[1]; msg[0] = e.getMessage(); @@ -338,15 +371,15 @@ } JSONObject.put("isSuccessfullySent", isSuccessfullySent); - + //prepare data for audit log scheduleDateStr = "now"; - emailClauseStr = "for users (userIds: " + StringUtils.join(userIdStrs,",") + ")"; - + emailClauseStr = "for users (userIds: " + StringUtils.join(userIdStrs, ",") + ")"; + } else { try { Calendar now = Calendar.getInstance(); - + Map searchParameters = new HashMap(); copySearchParametersFromRequestToMap(request, searchParameters); @@ -370,7 +403,7 @@ Scheduler scheduler = getScheduler(); scheduler.scheduleJob(emailScheduleMessageJob, startLessonTrigger); JSONObject.put("isSuccessfullyScheduled", true); - + //prepare data for audit log scheduleDateStr = "on " + scheduleDate; Object lessonIdObj = searchParameters.get(AttributeNames.PARAM_LESSON_ID); @@ -379,11 +412,11 @@ if (lessonIdObj != null) { emailClauseStr = "for lesson (lessonId: " + lessonIdObj + ")"; } else if (lessonIDsObj != null) { - emailClauseStr = "for lessons (lessonIDs: " + StringUtils.join((String[])lessonIDsObj,",") + ")"; + emailClauseStr = "for lessons (lessonIDs: " + StringUtils.join((String[]) lessonIDsObj, ",") + ")"; } else if (organisationIdObj != null) { emailClauseStr = "for organisation (organisationId: " + organisationIdObj + ")"; } - + } catch (SchedulerException e) { LamsDispatchAction.log.error("Error occurred at " + "[emailScheduleMessage]- fail to email scheduling", e); @@ -392,7 +425,7 @@ //audit log getAuditService().log(MonitoringConstants.MONITORING_MODULE_NAME, - "User " + getCurrentUser().getLogin() + " set a notification "+ emailClauseStr + " " + scheduleDateStr + "User " + getCurrentUser().getLogin() + " set a notification " + emailClauseStr + " " + scheduleDateStr + " with the following notice: " + emailBody); response.setContentType("application/json;charset=utf-8"); Index: lams_monitoring/web/WEB-INF/struts-config.xml =================================================================== diff -u -r8714ac689fdad46746bbb7f28005ec080d1d4ba6 -r41771fed1bd0652923d05a84de584769dcfe0ef7 --- lams_monitoring/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 8714ac689fdad46746bbb7f28005ec080d1d4ba6) +++ lams_monitoring/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 41771fed1bd0652923d05a84de584769dcfe0ef7) @@ -134,6 +134,11 @@ path="/emailnotifications/scheduledEmailList.jsp" redirect="false" /> + - - - - lessonID=${lesson.lessonId} - - - organisationID=${org.organisationId} - - - - - Index: lams_monitoring/web/emailnotifications/archivedEmailList.jsp =================================================================== diff -u --- lams_monitoring/web/emailnotifications/archivedEmailList.jsp (revision 0) +++ lams_monitoring/web/emailnotifications/archivedEmailList.jsp (revision 41771fed1bd0652923d05a84de584769dcfe0ef7) @@ -0,0 +1,90 @@ +<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %> +<%@ taglib uri="tags-tiles" prefix="tiles" %> +<%@ taglib uri="tags-html" prefix="html" %> +<%@ taglib uri="tags-fmt" prefix="fmt" %> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-lams" prefix="lams" %> +<%@ taglib uri="tags-function" prefix="fn"%> +<%@ page import="org.lamsfoundation.lams.util.Configuration"%> +<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys"%> + + + + + + + + + + + + + + + + + + + + +

+ +

+ + + + + + + + + + + + + +
+ + + + + + + + +
+ ${email.date}
+
+ + + + + + + + + + + + + +
+ + + ${email.sentCount} + +
+ ${email.body} +
+ + + + +
+ + +
Index: lams_monitoring/web/emailnotifications/courseNotifications.jsp =================================================================== diff -u -re6b3b4b473ebb151c10733808c40d4276b4f81ab -r41771fed1bd0652923d05a84de584769dcfe0ef7 --- lams_monitoring/web/emailnotifications/courseNotifications.jsp (.../courseNotifications.jsp) (revision e6b3b4b473ebb151c10733808c40d4276b4f81ab) +++ lams_monitoring/web/emailnotifications/courseNotifications.jsp (.../courseNotifications.jsp) (revision 41771fed1bd0652923d05a84de584769dcfe0ef7) @@ -217,6 +217,20 @@
+
+ +
+
+

@@ -262,7 +276,7 @@
- +






Index: lams_monitoring/web/emailnotifications/lessonNotifications.jsp =================================================================== diff -u -re6b3b4b473ebb151c10733808c40d4276b4f81ab -r41771fed1bd0652923d05a84de584769dcfe0ef7 --- lams_monitoring/web/emailnotifications/lessonNotifications.jsp (.../lessonNotifications.jsp) (revision e6b3b4b473ebb151c10733808c40d4276b4f81ab) +++ lams_monitoring/web/emailnotifications/lessonNotifications.jsp (.../lessonNotifications.jsp) (revision 41771fed1bd0652923d05a84de584769dcfe0ef7) @@ -188,6 +188,20 @@
+
+ +
+
+

@@ -235,7 +249,7 @@
-

Message:

+






${lesson.lessonName}home.do?method=learner&lessonID=${lesson.lessonId}