added Members and Unjoin functionality, setting of public/private/invitation-
only for communities
This commit is contained in:
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user