added "date of birth" as a users table field, added appropriate code to core
to get and set it, added "date" dialog field and updated registration, profile, and admin modify to use it to change a user's date of birth; added BDAY support to vCards and rigged user import/export to take it into account; cleaned up a few other matters while I was in that particular code
This commit is contained in:
parent
50c76b3dc7
commit
5c0f841ab7
|
@ -490,6 +490,8 @@ To create a new account, please enter your information below.
|
|||
<countrylist name="country" capt="Country" required="true"/>
|
||||
<header capt="E-Mail"/>
|
||||
<email name="email" capt="E-mail address" required="true" size="32" maxlength="255"/>
|
||||
<header capt="Other Information"/>
|
||||
<date name="dob" capt="Date of birth" years="-100"/>
|
||||
<header capt="Account Information"/>
|
||||
<veniceid name="user" capt="User name" required="true" size="32" maxlength="64"/>
|
||||
<password name="pass1" capt="Password" required="true" size="32" maxlength="128"/>
|
||||
|
@ -549,6 +551,7 @@ will be fully validated. If you have not received your confirmation within a fe
|
|||
<checkbox name="pvt_email" capt="Hide E-mail address in profile"/>
|
||||
<text name="url" capt="Home Page" capt2="(URL)" size="32" maxlength="255"/>
|
||||
<header capt="Personal"/>
|
||||
<date name="dob" capt="Date of birth" years="-100"/>
|
||||
<text name="descr" capt="Personal description" size="32" maxlength="255"/>
|
||||
<userphoto name="photo" capt="User Photo" link="profile_photo.js.vs" type="servlet"/>
|
||||
<header capt="User Preferences"/>
|
||||
|
@ -708,6 +711,7 @@ the community's host, or via an invitation e-mail message. Please enter it in th
|
|||
<checkbox name="pvt_email" capt="Hide E-mail address in profile"/>
|
||||
<text name="url" capt="Home Page" capt2="(URL)" size="32" maxlength="255"/>
|
||||
<header capt="Personal"/>
|
||||
<date name="dob" capt="Date of birth" years="-100"/>
|
||||
<text name="descr" capt="Personal description" size="32" maxlength="255"/>
|
||||
<userphoto name="photo" capt="User Photo" link="sysadmin/modify_photo.js.vs" type="servlet"/>
|
||||
<header capt="User Preferences"/>
|
||||
|
|
|
@ -84,7 +84,7 @@ if (op=="create")
|
|||
|
||||
// Create the new user account and set up its initial context.
|
||||
uc = rinput.engine.createNewAccount(rinput.sourceAddress,dlg.getValue("user"),dlg.getValue("pass1"),
|
||||
dlg.getValue("remind"));
|
||||
dlg.getValue("remind"),dlg.getValue("dob"));
|
||||
|
||||
// Set up the account's contact info.
|
||||
ci = uc.getContactInfo();
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// 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 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
// Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
|
@ -74,6 +74,7 @@ if ("GET"==rinput.verb)
|
|||
if (ci.privateEmail)
|
||||
dlg.setValue("pvt_email",1);
|
||||
dlg.setValue("url",ci.URL);
|
||||
dlg.setValue("dob",user.dateOfBirth);
|
||||
dlg.setValue("descr",user.description);
|
||||
dlg.setValue("photo",ci.photoURL);
|
||||
dlg.sendMessage("photo","setLinkURL","profile_photo.js.vs?tgt=" + vlib.encodeURL(target));
|
||||
|
@ -175,6 +176,7 @@ if (op=="update")
|
|||
user.properties = props;
|
||||
|
||||
// Save off the user's description and preferences.
|
||||
user.dateOfBirth = dlg.getValue("dob");
|
||||
user.description = dlg.getValue("descr");
|
||||
user.locale = dlg.getValue("locale");
|
||||
user.timeZone = dlg.getValue("tz");
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// 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 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
// Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
|
@ -115,6 +115,7 @@ if ("GET"==rinput.verb)
|
|||
if (ci.privateEmail)
|
||||
dlg.setValue("pvt_email",1);
|
||||
dlg.setValue("url",ci.URL);
|
||||
dlg.setValue("dob",admuser.dateOfBirth);
|
||||
dlg.setValue("descr",admuser.description);
|
||||
dlg.setValue("photo",ci.photoURL);
|
||||
if (props.displayPostPictures)
|
||||
|
@ -233,6 +234,7 @@ if (op=="update")
|
|||
admuser.properties = props;
|
||||
|
||||
// Save off the user's description and preferences.
|
||||
admuser.dateOfBirth = dlg.getValue("dob");
|
||||
admuser.description = dlg.getValue("descr");
|
||||
admuser.locale = dlg.getValue("locale");
|
||||
admuser.timeZone = dlg.getValue("tz");
|
||||
|
|
|
@ -90,6 +90,7 @@ CREATE TABLE users (
|
|||
lastaccess DATETIME,
|
||||
passreminder VARCHAR(255) DEFAULT '',
|
||||
description VARCHAR(255),
|
||||
dob DATE,
|
||||
UNIQUE INDEX username_x (username)
|
||||
);
|
||||
|
||||
|
|
|
@ -24,40 +24,38 @@ import com.silverwrist.venice.security.Role;
|
|||
|
||||
public interface AdminOperations
|
||||
{
|
||||
public abstract SecurityInfo getSecurityInfo();
|
||||
public SecurityInfo getSecurityInfo();
|
||||
|
||||
public abstract List getAllowedRoleList();
|
||||
public List getAllowedRoleList();
|
||||
|
||||
public abstract List getAuditRecords(int offset, int count) throws DataException;
|
||||
public List getAuditRecords(int offset, int count) throws DataException;
|
||||
|
||||
public abstract int getAuditRecordCount() throws DataException;
|
||||
public int getAuditRecordCount() throws DataException;
|
||||
|
||||
public abstract AdminUserContext getUserContext(int uid) throws DataException;
|
||||
public AdminUserContext getUserContext(int uid) throws DataException;
|
||||
|
||||
public abstract AdminUserContext getUserContext(String username) throws DataException;
|
||||
public AdminUserContext getUserContext(String username) throws DataException;
|
||||
|
||||
public abstract CommunityContext getCommunityContext(int cid) throws DataException;
|
||||
public CommunityContext getCommunityContext(int cid) throws DataException;
|
||||
|
||||
public abstract CommunityContext getCommunityContext(String alias) throws DataException;
|
||||
public CommunityContext getCommunityContext(String alias) throws DataException;
|
||||
|
||||
public abstract GlobalProperties getProperties();
|
||||
public GlobalProperties getProperties();
|
||||
|
||||
public abstract void setProperties(GlobalProperties props) throws DataException;
|
||||
public void setProperties(GlobalProperties props) throws DataException;
|
||||
|
||||
public abstract AdminUserContext createNewAccount(String username, String password, boolean prehashed,
|
||||
String reminder, boolean verify_email, boolean lockout,
|
||||
Role base_role, String description, boolean auto_join)
|
||||
throws DataException, AccessError;
|
||||
public AdminUserContext createNewAccount(String username, String password, boolean prehashed, String reminder,
|
||||
boolean verify_email, boolean lockout, Role base_role, String description,
|
||||
java.sql.Date dob, boolean auto_join) throws DataException, AccessError;
|
||||
|
||||
public abstract List getIPBanInfo() throws DataException;
|
||||
public List getIPBanInfo() throws DataException;
|
||||
|
||||
public abstract IPBanInfo getIPBanInfo(int id) throws DataException;
|
||||
public IPBanInfo getIPBanInfo(int id) throws DataException;
|
||||
|
||||
public abstract void enableIPBan(int id, boolean enab) throws DataException;
|
||||
public void enableIPBan(int id, boolean enab) throws DataException;
|
||||
|
||||
public abstract void removeIPBan(int id) throws DataException;
|
||||
public void removeIPBan(int id) throws DataException;
|
||||
|
||||
public abstract void addIPBan(String address, String mask, java.util.Date expires, String message)
|
||||
throws DataException;
|
||||
public void addIPBan(String address, String mask, java.util.Date expires, String message) throws DataException;
|
||||
|
||||
} // end interface AdminOperations
|
||||
|
|
|
@ -27,54 +27,58 @@ import com.silverwrist.venice.security.Role;
|
|||
|
||||
public interface AdminUserContext
|
||||
{
|
||||
public abstract int getUID();
|
||||
public int getUID();
|
||||
|
||||
public abstract String getUserName();
|
||||
public String getUserName();
|
||||
|
||||
public abstract int getContactID();
|
||||
public int getContactID();
|
||||
|
||||
public abstract String getDescription();
|
||||
public String getDescription();
|
||||
|
||||
public abstract void setDescription(String new_descr) throws DataException;
|
||||
public void setDescription(String new_descr) throws DataException;
|
||||
|
||||
public abstract int getBaseLevel();
|
||||
public int getBaseLevel();
|
||||
|
||||
public abstract void setBaseLevel(int new_level) throws DataException;
|
||||
public void setBaseLevel(int new_level) throws DataException;
|
||||
|
||||
public abstract Role getBaseRole();
|
||||
public Role getBaseRole();
|
||||
|
||||
public abstract void setBaseRole(Role new_role) throws DataException;
|
||||
public void setBaseRole(Role new_role) throws DataException;
|
||||
|
||||
public abstract boolean isEmailVerified();
|
||||
public boolean isEmailVerified();
|
||||
|
||||
public abstract void setEmailVerified(boolean flag) throws DataException;
|
||||
public void setEmailVerified(boolean flag) throws DataException;
|
||||
|
||||
public abstract boolean isLockedOut();
|
||||
public boolean isLockedOut();
|
||||
|
||||
public abstract void setLockedOut(boolean flag) throws DataException;
|
||||
public void setLockedOut(boolean flag) throws DataException;
|
||||
|
||||
public abstract ContactInfo getContactInfo() throws DataException;
|
||||
public ContactInfo getContactInfo() throws DataException;
|
||||
|
||||
public abstract void putContactInfo(ContactInfo ci) throws DataException;
|
||||
public void putContactInfo(ContactInfo ci) throws DataException;
|
||||
|
||||
public abstract void setPassword(String password, String reminder) throws DataException;
|
||||
public void setPassword(String password, String reminder) throws DataException;
|
||||
|
||||
public abstract Locale getLocale();
|
||||
public Locale getLocale();
|
||||
|
||||
public abstract void setLocale(Locale locale) throws DataException;
|
||||
public void setLocale(Locale locale) throws DataException;
|
||||
|
||||
public abstract TimeZone getTimeZone();
|
||||
public TimeZone getTimeZone();
|
||||
|
||||
public abstract void setTimeZone(TimeZone timezone) throws DataException;
|
||||
public void setTimeZone(TimeZone timezone) throws DataException;
|
||||
|
||||
public abstract Date getCreationDate();
|
||||
public Date getCreationDate();
|
||||
|
||||
public abstract Date getLastAccessDate();
|
||||
public Date getLastAccessDate();
|
||||
|
||||
public abstract AdminUserProperties getProperties() throws DataException;
|
||||
public AdminUserProperties getProperties() throws DataException;
|
||||
|
||||
public abstract void setProperties(AdminUserProperties props) throws DataException;
|
||||
public void setProperties(AdminUserProperties props) throws DataException;
|
||||
|
||||
public abstract void export(Writer xml) throws IOException, DataException;
|
||||
public void export(Writer xml) throws IOException, DataException;
|
||||
|
||||
public java.sql.Date getDateOfBirth();
|
||||
|
||||
public void setDateOfBirth(java.sql.Date date) throws DataException;
|
||||
|
||||
} // end interface AdminUserContext
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* 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 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
@ -26,106 +26,109 @@ import com.silverwrist.venice.except.EmailException;
|
|||
|
||||
public interface UserContext extends SearchMode
|
||||
{
|
||||
public abstract int getUID();
|
||||
public int getUID();
|
||||
|
||||
public abstract String getUserName();
|
||||
public String getUserName();
|
||||
|
||||
public abstract int getContactID();
|
||||
public int getContactID();
|
||||
|
||||
public abstract String getDescription();
|
||||
public String getDescription();
|
||||
|
||||
public abstract boolean isLoggedIn();
|
||||
public boolean isLoggedIn();
|
||||
|
||||
public abstract boolean isEmailVerified();
|
||||
public boolean isEmailVerified();
|
||||
|
||||
public abstract void authenticate(String username, String password)
|
||||
throws AccessError, DataException;
|
||||
public void authenticate(String username, String password) throws AccessError, DataException;
|
||||
|
||||
public abstract void confirmEmail(int conf_num) throws AccessError, DataException;
|
||||
public void confirmEmail(int conf_num) throws AccessError, DataException;
|
||||
|
||||
public abstract void resendEmailConfirmation() throws DataException, EmailException;
|
||||
public void resendEmailConfirmation() throws DataException, EmailException;
|
||||
|
||||
public abstract ContactInfo getContactInfo() throws DataException;
|
||||
public ContactInfo getContactInfo() throws DataException;
|
||||
|
||||
public abstract boolean putContactInfo(ContactInfo ci) throws DataException, EmailException;
|
||||
public boolean putContactInfo(ContactInfo ci) throws DataException, EmailException;
|
||||
|
||||
public abstract UserProfile getProfile(String xusername) throws DataException;
|
||||
public UserProfile getProfile(String xusername) throws DataException;
|
||||
|
||||
public abstract UserProfile getProfile(int xuid) throws DataException;
|
||||
public UserProfile getProfile(int xuid) throws DataException;
|
||||
|
||||
public abstract void setPassword(String password, String reminder) throws DataException;
|
||||
public void setPassword(String password, String reminder) throws DataException;
|
||||
|
||||
public abstract void setDescription(String new_descr) throws DataException;
|
||||
public void setDescription(String new_descr) throws DataException;
|
||||
|
||||
public abstract List getMemberCommunities() throws DataException;
|
||||
public List getMemberCommunities() throws DataException;
|
||||
|
||||
public abstract CommunityContext getCommunityContext(int cid) throws DataException;
|
||||
public CommunityContext getCommunityContext(int cid) throws DataException;
|
||||
|
||||
public abstract CommunityContext getCommunityContext(String alias) throws DataException;
|
||||
public CommunityContext getCommunityContext(String alias) throws DataException;
|
||||
|
||||
public abstract List getRootCategoryList() throws DataException;
|
||||
public List getRootCategoryList() throws DataException;
|
||||
|
||||
public abstract CategoryDescriptor getCategoryDescriptor(int catid) throws DataException;
|
||||
public CategoryDescriptor getCategoryDescriptor(int catid) throws DataException;
|
||||
|
||||
public abstract List searchForCommunities(int field, int mode, String term, int offset, int count)
|
||||
public List searchForCommunities(int field, int mode, String term, int offset, int count)
|
||||
throws DataException;
|
||||
|
||||
public abstract int getSearchCommunityCount(int field, int mode, String term) throws DataException;
|
||||
public int getSearchCommunityCount(int field, int mode, String term) throws DataException;
|
||||
|
||||
public abstract List getCommunitiesInCategory(int catid, int offset, int count) throws DataException;
|
||||
public List getCommunitiesInCategory(int catid, int offset, int count) throws DataException;
|
||||
|
||||
public abstract List getCommunitiesInCategory(CategoryDescriptor cat, int offset, int count)
|
||||
public List getCommunitiesInCategory(CategoryDescriptor cat, int offset, int count)
|
||||
throws DataException;
|
||||
|
||||
public abstract int getNumCommunitiesInCategory(int catid) throws DataException;
|
||||
public int getNumCommunitiesInCategory(int catid) throws DataException;
|
||||
|
||||
public abstract int getNumCommunitiesInCategory(CategoryDescriptor cat) throws DataException;
|
||||
public int getNumCommunitiesInCategory(CategoryDescriptor cat) throws DataException;
|
||||
|
||||
public abstract List searchForCategories(int mode, String term, int offset, int count) throws DataException;
|
||||
public List searchForCategories(int mode, String term, int offset, int count) throws DataException;
|
||||
|
||||
public abstract int getSearchCategoryCount(int mode, String term) throws DataException;
|
||||
public int getSearchCategoryCount(int mode, String term) throws DataException;
|
||||
|
||||
public abstract CommunityContext createCommunity(String name, String alias, String language, String synopsis,
|
||||
String rules, String joinkey, int hide_mode)
|
||||
public CommunityContext createCommunity(String name, String alias, String language, String synopsis,
|
||||
String rules, String joinkey, int hide_mode)
|
||||
throws DataException, AccessError;
|
||||
|
||||
public abstract boolean canCreateCommunity();
|
||||
public boolean canCreateCommunity();
|
||||
|
||||
public abstract List getSideBoxList() throws DataException;
|
||||
public List getSideBoxList() throws DataException;
|
||||
|
||||
public abstract void addSideBox(int id) throws DataException;
|
||||
public void addSideBox(int id) throws DataException;
|
||||
|
||||
public abstract List getConferenceHotlist() throws DataException;
|
||||
public List getConferenceHotlist() throws DataException;
|
||||
|
||||
public abstract boolean hasAdminAccess();
|
||||
public boolean hasAdminAccess();
|
||||
|
||||
public abstract AdminOperations getAdminInterface() throws AccessError;
|
||||
public AdminOperations getAdminInterface() throws AccessError;
|
||||
|
||||
public abstract Locale getLocale() throws DataException;
|
||||
public Locale getLocale() throws DataException;
|
||||
|
||||
public abstract void setLocale(Locale locale) throws DataException;
|
||||
public void setLocale(Locale locale) throws DataException;
|
||||
|
||||
public abstract TimeZone getTimeZone() throws DataException;
|
||||
public TimeZone getTimeZone() throws DataException;
|
||||
|
||||
public abstract void setTimeZone(TimeZone timezone) throws DataException;
|
||||
public void setTimeZone(TimeZone timezone) throws DataException;
|
||||
|
||||
public abstract String getAuthenticationToken() throws AccessError, DataException;
|
||||
public String getAuthenticationToken() throws AccessError, DataException;
|
||||
|
||||
public abstract boolean authenticateWithToken(String token) throws DataException;
|
||||
public boolean authenticateWithToken(String token) throws DataException;
|
||||
|
||||
public abstract Advertisement selectAd();
|
||||
public Advertisement selectAd();
|
||||
|
||||
public abstract boolean displayPostPictures() throws DataException;
|
||||
public boolean displayPostPictures() throws DataException;
|
||||
|
||||
public abstract UserProperties getProperties() throws DataException;
|
||||
public UserProperties getProperties() throws DataException;
|
||||
|
||||
public abstract void setProperties(UserProperties props) throws DataException;
|
||||
public void setProperties(UserProperties props) throws DataException;
|
||||
|
||||
public abstract boolean canSetUserPhoto() throws DataException;
|
||||
public boolean canSetUserPhoto() throws DataException;
|
||||
|
||||
public abstract List searchPosts(String search_terms, int offset, int count) throws DataException;
|
||||
public List searchPosts(String search_terms, int offset, int count) throws DataException;
|
||||
|
||||
public abstract int getSearchPostCount(String search_terms) throws DataException;
|
||||
public int getSearchPostCount(String search_terms) throws DataException;
|
||||
|
||||
public java.sql.Date getDateOfBirth();
|
||||
|
||||
public void setDateOfBirth(java.sql.Date date) throws DataException;
|
||||
|
||||
} // end interface UserContext
|
||||
|
||||
|
|
|
@ -29,68 +29,65 @@ import com.silverwrist.venice.htmlcheck.HTMLChecker;
|
|||
|
||||
public interface VeniceEngine extends SearchMode, ServiceGroup
|
||||
{
|
||||
public abstract void initialize(Document config, String app_root) throws ConfigException, DataException;
|
||||
public void initialize(Document config, String app_root) throws ConfigException, DataException;
|
||||
|
||||
public abstract void shutdown() throws ConfigException;
|
||||
public void shutdown() throws ConfigException;
|
||||
|
||||
public abstract UserContext createUserContext(String remote_addr) throws DataException;
|
||||
public UserContext createUserContext(String remote_addr) throws DataException;
|
||||
|
||||
public abstract String getEmailAddressForUser(String username) throws DataException, AccessError;
|
||||
public String getEmailAddressForUser(String username) throws DataException, AccessError;
|
||||
|
||||
public abstract void sendPasswordReminder(String username)
|
||||
throws DataException, AccessError, EmailException;
|
||||
public void sendPasswordReminder(String username) throws DataException, AccessError, EmailException;
|
||||
|
||||
public abstract void completePasswordChange(int uid, int authentication)
|
||||
throws DataException, AccessError, EmailException;
|
||||
public void completePasswordChange(int uid, int authentication) throws DataException, AccessError, EmailException;
|
||||
|
||||
public abstract UserContext createNewAccount(String remote_addr, String username, String password,
|
||||
String reminder) throws DataException, AccessError;
|
||||
public UserContext createNewAccount(String remote_addr, String username, String password,
|
||||
String reminder, java.sql.Date dob) throws DataException, AccessError;
|
||||
|
||||
public abstract boolean aliasExists(String alias, int exist_cid);
|
||||
public boolean aliasExists(String alias, int exist_cid);
|
||||
|
||||
public abstract boolean isValidCategoryID(int catid);
|
||||
public boolean isValidCategoryID(int catid);
|
||||
|
||||
public abstract List searchForUsers(int field, int mode, String term, int offset, int count)
|
||||
throws DataException;
|
||||
public List searchForUsers(int field, int mode, String term, int offset, int count) throws DataException;
|
||||
|
||||
public abstract int getSearchUserCount(int field, int mode, String term) throws DataException;
|
||||
public int getSearchUserCount(int field, int mode, String term) throws DataException;
|
||||
|
||||
public abstract int getStdNumSearchResults();
|
||||
public int getStdNumSearchResults();
|
||||
|
||||
public abstract boolean isEmailAddressBanned(String email);
|
||||
public boolean isEmailAddressBanned(String email);
|
||||
|
||||
public abstract boolean confAliasExists(String alias);
|
||||
public boolean confAliasExists(String alias);
|
||||
|
||||
public abstract HTMLChecker getEscapingChecker();
|
||||
public HTMLChecker getEscapingChecker();
|
||||
|
||||
public abstract int getNumPostsPerPage();
|
||||
public int getNumPostsPerPage();
|
||||
|
||||
public abstract int getNumOldPostsBeforeNew();
|
||||
public int getNumOldPostsBeforeNew();
|
||||
|
||||
public abstract int getMaxNumConferenceMembersDisplay();
|
||||
public int getMaxNumConferenceMembersDisplay();
|
||||
|
||||
public abstract int getMaxNumCommunityMembersDisplay();
|
||||
public int getMaxNumCommunityMembersDisplay();
|
||||
|
||||
public abstract List getMasterSideBoxList();
|
||||
public List getMasterSideBoxList();
|
||||
|
||||
public abstract List getPublishedMessages(boolean all) throws DataException;
|
||||
public List getPublishedMessages(boolean all) throws DataException;
|
||||
|
||||
public abstract int getNumAuditRecordsPerPage();
|
||||
public int getNumAuditRecordsPerPage();
|
||||
|
||||
public abstract Advertisement getAdByID(int id);
|
||||
public Advertisement getAdByID(int id);
|
||||
|
||||
public abstract Advertisement selectAd();
|
||||
public Advertisement selectAd();
|
||||
|
||||
public abstract BinaryData loadImage(int id) throws DataException;
|
||||
public BinaryData loadImage(int id) throws DataException;
|
||||
|
||||
public abstract Dimension getUserPhotoSize();
|
||||
public Dimension getUserPhotoSize();
|
||||
|
||||
public abstract Dimension getCommunityLogoSize();
|
||||
public Dimension getCommunityLogoSize();
|
||||
|
||||
public abstract SecurityInfo getSecurityInfo();
|
||||
public SecurityInfo getSecurityInfo();
|
||||
|
||||
public abstract boolean useCategories();
|
||||
public boolean useCategories();
|
||||
|
||||
public abstract String testIPBan(String ip_address) throws DataException;
|
||||
public String testIPBan(String ip_address) throws DataException;
|
||||
|
||||
} // end interface VeniceEngine
|
||||
|
|
|
@ -278,7 +278,7 @@ class AdminOperationsImpl implements AdminOperations
|
|||
|
||||
public AdminUserContext createNewAccount(String username, String password, boolean prehashed, String reminder,
|
||||
boolean verify_email, boolean lockout, Role base_role,
|
||||
String description, boolean auto_join)
|
||||
String description, java.sql.Date dob, boolean auto_join)
|
||||
throws DataException, AccessError
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
|
@ -289,13 +289,13 @@ class AdminOperationsImpl implements AdminOperations
|
|||
|
||||
// Create the user account.
|
||||
ReturnNewUser rnu = UserContextImpl.createAccount(env,env.getRemoteAddress(),username,password,prehashed,reminder,
|
||||
verify_email,lockout,0,base_role,description);
|
||||
verify_email,lockout,0,base_role,description,dob);
|
||||
|
||||
if (auto_join)
|
||||
{ // Need to create a normal user context here for just a minute to autojoin the communities.
|
||||
UserContextImpl rc = new UserContextImpl(globalsite,env);
|
||||
rc.loadNewUser("0.0.0.0",rnu.getUserID(),base_role.getLevel(),username,0,rnu.getCreationDate(),
|
||||
rnu.getCreationDate());
|
||||
rnu.getCreationDate(),dob);
|
||||
rc.autoJoinCommunities();
|
||||
|
||||
} // end if
|
||||
|
|
|
@ -54,6 +54,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
private java.util.Date created; // when was this user created? (GMT)
|
||||
private java.util.Date last_access; // when did we last log in? (GMT)
|
||||
private String description; // personal description
|
||||
private java.sql.Date m_dob; // date of birth
|
||||
private Locale my_locale; // my default locale (cached)
|
||||
private TimeZone my_tz; // my default timezone (cached)
|
||||
private OptionSet flags = null; // option flags
|
||||
|
@ -75,15 +76,17 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
this.created = SQLUtil.getFullDateTime(rs,"created");
|
||||
this.last_access = SQLUtil.getFullDateTime(rs,"lastaccess");
|
||||
this.description = rs.getString("description");
|
||||
this.m_dob = rs.getDate("dob");
|
||||
this.my_locale = International.get().createLocale(rs.getString("localeid"));
|
||||
this.my_tz = TimeZone.getTimeZone(rs.getString("tzid"));
|
||||
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try
|
||||
{ // get user properties
|
||||
stmt = conn.createStatement();
|
||||
ResultSet rs2 = stmt.executeQuery("SELECT ndx, data FROM propuser WHERE uid = " + this.uid + ";");
|
||||
stmt = conn.prepareStatement("SELECT ndx, data FROM propuser WHERE uid = ?;");
|
||||
stmt.setInt(1,uid);
|
||||
ResultSet rs2 = stmt.executeQuery();
|
||||
while (rs2.next())
|
||||
{ // load the properties...
|
||||
switch (rs2.getInt(1))
|
||||
|
@ -116,19 +119,18 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
private final void updateProperties(BitSet delta) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
try
|
||||
{ // get a connection and create a statement
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer();
|
||||
|
||||
if (delta.get(UserContextImpl.PROP_FLAGS))
|
||||
{ // store the flags
|
||||
sql.append("UPDATE propuser SET data = '").append(flags.asString()).append("' WHERE uid = ");
|
||||
sql.append(uid).append(" AND ndx = ").append(UserContextImpl.PROP_FLAGS).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
sql.setLength(0);
|
||||
stmt = conn.prepareStatement("UPDATE propuser SET data = ? WHERE uid = ? AND ndx = ?;");
|
||||
stmt.setString(1,flags.asString());
|
||||
stmt.setInt(2,uid);
|
||||
stmt.setInt(3,UserContextImpl.PROP_FLAGS);
|
||||
stmt.executeUpdate();
|
||||
|
||||
} // end if
|
||||
|
||||
|
@ -211,7 +213,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
public void setDescription(String new_descr) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
if (new_descr.equals(description))
|
||||
|
@ -220,11 +222,10 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET description = '");
|
||||
sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
stmt = conn.prepareStatement("UPDATE users SET description = ? WHERE uid = ?;");
|
||||
stmt.setString(1,new_descr);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
description = new_descr; // change stored information
|
||||
ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=description");
|
||||
|
||||
|
@ -254,7 +255,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
public void setBaseLevel(int new_level) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
if (level==new_level)
|
||||
|
@ -263,11 +264,10 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET base_lvl = ");
|
||||
sql.append(new_level).append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
stmt = conn.prepareStatement("UPDATE users SET base_lvl = ? WHERE uid = ?;");
|
||||
stmt.setInt(1,new_level);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
level = new_level;
|
||||
ar = env.newAudit(AuditRecord.ADMIN_SET_SECURITY,"uid=" + uid,"level=" + new_level);
|
||||
|
||||
|
@ -309,7 +309,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
public void setEmailVerified(boolean flag) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
if (flag==email_verified)
|
||||
|
@ -318,11 +318,10 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = ");
|
||||
sql.append(flag ? '1' : '0').append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
stmt = conn.prepareStatement("UPDATE users SET verify_email = ? WHERE uid = ?;");
|
||||
stmt.setInt(1,flag ? 1 : 0);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
email_verified = flag;
|
||||
ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=verify_email");
|
||||
|
||||
|
@ -352,7 +351,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
public void setLockedOut(boolean flag) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
if (flag==lockout)
|
||||
|
@ -361,11 +360,10 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET lockout = ");
|
||||
sql.append(flag ? '1' : '0').append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
stmt = conn.prepareStatement("UPDATE users SET lockout = ? WHERE uid = ?;");
|
||||
stmt.setInt(1,flag ? 1 : 0);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
lockout = flag;
|
||||
ar = env.newAudit(AuditRecord.ADMIN_LOCK_OUT,"uid=" + uid,flag ? "locked" : "unlocked");
|
||||
|
||||
|
@ -459,18 +457,17 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
public void setPassword(String password, String reminder) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
String hash_value = Generator.hashPassword(password);
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
|
||||
sql.append(hash_value).append("', passreminder = '").append(SQLUtil.encodeString(reminder));
|
||||
sql.append("', access_tries = 0 WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
stmt = conn.prepareStatement("UPDATE users SET passhash = ?, passreminder = ?, access_tries = 0 WHERE uid = ?;");
|
||||
stmt.setString(1,Generator.hashPassword(password));
|
||||
stmt.setString(2,reminder);
|
||||
stmt.setInt(3,uid);
|
||||
stmt.executeUpdate();
|
||||
|
||||
// record an audit record for this user
|
||||
ar = env.newAudit(AuditRecord.ADMIN_PASSWORD_CHANGE,"uid=" + uid);
|
||||
|
@ -501,20 +498,20 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
public void setLocale(Locale locale) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
|
||||
// create the update statement
|
||||
StringBuffer sql = new StringBuffer("UPDATE userprefs SET localeid = '");
|
||||
sql.append(SQLUtil.encodeString(locale.toString())).append("' WHERE uid = ").append(uid).append(';');
|
||||
stmt = conn.prepareStatement("UPDATE userprefs SET localeid = ? WHERE uid = ?;");
|
||||
stmt.setString(1,locale.toString());
|
||||
stmt.setInt(2,uid);
|
||||
|
||||
// execute the statement
|
||||
stmt.executeUpdate(sql.toString());
|
||||
stmt.executeUpdate();
|
||||
|
||||
// replace the locale here
|
||||
my_locale = locale;
|
||||
|
@ -546,20 +543,20 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
public void setTimeZone(TimeZone timezone) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
|
||||
// create the update statement
|
||||
StringBuffer sql = new StringBuffer("UPDATE userprefs SET tzid = '");
|
||||
sql.append(SQLUtil.encodeString(timezone.getID())).append("' WHERE uid = ").append(uid).append(';');
|
||||
stmt = conn.prepareStatement("UPDATE userprefs SET tzid = ? WHERE uid = ?;");
|
||||
stmt.setString(1,timezone.getID());
|
||||
stmt.setInt(2,uid);
|
||||
|
||||
// execute the statement
|
||||
stmt.executeUpdate(sql.toString());
|
||||
stmt.executeUpdate();
|
||||
|
||||
// replace the locale here
|
||||
my_tz = timezone;
|
||||
|
@ -724,6 +721,7 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
// get the vCard info and serialize it
|
||||
BuildVCard bvc = ci.getVCardBuilder();
|
||||
bvc.setBirthday(m_dob);
|
||||
bvc.setTimeZone(my_tz);
|
||||
bvc.create().exportXML(xml);
|
||||
|
||||
|
@ -743,6 +741,48 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
|
||||
} // end export
|
||||
|
||||
public java.sql.Date getDateOfBirth()
|
||||
{
|
||||
return m_dob;
|
||||
|
||||
} // end getDateOfBirth
|
||||
|
||||
public void setDateOfBirth(java.sql.Date date) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
if (date.equals(m_dob))
|
||||
return;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = env.getConnection();
|
||||
stmt = conn.prepareStatement("UPDATE users SET dob = ? WHERE uid = ?;");
|
||||
stmt.setDate(1,date);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
m_dob = date; // change stored information
|
||||
ar = env.newAudit(AuditRecord.ADMIN_ACCOUNT_CHANGE,"uid=" + uid,"field=dob");
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
{ // turn SQLException into data exception
|
||||
logger.error("DB error changing date of birth: " + e.getMessage(),e);
|
||||
throw new DataException("Unable to set user date of birth: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
SQLUtil.shutdown(stmt);
|
||||
AuditRecord.store(conn,ar);
|
||||
SQLUtil.shutdown(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end setDateOfBirth
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Package-level static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -751,14 +791,15 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
static AdminUserContext getAdminUserContext(EnvUser env, int uid) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users INNER JOIN userprefs "
|
||||
+ "ON users.uid = userprefs.uid WHERE users.uid = " + uid + ";");
|
||||
stmt = conn.prepareStatement("SELECT * FROM users INNER JOIN userprefs ON users.uid = userprefs.uid "
|
||||
+ "WHERE users.uid = ?;");
|
||||
stmt.setInt(1,uid);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
if (!(rs.next()))
|
||||
throw new DataException("The user with UID #" + uid + " was not found.");
|
||||
if (rs.getBoolean("is_anon"))
|
||||
|
@ -785,15 +826,15 @@ class AdminUserContextImpl implements AdminUserContext
|
|||
static AdminUserContext getAdminUserContext(EnvUser env, String username) throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = env.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users INNER JOIN userprefs "
|
||||
+ "ON users.uid = userprefs.uid WHERE users.username = '"
|
||||
+ SQLUtil.encodeString(username) + "';");
|
||||
stmt = conn.prepareStatement("SELECT * FROM users INNER JOIN userprefs ON users.uid = userprefs.uid "
|
||||
+ "WHERE users.username = ?;");
|
||||
stmt.setString(1,username);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
if (!(rs.next()))
|
||||
throw new DataException("The user '" + username + "' was not found.");
|
||||
if (rs.getBoolean("is_anon"))
|
||||
|
|
|
@ -70,7 +70,8 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
private String username; // the user name we're using
|
||||
private java.util.Date created; // when was this user created? (GMT)
|
||||
private java.util.Date last_access; // when did we last log in? (GMT)
|
||||
private String description; // personal description
|
||||
private String m_description; // personal description
|
||||
private java.sql.Date m_dob; // date of birth
|
||||
private String my_email = null; // my email address (cached)
|
||||
private String my_pseud = null; // my pseud (cached)
|
||||
private String full_name = null; // my full name (cached)
|
||||
|
@ -110,7 +111,8 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
created = SQLUtil.getFullDateTime(rs,"created");
|
||||
last_access = SQLUtil.getFullDateTime(rs,"lastaccess");
|
||||
// skip field "passreminder"
|
||||
description = rs.getString("description");
|
||||
m_description = rs.getString("description");
|
||||
m_dob = rs.getDate("dob");
|
||||
|
||||
// purge any "cached" fields that may be left over
|
||||
my_email = null;
|
||||
|
@ -222,19 +224,15 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
if (logger.isDebugEnabled())
|
||||
logger.debug("autoJoinCommunities (uid " + uid + ", level " + level + ")");
|
||||
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null, stmt2 = null;
|
||||
|
||||
try
|
||||
{ // See which communities we are eligible to autojoin.
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql =
|
||||
new StringBuffer("SELECT sigmember.sigid, sigmember.locked FROM users, sigmember, sigs "
|
||||
+ "WHERE sigmember.uid = users.uid AND sigmember.sigid = sigs.sigid "
|
||||
+ "AND users.is_anon = 1 AND sigs.join_lvl <= ");
|
||||
sql.append(level).append(';');
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
stmt = conn.prepareStatement("SELECT sigmember.sigid, sigmember.locked FROM users, sigmember, sigs "
|
||||
+ "WHERE sigmember.uid = users.uid AND sigmember.sigid = sigs.sigid "
|
||||
+ "AND users.is_anon = 1 AND sigs.join_lvl <= ?;");
|
||||
stmt.setInt(1,level);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
|
||||
// Save the community IDs returned into temporary array lists.
|
||||
ArrayList tmp_cid = new ArrayList();
|
||||
|
@ -247,41 +245,34 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
} // end while
|
||||
|
||||
// Figure out which of those communities we haven't joined yet and set up to autojoin them.
|
||||
sql.setLength(0);
|
||||
stmt = conn.prepareStatement("SELECT sigid FROM sigmember WHERE sigid = ? AND uid = ?;");
|
||||
stmt2 = conn.prepareStatement("INSERT INTO sigmember (sigid, uid, granted_lvl, locked) VALUES (?, ?, ?, ?);");
|
||||
SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class,"Community"));
|
||||
int new_level = smon.getDefaultRole("Community.NewUser").getLevel();
|
||||
for (int i=0; i<tmp_cid.size(); i++)
|
||||
{ // see if the user is already a member of this community
|
||||
Integer x_cid = (Integer)(tmp_cid.get(i));
|
||||
rs = stmt.executeQuery("SELECT sigid FROM sigmember WHERE sigid = " + x_cid + " AND uid = " + uid
|
||||
+ ";");
|
||||
stmt.setInt(1,x_cid.intValue());
|
||||
stmt.setInt(2,uid);
|
||||
rs = stmt.executeQuery();
|
||||
if (!(rs.next()))
|
||||
{ // tack this information onto the end of our big "INSERT" command
|
||||
Boolean x_locked = (Boolean)(tmp_locked.get(i));
|
||||
if (sql.length()==0)
|
||||
sql.append("INSERT INTO sigmember (sigid, uid, granted_lvl, locked) VALUES ");
|
||||
else
|
||||
sql.append(", ");
|
||||
sql.append("(").append(x_cid).append(", ").append(uid).append(", ").append(new_level).append(", ");
|
||||
sql.append(x_locked.booleanValue() ? '1' : '0').append(")");
|
||||
stmt2.setInt(1,x_cid.intValue());
|
||||
stmt2.setInt(2,uid);
|
||||
stmt2.setInt(3,new_level);
|
||||
stmt2.setInt(4,x_locked.booleanValue() ? 1 : 0);
|
||||
stmt2.executeUpdate();
|
||||
|
||||
} // end if
|
||||
|
||||
} // end for
|
||||
|
||||
if (sql.length()>0)
|
||||
{ // execute the big update
|
||||
sql.append(';');
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("SQL: " + sql.toString());
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
} // end if
|
||||
|
||||
} // end try
|
||||
finally
|
||||
{ // shut down the statement to conserve resources
|
||||
SQLUtil.shutdown(stmt);
|
||||
SQLUtil.shutdown(stmt2);
|
||||
|
||||
} // end finally
|
||||
|
||||
|
@ -376,7 +367,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
return m_description;
|
||||
|
||||
} // end getDescription
|
||||
|
||||
|
@ -407,15 +398,15 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
logger.debug("authenticate(): authenticating user \"" + username + "\"...");
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
try
|
||||
{ // look for a user name matching this user record
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE username = '"
|
||||
+ SQLUtil.encodeString(username) + "';");
|
||||
stmt = conn.prepareStatement("SELECT * FROM users WHERE username = ?;");
|
||||
stmt.setString(1,username);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
|
||||
if (!(rs.next()))
|
||||
{ // user not found
|
||||
|
@ -460,11 +451,15 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
// we're authenticated - load the user data into the context
|
||||
loadUserData(rs);
|
||||
rs.close();
|
||||
|
||||
// update the "last access" time in the database
|
||||
stmt.close();
|
||||
stmt = conn.prepareStatement("UPDATE users SET lastaccess = ? WHERE uid = ?;");
|
||||
java.util.Date mydate = new java.util.Date();
|
||||
stmt.executeUpdate("UPDATE users SET lastaccess = '" + SQLUtil.encodeDate(mydate)
|
||||
+ "' WHERE uid = " + uid + ";");
|
||||
SQLUtil.setFullDateTime(stmt,1,mydate);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
|
||||
// update the "last access" time in this object
|
||||
last_access = mydate;
|
||||
|
@ -516,17 +511,17 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
} // end if
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class));
|
||||
Role new_role = smon.getDefaultRole("Global.AfterVerify");
|
||||
|
||||
try
|
||||
{ // get a connection and set the user's status to reflect the verification
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 1, base_lvl = ");
|
||||
sql.append(new_role.getLevel()).append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
stmt = conn.prepareStatement("UPDATE users SET verify_email = 1, base_lvl = ? WHERE uid = ?;");
|
||||
stmt.setInt(1,new_role.getLevel());
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
email_verified = true;
|
||||
level = new_role.getLevel();
|
||||
|
||||
|
@ -569,22 +564,21 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
getContactInfo(); // forces my_email to be updated
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
try
|
||||
{ // need to change the user's email confirmation number first
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
|
||||
// generate new confirmation number
|
||||
int new_confirm_num = Generator.get().getNewConfirmationNumber();
|
||||
|
||||
// create an SQL statement to reset the user account information, and execute it
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET email_confnum = ");
|
||||
sql.append(new_confirm_num).append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
stmt = conn.prepareStatement("UPDATE users SET email_confnum = ? WHERE uid = ?;");
|
||||
stmt.setInt(1,new_confirm_num);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
confirm_num = new_confirm_num; // save changed value
|
||||
|
||||
// now send the email confirmation!
|
||||
|
@ -694,14 +688,15 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class));
|
||||
Role new_role = smon.getDefaultRole("Global.Unverified");
|
||||
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
try
|
||||
{ // create an SQL statement to reset the user account information, and execute it
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET verify_email = 0, email_confnum = ");
|
||||
sql.append(new_confirm_num).append(", base_lvl = ").append(new_role.getLevel());
|
||||
sql.append(" WHERE uid = ").append(uid).append(';');
|
||||
stmt = conn.createStatement();
|
||||
stmt.executeUpdate(sql.toString());
|
||||
stmt = conn.prepareStatement("UPDATE users SET verify_email = 0, email_confnum = ?, base_lvl = ? "
|
||||
+ "WHERE uid = ?;");
|
||||
stmt.setInt(1,new_confirm_num);
|
||||
stmt.setInt(2,new_role.getLevel());
|
||||
stmt.setInt(3,uid);
|
||||
stmt.executeUpdate();
|
||||
|
||||
} // end try
|
||||
finally
|
||||
|
@ -816,18 +811,17 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
} // end if
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
String hash_value = Generator.hashPassword(password);
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET passhash = '");
|
||||
sql.append(hash_value).append("', passreminder = '").append(SQLUtil.encodeString(reminder));
|
||||
sql.append("' WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
stmt = conn.prepareStatement("UPDATE users SET passhash = ?, passreminder = ? WHERE uid = ?;");
|
||||
stmt.setString(1,Generator.hashPassword(password));
|
||||
stmt.setString(2,reminder);
|
||||
stmt.setInt(3,uid);
|
||||
stmt.executeUpdate();
|
||||
|
||||
// record an audit record for this user
|
||||
ar = new AuditRecord(AuditRecord.PASSWORD_CHANGE,uid,remote_addr);
|
||||
|
@ -859,17 +853,16 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
} // end if
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET description = '");
|
||||
sql.append(SQLUtil.encodeString(new_descr)).append("' WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
description = new_descr; // change stored information
|
||||
stmt = conn.prepareStatement("UPDATE users SET description = ? WHERE uid = ?;");
|
||||
stmt.setString(1,new_descr);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
m_description = new_descr; // change stored information
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -1018,17 +1011,17 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
public List getSideBoxList() throws DataException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
ArrayList rc = new ArrayList();
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
|
||||
// retrieve the necessary rows from the sideboxes table
|
||||
ResultSet rs = stmt.executeQuery("SELECT boxid, sequence FROM sideboxes WHERE uid = " + uid
|
||||
+ " ORDER BY sequence;");
|
||||
stmt = conn.prepareStatement("SELECT boxid, sequence FROM sideboxes WHERE uid = ? ORDER BY sequence;");
|
||||
stmt.setInt(1,uid);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
while (rs.next())
|
||||
{ // create the implementation objects and return them all
|
||||
SideBoxDescriptor sbd =
|
||||
|
@ -1063,6 +1056,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement pstmt = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection
|
||||
|
@ -1072,25 +1066,29 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
stmt.executeUpdate("LOCK TABLES sideboxes WRITE;");
|
||||
try
|
||||
{ // do a quickie query to see if we're already in the sidebox list
|
||||
StringBuffer sql = new StringBuffer("SELECT sequence FROM sideboxes WHERE uid = ");
|
||||
sql.append(uid).append(" AND boxid = ").append(id).append(';');
|
||||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
pstmt = conn.prepareStatement("SELECT sequence FROM sideboxes WHERE uid = ? AND boxid = ?;");
|
||||
pstmt.setInt(1,uid);
|
||||
pstmt.setInt(2,id);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
return; // already in sidebox list - this is a no-op
|
||||
|
||||
// find a sequence number for the new entry
|
||||
sql.setLength(0);
|
||||
sql.append("SELECT MAX(sequence) FROM sideboxes WHERE uid = ").append(uid).append(';');
|
||||
rs = stmt.executeQuery(sql.toString());
|
||||
pstmt.close();
|
||||
pstmt = conn.prepareStatement("SELECT MAX(sequence) FROM sideboxes WHERE uid = ?;");
|
||||
pstmt.setInt(1,uid);
|
||||
rs = pstmt.executeQuery();
|
||||
if (!(rs.next()))
|
||||
throw new InternalStateError("bogus query result on addSideBox");
|
||||
int new_sequence = rs.getInt(1) + 100;
|
||||
|
||||
// add the new record
|
||||
sql.setLength(0);
|
||||
sql.append("INSERT INTO sideboxes (uid, sequence, boxid) VALUES (").append(uid).append(", ");
|
||||
sql.append(new_sequence).append(", ").append(id).append(");");
|
||||
stmt.executeUpdate(sql.toString());
|
||||
pstmt.close();
|
||||
pstmt = conn.prepareStatement("INSERT INTO sideboxes (uid, sequence, boxid) VALUES (?, ?, ?);");
|
||||
pstmt.setInt(1,uid);
|
||||
pstmt.setInt(2,new_sequence);
|
||||
pstmt.setInt(3,id);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
} // end try
|
||||
finally
|
||||
|
@ -1108,6 +1106,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure we release the connection before we go
|
||||
SQLUtil.shutdown(pstmt);
|
||||
SQLUtil.shutdown(stmt);
|
||||
SQLUtil.shutdown(conn);
|
||||
|
||||
|
@ -1236,15 +1235,15 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
// Generate a random authentication string and poke it into the database for this user.
|
||||
String tokenauth = Generator.get().generateRandomAuthString();
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
StringBuffer sql = new StringBuffer("UPDATE users SET tokenauth = '");
|
||||
sql.append(tokenauth).append("' WHERE uid = ").append(uid).append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
stmt = conn.prepareStatement("UPDATE users SET tokenauth = ? WHERE uid = ?;");
|
||||
stmt.setString(1,tokenauth);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
|
@ -1363,14 +1362,15 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
logger.debug("Authenticating user ID#" + pending_uid);
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
try
|
||||
{ // look for a user record matching this user ID
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT * FROM users WHERE uid = " + pending_uid + ";");
|
||||
stmt = conn.prepareStatement("SELECT * FROM users WHERE uid = ?;");
|
||||
stmt.setInt(1,pending_uid);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
|
||||
if (!(rs.next()))
|
||||
{ // user not found
|
||||
|
@ -1412,9 +1412,11 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
loadUserData(rs);
|
||||
|
||||
// update the "last access" time in the database
|
||||
stmt = conn.prepareStatement("UPDATE users SET lastaccess = ? WHERE uid = ?;");
|
||||
java.util.Date mydate = new java.util.Date();
|
||||
stmt.executeUpdate("UPDATE users SET lastaccess = '" + SQLUtil.encodeDate(mydate)
|
||||
+ "' WHERE uid = " + uid + ";");
|
||||
SQLUtil.setFullDateTime(stmt,1,mydate);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
|
||||
// update the "last access" time in this object
|
||||
last_access = mydate;
|
||||
|
@ -1514,32 +1516,32 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
ServiceToken conf_token = env.getSCM().getTokenForSymbol(ServiceControl.SVCGRP_COMMUNITY,"Conference");
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
ArrayList rc = new ArrayList();
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = globalsite.getConnection(null);
|
||||
TopicMessageFoundHelper helper = new TopicMessageFoundHelper(conn);
|
||||
stmt = conn.createStatement();
|
||||
|
||||
// create the SQL statement
|
||||
StringBuffer sql =
|
||||
new StringBuffer("SELECT s.sigid, c.confid, t.topicid, t.num, p.postid, p.num, p.creator_uid, "
|
||||
+ "p.posted, p.linecount, d.data FROM confs c, sigtoconf s, topics t, posts p, "
|
||||
+ "postdata d, users u, sigmember m, sigftrs f LEFT JOIN confmember x "
|
||||
+ "ON (c.confid = x.confid AND u.uid = x.uid) WHERE u.uid = ");
|
||||
sql.append(uid);
|
||||
sql.append(" AND s.sigid = m.sigid AND m.uid = u.uid AND s.sigid = f.sigid AND f.ftr_code = ");
|
||||
sql.append(conf_token.getIndex());
|
||||
sql.append(" AND c.confid = s.confid AND GREATEST(u.base_lvl,m.granted_lvl,s.granted_lvl,"
|
||||
+ "IFNULL(x.granted_lvl,0)) >= c.read_lvl AND t.confid = c.confid AND t.topicid = p.topicid "
|
||||
+ "AND p.scribble_uid IS NULL AND p.postid = d.postid AND MATCH(d.data) AGAINST (");
|
||||
sql.append(SQLUtil.encodeStringArg(search_terms)).append(") LIMIT ").append(offset).append(", ");
|
||||
sql.append(count+1).append(';');
|
||||
stmt = conn.prepareStatement("SELECT s.sigid, c.confid, t.topicid, t.num, p.postid, p.num, p.creator_uid, "
|
||||
+ "p.posted, p.linecount, d.data FROM confs c, sigtoconf s, topics t, posts p, "
|
||||
+ "postdata d, users u, sigmember m, sigftrs f LEFT JOIN confmember x "
|
||||
+ "ON (c.confid = x.confid AND u.uid = x.uid) WHERE u.uid = ? AND "
|
||||
+ "s.sigid = m.sigid AND m.uid = u.uid AND s.sigid = f.sigid AND f.ftr_code = ? "
|
||||
+ " AND c.confid = s.confid AND GREATEST(u.base_lvl,m.granted_lvl,s.granted_lvl,"
|
||||
+ "IFNULL(x.granted_lvl,0)) >= c.read_lvl AND t.confid = c.confid AND "
|
||||
+ "t.topicid = p.topicid AND p.scribble_uid IS NULL AND p.postid = d.postid "
|
||||
+ "AND MATCH(d.data) AGAINST (?) LIMIT ?, ?;");
|
||||
stmt.setInt(1,uid);
|
||||
stmt.setInt(2,conf_token.getIndex());
|
||||
stmt.setString(3,search_terms);
|
||||
stmt.setInt(4,offset);
|
||||
stmt.setInt(5,count + 1);
|
||||
|
||||
// execute the query and load the results into the return arraylist
|
||||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
while (rs.next())
|
||||
rc.add(new TopicMessageFoundImpl(helper,rs.getInt(1),rs.getInt(2),rs.getInt(3),rs.getInt(4),
|
||||
rs.getLong(5),rs.getInt(6),rs.getInt(7),
|
||||
|
@ -1575,28 +1577,26 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
ServiceToken conf_token = env.getSCM().getTokenForSymbol(ServiceControl.SVCGRP_COMMUNITY,"Conference");
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try
|
||||
{ // get a database connection
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.createStatement();
|
||||
|
||||
// create the SQL statement
|
||||
StringBuffer sql =
|
||||
new StringBuffer("SELECT COUNT(*) FROM confs c, sigtoconf s, topics t, posts p, postdata d, "
|
||||
+ "users u, sigmember m, sigftrs f LEFT JOIN confmember x ON (c.confid = x.confid "
|
||||
+ "AND u.uid = x.uid) WHERE u.uid = ");
|
||||
sql.append(uid);
|
||||
sql.append(" AND s.sigid = m.sigid AND m.uid = u.uid AND s.sigid = f.sigid AND f.ftr_code = ");
|
||||
sql.append(conf_token.getIndex());
|
||||
sql.append(" AND c.confid = s.confid AND GREATEST(u.base_lvl,m.granted_lvl,s.granted_lvl,"
|
||||
+ "IFNULL(x.granted_lvl,0)) >= c.read_lvl AND t.confid = c.confid AND t.topicid = p.topicid "
|
||||
+ "AND p.scribble_uid IS NULL AND p.postid = d.postid AND MATCH(d.data) AGAINST (");
|
||||
sql.append(SQLUtil.encodeStringArg(search_terms)).append(");");
|
||||
stmt = conn.prepareStatement("SELECT COUNT(*) FROM confs c, sigtoconf s, topics t, posts p, postdata d, "
|
||||
+ "users u, sigmember m, sigftrs f LEFT JOIN confmember x ON (c.confid = x.confid "
|
||||
+ "AND u.uid = x.uid) WHERE u.uid = ? AND s.sigid = m.sigid AND m.uid = u.uid "
|
||||
+ "AND s.sigid = f.sigid AND f.ftr_code = ? AND c.confid = s.confid AND "
|
||||
+ "GREATEST(u.base_lvl,m.granted_lvl,s.granted_lvl,IFNULL(x.granted_lvl,0)) "
|
||||
+ ">= c.read_lvl AND t.confid = c.confid AND t.topicid = p.topicid AND "
|
||||
+ "p.scribble_uid IS NULL AND p.postid = d.postid AND MATCH(d.data) AGAINST (?);");
|
||||
stmt.setInt(1,uid);
|
||||
stmt.setInt(2,conf_token.getIndex());
|
||||
stmt.setString(3,search_terms);
|
||||
|
||||
// execute the query and load the results
|
||||
ResultSet rs = stmt.executeQuery(sql.toString());
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
if (!(rs.next()))
|
||||
throw new InternalStateError("query failure in UserContextImpl.getSearchPostCount!");
|
||||
return rs.getInt(1);
|
||||
|
@ -1617,6 +1617,49 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
} // end getSearchPostCount
|
||||
|
||||
public java.sql.Date getDateOfBirth()
|
||||
{
|
||||
return m_dob;
|
||||
|
||||
} // end getDateOfBirth
|
||||
|
||||
public void setDateOfBirth(java.sql.Date date) throws DataException
|
||||
{
|
||||
if (is_anon)
|
||||
{ // trying to change Anonymous Honyak's (nonexistent) date of birth?
|
||||
logger.error("cannot change date of birth of anonymous account");
|
||||
throw new DataException("The anonymous account cannot change its date of birth.");
|
||||
|
||||
} // end if
|
||||
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
try
|
||||
{ // retrieve a connection from the data pool
|
||||
conn = globalsite.getConnection(null);
|
||||
stmt = conn.prepareStatement("UPDATE users SET dob = ? WHERE uid = ?;");
|
||||
stmt.setDate(1,date);
|
||||
stmt.setInt(2,uid);
|
||||
stmt.executeUpdate();
|
||||
m_dob = date; // change stored information
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
{ // turn SQLException into data exception
|
||||
logger.error("DB error changing date of birth: " + e.getMessage(),e);
|
||||
throw new DataException("Unable to set user date of birth: " + e.getMessage(),e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
SQLUtil.shutdown(stmt);
|
||||
SQLUtil.shutdown(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end setDateOfBirth
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ServiceProvider
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -1755,7 +1798,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
} // end loadAnonymous
|
||||
|
||||
void loadNewUser(String remote_addr, int uid, int level, String username, int confirm_num,
|
||||
java.util.Date created, java.util.Date last_access)
|
||||
java.util.Date created, java.util.Date last_access, java.sql.Date dob)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("loadNewUser() on UserContext: addr " + remote_addr + ", uid " + uid + ", level "
|
||||
|
@ -1769,6 +1812,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
this.confirm_num = confirm_num;
|
||||
this.created = created;
|
||||
this.last_access = last_access;
|
||||
m_dob = dob;
|
||||
|
||||
} // end loadNewUser
|
||||
|
||||
|
@ -1803,14 +1847,14 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
static final ReturnNewUser createAccount(EnvEngine env, String remote_addr, String username, String password,
|
||||
boolean prehashed, String reminder, boolean verify_email, boolean lockout,
|
||||
int confirm_num, Role base_role, String description)
|
||||
int confirm_num, Role base_role, String description, java.sql.Date dob)
|
||||
throws AccessError, DataException
|
||||
{
|
||||
String encode_username = SQLUtil.encodeString(username);
|
||||
int new_uid; // new user ID - return from this function
|
||||
java.util.Date created; // date created - return from this function
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
PreparedStatement pstmt = null;
|
||||
AuditRecord ar = null;
|
||||
|
||||
try
|
||||
|
@ -1822,7 +1866,9 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
try
|
||||
{ // make sure the user account doesn't already exist
|
||||
ResultSet rs = stmt.executeQuery("SELECT uid FROM users WHERE username = '" + encode_username + "';");
|
||||
pstmt = conn.prepareStatement("SELECT uid FROM users WHERE username = ?;");
|
||||
pstmt.setString(1,username);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
if (rs.next())
|
||||
{ // the user account already exists
|
||||
logger.warn("username \"" + username + "\" already exists");
|
||||
|
@ -1830,21 +1876,27 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
|
||||
} // end if
|
||||
|
||||
SQLUtil.shutdown(rs);
|
||||
rs.close();
|
||||
|
||||
// Insert a new record for this user
|
||||
String hash_value = (prehashed ? password : Generator.hashPassword(password));
|
||||
StringBuffer sql =
|
||||
new StringBuffer("INSERT INTO users (username, passhash, verify_email, lockout, email_confnum, "
|
||||
+ "base_lvl, created, lastaccess, passreminder, description) VALUES ('");
|
||||
sql.append(encode_username).append("', '").append(hash_value).append("', ");
|
||||
sql.append(verify_email ? '1' : '0').append(", ").append(lockout ? '1' : '0').append(", ");
|
||||
sql.append(confirm_num).append(", ").append(base_role.getLevel()).append(", '");
|
||||
pstmt.close();
|
||||
pstmt = conn.prepareStatement("INSERT INTO users (username, passhash, verify_email, lockout, email_confnum, "
|
||||
+ "base_lvl, created, lastaccess, passreminder, description, dob) VALUES "
|
||||
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
pstmt.setString(1,username);
|
||||
pstmt.setString(2,hash_value);
|
||||
pstmt.setInt(3,verify_email ? 1 : 0);
|
||||
pstmt.setInt(4,lockout ? 1 : 0);
|
||||
pstmt.setInt(5,confirm_num);
|
||||
pstmt.setInt(6,base_role.getLevel());
|
||||
created = new java.util.Date();
|
||||
sql.append(SQLUtil.encodeDate(created)).append("', '").append(SQLUtil.encodeDate(created));
|
||||
sql.append("', ").append(SQLUtil.encodeStringArg(reminder)).append(", ");
|
||||
sql.append(SQLUtil.encodeStringArg(description)).append(");");
|
||||
stmt.executeUpdate(sql.toString());
|
||||
SQLUtil.setFullDateTime(pstmt,7,created);
|
||||
SQLUtil.setFullDateTime(pstmt,8,created);
|
||||
pstmt.setString(9,reminder);
|
||||
pstmt.setString(10,description);
|
||||
pstmt.setDate(11,dob);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
// what is the new user ID?
|
||||
rs = stmt.executeQuery("SELECT LAST_INSERT_ID();");
|
||||
|
@ -1858,12 +1910,13 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
new_uid = rs.getInt(1);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...created user \"" + username + "\" with UID " + new_uid);
|
||||
SQLUtil.shutdown(rs);
|
||||
rs.close();
|
||||
|
||||
// add a UserPrefs record for this user, too
|
||||
sql.setLength(0);
|
||||
sql.append("INSERT INTO userprefs (uid) VALUES (").append(new_uid).append(");");
|
||||
stmt.executeUpdate(sql.toString());
|
||||
pstmt.close();
|
||||
pstmt = conn.prepareStatement("INSERT INTO userprefs (uid) VALUES (?);");
|
||||
pstmt.setInt(1,new_uid);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...created userprefs");
|
||||
|
@ -1871,75 +1924,52 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
// add a properties configuration for this user
|
||||
rs = stmt.executeQuery("SELECT propuser.ndx, propuser.data FROM propuser, users WHERE "
|
||||
+ "propuser.uid = users.uid AND users.is_anon = 1;");
|
||||
sql.setLength(0);
|
||||
pstmt.close();
|
||||
pstmt = conn.prepareStatement("INSERT INTO propuser (uid, ndx, data) VALUES (?, ?, ?);");
|
||||
while (rs.next())
|
||||
{ // set up to insert into the propuser table
|
||||
if (sql.length()==0)
|
||||
sql.append("INSERT INTO propuser (uid, ndx, data) VALUES ");
|
||||
else
|
||||
sql.append(", ");
|
||||
sql.append("(").append(new_uid).append(", ").append(rs.getInt(1)).append(", '");
|
||||
sql.append(SQLUtil.encodeString(rs.getString(2))).append("')");
|
||||
pstmt.setInt(1,new_uid);
|
||||
pstmt.setInt(2,rs.getInt(1));
|
||||
pstmt.setString(3,rs.getString(2));
|
||||
pstmt.executeUpdate();
|
||||
|
||||
} // end while
|
||||
|
||||
if (sql.length()>0)
|
||||
{ // execute the big update
|
||||
sql.append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...created user properties");
|
||||
|
||||
// get the sidebox configuration for this user
|
||||
rs = stmt.executeQuery("SELECT sideboxes.boxid, sideboxes.sequence FROM sideboxes, "
|
||||
+ "users WHERE sideboxes.uid = users.uid AND users.is_anon = 1;");
|
||||
sql.setLength(0);
|
||||
pstmt.close();
|
||||
pstmt = conn.prepareStatement("INSERT INTO sideboxes (uid, boxid, sequence) VALUES (?, ?, ?);");
|
||||
while (rs.next())
|
||||
{ // set up to insert into the sideboxes table
|
||||
if (sql.length()==0)
|
||||
sql.append("INSERT INTO sideboxes (uid, boxid, sequence) VALUES ");
|
||||
else
|
||||
sql.append(", ");
|
||||
sql.append("(").append(new_uid).append(", ").append(rs.getInt(1)).append(", ");
|
||||
sql.append(rs.getInt(2)).append(')');
|
||||
pstmt.setInt(1,new_uid);
|
||||
pstmt.setInt(2,rs.getInt(1));
|
||||
pstmt.setInt(3,rs.getInt(2));
|
||||
pstmt.executeUpdate();
|
||||
|
||||
} // end while
|
||||
|
||||
if (sql.length()>0)
|
||||
{ // execute the big update
|
||||
sql.append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...loaded default sidebox config");
|
||||
|
||||
// get the hotlist configuration for this user
|
||||
rs = stmt.executeQuery("SELECT confhotlist.sequence, confhotlist.sigid, confhotlist.confid FROM "
|
||||
+ "confhotlist, users WHERE confhotlist.uid = users.uid AND users.is_anon = 1;");
|
||||
sql.setLength(0);
|
||||
pstmt.close();
|
||||
pstmt = conn.prepareStatement("INSERT INTO confhotlist (uid, sequence, sigid, confid) VALUES (?, ?, ?, ?);");
|
||||
while (rs.next())
|
||||
{ // set up to insert into the confhotlist table
|
||||
if (sql.length()==0)
|
||||
sql.append("INSERT INTO confhotlist (uid, sequence, sigid, confid) VALUES ");
|
||||
else
|
||||
sql.append(", ");
|
||||
sql.append('(').append(new_uid).append(", ").append(rs.getInt(1)).append(", ").append(rs.getInt(2));
|
||||
sql.append(", ").append(rs.getInt(3)).append(')');
|
||||
pstmt.setInt(1,new_uid);
|
||||
pstmt.setInt(2,rs.getInt(1));
|
||||
pstmt.setInt(3,rs.getInt(2));
|
||||
pstmt.setInt(4,rs.getInt(3));
|
||||
pstmt.executeUpdate();
|
||||
|
||||
} // end while
|
||||
|
||||
if (sql.length()>0)
|
||||
{ // execute the big update
|
||||
sql.append(';');
|
||||
stmt.executeUpdate(sql.toString());
|
||||
|
||||
} // end if
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...loaded default hotlist config");
|
||||
|
||||
|
@ -1962,6 +1992,7 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
|
|||
} // end catch
|
||||
finally
|
||||
{ // make sure the connection is released before we go
|
||||
SQLUtil.shutdown(pstmt);
|
||||
SQLUtil.shutdown(stmt);
|
||||
AuditRecord.store(conn,ar);
|
||||
SQLUtil.shutdown(conn);
|
||||
|
|
|
@ -858,8 +858,8 @@ public class VeniceEngineImpl implements VeniceEngine, ServiceProvider, EngineBa
|
|||
|
||||
} // end completePasswordChange
|
||||
|
||||
public UserContext createNewAccount(String remote_addr, String username, String password, String reminder)
|
||||
throws DataException, AccessError
|
||||
public UserContext createNewAccount(String remote_addr, String username, String password, String reminder,
|
||||
java.sql.Date dob) throws DataException, AccessError
|
||||
{
|
||||
checkInitialized();
|
||||
SecurityMonitor smon = (SecurityMonitor)(globalsite.queryService(SecurityMonitor.class));
|
||||
|
@ -872,12 +872,12 @@ public class VeniceEngineImpl implements VeniceEngine, ServiceProvider, EngineBa
|
|||
|
||||
// Create the user account.
|
||||
ReturnNewUser rnu = UserContextImpl.createAccount(env,remote_addr,username,password,false,reminder,false,
|
||||
false,confirm_num,new_role,null);
|
||||
false,confirm_num,new_role,null,dob);
|
||||
|
||||
// create a new context for the user (they're now effectively logged in)
|
||||
UserContextImpl rc = new UserContextImpl(globalsite,env);
|
||||
rc.loadNewUser(remote_addr,rnu.getUserID(),new_role.getLevel(),username,confirm_num,rnu.getCreationDate(),
|
||||
rnu.getCreationDate());
|
||||
rnu.getCreationDate(),dob);
|
||||
rc.autoJoinCommunities(); // EJB 4/14/2001
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("...created new user context");
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* 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 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
@ -21,6 +21,6 @@ import java.io.IOException;
|
|||
|
||||
public interface RenderDirect
|
||||
{
|
||||
public abstract void render(RequestOutput out) throws IOException;
|
||||
public void render(RequestOutput out) throws IOException;
|
||||
|
||||
} // end interface RenderDirect
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* 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-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return A <CODE>String</CODE> specifying the real path, or <CODE>null</CODE> if the translation cannot
|
||||
* be performed.
|
||||
*/
|
||||
public abstract String mapPath(String s);
|
||||
public String mapPath(String s);
|
||||
|
||||
/**
|
||||
* Returns the portion of the request URI that indicates the context of the request, i.e. the servlet
|
||||
|
@ -58,7 +58,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return A <CODE>String</CODE> specifying the portion of the request URI that indicates the context
|
||||
* of the request.
|
||||
*/
|
||||
public abstract String getContextPath();
|
||||
public String getContextPath();
|
||||
|
||||
/**
|
||||
* Returns the part of this request's URI that calls the servlet. This includes either the servlet name
|
||||
|
@ -67,7 +67,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return A <CODE>String</CODE> containing the name or path of the servlet being called, as specified
|
||||
* in the request URI.
|
||||
*/
|
||||
public abstract String getServletPath();
|
||||
public String getServletPath();
|
||||
|
||||
/**
|
||||
* Returns any extra path information associated with the URI the client sent when it made this request.
|
||||
|
@ -79,7 +79,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* but before the query string in the request URI; or <CODE>null</CODE> if the URI does not
|
||||
* have any extra path information.
|
||||
*/
|
||||
public abstract String getPathInfo();
|
||||
public String getPathInfo();
|
||||
|
||||
/**
|
||||
* Returns the query string that is contained in the request URI after the path. This method returns
|
||||
|
@ -88,21 +88,21 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return A <CODE>String</CODE> containing the query string or <CODE>null</CODE> if the URI contains
|
||||
* no query string.
|
||||
*/
|
||||
public abstract String getQueryString();
|
||||
public String getQueryString();
|
||||
|
||||
/**
|
||||
* Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
|
||||
*
|
||||
* @return A <CODE>String</CODE> specifying the name of the method with which this request was made.
|
||||
*/
|
||||
public abstract String getVerb();
|
||||
public String getVerb();
|
||||
|
||||
/**
|
||||
* Returns the Internet Protocol (IP) address of the client that sent the request.
|
||||
*
|
||||
* @return A <CODE>String</CODE> containing the IP address of the client that sent the request.
|
||||
*/
|
||||
public abstract String getSourceAddress();
|
||||
public String getSourceAddress();
|
||||
|
||||
/**
|
||||
* Returns <CODE>true</CODE> if the request parameter with the specified name is defined,
|
||||
|
@ -112,7 +112,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param name Parameter name to be checked.
|
||||
* @return See above.
|
||||
*/
|
||||
public abstract boolean hasParameter(String name);
|
||||
public boolean hasParameter(String name);
|
||||
|
||||
/**
|
||||
* Returns the value of a request parameter as a <CODE>String</CODE>, or <CODE>null</CODE> if the
|
||||
|
@ -127,7 +127,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return A <CODE>String</CODE> representing the single value of the parameter.
|
||||
* @see #getParameterValues(java.lang.String)
|
||||
*/
|
||||
public abstract String getParameter(String name);
|
||||
public String getParameter(String name);
|
||||
|
||||
/**
|
||||
* Returns the value of a request parameter as a <CODE>int</CODE>, or a specified default value if
|
||||
|
@ -140,7 +140,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param default_value The default value to use for the parameter if the specified parameter does not exist.
|
||||
* @return An <CODE>int</CODE> representing the single value of the parameter.
|
||||
*/
|
||||
public abstract int getParameterInt(String name, int default_value);
|
||||
public int getParameterInt(String name, int default_value);
|
||||
|
||||
/**
|
||||
* Returns the value of a request parameter as a <CODE>short</CODE>, or a specified default value if
|
||||
|
@ -153,7 +153,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param default_value The default value to use for the parameter if the specified parameter does not exist.
|
||||
* @return A <CODE>short</CODE> representing the single value of the parameter.
|
||||
*/
|
||||
public abstract short getParameterShort(String name, short default_value);
|
||||
public short getParameterShort(String name, short default_value);
|
||||
|
||||
/**
|
||||
* Returns the value of a request parameter as a <CODE>long</CODE>, or a specified default value if
|
||||
|
@ -166,7 +166,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param default_value The default value to use for the parameter if the specified parameter does not exist.
|
||||
* @return A <CODE>long</CODE> representing the single value of the parameter.
|
||||
*/
|
||||
public abstract long getParameterLong(String name, long default_value);
|
||||
public long getParameterLong(String name, long default_value);
|
||||
|
||||
/**
|
||||
* Returns an <CODE>Enumeration</CODE> of <CODE>String</CODE> objects containing the names of the
|
||||
|
@ -177,7 +177,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* containing the name of a request parameter, or an empty <CODE>Enumeration</CODE> if the
|
||||
* request has no parameters.
|
||||
*/
|
||||
public abstract Enumeration getParameterNames();
|
||||
public Enumeration getParameterNames();
|
||||
|
||||
/**
|
||||
* Returns an array of <CODE>String</CODE> objects containing all of the values the given request
|
||||
|
@ -188,7 +188,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return An array of <CODE>String</CODE> objects containing the parameter's values.
|
||||
* @see #getParameter(java.lang.String)
|
||||
*/
|
||||
public abstract String[] getParameterValues(String name);
|
||||
public String[] getParameterValues(String name);
|
||||
|
||||
/**
|
||||
* Returns <CODE>true</CODE> if the specified parameter is a file parameter, <CODE>false</CODE> if
|
||||
|
@ -197,7 +197,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param name A <CODE>String</CODE> containing the name of the parameter to test.
|
||||
* @return See above.
|
||||
*/
|
||||
public abstract boolean isFileParam(String name);
|
||||
public boolean isFileParam(String name);
|
||||
|
||||
/**
|
||||
* Returns the MIME type of the specified parameter. If the type cannot be determined, the return
|
||||
|
@ -208,7 +208,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param name A <CODE>String</CODE> containing the name of the parameter to test.
|
||||
* @return See above.
|
||||
*/
|
||||
public abstract String getParameterType(String name);
|
||||
public String getParameterType(String name);
|
||||
|
||||
/**
|
||||
* Returns the size in bytes of the specified parameter. If the size cannot be determined, the return
|
||||
|
@ -219,7 +219,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param name A <CODE>String</CODE> containing the name of the parameter to test.
|
||||
* @return See above.
|
||||
*/
|
||||
public abstract int getParameterSize(String name);
|
||||
public int getParameterSize(String name);
|
||||
|
||||
/**
|
||||
* Returns an <CODE>InputStream</CODE> reading from the data of the named file parameter. If the
|
||||
|
@ -230,7 +230,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @exception com.silverwrist.util.ServletMultipartException If there is a problem retrieving
|
||||
* the parameter data stream.
|
||||
*/
|
||||
public abstract InputStream getParameterDataStream(String name) throws ServletMultipartException;
|
||||
public InputStream getParameterDataStream(String name) throws ServletMultipartException;
|
||||
|
||||
/**
|
||||
* Returns <CODE>true</CODE> if the parameter set reflects the clicking of an image button with a
|
||||
|
@ -239,7 +239,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param name A <CODE>String</CODE> containing the name of the image button to test.
|
||||
* @return See above.
|
||||
*/
|
||||
public abstract boolean isImageButtonClicked(String name);
|
||||
public boolean isImageButtonClicked(String name);
|
||||
|
||||
/**
|
||||
* Returns the application-level attribute with the given name, or <CODE>null</CODE> if there is no
|
||||
|
@ -249,7 +249,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return An <CODE>Object</CODE> containing the value of the attribute, or <CODE>null</CODE> if no
|
||||
* attribute exists matching the given name.
|
||||
*/
|
||||
public abstract Object getAppAttribute(String name);
|
||||
public Object getAppAttribute(String name);
|
||||
|
||||
/**
|
||||
* Sets the application-level attribute with the given name.
|
||||
|
@ -258,7 +258,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param o The object to be bound as the value of that attribute, or <CODE>null</CODE> if the binding
|
||||
* is to be removed.
|
||||
*/
|
||||
public abstract void setAppAttribute(String name, Object o);
|
||||
public void setAppAttribute(String name, Object o);
|
||||
|
||||
/**
|
||||
* Returns the session-level attribute with the given name, or <CODE>null</CODE> if there is no
|
||||
|
@ -268,7 +268,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return An <CODE>Object</CODE> containing the value of the attribute, or <CODE>null</CODE> if no
|
||||
* attribute exists matching the given name.
|
||||
*/
|
||||
public abstract Object getSessionAttribute(String name);
|
||||
public Object getSessionAttribute(String name);
|
||||
|
||||
/**
|
||||
* Sets the session-level attribute with the given name.
|
||||
|
@ -277,7 +277,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param o The object to be bound as the value of that attribute, or <CODE>null</CODE> if the binding
|
||||
* is to be removed.
|
||||
*/
|
||||
public abstract void setSessionAttribute(String name, Object o);
|
||||
public void setSessionAttribute(String name, Object o);
|
||||
|
||||
/**
|
||||
* Returns the request-level attribute with the given name, or <CODE>null</CODE> if there is no
|
||||
|
@ -287,7 +287,7 @@ public interface RequestInput extends ServiceProvider
|
|||
* @return An <CODE>Object</CODE> containing the value of the attribute, or <CODE>null</CODE> if no
|
||||
* attribute exists matching the given name.
|
||||
*/
|
||||
public abstract Object getRequestAttribute(String name);
|
||||
public Object getRequestAttribute(String name);
|
||||
|
||||
/**
|
||||
* Sets the request-level attribute with the given name.
|
||||
|
@ -296,21 +296,21 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param o The object to be bound as the value of that attribute, or <CODE>null</CODE> if the binding
|
||||
* is to be removed.
|
||||
*/
|
||||
public abstract void setRequestAttribute(String name, Object o);
|
||||
public void setRequestAttribute(String name, Object o);
|
||||
|
||||
/**
|
||||
* Returns the instance of the Venice engine associated with the application.
|
||||
*
|
||||
* @return See above.
|
||||
*/
|
||||
public abstract VeniceEngine getEngine();
|
||||
public VeniceEngine getEngine();
|
||||
|
||||
/**
|
||||
* Returns the instance of the Venice user object associated with the session.
|
||||
*
|
||||
* @return See above.
|
||||
*/
|
||||
public abstract UserContext getUser();
|
||||
public UserContext getUser();
|
||||
|
||||
/**
|
||||
* Returns the current servlet location. This is used, for instance, as the context to return to
|
||||
|
@ -318,7 +318,7 @@ public interface RequestInput extends ServiceProvider
|
|||
*
|
||||
* @return The current servlet location.
|
||||
*/
|
||||
public abstract String getLocation();
|
||||
public String getLocation();
|
||||
|
||||
/**
|
||||
* Sets the "current" servlet location that is displayed. This is used, for instance,
|
||||
|
@ -326,7 +326,7 @@ public interface RequestInput extends ServiceProvider
|
|||
*
|
||||
* @param str The new location to be set.
|
||||
*/
|
||||
public abstract void setLocation(String str);
|
||||
public void setLocation(String str);
|
||||
|
||||
/**
|
||||
* Returns <CODE>true</CODE> if the "Log In" link is to be displayed on the outer frame,
|
||||
|
@ -334,7 +334,7 @@ public interface RequestInput extends ServiceProvider
|
|||
*
|
||||
* @return See above.
|
||||
*/
|
||||
public abstract boolean getDisplayLogin();
|
||||
public boolean getDisplayLogin();
|
||||
|
||||
/**
|
||||
* Sets whether or not the "Log In" link is to be displayed on the outer frame.
|
||||
|
@ -342,26 +342,26 @@ public interface RequestInput extends ServiceProvider
|
|||
* @param val <CODE>true</CODE> to display the "Log In" link on the outer frame,
|
||||
* <CODE>false</CODE> to omit it.
|
||||
*/
|
||||
public abstract void setDisplayLogin(boolean val);
|
||||
public void setDisplayLogin(boolean val);
|
||||
|
||||
public abstract MenuComponent getMenu(String name);
|
||||
public MenuComponent getMenu(String name);
|
||||
|
||||
public abstract MenuComponent getMenu(String name, Map vars);
|
||||
public MenuComponent getMenu(String name, Map vars);
|
||||
|
||||
public abstract Dialog getDialog(String name);
|
||||
public Dialog getDialog(String name);
|
||||
|
||||
public abstract Content[] getSideBoxes() throws AccessError, DataException;
|
||||
public Content[] getSideBoxes() throws AccessError, DataException;
|
||||
|
||||
public abstract CommunityContext getCommunity();
|
||||
public CommunityContext getCommunity();
|
||||
|
||||
public abstract CommunityContext getCommunity(boolean required, String on_error) throws ErrorBox;
|
||||
public CommunityContext getCommunity(boolean required, String on_error) throws ErrorBox;
|
||||
|
||||
public abstract String getDefaultServletAddress(CommunityContext comm);
|
||||
public String getDefaultServletAddress(CommunityContext comm);
|
||||
|
||||
public abstract void registerCleanup(AutoCleanup ac);
|
||||
public void registerCleanup(AutoCleanup ac);
|
||||
|
||||
public abstract String getConfigProperty(String name);
|
||||
public String getConfigProperty(String name);
|
||||
|
||||
public abstract String getConfigProperty(String name, String default_val);
|
||||
public String getConfigProperty(String name, String default_val);
|
||||
|
||||
} // end interface RequestInput
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* 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-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
@ -24,32 +24,32 @@ import com.silverwrist.venice.util.ServiceProvider;
|
|||
|
||||
public interface RequestOutput extends ServiceProvider, LinkTypes
|
||||
{
|
||||
public abstract Writer getWriter() throws IOException;
|
||||
public Writer getWriter() throws IOException;
|
||||
|
||||
public abstract void write(String s) throws IOException;
|
||||
public void write(String s) throws IOException;
|
||||
|
||||
public abstract void writeStackTrace(Throwable t) throws IOException;
|
||||
public void writeStackTrace(Throwable t) throws IOException;
|
||||
|
||||
public abstract void flush() throws IOException;
|
||||
public void flush() throws IOException;
|
||||
|
||||
public abstract void output(Content c) throws IOException, ServletException;
|
||||
public void output(Content c) throws IOException, ServletException;
|
||||
|
||||
public abstract void output(Writer out, Content c) throws IOException, ServletException;
|
||||
public void output(Writer out, Content c) throws IOException, ServletException;
|
||||
|
||||
public abstract void writeFrameHead(Writer out, Content c) throws IOException;
|
||||
public void writeFrameHead(Writer out, Content c) throws IOException;
|
||||
|
||||
public abstract void writeFrameHead(Content c) throws IOException;
|
||||
public void writeFrameHead(Content c) throws IOException;
|
||||
|
||||
public abstract void writeSiteImageTag(Writer out) throws IOException;
|
||||
public void writeSiteImageTag(Writer out) throws IOException;
|
||||
|
||||
public abstract void writeSiteImageTag() throws IOException;
|
||||
public void writeSiteImageTag() throws IOException;
|
||||
|
||||
public abstract void writeVeniceLogo(Writer out) throws IOException;
|
||||
public void writeVeniceLogo(Writer out) throws IOException;
|
||||
|
||||
public abstract void writeVeniceLogo() throws IOException;
|
||||
public void writeVeniceLogo() throws IOException;
|
||||
|
||||
public abstract void writeContentHeader(Writer out, String primary, String secondary) throws IOException;
|
||||
public void writeContentHeader(Writer out, String primary, String secondary) throws IOException;
|
||||
|
||||
public abstract void writeContentHeader(String primary, String secondary) throws IOException;
|
||||
public void writeContentHeader(String primary, String secondary) throws IOException;
|
||||
|
||||
} // end interface RequestOutput
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* 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-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
@ -103,9 +103,9 @@ public abstract class BaseDialogField implements DialogField
|
|||
out.write(" " + StringUtil.encodeHTML(caption2));
|
||||
if (!reverse)
|
||||
out.write(":");
|
||||
out.write("</FONT>");
|
||||
out.write("</font>");
|
||||
if (required)
|
||||
out.write(html.getFontTag("red","content") + "*</FONT>");
|
||||
out.write(html.getFontTag("red","content") + "*</font>");
|
||||
|
||||
} // end renderCaption
|
||||
|
||||
|
@ -150,17 +150,17 @@ public abstract class BaseDialogField implements DialogField
|
|||
|
||||
public void render(RequestOutput out) throws IOException
|
||||
{
|
||||
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=RIGHT CLASS=\"content\">");
|
||||
out.write("<tr valign=\"middle\">\n<td align=\"right\" class=\"content\">");
|
||||
if (reverse)
|
||||
renderField(out);
|
||||
else
|
||||
renderCaption(out);
|
||||
out.write("</TD>\n<TD ALIGN=LEFT CLASS=\"content\">");
|
||||
out.write("</td>\n<td align=\"left\" class=\"content\">");
|
||||
if (reverse)
|
||||
renderCaption(out);
|
||||
else
|
||||
renderField(out);
|
||||
out.write("</TD>\n</TR>\n");
|
||||
out.write("</td>\n</tr>\n");
|
||||
|
||||
} // end render
|
||||
|
||||
|
|
592
src/com/silverwrist/venice/ui/dlg/DateField.java
Normal file
592
src/com/silverwrist/venice/ui/dlg/DateField.java
Normal file
|
@ -0,0 +1,592 @@
|
|||
/*
|
||||
* 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) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.ui.dlg;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
import org.apache.regexp.*;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.venice.except.*;
|
||||
import com.silverwrist.venice.ui.*;
|
||||
import com.silverwrist.venice.ui.helpers.HTMLRendering;
|
||||
import com.silverwrist.venice.util.XMLLoader;
|
||||
|
||||
public class DateField implements DialogField
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static final String TAGNAME = "date";
|
||||
|
||||
private static Logger logger = Logger.getLogger(DateField.class);
|
||||
|
||||
private static final int FLD_MONTH = 1;
|
||||
private static final int FLD_DAY = 2;
|
||||
private static final int FLD_YEAR = 3;
|
||||
|
||||
private static REProgram YRANGE = null;
|
||||
private static REProgram YPLUS = null;
|
||||
private static REProgram YMINUS = null;
|
||||
private static REProgram YPLUSMINUS = null;
|
||||
private static REProgram YMINUSPLUS = null;
|
||||
private static REProgram YSOLO = null;
|
||||
|
||||
private static Hashtable s_locale_ordering = new Hashtable();
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name; // field name (parameter name)
|
||||
private String m_caption; // primary caption
|
||||
private String m_caption2; // secondary caption
|
||||
private boolean m_required; // is this field required?
|
||||
private boolean m_enabled; // are we enabled?
|
||||
private int m_year_start; // first year for dropdown
|
||||
private int m_year_stop; // last year for dropdown
|
||||
private java.sql.Date m_value = null; // selected date
|
||||
private int m_ndx_month = -1; // index of selected month
|
||||
private int m_ndx_day = -1; // index of selected day
|
||||
private int m_ndx_year = -1; // index of selected year
|
||||
private boolean m_input_error = false; // input error?
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public DateField(String name, String caption, String caption2, boolean required, boolean enabled, int year_start,
|
||||
int year_stop)
|
||||
{
|
||||
m_name = name;
|
||||
m_caption = caption;
|
||||
m_caption2 = caption2;
|
||||
m_required = required;
|
||||
m_enabled = enabled;
|
||||
m_year_start = year_start;
|
||||
m_year_stop = year_stop;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public DateField(Element elt) throws ConfigException
|
||||
{
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
m_name = loader.configGetAttribute(elt,"name");
|
||||
m_caption = loader.configGetAttribute(elt,"capt");
|
||||
m_caption2 = elt.getAttribute("capt2");
|
||||
DOMElementHelper h = new DOMElementHelper(elt);
|
||||
m_required = h.hasAttribute("required");
|
||||
m_enabled = !(h.hasAttribute("disabled"));
|
||||
String countdir = elt.getAttribute("direction");
|
||||
if (StringUtil.isStringEmpty(countdir))
|
||||
countdir = "down";
|
||||
else if (!(countdir.equalsIgnoreCase("up") || countdir.equalsIgnoreCase("down")))
|
||||
throw new ConfigException("<date/> direction= attribute must be 'up' or 'down'",elt);
|
||||
int y1, y2;
|
||||
String yearspec = elt.getAttribute("years");
|
||||
if (StringUtil.isStringEmpty(yearspec))
|
||||
{ // use a 70 year span back from the current year
|
||||
Calendar cal = Calendar.getInstance();
|
||||
y1 = cal.get(Calendar.YEAR);
|
||||
y2 = y1 - 70;
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // now recognize what the field value is
|
||||
do
|
||||
{ // attempt to recognize a range
|
||||
RE re = new RE(YRANGE);
|
||||
if (re.match(yearspec))
|
||||
{ // got a year range
|
||||
y1 = Integer.parseInt(re.getParen(1));
|
||||
y2 = Integer.parseInt(re.getParen(2));
|
||||
break;
|
||||
|
||||
} // end if
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
re = new RE(YPLUS);
|
||||
if (re.match(yearspec))
|
||||
{ // +number - range from current year forward some years
|
||||
y1 = cal.get(Calendar.YEAR);
|
||||
y2 = y1 + Integer.parseInt(re.getParen(1));
|
||||
break;
|
||||
|
||||
} // end if
|
||||
|
||||
re = new RE(YMINUS);
|
||||
if (re.match(yearspec))
|
||||
{ // -number - range from current year backward some years
|
||||
y1 = cal.get(Calendar.YEAR);
|
||||
y2 = y1 - Integer.parseInt(re.getParen(1));
|
||||
break;
|
||||
|
||||
} // end if
|
||||
|
||||
re = new RE(YPLUSMINUS);
|
||||
if (re.match(yearspec))
|
||||
{ // +number -number - brackets around the current year
|
||||
int foo = cal.get(Calendar.YEAR);
|
||||
y1 = foo + Integer.parseInt(re.getParen(1));
|
||||
y2 = foo - Integer.parseInt(re.getParen(2));
|
||||
break;
|
||||
|
||||
} // end if
|
||||
|
||||
re = new RE(YMINUSPLUS);
|
||||
if (re.match(yearspec))
|
||||
{ // -number +number - brackets around the current year
|
||||
int foo = cal.get(Calendar.YEAR);
|
||||
y1 = foo - Integer.parseInt(re.getParen(1));
|
||||
y2 = foo + Integer.parseInt(re.getParen(2));
|
||||
break;
|
||||
|
||||
} // end if
|
||||
|
||||
re = new RE(YSOLO);
|
||||
if (re.match(yearspec))
|
||||
{ // solo number - one end of year spec, current year being the other
|
||||
y1 = cal.get(Calendar.YEAR);
|
||||
y2 = Integer.parseInt(re.getParen(1));
|
||||
break;
|
||||
|
||||
} // end if
|
||||
|
||||
throw new ConfigException("<date/> years= attribute: invalid syntax",elt);
|
||||
|
||||
} while (false); // end do
|
||||
|
||||
} // end else
|
||||
|
||||
if (countdir.equalsIgnoreCase("down"))
|
||||
{ // organize for counting downward
|
||||
m_year_start = Math.max(y1,y2);
|
||||
m_year_stop = Math.min(y1,y2);
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // organize for counting upward
|
||||
m_year_start = Math.min(y1,y2);
|
||||
m_year_stop = Math.max(y1,y2);
|
||||
|
||||
} // end else
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected DateField(DateField other)
|
||||
{
|
||||
m_name = other.m_name;
|
||||
m_caption = other.m_caption;
|
||||
m_caption2 = other.m_caption2;
|
||||
m_required = other.m_required;
|
||||
m_enabled = other.m_enabled;
|
||||
m_year_start = other.m_year_start;
|
||||
m_year_stop = other.m_year_stop;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final int[] getDateFieldOrdering(Locale locale)
|
||||
{
|
||||
int[] rc = (int[])(s_locale_ordering.get(locale));
|
||||
if (rc!=null)
|
||||
return rc;
|
||||
|
||||
// We determine the date format by encoding the date September 18, 2003, into "short"
|
||||
// date format, then measuring the relative positions of the digits 9, 8, and 3.
|
||||
// It's severely hackish, but there seems to be no Java API whereby we can directly
|
||||
// get this information.
|
||||
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT,locale);
|
||||
Calendar cal = fmt.getCalendar();
|
||||
cal.set(Calendar.YEAR,2003);
|
||||
cal.set(Calendar.MONTH,Calendar.SEPTEMBER);
|
||||
cal.set(Calendar.DAY_OF_MONTH,18);
|
||||
String s = fmt.format(cal.getTime());
|
||||
int pday = s.indexOf('8');
|
||||
int pmonth = s.indexOf('9');
|
||||
int pyear = s.indexOf('3');
|
||||
rc = new int[3];
|
||||
if (pday<pmonth)
|
||||
{ // day before month
|
||||
if (pday<pyear)
|
||||
{ // we're definitely DAY first
|
||||
rc[0] = FLD_DAY;
|
||||
if (pmonth<pyear)
|
||||
{ // D-M-Y (Euro standard)
|
||||
rc[1] = FLD_MONTH;
|
||||
rc[2] = FLD_YEAR;
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // D-Y-M? Well, OK...
|
||||
rc[1] = FLD_YEAR;
|
||||
rc[2] = FLD_MONTH;
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // day before month, but after year - Y-D-M? OK...
|
||||
rc[0] = FLD_YEAR;
|
||||
rc[1] = FLD_DAY;
|
||||
rc[2] = FLD_MONTH;
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // month before day
|
||||
if (pmonth<pyear)
|
||||
{ // definitely MONTH first...
|
||||
rc[0] = FLD_MONTH;
|
||||
if (pday<pyear)
|
||||
{ // M-D-Y (American standard)
|
||||
rc[1] = FLD_DAY;
|
||||
rc[2] = FLD_YEAR;
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // M-Y-D? OK...
|
||||
rc[1] = FLD_YEAR;
|
||||
rc[2] = FLD_DAY;
|
||||
|
||||
} // end else
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // month before day, but after year - Y-M-D (Japanese standard)
|
||||
rc[0] = FLD_YEAR;
|
||||
rc[1] = FLD_MONTH;
|
||||
rc[2] = FLD_DAY;
|
||||
|
||||
} // end else
|
||||
|
||||
} // end else
|
||||
|
||||
s_locale_ordering.put(locale,rc);
|
||||
return rc;
|
||||
|
||||
} // end getDateFieldOrdering
|
||||
|
||||
private final void renderDropDown(int which, RequestOutput out) throws IOException
|
||||
{
|
||||
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
||||
Calendar cal = Calendar.getInstance(TimeZone.getDefault(),html.getLocale());
|
||||
if (which==FLD_MONTH)
|
||||
{ // render the "month" field
|
||||
out.write("<select class=\"content\" name=\"" + m_name + "_month\" size=\"1\"");
|
||||
if (!m_enabled)
|
||||
out.write(" disabled=\"disabled\"");
|
||||
out.write("><option value=\"-1\"");
|
||||
if (m_ndx_month==-1)
|
||||
out.write(" selected=\"selected\"");
|
||||
out.write(">---</option>");
|
||||
DateFormatSymbols syms = new DateFormatSymbols(html.getLocale());
|
||||
String[] months = syms.getMonths();
|
||||
for (int i=cal.getMinimum(Calendar.MONTH); i<=cal.getMaximum(Calendar.MONTH); i++)
|
||||
{ // write the choices
|
||||
out.write("<option value=\"" + i + "\"");
|
||||
if (m_ndx_month==i)
|
||||
out.write(" selected=\"selected\"");
|
||||
out.write(">" + StringUtil.encodeHTML(months[i]) + "</option>");
|
||||
|
||||
} // end for
|
||||
|
||||
out.write("</select>\n");
|
||||
|
||||
} // end if
|
||||
else if (which==FLD_DAY)
|
||||
{ // render the "day" field
|
||||
out.write("<select class=\"content\" name=\"" + m_name + "_day\" size=\"1\"");
|
||||
if (!m_enabled)
|
||||
out.write(" disabled=\"disabled\"");
|
||||
out.write("><option value=\"-1\"");
|
||||
if (m_ndx_day==-1)
|
||||
out.write(" selected=\"selected\"");
|
||||
out.write(">---</option>");
|
||||
for (int i=cal.getMinimum(Calendar.DAY_OF_MONTH); i<=cal.getMaximum(Calendar.DAY_OF_MONTH); i++)
|
||||
{ // write the day values
|
||||
out.write("<option value=\"" + i + "\"");
|
||||
if (m_ndx_day==i)
|
||||
out.write(" selected=\"selected\"");
|
||||
out.write(">" + i + "</option>");
|
||||
|
||||
} // end for
|
||||
|
||||
out.write("</select>\n");
|
||||
|
||||
} // end if
|
||||
else if (which==FLD_YEAR)
|
||||
{ // render the "year" drop down
|
||||
out.write("<select class=\"content\" name=\"" + m_name + "_year\" size=\"1\"");
|
||||
if (!m_enabled)
|
||||
out.write(" disabled=\"disabled\"");
|
||||
out.write("><option value=\"-1\"");
|
||||
if (m_ndx_year==-1)
|
||||
out.write(" selected=\"selected\"");
|
||||
out.write(">---</option>");
|
||||
int step = ((m_year_start>m_year_stop) ? -1 : 1);
|
||||
for (int i=m_year_start; i!=m_year_stop; i+=step)
|
||||
{ // write out years
|
||||
out.write("<option value=\"" + i + "\"");
|
||||
if (m_ndx_year==i)
|
||||
out.write(" selected=\"selected\"");
|
||||
out.write(">" + i + "</option>");
|
||||
|
||||
} // end for
|
||||
|
||||
// write the last year value
|
||||
out.write("<option value=\"" + m_year_stop + "\"");
|
||||
if (m_ndx_year==m_year_stop)
|
||||
out.write(" selected=\"selected\"");
|
||||
out.write(">" + m_year_stop + "</option></select>\n");
|
||||
|
||||
} // end else if
|
||||
|
||||
} // end renderDropDown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface RenderDirect
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void render(RequestOutput out) throws IOException
|
||||
{
|
||||
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
||||
Calendar cal = Calendar.getInstance(TimeZone.getDefault(),html.getLocale());
|
||||
if ((m_value!=null) && !m_input_error)
|
||||
{ // split date into month, day, and year
|
||||
cal.setTime(m_value);
|
||||
if (m_ndx_month==-1)
|
||||
m_ndx_month = cal.get(Calendar.MONTH);
|
||||
if (m_ndx_day==-1)
|
||||
m_ndx_day = cal.get(Calendar.DAY_OF_MONTH);
|
||||
if (m_ndx_year==-1)
|
||||
m_ndx_year = cal.get(Calendar.YEAR);
|
||||
|
||||
} // end if
|
||||
else // everything is not set
|
||||
m_ndx_month = m_ndx_day = m_ndx_year = -1;
|
||||
|
||||
// write the caption and the basic table framework
|
||||
out.write("<tr valign=\"middle\">\n<td align=\"right\" class=\"content\">");
|
||||
out.write(html.getFontTag(m_enabled ? html.CONTENT_FOREGROUND : html.CONTENT_DISABLED,"content"));
|
||||
out.write(StringUtil.encodeHTML(m_caption));
|
||||
if (!(StringUtil.isStringEmpty(m_caption2)))
|
||||
out.write(" " + StringUtil.encodeHTML(m_caption2));
|
||||
out.write(":</font>");
|
||||
if (m_required)
|
||||
out.write(html.getFontTag("red","content") + "*</font>");
|
||||
out.write("</td>\n<td align=\"left\" class=\"content\">");
|
||||
|
||||
// write the drop-down list boxes
|
||||
int[] order = getDateFieldOrdering(html.getLocale());
|
||||
renderDropDown(order[0],out);
|
||||
out.write(" \n");
|
||||
renderDropDown(order[1],out);
|
||||
out.write(" \n");
|
||||
renderDropDown(order[2],out);
|
||||
|
||||
// finish up
|
||||
out.write("</td>\n</tr>\n");
|
||||
|
||||
} // end render
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DialogField
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
public Object getValue()
|
||||
{
|
||||
return m_value;
|
||||
|
||||
} // end getValue
|
||||
|
||||
public void setValue(Object o)
|
||||
{
|
||||
if (o==null)
|
||||
m_value = null;
|
||||
else if (o instanceof java.sql.Date)
|
||||
m_value = (java.sql.Date)(((java.sql.Date)o).clone());
|
||||
else if (o instanceof java.util.Date)
|
||||
m_value = new java.sql.Date(((java.util.Date)o).getTime());
|
||||
else if (o instanceof Calendar)
|
||||
m_value = new java.sql.Date(((Calendar)o).getTimeInMillis());
|
||||
else if (o instanceof Number)
|
||||
m_value = new java.sql.Date(((Number)o).longValue());
|
||||
else
|
||||
throw new IllegalArgumentException("cannot convert argument to java.sql.Date");
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Set date: " + m_value);
|
||||
m_ndx_month = m_ndx_day = m_ndx_year = -1; // kill indexes
|
||||
m_input_error = false;
|
||||
|
||||
} // end setValue
|
||||
|
||||
public void setValueFrom(RequestInput ri)
|
||||
{
|
||||
m_ndx_month = ri.getParameterInt(m_name + "_month",-1);
|
||||
m_ndx_day = ri.getParameterInt(m_name + "_day",-1);
|
||||
m_ndx_year = ri.getParameterInt(m_name + "_year",-1);
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Raw input: M=" + m_ndx_month + ", D=" + m_ndx_day + ", Y=" + m_ndx_year);
|
||||
|
||||
if ((m_ndx_month==-1) || (m_ndx_day==-1) || (m_ndx_year==-1))
|
||||
{ // the date is to be treated as "unspecified"
|
||||
logger.debug("Killing the kittens!");
|
||||
m_value = null;
|
||||
m_ndx_month = m_ndx_day = m_ndx_year = -1; // kill indexes
|
||||
m_input_error = false;
|
||||
return;
|
||||
|
||||
} // end if
|
||||
|
||||
HTMLRendering html = (HTMLRendering)(ri.queryService(HTMLRendering.class));
|
||||
Calendar cal = Calendar.getInstance(TimeZone.getDefault(),html.getLocale());
|
||||
cal.clear();
|
||||
cal.setLenient(false);
|
||||
m_input_error = false;
|
||||
try
|
||||
{ // set the calendar and create the actual value
|
||||
cal.set(Calendar.YEAR,m_ndx_year);
|
||||
cal.set(Calendar.MONTH,m_ndx_month);
|
||||
cal.set(Calendar.DAY_OF_MONTH,m_ndx_day);
|
||||
cal.set(Calendar.HOUR,0);
|
||||
cal.set(Calendar.MINUTE,0);
|
||||
cal.set(Calendar.SECOND,0);
|
||||
cal.set(Calendar.MILLISECOND,0);
|
||||
m_value = new java.sql.Date(cal.getTimeInMillis());
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Verified date: " + m_value);
|
||||
|
||||
} // end try
|
||||
catch (IllegalArgumentException e)
|
||||
{ // set error flag and recompute value with relaxed rules
|
||||
m_input_error = true;
|
||||
cal.clear();
|
||||
cal.setLenient(true);
|
||||
cal.set(Calendar.YEAR,m_ndx_year);
|
||||
cal.set(Calendar.MONTH,m_ndx_month);
|
||||
cal.set(Calendar.DAY_OF_MONTH,m_ndx_day);
|
||||
cal.set(Calendar.HOUR,0);
|
||||
cal.set(Calendar.MINUTE,0);
|
||||
cal.set(Calendar.SECOND,0);
|
||||
cal.set(Calendar.MILLISECOND,0);
|
||||
m_value = new java.sql.Date(cal.getTimeInMillis());
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("UN-Verified date: " + m_value);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end setValueFrom
|
||||
|
||||
public boolean isRequired()
|
||||
{
|
||||
return m_required;
|
||||
|
||||
} // end isRequired
|
||||
|
||||
public boolean isFile()
|
||||
{
|
||||
return false;
|
||||
|
||||
} // end isFile
|
||||
|
||||
public boolean isHidden()
|
||||
{
|
||||
return false;
|
||||
|
||||
} // end isHidden
|
||||
|
||||
public void validate() throws ValidationException
|
||||
{
|
||||
if (m_required && (m_value==null))
|
||||
throw new ValidationException("The '" + m_caption + "' field is required.");
|
||||
if (m_input_error)
|
||||
throw new ValidationException("Invalid date entered in the '" + m_caption + "' field.");
|
||||
|
||||
} // end validate
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return m_enabled;
|
||||
|
||||
} // end isEnabled
|
||||
|
||||
public void setEnabled(boolean flag)
|
||||
{
|
||||
m_enabled = flag;
|
||||
|
||||
} // end setEnabled
|
||||
|
||||
public Object sendMessage(String msg, Object data)
|
||||
{
|
||||
return null;
|
||||
|
||||
} // end sendMessage
|
||||
|
||||
public DialogField duplicate()
|
||||
{
|
||||
return new DateField(this);
|
||||
|
||||
} // end duplicate
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static initializer
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static
|
||||
{
|
||||
RECompiler compiler = new RECompiler();
|
||||
try
|
||||
{ // compile all local regular expressions
|
||||
YRANGE = compiler.compile("^\\s*(\\d+)\\s*-\\s*(\\d+)\\s*$");
|
||||
YPLUS = compiler.compile("^\\s*\\+\\s*(\\d+)\\s*$");
|
||||
YMINUS = compiler.compile("^\\s*-\\s*(\\d+)\\s*$");
|
||||
YPLUSMINUS = compiler.compile("^\\s*\\+\\s*(\\d+)\\s*-\\s*(\\d+)\\s*$");
|
||||
YMINUSPLUS = compiler.compile("^\\s*-\\s*(\\d+)\\s*\\+\\s*(\\d+)\\s*$");
|
||||
YSOLO = compiler.compile("^\\s*(\\d+)\\s*$");
|
||||
|
||||
} // end try
|
||||
catch (RESyntaxException e)
|
||||
{ // whoops!
|
||||
logger.fatal("Regexp Syntax Error",e);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end static initializer
|
||||
|
||||
} // end class DateField
|
|
@ -31,13 +31,13 @@ public class DialogElementLoader
|
|||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Category logger = Category.getInstance(DialogElementLoader.class);
|
||||
private static Logger logger = Logger.getLogger(DialogElementLoader.class);
|
||||
|
||||
private static DialogElementLoader self = null;
|
||||
|
||||
private static final Class[] init_classes = {
|
||||
CategoryHeader.class, CheckBoxField.class, CommunityLogoField.class, CountryListField.class,
|
||||
EMailAddressField.class, HiddenField.class, ImageButton.class, IntegerField.class,
|
||||
DateField.class, EMailAddressField.class, HiddenField.class, ImageButton.class, IntegerField.class,
|
||||
IPAddressField.class, LanguageListField.class, LocaleListField.class, PasswordField.class,
|
||||
RoleListField.class, StaticPickListField.class, TextField.class, TimeZoneListField.class,
|
||||
UserPhotoField.class, VeniceIDField.class
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* 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 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
@ -23,28 +23,28 @@ import com.silverwrist.venice.ui.RequestInput;
|
|||
|
||||
public interface DialogField extends RenderDirect
|
||||
{
|
||||
public abstract String getName();
|
||||
public String getName();
|
||||
|
||||
public abstract Object getValue();
|
||||
public Object getValue();
|
||||
|
||||
public abstract void setValue(Object o);
|
||||
public void setValue(Object o);
|
||||
|
||||
public abstract void setValueFrom(RequestInput ri);
|
||||
public void setValueFrom(RequestInput ri);
|
||||
|
||||
public abstract boolean isRequired();
|
||||
public boolean isRequired();
|
||||
|
||||
public abstract boolean isFile();
|
||||
public boolean isFile();
|
||||
|
||||
public abstract boolean isHidden();
|
||||
public boolean isHidden();
|
||||
|
||||
public abstract void validate() throws ValidationException;
|
||||
public void validate() throws ValidationException;
|
||||
|
||||
public abstract boolean isEnabled();
|
||||
public boolean isEnabled();
|
||||
|
||||
public abstract void setEnabled(boolean flag);
|
||||
public void setEnabled(boolean flag);
|
||||
|
||||
public abstract Object sendMessage(String msg, Object data);
|
||||
public Object sendMessage(String msg, Object data);
|
||||
|
||||
public abstract DialogField duplicate();
|
||||
public DialogField duplicate();
|
||||
|
||||
} // end interface DialogField
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* 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 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
@ -75,9 +75,9 @@ public abstract class PickListField extends BaseDialogField
|
|||
|
||||
protected void renderField(RequestOutput out) throws IOException
|
||||
{
|
||||
out.write("<SELECT CLASS=\"content\" NAME=\"" + getName() + "\" SIZE=1");
|
||||
out.write("<select class=\"content\" name=\"" + getName() + "\" size=\"1\"");
|
||||
if (!isEnabled())
|
||||
out.write(" DISABLED");
|
||||
out.write(" disabled=\"disabled\"");
|
||||
out.write(">\n");
|
||||
Iterator it = choices.iterator();
|
||||
String val = getStringValue();
|
||||
|
@ -85,14 +85,14 @@ public abstract class PickListField extends BaseDialogField
|
|||
{ // loop through the list and render the choices
|
||||
Object ch = it.next();
|
||||
String ch_name = getChoiceName(ch);
|
||||
out.write("<OPTION VALUE=\"" + ch_name + "\"");
|
||||
out.write("<option value=\"" + ch_name + "\"");
|
||||
if (ch_name.equals(val))
|
||||
out.write(" SELECTED");
|
||||
out.write(">" + StringUtil.encodeHTML(getChoiceValue(ch)) + "</OPTION>\n");
|
||||
out.write(" selected=\"selected\"");
|
||||
out.write(">" + StringUtil.encodeHTML(getChoiceValue(ch)) + "</option>\n");
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</SELECT>\n"); // all done
|
||||
out.write("</select>\n"); // all done
|
||||
|
||||
} // end render
|
||||
|
||||
|
|
|
@ -9,64 +9,70 @@
|
|||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* 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) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
* Copyright (C) 2002-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.ui.helpers;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import com.silverwrist.venice.ui.ColorSelectors;
|
||||
import com.silverwrist.venice.ui.LinkTypes;
|
||||
|
||||
public interface HTMLRendering extends ColorSelectors, LinkTypes
|
||||
{
|
||||
public abstract String getColor(int selector);
|
||||
public String getColor(int selector);
|
||||
|
||||
public abstract String getColor(String name);
|
||||
public String getColor(String name);
|
||||
|
||||
public abstract boolean useHTMLComments();
|
||||
public boolean useHTMLComments();
|
||||
|
||||
public abstract String formatURL(String url, int type);
|
||||
public String formatURL(String url, int type);
|
||||
|
||||
public abstract String formatDate(Date date);
|
||||
public String formatDate(Date date);
|
||||
|
||||
public abstract String getFontTag(int colorsel, int size);
|
||||
public String getFontTag(int colorsel, int size);
|
||||
|
||||
public abstract String getFontTag(String color, int size);
|
||||
public String getFontTag(String color, int size);
|
||||
|
||||
public abstract String getFontTag(int colorsel, String size);
|
||||
public String getFontTag(int colorsel, String size);
|
||||
|
||||
public abstract String getFontTag(String color, String size);
|
||||
public String getFontTag(String color, String size);
|
||||
|
||||
public abstract int convertLinkType(String str);
|
||||
public int convertLinkType(String str);
|
||||
|
||||
public abstract String getStockMessage(String key);
|
||||
public String getStockMessage(String key);
|
||||
|
||||
public abstract String getStockMessage(String key, Map vars);
|
||||
public String getStockMessage(String key, Map vars);
|
||||
|
||||
public abstract String getStaticPath(String s);
|
||||
public String getStaticPath(String s);
|
||||
|
||||
public abstract String getExternalStaticPath(String s);
|
||||
public String getExternalStaticPath(String s);
|
||||
|
||||
public abstract String getImagePath(String s);
|
||||
public String getImagePath(String s);
|
||||
|
||||
public abstract String getButtonVisual(String id);
|
||||
public String getButtonVisual(String id);
|
||||
|
||||
public abstract String getButtonInput(String id);
|
||||
public String getButtonInput(String id);
|
||||
|
||||
public abstract String getUserPhotoTag(String url);
|
||||
public String getUserPhotoTag(String url);
|
||||
|
||||
public abstract String getUserPhotoTag(String url, Dimension size);
|
||||
public String getUserPhotoTag(String url, Dimension size);
|
||||
|
||||
public abstract String getActivityString(Date date);
|
||||
public String getActivityString(Date date);
|
||||
|
||||
public abstract String getCommunityLogoTag(String url);
|
||||
public String getCommunityLogoTag(String url);
|
||||
|
||||
public abstract String expandServletPath(String spath);
|
||||
public String expandServletPath(String spath);
|
||||
|
||||
public Calendar getCalendar();
|
||||
|
||||
public Locale getLocale();
|
||||
|
||||
} // end interface HTMLRendering
|
||||
|
|
|
@ -241,7 +241,7 @@ public class ImportHelper
|
|||
try
|
||||
{ // create the user context
|
||||
AdminUserContext uc = adm.createNewAccount(username,password,prehashed,reminder,confirm,locked,r,
|
||||
description,autojoin);
|
||||
description,vcard.getBirthday(),autojoin);
|
||||
|
||||
// set up the contact info
|
||||
ContactInfo ci = uc.getContactInfo();
|
||||
|
|
|
@ -656,7 +656,10 @@ public class RequestImpl implements RequestInput
|
|||
{ // read the user's preferred locale
|
||||
try
|
||||
{ // get the user default locale
|
||||
my_locale = session.getUser().getLocale();
|
||||
if (session.getUser()!=null)
|
||||
my_locale = session.getUser().getLocale();
|
||||
else
|
||||
my_locale = Locale.getDefault();
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
|
@ -2248,6 +2251,18 @@ class HTMLRenderingImpl implements HTMLRendering
|
|||
|
||||
} // end expandServletPath
|
||||
|
||||
public Calendar getCalendar()
|
||||
{
|
||||
return new GregorianCalendar(req.getTimeZone(),req.getLocale());
|
||||
|
||||
} // end getCalendar
|
||||
|
||||
public Locale getLocale()
|
||||
{
|
||||
return req.getLocale();
|
||||
|
||||
} // end getLocale
|
||||
|
||||
} // end class HTMLRenderingImpl
|
||||
|
||||
class ScriptSupportImpl implements ScriptSupport
|
||||
|
|
|
@ -45,6 +45,7 @@ public class BuildVCard
|
|||
private String note = null;
|
||||
private String sort_string = null;
|
||||
private String url = null;
|
||||
private java.sql.Date m_bday = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
|
@ -315,6 +316,18 @@ public class BuildVCard
|
|||
|
||||
} // end setURL
|
||||
|
||||
public final java.sql.Date getBirthday()
|
||||
{
|
||||
return m_bday;
|
||||
|
||||
} // end getBirthday
|
||||
|
||||
public final void setBirthday(java.sql.Date d)
|
||||
{
|
||||
m_bday = d;
|
||||
|
||||
} // end setBirthday
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -340,13 +353,14 @@ public class BuildVCard
|
|||
note = null;
|
||||
sort_string = null;
|
||||
url = null;
|
||||
m_bday = null;
|
||||
|
||||
} // end reset
|
||||
|
||||
public VCard create()
|
||||
{
|
||||
return new VCard(realFormattedName(),family_name,given_name,middle_name,prefix,suffix,nickname,addresses,phones,
|
||||
email_addresses,mailer,timezone,title,role,orgname,note,sort_string,url);
|
||||
email_addresses,mailer,timezone,title,role,orgname,note,sort_string,url,m_bday);
|
||||
|
||||
} // end create
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package com.silverwrist.venice.util;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import org.apache.log4j.*;
|
||||
import org.w3c.dom.*;
|
||||
|
@ -33,6 +34,9 @@ public class VCard
|
|||
|
||||
private static Category logger = Category.getInstance(VCard.class);
|
||||
|
||||
private static final DateFormat ISO_EXTENDED = new SimpleDateFormat("yyyy-MM-dd");
|
||||
private static final DateFormat ISO_STD = new SimpleDateFormat("yyyyMMdd");
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -56,6 +60,7 @@ public class VCard
|
|||
private String note = null;
|
||||
private String sort_string = null;
|
||||
private String url = null;
|
||||
private java.sql.Date m_bday = null;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructors
|
||||
|
@ -64,7 +69,8 @@ public class VCard
|
|||
|
||||
VCard(String formatted_name, String family_name, String given_name, String middle_name, String prefix, String suffix,
|
||||
String nickname, Collection addresses, Collection phones, Collection email_addresses, String mailer,
|
||||
String timezone, String title, String role, String orgname, String note, String sort_string, String url)
|
||||
String timezone, String title, String role, String orgname, String note, String sort_string, String url,
|
||||
java.sql.Date bday)
|
||||
{
|
||||
this.formatted_name = formatted_name;
|
||||
this.family_name = family_name;
|
||||
|
@ -84,6 +90,7 @@ public class VCard
|
|||
this.note = note;
|
||||
this.sort_string = sort_string;
|
||||
this.url = url;
|
||||
m_bday = bday;
|
||||
|
||||
} // end constructor
|
||||
|
||||
|
@ -176,10 +183,11 @@ public class VCard
|
|||
sort_string = readElemText((Element)n);
|
||||
else if (nm.equals("URL"))
|
||||
url = readElemText((Element)n);
|
||||
else if ( nm.equals("PHOTO") || nm.equals("BDAY") || nm.equals("LABEL") || nm.equals("GEO")
|
||||
|| nm.equals("LOGO") || nm.equals("AGENT") || nm.equals("CATEGORIES") || nm.equals("PRODID")
|
||||
|| nm.equals("REV") || nm.equals("SOUND") || nm.equals("UID") || nm.equals("CLASS")
|
||||
|| nm.equals("KEY"))
|
||||
else if (nm.equals("BDAY"))
|
||||
m_bday = readDateValue((Element)n);
|
||||
else if ( nm.equals("PHOTO") || nm.equals("LABEL") || nm.equals("GEO") || nm.equals("LOGO")
|
||||
|| nm.equals("AGENT") || nm.equals("CATEGORIES") || nm.equals("PRODID") || nm.equals("REV")
|
||||
|| nm.equals("SOUND") || nm.equals("UID") || nm.equals("CLASS") || nm.equals("KEY"))
|
||||
{ // a catch-all for elements that we don't support yet
|
||||
logger.warn("vCard <" + nm + "/> element is not yet supported");
|
||||
|
||||
|
@ -265,6 +273,39 @@ public class VCard
|
|||
|
||||
} // end readTimeZoneText
|
||||
|
||||
private static final java.sql.Date readDateValue(Element elt) throws ValidationException
|
||||
{
|
||||
DOMElementHelper h = new DOMElementHelper(elt);
|
||||
String s = h.getElementText();
|
||||
if (s==null)
|
||||
return null;
|
||||
s = s.trim();
|
||||
|
||||
java.util.Date tmp;
|
||||
try
|
||||
{ // try parsing via extended first
|
||||
tmp = ISO_EXTENDED.parse(s);
|
||||
return new java.sql.Date(tmp.getTime());
|
||||
|
||||
} // end try
|
||||
catch (ParseException e)
|
||||
{ // do nothing, just fall through and try again
|
||||
} // end catch
|
||||
|
||||
try
|
||||
{ // now try parsing with standard format
|
||||
tmp = ISO_STD.parse(s);
|
||||
return new java.sql.Date(tmp.getTime());
|
||||
|
||||
} // end try
|
||||
catch (ParseException e)
|
||||
{ // NOW bail out of here!
|
||||
throw new ValidationException("date value could not be parsed");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end readDateValue
|
||||
|
||||
private VCardAddress findAddress(VCardAddress.Predicate pred)
|
||||
{
|
||||
Iterator it = addresses.iterator();
|
||||
|
@ -405,6 +446,12 @@ public class VCard
|
|||
|
||||
} // end getURL
|
||||
|
||||
public final java.sql.Date getBirthday()
|
||||
{
|
||||
return m_bday;
|
||||
|
||||
} // end getBirthday
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External operations
|
||||
*--------------------------------------------------------------------------------
|
||||
|
@ -650,6 +697,8 @@ public class VCard
|
|||
xml_writer.write("<SORTSTR>" + sort_string + "</SORTSTR>\n");
|
||||
if (!StringUtil.isStringEmpty(url))
|
||||
xml_writer.write("<URL>" + url + "</URL>\n");
|
||||
if (m_bday!=null)
|
||||
xml_writer.write("<BDAY>" + ISO_EXTENDED.format(m_bday) + "</BDAY>\n");
|
||||
xml_writer.write("</vCard>\n");
|
||||
|
||||
} // end exportXML
|
||||
|
|
Loading…
Reference in New Issue
Block a user