added initial implementation of Edit Community Profile dialog; added additional

fields needed to implement the dialog; changed build script to keep from
recompiling the JavaCC-compiled parser stuff needlessly
This commit is contained in:
Eric J. Bowersox
2003-06-16 21:11:59 +00:00
parent eb32d42bd7
commit f8ddd74223
11 changed files with 495 additions and 12 deletions

View File

@@ -0,0 +1,57 @@
<?xml version="1.0"?>
<!--
The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
The Original Code is the Venice Web Communities System.
The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
Contributor(s):
-->
<dialog name="community_profile" defaultbutton="update">
<title>Edit Community Profile:</title>
<action>comm/admin/profile.js.vs</action>
<hidden name="cc" value=""/>
<header name="basic_hdr" caption="Basic Information"/>
<text name="name" caption="Community Name" required="true" size="32" maxlength="128"/>
<dynamo-id name="alias" caption="Community Alias" required="true" size="32" maxlength="32"/>
<text name="synopsis" caption="Synopsis" size="32" maxlength="254"/>
<text name="rules" caption="Rules" size="32" maxlength="254"/>
<languagelist name="language" caption="Primary Language" required="true"/>
<text name="url" caption="Home Page" size="32" maxlength="254"/>
<!-- <communitylogo name="logo" caption="Community Logo" link="comm/photo.js.vs" type="servlet"/> -->
<header name="location_hdr" caption="Location"/>
<text name="company" caption="Company" size="32" maxlength="254"/>
<text name="addr1" caption="Address" size="32" maxlength="254"/>
<text name="addr2" caption="Address" caption2="(line 2)" size="32" maxlength="254"/>
<text name="loc" caption="City" size="32" maxlength="64"/>
<text name="reg" caption="State/Province" size="32" maxlength="64"/>
<text name="pcode" caption="Zip/Postal Code" required="true" size="32" maxlength="64"/>
<countrylist name="country" caption="Country" required="true"/>
<header name="security_hdr" caption="Security"/>
<list name="comtype" caption="Community Type" required="true">
<choice id="0">Public</choice>
<choice id="1">Private</choice>
<choice id="2">Invitation-only</choice>
</list>
<text name="joinkey" caption="Join Key" caption2="(for private communities)" size="32" maxlength="254"/>
<list name="visibility" caption="Community Visibility" required="true">
<choice id="SEARCHDIR">Show in both directory and search</choice>
<choice id="SEARCHONLY">Hide in directory, but not in search</choice>
<choice id="NONE">Hide in both directory and search</choice>
</list>
<button name="update"/>
<button name="cancel"/>
</dialog>

View File

@@ -27,7 +27,7 @@
</header>
<password name="pass1" caption="Password" size="32" maxlength="128"/>
<password name="pass2" caption="Password" caption2="(retype)" size="32" maxlength="128"/>
<text name="remind" caption="Password reminder phrase" size="32" maxlength="255"/>
<text name="remind" caption="Password reminder phrase" size="32" maxlength="254"/>
<header name="name_hdr" caption="Name"/>
<text name="prefix" caption="Prefix" caption2="(Mr., Ms., etc.)" size="8" maxlength="8"/>
@@ -37,9 +37,9 @@
<text name="suffix" caption="Suffix" caption2="(Jr., III, etc.)" size="16" maxlength="16"/>
<header name="loc_hdr" caption="Location"/>
<text name="company" caption="Company" size="32" maxlength="255"/>
<text name="addr1" caption="Address" size="32" maxlength="255"/>
<text name="addr2" caption="Address" caption2="(line 2)" size="32" maxlength="255"/>
<text name="company" caption="Company" size="32" maxlength="254"/>
<text name="addr1" caption="Address" size="32" maxlength="254"/>
<text name="addr2" caption="Address" caption2="(line 2)" size="32" maxlength="254"/>
<checkbox name="pvt_addr" caption="Hide address in profile"/>
<text name="loc" caption="City" required="true" size="32" maxlength="64"/>
<text name="reg" caption="State/Province" required="true" size="32" maxlength="64"/>
@@ -55,12 +55,12 @@
<checkbox name="pvt_fax" caption="Hide fax number in profile"/>
<header name="email_hdr" caption="Internet"/>
<email name="email" caption="E-mail address" required="true" size="32" maxlength="255"/>
<email name="email" caption="E-mail address" required="true" size="32" maxlength="254"/>
<checkbox name="pvt_email" caption="Hide E-mail address in profile"/>
<text name="url" caption="Home Page" caption2="(URL)" size="32" maxlength="255"/>
<text name="url" caption="Home Page" caption2="(URL)" size="32" maxlength="254"/>
<header name="pers_hdr" caption="Personal"/>
<text name="descr" caption="Personal description" size="32" maxlength="255"/>
<text name="descr" caption="Personal description" size="32" maxlength="254"/>
<userphoto name="photo" caption="User Photo" link="profile_photo.js.vs?tgt=${rtgt}" type="servlet"/>
<header name="prefs_hdr" caption="User Preferences"/>

View File

@@ -34,5 +34,5 @@ aclids[0] = comm.getAcl().getAclID();
aclids[1] = srm.getGlobalAcl().getAclID();
menu = mprov.getStandardMenu(user,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"admin.menu",aclids);
menu.setVariable("name",comm.getName());
menu.setVariable("cid",String.valueOf(comm.getCID()));
menu.setVariable("cid",comm.getCID() + "");
dynamo.scriptOutput(menu);

View File

@@ -0,0 +1,146 @@
// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(java.lang);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.except);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.CommunityVisibility);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.frame);
importPackage(Packages.com.silverwrist.venice.iface);
req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
user = vlib.getUser(req);
comm = vlib.getCommunity(req);
// Make sure we are permitted to be here.
acl = comm.getAcl();
if (!( acl.testPermission(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.property")
&& acl.testPermission(user,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"grant.revoke.access")
&& acl.testPermission(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.visibility")
&& acl.testPermission(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.name")
&& acl.testPermission(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.alias")))
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error",
"You are not permitted to modify this community's profile."));
// Create the dialog.
loader = cast.queryDialogLoader(req);
dlg = loader.loadDialogResource("comm/community_profile.dlg.xml");
return_URL = "comm/admin/main.js.vs?cc=" + comm.getCID(); // shortcut
rc = null;
if (req_help.isVerb("GET"))
{ // Load the dialog with its initial values.
dlg.setValue("cc",comm.getCID() + "");
dlg.setValue("name",comm.getName());
dlg.setValue("alias",comm.getAlias());
dlg.setValue("synopsis",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,
"synopsis"));
dlg.setValue("rules",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"rules"));
dlg.setValue("language",comm.getObject(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"language"));
dlg.setValue("url",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.homepage"));
// TODO: set community logo here
dlg.setValue("company",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,
"company.name"));
dlg.setValue("addr1",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"address.1"));
dlg.setValue("addr2",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"address.2"));
dlg.setValue("loc",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"locality"));
dlg.setValue("reg",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"region"));
dlg.setValue("pcode",comm.getObject(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"postal.code"));
dlg.setValue("country",comm.getObject(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"country"));
dlg.setValue("comtype","0"); // TODO: replace with something real
dlg.setValue("joinkey",""); // TODO: replace with something real
dlg.setValue("visibility",comm.getVisibility().getName());
} // end if
else
{ // Load information from the dialog
op = dlg.getClickedButton(req) + "";
if (op=="cancel") // user cancelled - bounce back to the previous menu
rc = new Redirect("SERVLET",return_URL);
else
{ // load and validate the dialog
dlg.load(req);
try
{ // validate the dialog
dlg.validate(req);
// set the appropriate values into the community properties
comm.setName(user,dlg.getValue("name"));
comm.setAlias(user,dlg.getValue("alias"));
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"synopsis",
dlg.getValue("synopsis"));
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"rules",dlg.getValue("rules"));
comm.setObject(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"language",dlg.getValue("language"));
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.homepage",
dlg.getValue("url"));
// TODO: deal with community logo
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"company.name",
dlg.getValue("company"));
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"address.1",
dlg.getValue("addr1"));
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"address.2",
dlg.getValue("addr2"));
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"locality",
dlg.getValue("loc"));
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"region",
dlg.getValue("reg"));
comm.setObject(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"postal.code",dlg.getValue("pcode"));
comm.setObject(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"country",dlg.getValue("country"));
// TODO: do something with "comtype" and "joinkey"
comm.setVisibility(user,CommunityVisibility.getEnum(dlg.getValue("visibility")));
vlib.forceReloadMenu(req); // the menu might have changed, so reload it
// All done - bounce back to the main admin menu
rc = new Redirect("SERVLET",return_URL);
} // end try
catch (e)
{ // get the exception type and check it out
etype = dynamo.exceptionType(e) + "";
logger.error("Caught exception of type " + etype);
if (etype.match(/ValidationException/))
dlg.setErrorMessage(dynamo.exceptionMessage(e) + " Please try again.");
else if (etype.match(/DatabaseException/))
rc = new ErrorBox("Database Error",e,"SERVLET",return_URL);
else if (etype.match(/DynamoSecurityException/))
rc = new ErrorBox("Security Error",e,"SERVLET",return_URL);
else
rc = new ErrorBox("Unknown Exception",e,"SERVLET",return_URL);
} // end catch
} // end else
} // end else
if (rc==null)
{ // output dialog if we don't have another value
dlg.setSubtitle(comm.getName());
rc = new FrameDialog(dlg);
} // end if
dynamo.scriptOutput(rc);