b1d1f8e381
bugs
106 lines
3.9 KiB
JavaScript
106 lines
3.9 KiB
JavaScript
// 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@silcom.com>,
|
|
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
|
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
|
//
|
|
// Contributor(s):
|
|
|
|
importPackage(java.lang);
|
|
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
|
importPackage(Packages.com.silverwrist.dynamo.iface);
|
|
importPackage(Packages.com.silverwrist.dynamo.util);
|
|
importClass(Packages.com.silverwrist.venice.SearchMode);
|
|
importClass(Packages.com.silverwrist.venice.UserSearchField);
|
|
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
|
importClass(Packages.com.silverwrist.venice.app.AdvancedUserService);
|
|
importPackage(Packages.com.silverwrist.venice.content);
|
|
|
|
req = bsf.lookupBean("request"); // get request
|
|
rhelp = bsf.lookupBean("request_help"); // get request helper
|
|
session = rhelp.getSession(); // get the session
|
|
user = vlib.getUser(session); // get user
|
|
|
|
// Tell the session we visited this page last.
|
|
session.setObject("/find.js.vs","last.visited","find_users.js.vs");
|
|
|
|
// Get the user's configured page size.
|
|
pagesize = cast.toInteger(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count"));
|
|
|
|
field = UserSearchField.USERNAME;
|
|
mode = SearchMode.PREFIX;
|
|
term = "";
|
|
ofs = 0;
|
|
fcount = -1;
|
|
results = null;
|
|
rc = null;
|
|
|
|
if (rhelp.isVerb("POST"))
|
|
{ // Read the form parameters
|
|
field = UserSearchField.getEnum(rhelp.getParameter("field"));
|
|
mode = SearchMode.getEnum(rhelp.getParameter("mode"));
|
|
term = rhelp.getParameter("term");
|
|
ofs = rhelp.getParameterInt("ofs",0);
|
|
fcount = rhelp.getParameterInt("fcount",-1);
|
|
|
|
// Adjust offset based on the button that was clicked.
|
|
if (rhelp.isImageButtonClicked("search"))
|
|
{ // beginning of a new search
|
|
ofs = 0;
|
|
fcount = -1;
|
|
|
|
} // end if
|
|
else if (rhelp.isImageButtonClicked("previous"))
|
|
ofs = Math.max(ofs - pagesize,0);
|
|
else if (rhelp.isImageButtonClicked("next"))
|
|
ofs += pagesize;
|
|
|
|
// Get the advanced user service object.
|
|
usersvc = vcast.queryAdvancedUserService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"adv-users"));
|
|
|
|
try
|
|
{ // search for users!
|
|
if (fcount<0)
|
|
fcount = usersvc.getSearchUserCount(user,field,mode,term);
|
|
results = usersvc.searchForUsers(user,field,mode,term,ofs,pagesize);
|
|
|
|
} // end try
|
|
catch (e)
|
|
{ // exception thrown
|
|
rc = new ErrorBox("Database Error",e,"SERVLET","find_users.js.vs");
|
|
|
|
} // end catch
|
|
|
|
} // end else
|
|
|
|
if (rc==null)
|
|
{ // create the VelocityView for the output
|
|
rc = new VelocityView("Find Users","find_users.vm");
|
|
rc.setParameter("field",field.getName());
|
|
rc.setParameter("mode",mode.getName());
|
|
rc.setParameter("term",term.toString());
|
|
rc.setParameter("ofs",cast.toIntegerObject(ofs));
|
|
rc.setParameter("fcount",cast.toIntegerObject(fcount));
|
|
rc.setParameter("pagesize",cast.toIntegerObject(pagesize));
|
|
if (results!=null)
|
|
rc.setParameter("results",results);
|
|
|
|
// Load the profile menu.
|
|
mprov = vcast.queryMenuProvider(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-menus"));
|
|
menu = mprov.getInlineMenu(user,VeniceNamespaces.CONTENT_LAF_NAMESPACE,"find.menu",cast.newIntArray(0));
|
|
ndx = menu.getItemContainingLinkText("find_users.js.vs");
|
|
menu.setSelectedIndex(ndx);
|
|
rc.setParameter("menu",menu);
|
|
|
|
} // end if
|
|
|
|
dynamo.scriptOutput(rc);
|