*** empty log message ***
This commit is contained in:
120
venice-data/util/create_profile.js
Normal file
120
venice-data/util/create_profile.js
Normal file
@@ -0,0 +1,120 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.lang);
|
||||
importPackage(Packages.com.silverwrist.util);
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.security);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
req_help = bsf.lookupBean("request_help"); // get request helper
|
||||
me = vlib.getUser(req); // get self
|
||||
user = cast.queryDynamoUser(req.getObject("temp:","user")); // get user being displayed
|
||||
|
||||
// are we allowed to view "private" data?
|
||||
view_all = me.equals(user);
|
||||
if (!view_all)
|
||||
{ // look to see if we're an administrator
|
||||
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"srm"));
|
||||
view_all = srm.getGlobalAcl().testPermission(me,Namespaces.DYNAMO_USER_INFO_NAMESPACE,"view.all");
|
||||
|
||||
} // end if
|
||||
|
||||
// create the view object
|
||||
view = new VelocityView("User Profile: " + user.getName(),"user/profile.vm");
|
||||
view.setPageQID("user/" + user.getName());
|
||||
|
||||
// get the privacy options for this user
|
||||
priv = cast.toOptionSet(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"privacy"));
|
||||
|
||||
// get the user photo renderer
|
||||
uphoto = vcast.queryRenderImage(req_help.getRequestObject(VeniceNamespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"venice-userphoto"));
|
||||
|
||||
// set the view parameters
|
||||
view.setParameter("uid",cast.toIntegerObject(user.getUID()));
|
||||
view.setParameter("username",user.getName());
|
||||
photo_url = PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"url.photo");
|
||||
if (photo_url==null)
|
||||
{ // get the "No Photo Available" default
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
url = globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.nophoto.url");
|
||||
urltype = globals.getObject(VeniceNamespaces.CONTENT_LAF_NAMESPACE,"user.nophoto.url.type");
|
||||
rewriter = cast.queryURLRewriter(req);
|
||||
photo_url = rewriter.rewriteURL(urltype,url);
|
||||
|
||||
} // end if
|
||||
|
||||
view.setParameter("photo",uphoto.getRenderingObject(photo_url));
|
||||
view.setParameter("date_create",user.creationDate);
|
||||
view.setParameter("date_lastlogin",user.lastAccessDate);
|
||||
view.setParameter("date_lastupdate",user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"last.update"));
|
||||
|
||||
buf = new StringBuffer();
|
||||
s = PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.prefix");
|
||||
if (s!=null)
|
||||
buf.append(s).append(" ");
|
||||
buf.append(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.given")).append(" ");
|
||||
ch = PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.mi");
|
||||
if (ch!=null)
|
||||
buf.append(ch).append(". ");
|
||||
buf.append(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.family"));
|
||||
s = PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.suffix");
|
||||
if (s!=null)
|
||||
buf.append(" ").append(s);
|
||||
view.setParameter("fullname",buf.toString());
|
||||
|
||||
if (view_all || !(priv.get(4)))
|
||||
view.setParameter("email",user.getEMailAddress());
|
||||
view.setParameter("url",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"url.homepage"));
|
||||
view.setParameter("company",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"company.name"));
|
||||
if (view_all || !(priv.get(0)))
|
||||
{ // add the address lines
|
||||
view.setParameter("addr1",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"address.1"));
|
||||
view.setParameter("addr2",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"address.2"));
|
||||
|
||||
} // end if
|
||||
|
||||
buf = new StringBuffer(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"locality").toString());
|
||||
buf.append(", ").append(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"region"));
|
||||
buf.append(" ").append(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"postal.code"));
|
||||
view.setParameter("addr_last",buf.toString());
|
||||
view.setParameter("country",cast.toCountry(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"country")).getName());
|
||||
if (view_all || !(priv.get(1)))
|
||||
view.setParameter("phone",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"phone.voice"));
|
||||
if (view_all || !(priv.get(3)))
|
||||
view.setParameter("fax",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"phone.fax"));
|
||||
if (view_all || !(priv.get(2)))
|
||||
view.setParameter("mobile",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"phone.mobile"));
|
||||
view.setParameter("description",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"description"));
|
||||
if (!(me.isAnonymous() || user.isAnonymous()))
|
||||
view.setParameter("quick_email",Boolean.TRUE);
|
||||
|
||||
dynamo.scriptOutput(view); // all done!
|
||||
62
venice-data/util/password_recovery.js
Normal file
62
venice-data/util/password_recovery.js
Normal file
@@ -0,0 +1,62 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.util);
|
||||
importClass(Packages.com.silverwrist.dynamo.UserInfoNamespace);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.mail);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
importPackage(Packages.com.silverwrist.venice.session);
|
||||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
req_help = bsf.lookupBean("request_help"); // get request
|
||||
uid = req_help.getParameterString("uid");
|
||||
auth = req_help.getParameterString("auth");
|
||||
if ((uid==null) || (auth==null))
|
||||
dynamo.scriptReturn(new ErrorBox(null,"Invalid parameters."));
|
||||
|
||||
user = vlib.lookupUser(req,cast.toInteger(uid));
|
||||
if (user==null)
|
||||
dynamo.scriptReturn(new ErrorBox(null,"User account not found."));
|
||||
|
||||
if (!(user.authenticate(VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"password.recovery","",auth.toString())))
|
||||
dynamo.scriptReturn(new ErrorBox(null,"Invalid password recovery request."));
|
||||
|
||||
// clear the old password recovery data
|
||||
user.clearAuthenticationData(user,VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"password.recovery");
|
||||
|
||||
// generate a new password and set it for the user
|
||||
newpass = vlib.randomPassword();
|
||||
user.setAuthenticationData(user,UserInfoNamespace.NAMESPACE,UserInfoNamespace.AUTH_DEFAULT,"",newpass);
|
||||
|
||||
// E-mail the user with a new password.
|
||||
mailprov = cast.queryMailMessageProvider(req);
|
||||
msg = mailprov.createSystemMessage(req);
|
||||
msg.addRecipient(MailMessage.RECIP_TO,user.getEMailAddress());
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
msg.setSubject(globals.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,
|
||||
"password.change.message.title").toString());
|
||||
blocks = vcast.getGlobalBlocksStore(req);
|
||||
msg.setText(blocks.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,"password.change.message").toString());
|
||||
msg.setVariable("username",user.getName());
|
||||
msg.setVariable("password",newpass);
|
||||
msg.send();
|
||||
|
||||
// Now pass back a "password changed" page.
|
||||
vlib.setLocation(req,"top.js.vs"); // lie so we can get the "Log In" link up top
|
||||
view = new VelocityView("Your Password Has Been Changed","password_changed.vm");
|
||||
dynamo.scriptOutput(view);
|
||||
67
venice-data/util/session_init.js
Normal file
67
venice-data/util/session_init.js
Normal file
@@ -0,0 +1,67 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.session);
|
||||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||
if (rhelp.isRequestType("_SESSION") && rhelp.isVerb("PUT"))
|
||||
{ // OK, this is a session-established event...
|
||||
if (rhelp.isSessionType("HTTP"))
|
||||
{ // Check to see if the user can automatically log in with a cookie.
|
||||
cctrl = cast.queryCookieControl(req);
|
||||
if (cctrl.isCookiePresent(venice_session.loginCookieName))
|
||||
{ // retrieve and parse the cookie value
|
||||
logged_in = false;
|
||||
arr = stringutils.split(cctrl.getCookie(venice_session.loginCookieName),":");
|
||||
s = arr[0] + "";
|
||||
if (s=="VQAT2")
|
||||
{ // get the user corresponding to the UID embedded in this object
|
||||
new_user = vlib.lookupUser(req,cast.toInteger(arr[1]));
|
||||
if (new_user!=null)
|
||||
{ // attempt to authenticate with the cookie value
|
||||
if (new_user.authenticate(VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"cookie",arr[2],arr[3]))
|
||||
{ // this is the real user we're logged in as - set it into the session
|
||||
session = rhelp.getSession();
|
||||
session.setObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_USER,new_user);
|
||||
session.setObject(SessionInfoParams.NAMESPACE,SessionInfoParams.ATTR_COOKIE_AUTH_SOURCE,arr[2]);
|
||||
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"login.ok");
|
||||
new_user.setLastAccessDate(new_user,new java.util.Date());
|
||||
logged_in = true;
|
||||
|
||||
} // end if
|
||||
// else authentication failed - just dump out
|
||||
|
||||
} // end if
|
||||
// else we don't know this UID - bail out
|
||||
|
||||
} // end if
|
||||
// else our cookie format does not match - bail out
|
||||
|
||||
if (!logged_in) // if we failed to log in with this cookie, delete it
|
||||
cctrl.deleteCookie(venice_session.loginCookieName);
|
||||
|
||||
} // end if
|
||||
|
||||
// Now set up the established user (either the one that just logged in or Anonymous_Honyak).
|
||||
dynamo.exec("/util/setup_user.js");
|
||||
|
||||
} // end if (session is HTTP)
|
||||
|
||||
} // end if (session-PUT event)
|
||||
45
venice-data/util/setup_user.js
Normal file
45
venice-data/util/setup_user.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (the "License"); you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
importPackage(Packages.com.silverwrist.venice.session);
|
||||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||
session = rhelp.getSession(); // get session object
|
||||
user = vlib.getUser(session); // get user object
|
||||
|
||||
// Create the date formatter object.
|
||||
df = null;
|
||||
try
|
||||
{ // create the user date formatter bottom half
|
||||
df = new UserDateFormatterBottomHalf(req,user);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // create a default one if the user one throws any exceptions
|
||||
df = new DefaultDateFormatterBottomHalf(req);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Set the date formatter object into the session.
|
||||
session.setObject(DateFormatterTopHalf.NAMESPACE,DateFormatterTopHalf.PROPERTY,df);
|
||||
|
||||
// clear any password-recovery authentication data for this user
|
||||
user.clearAuthenticationData(user,VeniceNamespaces.SESSION_CONTROL_NAMESPACE,"password.recovery");
|
||||
Reference in New Issue
Block a user