diff --git a/conf/venice-db-init-mysql.sql b/conf/venice-db-init-mysql.sql index 00a0a8d..90717a8 100644 --- a/conf/venice-db-init-mysql.sql +++ b/conf/venice-db-init-mysql.sql @@ -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) diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java b/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java index 679b05c..468f9f9 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java @@ -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 diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityOps.java b/src/venice-base/com/silverwrist/venice/community/CommunityOps.java index 4791bf9..582293a 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityOps.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityOps.java @@ -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 diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java b/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java index 06517f6..98efc27 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java @@ -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 diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityProxy.java b/src/venice-base/com/silverwrist/venice/community/CommunityProxy.java index 4e0beef..6ce5e46 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityProxy.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityProxy.java @@ -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 *-------------------------------------------------------------------------------- diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityServiceDescriptor.java b/src/venice-base/com/silverwrist/venice/community/CommunityServiceDescriptor.java index 31246ac..2ce5053 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityServiceDescriptor.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityServiceDescriptor.java @@ -66,6 +66,12 @@ public final class CommunityServiceDescriptor } // end getController + String getShortVar() + { + return m_shortvar; + + } // end getShortVar + /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- diff --git a/src/venice-base/com/silverwrist/venice/frame/FrameAssembler.java b/src/venice-base/com/silverwrist/venice/frame/FrameAssembler.java index 4bdf19f..f7747bc 100644 --- a/src/venice-base/com/silverwrist/venice/frame/FrameAssembler.java +++ b/src/venice-base/com/silverwrist/venice/frame/FrameAssembler.java @@ -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 diff --git a/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java b/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java index 98399d5..6eb15b8 100644 --- a/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java +++ b/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java @@ -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 diff --git a/src/venice-base/com/silverwrist/venice/util/CommunityMenuInstaller.java b/src/venice-base/com/silverwrist/venice/util/CommunityMenuInstaller.java index 5f7a9ab..9c2c8ab 100644 --- a/src/venice-base/com/silverwrist/venice/util/CommunityMenuInstaller.java +++ b/src/venice-base/com/silverwrist/venice/util/CommunityMenuInstaller.java @@ -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 diff --git a/venice-data/scripts/comm/admin/modadmin.js b/venice-data/scripts/comm/admin/modadmin.js new file mode 100644 index 0000000..ef65613 --- /dev/null +++ b/venice-data/scripts/comm/admin/modadmin.js @@ -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 . +// +// 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 , +// 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);