added Members and Unjoin functionality, setting of public/private/invitation-

only for communities
This commit is contained in:
Eric J. Bowersox
2003-06-19 03:34:12 +00:00
parent 3be3c52161
commit fbaf90e156
31 changed files with 1079 additions and 27 deletions

View File

@@ -16,8 +16,10 @@
importPackage(java.lang);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importClass(Packages.com.silverwrist.dynamo.UserInfoNamespace);
importPackage(Packages.com.silverwrist.dynamo.except);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.security);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.CommunityVisibility);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
@@ -39,6 +41,8 @@ if (!( acl.testPermission(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"s
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error",
"You are not permitted to modify this community's profile."));
variable_type = acl.testPermission(user,VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"set.property")
// Create the dialog.
loader = cast.queryDialogLoader(req);
dlg = loader.loadDialogResource("comm/community_profile.dlg.xml");
@@ -77,8 +81,9 @@ if (req_help.isVerb("GET"))
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("comtype",comm.getObject(VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"type.hint"));
dlg.setValue("joinkey",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,
"join.key"));
dlg.setValue("visibility",comm.getVisibility().getName());
} // end if
@@ -118,7 +123,47 @@ else
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"
if (variable_type)
{ // see if the community type is changing, set a join key if it is
old_comtype = cast.toInteger(comm.getObject(VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"type.hint"));
new_comtype = cast.toInteger(dlg.getValue("comtype"));
if (old_comtype!=new_comtype)
{ // "Community type" mainly affects the authentication required for the "All Verified Users" group.
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
"srm"));
the_group = srm.getVerifiedUsersGroup();
switch (new_comtype)
{
case 0: // public access
comm.grantAccess(user,the_group,null,null,null,null,false);
if (PropertyUtils.hasProperty(comm,VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"join.key"))
comm.removeObject(user,VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"join.key");
break;
case 1: // private access
jkey = dlg.getValue("joinkey");
comm.grantAccess(user,the_group,UserInfoNamespace.NAMESPACE,UserInfoNamespace.AUTH_DEFAULT,"",
jkey,false);
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"join.key",jkey);
break;
case 2: // invitation-only access
comm.revokeAccess(user,the_group);
if (PropertyUtils.hasProperty(comm,VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"join.key"))
comm.removeObject(user,VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"join.key");
break;
} // end switch
// save off the new type
comm.setObject(user,VeniceNamespaces.COMMUNITY_SECURITY_NAMESPACE,"type.hint",
cast.toIntegerObject(new_comtype));
} // end if
} // end if
comm.setVisibility(user,CommunityVisibility.getEnum(dlg.getValue("visibility")));
vlib.forceReloadMenu(req); // the menu might have changed, so reload it
@@ -166,6 +211,13 @@ if (rc==null)
{ // output dialog if we don't have another value
dlg.setSubtitle(comm.getName());
dlg.setRenderParam("cid",comm.getCID() + "");
if (!variable_type)
{ // disable "community type" and "join key"
dlg.setEnabled("comtype",false);
dlg.setEnabled("joinkey",false);
} // end if
rc = new FrameDialog(dlg);
rc.menuSelector = "community";

View File

@@ -0,0 +1,111 @@
// 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.iface);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.SearchMode);
importClass(Packages.com.silverwrist.venice.UserSearchField);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importClass(Packages.com.silverwrist.venice.app.AdvancedUserService);
importPackage(Packages.com.silverwrist.venice.content);
req = bsf.lookupBean("request"); // get request
rhelp = bsf.lookupBean("request_help"); // get request helper
user = vlib.getUser(req); // get user
comm = vlib.getCommunity(req); // get community
membergroup = comm.getMemberGroup();
// Get the user's configured page size.
pagesize = cast.toInteger(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count"));
stdlist = 1;
field = UserSearchField.USERNAME;
mode = SearchMode.PREFIX;
term = "";
ofs = 0;
fcount = -1;
results = null;
rc = null;
if (rhelp.isVerb("POST"))
{ // Read the form parameters
stdlist = rhelp.getParameterInt("sl",1);
field = UserSearchField.getEnum(rhelp.getParameter("field"));
mode = SearchMode.getEnum(rhelp.getParameter("mode"));
term = rhelp.getParameter("term");
ofs = rhelp.getParameterInt("ofs",0);
fcount = rhelp.getParameterInt("fcount",-1);
// Adjust offset based on the button that was clicked.
if (rhelp.isImageButtonClicked("search"))
{ // beginning of a new search
ofs = 0;
fcount = -1;
} // end if
else if (rhelp.isImageButtonClicked("previous"))
ofs = Math.max(ofs - pagesize,0);
else if (rhelp.isImageButtonClicked("next"))
ofs += pagesize;
} // end else
try
{ // fill in the results and find count
if (stdlist==1)
{ // get the usual member list
if (fcount<0)
fcount = membergroup.getMemberCount();
results = membergroup.getMembers(ofs,pagesize);
} // end if
else
{ // we're searching
usersvc = vcast.queryAdvancedUserService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"adv-users"));
if (fcount<0)
fcount = usersvc.getSearchMemberCount(user,membergroup,field,mode,term);
results = usersvc.searchForMembers(user,membergroup,field,mode,term,ofs,pagesize);
} // end else
} // end try
catch (e)
{ // exception thrown
rc = new ErrorBox("Database Error",e,"SERVLET","comm/members.js.vs");
} // end catch
if (rc==null)
{ // create the VelocityView for the output
rc = new VelocityView(comm.name + ": Members","comm/members.vm");
rc.menuSelector = "community";
rc.setParameter("comm",comm);
rc.setParameter("stdlist",cast.toIntegerObject(stdlist));
rc.setParameter("field",field.getName());
rc.setParameter("mode",mode.getName());
rc.setParameter("term",term.toString());
rc.setParameter("ofs",cast.toIntegerObject(ofs));
rc.setParameter("fcount",cast.toIntegerObject(fcount));
rc.setParameter("pagesize",cast.toIntegerObject(pagesize));
if (results!=null)
rc.setParameter("results",results);
} // end if
dynamo.scriptOutput(rc);

View File

@@ -0,0 +1,41 @@
// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(java.lang);
importPackage(java.util);
importPackage(Packages.com.silverwrist.util);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.except);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.util);
importPackage(Packages.com.silverwrist.venice.content);
importPackage(Packages.com.silverwrist.venice.iface);
req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
user = vlib.getUser(req);
comm = vlib.getCommunity(req);
if (vlib.confirmed(req,"/comm/unjoin.js.vs","confirmation","confnum"))
{ // we're confirmed - unjoin us and throw us back to the front page
comm.unjoin(user);
dynamo.scriptReturn(new Redirect("SERVLET","top.js.vs"));
} // end if
dynamo.scriptOutput(new ConfirmBox(req,"/comm/unjoin.js.vs","confirmation","confnum","Unjoin Confirmation",
"You are about to unjoin the '" + comm.name + "' community! Are you sure you want to do this?",
"SERVLET","comm/unjoin.js.vs?cc=" + comm.getCID(),"SERVLET","community/" + comm.alias));

View File

@@ -156,6 +156,7 @@ if (op=="create")
logger.debug("OK to join community: " + comm.name);
if (comm.join(new_user))
{
// TODO: what do we do after we join the community?
}
} // end if