venice-main-classic/scripts/showuser.js

108 lines
3.4 KiB
JavaScript
Raw Normal View History

// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(Packages.com.silverwrist.venice.core);
importPackage(Packages.com.silverwrist.venice.except);
importPackage(Packages.com.silverwrist.venice.ui);
importPackage(Packages.com.silverwrist.venice.ui.helpers);
importPackage(Packages.com.silverwrist.venice.ui.view);
// get the request object and the username
rinput = bsf.lookupBean("request");
username = rinput.getRequestAttribute("username");
rc = null;
try
{ // retrieve the user profile and save it off
prof = rinput.user.getProfile(username);
rinput.setRequestAttribute("profile",prof);
// determine the full name of the user and save it off
buf = new java.lang.StringBuffer(prof.givenName);
if (!(vlib.emptyString(prof.namePrefix)))
{ // insert the prefix at the beginning of the string
buf.insert(0," ");
buf.insert(0,prof.namePrefix);
} // end if
tmp = String.fromCharCode(prof.middleInitial);
if (tmp!=" ")
{ // append the middle initial
buf.append(" ");
buf.append(tmp);
buf.append(".");
} // end if
buf.append(" ");
buf.append(prof.familyName);
if (!(vlib.emptyString(prof.nameSuffix)))
{ // append the name suffix
buf.append(" ");
buf.append(prof.nameSuffix);
} // end if
rinput.setRequestAttribute("fullname",buf.toString());
// determine the last line of the address and save it off
if (vlib.emptyString(prof.locality))
{ // allocate stringbuffer based on region
if (vlib.emptyString(prof.region))
buf = new java.lang.StringBuffer();
else
buf = new java.lang.StringBuffer(prof.region);
} // end if
else if (vlib.emptyString(prof.region))
buf = new java.lang.StringBuffer(prof.locality);
else
{ // tack together both locality and region
buf = new java.lang.StringBuffer(prof.locality);
buf.append(", ");
buf.append(prof.region);
} // end else
if (!(vlib.emptyString(prof.postalCode)))
{ // append the postal code
buf.append(" ");
buf.append(prof.postalCode);
} // end if
rinput.setRequestAttribute("address.lastline",buf.toString());
// Save off the user photo tag.
html = vlib.queryHTMLRendering(rinput);
rinput.setRequestAttribute("user.photo",html.getUserPhotoTag(prof.photoURL));
// Create a view object and send it out.
rc = new JSPView("User Profile - " + username,"user_profile.jsp");
} // end try
catch (e)
{ // handle an exception thrown by the profile code
etype = vlib.exceptionType(e) + "";
if (etype.match("DataException"))
rc = new ErrorBox("Database Error","Database error finding user: " + e.message,"top.js.vs");
else
rc = e;
} // end catch
vlib.output(rc); // all done!