added administrative control of user photos - ability to replace or clear
a user's photo, keep the user from uploading a new one
This commit is contained in:
@@ -489,8 +489,10 @@ public class Account extends VeniceServlet
|
||||
{ // we're ready to update the user profile
|
||||
dlg.loadValues(request); // load field values
|
||||
|
||||
boolean photo_flag = true;
|
||||
try
|
||||
{ // validate the dialog and reset profile info
|
||||
photo_flag = user.canSetUserPhoto();
|
||||
if (dlg.doDialog(user)) // need to reconfirm email address
|
||||
throw new RedirectResult("account?cmd=V&tgt=" + URLEncoder.encode(tgt));
|
||||
else
|
||||
@@ -499,7 +501,7 @@ public class Account extends VeniceServlet
|
||||
} // end try
|
||||
catch (ValidationException ve)
|
||||
{ // there was a validation error...
|
||||
dlg.resetOnError(ve.getMessage() + " Please try again.");
|
||||
dlg.resetOnError(photo_flag,ve.getMessage() + " Please try again.");
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
|
||||
203
src/com/silverwrist/venice/servlets/AdminUserPhoto.java
Normal file
203
src/com/silverwrist/venice/servlets/AdminUserPhoto.java
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import org.apache.log4j.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.util.ServletMultipartHandler;
|
||||
import com.silverwrist.util.ServletMultipartException;
|
||||
import com.silverwrist.util.image.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.except.*;
|
||||
import com.silverwrist.venice.servlets.format.*;
|
||||
|
||||
public class AdminUserPhoto extends VeniceServlet
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(AdminUserPhoto.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class HttpServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getServletInfo()
|
||||
{
|
||||
String rc = "AdminUserPhoto servlet - changes the user photo for a user\n"
|
||||
+ "Part of the Venice Web Communities System\n";
|
||||
return rc;
|
||||
|
||||
} // end getServletInfo
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class VeniceServlet
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected VeniceContent doVeniceGet(HttpServletRequest request, VeniceEngine engine,
|
||||
UserContext user, RenderData rdat)
|
||||
throws ServletException, IOException, VeniceServletResult
|
||||
{
|
||||
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));
|
||||
|
||||
if (request.getParameter("null")!=null)
|
||||
{ // null the photo out and return
|
||||
ContactInfo ci = admuser.getContactInfo();
|
||||
ci.setPhotoURL(null);
|
||||
admuser.putContactInfo(ci);
|
||||
throw new RedirectResult("sysadmin?cmd=UM&uid=" + admuser.getUID());
|
||||
|
||||
} // end if
|
||||
|
||||
return new AdminUserPhotoData(engine,admuser,rdat);
|
||||
|
||||
} // 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 doVeniceGet
|
||||
|
||||
protected VeniceContent doVenicePost(HttpServletRequest request, ServletMultipartHandler mphandler,
|
||||
VeniceEngine engine, UserContext user, RenderData rdat)
|
||||
throws ServletException, IOException, VeniceServletResult
|
||||
{
|
||||
AdminUserContext admuser;
|
||||
try
|
||||
{ // get the user to be modified
|
||||
AdminOperations adm = user.getAdminInterface();
|
||||
String s_uid = mphandler.getValue("uid");
|
||||
if (s_uid==null)
|
||||
throw new ErrorBox(null,"User ID parameter not found.","sysadmin?cmd=UF");
|
||||
admuser = adm.getUserContext(Integer.parseInt(s_uid));
|
||||
|
||||
} // 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
|
||||
|
||||
if (isImageButtonClicked(mphandler,"cancel"))
|
||||
throw new RedirectResult("sysadmin?cmd=UM&uid=" + admuser.getUID());
|
||||
|
||||
if (isImageButtonClicked(mphandler,"upload"))
|
||||
{ // uploading the image here!
|
||||
// also check on file parameter status
|
||||
if (!(mphandler.isFileParam("thepic")))
|
||||
{ // bogus file parameter
|
||||
logger.error("Internal Error: 'thepic' should be a file param");
|
||||
return new ErrorBox(null,"Internal Error: 'thepic' should be a file param",
|
||||
"sysadmin?cmd=UM&uid=" + admuser.getUID());
|
||||
|
||||
} // end if
|
||||
|
||||
if (!(mphandler.getContentType("thepic").startsWith("image/")))
|
||||
{ // must be an image type we uploaded!
|
||||
logger.error("Error: 'thepic' not an image type");
|
||||
return new ErrorBox(null,"You did not upload an image file. Try again.",
|
||||
"sysadmin?cmd=UM&uid=" + admuser.getUID());
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // get the real picture (normalized to 100x100 size)
|
||||
ImageLengthPair real_pic = ImageNormalizer.normalizeImage(mphandler.getFileContentStream("thepic"),
|
||||
engine.getUserPhotoSize(),"jpeg");
|
||||
|
||||
// set the user photo data!
|
||||
ContactInfo ci = admuser.getContactInfo();
|
||||
ci.setPhotoData(request.getContextPath() + "/imagedata/","image/jpeg",real_pic.getLength(),
|
||||
real_pic.getData());
|
||||
admuser.putContactInfo(ci);
|
||||
|
||||
// Jump back to the profile form.
|
||||
throw new RedirectResult("sysadmin?cmd=UM&uid=" + admuser.getUID());
|
||||
|
||||
} // end try
|
||||
catch (ServletMultipartException smpe)
|
||||
{ // the servlet multipart parser screwed up
|
||||
logger.error("Servlet multipart error:",smpe);
|
||||
return new ErrorBox(null,"Internal Error: " + smpe.getMessage(),
|
||||
"sysadmin?cmd=UM&uid=" + admuser.getUID());
|
||||
|
||||
} // end catch
|
||||
catch (ImageNormalizerException ine)
|
||||
{ // the image was not valid
|
||||
logger.error("Image normalizer error:",ine);
|
||||
return new ErrorBox(null,ine.getMessage(),"admuserphoto?uid=" + admuser.getUID());
|
||||
|
||||
} // end catch
|
||||
catch (DataException de)
|
||||
{ // error in the database!
|
||||
logger.error("DataException:",de);
|
||||
return new ErrorBox("Database Error","Database error storing user photo: " + de.getMessage(),
|
||||
"sysadmin?cmd=UM&uid=" + admuser.getUID());
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // the button must be wrong!
|
||||
logger.error("no known button click on AdminUserPhoto.doPost");
|
||||
return new ErrorBox("Internal Error","Unknown command button pressed",
|
||||
"sysadmin?cmd=UM&uid=" + admuser.getUID());
|
||||
|
||||
} // end else
|
||||
|
||||
} // end doVenicePost
|
||||
|
||||
} // end class AdminUserPhoto
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
@@ -25,6 +27,74 @@ import com.silverwrist.venice.security.Role;
|
||||
|
||||
public class AdminModifyUserDialog extends ContentDialog
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* The photo URL control class.
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static class CDUserPhotoControl extends CDBaseFormField
|
||||
{
|
||||
private String linkURL;
|
||||
|
||||
public CDUserPhotoControl(String name, String caption, String linkURL)
|
||||
{
|
||||
super(name,caption,"(click to change)",false);
|
||||
this.linkURL = linkURL;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected CDUserPhotoControl(CDUserPhotoControl other)
|
||||
{
|
||||
super(other);
|
||||
this.linkURL = other.linkURL;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected void renderActualField(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
if (isEnabled())
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath(linkURL) + "\">");
|
||||
String photo = getValue();
|
||||
if (StringUtil.isStringEmpty(photo))
|
||||
photo = rdat.getPhotoNotAvailURL();
|
||||
out.write("<IMG SRC=\"" + photo + "\" ALT=\"\" BORDER=0 WIDTH=100 HEIGHT=100></A>");
|
||||
if (isEnabled())
|
||||
out.write("</A>");
|
||||
|
||||
} // end renderActualField
|
||||
|
||||
protected void validateContents(String value) throws ValidationException
|
||||
{ // this is a do-nothing value
|
||||
} // end validateContents
|
||||
|
||||
public CDFormField duplicate()
|
||||
{
|
||||
return new CDUserPhotoControl(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
public void setLinkURL(String s)
|
||||
{
|
||||
linkURL = s;
|
||||
|
||||
} // end setLinkURL
|
||||
|
||||
} // end class CDUserPhotoControl
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String YES = "Y";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private CDUserPhotoControl photo_control;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
@@ -43,8 +113,9 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
addFormField(new CDTextFormField("remind","Password reminder phrase",null,false,32,255));
|
||||
addFormField(new CDRoleListFormField("base_lvl","Base security level",null,true,
|
||||
Collections.EMPTY_LIST));
|
||||
addFormField(new CDCheckBoxFormField("verify_email","E-mail address verified",null,"Y"));
|
||||
addFormField(new CDCheckBoxFormField("lockout","Account locked out",null,"Y"));
|
||||
addFormField(new CDCheckBoxFormField("verify_email","E-mail address verified",null,YES));
|
||||
addFormField(new CDCheckBoxFormField("lockout","Account locked out",null,YES));
|
||||
addFormField(new CDCheckBoxFormField("nophoto","Disallow photo uploads for this user",null,YES));
|
||||
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));
|
||||
@@ -55,7 +126,7 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
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 CDCheckBoxFormField("pvt_addr","Hide address in profile",null,YES));
|
||||
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));
|
||||
@@ -63,16 +134,20 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
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 CDCheckBoxFormField("pvt_phone","Hide phone/mobile numbers in profile",null,YES));
|
||||
addFormField(new CDTextFormField("fax","Fax",null,false,32,32));
|
||||
addFormField(new CDCheckBoxFormField("pvt_fax","Hide fax number in profile",null,"Y"));
|
||||
addFormField(new CDCheckBoxFormField("pvt_fax","Hide fax number in profile",null,YES));
|
||||
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 CDCheckBoxFormField("pvt_email","Hide e-mail address in profile",null,YES));
|
||||
addFormField(new CDTextFormField("url","Home page","(URL)",false,32,255));
|
||||
addFormField(new CDFormCategoryHeader("Personal"));
|
||||
addFormField(new CDTextFormField("descr","Personal description",null,false,32,255));
|
||||
photo_control = new CDUserPhotoControl("photo","User Photo","userphoto");
|
||||
addFormField(photo_control);
|
||||
addFormField(new CDFormCategoryHeader("User Preferences"));
|
||||
addFormField(new CDCheckBoxFormField("pic_in_post","Display user photos next to conference posts",
|
||||
"(where applicable)",YES));
|
||||
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));
|
||||
@@ -83,6 +158,7 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
protected AdminModifyUserDialog(AdminModifyUserDialog other)
|
||||
{
|
||||
super(other);
|
||||
photo_control = (CDUserPhotoControl)modifyField("photo");
|
||||
|
||||
} // end AdminModifyUserDialog
|
||||
|
||||
@@ -172,12 +248,15 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
|
||||
setFieldValue("base_lvl",String.valueOf(admuser.getBaseLevel()));
|
||||
if (admuser.isEmailVerified())
|
||||
setFieldValue("verify_email","Y");
|
||||
setFieldValue("verify_email",YES);
|
||||
if (admuser.isLockedOut())
|
||||
setFieldValue("lockout","Y");
|
||||
setFieldValue("lockout",YES);
|
||||
|
||||
ContactInfo ci = admuser.getContactInfo(); // get the main contact info
|
||||
AdminUserProperties props = admuser.getProperties();
|
||||
|
||||
if (props.getDisallowPhoto())
|
||||
setFieldValue("nophoto",YES);
|
||||
setFieldValue("prefix",ci.getNamePrefix());
|
||||
setFieldValue("first",ci.getGivenName());
|
||||
char init = ci.getMiddleInitial();
|
||||
@@ -189,7 +268,7 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
setFieldValue("addr1",ci.getAddressLine1());
|
||||
setFieldValue("addr2",ci.getAddressLine2());
|
||||
if (ci.getPrivateAddress())
|
||||
setFieldValue("pvt_addr","Y");
|
||||
setFieldValue("pvt_addr",YES);
|
||||
setFieldValue("loc",ci.getLocality());
|
||||
setFieldValue("reg",ci.getRegion());
|
||||
setFieldValue("pcode",ci.getPostalCode());
|
||||
@@ -197,15 +276,19 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
setFieldValue("phone",ci.getPhone());
|
||||
setFieldValue("mobile",ci.getMobile());
|
||||
if (ci.getPrivatePhone())
|
||||
setFieldValue("pvt_phone","Y");
|
||||
setFieldValue("pvt_phone",YES);
|
||||
setFieldValue("fax",ci.getFax());
|
||||
if (ci.getPrivateFax())
|
||||
setFieldValue("pvt_fax","Y");
|
||||
setFieldValue("pvt_fax",YES);
|
||||
setFieldValue("email",ci.getEmail());
|
||||
if (ci.getPrivateEmail())
|
||||
setFieldValue("pvt_email","Y");
|
||||
setFieldValue("pvt_email",YES);
|
||||
setFieldValue("url",ci.getURL());
|
||||
setFieldValue("descr",admuser.getDescription());
|
||||
setFieldValue("photo",ci.getPhotoURL());
|
||||
photo_control.setLinkURL("adminuserphoto?uid=" + admuser.getUID());
|
||||
if (props.getDisplayPostPictures())
|
||||
setFieldValue("pic_in_post",YES);
|
||||
setFieldValue("locale",admuser.getLocale().toString());
|
||||
setFieldValue("tz",admuser.getTimeZone().getID());
|
||||
|
||||
@@ -215,8 +298,6 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
{
|
||||
validate(); // validate the dialog
|
||||
|
||||
final String yes = "Y"; // the "yes" string
|
||||
|
||||
try
|
||||
{ // reset the base level
|
||||
admuser.setBaseLevel(Integer.parseInt(getFieldValue("base_lvl")));
|
||||
@@ -233,12 +314,14 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
if (!StringUtil.isStringEmpty(foo))
|
||||
admuser.setPassword(foo,getFieldValue("remind"));
|
||||
|
||||
admuser.setEmailVerified(yes.equals(getFieldValue("verify_email")));
|
||||
admuser.setLockedOut(yes.equals(getFieldValue("lockout")));
|
||||
admuser.setEmailVerified(YES.equals(getFieldValue("verify_email")));
|
||||
admuser.setLockedOut(YES.equals(getFieldValue("lockout")));
|
||||
|
||||
ContactInfo ci = admuser.getContactInfo(); // get the main contact info
|
||||
AdminUserProperties props = admuser.getProperties();
|
||||
|
||||
// Reset all the contact info fields.
|
||||
props.setDisallowPhoto(YES.equals(getFieldValue("nophoto")));
|
||||
ci.setNamePrefix(getFieldValue("prefix"));
|
||||
ci.setGivenName(getFieldValue("first"));
|
||||
foo = getFieldValue("mid");
|
||||
@@ -251,22 +334,24 @@ public class AdminModifyUserDialog extends ContentDialog
|
||||
ci.setCompany(getFieldValue("company"));
|
||||
ci.setAddressLine1(getFieldValue("addr1"));
|
||||
ci.setAddressLine2(getFieldValue("addr2"));
|
||||
ci.setPrivateAddress(yes.equals(getFieldValue("pvt_addr")));
|
||||
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.setPrivatePhone(YES.equals(getFieldValue("pvt_phone")));
|
||||
ci.setFax(getFieldValue("fax"));
|
||||
ci.setPrivateFax(yes.equals(getFieldValue("pvt_fax")));
|
||||
ci.setPrivateFax(YES.equals(getFieldValue("pvt_fax")));
|
||||
ci.setEmail(getFieldValue("email"));
|
||||
ci.setPrivateEmail(yes.equals(getFieldValue("pvt_email")));
|
||||
ci.setPrivateEmail(YES.equals(getFieldValue("pvt_email")));
|
||||
ci.setURL(getFieldValue("url"));
|
||||
props.setDisplayPostPictures(YES.equals(getFieldValue("pic_in_post")));
|
||||
|
||||
// Store the completed contact info.
|
||||
admuser.putContactInfo(ci);
|
||||
admuser.setProperties(props);
|
||||
|
||||
// Save off the user's description and preferences.
|
||||
admuser.setDescription(getFieldValue("descr"));
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* 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.awt.Dimension;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.*;
|
||||
import com.silverwrist.venice.except.*;
|
||||
|
||||
public class AdminUserPhotoData implements JSPRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Attribute name for request attribute
|
||||
protected static final String ATTR_NAME = "com.silverwrist.venice.content.AdminUserPhotoData";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private Dimension photo_dims;
|
||||
private String photo_url;
|
||||
private int uid;
|
||||
private String user_name;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public AdminUserPhotoData(VeniceEngine engine, AdminUserContext admuser, RenderData rdat)
|
||||
throws DataException
|
||||
{
|
||||
photo_dims = engine.getUserPhotoSize();
|
||||
photo_url = admuser.getContactInfo().getPhotoURL();
|
||||
if (StringUtil.isStringEmpty(photo_url))
|
||||
photo_url = rdat.getPhotoNotAvailURL();
|
||||
this.uid = admuser.getUID();
|
||||
this.user_name = admuser.getUserName();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static functions
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static AdminUserPhotoData retrieve(ServletRequest request)
|
||||
{
|
||||
return (AdminUserPhotoData)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VeniceContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
return "Set User Photo";
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
public String getPageQID()
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end getPageQID
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface JSPRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void store(ServletRequest request)
|
||||
{
|
||||
request.setAttribute(ATTR_NAME,this);
|
||||
|
||||
} // end store
|
||||
|
||||
public String getTargetJSPName()
|
||||
{
|
||||
return "admin_user_photo.jsp";
|
||||
|
||||
} // end getTargetJSPName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public int getUID()
|
||||
{
|
||||
return uid;
|
||||
|
||||
} // end getUID
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
return user_name;
|
||||
|
||||
} // end getUserName
|
||||
|
||||
public String getPhotoTag(RenderData rdat)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer("<IMG SRC=\"");
|
||||
buf.append(photo_url).append("\" ALT=\"\" ALIGN=LEFT WIDTH=").append(photo_dims.width).append(" HEIGHT=");
|
||||
buf.append(photo_dims.height).append(" HSPACE=6 VSPACE=0 BORDER=0>");
|
||||
return buf.toString();
|
||||
|
||||
} // end getPhotoTag
|
||||
|
||||
} // end class AdminUserPhotoData
|
||||
@@ -208,6 +208,7 @@ public class EditProfileDialog extends ContentDialog
|
||||
ContactInfo ci = uc.getContactInfo(); // get the main contact info
|
||||
UserProperties props = uc.getProperties(); // get the properties
|
||||
|
||||
setFieldEnabled("photo",ci.canSetPhoto());
|
||||
setFieldValue("prefix",ci.getNamePrefix());
|
||||
setFieldValue("first",ci.getGivenName());
|
||||
char init = ci.getMiddleInitial();
|
||||
@@ -300,11 +301,12 @@ public class EditProfileDialog extends ContentDialog
|
||||
|
||||
} // end doDialog
|
||||
|
||||
public void resetOnError(String message)
|
||||
public void resetOnError(boolean photo_flag, String message)
|
||||
{
|
||||
setErrorMessage(message);
|
||||
setFieldValue("pass1",null);
|
||||
setFieldValue("pass2",null);
|
||||
setFieldEnabled("photo",photo_flag);
|
||||
|
||||
} // end resetOnError
|
||||
|
||||
|
||||
Reference in New Issue
Block a user