added code to auto-join new users to a new community, where necessary

This commit is contained in:
Eric J. Bowersox
2003-06-02 12:05:44 +00:00
parent 31e0cbe4a0
commit d72db2985b
12 changed files with 461 additions and 8 deletions

View File

@@ -15,6 +15,7 @@
// Contributor(s):
importPackage(java.lang);
importPackage(java.util);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importClass(Packages.com.silverwrist.dynamo.UserInfoNamespace);
importPackage(Packages.com.silverwrist.dynamo.dialog);
@@ -22,7 +23,9 @@ importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.mail);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.community);
importPackage(Packages.com.silverwrist.venice.frame);
importPackage(Packages.com.silverwrist.venice.iface);
importPackage(Packages.com.silverwrist.venice.session);
req = bsf.lookupBean("request");
@@ -132,13 +135,33 @@ if (op=="create")
dynamo.scriptReturn(new ErrorBox("Internal Error","Unable to copy settings to new user.",target));
// Add this user to the "all users" group.
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
"srm"));
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"srm"));
srm.getAllUsersGroup().addMember(new_user);
// Write an audit message indicating the new user was created.
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"user.created");
// Get all communities that the anonymous user is a member of and add the new user as a member of
// any community that they can join as a result.
commsvc = vcast.queryCommunityService(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"communities"));
anon_list = commsvc.getMemberCommunities(new_user,umgmt.getAnonymousUser());
it = anon_list.iterator();
while (it.hasNext())
{ // get each community and its join requirements
comm = vcast.toVeniceCommunity(it.next());
logger.debug("Checking community: " + comm.name);
jreq = comm.getJoinRequirement(new_user);
if (cast.isBooleanTrue(jreq))
{ // OK, join this community
logger.debug("OK to join community: " + comm.name);
if (comm.join(new_user))
{
}
} // end if
} // end while
// Generate an E-mail confirmation number and add it to the user properties.
confnum = vlib.randomConfirmationNumber();
new_user.setObject(new_user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"confirmation.number",
@@ -154,8 +177,7 @@ if (op=="create")
msg = mailprov.createSystemMessage(req);
msg.addRecipient(MailMessage.RECIP_TO,new_user.getEMailAddress());
globals = vcast.getGlobalPropertiesStore(req);
msg.setSubject(globals.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,
"confirm.message.title").toString());
msg.setSubject(globals.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,"confirm.message.title").toString());
blocks = vcast.getGlobalBlocksStore(req);
msg.setText(blocks.getObject(VeniceNamespaces.MAIL_MESSAGES_NAMESPACE,"confirm.message").toString());
msg.setVariable("username",new_user.getName());
@@ -163,8 +185,7 @@ if (op=="create")
msg.send();
// Write an audit message.
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"send.confirm.email",
new_user.getEMailAddress());
audit.write(req,new_user,VeniceNamespaces.USER_EVENT_NAMESPACE,"send.confirm.email",new_user.getEMailAddress());
// Now bounce us to the "verification" dialog.
dynamo.scriptOutput(new Redirect("SERVLET","verify_email.js.vs?tgt=" + stringutils.encodeURL(target)));

View File

@@ -14,12 +14,16 @@
//
// Contributor(s):
importPackage(java.lang);
importPackage(java.util);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.mail);
importPackage(Packages.com.silverwrist.dynamo.security);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.community);
importPackage(Packages.com.silverwrist.venice.iface);
req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
@@ -140,6 +144,26 @@ if (op=="ok")
"srm"));
srm.getVerifiedUsersGroup().addMember(user);
// Get all communities that the anonymous user is a member of and add the new user as a member of
// any community that they can join as a result.
umgmt = cast.queryUserManagement(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"users"));
commsvc = vcast.queryCommunityService(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"communities"));
anon_list = commsvc.getMemberCommunities(user,umgmt.getAnonymousUser());
it = anon_list.iterator();
while (it.hasNext())
{ // get each community and its join requirements
comm = vcast.toVeniceCommunity(it.next());
jreq = comm.getJoinRequirement(user);
if (cast.isBooleanTrue(jreq))
{ // OK, join the community
if (comm.join(user))
{
}
} // end if
} // end while
// and that does it - bounce us on to whereever we were going
dynamo.scriptOutput(new Redirect("SERVLET",target));