venice-main-classic/src/com/silverwrist/venice/ui/view/MembersView.java
Eric J. Bowersox 2966ab703a added UI for exporting all the members from a community, and tweaked the
implementation of XML generation and importing
2004-06-13 21:34:51 +00:00

258 lines
6.3 KiB
Java

/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.ui.view;
import java.util.*;
import javax.servlet.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.security.Role;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.servlet.RequestImpl;
public class MembersView implements ContentJSP
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int max_results; // the maximum number of results displayed
private String community_name; // the current community name
private boolean simple = true; // is this a simple listing or not?
private RequestInput rinput = null; // the RequestInput (during execution)
private int field = -1; // search field indicator
private int mode = -1; // search mode indicator
private String term = ""; // current search term
private List results = null; // the search results
private int offset = 0; // offset in list of results
private int find_count = -1; // total count of things found
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
public MembersView(int max_results, String community_name)
{
this.max_results = max_results;
this.community_name = community_name;
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface Content
*--------------------------------------------------------------------------------
*/
public boolean needFrame()
{
return true;
} // end needFrame
public int getMenuSelector()
{
return MENU_SELECTOR_COMMUNITY;
} // end getMenuSelector
public String getPageTitle(RequestOutput ro)
{
return "Members of Community " + community_name;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface ContentJSP
*--------------------------------------------------------------------------------
*/
public String getJSPName()
{
return "comm/members.jsp";
} // end getJSPName
public void initialize(RequestInput req)
{
rinput = req;
} // end initialize
public void terminate(RequestInput req)
{
rinput = null;
} // end terminate
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getMaxResults()
{
return max_results;
} // end getMaxResults
public final String getCommunityName()
{
return community_name;
} // end getCommunityName
public final boolean getSimple()
{
return simple;
} // end getSimple
public final void setSimple(boolean b)
{
simple = b;
} // end setSimple
public final int getField()
{
return field;
} // end getField
public final void setField(int v)
{
field = v;
} // end setField
public final boolean testField(int v)
{
return (field==v);
} // end testField
public final int getMode()
{
return mode;
} // end getMode
public final void setMode(int v)
{
mode = v;
} // end setMode
public final boolean testMode(int v)
{
return (mode==v);
} // end testMode
public final String getTerm()
{
return term;
} // end getTerm
public final void setTerm(String v)
{
term = v;
} // end setTerm
public final List getResults()
{
return results;
} // end getResults
public final void setResults(List v)
{
results = v;
} // end setResults
public final int getOffset()
{
return offset;
} // end getOffset
public final void setOffset(int v)
{
offset = v;
} // end setOffset
public final int getFindCount()
{
return find_count;
} // end getFindCount
public final void setFindCount(int v)
{
find_count = v;
} // end setFindCount
public boolean isCommunityAdmin(UserFound uf)
{
if (rinput==null)
return false;
SecurityInfo sinf = rinput.getCommunity().getSecurityInfo();
Role r = sinf.getRole("Community.Host");
return r.isSatisfiedBy(uf.getLevel());
} // end isCommunityAdmin
public boolean canExportMembers()
{
if (rinput==null)
return false;
return rinput.getUser().hasAdminAccess();
} // end canExportMembers
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
*/
public static final MembersView get(ServletRequest sreq) throws ServletException
{
Object obj = sreq.getAttribute(RequestImpl.REQUEST_CONTENT);
if (obj==null)
throw new ServletException("MembersView.get: unable to get request content");
if (obj instanceof MembersView)
return (MembersView)obj;
throw new ServletException("MembersView.get: request content is not a MembersView object");
} // end get
} // end class MembersView