Author: unibrew Date: 2006-05-28 20:41:33 -0400 (Sun, 28 May 2006) New Revision: 4459 Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_move.xhtml Removed: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeleteTopic.java 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/ModeratorAction.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml Log: [JBFORUMS-51] Working on move action for moderator's panel. 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-28 22:06:26 UTC (rev 4458) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-29 00:41:33 UTC (rev 4459) @@ -48,6 +48,7 @@ public static final String p_postId = "p"; public static final String p_userId = "uid"; public static final String p_option = "o"; + public static final String p_forum_to_id="forum_to_id"; public static final String p_poll_title = "POLL_TITLE"; public static final String p_poll_delete = "POLL_DELETE"; public static final String p_attachment = "ATTACHMENT"; Deleted: 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-28 22:06:26 UTC (rev 4458) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/DeleteTopic.java 2006-05-29 00:41:33 UTC (rev 4459) @@ -1,87 +0,0 @@ -/* -* 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-28 22:06:26 UTC (rev 4458) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2006-05-29 00:41:33 UTC (rev 4459) @@ -180,7 +180,57 @@ public String moveTopic () { - return ""; + System.out.println("HELLO WORLD"); + String message=""; + String forum_to_id = ForumUtil.getParameter(Constants.p_forum_to_id); + if (forum_to_id==null || forum_to_id.trim().compareToIgnoreCase("-1")==0) + { + message = bundle.getString("ERR_NO_DEST_FORUM"); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_ERROR,message,"moderate")); + return "success"; + } + + try { + Forum forum = this.getForumsModule().findForumById(new Integer(forum_to_id)); + } catch (Exception e) + { + message = bundle.getString("ERR_INTERNAL"); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_ERROR,message,"moderate")); + return "success"; + } + Iterator it = checkboxes.keySet().iterator(); + try { + while (it.hasNext()) + { + Integer topicId = (Integer)it.next(); + boolean value = ((Boolean)checkboxes.get(topicId)).booleanValue(); + if (value) + { + Topic topic = null; + try { + topic = getForumsModule().findTopicById(topicId); + } catch(Exception e) + { + message = bundle.getString("ERR_INTERNAL"); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_ERROR,message,"moderate")); + return "success"; + } + forum.addTopic(topic); + } + } + message = bundle.getString("SUCC_TOPIC_MOVED"); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_INFO,message, "moderate")); + this.forum = BaseController.getForumsModule().findForumById(forum.getId()); + checkboxes=new HashMap(); + } catch (Exception e) + { + JSFUtil.handleException(e); + } + return "success"; } public String lockTopic () @@ -288,6 +338,20 @@ } } + public String moveConfirm() + { + if (isAnyCheckboxSelected()) + { + return "confirmMove"; + } else + { + String message = bundle.getString("None_selected"); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_ERROR,message,"moderate")); + return ""; + } + } + private boolean isAnyCheckboxSelected() { Iterator it = checkboxes.keySet().iterator(); Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-05-28 22:06:26 UTC (rev 4458) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2006-05-29 00:41:33 UTC (rev 4459) @@ -1090,6 +1090,7 @@ Confirm_move_topic=Are you sure you want to move the selected topic/s? Move_to_forum=Move to forum +Move_dstination_forum=Select destination forum Leave_shadow_topic=Leave shadow topic in old forum. L_SPLIT_TOPIC=Split Topic Control Panel Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml 2006-05-28 22:06:26 UTC (rev 4458) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml 2006-05-29 00:41:33 UTC (rev 4459) @@ -1,3 +1,27 @@ +<!-- +/* +* 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" @@ -78,7 +102,7 @@ <f:param name="f" value="#{forum.forum.id}"/> </h:commandButton> &nbsp; - <h:commandButton action="#{moveConfirm}" class="liteoption" value="${resource.Move}"> + <h:commandButton action="#{moderator.moveConfirm}" class="liteoption" value="${resource.Move}"> <f:param name="f" value="#{forum.forum.id}"/> </h:commandButton> &nbsp; @@ -114,7 +138,6 @@ </td> </tr> </table> -<ui:debug hotkey="l" /> </ui:define> </ui:composition> </div> Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_move.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_move.xhtml 2006-05-28 22:06:26 UTC (rev 4458) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_move.xhtml 2006-05-29 00:41:33 UTC (rev 4459) @@ -0,0 +1,114 @@ +<!-- +/* +* 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"> + <form> + <table width="100%" cellspacing="2" cellpadding="2" border="0" + align="center"> + <tr> + <td align="left" class="nav"> + <h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}" + styleClass="nav"> + <f:param name="f" value="#{moderator.forum.id}"/> + <h:outputText value="#{moderator.forum.name}"/> + </h:outputLink> + </td> + </tr> + </table> + <table width="100%" cellpadding="4" cellspacing="1" border="0" + class="forumline"> + <tr> + <th height="25" class="thHead"> + <b>${resource.Confirm}</b> + </th> + </tr> + <tr> + <td class="row1"> + <table width="100%" border="0" cellspacing="0" + cellpadding="1"> + <tr> + <td>&nbsp;</td> + </tr> + <tr> + <td align="center"> + <span class="gen"> + ${resource.Move_to_forum} &nbsp; + <select name="forum_to_id"> + <option value="-1">${resource.Select_forum}</option> + <c:forEach items="${jumpbox.categories}" + var="category"> + <option value="-1"></option> + <option value="-1">${category.title}</option> + <option value="-1">----------------</option> + <c:forEach items="${category.forums}" + var="forum"> + <option value="${forum.id}">${forum.name}</option> + </c:forEach> + </c:forEach> + </select> + <br/> + <br/> + <!-- TODO: FUTURE FEATURE: SHADOW NOT AVAILABLE--> + <!--<input type="checkbox" name="move_leave_shadow" checked="checked"DISABLED/>${resource.Leave_shadow_topic}[N/A yet...]<br /> --> + <br/> + ${resource.Confirm_move_topic} + </span> + <br/> + <br/> + <h:commandButton type="submit" value="Yes" + styleClass="mainoption" + action="#{moderator.moveTopic}"> + <f:param name="f" + value="#{moderator.forum.id}"/> + </h:commandButton> + &nbsp;&nbsp; + <h:commandButton type="button" value="No" + styleClass="liteoption" + onclick="javascript:history.back();"> + <f:param name="f" + value="#{moderator.forum.id}"/> + </h:commandButton> + </td> + </tr> + <tr> + <td>&nbsp;</td> + </tr> + </table> + </td> + </tr> + </table> + </form> + <ui:debug key="s" /> + </ui:define> + </ui:composition> + +</div> \ No newline at end of file |