Author: unibrew Date: 2006-05-24 20:54:30 -0400 (Wed, 24 May 2006) New Revision: 4415 Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeleteTopic.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/delete_topic.xhtml Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml Log: [JBFORUMS-39] Moderator DeleteTopic Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeleteTopic.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeleteTopic.java 2006-05-25 00:11:04 UTC (rev 4414) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeleteTopic.java 2006-05-25 00:54:30 UTC (rev 4415) @@ -0,0 +1,87 @@ +/* +* 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. +*/ +package org.jboss.portlet.forums.ui.action; + +import org.jboss.portlet.forums.ui.BaseController; +import org.jboss.portlet.forums.ui.Constants; +import org.jboss.portlet.forums.ui.ForumUtil; +import org.jboss.portlet.forums.ui.JSFUtil; + +import org.jboss.portlet.forums.model.Forum; +import org.jboss.portlet.forums.model.Topic; + + +/** + * @author <a href="mailto:rys...@jb...">Ryszard Kozmik</a> + * + */ +public class DeleteTopic + extends ActionController +{ + //---------------------------------------------------------------------------------------------------------------------------------- + + /** + * + * + */ + public DeleteTopic() + { + + } + //actions--------------------------------------------------------------------------------------------------------------------------------- + + /** + * + */ + public String confirmDelete() + { + String navState = null; + try + { + //get the post id + int topicId = -1; + String t = ForumUtil.getParameter(Constants.p_topicId); + if (t != null && t.trim().length() > 0) + { + topicId = Integer.parseInt(t); + } + + //setup the business objects/data of interest + Topic topic = + BaseController.getForumsModule().findTopicById(new Integer(topicId)); + Forum forum = topic.getForum(); + + this.getForumsModule().removeTopic(topic); + forum.setPostCount(forum.getPostCount() - 1); + forum.setTopicCount(forum.getTopicCount() - 1); + + //set the proper navigation state + navState = Constants.TOPIC_DELETED; + + } + catch (Exception e) + { + JSFUtil.handleException(e); + } + return navState; + } +} Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2006-05-25 00:11:04 UTC (rev 4414) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2006-05-25 00:54:30 UTC (rev 4415) @@ -140,11 +140,29 @@ //ui actions supported by this bean---------------------------------------------------------------------------------------------------- - + //TODO: STILL NOT FINISHED public String deleteTopic () { - //System.out.println("HELLO"); - //FacesContext.getCurrentInstance().addMessage("message",new FacesMessage(FacesMessage.SEVERITY_INFO,"ehhh","ehhh")); + Iterator it = checkboxes.keySet().iterator(); + + // This flag checks if there was at least one topic selected + boolean isAnySet=false; + while (it.hasNext()) + { + Integer topicId = (Integer)it.next(); + boolean value = ((Boolean)checkboxes.get(topicId)).booleanValue(); + if ( value ) isAnySet=true; + Topic topic = (Topic)forum.getTopics().get(topicId.intValue()); + try { + this.getForumsModule().removeTopic(topic); + } catch(Exception e) + { + JSFUtil.handleException(e); + } + } + if (!isAnySet) + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_WARN,"","ehhh")); return ""; } @@ -155,11 +173,7 @@ public String lockTopic () { - Iterator it = checkboxes.keySet().iterator(); - while (it.hasNext()) - { - Integer topicId = (Integer)it.next(); - } + return ""; } 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-25 00:11:04 UTC (rev 4414) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-25 00:54:30 UTC (rev 4415) @@ -379,5 +379,17 @@ <from-outcome>deleteForum</from-outcome> <to-view-id>/views/admin/index.xhtml</to-view-id> </navigation-case> - </navigation-rule> + </navigation-rule> + <managed-bean> + <managed-bean-name>deleteTopic</managed-bean-name> + <managed-bean-class>org.jboss.portlet.forums.ui.action.DeleteTopic</managed-bean-class> + <managed-bean-scope>request</managed-bean-scope> + </managed-bean> + <navigation-rule> + <from-view-id>/views/moderator/delete_topic.xhtml</from-view-id> + <navigation-case> + <from-action>#{deleteTopic.confirmDelete}</from-action> + <to-view-id>/views/moderator/modcp_body.xhtml</to-view-id> + </navigation-case> + </navigation-rule> </faces-config> \ No newline at end of file Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/delete_topic.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/delete_topic.xhtml 2006-05-25 00:11:04 UTC (rev 4414) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/delete_topic.xhtml 2006-05-25 00:54:30 UTC (rev 4415) @@ -0,0 +1,63 @@ +<!-- +/* +* 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:t="http://myfaces.apache.org/tomahawk" + xmlns:forums="http://www.jboss.com/products/jbossportal/forums" + class="bb" +> + +<ui:composition template="/views/common/common.xhtml"> +<ui:define name="mainContent"> + + <table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0"> + <tr> + <th class="thHead" height="25" valign="middle"><span class="tableTitle">${resource.Topic_delete_message}</span></th> + </tr> + <tr> + <td class="row1" align="center"> + <h:form> + <span class="gen"><br/> + ${resource.Topic_delete_confirm} + <br/><br/> + <input type="hidden" name="t" value="#{param['t']}"/> + <input type="hidden" name="f" value="#{param['f']}"/> + <h:commandButton type="submit" value="Yes" styleClass="mainoption" action="#{deleteTopic.confirmDelete}"/> + &nbsp;&nbsp; + <h:commandButton type="button" value="No" styleClass="liteoption" onclick="javascript:history.back();"/> + </span> + </h:form> + </td> + </tr> + </table> + + +</ui:define> +</ui:composition> + +</div> \ No newline at end of file |