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

View File

@@ -0,0 +1,151 @@
#*
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):
*#
#*
Parameters:
comm = Community we're working with
stdlist = 0 if this is a "search" operation, 1 if this is a "member list" operation
field = Search field (string equivalent)
mode = Search mode (string equivalent)
term = Search term
ofs = Offset within the search we're at right now
fcount = Total number of items found in current search
pagesize = Number of items to display per page
results = Results list from find/member list, a List of DynamoUser objects (may be null)
*#
#header2( "Community Members:" "$comm.Name" )
<form method="POST" action="#formatURL( "SERVLET" "comm/members.js.vs")">
<input type="hidden" name="cc" value="${comm.getCID()}" />
<input type="hidden" name="ofs" value="0" />
<input type="hidden" name="sl" value="0" />
#comment( "Find Community Members form" )
<div align="left">
<p><b>Search for members of community &quot;$comm.Name&quot;:</b></p>
<p>Display all users whose&nbsp;
<select name="field" size="1">
<option value="USERNAME" #if( $field.equals("USERNAME") )selected="selected"#end >username</option>
<option value="DESCRIPTION" #if( $field.equals("DESCRIPTION") )selected="selected"#end >description</option>
<option value="FIRSTNAME" #if( $field.equals("FIRSTNAME") )selected="selected"#end >first name</option>
<option value="LASTNAME" #if( $field.equals("LASTNAME") )selected="selected"#end >last name</option>
</select>&nbsp;
<select name="mode" size="1">
<option value="PREFIX" #if( $mode.equals("PREFIX") )selected="selected"#end >starts with the string</option>
<option value="SUBSTRING" #if( $mode.equals("SUBSTRING") )selected="selected"#end >contains the string</option>
<option value="REGEXP" #if( $mode.equals("REGEXP") )selected="selected"#end >matches the regular
expression</option>
</select>&nbsp;&nbsp;
<input type="text" name="term" size="32" maxlength="255" value="$!term" /></p>
<p>#button( "INPUT" "search" )</p>
</div>
#comment( "end Find Community Members form" )
</form>
#if( $results )
## Do a tricky set of computations here to figure out what we need to display in terms of the search results
## and the form to the right that lets us page through results.
#set( $resultcount = $results.size() )
#set( $is_next = 0 )
#set( $is_prev = 0 )
#if( $resultcount > $pagesize )
#set( $resultcount = $pagesize )
#set( $is_next = 1 )
#end
#if( $ofs > 0 )
#set( $is_prev = 1 )
#end
#set( $is_form = $is_next + $is_prev )
#set( $ndx_first = $ofs + 1 )
#set( $ndx_last = $ofs + $pagesize )
#if( $ndx_last > $fcount )
#set( $ndx_last = $fcount )
#end
#comment( "Results display" )
<hr />
<table width="100%" border="0" align="center"><tr valign="middle">
<td width="50%" align="left" class="subhead">
#if( $stdlist == 1 )
<b>Community Members</b>
#else
<b>Search Results</b>
#end
#if( $is_form >= 1 )
(Displaying ${ndx_first}-${ndx_last} of ${fcount})
#end
</td>
<td width="50%" align="right">
#if( $is_form >= 1 )
#comment( "Results navigation form" )
<form method="POST" action="#formatURL( "SERVLET" "comm/members.js.vs")">
<input type="hidden" name="cc" value="${comm.getCID()}" />
<input type="hidden" name="sl" value="$stdlist" />
<input type="hidden" name="field" value="$!field" />
<input type="hidden" name="mode" value="$!mode" />
<input type="hidden" name="term" value="$!term" />
<input type="hidden" name="ofs" value="$ofs" />
<input type="hidden" name="fcount" value="$fcount" />
#if( $is_prev == 1 )
#button( "INPUT" "previous" )
#else
#button( "IMAGE" "0transparent" )
#end
&nbsp;&nbsp;
#if( $is_next == 1 )
#button( "INPUT" "next" )
#else
#button( "IMAGE" "0transparent" )
#end
</form>
#else
&nbsp;
#end
</td>
</tr></table>
#if( $fcount > 0 )
#set( $i = $resultcount )
#set( $prof_ns = "http://www.silverwrist.com/NS/venice/2002/12/31/user.profile" )
<table border="0" align="left" cellpadding="0" cellspacing="4">
#foreach( $usr in $results )
#set( $i = $i - 1 )
#if( $i >= 0 )
#set( $first = $std.getProperty($usr,$prof_ns,"name.given") )
#set( $last = $std.getProperty($usr,$prof_ns,"name.family") )
#set( $city = $std.getProperty($usr,$prof_ns,"locality") )
#set( $state = $std.getProperty($usr,$prof_ns,"region") )
#set( $country = $std.getProperty($usr,$prof_ns,"country") )
#set( $descr = $std.getProperty($usr,$prof_ns,"description") )
<tr valign="top">
<td align="center" width="14">#bullet()</td>
<td align="left" class="content">
<a href="#formatURL( "SERVLET" "user/${usr.Name}" )">#encodeHTML( $usr.Name )</a><br />
#encodeHTML( $first ) #encodeHTML( $last ), from #encodeHTML( $city ), #encodeHTML( $state )
&nbsp;#encodeHTML( $country.getCode() )
#if( $descr )
<br /><em>#encodeHTML( $descr )</em>
#end
</td>
</tr>
#end
#end
</table>
#else
<em>No members found.</em>
#end
#comment( "End results display" )
#end

View File

@@ -73,6 +73,13 @@ body td.errorhead, body td.errorbody {
font-size: medium;
}
body td.confirmhead, body td.confirmbody {
font-size: small;
voice-family: "\"}\"";
voice-family: inherit;
font-size: medium;
}
body td.sideboxtop, body div.sideboxtop, body p.sideboxtop {
font-size: small;
voice-family: "\"}\"";
@@ -119,6 +126,10 @@ html>body td.errorhead, html>body td.errorbody {
font-size: medium;
}
html>body td.confirmhead, html>body td.confirmbody {
font-size: medium;
}
html>body td.sideboxtop, html>body div.sideboxtop, html>body p.sideboxtop {
font-size: medium;
}

View File

@@ -97,6 +97,7 @@ td.errorhead {
background-color: #660000;
text-align: center;
font-size: 15px;
font-weight: bold;
}
td.errorbody {
@@ -104,6 +105,19 @@ td.errorbody {
font-size: 15px;
}
td.confirmhead {
color: #ffffff;
background-color: #006600;
text-align: center;
font-size: 15px;
font-weight: bold;
}
td.confirmbody {
text-align: center;
font-size: 15px;
}
.selectedItem {
color: #3333aa;
font-weight: bold;