From: <jbo...@li...> - 2006-05-24 18:35:26
|
Author: soh...@jb... Date: 2006-05-24 14:35:03 -0400 (Wed, 24 May 2006) New Revision: 4408 Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/deleteForum.xhtml Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml Log: http://jira.jboss.com/jira/browse/JBFORUMS-60 - Delete Forum http://jira.jboss.com/jira/browse/JBFORUMS-61 - Delete All Forum Posts http://jira.jboss.com/jira/browse/JBFORUMS-62 - Move All Forum contents Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-24 17:39:43 UTC (rev 4407) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-24 18:35:03 UTC (rev 4408) @@ -40,6 +40,7 @@ public static final String EDIT_CATEGORY = "editCategory"; public static final String EDIT_FORUM = "editForum"; public static final String DELETE_CATEGORY = "deleteCategory"; + public static final String DELETE_FORUM = "deleteForum"; //---------parameter constants-------------------------------------------------------------------------------------------------- public static final String p_categoryId = "c"; public static final String p_forumId = "f"; Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-24 17:39:43 UTC (rev 4407) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-24 18:35:03 UTC (rev 4408) @@ -21,6 +21,7 @@ */ package org.jboss.portlet.forums.ui.action; +import java.util.ArrayList; import java.util.Iterator; import java.util.Collection; @@ -28,6 +29,7 @@ import org.jboss.portlet.forums.model.Category; import org.jboss.portlet.forums.model.Forum; +import org.jboss.portlet.forums.model.Topic; /** * @@ -57,6 +59,7 @@ * ui data associated with selecting a category to perform a certain operation */ private int selectedCategory = 0; + private int selectedForum = 0; //-----ui data------------------------------------------------------------------------------------------------------------------------- /** * @return Returns the categoryName. @@ -116,6 +119,22 @@ { this.selectedCategory = selectedCategory; } + /** + * + * + */ + public int getSelectedForum() + { + return this.selectedForum; + } + /** + * + * + */ + public void setSelectedForum(int selectedForum) + { + this.selectedForum = selectedForum; + } //cleanup related---------------------------------------------------------------------------------------------------------------------- /** * @@ -126,6 +145,7 @@ this.forumName = null; this.forumDescription = null; this.selectedCategory = 0; + this.selectedForum = 0; } //------------------------------------------------------------------------------------------------------------------------------------- /** @@ -375,6 +395,66 @@ * * */ + public String deleteForum() + { + String navState = null; + boolean success = false; + try + { + int forumId = -1; + String cour = ForumUtil.getParameter(Constants.p_forumId); + if(cour!=null && cour.trim().length()>0) + { + forumId = Integer.parseInt(cour); + } + + Forum source = BaseController.getForumsModule().findForumById(new Integer(forumId)); + + //move all the topics/posts of this forum to the specified target forum + if(this.selectedForum!=-1) + { + Forum target = BaseController.getForumsModule().findForumById(new Integer(selectedForum)); + target.getTopics().addAll(source.getTopics()); + target.setPostCount(target.getPostCount() + source.getPostCount()); + target.setTopicCount(target.getTopicCount() + source.getTopicCount()); + for (Iterator i = target.getTopics().iterator(); i.hasNext();) + { + Topic tp = (Topic)i.next(); + tp.setForum(target); + } + + //clear the source out before delete + source.setTopics(new ArrayList()); + } + + + //means delete all topic/posts on this forum + BaseController.getForumsModule().removeForum(source); + + + JSFUtil.setMessage(Constants.FEEDBACK,"The Forum \""+this.forumName+"\" was successfully deleted."); + navState = Constants.DELETE_FORUM; + success = true; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + finally + { + if(success) + { + //cleanup the state + this.cleanup(); + } + } + return navState; + } + + /** + * + * + */ public String moveCategoryUp() { String navState = null; Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java 2006-05-24 17:39:43 UTC (rev 4407) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java 2006-05-24 18:35:03 UTC (rev 4408) @@ -61,6 +61,24 @@ { JSFUtil.handleException(e); } - return null ; + return null; } + + /** + * + * + */ + public List getForums() + { + try + { + List forums = getForumsModule().findForums(); + return forums; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return null; + } } Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-24 17:39:43 UTC (rev 4407) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-24 18:35:03 UTC (rev 4408) @@ -374,9 +374,9 @@ </navigation-case> </navigation-rule> <navigation-rule> - <from-view-id>/views/admin/editForum.xhtml</from-view-id> + <from-view-id>/views/admin/deleteForum.xhtml</from-view-id> <navigation-case> - <from-outcome>editForum</from-outcome> + <from-outcome>deleteForum</from-outcome> <to-view-id>/views/admin/index.xhtml</to-view-id> </navigation-case> </navigation-rule> Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/deleteForum.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/deleteForum.xhtml 2006-05-24 17:39:43 UTC (rev 4407) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/deleteForum.xhtml 2006-05-24 18:35:03 UTC (rev 4408) @@ -0,0 +1,84 @@ +<!-- +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +--> + +<div xmlns="http://www.w3.org/1999/xhtml" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:forums="http://www.jboss.com/products/jbossportal/forums" class="bb"> + + <ui:composition template="/views/common/common.xhtml"> + <ui:define name="mainContent"> + + <h1>${resource.Forum_delete}</h1> + + <p>${resource.Forum_delete_explain}</p> + + <!-- display the delete category widget --> + <h:form> + <input type="hidden" name="f" value="#{param['f']}"/> + <table cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th colspan="2" class="thHead">${resource.Forum_delete}</th> + </tr> + <tr> + <td class="row1">${resource.Forum}</td> + <td class="row1"><span class="row1">#{adminController.forumName}</span></td> + </tr> + <tr> + <td class="row1">${resource.Move_contents} to - </td> + <td class="row1"> + <h:selectOneMenu value="#{adminController.selectedForum}"> + <f:selectItem itemValue="-1" itemLabel="Delete All Topics/Posts" /> + <c:forEach items="#{adminPanel.forums}" var="forum"> + <c:if test="#{forum.id != param['f']}"> + <f:selectItem itemValue="#{forum.id}" itemLabel="#{forum.name}" /> + </c:if> + </c:forEach> + </h:selectOneMenu> + </td> + </tr> + <tr> + <td class="catBottom" colspan="2" align="center"> + <h:commandButton value="Submit" styleClass="mainoption" action="#{adminController.deleteForum}"/> + </td> + </tr> + </table> + </h:form> + + + + <!-- integrate the jump box --> + <table cellspacing="0" cellpadding="0" border="0" align="right"> + <tr> + <td align="right" valign="top" nowrap="nowrap"> + <ui:include src="/views/jumpbox.xhtml"/> + </td> + </tr> + </table> + + </ui:define> + </ui:composition> +</div> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-24 17:39:43 UTC (rev 4407) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-24 18:35:03 UTC (rev 4408) @@ -52,7 +52,10 @@ <td class="catLeft" colspan="3"> <span class="cattitle"> <b> - <a href="">${category.title}</a> + <h:outputLink value="#{forums:outputLink(shared.links['category'],true)}"> + <f:param name="c" value="#{category.id}"/> + ${category.title} + </h:outputLink> </b> </span> </td> @@ -101,7 +104,10 @@ <tr> <td class="row2"> <span class="gen"> - <a href="" target="_new">${forum.name}</a> + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}" target="_new"> + <f:param name="f" value="#{forum.id}"/> + ${forum.name} + </h:outputLink> </span> <br/><span class="gensmall">${forum.description}</span> </td> @@ -123,9 +129,15 @@ </forums:isAllowed> </td> <td class="row2" align="center" valign="middle"> - <span class="gen"> - <a href="">${resource.Delete}</a> - </span> + <!-- security check to make sure this link should be displayed or not --> + <forums:isAllowed fragment="acl://deleteForum/deleteLink" contextData="#{forum}"> + <span class="gen"> + <h:outputLink value="#{forums:outputLink('/views/admin/deleteForum.jsf',true)}"> + <f:param name="f" value="#{forum.id}"/> + <h:outputText value="${resource.Delete}"/> + </h:outputLink> + </span> + </forums:isAllowed> </td> <td class="row1" align="center" valign="middle"> <span class="gen"> |