added Admin Modify User functionality
This commit is contained in:
@@ -23,6 +23,7 @@ import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
@@ -57,6 +58,23 @@ public class SystemAdmin extends VeniceServlet
|
||||
|
||||
} // end makeSystemAdminTop
|
||||
|
||||
private AdminModifyUserDialog makeAdminModifyUserDialog() throws ServletException
|
||||
{
|
||||
final String desired_name = "AdminModifyUserDialog";
|
||||
DialogCache cache = DialogCache.getDialogCache(getServletContext());
|
||||
|
||||
if (!(cache.isCached(desired_name)))
|
||||
{ // create a template and save it off
|
||||
AdminModifyUserDialog template = new AdminModifyUserDialog(getCountryList());
|
||||
cache.saveTemplate(template);
|
||||
|
||||
} // end if
|
||||
|
||||
// return a new copy
|
||||
return (AdminModifyUserDialog)(cache.getNewDialog(desired_name));
|
||||
|
||||
} // end makeAdminModifyUserDialog
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
@@ -127,6 +145,54 @@ public class SystemAdmin extends VeniceServlet
|
||||
|
||||
} // end if ("A" command)
|
||||
|
||||
if (cmd.equals("UF"))
|
||||
{ // "UF" = "User Find" - the initial screen of User Account Management
|
||||
if (!(user.hasAdminAccess()))
|
||||
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
|
||||
// prepare and load the display
|
||||
AdminFindUser afu = new AdminFindUser(engine);
|
||||
afu.loadGet();
|
||||
setMyLocation(request,"sysadmin?cmd=UF");
|
||||
return afu;
|
||||
|
||||
} // end if ("UF" command)
|
||||
|
||||
if (cmd.equals("UM"))
|
||||
{ // "UM" = "User Modify" - the second screen of user account management
|
||||
try
|
||||
{ // get the user to be modified
|
||||
AdminOperations adm = user.getAdminInterface();
|
||||
String s_uid = request.getParameter("uid");
|
||||
if (s_uid==null)
|
||||
throw new ErrorBox(null,"User ID parameter not found.","sysadmin?cmd=UF");
|
||||
AdminUserContext admuser = adm.getUserContext(Integer.parseInt(s_uid));
|
||||
|
||||
AdminModifyUserDialog dlg = makeAdminModifyUserDialog();
|
||||
dlg.setupDialog(adm.isGlobalAdmin(),admuser);
|
||||
setMyLocation(request,"sysadmin?cmd=UM");
|
||||
return dlg;
|
||||
|
||||
} // end try
|
||||
catch (AccessError ae)
|
||||
{ // an access error generally means we're not an administrator
|
||||
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // error pulling the audit records
|
||||
return new ErrorBox("Database Error","Unable to retrieve user information: " + de.getMessage(),
|
||||
"sysadmin?cmd=UF");
|
||||
|
||||
} // end catch
|
||||
catch (NumberFormatException nfe)
|
||||
{ // this is if we get a bogus UID
|
||||
return new ErrorBox(null,"Invalid user ID parameter.","sysadmin?cmd=UF");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("UM" command)
|
||||
|
||||
// TODO: other command handling
|
||||
|
||||
if (!(user.hasAdminAccess()))
|
||||
@@ -137,4 +203,110 @@ public class SystemAdmin extends VeniceServlet
|
||||
|
||||
} // end doVeniceGet
|
||||
|
||||
protected VeniceContent doVenicePost(HttpServletRequest request, VeniceEngine engine,
|
||||
UserContext user, RenderData rdat)
|
||||
throws ServletException, IOException, VeniceServletResult
|
||||
{
|
||||
// decide what to do based on the "cmd" parameter
|
||||
String cmd = getStandardCommandParam(request);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SystemAdmin/doPost command value = " + cmd);
|
||||
|
||||
if (cmd.equals("UF"))
|
||||
{ // "UF" = "User Find" - the initial screen of User Account Management
|
||||
if (!(user.hasAdminAccess()))
|
||||
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
|
||||
try
|
||||
{ // prepare and load the display
|
||||
AdminFindUser afu = new AdminFindUser(engine);
|
||||
afu.loadPost(request);
|
||||
setMyLocation(request,"sysadmin?cmd=UF");
|
||||
return afu;
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
{ // catch a database error and return it
|
||||
return new ErrorBox("Database Error","Database error on find: " + de.getMessage(),"sysadmin?cmd=UF");
|
||||
|
||||
} // end catch
|
||||
catch (ValidationException ve)
|
||||
{ // there was a validation error
|
||||
return new ErrorBox("Find Error",ve.getMessage(),"sysadmin?cmd=UF");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("UF" command)
|
||||
|
||||
if (cmd.equals("UM"))
|
||||
{ // "UM" = "User Modify" - the second screen of user account management
|
||||
try
|
||||
{ // get the dialog box
|
||||
AdminModifyUserDialog dlg = makeAdminModifyUserDialog();
|
||||
|
||||
if (dlg.isButtonClicked(request,"cancel"))
|
||||
throw new RedirectResult("sysadmin?cmd=UF"); // we decided not to bother - go back
|
||||
|
||||
if (dlg.isButtonClicked(request,"update"))
|
||||
{ // get the user to be modified
|
||||
AdminOperations adm = user.getAdminInterface();
|
||||
String s_uid = request.getParameter("uid");
|
||||
if (s_uid==null)
|
||||
throw new ErrorBox(null,"User ID parameter not found.","sysadmin?cmd=UF");
|
||||
AdminUserContext admuser = adm.getUserContext(Integer.parseInt(s_uid));
|
||||
|
||||
dlg.loadValues(request); // load field values
|
||||
|
||||
try
|
||||
{ // execute the dialog!
|
||||
dlg.doDialog(admuser);
|
||||
throw new RedirectResult("sysadmin?cmd=UF");
|
||||
|
||||
} // end try
|
||||
catch (ValidationException ve)
|
||||
{ // this is a simple error
|
||||
dlg.resetOnError(adm.isGlobalAdmin(),admuser,ve.getMessage() + " Please try again.");
|
||||
setMyLocation(request,"sysadmin?cmd=UM");
|
||||
return dlg;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // the button must be wrong!
|
||||
logger.error("no known button click on Account.doPost, cmd=P");
|
||||
return new ErrorBox("Internal Error","Unknown command button pressed","sysadmin?cmd=UF");
|
||||
|
||||
} // end else
|
||||
|
||||
} // end try
|
||||
catch (AccessError ae)
|
||||
{ // an access error generally means we're not an administrator
|
||||
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // error pulling the audit records
|
||||
return new ErrorBox("Database Error","Unable to retrieve user information: " + de.getMessage(),
|
||||
"sysadmin?cmd=UF");
|
||||
|
||||
} // end catch
|
||||
catch (NumberFormatException nfe)
|
||||
{ // this is if we get a bogus UID
|
||||
return new ErrorBox(null,"Invalid user ID parameter.","sysadmin?cmd=UF");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if ("UM" command)
|
||||
|
||||
// TODO: other command handling
|
||||
|
||||
if (!(user.hasAdminAccess()))
|
||||
return new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
|
||||
setMyLocation(request,"sysadmin");
|
||||
return makeSystemAdminTop();
|
||||
|
||||
} // end doVenicePost
|
||||
|
||||
} // end class SystemAdmin
|
||||
|
||||
240
src/com/silverwrist/venice/servlets/format/AdminFindUser.java
Normal file
240
src/com/silverwrist/venice/servlets/format/AdminFindUser.java
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class AdminFindUser implements JSPRender, SearchMode
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.AdminFindUser";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private VeniceEngine engine;
|
||||
private int field = -1;
|
||||
private int mode = -1;
|
||||
private String term = null;
|
||||
private int offset = 0;
|
||||
private List results = null;
|
||||
private int find_count = -1;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public AdminFindUser(VeniceEngine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static int getParamInt(ServletRequest request, String name, int default_val)
|
||||
{
|
||||
String str = request.getParameter(name);
|
||||
if (str==null)
|
||||
return -1;
|
||||
|
||||
try
|
||||
{ // parse the integer value
|
||||
return Integer.parseInt(str);
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // in case of conversion error, return default
|
||||
return default_val;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end getParamInt
|
||||
|
||||
private static boolean isImageButtonClicked(ServletRequest request, String name)
|
||||
{
|
||||
String val = request.getParameter(name + ".x");
|
||||
return (val!=null);
|
||||
|
||||
} // end isImageButtonClicked
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static AdminFindUser retrieve(ServletRequest request)
|
||||
{
|
||||
return (AdminFindUser)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VeniceContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
return "User Account Management";
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "admin_find.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public int getSearchField()
|
||||
{
|
||||
return field;
|
||||
|
||||
} // end getSearchField
|
||||
|
||||
public boolean searchFieldIs(int value)
|
||||
{
|
||||
return (value==field);
|
||||
|
||||
} // end searchFieldIs
|
||||
|
||||
public int getSearchMode()
|
||||
{
|
||||
return mode;
|
||||
|
||||
} // end getSearchMode
|
||||
|
||||
public boolean searchModeIs(int value)
|
||||
{
|
||||
return (value==mode);
|
||||
|
||||
} // end searchModeIs
|
||||
|
||||
public String getSearchTerm()
|
||||
{
|
||||
return term;
|
||||
|
||||
} // end getSearchTerm
|
||||
|
||||
public List getResultsList()
|
||||
{
|
||||
return results;
|
||||
|
||||
} // end getResultsList
|
||||
|
||||
public int getNumResultsDisplayed()
|
||||
{
|
||||
return engine.getStdNumSearchResults();
|
||||
|
||||
} // end getNumResultsDisplayed
|
||||
|
||||
public int getFindCount()
|
||||
{
|
||||
return find_count;
|
||||
|
||||
} // end getFindCount
|
||||
|
||||
public int getOffset()
|
||||
{
|
||||
return offset;
|
||||
|
||||
} // end getOffset
|
||||
|
||||
public void loadGet()
|
||||
{
|
||||
field = FIELD_USER_NAME;
|
||||
mode = SEARCH_PREFIX;
|
||||
term = "";
|
||||
|
||||
} // end loadGet
|
||||
|
||||
public void loadPost(ServletRequest request) throws ValidationException, DataException
|
||||
{
|
||||
int catid = -1;
|
||||
|
||||
// Retrieve all the posted parameters from the form and validate them.
|
||||
field = getParamInt(request,"field",FIELD_USER_NAME);
|
||||
if ( (field!=FIELD_USER_NAME) && (field!=FIELD_USER_DESCRIPTION) && (field!=FIELD_USER_GIVEN_NAME)
|
||||
&& (field!=FIELD_USER_FAMILY_NAME))
|
||||
throw new ValidationException("The field search parameter is not valid.");
|
||||
mode = getParamInt(request,"mode",SEARCH_PREFIX);
|
||||
if ((mode!=SEARCH_PREFIX) && (mode!=SEARCH_SUBSTRING) && (mode!=SEARCH_REGEXP))
|
||||
throw new ValidationException("The search mode parameter is not valid.");
|
||||
term = request.getParameter("term");
|
||||
if (term==null)
|
||||
term = "";
|
||||
|
||||
// Retrieve the offset and find count parameters.
|
||||
offset = getParamInt(request,"ofs",0);
|
||||
find_count = getParamInt(request,"fcount",-1);
|
||||
|
||||
// Adjust the search return offset based on the command button click.
|
||||
int count = getNumResultsDisplayed();
|
||||
if (isImageButtonClicked(request,"search"))
|
||||
offset = 0;
|
||||
else if (isImageButtonClicked(request,"previous"))
|
||||
{ // adjust the offset in the reverse direction
|
||||
offset -= count;
|
||||
if (offset<0)
|
||||
offset = 0;
|
||||
|
||||
} // end else if
|
||||
else if (isImageButtonClicked(request,"next"))
|
||||
offset += count; // go forwards instead
|
||||
else
|
||||
throw new ValidationException("Unable to determine what action triggered the form.");
|
||||
|
||||
// Run the actual search.
|
||||
results = engine.searchForUsers(field,mode,term,offset,count);
|
||||
if (find_count<0)
|
||||
find_count = engine.getSearchUserCount(field,mode,term);
|
||||
|
||||
} // end loadPost
|
||||
|
||||
} // end class AdminFindUser
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.LocaleFactory;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.ValidationException;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.security.Role;
|
||||
|
||||
public class AdminModifyUserDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public AdminModifyUserDialog(List country_list)
|
||||
{
|
||||
super("Modify User Account",null,"moduserform","sysadmin");
|
||||
setHiddenField("cmd","UM");
|
||||
setHiddenField("uid","");
|
||||
|
||||
addFormField(new CDFormCategoryHeader("Security Information","To change the user's password, enter a new "
|
||||
+ "password into the fields below."));
|
||||
addFormField(new CDPasswordFormField("pass1","Password",null,false,32,128));
|
||||
addFormField(new CDPasswordFormField("pass2","Password","(retype)",false,32,128));
|
||||
addFormField(new CDTextFormField("remind","Password reminder phrase",null,false,32,255));
|
||||
addFormField(new CDRoleListFormField("base_lvl","Base security level",null,true,
|
||||
Role.getBaseLevelChoices()));
|
||||
addFormField(new CDCheckBoxFormField("verify_email","E-mail address verified",null,"Y"));
|
||||
addFormField(new CDCheckBoxFormField("lockout","Account locked out",null,"Y"));
|
||||
addFormField(new CDFormCategoryHeader("Name"));
|
||||
addFormField(new CDTextFormField("prefix","Prefix","(Mr., Ms., etc.)",false,8,8));
|
||||
addFormField(new CDTextFormField("first","First name",null,true,32,64));
|
||||
addFormField(new CDTextFormField("mid","Middle initial",null,false,1,1));
|
||||
addFormField(new CDTextFormField("last","Last name",null,true,32,64));
|
||||
addFormField(new CDTextFormField("suffix","Suffix","(Jr., III, etc.)",false,16,16));
|
||||
addFormField(new CDFormCategoryHeader("Location"));
|
||||
addFormField(new CDTextFormField("company","Company",null,false,32,255));
|
||||
addFormField(new CDTextFormField("addr1","Address",null,false,32,255));
|
||||
addFormField(new CDTextFormField("addr2","Address","(line 2)",false,32,255));
|
||||
addFormField(new CDCheckBoxFormField("pvt_addr","Hide address in profile",null,"Y"));
|
||||
addFormField(new CDTextFormField("loc","City",null,true,32,64));
|
||||
addFormField(new CDTextFormField("reg","State/Province",null,true,32,64));
|
||||
addFormField(new CDTextFormField("pcode","Zip/Postal Code",null,true,32,64));
|
||||
addFormField(new CDCountryListFormField("country","Country",null,true,country_list));
|
||||
addFormField(new CDFormCategoryHeader("Phone Numbers"));
|
||||
addFormField(new CDTextFormField("phone","Telephone",null,false,32,32));
|
||||
addFormField(new CDTextFormField("mobile","Mobile/cellphone",null,false,32,32));
|
||||
addFormField(new CDCheckBoxFormField("pvt_phone","Hide phone/mobile numbers in profile",null,"Y"));
|
||||
addFormField(new CDTextFormField("fax","Fax",null,false,32,32));
|
||||
addFormField(new CDCheckBoxFormField("pvt_fax","Hide fax number in profile",null,"Y"));
|
||||
addFormField(new CDFormCategoryHeader("Internet"));
|
||||
addFormField(new CDEmailAddressFormField("email","E-mail address",null,true,32,255));
|
||||
addFormField(new CDCheckBoxFormField("pvt_email","Hide e-mail address in profile",null,"Y"));
|
||||
addFormField(new CDTextFormField("url","Home page","(URL)",false,32,255));
|
||||
addFormField(new CDFormCategoryHeader("Personal"));
|
||||
addFormField(new CDTextFormField("descr","Personal description",null,false,32,255));
|
||||
addFormField(new CDFormCategoryHeader("User Preferences"));
|
||||
addFormField(new CDLocaleListFormField("locale","Default locale","(for formatting dates/times)",true));
|
||||
addFormField(new CDTimeZoneListFormField("tz","Default time zone",null,true));
|
||||
addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24));
|
||||
addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected AdminModifyUserDialog(AdminModifyUserDialog other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end AdminModifyUserDialog
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private void coreSetup(boolean is_global_admin, AdminUserContext admuser)
|
||||
{
|
||||
setSubtitle("User: " + admuser.getUserName());
|
||||
setHiddenField("uid",String.valueOf(admuser.getUID()));
|
||||
|
||||
CDPickListFormField level_field = (CDPickListFormField)modifyField("base_lvl");
|
||||
List role_list;
|
||||
if (is_global_admin)
|
||||
role_list = level_field.getChoicesList();
|
||||
else
|
||||
{ // not a global admin - deny user the right to select assistant admin choices
|
||||
role_list = Role.getBaseLevelChoices2();
|
||||
level_field.setChoicesList(role_list);
|
||||
|
||||
} // end else
|
||||
|
||||
// See if this level was found on the list.
|
||||
boolean found = false;
|
||||
Iterator it = role_list.iterator();
|
||||
while (it.hasNext())
|
||||
{ // seek each role in turn
|
||||
Role r = (Role)(it.next());
|
||||
if (r.getLevel()==admuser.getBaseLevel())
|
||||
{ // found it!
|
||||
found = true;
|
||||
break;
|
||||
|
||||
} // end if
|
||||
|
||||
} // end while
|
||||
|
||||
if (!found)
|
||||
{ // not in the list - set the defined "role list" to be a singleton of our current level
|
||||
role_list = Collections.singletonList(Role.getRoleForLevel(admuser.getBaseLevel()));
|
||||
level_field.setChoicesList(role_list);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end coreSetup
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class Object
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new AdminModifyUserDialog(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class ContentDialog
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected void validateWholeForm() throws ValidationException
|
||||
{
|
||||
String pass1 = getFieldValue("pass1");
|
||||
String pass2 = getFieldValue("pass2");
|
||||
|
||||
if (StringUtil.isStringEmpty(pass1))
|
||||
{ // empty must match empty
|
||||
if (!StringUtil.isStringEmpty(pass2))
|
||||
throw new ValidationException("The typed passwords do not match.");
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // the two passwords must match
|
||||
if (!(pass1.equals(pass2)))
|
||||
throw new ValidationException("The typed passwords do not match.");
|
||||
|
||||
} // end if
|
||||
|
||||
} // end validateWholeForm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void setupDialog(boolean is_global_admin, AdminUserContext admuser) throws DataException
|
||||
{
|
||||
coreSetup(is_global_admin,admuser);
|
||||
|
||||
setFieldValue("base_lvl",String.valueOf(admuser.getBaseLevel()));
|
||||
if (admuser.isEmailVerified())
|
||||
setFieldValue("verify_email","Y");
|
||||
if (admuser.isLockedOut())
|
||||
setFieldValue("lockout","Y");
|
||||
|
||||
ContactInfo ci = admuser.getContactInfo(); // get the main contact info
|
||||
|
||||
setFieldValue("prefix",ci.getNamePrefix());
|
||||
setFieldValue("first",ci.getGivenName());
|
||||
char init = ci.getMiddleInitial();
|
||||
if (init!=' ')
|
||||
setFieldValue("mid",String.valueOf(init));
|
||||
setFieldValue("last",ci.getFamilyName());
|
||||
setFieldValue("suffix",ci.getNameSuffix());
|
||||
setFieldValue("company",ci.getCompany());
|
||||
setFieldValue("addr1",ci.getAddressLine1());
|
||||
setFieldValue("addr2",ci.getAddressLine2());
|
||||
if (ci.getPrivateAddress())
|
||||
setFieldValue("pvt_addr","Y");
|
||||
setFieldValue("loc",ci.getLocality());
|
||||
setFieldValue("reg",ci.getRegion());
|
||||
setFieldValue("pcode",ci.getPostalCode());
|
||||
setFieldValue("country",ci.getCountry());
|
||||
setFieldValue("phone",ci.getPhone());
|
||||
setFieldValue("mobile",ci.getMobile());
|
||||
if (ci.getPrivatePhone())
|
||||
setFieldValue("pvt_phone","Y");
|
||||
setFieldValue("fax",ci.getFax());
|
||||
if (ci.getPrivateFax())
|
||||
setFieldValue("pvt_fax","Y");
|
||||
setFieldValue("email",ci.getEmail());
|
||||
if (ci.getPrivateEmail())
|
||||
setFieldValue("pvt_email","Y");
|
||||
setFieldValue("url",ci.getURL());
|
||||
setFieldValue("descr",admuser.getDescription());
|
||||
setFieldValue("locale",admuser.getLocale().toString());
|
||||
setFieldValue("tz",admuser.getTimeZone().getID());
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
public void doDialog(AdminUserContext admuser) throws ValidationException, DataException
|
||||
{
|
||||
validate(); // validate the dialog
|
||||
|
||||
final String yes = "Y"; // the "yes" string
|
||||
|
||||
try
|
||||
{ // reset the base level
|
||||
admuser.setBaseLevel(Integer.parseInt(getFieldValue("base_lvl")));
|
||||
|
||||
} // end try
|
||||
catch (NumberFormatException nfe)
|
||||
{ // this shouldn't happen
|
||||
throw new InternalStateError("new_level should be an integer - form screwup");
|
||||
|
||||
} // end catch
|
||||
|
||||
// Change the password if applicable.
|
||||
String foo = getFieldValue("pass1");
|
||||
if (!StringUtil.isStringEmpty(foo))
|
||||
admuser.setPassword(foo,getFieldValue("remind"));
|
||||
|
||||
admuser.setEmailVerified(yes.equals(getFieldValue("verify_email")));
|
||||
admuser.setLockedOut(yes.equals(getFieldValue("lockout")));
|
||||
|
||||
ContactInfo ci = admuser.getContactInfo(); // get the main contact info
|
||||
|
||||
// Reset all the contact info fields.
|
||||
ci.setNamePrefix(getFieldValue("prefix"));
|
||||
ci.setGivenName(getFieldValue("first"));
|
||||
foo = getFieldValue("mid");
|
||||
if ((foo==null) || (foo.length()<1))
|
||||
ci.setMiddleInitial(' ');
|
||||
else
|
||||
ci.setMiddleInitial(foo.charAt(0));
|
||||
ci.setFamilyName(getFieldValue("last"));
|
||||
ci.setNameSuffix(getFieldValue("suffix"));
|
||||
ci.setCompany(getFieldValue("company"));
|
||||
ci.setAddressLine1(getFieldValue("addr1"));
|
||||
ci.setAddressLine2(getFieldValue("addr2"));
|
||||
ci.setPrivateAddress(yes.equals(getFieldValue("pvt_addr")));
|
||||
ci.setLocality(getFieldValue("loc"));
|
||||
ci.setRegion(getFieldValue("reg"));
|
||||
ci.setPostalCode(getFieldValue("pcode"));
|
||||
ci.setCountry(getFieldValue("country"));
|
||||
ci.setPhone(getFieldValue("phone"));
|
||||
ci.setMobile(getFieldValue("mobile"));
|
||||
ci.setPrivatePhone(yes.equals(getFieldValue("pvt_phone")));
|
||||
ci.setFax(getFieldValue("fax"));
|
||||
ci.setPrivateFax(yes.equals(getFieldValue("pvt_fax")));
|
||||
ci.setEmail(getFieldValue("email"));
|
||||
ci.setPrivateEmail(yes.equals(getFieldValue("pvt_email")));
|
||||
ci.setURL(getFieldValue("url"));
|
||||
|
||||
// Store the completed contact info.
|
||||
admuser.putContactInfo(ci);
|
||||
|
||||
// Save off the user's description and preferences.
|
||||
admuser.setDescription(getFieldValue("descr"));
|
||||
admuser.setLocale(LocaleFactory.createLocale(getFieldValue("locale")));
|
||||
admuser.setTimeZone(TimeZone.getTimeZone(getFieldValue("tz")));
|
||||
|
||||
} // end doDialog
|
||||
|
||||
public void resetOnError(boolean is_global_admin, AdminUserContext admuser, String message)
|
||||
{
|
||||
coreSetup(is_global_admin,admuser);
|
||||
setErrorMessage(message);
|
||||
setFieldValue("pass1",null);
|
||||
setFieldValue("pass2",null);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
} // end class AdminModifyUserDialog
|
||||
@@ -83,4 +83,21 @@ public abstract class CDPickListFormField extends CDBaseFormField
|
||||
|
||||
} // end renderActualField
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public List getChoicesList()
|
||||
{
|
||||
return choices;
|
||||
|
||||
} // end getChoicesList
|
||||
|
||||
public void setChoicesList(List list)
|
||||
{
|
||||
this.choices = list;
|
||||
|
||||
} // end setChoicesList
|
||||
|
||||
} // end class CDPickListFormField
|
||||
|
||||
@@ -219,6 +219,17 @@ public class ContentDialog implements Cloneable, ContentRender
|
||||
|
||||
} // end renderHere
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Operations usable only from derived classes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected CDFormField modifyField(String name)
|
||||
{
|
||||
return (CDFormField)(form_fields.get(name));
|
||||
|
||||
} // end modifyField
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
@@ -230,6 +241,12 @@ public class ContentDialog implements Cloneable, ContentRender
|
||||
|
||||
} // end setTitle
|
||||
|
||||
public void setSubtitle(String subtitle)
|
||||
{
|
||||
this.subtitle = subtitle;
|
||||
|
||||
} // end setSubtitle
|
||||
|
||||
public void setErrorMessage(String message)
|
||||
{
|
||||
this.error_message = message;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* 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 Community System.
|
||||
* 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
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SystemAdminTop extends ContentMenuPanel
|
||||
super("System Administration",null);
|
||||
addChoice("Set Global Parameters","TODO");
|
||||
addChoice("View/Edit Banned Users","TODO");
|
||||
addChoice("User Account Management","TODO");
|
||||
addChoice("User Account Management","sysadmin?cmd=UF");
|
||||
addChoice("System Audit Logs","sysadmin?cmd=A");
|
||||
|
||||
} // end constructor
|
||||
|
||||
Reference in New Issue
Block a user