Index: lams_tool_wiki/build.properties =================================================================== diff -u -r8d32e52903d230f8018ac609041934db7f180e73 -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/build.properties (.../build.properties) (revision 8d32e52903d230f8018ac609041934db7f180e73) +++ lams_tool_wiki/build.properties (.../build.properties) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -3,7 +3,7 @@ signature=lawiki10 #project version -tool.version=20090121 +tool.version=20120315 package=org/lamsfoundation/lams/tool/wiki package.name=org.lamsfoundation.lams.tool.wiki Index: lams_tool_wiki/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -rdb46abfd22650e81e900fbbf9f93cee55421a3fd -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision db46abfd22650e81e900fbbf9f93cee55421a3fd) +++ lams_tool_wiki/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -118,6 +118,9 @@ label.wiki.remove =Remove label.wiki.remove.toolTip =Remove this Wiki page label.wiki.remove.confirm =Are you sure you want to delete this Wiki page? This action cannot be undone. +label.wiki.remove.mark.toolTip =Mark this page as removed +label.wiki.remove.mark.confirm =Are you sure you want to mark this Wiki page as removed? +label.wiki.removed =This page has been removed. label.wiki.pages =Wiki Pages label.wiki.savechanges =Save changes label.wiki.history =History Index: lams_tool_wiki/db/sql/create_lams_tool_wiki.sql =================================================================== diff -u -rf6a03ee21a18654d54498cd94d9f68fbea3b996a -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/db/sql/create_lams_tool_wiki.sql (.../create_lams_tool_wiki.sql) (revision f6a03ee21a18654d54498cd94d9f68fbea3b996a) +++ lams_tool_wiki/db/sql/create_lams_tool_wiki.sql (.../create_lams_tool_wiki.sql) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -15,7 +15,8 @@ uid bigint not null auto_increment, wiki_uid bigint, title varchar(255), - editable bit, + editable bit, + deleted bit DEFAULT 0, wiki_current_content bigint, added_by bigint, wiki_session_uid bigint, Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dao/hibernate/WikiPageDAO.java =================================================================== diff -u -r1082bdcc357c105126a5641cecc68acfa645b66b -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dao/hibernate/WikiPageDAO.java (.../WikiPageDAO.java) (revision 1082bdcc357c105126a5641cecc68acfa645b66b) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dao/hibernate/WikiPageDAO.java (.../WikiPageDAO.java) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -1,8 +1,10 @@ package org.lamsfoundation.lams.tool.wiki.dao.hibernate; import org.hibernate.Query; +import org.hibernate.SQLQuery; import org.lamsfoundation.lams.dao.hibernate.BaseDAO; import org.lamsfoundation.lams.tool.wiki.dao.IWikiPageDAO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageDTO; import org.lamsfoundation.lams.tool.wiki.model.Wiki; import org.lamsfoundation.lams.tool.wiki.model.WikiPage; import org.lamsfoundation.lams.tool.wiki.model.WikiSession; @@ -15,6 +17,11 @@ public static final String GET_BY_SESSION_AND_TITLE = "from tl_lawiki10_wiki_page in class " + WikiPage.class.getName() + " where wiki_session_uid=? AND title=?"; + public static final String REMOVE_WIKI_REFERENCES = "UPDATE tl_lawiki10_wiki_page_content " + + "SET body=REPLACE(body,?,?) WHERE editor IS NULL"; + + public static final String CHANGE_WIKI_JAVASCRIPT_METHOD = "javascript:changeWikiPage('?')"; + public void saveOrUpdate(WikiPage wikiPage) { this.getHibernateTemplate().saveOrUpdate(wikiPage); } @@ -41,4 +48,19 @@ return null; } -} + public void delete(Object object) { + // remove references to the removed page + WikiPage removedWikiPage = (WikiPage) object; + String title = removedWikiPage.getTitle(); + String escapedTitle = WikiPageDTO.javaScriptEscape(title); + String codeToReplace = WikiPageDAO.CHANGE_WIKI_JAVASCRIPT_METHOD.replace("?", escapedTitle); + String replacementCode = "#"; + + SQLQuery query = this.getSession().createSQLQuery(REMOVE_WIKI_REFERENCES); + query.setString(0, codeToReplace); + query.setString(1, replacementCode); + + super.delete(object); + query.executeUpdate(); + } +} \ No newline at end of file Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dbupdates/patch20120315.sql =================================================================== diff -u --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dbupdates/patch20120315.sql (revision 0) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dbupdates/patch20120315.sql (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -0,0 +1,18 @@ +-- SQL statements to update from LAMS 2.2 + +-- Turn off autocommit, so nothing is committed if there is an error +SET AUTOCOMMIT = 0; + +----------------------Put all sql statements below here------------------------- + +SET FOREIGN_KEY_CHECKS=0; + +ALTER TABLE tl_lawiki10_wiki_page ADD COLUMN deleted bit DEFAULT 0 AFTER editable; + +SET FOREIGN_KEY_CHECKS=1; + +----------------------Put all sql statements above here------------------------- + +-- If there were no errors, commit and restore autocommit to on +COMMIT; +SET AUTOCOMMIT = 1; \ No newline at end of file Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dto/WikiPageDTO.java =================================================================== diff -u -re3b4354d83bbeff0b953d1fce2bc3be6323c0b50 -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dto/WikiPageDTO.java (.../WikiPageDTO.java) (revision e3b4354d83bbeff0b953d1fce2bc3be6323c0b50) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/dto/WikiPageDTO.java (.../WikiPageDTO.java) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -8,6 +8,7 @@ private String title; private String javaScriptTitle; private Boolean editable; + private Boolean deleted; private WikiPageContentDTO currentWikiContentDTO; public WikiPageDTO() { @@ -17,6 +18,7 @@ this.uid = wikiPage.getUid(); this.title = wikiPage.getTitle().trim(); this.editable = wikiPage.getEditable(); + this.deleted = wikiPage.getDeleted(); this.currentWikiContentDTO = new WikiPageContentDTO(wikiPage.getCurrentWikiContent()); this.javaScriptTitle = this.javaScriptEscape(wikiPage.getTitle()); } @@ -45,6 +47,14 @@ this.editable = editable; } + public Boolean getDeleted() { + return deleted; + } + + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + public WikiPageContentDTO getCurrentWikiContentDTO() { return currentWikiContentDTO; } @@ -65,7 +75,7 @@ return wikiPageDTO.getUid().compareTo(uid) * -1; } - public String javaScriptEscape(String string) + public static String javaScriptEscape(String string) { String replaced = string.replaceAll("\n", "").replaceAll("\'", "`").replaceAll("\"","\\"");; Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/model/WikiPage.java =================================================================== diff -u -r85945835ae1b4cf10ddf0dbc624fc149ae1394a2 -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/model/WikiPage.java (.../WikiPage.java) (revision 85945835ae1b4cf10ddf0dbc624fc149ae1394a2) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/model/WikiPage.java (.../WikiPage.java) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -22,6 +22,7 @@ private Wiki parentWiki; private String title; private Boolean editable; + private Boolean deleted; private Set wikiContentVersions; private WikiPageContent currentWikiContent; private WikiSession wikiSession; @@ -78,7 +79,19 @@ public void setEditable(Boolean editable) { this.editable = editable; } + + /** + * @hibernate.property column="deleted" length="1" + * + */ + public Boolean getDeleted() { + return deleted; + } + public void setDeleted(Boolean deleted) { + this.deleted = deleted; + } + /** * @hibernate.set lazy="true" inverse="false" cascade="all-delete-orphan" * order-by="uid asc" Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/IWikiService.java =================================================================== diff -u -r6d29456e3a6b018730d32c60729d6f2e693ac55e -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/IWikiService.java (.../IWikiService.java) (revision 6d29456e3a6b018730d32c60729d6f2e693ac55e) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/IWikiService.java (.../IWikiService.java) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -148,6 +148,13 @@ * @param wikiPage */ public void deleteWikiPage(WikiPage wikiPage); + + /** + * Mark an existing wiki page as deleted, but do not remove it for real. + * + * @param wikiPage + */ + public void markWikiPageAsDeleted(WikiPage wikiPage); /** * Gets a wiki page by wiki and title Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java =================================================================== diff -u -r6d29456e3a6b018730d32c60729d6f2e693ac55e -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java (.../WikiService.java) (revision 6d29456e3a6b018730d32c60729d6f2e693ac55e) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/service/WikiService.java (.../WikiService.java) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -739,6 +739,11 @@ public void deleteWikiPage(WikiPage wikiPage) { wikiPageDAO.delete(wikiPage); } + + public void markWikiPageAsDeleted(WikiPage wikiPage) { + wikiPage.setDeleted(true); + wikiPageDAO.saveOrUpdate(wikiPage); + } public void deleteInstructionFile(Long contentID, Long uuid, Long versionID, String type) { wikiDAO.deleteInstructionFile(contentID, uuid, versionID, type); Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java =================================================================== diff -u -re66bdae723516ab13d4a6f81e5f598018f6dbe58 -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision e66bdae723516ab13d4a6f81e5f598018f6dbe58) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -115,7 +115,7 @@ String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, "mode", true); + ToolAccessMode mode = getAccessMode(request); // Set up the authForm. AuthoringForm authForm = (AuthoringForm) form; @@ -156,7 +156,8 @@ if (currentPageUid != null) { currentWikiPage = wikiService.getWikiPageByUid(currentPageUid); } else { - currentWikiPage = wiki.getMainPage(); + // get real instance instead of lazily initialized handler + currentWikiPage = wiki.getMainPage(); } WikiPageDTO currentPageDTO = new WikiPageDTO(currentWikiPage); request.setAttribute(WikiConstants.ATTR_CURRENT_WIKI, currentPageDTO); @@ -174,12 +175,17 @@ // Get the child wiki pages SortedSet wikiPageDTOs = new TreeSet(); for (WikiPage wikiPage : wiki.getWikiPages()) { - wikiPageDTOs.add(new WikiPageDTO(wikiPage)); + // check if page exists in real, not only phantom proxied object + // (happens after removing a wiki page) + wikiPage = wikiService.getWikiPageByUid(wikiPage.getUid()); + if (wikiPage != null) { + wikiPageDTOs.add(new WikiPageDTO(wikiPage)); + } } request.setAttribute(WikiConstants.ATTR_WIKI_PAGES, wikiPageDTOs); // Set up sessionMap - SessionMap map = createSessionMap(wiki, getAccessMode(request), contentFolderID, toolContentID); + SessionMap map = createSessionMap(wiki, mode, contentFolderID, toolContentID); authForm.setSessionMapID(map.getSessionID()); // add the sessionMap to HTTPSession. @@ -189,6 +195,29 @@ return mapping.findForward("success"); } + public ActionForward removePage(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + Wiki wiki = wikiService.getWikiByContentId(toolContentID); + if (wiki.isDefineLater()) { + // Only mark as removed if editing a live version (monitor/live edit) + return super.removePage(mapping, form, request, response); + } + // Completely delete the page + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // set up wikiService + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + WikiPage wikiPage = wikiService.getWikiPageByUid(currentPageUid); + wikiService.deleteWikiPage(wikiPage); + + // return to the main page, by setting the current page to null + return this.returnToWiki(mapping, form, request, response, null); + } + /** * Wrapper method to make sure that the correct wiki is returned to from the WikiPageAction class */ @@ -530,14 +559,11 @@ * @return */ private ToolAccessMode getAccessMode(HttpServletRequest request) { - ToolAccessMode mode; String modeStr = request.getParameter(AttributeNames.ATTR_MODE); if (StringUtils.equalsIgnoreCase(modeStr, ToolAccessMode.TEACHER.toString())) { - mode = ToolAccessMode.TEACHER; - } else { - mode = ToolAccessMode.AUTHOR; + return ToolAccessMode.TEACHER; } - return mode; + return ToolAccessMode.AUTHOR; } /** Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java =================================================================== diff -u -r31d297d14df060ae066a55e125b5025ed713d681 -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java (.../WikiPageAction.java) (revision 31d297d14df060ae066a55e125b5025ed713d681) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/actions/WikiPageAction.java (.../WikiPageAction.java) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -428,15 +428,15 @@ // Updating the wikiPage, setting a null user which indicated this // change was made in author - wikiService.deleteWikiPage(wikiPage); + wikiService.markWikiPageAsDeleted(wikiPage); // Send removed page notifications if (toolSessionID != null && user != null) { notifyWikiChange(toolSessionID, "notify.pageRemoved.subject", "notify.pageRemoved.body", user, request); } - // return to the main page, by setting the current page to null - return this.returnToWiki(mapping, form, request, response, null); + // return to the same page with information about being removed displayed + return this.returnToWiki(mapping, form, request, response, currentPageUid); } Index: lams_tool_wiki/web/pages/authoring/authoring.jsp =================================================================== diff -u -r98272e08314f1487800201921390914652849147 -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 98272e08314f1487800201921390914652849147) +++ lams_tool_wiki/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -7,9 +7,9 @@ - + - + @@ -318,5 +328,4 @@ --> - - + \ No newline at end of file Index: lams_tool_wiki/web/pages/learning/wiki.jsp =================================================================== diff -u -r03aad5c6d9e089f1894d912b47140c6a4ccdc420 -r4161978f8d7ac38d8de94e68128ae300b0892e9d --- lams_tool_wiki/web/pages/learning/wiki.jsp (.../wiki.jsp) (revision 03aad5c6d9e089f1894d912b47140c6a4ccdc420) +++ lams_tool_wiki/web/pages/learning/wiki.jsp (.../wiki.jsp) (revision 4161978f8d7ac38d8de94e68128ae300b0892e9d) @@ -99,6 +99,9 @@ + +

+
  @@ -115,7 +118,7 @@ - + @@ -165,8 +168,8 @@   - ')" - title="" + ')" + title="" >