Index: lams_tool_wiki/conf/hibernate/mappings/org/lamsfoundation/lams/tool/wiki/model/Wiki.hbm.xml =================================================================== diff -u -r1082bdcc357c105126a5641cecc68acfa645b66b -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/conf/hibernate/mappings/org/lamsfoundation/lams/tool/wiki/model/Wiki.hbm.xml (.../Wiki.hbm.xml) (revision 1082bdcc357c105126a5641cecc68acfa645b66b) +++ lams_tool_wiki/conf/hibernate/mappings/org/lamsfoundation/lams/tool/wiki/model/Wiki.hbm.xml (.../Wiki.hbm.xml) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -114,6 +114,15 @@ /> + + + * in JSP pages. + * + * @param key + * key of the message + * @param args + * arguments for the message + * @return message content + */ + String getLocalisedMessage(String key, Object[] args); + + /** + * Fetches the wiki notification service + * + * @return + */ + IEventNotificationService getEventNotificationService(); + + /** + * Gets a list of monitors for the given tool session + * + * @param sessionId + * @return + */ + List getMonitorsByToolSessionId(Long sessionId); } Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java =================================================================== diff -u -rbec4861a186a6a8972771f054c3fa1fb0f51da72 -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java (.../WikiService.java) (revision bec4861a186a6a8972771f054c3fa1fb0f51da72) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java (.../WikiService.java) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -50,10 +50,12 @@ import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; import org.lamsfoundation.lams.contentrepository.service.RepositoryProxy; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; +import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; +import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; import org.lamsfoundation.lams.tool.ToolContentImport102Manager; @@ -84,8 +86,10 @@ import org.lamsfoundation.lams.tool.wiki.util.diff.Diff; import org.lamsfoundation.lams.tool.wiki.util.diff.Difference; import org.lamsfoundation.lams.tool.wiki.web.forms.WikiPageForm; +import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.FileUtil; +import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.util.audit.IAuditService; @@ -95,63 +99,6 @@ * As a requirement, all LAMS tool's service bean must implement * ToolContentManager and ToolSessionManager. */ - -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ -/** - * @author lfoxton - * - */ public class WikiService implements ToolSessionManager, ToolContentManager, IWikiService, ToolContentImport102Manager { static Logger logger = Logger.getLogger(WikiService.class.getName()); @@ -183,6 +130,12 @@ private ICoreNotebookService coreNotebookService; private WikiOutputFactory wikiOutputFactory; + + private IEventNotificationService eventNotificationService; + + private MessageService messageService; + + private ILessonService lessonService; public WikiService() { super(); @@ -870,8 +823,8 @@ } /** - * This method verifies the credentials of the Wiki Tool and gives it - * the Ticket to login and access the Content Repository. + * This method verifies the credentials of the Wiki Tool and gives it the + * Ticket to login and access the Content Repository. * * A valid ticket is needed in order to access the content from the * repository. This method would be called evertime the tool needs to @@ -1098,4 +1051,37 @@ public void setWikiOutputFactory(WikiOutputFactory wikiOutputFactory) { this.wikiOutputFactory = wikiOutputFactory; } + + public IEventNotificationService getEventNotificationService() { + return eventNotificationService; + } + + public void setEventNotificationService(IEventNotificationService eventNotificationService) { + this.eventNotificationService = eventNotificationService; + } + + public MessageService getMessageService() { + return messageService; + } + + public void setMessageService(MessageService messageService) { + this.messageService = messageService; + } + + public String getLocalisedMessage(String key, Object[] args) { + return messageService.getMessage(key, args); + } + + public List getMonitorsByToolSessionId(Long sessionId) { + return getLessonService().getMonitorsByToolSessionId(sessionId); + } + + public ILessonService getLessonService() { + return lessonService; + } + + public void setLessonService(ILessonService lessonService) { + this.lessonService = lessonService; + } + } Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/util/WikiConstants.java =================================================================== diff -u -r02454b2f2a995f3aab41c2007c44290979605d8e -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/util/WikiConstants.java (.../WikiConstants.java) (revision 02454b2f2a995f3aab41c2007c44290979605d8e) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/util/WikiConstants.java (.../WikiConstants.java) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -63,6 +63,10 @@ public static final String ATTR_FINISHED_ACTIVITY = "finishedActivity"; public static final String ATTR_CONTENT_EDITAVLE = "contentEditable"; public static final String ATTR_MAIN_PAGE_TITLE = "mainPageTitle"; + + // Events + public static final String EVENT_NOTIFY_TEACHERS = "wikiNotifyTeachers"; + public static final String EVENT_NOTIFY_LEARNERS = "wikiNotifyLearners"; // Parameter names public static final String PARAM_PARENT_PAGE = "parentPage"; Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java =================================================================== diff -u -rbec4861a186a6a8972771f054c3fa1fb0f51da72 -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision bec4861a186a6a8972771f054c3fa1fb0f51da72) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -54,23 +54,19 @@ import org.lamsfoundation.lams.tool.wiki.model.WikiPageContent; import org.lamsfoundation.lams.tool.wiki.model.WikiUser; import org.lamsfoundation.lams.tool.wiki.service.IWikiService; -import org.lamsfoundation.lams.tool.wiki.service.WikiServiceProxy; // import - // org.lamsfoundation.lams.tool.wiki.util.Diff; -import org.lamsfoundation.lams.tool.wiki.util.diff.Diff; -import org.lamsfoundation.lams.tool.wiki.util.diff.Difference; +import org.lamsfoundation.lams.tool.wiki.service.WikiServiceProxy; import org.lamsfoundation.lams.tool.wiki.util.WikiConstants; import org.lamsfoundation.lams.tool.wiki.web.forms.AuthoringForm; import org.lamsfoundation.lams.util.FileValidatorUtil; import org.lamsfoundation.lams.util.WebUtil; -import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; /** * This action handles all the authoring actions, which include opening author, * saving, uploading instruction files and all the wikipage actions * - * It inherits from the WikiPageAction which inherits from the + * It inherits from the WikiPageAction which inherits from the * LamsDispatchAction so that common actions can be used in learner, monitor and * author * @@ -79,16 +75,11 @@ * * @struts.action path="/authoring" name="authoringForm" parameter="dispatch" * scope="request" validate="false" - * * @struts.action-forward name="success" path="tiles:/authoring/main" * @struts.action-forward name="compareWiki" path="/pages/wiki/compare.jsp" * @struts.action-forward name="viewWiki" path="/pages/wiki/viewWiki.jsp" * @struts.action-forward name="message_page" path="tiles:/generic/message" */ -/** - * @author lfoxton - * - */ public class AuthoringAction extends WikiPageAction { private static Logger logger = Logger.getLogger(AuthoringAction.class); @@ -171,7 +162,7 @@ } WikiPageDTO currentPageDTO = new WikiPageDTO(currentWikiPage); request.setAttribute(WikiConstants.ATTR_CURRENT_WIKI, currentPageDTO); - + // Reset the isEditable field for the form authForm.setIsEditable(currentPageDTO.getEditable()); @@ -210,7 +201,7 @@ authForm.setCurrentWikiPageId(currentWikiPageId); return unspecified(mapping, authForm, request, response); } - + /** * Implements the abstract method, since this is author we return null here * as there is no user @@ -223,7 +214,7 @@ /** * Saves the Wiki content including uploaded files and advance options * - * The WikiPage content is not saved here as that is done in the + * The WikiPage content is not saved here as that is done in the * WikiPageAction * * @param mapping @@ -375,6 +366,7 @@ /** * Delete a file + * * @param mapping * @param authForm * @param type @@ -470,6 +462,7 @@ wiki.setAllowLearnerInsertLinks(authForm.isAllowLearnerInsertLinks()); wiki.setReflectOnActivity(authForm.isReflectOnActivity()); wiki.setReflectInstructions(authForm.getReflectInstructions()); + wiki.setNotifyUpdates(authForm.isNotifyUpdates()); wiki.setMaximumEdits(authForm.getMaximumEdits()); wiki.setMinimumEdits(authForm.getMinimumEdits()); } @@ -494,6 +487,7 @@ authForm.setMaximumEdits(wiki.getMaximumEdits()); authForm.setMinimumEdits(wiki.getMinimumEdits()); authForm.setNewPageIsEditable(true); + authForm.setNotifyUpdates(wiki.isNotifyUpdates()); } /** Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/LearningAction.java =================================================================== diff -u -rbec4861a186a6a8972771f054c3fa1fb0f51da72 -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/LearningAction.java (.../LearningAction.java) (revision bec4861a186a6a8972771f054c3fa1fb0f51da72) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/LearningAction.java (.../LearningAction.java) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -36,6 +36,7 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.ToolAccessMode; @@ -65,7 +66,7 @@ * This action handles all the learning actions, which include opening learner, * relection, going to the next activity, and all the wikipage actions * - * It inherits from the WikiPageAction which inherits from the + * It inherits from the WikiPageAction which inherits from the * LamsDispatchAction so that common actions can be used in learner, monitor and * author * @@ -90,8 +91,8 @@ private IWikiService wikiService; /** - * unspecified loads the learner window with the current wiki page - * as well as setting all the advanced options and user-specifice info + * unspecified loads the learner window with the current wiki page as well + * as setting all the advanced options and user-specifice info */ protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -142,6 +143,7 @@ return mapping.findForward("runOffline"); } + // get the user WikiUser wikiUser; if (mode.equals(ToolAccessMode.TEACHER)) { Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); @@ -150,6 +152,7 @@ wikiUser = getCurrentUser(toolSessionID); } + // Create the userDTO WikiUserDTO wikiUserDTO = new WikiUserDTO(wikiUser); if (wikiUser.isFinishedActivity()) { // get the notebook entry. @@ -159,8 +162,19 @@ wikiUserDTO.setNotebookEntry(notebookEntry.getEntry()); } } + + // Set whether the user has enabled notifications + if (wikiService.getEventNotificationService().eventExists(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID) + && wikiService.getEventNotificationService().isSubscribed(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID, wikiUser.getUserId().longValue())) { + + wikiUserDTO.setNotificationEnabled(true); + } + + // add the userDTO to attributes request.setAttribute(WikiConstants.ATTR_USER_DTO, wikiUserDTO); - + // Set whether user has reached maximum edits int maxEdits = wiki.getMaximumEdits(); Boolean maxEditsReached = (maxEdits != 0 && wikiUser.getWikiEdits() >= maxEdits); @@ -174,16 +188,11 @@ // Get the wikipages from the session and the main page SortedSet wikiPageDTOs = new TreeSet(); - // WikiPage mainPage = null; for (WikiPage wikiPage : wikiSession.getWikiPages()) { WikiPageDTO pageDTO = new WikiPageDTO(wikiPage); wikiPageDTOs.add(pageDTO); - // Set the main page - // if (wikiPage.getTitle().equals(wiki.getMainPage().getTitle())) { - // mainPage = wikiPage; - // } } request.setAttribute(WikiConstants.ATTR_WIKI_PAGES, wikiPageDTOs); request.setAttribute(WikiConstants.ATTR_MAIN_WIKI_PAGE, new WikiPageDTO(wikiSession.getMainPage())); @@ -206,7 +215,7 @@ // Set the content folder id request.setAttribute(WikiConstants.ATTR_CONTENT_FOLDER_ID, wikiSession.getContentFolderID()); - + // set readOnly flag. if (mode.equals(ToolAccessMode.TEACHER) || (wiki.isLockOnFinished() && wikiUser.isFinishedActivity())) { request.setAttribute(WikiConstants.ATTR_CONTENT_EDITAVLE, false); @@ -248,10 +257,11 @@ return wikiUser; } - + /** - * Finish the activity, we dont need to save anything here, as that is - * done by the wikipage actions + * Finish the activity, we dont need to save anything here, as that is done + * by the wikipage actions + * * @param mapping * @param form * @param request @@ -292,6 +302,7 @@ /** * Opens the notebook page for reflections + * * @param mapping * @param form * @param request @@ -321,6 +332,7 @@ /** * Submit reflections + * * @param mapping * @param form * @param request Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/MonitoringAction.java =================================================================== diff -u -rbec4861a186a6a8972771f054c3fa1fb0f51da72 -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision bec4861a186a6a8972771f054c3fa1fb0f51da72) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -29,11 +29,13 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.wiki.dto.WikiDTO; @@ -108,7 +110,7 @@ Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); wikiDT0.setCurrentTab(currentTab); - + request.setAttribute(WikiConstants.ATTR_WIKI_DTO, wikiDT0); request.setAttribute(WikiConstants.ATTR_CONTENT_FOLDER_ID, contentFolderID); return mapping.findForward("success"); Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java =================================================================== diff -u -r98272e08314f1487800201921390914652849147 -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java (.../WikiPageAction.java) (revision 98272e08314f1487800201921390914652849147) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java (.../WikiPageAction.java) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -24,13 +24,18 @@ package org.lamsfoundation.lams.tool.wiki.web.actions; +import java.net.URLEncoder; +import java.util.List; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.wiki.dto.WikiPageContentDTO; import org.lamsfoundation.lams.tool.wiki.dto.WikiPageDTO; @@ -43,8 +48,13 @@ import org.lamsfoundation.lams.tool.wiki.service.WikiServiceProxy; import org.lamsfoundation.lams.tool.wiki.util.WikiConstants; import org.lamsfoundation.lams.tool.wiki.web.forms.WikiPageForm; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; /** @@ -103,36 +113,44 @@ // Get the current wiki page WikiPage currentPage = wikiService.getWikiPageByUid(currentPageUid); - // Set up the wiki user if this is a tool session (learner) - // Also set the editable flag here - Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); - WikiUser user = null; - if (toolSessionID != null) { - user = this.getCurrentUser(toolSessionID); - } + // Check if the content is different + if (!currentPage.getCurrentWikiContent().getBody().equals(wikiForm.getWikiBody())) { - // Setting the editable flag based on call origin - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true); - if (mode == null || mode==ToolAccessMode.TEACHER) - { - // Author/Monitor/Live edit - // If no editable flag came in the form (as in learner), set false - if (wikiForm.getIsEditable() == null) { - wikiForm.setIsEditable(false); + // Set up the wiki user if this is a tool session (learner) + // Also set the editable flag here + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + WikiUser user = null; + if (toolSessionID != null) { + user = this.getCurrentUser(toolSessionID); } - } - else - { - // Learner or preview - // If no editable flag came in the form (as in learner), set true - if (wikiForm.getIsEditable() == null) { - wikiForm.setIsEditable(true); + + // Setting the editable flag based on call origin + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true); + if (mode == null || mode == ToolAccessMode.TEACHER) { + + // Author/Monitor/Live edit + // If no editable flag came in the form (as in learner), set + // false + if (wikiForm.getIsEditable() == null) { + wikiForm.setIsEditable(false); + } + } else { + // Learner or preview If no editable flag came in the form + // (as in learner), set true + if (wikiForm.getIsEditable() == null) { + wikiForm.setIsEditable(true); + } } - } - // Updating the wikiPage, setting a null user which indicated this - // change was made in author - wikiService.updateWikiPage(wikiForm, currentPage, user); + // Updating the wikiPage, setting a null user which indicated + // this change was made in author + wikiService.updateWikiPage(wikiForm, currentPage, user); + // Send edit notifications + if (toolSessionID != null && user != null) { + notifyWikiChange(toolSessionID, "notify.pageEdited.subject", "notify.pageEdited.body", user, request); + } + + } // Make sure the current page is set correctly then return to the wiki return returnToWiki(mapping, wikiForm, request, response, currentPageUid); } @@ -295,10 +313,9 @@ // Get the page to change to wikiPage = wikiService.getWikiBySessionAndTitle(session, newPageName); } - - if (wikiPage == null) - { - //TODO: Error handling page does not exist + + if (wikiPage == null) { + // TODO: Error handling page does not exist } // go through unspecified to display the author screen, using wrapper @@ -343,22 +360,18 @@ session = wikiService.getSessionBySessionId(toolSessionID); wiki = session.getWiki(); user = getCurrentUser(toolSessionID); - - + } - + // Setting the editable flag based on call origin ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true); - if (mode == null || mode==ToolAccessMode.TEACHER) - { - // Author/Monitor/Live edit + if (mode == null || mode == ToolAccessMode.TEACHER) { + // Author/Monitor/Live edit // If no editable flag came in the form (as in learner), set false if (wikiForm.getNewPageIsEditable() == null) { wikiForm.setNewPageIsEditable(false); } - } - else - { + } else { // Learner or preview // If no editable flag came in the form (as in learner), set true if (wikiForm.getNewPageIsEditable() == null) { @@ -368,10 +381,10 @@ // inserting the wiki page, null user and session indicates that this // page was saved in author - Long currentWikiPageUid = wikiService.insertWikiPage(wikiForm, wiki, user, session); + Long currentPageUid = wikiService.insertWikiPage(wikiForm, wiki, user, session); // go to the new wiki page - return returnToWiki(mapping, wikiForm, request, response, currentWikiPageUid); + return returnToWiki(mapping, wikiForm, request, response, currentPageUid); } /** @@ -403,4 +416,120 @@ return this.returnToWiki(mapping, form, request, response, null); } + + /** + * Toggles whether a learner wants to receive notifications for wiki changes + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward toggleLearnerSubsciption(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // Get the current user + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + + // set up wikiService + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + IEventNotificationService notificationService = wikiService.getEventNotificationService(); + + // first check whether the event exists and create it if it doesnt + if (!notificationService.eventExists(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID)) { + notificationService.createEvent(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID, null, null); + } + + // Get whether the user is subscribed + boolean subscribed = notificationService.isSubscribed(WikiConstants.TOOL_SIGNATURE, + WikiConstants.EVENT_NOTIFY_LEARNERS, toolSessionID, user.getUserID().longValue()); + + if (subscribed) { + // unsubscribe the learner to the event + notificationService.unsubscribe(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID, user.getUserID().longValue()); + } else { + // subscribe the learner to the event + notificationService.subscribe(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID, user.getUserID().longValue(), IEventNotificationService.DELIVERY_METHOD_MAIL, + IEventNotificationService.PERIODICITY_SINGLE); + } + + // go to the new wiki page + return returnToWiki(mapping, (WikiPageForm) form, request, response, currentPageUid); + + } + + private void notifyWikiChange(Long toolSessionID, String subjectLangKey, String bodyLangKey, WikiUser wikiUser, + HttpServletRequest request) throws Exception { + + // set up wikiService + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + WikiSession wikiSession = wikiService.getSessionBySessionId(toolSessionID); + + IEventNotificationService notificationService = wikiService.getEventNotificationService(); + + String subject = wikiService.getLocalisedMessage(subjectLangKey, new Object[] { wikiSession + .getSessionName() }); + String fullName = wikiUser.getFirstName() + " " + wikiUser.getLastName(); + + // Notify all the monitors + if (wikiSession.getWiki().isNotifyUpdates()) { + + List users = wikiService.getMonitorsByToolSessionId(toolSessionID); + Long[] monitoringUsersIds = new Long[users.size()]; + for (int i = 0; i < monitoringUsersIds.length; i++) { + monitoringUsersIds[i] = users.get(i).getUserId().longValue(); + } + + String relativePath = "/tool/" + WikiConstants.TOOL_SIGNATURE + + "/monitoring.do?dispatch=showWiki&toolSessionID=" + toolSessionID.toString(); + + String link = Configuration.get(ConfigurationKeys.SERVER_URL) + "r.do?" + + "r=" + URLEncoder.encode(relativePath, "UTF-8") + + "&t=" + toolSessionID.toString() + + "&a=t"; + + String body = wikiService.getLocalisedMessage(bodyLangKey, new Object[] { fullName, + wikiSession.getSessionName(), link }); + + notificationService.sendMessage(monitoringUsersIds, IEventNotificationService.DELIVERY_METHOD_MAIL, + subject, body); + } + + // trigger the event if exists for all the learners who are subscribed + if (notificationService.eventExists(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID)) { + + String relativePath = "/tool/" + WikiConstants.TOOL_SIGNATURE + + "/learning.do?mode=learner&toolSessionID=" + toolSessionID.toString(); + + String link = Configuration.get(ConfigurationKeys.SERVER_URL) + "r.do?" + + "r=" + URLEncoder.encode(relativePath, "UTF-8") + + "&t=" + toolSessionID.toString() + + "&a=l"; + + String body = wikiService.getLocalisedMessage(bodyLangKey, new Object[] { fullName, + wikiSession.getSessionName(), link }); + + notificationService.trigger(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, toolSessionID, + subject, body); + } + + + + } } Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/AuthoringForm.java =================================================================== diff -u -r1082bdcc357c105126a5641cecc68acfa645b66b -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 1082bdcc357c105126a5641cecc68acfa645b66b) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -54,6 +54,8 @@ boolean allowLearnerInsertLinks; boolean allowLearnerAttachImages; + + boolean notifyUpdates; boolean reflectOnActivity; @@ -194,7 +196,15 @@ public void setAllowLearnerAttachImages(boolean allowLearnerAttachImages) { this.allowLearnerAttachImages = allowLearnerAttachImages; } + + public boolean isNotifyUpdates() { + return notifyUpdates; + } + public void setNotifyUpdates(boolean notifyUpdates) { + this.notifyUpdates = notifyUpdates; + } + public boolean isReflectOnActivity() { return reflectOnActivity; } Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/wikiApplicationContext.xml =================================================================== diff -u -r1082bdcc357c105126a5641cecc68acfa645b66b -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/wikiApplicationContext.xml (.../wikiApplicationContext.xml) (revision 1082bdcc357c105126a5641cecc68acfa645b66b) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/wikiApplicationContext.xml (.../wikiApplicationContext.xml) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -43,6 +43,9 @@ + + + @@ -96,5 +99,13 @@ + + + + + org.lamsfoundation.lams.tool.wiki.ApplicationResources + + + Index: lams_tool_wiki/web/login.jsp =================================================================== diff -u --- lams_tool_wiki/web/login.jsp (revision 0) +++ lams_tool_wiki/web/login.jsp (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -0,0 +1,22 @@ +<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ page import="org.lamsfoundation.lams.security.JspRedirectStrategy" %> + + +gyig +<% +if(true) +{ + return; +} +%> +fufy + + + Fisheye: Tag f08d91b95c1892c71594dd4f7fd6e9b4509cccc7 refers to a dead (removed) revision in file `lams_tool_wiki/web/pages/aa.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_wiki/web/pages/authoring/advanced.jsp =================================================================== diff -u -r16b67860ab51e6ba2a8f91220dda61d67334e1b0 -rf08d91b95c1892c71594dd4f7fd6e9b4509cccc7 --- lams_tool_wiki/web/pages/authoring/advanced.jsp (.../advanced.jsp) (revision 16b67860ab51e6ba2a8f91220dda61d67334e1b0) +++ lams_tool_wiki/web/pages/authoring/advanced.jsp (.../advanced.jsp) (revision f08d91b95c1892c71594dd4f7fd6e9b4509cccc7) @@ -24,6 +24,12 @@ styleId="allowLearnerAttachImages">

+ +