Index: lams_tool_forum/conf/language/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/conf/language/Attic/ApplicationResources.properties,v diff -u -r1.18 -r1.19 --- lams_tool_forum/conf/language/ApplicationResources.properties 11 Aug 2006 07:00:13 -0000 1.18 +++ lams_tool_forum/conf/language/ApplicationResources.properties 22 Aug 2006 04:50:34 -0000 1.19 @@ -66,7 +66,7 @@ errors.footer = error.valueReqd =Value Required error.inputFileTooLarge =Input File size is too large! -error.uploading =error uploading +error.uploading =Error on uploading error.mark.needNumber =Mark must be int value error.mark.invalid.number =Mark is invalid number format error.fail.get.forum =No Forum available Index: lams_tool_forum/conf/xdoclet/struts-actions.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/conf/xdoclet/struts-actions.xml,v diff -u -r1.38 -r1.39 --- lams_tool_forum/conf/xdoclet/struts-actions.xml 18 Aug 2006 06:59:44 -0000 1.38 +++ lams_tool_forum/conf/xdoclet/struts-actions.xml 22 Aug 2006 04:50:34 -0000 1.39 @@ -145,6 +145,8 @@ @@ -191,20 +193,19 @@ scope="request"> + + + + + - - - 0){ + List delTopicAtt = getTopicDeletedAttachmentList(sessionMap); + delTopicAtt.add(att.iterator().next()); + } newMsg.setHasAttachment(false); newMsg.getMessage().setAttachments(null); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ExportServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ExportServlet.java,v diff -u -r1.6 -r1.7 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ExportServlet.java 10 Aug 2006 07:13:42 -0000 1.6 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ExportServlet.java 22 Aug 2006 04:50:35 -0000 1.7 @@ -129,7 +129,7 @@ request.getSession().setAttribute(ForumConstants.ATTR_TOOL_CONTENT_TOPICS, sessionTopicMap); //set forum title - request.setAttribute(ForumConstants.FORUM_TITLE, session.getForum().getTitle()); + request.setAttribute(ForumConstants.ATTR_FORUM_TITLE, session.getForum().getTitle()); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java,v diff -u -r1.38 -r1.39 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java 9 Aug 2006 07:09:27 -0000 1.38 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java 22 Aug 2006 04:50:34 -0000 1.39 @@ -64,6 +64,7 @@ import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -111,13 +112,12 @@ if (param.equals("updateTopic")) { return updateTopic(mapping, form, request, response); } - if (param.equals("updateMessageHideFlag")) { - return updateMessageHideFlag(mapping, form, request, response); - } if (param.equals("deleteAttachment")) { return deleteAttachment(mapping, form, request, response); } - + if (param.equals("updateMessageHideFlag")) { + return updateMessageHideFlag(mapping, form, request, response); + } return mapping.findForward("error"); } @@ -131,50 +131,44 @@ */ private ActionForward viewForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + + //initial Session Map + String sessionMapID = request.getParameter(ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap; + //refresh forum page, not initial enter + if(sessionMapID != null){ + sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + }else{ + sessionMap = new SessionMap(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + } + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + // set the mode into http session ToolAccessMode mode = null; try { - mode = WebUtil.readToolAccessModeParam(request, - AttributeNames.PARAM_MODE, MODE_OPTIONAL); - request.getSession().setAttribute(AttributeNames.ATTR_MODE, mode); + mode = WebUtil.readToolAccessModeParam(request,AttributeNames.PARAM_MODE, MODE_OPTIONAL); } catch (Exception exp) { - // check wether it already existed in Session - mode = (ToolAccessMode) request.getSession().getAttribute( - AttributeNames.ATTR_MODE); + //set it as default mode + mode = ToolAccessMode.LEARNER; } if (mode == null) { throw new ForumException("Mode is required."); } // get sessionId from HttpServletRequest - String sessionIdStr = request - .getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); - Long sessionId; - if (StringUtils.isEmpty(sessionIdStr)) - // if SessionID in request is empty, then try to get it from - // session. This happens when client "refresh" - // page after create a new topic - sessionId = (Long) request.getSession().getAttribute( - AttributeNames.PARAM_TOOL_SESSION_ID); - else - sessionId = new Long(Long.parseLong(sessionIdStr)); - // cache this sessionId into HttpSession - request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, - sessionId); + Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); // Try to get ForumID according to sessionId forumService = getForumManager(); - ForumToolSession session = forumService - .getSessionBySessionId(sessionId); + ForumToolSession session = forumService.getSessionBySessionId(sessionId); if (session == null || session.getForum() == null) { - log.error("Failed on getting session by given sessionID:" - + sessionId); + log.error("Failed on getting session by given sessionID:" + sessionId); return mapping.findForward("error"); } boolean lock = session.getForum().getLockWhenFinished(); lock = lock && (session.getStatus() == ForumConstants.SESSION_STATUS_FINISHED ? true : false); - request.getSession().setAttribute(ForumConstants.FINISHEDLOCK, new Boolean(lock)); Forum forum = session.getForum(); //add define later support @@ -190,21 +184,19 @@ Boolean allowRichEditor = new Boolean(forum.isAllowRichEditor()); int allowNumber = forum.getLimitedChar(); - request.getSession().setAttribute(ForumConstants.FORUM_ID, forumId); - request.getSession().setAttribute(ForumConstants.ALLOW_EDIT, forum.isAllowEdit()); - request.getSession().setAttribute(ForumConstants.ATTR_ALLOW_UPLOAD,forum.isAllowUpload()); - request.getSession().setAttribute(ForumConstants.ATTR_ALLOW_NEW_TOPICS,forum.isAllowNewTopic()); + sessionMap.put(ForumConstants.FORUM_ID, forumId); + sessionMap.put(AttributeNames.ATTR_MODE, mode); + sessionMap.put(ForumConstants.ATTR_FINISHED_LOCK, new Boolean(lock)); + sessionMap.put(ForumConstants.ATTR_ALLOW_EDIT, forum.isAllowEdit()); + sessionMap.put(ForumConstants.ATTR_ALLOW_UPLOAD,forum.isAllowUpload()); + sessionMap.put(ForumConstants.ATTR_ALLOW_NEW_TOPICS,forum.isAllowNewTopic()); + sessionMap.put(ForumConstants.ATTR_ALLOW_RICH_EDITOR,allowRichEditor); + sessionMap.put(ForumConstants.ATTR_LIMITED_CHARS,new Integer(allowNumber)); + sessionMap.put(ForumConstants.ATTR_FORUM_TITLE,forum.getTitle()); + sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId); + sessionMap.put(ForumConstants.ATTR_FORUM_INSTRCUTION,forum.getInstructions()); - request.getSession().setAttribute(ForumConstants.ALLOW_RICH_EDITOR, - allowRichEditor); - request.getSession().setAttribute(ForumConstants.LIMITED_CHARS, - new Integer(allowNumber)); - - // get all root topic to display on init page - request.setAttribute(ForumConstants.ATTR_FORUM_TITLE,forum.getTitle()); - request.setAttribute(ForumConstants.ATTR_FORUM_INSTRCUTION,forum.getInstructions()); - List rootTopics = forumService.getRootTopics(sessionId); request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); @@ -216,27 +208,6 @@ return mapping.findForward("success"); } - /** - * Display empty page for a new topic in forum - * - * @param mapping - * @param form - * @param request - * @param response - * @return - */ - private ActionForward newTopic(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) { - Long sessionId = (Long) request.getSession().getAttribute( - AttributeNames.PARAM_TOOL_SESSION_ID); - forumService = getForumManager(); - ForumToolSession session = forumService - .getSessionBySessionId(sessionId); - - Forum forum = session.getForum(); - request.setAttribute(ForumConstants.FORUM_TITLE,forum.getTitle()); - return mapping.findForward("success"); - } /** * Learner click "finish" button in forum page, this method will turn on @@ -250,14 +221,12 @@ */ private ActionForward finish(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long sessionId = (Long) request.getSession().getAttribute( - AttributeNames.PARAM_TOOL_SESSION_ID); - ToolAccessMode mode = (ToolAccessMode) request.getSession() - .getAttribute(AttributeNames.ATTR_MODE); + Long sessionId = WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_SESSION_ID); + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request,AttributeNames.PARAM_MODE, MODE_OPTIONAL); - forumService = getForumManager(); - ForumToolSession session = forumService.getSessionBySessionId(sessionId); if (mode == ToolAccessMode.LEARNER || mode==ToolAccessMode.AUTHOR) { + forumService = getForumManager(); + ForumToolSession session = forumService.getSessionBySessionId(sessionId); Forum forum = session.getForum(); // get session from shared session. HttpSession ss = SessionManager.getSession(); @@ -270,8 +239,6 @@ errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("error.less.mini.post",(forum.getMinimumReply() - postNum))); saveErrors(request, errors); // get all root topic to display on init page - request.setAttribute(ForumConstants.ATTR_FORUM_TITLE,forum.getTitle()); - request.setAttribute(ForumConstants.ATTR_FORUM_INSTRCUTION,forum.getInstructions()); List rootTopics = forumService.getRootTopics(sessionId); request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); return mapping.findForward("success"); @@ -297,8 +264,6 @@ // get all root topic to display on init page List rootTopics = forumService.getRootTopics(sessionId); request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); - if(session != null) - request.setAttribute(ForumConstants.FORUM_TITLE,session.getForum().getTitle()); return mapping.findForward("success"); } @@ -319,25 +284,43 @@ */ private ActionForward viewTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long topicId = new Long(WebUtil.readLongParam(request, "topicId")); - + + Long rootTopicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); forumService = getForumManager(); // get root topic list - List msgDtoList = forumService.getTopicThread(topicId); - - setAuthorMark(msgDtoList); - - + List msgDtoList = forumService.getTopicThread(rootTopicId); + updateMesssageFlag(msgDtoList); request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); - String title = getForumTitle(msgDtoList); - request.setAttribute(ForumConstants.FORUM_TITLE,title); - request.getSession().setAttribute(ForumConstants.ROOT_TOPIC_UID,topicId); + + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + + //transfer SessionMapID as well + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return mapping.findForward("success"); } + /** + * Display empty page for a new topic in forum + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward newTopic(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) { + //transfer SessionMapID as well + ((MessageForm)form).setSessionMapID(WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID)); + return mapping.findForward("success"); + } + /** * Create a new root topic. * @@ -355,36 +338,33 @@ throws IOException, ServletException, PersistenceException { MessageForm messageForm = (MessageForm) form; + SessionMap sessionMap = getSessionMap(request, messageForm); + Long forumId = (Long) sessionMap.get(ForumConstants.FORUM_ID); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); Message message = messageForm.getMessage(); message.setIsAuthored(false); message.setCreated(new Date()); message.setUpdated(new Date()); message.setLastReplyDate(new Date()); - ForumUser forumUser = getCurrentUser(request); + ForumUser forumUser = getCurrentUser(request,sessionId); message.setCreatedBy(forumUser); message.setModifiedBy(forumUser); setAttachment(messageForm, message); - + // save message into database forumService = getForumManager(); - Long forumId = (Long) request.getSession().getAttribute( - ForumConstants.FORUM_ID); - Long sessionId = (Long) request.getSession().getAttribute( - AttributeNames.PARAM_TOOL_SESSION_ID); forumService.createRootTopic(forumId, sessionId, message); // echo back current root topic to fourm init page - Forum forum = forumService.getForum(forumId); - request.setAttribute(ForumConstants.ATTR_FORUM_TITLE,forum.getTitle()); - request.setAttribute(ForumConstants.ATTR_FORUM_INSTRCUTION,forum.getInstructions()); - List rootTopics = forumService.getRootTopics(sessionId); request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,messageForm.getSessionMapID()); return mapping.findForward("success"); } + /** * Dipslay replay topic page. Message form subject will include parent * topics same subject. @@ -397,23 +377,22 @@ */ private ActionForward newReplyTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long parentId = new Long(WebUtil.readLongParam(request, "parentId")); + String sessionMapID = request.getParameter(ForumConstants.ATTR_SESSION_MAP_ID); + MessageForm msgForm = (MessageForm) form; + msgForm.setSessionMapID(sessionMapID); + + Long parentId = WebUtil.readLongParam(request, ForumConstants.ATTR_PARENT_TOPIC_ID); // get parent topic, it can decide default subject of reply. MessageDTO topic = getTopic(parentId); if (topic != null && topic.getMessage() != null) { // echo back current topic subject to web page - MessageForm msgForm = (MessageForm) form; - msgForm.getMessage().setSubject( - "Re:" + topic.getMessage().getSubject()); + msgForm.getMessage().setSubject("Re:" + topic.getMessage().getSubject()); } - - // cache this parentId in order to create reply - request.getSession().setAttribute("parentId", parentId); + SessionMap sessionMap = getSessionMap(request, msgForm); + sessionMap.put(ForumConstants.ATTR_PARENT_TOPIC_ID, parentId); - String title = getForumTitle(topic); - request.setAttribute(ForumConstants.FORUM_TITLE,title); return mapping.findForward("success"); } @@ -429,43 +408,44 @@ */ private ActionForward replyTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long parentId = (Long) request.getSession().getAttribute("parentId"); - Long sessionId = (Long) request.getSession().getAttribute( - AttributeNames.PARAM_TOOL_SESSION_ID); + MessageForm messageForm = (MessageForm) form; + SessionMap sessionMap = getSessionMap(request, messageForm); + Long parentId = (Long) sessionMap.get(ForumConstants.ATTR_PARENT_TOPIC_ID); + Long sessionId =(Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + Message message = messageForm.getMessage(); message.setIsAuthored(false); message.setCreated(new Date()); message.setUpdated(new Date()); message.setLastReplyDate(new Date()); - ForumUser forumUser = getCurrentUser(request); + ForumUser forumUser = getCurrentUser(request,sessionId); message.setCreatedBy(forumUser); message.setModifiedBy(forumUser); setAttachment(messageForm, message); + // save message into database forumService = getForumManager(); forumService.replyTopic(parentId, sessionId, message); // echo back this topic thread into page Long rootTopicId = forumService.getRootTopicId(parentId); List msgDtoList = forumService.getTopicThread(rootTopicId); - setAuthorMark(msgDtoList); + updateMesssageFlag(msgDtoList); request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,messageForm.getSessionMapID()); - String title = getForumTitle(msgDtoList); - request.setAttribute(ForumConstants.FORUM_TITLE,title); - //check whether allow more posts for this user ForumToolSession session = forumService.getSessionBySessionId(sessionId); Forum forum = session.getForum(); if(forum != null){ if(!forum.isAllowNewTopic()){ int posts = forumService.getTopicsNum(forumUser.getUserId(), sessionId); if(posts >= forum.getMaximumReply()) - request.getSession().setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, Boolean.TRUE); + sessionMap.put(ForumConstants.ATTR_NO_MORE_POSTS, Boolean.TRUE); } } return mapping.findForward("success"); @@ -484,23 +464,46 @@ public ActionForward editTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws PersistenceException { - Long topicId = new Long(WebUtil.readLongParam(request, "topicId")); + Long topicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); MessageDTO topic = getTopic(topicId); + // echo current topic content to web page + MessageForm msgForm = (MessageForm) form; if (topic != null) { - MessageForm msgForm = (MessageForm) form; msgForm.setMessage(topic.getMessage()); request.setAttribute(ForumConstants.AUTHORING_TOPIC, topic); } - // cache this topicId in order to create reply - request.getSession().setAttribute("topicId", topicId); + //cache this topicID, using in Update topic + SessionMap sessionMap = getSessionMap(request, msgForm); + sessionMap.put(ForumConstants.ATTR_TOPIC_ID, topicId); - String title = getForumTitle(topic); - request.setAttribute(ForumConstants.FORUM_TITLE,title); return mapping.findForward("success"); } + /** + * Delete attachment from topic. This method only reset attachment information in memory. The finally update + * will happen in updateTopic method. So topic can keep this attachment if user choose "Cancel" edit + * topic. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward deleteAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + //only reset not attachment flag. + MessageDTO dto = new MessageDTO(); + dto.setHasAttachment(false); + request.setAttribute(ForumConstants.AUTHORING_TOPIC, dto); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID)); + request.setAttribute(ForumConstants.ATTR_ALLOW_UPLOAD, sessionMap.get(ForumConstants.ATTR_ALLOW_UPLOAD)); + + return mapping.findForward("success"); + } /** * Update a topic. @@ -515,15 +518,15 @@ public ActionForward updateTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws PersistenceException { - // get value from HttpSession - Long topicId = (Long) request.getSession().getAttribute("topicId"); - - forumService = getForumManager(); + forumService = getForumManager(); + MessageForm messageForm = (MessageForm) form; - Message message = messageForm.getMessage(); + SessionMap sessionMap = getSessionMap(request, messageForm); + Long topicId = (Long) sessionMap.get(ForumConstants.ATTR_TOPIC_ID); + Message message = messageForm.getMessage(); - boolean makeAuditEntry = ToolAccessMode.TEACHER.equals((ToolAccessMode) request.getSession().getAttribute(AttributeNames.ATTR_MODE)); + boolean makeAuditEntry = ToolAccessMode.TEACHER.equals((ToolAccessMode)sessionMap.get(AttributeNames.ATTR_MODE)); String oldMessageString = null; // get PO from database and sync with Form @@ -534,7 +537,7 @@ messagePO.setSubject(message.getSubject()); messagePO.setBody(message.getBody()); messagePO.setUpdated(new Date()); - messagePO.setModifiedBy(getCurrentUser(request)); + messagePO.setModifiedBy(getCurrentUser(request,(Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID))); setAttachment(messageForm, messagePO); if ( makeAuditEntry ) { @@ -548,16 +551,17 @@ forumService.updateTopic(messagePO); // echo back this topic thread into page - forumService = getForumManager(); Long rootTopicId = forumService.getRootTopicId(topicId); List msgDtoList = forumService.getTopicThread(rootTopicId); - setAuthorMark(msgDtoList); + updateMesssageFlag(msgDtoList); request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); - + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,messageForm.getSessionMapID()); + return mapping.findForward("success"); } + /** * Sets the visibility of a message by updating the hide flag for a message * @@ -571,21 +575,20 @@ ActionForm form, HttpServletRequest request, HttpServletResponse response) { - Long msgId = new Long(WebUtil.readLongParam(request, "msgId")); + Long msgId = new Long(WebUtil.readLongParam(request,ForumConstants.ATTR_TOPIC_ID)); Boolean hideFlag = new Boolean(WebUtil.readBooleanParam(request, "hideFlag")); forumService = getForumManager(); + // TODO Skipping permissions for now, currently having issues with default learning designs not having an create_by field +// Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); // check if the user has permission to hide posts. - Long sessionId = (Long) request.getSession().getAttribute( - AttributeNames.PARAM_TOOL_SESSION_ID); - ForumToolSession toolSession = forumService - .getSessionBySessionId(sessionId); - - Forum forum = toolSession.getForum(); - ForumUser currentUser = getCurrentUser(request); - ForumUser forumCreatedBy = forum.getCreatedBy(); +// ForumToolSession toolSession = forumService +// .getSessionBySessionId(sessionId); +// +// Forum forum = toolSession.getForum(); +// ForumUser currentUser = getCurrentUser(request,sessionId); +// ForumUser forumCreatedBy = forum.getCreatedBy(); - // TODO Skipping permissions for now, currently having issues with default learning designs not having an create_by field // we should be looking at whether a user is a teacher and more specifically staff // if (currentUser.getUserId().equals(forumCreatedBy.getUserId())) { forumService.updateMessageHideFlag(msgId, hideFlag.booleanValue()); @@ -596,76 +599,26 @@ // echo back this topic thread into page - forumService = getForumManager(); Long rootTopicId = forumService.getRootTopicId(msgId); List msgDtoList = forumService.getTopicThread(rootTopicId); - setAuthorMark(msgDtoList); + updateMesssageFlag(msgDtoList); request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); - - String title = getForumTitle(msgDtoList); - request.setAttribute(ForumConstants.FORUM_TITLE,title); - return mapping.findForward("success"); - } + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,WebUtil.readLongParam(request,ForumConstants.ATTR_SESSION_MAP_ID)); - /** - * Only delete the attachemnt file for current topic. - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws PersistenceException - */ - public ActionForward deleteAttachment(ActionMapping mapping, - ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws PersistenceException { - // get value from HttpSession - Long topicId = (Long) request.getSession().getAttribute("topicId"); - Long versionID = new Long(WebUtil.readLongParam(request, "versionID")); - Long uuID = new Long(WebUtil.readLongParam(request, "uuid")); - forumService = getForumManager(); - forumService.deleteFromRepository(uuID, versionID); - - boolean makeAuditEntry = ToolAccessMode.TEACHER.equals((ToolAccessMode) request.getSession().getAttribute(AttributeNames.ATTR_MODE)); - String oldMessageString = null; - - // get value from HttpSession - Message messagePO = forumService.getMessage(topicId); - if ( makeAuditEntry ) { - oldMessageString = messagePO.toString(); - } - messagePO.setUpdated(new Date()); - messagePO.setModifiedBy(getCurrentUser(request)); - Set atts = messagePO.getAttachments(); - if(atts != null) - atts.clear(); - - if ( makeAuditEntry ) { - forumService.getAuditService().logChange(ForumConstants.TOOL_SIGNATURE, - messagePO.getCreatedBy().getUserId(), messagePO.getCreatedBy().getLoginName(), - oldMessageString, messagePO.toString()); - } - - // save message into database - forumService.updateTopic(messagePO); - - String title = getForumTitle(messagePO); - request.setAttribute(ForumConstants.FORUM_TITLE,title); return mapping.findForward("success"); } - // ========================================================================================== // Utility methods // ========================================================================================== /** - * If this topic is created by current login user, then set Author mark - * true. + * This method will set flag in message DTO: + *
  • If this topic is created by current login user, then set Author mark + * true.
  • * * @param msgDtoList */ - private void setAuthorMark(List msgDtoList) { + private void updateMesssageFlag(List msgDtoList) { // set current user to web page, so that can display "edit" button // correct. Only author alow to edit. HttpSession ss = SessionManager.getSession(); @@ -692,8 +645,7 @@ private MessageDTO getTopic(Long topicId) { // get Topic content according to TopicID forumService = getForumManager(); - MessageDTO topic = MessageDTO.getMessageDTO(forumService - .getMessage(topicId)); + MessageDTO topic = MessageDTO.getMessageDTO(forumService.getMessage(topicId)); return topic; } @@ -703,16 +655,14 @@ * instance of PO of ForumUser. * * @param request + * @param sessionId * @return Current user instance */ - private ForumUser getCurrentUser(HttpServletRequest request) { + private ForumUser getCurrentUser(HttpServletRequest request, Long sessionId) { // get login user (author) HttpSession ss = SessionManager.getSession(); // get back login user DTO UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - // check whether this user exist or not - Long sessionId = (Long) request.getSession().getAttribute( - AttributeNames.PARAM_TOOL_SESSION_ID); ForumUser forumUser = forumService.getUserByUserAndSession(new Long( user.getUserID().intValue()), sessionId); if (forumUser == null) { @@ -747,8 +697,7 @@ */ private void setAttachment(MessageForm messageForm, Message message) { if (messageForm.getAttachmentFile() != null - && !StringUtils.isEmpty(messageForm.getAttachmentFile() - .getFileName())) { + && !StringUtils.isBlank(messageForm.getAttachmentFile().getFileName())) { forumService = getForumManager(); Attachment att = forumService.uploadAttachment(messageForm .getAttachmentFile()); @@ -759,39 +708,20 @@ attSet.clear(); attSet.add(att); message.setAttachments(attSet); + }else if(!messageForm.isHasAttachment()){ + //user already called deleteAttachment in AJAX call + if(message.getAttachments() != null){ + Set atts = message.getAttachments(); + atts.clear(); + message.setAttachments(atts); + }else + message.setAttachments(null); } } - - /** - * @param msgDtoList - */ - private String getForumTitle(List msgDtoList) { - String title = ""; - for(MessageDTO msgDto : msgDtoList){ - title = getForumTitle(msgDto); - break; - } - - return title; - } - private String getForumTitle(MessageDTO msgDto) { - Message msg = msgDto.getMessage(); - return getForumTitle(msg); - } - - private String getForumTitle(Message msg) { - String title = ""; - ForumToolSession session = msg.getToolSession(); - Forum forum; - if(session == null){ - forum = msg.getForum(); - }else - forum = session.getForum(); - - if(forum != null) - title = forum.getTitle(); - return title; + private SessionMap getSessionMap(HttpServletRequest request, MessageForm messageForm) { + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(messageForm.getSessionMapID()); + return sessionMap; } } Index: lams_tool_forum/web/WEB-INF/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/WEB-INF/Attic/struts-config.xml,v diff -u -r1.43 -r1.44 --- lams_tool_forum/web/WEB-INF/struts-config.xml 18 Aug 2006 06:59:44 -0000 1.43 +++ lams_tool_forum/web/WEB-INF/struts-config.xml 22 Aug 2006 04:50:35 -0000 1.44 @@ -180,6 +180,8 @@
    @@ -226,20 +228,17 @@ scope="request"> + + + - - - Index: lams_tool_forum/web/includes/learnerLayout.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/includes/learnerLayout.jsp,v diff -u -r1.1 -r1.2 --- lams_tool_forum/web/includes/learnerLayout.jsp 2 Jul 2006 04:14:28 -0000 1.1 +++ lams_tool_forum/web/includes/learnerLayout.jsp 22 Aug 2006 04:50:34 -0000 1.2 @@ -3,11 +3,27 @@ <%@ include file="/common/taglibs.jsp"%> <%@ taglib uri="tags-tiles" prefix="tiles"%> - + + + + + + <bean:message key="activity.title" /> <%@ include file="/common/header.jsp"%> + + + +
    Index: lams_tool_forum/web/includes/javascript/message.js =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/includes/javascript/message.js,v diff -u -r1.1 -r1.2 --- lams_tool_forum/web/includes/javascript/message.js 18 Aug 2006 06:59:44 -0000 1.1 +++ lams_tool_forum/web/includes/javascript/message.js 22 Aug 2006 04:50:35 -0000 1.2 @@ -2,8 +2,9 @@ This is Resource Item instrcution area. */ var itemAttachmentTargetDiv = "itemAttachmentArea"; -// Please set these 2 variables in JSP file for using tag reason: - function removeItemAttachment(idx){ +// Please set these 1 variables in JSP file for using tag reason: +//removeItemAttachmentUrl + function removeItemAttachment(){ //var id = "instructionItem" + idx; //Element.remove(id); var url= removeItemAttachmentUrl; Index: lams_tool_forum/web/jsps/authoring/message/create.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/authoring/message/create.jsp,v diff -u -r1.23 -r1.24 --- lams_tool_forum/web/jsps/authoring/message/create.jsp 18 Aug 2006 06:59:44 -0000 1.23 +++ lams_tool_forum/web/jsps/authoring/message/create.jsp 22 Aug 2006 04:50:34 -0000 1.24 @@ -2,7 +2,6 @@ "http://www.w3.org/TR/html4/strict.dtd"> <%@ include file="/common/taglibs.jsp"%> - <%@ include file="/common/header.jsp"%> Index: lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp,v diff -u -r1.1 -r1.2 --- lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp 18 Aug 2006 06:59:44 -0000 1.1 +++ lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp 22 Aug 2006 04:50:34 -0000 1.2 @@ -8,7 +8,7 @@ - + Index: lams_tool_forum/web/jsps/export/exportportfolio.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/export/exportportfolio.jsp,v diff -u -r1.9 -r1.10 --- lams_tool_forum/web/jsps/export/exportportfolio.jsp 10 Aug 2006 07:13:42 -0000 1.9 +++ lams_tool_forum/web/jsps/export/exportportfolio.jsp 22 Aug 2006 04:50:35 -0000 1.10 @@ -9,7 +9,7 @@

    - ${forum_title} + ${title}

    Index: lams_tool_forum/web/jsps/learning/create.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/create.jsp,v diff -u -r1.8 -r1.9 --- lams_tool_forum/web/jsps/learning/create.jsp 3 Jul 2006 04:34:30 -0000 1.8 +++ lams_tool_forum/web/jsps/learning/create.jsp 22 Aug 2006 04:50:34 -0000 1.9 @@ -1,22 +1,26 @@ -<%@ include file="/includes/taglibs.jsp"%> - -

    - ${forum_title} -

    - -
    - -
    +<%@ include file="/common/taglibs.jsp"%> + + + + + -

    - -

    +

    + ${sessionMap.title} +

    - - - <%@ include file="/jsps/learning/message/topicform.jsp"%> - +
    + +
    + +

    + +

    + + + <%@ include file="/jsps/learning/message/topicform.jsp"%> + +
    -
    - + Index: lams_tool_forum/web/jsps/learning/edit.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/edit.jsp,v diff -u -r1.4 -r1.5 --- lams_tool_forum/web/jsps/learning/edit.jsp 3 Jul 2006 04:34:30 -0000 1.4 +++ lams_tool_forum/web/jsps/learning/edit.jsp 22 Aug 2006 04:50:34 -0000 1.5 @@ -1,25 +1,29 @@ -<%@ include file="/includes/taglibs.jsp"%> - -

    - ${forum_title} -

    - -
    - -
    - -

    - -

    +<%@ include file="/common/taglibs.jsp"%> + + + + + - +

    + ${sessionMap.title} +

    + +
    + +
    + +

    + +

    + + + + <%@ include file="/jsps/learning/message/topiceditform.jsp"%> + +
    - - <%@ include file="/jsps/learning/message/topiceditform.jsp"%> - - -
    - + Index: lams_tool_forum/web/jsps/learning/reply.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/reply.jsp,v diff -u -r1.5 -r1.6 --- lams_tool_forum/web/jsps/learning/reply.jsp 3 Jul 2006 04:34:30 -0000 1.5 +++ lams_tool_forum/web/jsps/learning/reply.jsp 22 Aug 2006 04:50:34 -0000 1.6 @@ -1,22 +1,26 @@ <%@ include file="/includes/taglibs.jsp"%> + + + + + + +

    + ${sessionMap.title} +

    + +
    + +
    + +

    + +

    + + + <%@ include file="/jsps/learning/message/topicreplyform.jsp"%> + +
    +
    -

    - ${forum_title} -

    - -
    - -
    - -

    - -

    - - - - <%@ include file="/jsps/learning/message/topicreplyform.jsp"%> - - -
    - Index: lams_tool_forum/web/jsps/learning/viewforum.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/viewforum.jsp,v diff -u -r1.9 -r1.10 --- lams_tool_forum/web/jsps/learning/viewforum.jsp 9 Aug 2006 07:09:27 -0000 1.9 +++ lams_tool_forum/web/jsps/learning/viewforum.jsp 22 Aug 2006 04:50:34 -0000 1.10 @@ -1,8 +1,8 @@ <%@ include file="/common/taglibs.jsp"%> - +

    - +

    @@ -13,7 +13,7 @@ @@ -30,32 +30,31 @@
    - +
    - - + - + - +
    - - + + - +
    - - + + Index: lams_tool_forum/web/jsps/learning/viewtopic.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/viewtopic.jsp,v diff -u -r1.9 -r1.10 --- lams_tool_forum/web/jsps/learning/viewtopic.jsp 8 Aug 2006 02:32:47 -0000 1.9 +++ lams_tool_forum/web/jsps/learning/viewtopic.jsp 22 Aug 2006 04:50:34 -0000 1.10 @@ -1,12 +1,14 @@ <%@ include file="/common/taglibs.jsp"%> + +

    - ${forum_title} + ${sessionMap.title}

    @@ -20,7 +22,7 @@

    - + Index: lams_tool_forum/web/jsps/learning/message/bodyarea.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/web/jsps/learning/message/bodyarea.jsp,v diff -u -r1.7 -r1.8 --- lams_tool_forum/web/jsps/learning/message/bodyarea.jsp 17 Aug 2006 06:22:54 -0000 1.7 +++ lams_tool_forum/web/jsps/learning/message/bodyarea.jsp 22 Aug 2006 04:50:35 -0000 1.8 @@ -2,7 +2,7 @@

    - +