Merge of the NewUI changes into the trunk
This commit is contained in:
46
scripts/comm/admin_menu.js
Normal file
46
scripts/comm/admin_menu.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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 and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canAdministerCommunity()))
|
||||
{ // no access - sorry buddy
|
||||
logger.error("tried to call up community admin menu without access...naughty naughty!");
|
||||
vlib.output(new ErrorBox("Access Error","You do not have access to administer this community.",
|
||||
"community/" + comm.alias));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// build the community admin menu
|
||||
vars = new HashMap();
|
||||
vars.put("cid",comm.communityID + "");
|
||||
vars.put("name",comm.name);
|
||||
menu = rinput.getMenu("community.admin",vars);
|
||||
|
||||
// build a view around it and return it
|
||||
rc = new MenuView(menu);
|
||||
rc.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
vlib.output(rc);
|
||||
59
scripts/comm/audit.js
Normal file
59
scripts/comm/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 and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
rc = null;
|
||||
try
|
||||
{ // read off the offset parameter
|
||||
offset = rinput.getParameterInt("ofs",0);
|
||||
|
||||
// generate the audit lists
|
||||
audit_list = comm.getAuditRecords(offset,rinput.engine.getNumAuditRecordsPerPage());
|
||||
audit_count = comm.getAuditRecordCount();
|
||||
|
||||
// output the audit data view
|
||||
rc = new AuditView(rinput.engine,audit_list,offset,audit_count,
|
||||
"Audit Records for Community \"" + comm.name + "\"",
|
||||
"comm/audit.js.vs?cc=" + comm.communityID + "&ofs=${offset}",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID,
|
||||
"Return to Community Administration Menu");
|
||||
rc.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
|
||||
} // 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,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
114
scripts/comm/category.js
Normal file
114
scripts/comm/category.js
Normal file
@@ -0,0 +1,114 @@
|
||||
// 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 community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canModifyProfile()))
|
||||
{ // no access - sorry, dude
|
||||
logger.error("tried to call up community profile screen without access...naughty naughty!");
|
||||
vlib.output(new ErrorBox("Unauthorized","You do not have access to modify this community's profile.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
rc = null;
|
||||
if (rinput.hasParameter("set"))
|
||||
{ // OK...they're actually setting the category here - change it and bail out
|
||||
catid = rinput.getParameterInt("set",-1);
|
||||
if (engine.isValidCategoryID(catid))
|
||||
{ // try setting the category ID
|
||||
try
|
||||
{ // set the category ID and bounce back to the menu
|
||||
comm.categoryID = catid;
|
||||
rc = new Redirect("comm/admin_menu.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception setting category
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error updating community: " + e.message,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else // invalid category ID
|
||||
rc = new ErrorBox("Invalid Input","Invalid category ID passed to category browser.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
|
||||
vlib.output(rc);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// we must be browsing - try and figure out what category we're supposed to be browsing
|
||||
curr_catid = 0;
|
||||
if (rinput.hasParameter("go"))
|
||||
curr_catid = rinput.getParameterInt("go",-1);
|
||||
else
|
||||
curr_catid = comm.categoryID;
|
||||
if (!(engine.isValidCategoryID(curr_catid)))
|
||||
{ // this is not a valid category ID
|
||||
vlib.output(new ErrorBox("Invalid Input","Invalid category ID passed to category browser.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // get the categories
|
||||
prev_cat = comm.category;
|
||||
rinput.setRequestAttribute("category.previous",prev_cat);
|
||||
curr_cat = null;
|
||||
if (prev_cat.categoryID!=curr_catid)
|
||||
curr_cat = rinput.user.getCategoryDescriptor(curr_catid);
|
||||
else
|
||||
curr_cat = prev_cat;
|
||||
rinput.setRequestAttribute("category.current",curr_cat);
|
||||
rinput.setRequestAttribute("category.subcats",curr_cat.getSubCategories());
|
||||
|
||||
// create a view and return it
|
||||
rc = new JSPView("Set Community Category","comm/category.jsp");
|
||||
rc.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // caught an exception here...
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error browsing categories: " + e.message,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
|
||||
124
scripts/comm/create.js
Normal file
124
scripts/comm/create.js
Normal file
@@ -0,0 +1,124 @@
|
||||
// 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.dlg);
|
||||
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.canCreateCommunity()))
|
||||
{ // can't create communities - bye!
|
||||
if (rinput.user.isLoggedIn())
|
||||
vlib.output(new ErrorBox("Community Error","You are not permitted to create communities.","top.js.vs"));
|
||||
else
|
||||
vlib.output(new LogInOrCreate());
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
dlg = rinput.getDialog("create.community");
|
||||
if ("GET"==rinput.verb)
|
||||
{ // just output the dialog
|
||||
dlg.setValue("language","en-US");
|
||||
dlg.setValue("country","US");
|
||||
vlib.output(dlg);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// everything following is for a POST
|
||||
op = dlg.whichButton(rinput) + "";
|
||||
if (op=="cancel")
|
||||
{ // user cancelled - bail out
|
||||
vlib.output(new Redirect("top.js.vs",LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
rc = null;
|
||||
if (op=="create")
|
||||
{ // actually creating a community
|
||||
dlg.load(rinput); // load the dialog values
|
||||
|
||||
try
|
||||
{ // start by validating the dialog
|
||||
dlg.validate();
|
||||
|
||||
// validate some extra stuff
|
||||
my_alias = dlg.getValue("alias");
|
||||
if (rinput.engine.aliasExists(my_alias,-1))
|
||||
throw new ValidationException("That alias is already used by another community on the system.");
|
||||
my_comtype = dlg.getValue("comtype") + "";
|
||||
my_joinkey = null;
|
||||
if (my_comtype=="1")
|
||||
{ // get the join key for this private community
|
||||
my_joinkey = dlg.getValue("joinkey");
|
||||
if (vlib.emptyString(my_joinkey))
|
||||
throw new ValidationException("Private communities must specify a join key value.");
|
||||
|
||||
} // end if
|
||||
|
||||
my_hidemode = parseInt(dlg.getValue("hidemode"),10); // get the hide mode
|
||||
|
||||
// Create the new community context.
|
||||
new_comm = rinput.user.createCommunity(dlg.getValue("name"),my_alias,dlg.getValue("language"),
|
||||
dlg.getValue("synopsis"),dlg.getValue("rules"),my_joinkey,
|
||||
my_hidemode);
|
||||
|
||||
// Get the new community's contact record and fill in the pieces of info we know.
|
||||
ci = new_comm.getContactInfo();
|
||||
ci.locality = dlg.getValue("loc");
|
||||
ci.region = dlg.getValue("reg");
|
||||
ci.postalCode = dlg.getValue("pcode");
|
||||
ci.country = dlg.getValue("country");
|
||||
new_comm.putContactInfo(ci);
|
||||
|
||||
// create the return view
|
||||
rinput.setRequestAttribute("new.community",new_comm);
|
||||
rc = new JSPView("New Community Created","comm/new.jsp");
|
||||
rc.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception creating the community
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ValidationException") || etype.match("AccessError"))
|
||||
{ // reset the dialog and let them try again
|
||||
dlg.setErrorMessage(e.message + " Please try again.");
|
||||
rc = dlg;
|
||||
|
||||
} // end if
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error creating community: " + e.message,"top.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // don't know what button was pressed
|
||||
logger.error("no known button click on POST to comm/create.js.vs");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed","top.js.vs");
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc); // all done!
|
||||
74
scripts/comm/delete.js
Normal file
74
scripts/comm/delete.js
Normal file
@@ -0,0 +1,74 @@
|
||||
// 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);
|
||||
|
||||
// get the request object and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canDelete()))
|
||||
{ // we can't delete the community, so what are we doing here?
|
||||
logger.error("you can't delete the community - not gonna do it, wouldn't be prudent");
|
||||
vlib.output(new ErrorBox("Access Error","You do not have permission to delete this community.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
CONFIRM_attr = "community.delete.confirm";
|
||||
CONFIRM_param = "confirm";
|
||||
|
||||
rc = null;
|
||||
|
||||
if (ConfirmBox.isConfirmed(rinput,CONFIRM_attr,CONFIRM_param))
|
||||
{ // we are confirmed - delete the community!
|
||||
try
|
||||
{ // delete the community
|
||||
comm.deleteCommunity();
|
||||
|
||||
// the community is now GONE - go back to the top
|
||||
rc = new Redirect("top.js.vs",LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // caught an exception while unjoining
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error deleting community: " + e.message,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // need to get confirmation
|
||||
message = "You are about to permanently delete the \"" + comm.name + "\" community, including all "
|
||||
+ "conferences and other resources it contains! Are you sure you want to do this?";
|
||||
rc = new ConfirmBox(rinput,CONFIRM_attr,CONFIRM_param,"Delete Community",message,
|
||||
"comm/delete.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET);
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc);
|
||||
86
scripts/comm/email.js
Normal file
86
scripts/comm/email.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// 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 and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canMassMail()))
|
||||
{ // we can't send mass mail to the community, so what are we doing here?
|
||||
logger.error("you can't mass-mail the community - not gonna do it, wouldn't be prudent");
|
||||
vlib.output(new ErrorBox("Access Error","You do not have permission to sent mass mail to this community.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if ("GET"==rinput.verb)
|
||||
{ // display the view
|
||||
view = new JSPView("Community E-Mail: " + comm.name,"comm/email.jsp");
|
||||
view.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
vlib.output(view);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (rinput.isImageButtonClicked("cancel"))
|
||||
{ // user cancelled - go back to the menu
|
||||
vlib.output(new Redirect("comm/admin_menu.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
rc = null;
|
||||
if (rinput.isImageButtonClicked("send"))
|
||||
{ // actually send the E-mail!
|
||||
try
|
||||
{ // do it!
|
||||
comm.massMail(rinput.getParameter("subj"),rinput.getParameter("pb"));
|
||||
|
||||
// now bounce back to the menu
|
||||
rc = new Redirect("comm/admin_menu.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception caught in the mass mailing
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error getting mailing list: " + e.message,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end try
|
||||
else
|
||||
{ // what the hell was that button
|
||||
logger.error("no known button click on POST to comm/email.js");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc);
|
||||
93
scripts/comm/invite.js
Normal file
93
scripts/comm/invite.js
Normal file
@@ -0,0 +1,93 @@
|
||||
// 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 and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canSendInvitation()))
|
||||
{ // you can't send an invitation
|
||||
vlib.output(new ErrorBox("Community Error","You are not permitted to send an invitation.",
|
||||
"community/" + comm.alias));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
locator = "cc=" + comm.communityID;
|
||||
if ("GET"==rinput.verb)
|
||||
{ // set up the invitation screen parameters
|
||||
rinput.setRequestAttribute("invitation.title","Send Community Invitation:");
|
||||
rinput.setRequestAttribute("invitation.subtitle",comm.name);
|
||||
rinput.setRequestAttribute("invitation.action",rinput.formatURL("comm/invite.js.vs",LinkTypes.SERVLET));
|
||||
rinput.setRequestAttribute("invitation.params",
|
||||
"<INPUT TYPE=\"HIDDEN\" NAME=\"cc\" VALUE=\"" + comm.communityID + "\">");
|
||||
|
||||
// create the invitation and display it
|
||||
view = new JSPView("Send Invitation","comm/invite.jsp");
|
||||
view.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
view.pageQID = "comm/invite.js.vs?" + locator;
|
||||
vlib.output(view);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (rinput.isImageButtonClicked("cancel"))
|
||||
{ // bounce back to the base page
|
||||
vlib.output(new Redirect("comm/show.js.vs?" + locator,LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
rc = null;
|
||||
if (rinput.isImageButtonClicked("send"))
|
||||
{ // do the actual send!
|
||||
try
|
||||
{ // send out the invitation and then redirect back
|
||||
comm.sendInvitation(rinput.getParameter("addr"),rinput.getParameter("pb"));
|
||||
rc = new Redirect("comm/show.js.vs?" + locator,LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception sending the invitation
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/show.js.vs?" + locator);
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error sending invitation: " + e.message,
|
||||
"comm/show.js.vs?" + locator);
|
||||
else if (etype.match("EmailException"))
|
||||
rc = new ErrorBox("E-Mail Error","Error sending E-mail: " + e.message,"comm/show.js.vs?" + locator);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // no known button pressed
|
||||
logger.error("no known button click on POST to comm/invite.js");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed","comm/show.js.vs?" + locator);
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc);
|
||||
70
scripts/comm/join.js
Normal file
70
scripts/comm/join.js
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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.dlg);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.helpers);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.view);
|
||||
|
||||
// get the request object and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canJoin()))
|
||||
{ // you can't join the community
|
||||
vlib.output(new ErrorBox("Community Error","You are not permitted to join this community.","top.js.vs"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (comm.isPublicCommunity())
|
||||
{ // the community is public - attempt to join right away
|
||||
rc = null;
|
||||
try
|
||||
{ // join the community!
|
||||
comm.join(null);
|
||||
|
||||
// force the menus to be redrawn
|
||||
rinput.setSessionAttribute(RequestInput.LEFT_MENU_SESSION_ATTR,null);
|
||||
|
||||
// create a return view
|
||||
rc = new JSPView("Welcome to " + comm.name,"comm/welcome.jsp");
|
||||
rc.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception when we tried to join the community
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","Unable to join community: " + e.message,"top.js.vs");
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error joining community: " + e.message,"top.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// Get the "join key" dialog.
|
||||
dlg = rinput.getDialog("join");
|
||||
dlg.setValue("cc",comm.communityID + "");
|
||||
vlib.output(dlg);
|
||||
98
scripts/comm/join_key.js
Normal file
98
scripts/comm/join_key.js
Normal file
@@ -0,0 +1,98 @@
|
||||
// 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.dlg);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.helpers);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.view);
|
||||
|
||||
// get the request object and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canJoin()))
|
||||
{ // you can't join the community
|
||||
vlib.output(new ErrorBox("Community Error","You are not permitted to join this community.","top.js.vs"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (comm.isPublicCommunity())
|
||||
{ // we shouldn't have gotten here!
|
||||
vlib.output(new ErrorBox("Internal Error","This community should already have been joined.",
|
||||
"comm/show.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// Get the "join key" dialog.
|
||||
dlg = rinput.getDialog("join");
|
||||
op = dlg.whichButton(rinput) + "";
|
||||
|
||||
if (op=="cancel")
|
||||
{ // cancel the join and bounce back to the profile
|
||||
vlib.output(new Redirect("comm/show.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
rc = null;
|
||||
if (op=="join_now")
|
||||
{ // go ahead and join up, if we can
|
||||
dlg.load(rinput);
|
||||
|
||||
try
|
||||
{ // get the join key
|
||||
key = dlg.getValue("key");
|
||||
if (vlib.emptyString("key"))
|
||||
throw new ValidationException("No join key specified.");
|
||||
|
||||
comm.join(key); // join the community!
|
||||
|
||||
// force the menus to be redrawn
|
||||
rinput.setSessionAttribute(RequestInput.LEFT_MENU_SESSION_ATTR,null);
|
||||
|
||||
// create a return view
|
||||
rc = new JSPView("Welcome to " + comm.name,"comm/welcome.jsp");
|
||||
rc.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception when we tried to join the community
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ValidationException") || etype.match("AccessError"))
|
||||
{ // reset the dialog and try again
|
||||
dlg.setErrorMessage(e.message + " Please try again.");
|
||||
dlg.setValue("key",null);
|
||||
rc = dlg;
|
||||
|
||||
} // end if
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error joining community: " + e.message,"top.js.vs");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // we don't know what button was clicked
|
||||
logger.error("no known button click on POST to comm.join_key.js");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed","top.js.vs");
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc);
|
||||
133
scripts/comm/members.js
Normal file
133
scripts/comm/members.js
Normal file
@@ -0,0 +1,133 @@
|
||||
// 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 and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
// create the view object
|
||||
view = new MembersView(rinput.engine.getStdNumSearchResults(),comm.name);
|
||||
rc = null;
|
||||
try
|
||||
{ // set up the member list
|
||||
if ("GET"==rinput.verb)
|
||||
{ // initial GET of the member list - just get the start of the list
|
||||
mbr_list = comm.getMemberList();
|
||||
view.simple = true;
|
||||
view.results = mbr_list;
|
||||
view.findCount = mbr_list.size();
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // this is a more complicated operation...
|
||||
if ("1"==rinput.getParameter("sl"))
|
||||
{ // Set up some of the easy initial parameters.
|
||||
view.simple = true;
|
||||
|
||||
// Retrieve the offset and find count.
|
||||
view.offset = rinput.getParameterInt("ofs",0);
|
||||
view.findCount = rinput.getParameterInt("fcount",-1);
|
||||
|
||||
// Adjust the offset based on the button clicked.
|
||||
if (rinput.isImageButtonClicked("search"))
|
||||
throw new ValidationException("Invalid button clicked."); // can't happen
|
||||
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 list and subset it if necessary.
|
||||
mbr_list = comm.getMemberList();
|
||||
if (view.findCount<0)
|
||||
view.findCount = mbr_list.size();
|
||||
if (view.offset==0)
|
||||
view.results = mbr_list;
|
||||
else
|
||||
view.results = mbr_list.subList(offset,mbr_list.size());
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // This is a search operation...
|
||||
view.simple = false;
|
||||
|
||||
// Get 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;
|
||||
|
||||
// Get 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;
|
||||
|
||||
// Get the search term parameter.
|
||||
view.term = rinput.getParameter("term");
|
||||
if (view.term==null)
|
||||
view.term = "";
|
||||
|
||||
// Retrieve the offset and find count.
|
||||
view.offset = rinput.getParameterInt("ofs",0);
|
||||
view.findCount = rinput.getParameterInt("fcount",-1);
|
||||
|
||||
// Adjust the offset based on the button clicked.
|
||||
if (rinput.isImageButtonClicked("search"))
|
||||
view.offset = 0; // begin a new search
|
||||
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.");
|
||||
|
||||
// Perform the search!
|
||||
view.results = comm.searchForMembers(view.field,view.mode,view.term,view.offset,view.maxResults);
|
||||
if (view.findCount<0)
|
||||
view.findCount = comm.getSearchMemberCount(view.field,view.mode,view.term);
|
||||
|
||||
} // end else (search operation)
|
||||
|
||||
} // end else (POST)
|
||||
|
||||
rc = view;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception in the find operation
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ValidationException"))
|
||||
rc = new ErrorBox("Find Error",e.message,"comm/members.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error getting member list: " + e.message,
|
||||
"community/" + comm.alias);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
136
scripts/comm/photo.js
Normal file
136
scripts/comm/photo.js
Normal file
@@ -0,0 +1,136 @@
|
||||
// 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 and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canModifyProfile()))
|
||||
{ // no access - sorry, dude
|
||||
logger.error("tried to call up community profile screen without access...naughty naughty!");
|
||||
vlib.output(new ErrorBox("Unauthorized","You do not have access to modify this community's profile.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
rc = null;
|
||||
if ("GET"==rinput.verb)
|
||||
{ // create a PhotoUploader to do the photo uploading
|
||||
try
|
||||
{ // create and initialize the PhotoUploader
|
||||
rc = new PhotoUploader("Upload Community Logo","comm/photo.js.vs",LinkTypes.SERVLET);
|
||||
rc.addHiddenParameter("cc",comm.communityID);
|
||||
rc.photoTag = rinput.getCommunityLogoTag(comm.getContactInfo().photoURL);
|
||||
rc.label = "New community logo";
|
||||
|
||||
} // 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,
|
||||
"comm/profile.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("Access Error"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/profile.js.vs?cc=" + comm.communityID);
|
||||
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("comm/profile.js.vs?cc=" + comm.communityID,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",
|
||||
"comm/profile.js.vs?cc=" + comm.communityID));
|
||||
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.",
|
||||
"comm/photo.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
try
|
||||
{ // normalize the photo to 100x100 pixels
|
||||
real_pic = ImageNormalizer.normalizeImage(rinput.getParameterDataStream("thepic"),
|
||||
rinput.engine.getCommunityLogoSize(),"jpeg");
|
||||
|
||||
// set the community logo data!
|
||||
ci = comm.getContactInfo();
|
||||
ci.setPhotoData(rinput.contextPath + "/imagedata/","image/jpeg",real_pic.length,real_pic.data);
|
||||
comm.putContactInfo(ci);
|
||||
|
||||
// Jump back to the profile form.
|
||||
rinput.setSessionAttribute(RequestInput.LEFT_MENU_SESSION_ATTR,null);
|
||||
rc = new Redirect("comm/profile.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception while setting community logo
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ServletMultipartException"))
|
||||
rc = new ErrorBox(null,"Internal Error: " + e.message,"comm/profile.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("ImageNormalizerException"))
|
||||
rc = new ErrorBox(null,e.message,"comm/photo.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error storing community logo: " + e.message,
|
||||
"comm/profile.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // don't know the command button!
|
||||
logger.error("no known button click on POST to comm/photo.js");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed",
|
||||
"comm/profile.js.vs?cc=" + comm.communityID);
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc); // all done!
|
||||
237
scripts/comm/profile.js
Normal file
237
scripts/comm/profile.js
Normal file
@@ -0,0 +1,237 @@
|
||||
// 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.dlg);
|
||||
importPackage(Packages.com.silverwrist.venice.ui.helpers);
|
||||
|
||||
// Define a simple function to set up the dialog stuff.
|
||||
function setupDialog(dlg,comm)
|
||||
{
|
||||
dlg.setSubtitle(comm.name);
|
||||
dlg.sendMessage("logo","setLinkURL","comm/photo.js.vs?cc=" + comm.communityID);
|
||||
sinf = comm.securityInfo;
|
||||
dlg.sendMessage("read_lvl","setRoleList",sinf.getRoleList("Community.Read"));
|
||||
dlg.sendMessage("write_lvl","setRoleList",sinf.getRoleList("Community.Write"));
|
||||
dlg.sendMessage("create_lvl","setRoleList",sinf.getRoleList("Community.Create"));
|
||||
dlg.sendMessage("delete_lvl","setRoleList",sinf.getRoleList("Community.Delete"));
|
||||
dlg.sendMessage("join_lvl","setRoleList",sinf.getRoleList("Community.Join"));
|
||||
|
||||
if (comm.isAdminCommunity())
|
||||
{ // need to disable a bunch of crap if this is the admin community
|
||||
dlg.setEnabled("comtype",false);
|
||||
dlg.setEnabled("joinkey",false);
|
||||
dlg.setEnabled("membersonly",false);
|
||||
dlg.setEnabled("hidemode",false);
|
||||
dlg.setEnabled("read_lvl",false);
|
||||
dlg.setEnabled("write_lvl",false);
|
||||
dlg.setEnabled("create_lvl",false);
|
||||
dlg.setEnabled("delete_lvl",false);
|
||||
dlg.setEnabled("join_lvl",false);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end setupDialog
|
||||
|
||||
// get the request object and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canModifyProfile()))
|
||||
{ // no access - sorry, dude
|
||||
logger.error("tried to call up community profile screen without access...naughty naughty!");
|
||||
vlib.output(new ErrorBox("Unauthorized","You do not have access to modify this community's profile.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
dlg = rinput.getDialog("community.profile");
|
||||
|
||||
rc = null;
|
||||
if ("GET"==rinput.verb)
|
||||
{ // set up the dialog and return
|
||||
setupDialog(dlg,comm);
|
||||
dlg.setValue("cc",comm.communityID + "");
|
||||
|
||||
try
|
||||
{ // load the parameters of the dialog
|
||||
ci = comm.getContactInfo();
|
||||
props = comm.properties;
|
||||
dlg.setValue("name",comm.name);
|
||||
dlg.setValue("alias",comm.alias);
|
||||
dlg.setValue("synopsis",comm.synopsis);
|
||||
dlg.setValue("rules",comm.rules);
|
||||
dlg.setValue("language",comm.getLanguageCode());
|
||||
dlg.setValue("url",ci.URL);
|
||||
dlg.setValue("logo",ci.photoURL);
|
||||
dlg.setValue("company",ci.company);
|
||||
dlg.setValue("addr1",ci.addressLine1);
|
||||
dlg.setValue("addr2",ci.addressLine2);
|
||||
dlg.setValue("loc",ci.locality);
|
||||
dlg.setValue("reg",ci.region);
|
||||
dlg.setValue("pcode",ci.postalCode);
|
||||
dlg.setValue("country",ci.country);
|
||||
if (comm.isPublicCommunity())
|
||||
{ // public community - has no join key
|
||||
dlg.setValue("comtype","0");
|
||||
dlg.setValue("joinkey","");
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // private community - display the join key
|
||||
dlg.setValue("comtype","1");
|
||||
dlg.setValue("joinkey",comm.joinKey);
|
||||
|
||||
} // end else
|
||||
|
||||
if (comm.membersOnly)
|
||||
dlg.setValue("membersonly",1);
|
||||
dlg.setValue("hidemode",comm.hideMode);
|
||||
dlg.setValue("read_lvl",comm.readLevel);
|
||||
dlg.setValue("write_lvl",comm.writeLevel);
|
||||
dlg.setValue("create_lvl",comm.createLevel);
|
||||
dlg.setValue("delete_lvl",comm.deleteLevel);
|
||||
dlg.setValue("join_lvl",comm.joinLevel);
|
||||
if (props.displayPostPictures)
|
||||
dlg.setValue("pic_in_post",1);
|
||||
|
||||
rc = dlg;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception in dialog initialization
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error retrieving profile: " + e.message,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Unauthorized","You do not have access to modify this community's profile.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
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("comm/admin_menu.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (op=="update")
|
||||
{ // OK, we can update the dialog!
|
||||
dlg.load(rinput); // load the dialog parameters
|
||||
|
||||
try
|
||||
{ // start by validating the dialog
|
||||
dlg.validate();
|
||||
|
||||
// validate some other stuff we didn't pick up in the fixed validation
|
||||
if (rinput.engine.aliasExists(dlg.getValue("alias"),comm.communityID))
|
||||
throw new ValidationException("That alias is already used by another community on the system.");
|
||||
|
||||
if ("1"==dlg.getValue("comtype"))
|
||||
{ // make sure if they flagged it as Private that they specified a join key
|
||||
if (vlib.emptyString(dlg.getValue("joinkey")))
|
||||
throw new ValidationException("Private communities must specify a join key value.");
|
||||
|
||||
} // end if
|
||||
|
||||
// save off the ContactInfo-related fields first
|
||||
ci = comm.getContactInfo();
|
||||
ci.URL = dlg.getValue("url");
|
||||
ci.company = dlg.getValue("company");
|
||||
ci.addressLine1 = dlg.getValue("addr1");
|
||||
ci.addressLine2 = dlg.getValue("addr2");
|
||||
ci.locality = dlg.getValue("loc");
|
||||
ci.region = dlg.getValue("reg");
|
||||
ci.postalCode = dlg.getValue("pcode");
|
||||
ci.country = dlg.getValue("country");
|
||||
comm.putContactInfo(ci);
|
||||
|
||||
// now save off the property-related fields
|
||||
props = comm.properties;
|
||||
props.displayPostPictures = dlg.getValue("pic_in_post").booleanValue();
|
||||
comm.properties = props;
|
||||
|
||||
// now save the big text fields
|
||||
comm.name = dlg.getValue("name");
|
||||
comm.alias = dlg.getValue("alias");
|
||||
comm.synopsis = dlg.getValue("synopsis");
|
||||
comm.rules = dlg.getValue("rules");
|
||||
comm.setLanguage(dlg.getValue("language"));
|
||||
|
||||
if (!(comm.isAdminCommunity()))
|
||||
{ // save off the security information
|
||||
if ("1"==dlg.getValue("comtype"))
|
||||
comm.joinKey = dlg.getValue("joinkey");
|
||||
else
|
||||
comm.joinKey = null;
|
||||
|
||||
comm.membersOnly = dlg.getValue("membersonly").booleanValue();
|
||||
comm.setHideMode(parseInt(dlg.getValue("hidemode"),10));
|
||||
comm.setSecurityLevels(parseInt(dlg.getValue("read_lvl"),10),parseInt(dlg.getValue("write_lvl"),10),
|
||||
parseInt(dlg.getValue("create_lvl"),10),parseInt(dlg.getValue("delete_lvl"),10),
|
||||
parseInt(dlg.getValue("join_lvl"),10));
|
||||
|
||||
} // end if
|
||||
|
||||
// bounce back to the admin menu
|
||||
rinput.setSessionAttribute(RequestInput.LEFT_MENU_SESSION_ATTR,null);
|
||||
rc = new Redirect("comm/admin_menu.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception setting the profile
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ValidationException"))
|
||||
{ // validation error - redisplay the dialog
|
||||
dlg.setErrorMessage(e.message + " Please try again.");
|
||||
setupDialog(dlg,comm);
|
||||
rc = dlg;
|
||||
|
||||
} // end if
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error updating community: " + e.message,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end try
|
||||
else
|
||||
{ // what the hell was that button?
|
||||
logger.error("no known button click on POST to comm/profile.js");
|
||||
rc = new ErrorBox("Internal Error","Unknown command button pressed",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
|
||||
} // end else
|
||||
|
||||
vlib.output(rc);
|
||||
46
scripts/comm/sb_list.js
Normal file
46
scripts/comm/sb_list.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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 and save the member communities list
|
||||
rinput.setRequestAttribute("communities.list",rinput.user.getMemberCommunities());
|
||||
|
||||
rc = new JSPView("Your Communities","comm/sb_list.jsp");
|
||||
rc.menuSelector = Content.MENU_SELECTOR_TOP;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // try to catch an exception
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Error getting communities list: " + e.message,"top.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
72
scripts/comm/sb_unjoin.js
Normal file
72
scripts/comm/sb_unjoin.js
Normal file
@@ -0,0 +1,72 @@
|
||||
// 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);
|
||||
|
||||
// get the request object and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"comm/sb_list.js.vs");
|
||||
|
||||
if (!(comm.canUnjoin()))
|
||||
{ // you can't unjoin the community
|
||||
vlib.output(new ErrorBox("Community Error","You are not permitted to unjoin this community.",
|
||||
"comm/sb_list.js.vs"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// the names of the confirmation attribute and parameter
|
||||
CONFIRM_attr = "confirmbox.unjoin";
|
||||
CONFIRM_param = "confirm";
|
||||
|
||||
rc = null;
|
||||
if (ConfirmBox.isConfirmed(rinput,CONFIRM_attr,CONFIRM_param))
|
||||
{ // we are confirmed - unjoin us!
|
||||
try
|
||||
{ // do the unjoin
|
||||
comm.unjoin();
|
||||
|
||||
// force the menus to be redrawn
|
||||
rinput.setSessionAttribute(RequestInput.LEFT_MENU_SESSION_ATTR,null);
|
||||
|
||||
// after which, return to the top
|
||||
rc = new Redirect("comm/sb_list.js.vs",LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // caught an exception while unjoining
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","Unable to unjoin community: " + e.message,"comm/sb_list.js.vs");
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error unjoining community: " + e.message,
|
||||
"comm/sb_list.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else // not yet confirmed - display the confirmation box
|
||||
rc = new ConfirmBox(rinput,CONFIRM_attr,CONFIRM_param,"Unjoining Community",
|
||||
"Are you sure you want to unjoin the '" + comm.name + "' community?",
|
||||
"comm/sb_unjoin.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET,
|
||||
"comm/sb_list.js.vs",LinkTypes.SERVLET);
|
||||
|
||||
vlib.output(rc);
|
||||
219
scripts/comm/set_member.js
Normal file
219
scripts/comm/set_member.js
Normal file
@@ -0,0 +1,219 @@
|
||||
// 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);
|
||||
|
||||
// Function which sets the correct community access level onto each entry of the input list.
|
||||
function augmentList(comm,list)
|
||||
{
|
||||
var rl = new ArrayList(list.size());
|
||||
var it = list.iterator();
|
||||
while (it.hasNext())
|
||||
{ // get the community level and add it to the UserFound object
|
||||
var uf = vlib.castUserFound(it.next());
|
||||
var level = comm.getMemberLevel(uf.UID);
|
||||
rl.add(uf.createNewLevel(level));
|
||||
|
||||
} // end while
|
||||
|
||||
return rl;
|
||||
|
||||
} // end augmentList
|
||||
|
||||
// get the request object and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canModifyProfile()))
|
||||
{ // no access - sorry, dude
|
||||
logger.error("tried to call up membership screen without access...naughty naughty!");
|
||||
vlib.output(new ErrorBox("Unauthorized","You do not have access to modify this community's membership.",
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// create the view object
|
||||
view = new SetMemberView(rinput.engine.getStdNumSearchResults(),comm);
|
||||
|
||||
rc = null;
|
||||
if ("GET"==rinput.verb)
|
||||
{ // set up the initial state of the view
|
||||
try
|
||||
{ // get the community membership list
|
||||
mbr_list = comm.getMemberList();
|
||||
view.simple = true;
|
||||
view.results = mbr_list;
|
||||
view.findCount = mbr_list.size();
|
||||
rc = view;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // we can get at least one exception here
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error retrieving membership list: " + e.message,
|
||||
"comm/admin_menu.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc);
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
if (rinput.isImageButtonClicked("update"))
|
||||
{ // do an update of privileges in this community
|
||||
list_uids = vlib.splitList(rinput.getParameter("listuids"),":");
|
||||
try
|
||||
{ // loop through the defined UIDs and check the level...
|
||||
it = list_uids.iterator();
|
||||
while (it.hasNext())
|
||||
{ // get the current and new levels, compare them, and reset if needed
|
||||
x = it.next();
|
||||
cur_level = rinput.getParameterInt("zxcur_" + x,-1);
|
||||
new_level = rinput.getParameterInt("zxnew_" + x,-1);
|
||||
if (cur_level!=new_level)
|
||||
comm.setMembership(parseInt(x,10),new_level);
|
||||
|
||||
} // end while
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // the update might throw an error message
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error adjusting permissions: " + e.message,
|
||||
"comm/set_member.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/set_member.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
vlib.output(rc); // bail out now with the error message
|
||||
vlib.done();
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
|
||||
// Carry on with the search operation now.
|
||||
try
|
||||
{ // handle the actual search
|
||||
if ("1"==rinput.getParameter("sl"))
|
||||
{ // Set up some of the easy initial parameters.
|
||||
view.simple = true;
|
||||
|
||||
// Retrieve the offset and find count.
|
||||
view.offset = rinput.getParameterInt("ofs",0);
|
||||
// view.findCount = rinput.getParameterInt("fcount",-1); (N.B.: will get reassigned below)
|
||||
|
||||
// Adjust the offset based on the button clicked.
|
||||
if (rinput.isImageButtonClicked("search"))
|
||||
throw new ValidationException("Invalid button clicked."); // can't happen
|
||||
else if (rinput.isImageButtonClicked("previous"))
|
||||
view.offset = Math.max(view.offset-view.maxResults,0);
|
||||
else if (rinput.isImageButtonClicked("next"))
|
||||
view.offset += view.maxResults;
|
||||
else if (!(rinput.isImageButtonClicked("update")))
|
||||
throw new ValidationException("Unable to determine what action triggered the form.");
|
||||
|
||||
// Get the list and subset it if necessary.
|
||||
// N.B.: Since the update function can reduce the size of the member list, we need to take into account
|
||||
// that the find count will need updating and the offset may be in the wrong place for the list now.
|
||||
mbr_list = comm.getMemberList();
|
||||
view.findCount = mbr_list.size();
|
||||
while ((view.offset>0) && (view.offset>=view.findCount))
|
||||
view.offset = Math.max(view.offset-view.maxResults,0);
|
||||
if (view.offset==0)
|
||||
view.results = mbr_list;
|
||||
else
|
||||
view.results = mbr_list.subList(offset,mbr_list.size());
|
||||
|
||||
} // end if
|
||||
else
|
||||
{ // This is a search operation...
|
||||
view.simple = false;
|
||||
|
||||
// Get 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;
|
||||
|
||||
// Get 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;
|
||||
|
||||
// Get the search term parameter.
|
||||
view.term = rinput.getParameter("term");
|
||||
if (view.term==null)
|
||||
view.term = "";
|
||||
|
||||
// Retrieve the offset and find count.
|
||||
view.offset = rinput.getParameterInt("ofs",0);
|
||||
view.findCount = rinput.getParameterInt("fcount",-1);
|
||||
|
||||
// Adjust the offset based on the button clicked.
|
||||
if (rinput.isImageButtonClicked("search"))
|
||||
view.offset = 0; // begin a new search
|
||||
else if (rinput.isImageButtonClicked("previous"))
|
||||
view.offset = Math.max(view.offset-view.maxResults,0);
|
||||
else if (rinput.isImageButtonClicked("next"))
|
||||
view.offset += view.maxResults;
|
||||
else if (!(rinput.isImageButtonClicked("update")))
|
||||
throw new ValidationException("Unable to determine what action triggered the form.");
|
||||
|
||||
// Perform the search! (Note that we search on USERS, not MEMBERS, as this is the way that we
|
||||
// add additional members to a community.)
|
||||
tmp_results = rinput.engine.searchForUsers(view.field,view.mode,view.term,view.offset,view.maxResults);
|
||||
view.results = augmentList(comm,tmp_results);
|
||||
if (view.findCount<0)
|
||||
view.findCount = rinput.engine.getSearchUserCount(view.field,view.mode,view.term);
|
||||
|
||||
} // end else (search operation)
|
||||
|
||||
rc = view;
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // handle an error in search
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("ValidationException"))
|
||||
rc = new ErrorBox("Find Error",e.message + " Please try again.",
|
||||
"comm/set_member.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error getting member list: " + e.message,
|
||||
"comm/set_member.js.vs?cc=" + comm.communityID);
|
||||
else if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error",e.message,"comm/set_member.js.vs?cc=" + comm.communityID);
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc); // all done!
|
||||
88
scripts/comm/show.js
Normal file
88
scripts/comm/show.js
Normal file
@@ -0,0 +1,88 @@
|
||||
// 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 community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
rc = null;
|
||||
try
|
||||
{ // retrieve certain possibly problematic data items and save them as attributes
|
||||
ci = comm.getContactInfo();
|
||||
rinput.setRequestAttribute("contact.info",ci);
|
||||
rinput.setRequestAttribute("host.profile",comm.getHostProfile());
|
||||
rinput.setRequestAttribute("category",comm.getCategory());
|
||||
|
||||
// determine the last line of the address and save it off
|
||||
buf = null;
|
||||
if (vlib.emptyString(ci.locality))
|
||||
{ // allocate stringbuffer based on region
|
||||
if (vlib.emptyString(ci.region))
|
||||
buf = new java.lang.StringBuffer();
|
||||
else
|
||||
buf = new java.lang.StringBuffer(ci.region);
|
||||
|
||||
} // end if
|
||||
else if (vlib.emptyString(ci.region))
|
||||
buf = new java.lang.StringBuffer(ci.locality);
|
||||
else
|
||||
{ // tack together both locality and region
|
||||
buf = new java.lang.StringBuffer(ci.locality);
|
||||
buf.append(", ");
|
||||
buf.append(ci.region);
|
||||
|
||||
} // end else
|
||||
|
||||
if (!(vlib.emptyString(ci.postalCode)))
|
||||
{ // append the postal code
|
||||
buf.append(" ");
|
||||
buf.append(ci.postalCode);
|
||||
|
||||
} // end if
|
||||
|
||||
rinput.setRequestAttribute("address.lastline",buf.toString());
|
||||
|
||||
// get the full country name and save it off
|
||||
ce = Packages.com.silverwrist.util.International.get().getCountryForCode(ci.country);
|
||||
if (ce!=null)
|
||||
rinput.setRequestAttribute("address.country",ce.name);
|
||||
|
||||
// Save off the community logo tag.
|
||||
rinput.setRequestAttribute("community.logo",rinput.getCommunityLogoTag(ci.photoURL));
|
||||
|
||||
// create the view object
|
||||
rc = new JSPView("Community Profile: " + comm.name,"comm/profile.jsp");
|
||||
rc.menuSelector = Content.MENU_SELECTOR_COMMUNITY;
|
||||
rc.pageQID = "go/" + comm.alias + "!";
|
||||
|
||||
} // 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 accessing community: " + e.message,"top.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
vlib.output(rc); // all done!
|
||||
70
scripts/comm/unjoin.js
Normal file
70
scripts/comm/unjoin.js
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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);
|
||||
|
||||
// get the request object and the community
|
||||
rinput = bsf.lookupBean("request");
|
||||
comm = rinput.getCommunity(true,"top.js.vs");
|
||||
|
||||
if (!(comm.canUnjoin()))
|
||||
{ // you can't unjoin the community
|
||||
vlib.output(new ErrorBox("Community Error","You are not permitted to unjoin this community.","top.js.vs"));
|
||||
vlib.done();
|
||||
|
||||
} // end if
|
||||
|
||||
// the names of the confirmation attribute and parameter
|
||||
CONFIRM_attr = "confirmbox.unjoin";
|
||||
CONFIRM_param = "confirm";
|
||||
|
||||
rc = null;
|
||||
if (ConfirmBox.isConfirmed(rinput,CONFIRM_attr,CONFIRM_param))
|
||||
{ // we are confirmed - unjoin us!
|
||||
try
|
||||
{ // do the unjoin
|
||||
comm.unjoin();
|
||||
|
||||
// force the menus to be redrawn
|
||||
rinput.setSessionAttribute(RequestInput.LEFT_MENU_SESSION_ATTR,null);
|
||||
|
||||
// after which, return to the top
|
||||
rc = new Redirect("top.js.vs",LinkTypes.SERVLET);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // caught an exception while unjoining
|
||||
etype = vlib.exceptionType(e) + "";
|
||||
if (etype.match("AccessError"))
|
||||
rc = new ErrorBox("Access Error","Unable to unjoin community: " + e.message,"top.js.vs");
|
||||
else if (etype.match("DataException"))
|
||||
rc = new ErrorBox("Database Error","Database error unjoining community: " + e.message,"top.js.vs");
|
||||
else
|
||||
rc = e;
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end if
|
||||
else // not yet confirmed - display the confirmation box
|
||||
rc = new ConfirmBox(rinput,CONFIRM_attr,CONFIRM_param,"Unjoining Community",
|
||||
"Are you sure you want to unjoin the '" + comm.name + "' community?",
|
||||
"comm/unjoin.js.vs?cc=" + comm.communityID,LinkTypes.SERVLET,
|
||||
"community/" + comm.alias,LinkTypes.SERVLET);
|
||||
|
||||
vlib.output(rc);
|
||||
Reference in New Issue
Block a user