added the module service admin menu for communities, the ability to fill in

menu variables for communities, and other stuff to flesh out menu support
This commit is contained in:
Eric J. Bowersox 2003-06-21 03:51:21 +00:00
parent 386f2a1fb6
commit 6c5e8b9f86
10 changed files with 134 additions and 5 deletions

View File

@ -1428,8 +1428,12 @@ INSERT INTO menuvars (menuid, var_name, default_val) VALUES
(7, 'name', NULL),
(7, 'cid', NULL);
INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link, perm_nsid, perm_name) VALUES
(7, 0, 'TEXT', 'Edit Community Profile', 'SERVLET', 'comm/admin/profile.js.vs?cc=${cid}', 15, 'set.property' ),
(7, 1, 'TEXT', 'Set Community Services', 'SERVLET', 'comm/admin/services.js.vs?cc=${cid}', 14, 'manage.services');
(7, 0, 'TEXT', 'Edit Community Profile', 'SERVLET', 'comm/admin/profile.js.vs?cc=${cid}', 15,
'set.property' ),
(7, 1, 'TEXT', 'Set Community Services', 'SERVLET', 'comm/admin/services.js.vs?cc=${cid}', 14,
'manage.services'),
(7, 2, 'TEXT', 'Manage Community Services', 'SERVLET', 'comm/admin/modadmin.js.vs?cc=${cid}', NULL,
NULL );
# Create the sysadmin globals menu. (ID #8)
INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle)

View File

@ -1082,7 +1082,7 @@ class CommunityImpl implements VeniceCommunity
} // end isAdministrator
public List getServices() throws DatabaseException
public synchronized List getServices() throws DatabaseException
{
if (m_service_list==null)
{ // need to fake up the service list
@ -1195,5 +1195,33 @@ class CommunityImpl implements VeniceCommunity
} // end removeService
public void setMenuVariables(MenuRenderObject menu) throws DatabaseException
{
if (m_service_list==null)
{ // have to call down to the database to get the short vars list
Set vars = m_ops.getMenuVars(m_id);
Iterator it = vars.iterator();
while (it.hasNext())
{ // set the variables
String vname = (String)(it.next());
menu.setVariable(vname,vname);
} // end while
} // end if
else
{ // scan the service list and set the variables that way
Iterator it = m_service_list.iterator();
while (it.hasNext())
{ // set the individual variables
CommunityServiceDescriptor csd = (CommunityServiceDescriptor)(it.next());
menu.setVariable(csd.getShortVar(),csd.getShortVar());
} // end while
} // end else
} // end setMenuVariables
} // end class CommunityImpl

View File

@ -88,4 +88,6 @@ abstract class CommunityOps extends OpsBase
abstract void removeService(int cid, int nsid, String name) throws DatabaseException;
abstract Set getMenuVars(int cid) throws DatabaseException;
} // end class CommunityOps

View File

@ -1223,4 +1223,41 @@ class CommunityOps_mysql extends CommunityOps
} // end removeService
Set getMenuVars(int cid) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// create and execute the statement
stmt = conn.prepareStatement("SELECT m.shortvar FROM commsvc_master m, commsvc c WHERE m.svcid = c.svcid "
+ "AND c.cid = ?;");
stmt.setInt(1,cid);
rs = stmt.executeQuery();
// fill in the return value
HashSet rc = new HashSet();
while (rs.next())
rc.add(rs.getString(1));
return rc;
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(conn);
} // end finally
} // end getMenuVars
} // end class CommunityOps_mysql

View File

@ -642,6 +642,12 @@ abstract class CommunityProxy implements VeniceCommunity, DynamicWrapper
} // end removeService
public void setMenuVariables(MenuRenderObject menu) throws DatabaseException
{
getRealCommunity().setMenuVariables(menu);
} // end setMenuVariables
/*--------------------------------------------------------------------------------
* Implementations from interface DynamicWrapper
*--------------------------------------------------------------------------------

View File

@ -66,6 +66,12 @@ public final class CommunityServiceDescriptor
} // end getController
String getShortVar()
{
return m_shortvar;
} // end getShortVar
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------

View File

@ -566,6 +566,7 @@ public class FrameAssembler
floating_menu.setVariable("alias",comm.getAlias());
floating_menu.setVariable("cid",String.valueOf(comm.getCID()));
floating_menu.setVariable("name",comm.getName());
comm.setMenuVariables(floating_menu);
floating_menu = new MyMenuObject(floating_menu,comm);
} // end else if

View File

@ -328,4 +328,6 @@ public interface VeniceCommunity extends NamedObject, SecureObjectStore
public void removeService(DynamoUser caller, Request req, String namespace, String name)
throws DatabaseException, DynamoSecurityException, CommunityServiceException;
public void setMenuVariables(MenuRenderObject menu) throws DatabaseException;
} // end interface VeniceCommunity

View File

@ -79,16 +79,18 @@ public class CommunityMenuInstaller
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link);
new_object.setIfDefVar(shortvar);
menu.addVariable(shortvar,null);
} // end installCommunityServiceEntry
public void removeCommunityServiceEntry(DynamoUser caller, String link_text)
public void removeCommunityServiceEntry(DynamoUser caller, String link_text, String shortvar)
throws DatabaseException, DynamoSecurityException
{
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.menu");
MenuEditItemObject item = menu.getItemContainingLinkText(link_text);
if (item!=null)
item.delete();
menu.removeVariable(shortvar);
} // end removeCommunityServiceEntry
@ -120,10 +122,11 @@ public class CommunityMenuInstaller
MenuEditItemObject new_object = menu.addItem("TEXT",new_sequence,text,linktype,link);
new_object.setPermission(perm_nsid,perm_name);
new_object.setIfDefVar(shortvar);
menu.addVariable(shortvar,null);
} // end installCommunityServiceAdminEntry
public void removeCommunityServiceAdminEntry(DynamoUser caller, String link_text)
public void removeCommunityServiceAdminEntry(DynamoUser caller, String link_text, String shortvar)
throws DatabaseException, DynamoSecurityException
{
MenuEditObject menu = m_provider.getEditMenu(caller,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,
@ -131,6 +134,7 @@ public class CommunityMenuInstaller
MenuEditItemObject item = menu.getItemContainingLinkText(link_text);
if (item!=null)
item.delete();
menu.removeVariable(shortvar);
} // end removeCommunityServiceAdminEntry

View File

@ -0,0 +1,39 @@
// 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.venice.iface);
importPackage(Packages.com.silverwrist.venice.menu);
req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
user = vlib.getUser(req);
comm = vlib.getCommunity(req);
// Get the menu provider and the menu.
mprov = vcast.queryMenuProvider(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-menus"));
srm = cast.querySecurityReferenceMonitor(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"srm"));
aclids = cast.newIntArray(2);
aclids[0] = comm.getAcl().getAclID();
aclids[1] = srm.getGlobalAcl().getAclID();
menu = mprov.getStandardMenu(user,VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.admin.service",aclids);
menu.setVariable("name",comm.getName());
menu.setVariable("cid",comm.getCID() + "");
comm.setMenuVariables(menu);
dynamo.scriptOutput(menu);