Merge of the NewUI changes into the trunk
This commit is contained in:
59
scripts/sysadmin/audit.js
Normal file
59
scripts/sysadmin/audit.js
Normal file
@@ -0,0 +1,59 @@
|
||||
// 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(java.util);
|
||||
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
|
||||
rinput = bsf.lookupBean("request");
|
||||
|
||||
rc = null;
|
||||
try
|
||||
{ // get the admin interface
|
||||
adm = rinput.user.adminInterface;
|
||||
|
||||
// read off the offset parameter
|
||||
offset = rinput.getParameterInt("ofs",0);
|
||||
|
||||
// generate the audit lists
|
||||
audit_list = adm.getAuditRecords(offset,rinput.engine.getNumAuditRecordsPerPage());
|
||||
audit_count = adm.getAuditRecordCount();
|
||||
|
||||
// output the audit data view
|
||||
rc = new AuditView(rinput.engine,audit_list,offset,audit_count,"System Audit Records",
|
||||
"sysadmin/audit.js.vs?ofs=${offset}","sysadmin/menu.js.vs",
|
||||
"Return to System Administration Menu");
|
||||
rc.menuSelector = Content.MENU_SELECTOR_NOCHANGE;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // display an error
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error getting audit records: " + e.message,
|
||||
"sysadmin/menu.js.vs");
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"sysadmin/menu.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
96
scripts/sysadmin/find_user.js
Normal file
96
scripts/sysadmin/find_user.js
Normal file
@@ -0,0 +1,96 @@
|
||||
// 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);
|
||||
|
||||
rinput = bsf.lookupBean("request");
|
||||
|
||||
if (!(rinput.user.hasAdminAccess()))
|
||||
{ // no admin access - we can't do this
|
||||
vlib.output(new ErrorBox("Access Error","You do not have permission to administer the system.",null));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// Create the new view.
|
||||
view = new AdminFindUserView(rinput.engine.getStdNumSearchResults());
|
||||
|
||||
if ("GET"==rinput.verb)
|
||||
{ // initialize the field, mode, and term and do the search
|
||||
view.field = SearchMode.FIELD_USER_NAME;
|
||||
view.mode = SearchMode.SEARCH_PREFIX;
|
||||
view.term = "";
|
||||
vlib.output(view);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// everything here on is for a POST
|
||||
rc = null;
|
||||
try
|
||||
{ // load the search field parameter
|
||||
x = rinput.getParameterInt("field",SearchMode.FIELD_USER_NAME);
|
||||
if ( (x!=SearchMode.FIELD_USER_NAME) && (x!=SearchMode.FIELD_USER_DESCRIPTION)
|
||||
&& (x!=SearchMode.FIELD_USER_GIVEN_NAME) && (x!=SearchMode.FIELD_USER_FAMILY_NAME))
|
||||
throw new ValidationException("The search field parameter is not valid.");
|
||||
view.field = x;
|
||||
|
||||
// load the search mode parameter
|
||||
x = rinput.getParameterInt("mode",SearchMode.SEARCH_PREFIX);
|
||||
if ((x!=SearchMode.SEARCH_PREFIX) && (x!=SearchMode.SEARCH_SUBSTRING) && (x!=SearchMode.SEARCH_REGEXP))
|
||||
throw new ValidationException("The search mode parameter is not valid.");
|
||||
view.mode = x;
|
||||
|
||||
// load the search term, offset, and find count
|
||||
view.term = rinput.getParameter("term");
|
||||
view.offset = rinput.getParameterInt("ofs",0);
|
||||
view.findCount = rinput.getParameterInt("fcount",-1);
|
||||
|
||||
// adjust the offset based on the command button click
|
||||
if (rinput.isImageButtonClicked("search"))
|
||||
view.offset = 0;
|
||||
else if (rinput.isImageButtonClicked("previous"))
|
||||
view.offset = Math.max(view_offset - view.maxResults,0);
|
||||
else if (rinput.isImageButtonClicked("next"))
|
||||
view.offset += view.maxResults;
|
||||
else
|
||||
throw new ValidationException("Unable to determine what action triggered the form.");
|
||||
|
||||
// get the user results
|
||||
view.results = rinput.engine.searchForUsers(view.field,view.mode,view.term,view.offset,view.maxResults);
|
||||
if (view.findCount<0)
|
||||
view.findCount = rinput.engine.getSearchUserCount(view.field,view.mode,view.term);
|
||||
|
||||
rc = view;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // get the exception type
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error on find: " + e.message,"sysadmin/find_user.js.vs");
|
||||
else if (etype.match("ValidationException"))
|
||||
rc = new ErrorBox("Find Error",e.message,"sysadmin/find_user.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
137
scripts/sysadmin/global.js
Normal file
137
scripts/sysadmin/global.js
Normal file
@@ -0,0 +1,137 @@
|
||||
// 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(java.util);
|
||||
importPackage(Packages.com.silverwrist.venice.core);
|
||||
importPackage(Packages.com.silverwrist.venice.except);
|
||||
importPackage(Packages.com.silverwrist.venice.ui);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.dlg);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.helpers);
|
||||
|
||||
// small function to setup the global properties dialog
|
||||
function setupDialog(dlg,engine)
|
||||
{
|
||||
sinf = engine.securityInfo;
|
||||
dlg.sendMessage("create_lvl","setRoleList",sinf.getRoleList("Global.CreateCommunity"));
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
// get the request object
|
||||
rinput = bsf.lookupBean("request");
|
||||
|
||||
dlg = rinput.getDialog("global.properties");
|
||||
rc = null;
|
||||
if ("GET"==rinput.verb)
|
||||
{ // set up the dialog
|
||||
setupDialog(dlg,rinput.engine);
|
||||
|
||||
try
|
||||
{ // get the administrative interface
|
||||
adm = user.adminInterface;
|
||||
props = adm.properties;
|
||||
dlg.setValue("search_items",props.searchItemsPerPage);
|
||||
dlg.setValue("fp_posts",props.postsOnFrontPage);
|
||||
dlg.setValue("audit_recs",props.auditRecordsPerPage);
|
||||
dlg.setValue("create_lvl",props.communityCreateLevel);
|
||||
dlg.setValue("comm_mbrs",props.communityMembersPerPage);
|
||||
dlg.setValue("posts_page",props.postsPerPage);
|
||||
dlg.setValue("old_posts",props.oldPostsAtTop);
|
||||
dlg.setValue("conf_mbrs",props.conferenceMembersPerPage);
|
||||
if (props.displayPostPictures)
|
||||
dlg.setValue("pic_in_post",1);
|
||||
|
||||
rc = dlg;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception setting up dialog
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// everything that follows is for a POST operation
|
||||
op = dlg.whichButton(rinput) + "";
|
||||
if (op=="cancel")
|
||||
{ // user cancelled profile update - bounce back to the menu
|
||||
vlib.output(new Redirect("sysadmin/menu.js.vs",LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (op=="update")
|
||||
{ // load the values from the dialog
|
||||
dlg.load(rinput);
|
||||
|
||||
try
|
||||
{ // validate the dialog first
|
||||
dlg.validate();
|
||||
|
||||
// set all the properties correctly
|
||||
adm = user.adminInterface;
|
||||
props = adm.properties;
|
||||
props.searchItemsPerPage = dlg.getValue("search_items").intValue();
|
||||
props.postsOnFrontPage = dlg.getValue("fp_posts").intValue();
|
||||
props.auditRecordsPerPage = dlg.getValue("audit_recs").intValue();
|
||||
props.communityCreateLevel = dlg.getValue("create_lvl").intValue();
|
||||
props.communityMembersPerPage = dlg.getValue("comm_mbrs").intValue();
|
||||
props.postsPerPage = dlg.getValue("posts_page").intValue();
|
||||
props.oldPostsAtTop = dlg.getValue("old_posts").intValue();
|
||||
props.conferenceMembersPerPage = dlg.getValue("conf_mbrs").intValue();
|
||||
props.displayPostPictures = dlg.getValue("pic_in_post").booleanValue();
|
||||
adm.properties = props;
|
||||
|
||||
// done - bounce back to the menu
|
||||
rc = new Redirect("sysadmin/menu.js.vs",LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // caught an exception - figure out what to do
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ValidationException"))
|
||||
{ // validation error - reset the dialog and try again
|
||||
dlg.setErrorMessage(e.message + " Please try again.");
|
||||
setupDialog(dlg,rinput.engine);
|
||||
rc = dlg;
|
||||
|
||||
} // end if
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Unable to update global properties: " + e.message,
|
||||
"sysadmin/menu.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // what the hell got clicked?
|
||||
logger.error("no known button click on POST to sysadmin/global.js");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed","sysadmin/menu.js.vs");
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc);
|
||||
85
scripts/sysadmin/import.js
Normal file
85
scripts/sysadmin/import.js
Normal file
@@ -0,0 +1,85 @@
|
||||
// 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.util);
|
||||
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);
|
||||
|
||||
rinput = bsf.lookupBean("request");
|
||||
|
||||
if (!(rinput.user.hasAdminAccess()))
|
||||
{ // no admin access - we can't do this
|
||||
vlib.output(new ErrorBox("Access Error","You do not have permission to administer the system.",null));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if ("GET"==rinput.verb)
|
||||
{ // build a JSPView to hold the upload form
|
||||
vlib.output(new JSPView("Import User Accounts","sysadmin/import_form.jsp"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// the following assumes a POST
|
||||
if (rinput.isImageButtonClicked("cancel"))
|
||||
{ // redirect back to the admin menu
|
||||
vlib.output(new Redirect("sysadmin/menu.js.vs",LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (!(rinput.isImageButtonClicked("upload")))
|
||||
{ // the buttons must be wrong!
|
||||
logger.error("no known button click on POST, to sysadmin/import.js");
|
||||
vlib.output(new ErrorBox("Internal Error","Unknown command button pressed","sysadmin/menu.js.vs"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (!(rinput.isFileParam("idata")))
|
||||
{ // the idata parameter MUST be a file parameter!
|
||||
vlib.output(new ErrorBox("Internal Error","Invalid input file parameter.","sysadmin/menu.js.vs"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
rc = null;
|
||||
try
|
||||
{ // prepare and load the XML file
|
||||
ihelper = new ImportHelper(rinput.user.adminInterface,rinput.getParameterDataStream("idata"));
|
||||
|
||||
// set up the return value
|
||||
rinput.setRequestAttribute("import.helper",ihelper);
|
||||
rc = new JSPView("Import User Accounts","sysadmin/import_results.jsp");
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // translate the various exception types here
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ServletMultipartException"))
|
||||
rc = new ErrorBox("Internal Error","Error loading post data: " + e.message,"sysadmin/menu.js.vs");
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc); // all done!
|
||||
37
scripts/sysadmin/menu.js
Normal file
37
scripts/sysadmin/menu.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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(java.util);
|
||||
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
|
||||
rinput = bsf.lookupBean("request");
|
||||
|
||||
if (!(rinput.user.hasAdminAccess()))
|
||||
{ // you don't have permission to administer the system
|
||||
vlib.output(new ErrorBox("Access Error","You do not have permission to administer the system.",null));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// build a view around it and return it
|
||||
rc = new MenuView(rinput.getMenu("system.admin"));
|
||||
rc.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
vlib.output(rc);
|
||||
148
scripts/sysadmin/modify_photo.js
Normal file
148
scripts/sysadmin/modify_photo.js
Normal file
@@ -0,0 +1,148 @@
|
||||
// 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):
|
||||
|
||||
importClass(java.awt.Dimension);
|
||||
importPackage(Packages.com.silverwrist.util);
|
||||
importPackage(Packages.com.silverwrist.util.image);
|
||||
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.
|
||||
rinput = bsf.lookupBean("request");
|
||||
|
||||
if (!(rinput.user.hasAdminAccess()))
|
||||
{ // no admin access - we can't do this
|
||||
vlib.output(new ErrorBox("Access Error","You do not have permission to administer the system.",null));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
uid = rinput.getParameterInt("uid",0);
|
||||
if (uid==0)
|
||||
{ // user ID not found
|
||||
vlib.output(new ErrorBox(null,"User ID parameter not found.","sysadmin/find_user.js.vs"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
rc = null;
|
||||
if ("GET"==rinput.verb)
|
||||
{ // create a PhotoUploader to do the photo uploading
|
||||
try
|
||||
{ // create and initialize the PhotoUploader
|
||||
adm = rinput.user.adminInterface;
|
||||
admuser = adm.getUserContext(uid);
|
||||
rc = new PhotoUploader("Upload User Photo","sysadmin/modify_photo.js.vs",LinkTypes.SERVLET);
|
||||
rc.addHiddenParameter("uid",uid);
|
||||
rc.photoTag = rinput.getUserPhotoTag(admuser.getContactInfo().photoURL);
|
||||
rc.label = "New user photo";
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // an exception in the output...
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error generating display: " + e.message,
|
||||
"sysadmin/find_user.js.vs");
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox(null,"User ID parameter not found.","sysadmin/find_user.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// If the cancel button was clicked, bounce out of here.
|
||||
if (rinput.isImageButtonClicked("cancel"))
|
||||
{ // user elected to cancel upload - bounce us out of here
|
||||
vlib.output(new Redirect("sysadmin/modify_user.js.vs?uid=" + uid,LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (rinput.isImageButtonClicked("upload"))
|
||||
{ // do some shorts-checking in the parameters
|
||||
if (!(rinput.isFileParam("thepic")))
|
||||
{ // bogus file parameter
|
||||
logger.error("Internal Error: 'thepic' should be a file param");
|
||||
vlib.output(new ErrorBox(null,"Internal Error: 'thepic' should be a file param",
|
||||
"sysadmin/modify_user.js.vs?uid=" + uid));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
mimetype = rinput.getParameterType("thepic") + "";
|
||||
if (!(mimetype.match("image/")))
|
||||
{ // not an image file type that got uploaded
|
||||
logger.error("Error: 'thepic' not an image type");
|
||||
vlib.output(new ErrorBox(null,"You did not upload an image file. Try again.",
|
||||
"sysadmin/modify_photo.js.vs?uid=" + uid));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // normalize the photo to 100x100 pixels
|
||||
real_pic = ImageNormalizer.normalizeImage(rinput.getParameterDataStream("thepic"),
|
||||
rinput.engine.getUserPhotoSize(),"jpeg");
|
||||
|
||||
// set the user photo data!
|
||||
adm = rinput.user.adminInterface;
|
||||
admuser = adm.getUserContext(uid);
|
||||
ci = admuser.getContactInfo();
|
||||
ci.setPhotoData(rinput.contextPath + "/imagedata/","image/jpeg",real_pic.length,real_pic.data);
|
||||
admuser.putContactInfo(ci);
|
||||
|
||||
// Jump back to the profile form.
|
||||
rc = new Redirect("sysadmin/modify_user.js.vs?uid=" + uid,LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception while setting user photo
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ServletMultipartException"))
|
||||
rc = new ErrorBox(null,"Internal Error: " + e.message,"sysadmin/modify_user.js.vs?uid=" + uid);
|
||||
else if (etype.match("ImageNormalizerException"))
|
||||
rc = new ErrorBox(null,e.message,"sysadmin/modify_photo.js.vs?uid=" + uid);
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error storing user photo: " + e.message,
|
||||
"sysadmin/modify_user.js.vs?uid=" + uid);
|
||||
else if (etype.match("EmailException"))
|
||||
rc = new ErrorBox(null,"Internal Error: " + e.message,"sysadmin/modify_user.js.vs?uid=" + uid);
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // don't know the command button!
|
||||
logger.error("no known button click on POST to sysadmin/modify_photo.js");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed",
|
||||
"sysadmin/modify_user.js.vs?uid=" + uid);
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc); // all done!
|
||||
283
scripts/sysadmin/modify_user.js
Normal file
283
scripts/sysadmin/modify_user.js
Normal file
@@ -0,0 +1,283 @@
|
||||
// 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(java.util);
|
||||
importPackage(Packages.com.silverwrist.venice.core);
|
||||
importPackage(Packages.com.silverwrist.venice.except);
|
||||
importPackage(Packages.com.silverwrist.venice.ui);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.dlg);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.helpers);
|
||||
|
||||
function setupDialog(dlg,adm,user)
|
||||
{
|
||||
dlg.setSubtitle("User: " + user.userName);
|
||||
var role_list = adm.getAllowedRoleList();
|
||||
dlg.sendMessage("base_lvl","setRoleList",role_list);
|
||||
|
||||
// See if this level was found on the list.
|
||||
var my_role = user.baseRole;
|
||||
var found = false;
|
||||
var it = role_list.iterator();
|
||||
while (it.hasNext())
|
||||
{ // seek each role in turn
|
||||
var r = it.next();
|
||||
if (r.equals(my_role))
|
||||
{ // found it!
|
||||
found = true;
|
||||
break;
|
||||
|
||||
} // end if
|
||||
|
||||
} // end while
|
||||
|
||||
if (!found) // role not found - set the defined role list to be a singleton
|
||||
dlg.sendMessage("base_lvl","setRoleList",Collections.singletonList(my_role));
|
||||
dlg.sendMessage("photo","setLinkURL","sysadmin/modify_photo.js.vs?uid=" + admuser.UID);
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
rinput = bsf.lookupBean("request");
|
||||
|
||||
if (!(rinput.user.hasAdminAccess()))
|
||||
{ // no admin access - we can't do this
|
||||
vlib.output(new ErrorBox("Access Error","You do not have permission to administer the system.",null));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
dlg = rinput.getDialog("admin.modify.user");
|
||||
|
||||
rc = null;
|
||||
if ("GET"==rinput.verb)
|
||||
{ // set up the dialog
|
||||
uid = rinput.getParameterInt("uid",0);
|
||||
if (uid==0)
|
||||
{ // user ID not found
|
||||
vlib.output(new ErrorBox(null,"User ID parameter not found.","sysadmin/find_user.js.vs"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // load the user's data and populate the dialog box
|
||||
adm = rinput.user.adminInterface;
|
||||
admuser = adm.getUserContext(uid);
|
||||
setupDialog(dlg,adm,admuser); // set up the dialog box
|
||||
dlg.setValue("uid",admuser.UID);
|
||||
|
||||
dlg.setValue("base_lvl",admuser.baseLevel);
|
||||
if (admuser.isEmailVerified())
|
||||
dlg.setValue("verify_email",1);
|
||||
if (admuser.isLockedOut())
|
||||
dlg.setValue("lockout",1);
|
||||
|
||||
ci = admuser.getContactInfo(); // get the main contact info
|
||||
props = admuser.properties;
|
||||
|
||||
if (props.disallowPhoto)
|
||||
dlg.setValue("nophoto",1);
|
||||
dlg.setValue("prefix",ci.namePrefix);
|
||||
dlg.setValue("first",ci.givenName);
|
||||
if (ci.middleInitial!=' ')
|
||||
dlg.setValue("mid",String.fromCharCode(ci.middleInitial));
|
||||
dlg.setValue("last",ci.familyName);
|
||||
dlg.setValue("suffix",ci.nameSuffix);
|
||||
dlg.setValue("company",ci.company);
|
||||
dlg.setValue("addr1",ci.addressLine1);
|
||||
dlg.setValue("addr2",ci.addressLine2);
|
||||
if (ci.privateAddress)
|
||||
dlg.setValue("pvt_addr",1);
|
||||
dlg.setValue("loc",ci.locality);
|
||||
dlg.setValue("reg",ci.region);
|
||||
dlg.setValue("pcode",ci.postalCode);
|
||||
dlg.setValue("country",ci.country);
|
||||
dlg.setValue("phone",ci.phone);
|
||||
dlg.setValue("mobile",ci.mobile);
|
||||
if (ci.privatePhone)
|
||||
dlg.setValue("pvt_phone",1);
|
||||
dlg.setValue("fax",ci.fax);
|
||||
if (ci.privateFax)
|
||||
dlg.setValue("pvt_fax",1);
|
||||
dlg.setValue("email",ci.email);
|
||||
if (ci.privateEmail)
|
||||
dlg.setValue("pvt_email",1);
|
||||
dlg.setValue("url",ci.URL);
|
||||
dlg.setValue("descr",admuser.description);
|
||||
dlg.setValue("photo",ci.photoURL);
|
||||
if (props.displayPostPictures)
|
||||
dlg.setValue("pic_in_post",1);
|
||||
if (props.massMailOptOut)
|
||||
dlg.setValue("no_mass_mail",1);
|
||||
dlg.setValue("locale",admuser.locale);
|
||||
dlg.setValue("tz",admuser.timeZone);
|
||||
|
||||
rc = dlg;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception initializing dialog
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Unable to retrieve user information: " + e.message,
|
||||
"sysadmin/find_user.js.vs");
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// everything that follows is for a POST operation
|
||||
op = dlg.whichButton(rinput) + "";
|
||||
if (op=="cancel")
|
||||
{ // user cancelled profile update - bounce back to the target
|
||||
vlib.output(new Redirect("sysadmin/find_user.js.vs",LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
dlg.load(rinput); // load the dialog parameters
|
||||
|
||||
if (op=="update")
|
||||
{ // we're updating the user
|
||||
try
|
||||
{ // get the admin interface and the user information
|
||||
uid = parseInt(dlg.getValue("uid"),10);
|
||||
adm = rinput.user.adminInterface;
|
||||
admuser = adm.getUserContext(uid);
|
||||
|
||||
try
|
||||
{ // validate the dialog
|
||||
dlg.validate();
|
||||
|
||||
// check the passwords
|
||||
pass1 = dlg.getValue("pass1") + "";
|
||||
pass2 = dlg.getValue("pass2") + "";
|
||||
|
||||
if (vlib.emptyString(pass1))
|
||||
{ // empty must match empty
|
||||
if (!(vlib.emptyString(pass2)))
|
||||
throw new ValidationException("The typed passwords do not match.");
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // the two passwords must match
|
||||
if (pass1!=pass2)
|
||||
throw new ValidationException("The typed passwords do not match.");
|
||||
|
||||
} // end else
|
||||
|
||||
// reset the base level
|
||||
admuser.baseLevel = dlg.getValue("base_lvl").intValue();
|
||||
|
||||
// Change the password if applicable.
|
||||
if (!(vlib.emptyString(pass1)))
|
||||
admuser.setPassword(pass1,dlg.getValue("remind"));
|
||||
|
||||
admuser.setEmailVerified(dlg.getValue("verify_email").booleanValue());
|
||||
admuser.setLockedOut(dlg.getValue("lockout").booleanValue());
|
||||
|
||||
ci = admuser.getContactInfo(); // get the main contact info
|
||||
props = admuser.properties;
|
||||
|
||||
// Reset all the contact info fields.
|
||||
props.disallowPhoto = dlg.getValue("nophoto").booleanValue();
|
||||
ci.namePrefix = dlg.getValue("prefix");
|
||||
ci.givenName = dlg.getValue("first");
|
||||
blort = dlg.getValue("mid") + "";
|
||||
if (blort.length<1)
|
||||
ci.middleInitial = " ";
|
||||
else
|
||||
ci.middleInitial = blort.substring(0,1);
|
||||
ci.familyName = dlg.getValue("last");
|
||||
ci.nameSuffix = dlg.getValue("suffix");
|
||||
ci.company = dlg.getValue("company");
|
||||
ci.addressLine1 = dlg.getValue("addr1");
|
||||
ci.addressLine2 = dlg.getValue("addr2");
|
||||
ci.privateAddress = dlg.getValue("pvt_addr").booleanValue();
|
||||
ci.locality = dlg.getValue("loc");
|
||||
ci.region = dlg.getValue("reg");
|
||||
ci.postalCode = dlg.getValue("pcode");
|
||||
ci.country = dlg.getValue("country");
|
||||
ci.phone = dlg.getValue("phone");
|
||||
ci.mobile = dlg.getValue("mobile");
|
||||
ci.privatePhone = dlg.getValue("pvt_phone").booleanValue();
|
||||
ci.fax = dlg.getValue("fax");
|
||||
ci.privateFax = dlg.getValue("pvt_fax").booleanValue();
|
||||
ci.email = dlg.getValue("email");
|
||||
ci.privateEmail = dlg.getValue("pvt_email").booleanValue();
|
||||
ci.URL = dlg.getValue("url");
|
||||
props.displayPostPictures = dlg.getValue("pic_in_post").booleanValue();
|
||||
props.massMailOptOut = dlg.getValue("no_mass_mail").booleanValue();
|
||||
|
||||
// Store the completed contact info.
|
||||
admuser.putContactInfo(ci);
|
||||
admuser.properties = props;
|
||||
|
||||
// Save off the user's description and preferences.
|
||||
admuser.description = dlg.getValue("descr");
|
||||
admuser.locale = dlg.getValue("locale");
|
||||
admuser.timeZone = dlg.getValue("tz");
|
||||
|
||||
// redirect back to the Find User page
|
||||
rc = new Redirect("sysadmin/find_user.js.vs",LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // catch ValidationExceptions here and redisplay the dialog
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ValidationException"))
|
||||
{ // on a ValidationException, redisplay the dialog and try again
|
||||
dlg.setErrorMessage(e.message + " Please try again.");
|
||||
setupDialog(dlg,adm,admuser); // set up the dialog box
|
||||
dlg.setValue("pass1",null);
|
||||
dlg.setValue("pass2",null);
|
||||
rc = dlg;
|
||||
|
||||
} // end if
|
||||
else // propagate other types of exceptions
|
||||
throw e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // this is used to catch the hard exceptions
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","You do not have permission to administer the system.",null);
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Unable to retrieve user information: " + e.message,
|
||||
"sysadmin/find_user.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // bogus button indicated
|
||||
logger.error("no known button click on POST to sysadmin/modify_user.js");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed","sysadmin/find_user.js.vs");
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc); // all done!
|
||||
Reference in New Issue
Block a user