diff --git a/conf/venice-db-init-mysql.sql b/conf/venice-db-init-mysql.sql index a16fd45..99b1ee7 100644 --- a/conf/venice-db-init-mysql.sql +++ b/conf/venice-db-init-mysql.sql @@ -601,6 +601,8 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES (6, 'bnc.previous', '!Previous' ), (6, 'bn.reminder', '!reminder.jpg' ), (6, 'bnc.reminder', '!Reminder' ), + (6, 'bn.remove', '!remove.jpg' ), + (6, 'bnc.remove', '!Remove' ), (6, 'bn.search', '!search.jpg' ), (6, 'bnc.search', '!Search' ), (6, 'bn.send.again', '!send_again.jpg' ), @@ -936,6 +938,7 @@ INSERT INTO ace (aceid, pri, flags) VALUES (9, 2, 0); INSERT INTO acldata (aclid, seq, aceid) VALUES (5, 1, 9); INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES (9, 14, 'grant.revoke.access'), + (9, 14, 'manage.services' ), (9, 15, 'set.category' ), (9, 15, 'set.visibility' ), (9, 15, 'set.name' ), @@ -947,6 +950,7 @@ INSERT INTO ace (aceid, pri, flags) VALUES (10, 5, 1); INSERT INTO acldata (aclid, seq, aceid) VALUES (5, 2, 10); INSERT INTO acedata (aceid, perm_nsid, perm_name) VALUES (10, 14, 'grant.revoke.access'), + (10, 14, 'manage.services' ), (10, 15, 'set.category' ), (10, 15, 'set.visibility' ), (10, 15, 'set.name' ), @@ -1423,7 +1427,8 @@ 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, 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'); # 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 a960c18..679b05c 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityImpl.java @@ -31,6 +31,7 @@ import com.silverwrist.dynamo.util.*; import com.silverwrist.venice.CommunityVisibility; import com.silverwrist.venice.VeniceNamespaces; import com.silverwrist.venice.event.*; +import com.silverwrist.venice.except.*; import com.silverwrist.venice.iface.*; /** @@ -1120,4 +1121,79 @@ class CommunityImpl implements VeniceCommunity } // end getServices + public boolean isUsingService(String namespace, String name) throws DatabaseException + { + return m_ops.isUsingService(m_id,m_nscache.namespaceNameToId(namespace),name); + + } // end isUsingService + + public synchronized void addService(DynamoUser caller, Request req, String namespace, String name) + throws DatabaseException, DynamoSecurityException, CommunityServiceException + { + testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"manage.services","auth.addService"); + int nsid = m_nscache.namespaceNameToId(namespace); + if (m_ops.isUsingService(m_id,nsid,name)) + { // we're already using this service - throw an exception + CommunityServiceException cse = new CommunityServiceException(CommunityImpl.class,"CommunityMessages", + "svc.already.using"); + cse.setParameter(0,namespace); + cse.setParameter(1,name); + throw cse; + + } // end if + + CommunityServiceDescriptor descr = m_base.getServiceForName(namespace,name); + if (descr==null) + { // this service is not defined - throw an exception + CommunityServiceException cse = new CommunityServiceException(CommunityImpl.class,"CommunityMessages", + "svc.notFound"); + cse.setParameter(0,namespace); + cse.setParameter(1,name); + throw cse; + + } // end if + + descr.getController().addServiceToCommunity(req,this); + m_ops.addService(m_id,nsid,name); + m_service_list = null; + + } // end addService + + public void removeService(DynamoUser caller, Request req, String namespace, String name) + throws DatabaseException, DynamoSecurityException, CommunityServiceException + { + testPermission(caller,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"manage.services","auth.removeService"); + int nsid = m_nscache.namespaceNameToId(namespace); + synchronized (this) + { // see if we're using this service + if (!(m_ops.isUsingService(m_id,nsid,name))) + { // we're not using this service - throw an exception + CommunityServiceException cse = new CommunityServiceException(CommunityImpl.class,"CommunityMessages", + "svc.not.using"); + cse.setParameter(0,namespace); + cse.setParameter(1,name); + throw cse; + + } // end if + + CommunityServiceDescriptor descr = m_base.getServiceForName(namespace,name); + if (descr==null) + { // this service is not defined - throw an exception + CommunityServiceException cse = new CommunityServiceException(CommunityImpl.class,"CommunityMessages", + "svc.notFound"); + cse.setParameter(0,namespace); + cse.setParameter(1,name); + throw cse; + + } // end if + + descr.getController().removeServiceFromCommunity(req,this); + m_ops.removeService(m_id,nsid,name); + m_service_list = null; + + } // end synchronized block + + } // end removeService + } // end class CommunityImpl + diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityManager.java b/src/venice-base/com/silverwrist/venice/community/CommunityManager.java index ae7d902..9aca1ac 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityManager.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityManager.java @@ -660,6 +660,12 @@ public class CommunityManager } // end getServiceForID + public CommunityServiceDescriptor getServiceForName(String namespace, String name) + { + return (CommunityServiceDescriptor)(m_qname_to_service.get(new QualifiedNameKey(namespace,name))); + + } // end getServiceForName + /*-------------------------------------------------------------------------------- * Implementations from interface CommunityProxyService *-------------------------------------------------------------------------------- diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityMessages.properties b/src/venice-base/com/silverwrist/venice/community/CommunityMessages.properties index bd08a0b..35a093b 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityMessages.properties +++ b/src/venice-base/com/silverwrist/venice/community/CommunityMessages.properties @@ -34,3 +34,8 @@ join.authFail=Unable to authenticate to community "{0}"; cannot join. svc.modname.mismatch=The name of the service module "{0}" did not match the name stored in the database. svc.object.badType=The service controller object {0}::{1} was of the wrong type. auth.unjoin=You are not permitted to unjoin community "{0}." +svc.already.using=This community is already using the service {0}::{1}. +svc.not.using=This community is not using the service {0}::{1}. +svc.notFound=No service is defined with the name {0}::{1}. +auth.addService=You are not authorized to add services to community "{0}." +auth.removeService=You are not authorized to remove services from community "{0}." diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityOps.java b/src/venice-base/com/silverwrist/venice/community/CommunityOps.java index 8cc04c6..4791bf9 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityOps.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityOps.java @@ -82,4 +82,10 @@ abstract class CommunityOps extends OpsBase abstract int[] getServiceIDs(int cid) throws DatabaseException; + abstract boolean isUsingService(int cid, int nsid, String name) throws DatabaseException; + + abstract void addService(int cid, int nsid, String name) throws DatabaseException; + + abstract void removeService(int cid, int nsid, String name) 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 b27992c..06517f6 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityOps_mysql.java @@ -1085,4 +1085,142 @@ class CommunityOps_mysql extends CommunityOps } // end getServiceIDs + boolean isUsingService(int cid, int nsid, String name) 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 c.svcid FROM commsvc c, commsvc_master m WHERE c.cid = ? " + + "AND c.svcid = m.svcid AND m.svc_nsid = ? AND m.svc_name = ?;"); + stmt.setInt(1,cid); + stmt.setInt(2,nsid); + stmt.setString(3,name); + rs = stmt.executeQuery(); + return rs.next(); + + } // 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 isUsingService + + void addService(int cid, int nsid, String name) throws DatabaseException + { + Connection conn = null; + PreparedStatement stmt = null; + Statement stmt2 = null; + ResultSet rs = null; + try + { // get a connection + conn = getConnection(); + + // lock the tables + stmt2 = conn.createStatement(); + stmt2.executeUpdate("LOCK TABLES commsvc WRITE, commsvc_master READ;"); + + // get the index for the service + stmt = conn.prepareStatement("SELECT svcid FROM commsvc_master WHERE svc_nsid = ? AND svc_name = ?;"); + stmt.setInt(1,nsid); + stmt.setString(2,name); + rs = stmt.executeQuery(); + int ndx = -1; + if (rs.next()) + ndx = rs.getInt(1); + else + return; + rs.close(); + rs = null; + stmt.close(); + + // Insert the record into the table. + stmt = conn.prepareStatement("INSERT INTO commsvc (cid, svcid) VALUES (?, ?);"); + stmt.setInt(1,cid); + stmt.setInt(2,ndx); + stmt.executeUpdate(); + + } // end try + catch (SQLException e) + { // translate to a general DatabaseException + throw generalException(e); + + } // end catch + finally + { // shut everything down + MySQLUtils.unlockTables(conn); + SQLUtils.shutdown(rs); + SQLUtils.shutdown(stmt); + SQLUtils.shutdown(stmt2); + SQLUtils.shutdown(conn); + + } // end finally + + } // end addService + + void removeService(int cid, int nsid, String name) throws DatabaseException + { + Connection conn = null; + PreparedStatement stmt = null; + Statement stmt2 = null; + ResultSet rs = null; + try + { // get a connection + conn = getConnection(); + + // lock the tables + stmt2 = conn.createStatement(); + stmt2.executeUpdate("LOCK TABLES commsvc WRITE, commsvc_master READ;"); + + // get the index for the service + stmt = conn.prepareStatement("SELECT svcid FROM commsvc_master WHERE svc_nsid = ? AND svc_name = ?;"); + stmt.setInt(1,nsid); + stmt.setString(2,name); + rs = stmt.executeQuery(); + int ndx = -1; + if (rs.next()) + ndx = rs.getInt(1); + else + return; + rs.close(); + rs = null; + stmt.close(); + + // delete the record from the table + stmt = conn.prepareStatement("DELETE FROM commsvc WHERE cid = ? AND svcid = ?;"); + stmt.setInt(1,cid); + stmt.setInt(2,ndx); + stmt.executeUpdate(); + + } // end try + catch (SQLException e) + { // translate to a general DatabaseException + throw generalException(e); + + } // end catch + finally + { // shut everything down + MySQLUtils.unlockTables(conn); + SQLUtils.shutdown(rs); + SQLUtils.shutdown(stmt); + SQLUtils.shutdown(stmt2); + SQLUtils.shutdown(conn); + + } // end finally + + } // end removeService + } // 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 0e573c5..4e0beef 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityProxy.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityProxy.java @@ -23,6 +23,7 @@ import java.util.*; import com.silverwrist.dynamo.except.*; import com.silverwrist.dynamo.iface.*; import com.silverwrist.venice.CommunityVisibility; +import com.silverwrist.venice.except.*; import com.silverwrist.venice.iface.*; /** @@ -621,6 +622,26 @@ abstract class CommunityProxy implements VeniceCommunity, DynamicWrapper } // end getServices + public boolean isUsingService(String namespace, String name) throws DatabaseException + { + return getRealCommunity().isUsingService(namespace,name); + + } // end isUsingService + + public void addService(DynamoUser caller, Request req, String namespace, String name) + throws DatabaseException, DynamoSecurityException, CommunityServiceException + { + getRealCommunity().addService(caller,req,namespace,name); + + } // end addService + + public void removeService(DynamoUser caller, Request req, String namespace, String name) + throws DatabaseException, DynamoSecurityException, CommunityServiceException + { + getRealCommunity().removeService(caller,req,namespace,name); + + } // end removeService + /*-------------------------------------------------------------------------------- * Implementations from interface DynamicWrapper *-------------------------------------------------------------------------------- diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityService.java b/src/venice-base/com/silverwrist/venice/community/CommunityService.java index 9f4f705..b15221b 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityService.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityService.java @@ -54,4 +54,6 @@ public interface CommunityService public CommunityServiceDescriptor getServiceForID(int id); + public CommunityServiceDescriptor getServiceForName(String namespace, String name); + } // end interface CommunityService diff --git a/src/venice-base/com/silverwrist/venice/iface/CommunityServiceController.java b/src/venice-base/com/silverwrist/venice/iface/CommunityServiceController.java index 6628e67..f0047d4 100644 --- a/src/venice-base/com/silverwrist/venice/iface/CommunityServiceController.java +++ b/src/venice-base/com/silverwrist/venice/iface/CommunityServiceController.java @@ -17,11 +17,20 @@ */ package com.silverwrist.venice.iface; +import com.silverwrist.dynamo.except.DatabaseException; import com.silverwrist.dynamo.iface.ComponentShutdown; import com.silverwrist.dynamo.iface.DynamicObject; +import com.silverwrist.dynamo.iface.Request; +import com.silverwrist.venice.except.CommunityServiceException; public interface CommunityServiceController extends DynamicObject, ComponentShutdown { public String getDescription(); + public void addServiceToCommunity(Request req, VeniceCommunity comm) + throws DatabaseException, CommunityServiceException; + + public void removeServiceFromCommunity(Request req, VeniceCommunity comm) + throws DatabaseException, CommunityServiceException; + } // end interface CommunityServiceController diff --git a/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java b/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java index 6e63935..98399d5 100644 --- a/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java +++ b/src/venice-base/com/silverwrist/venice/iface/VeniceCommunity.java @@ -28,8 +28,10 @@ import com.silverwrist.dynamo.iface.DynamoAcl; import com.silverwrist.dynamo.iface.DynamoGroup; import com.silverwrist.dynamo.iface.DynamoUser; import com.silverwrist.dynamo.iface.NamedObject; +import com.silverwrist.dynamo.iface.Request; import com.silverwrist.dynamo.iface.SecureObjectStore; import com.silverwrist.venice.CommunityVisibility; +import com.silverwrist.venice.except.CommunityServiceException; /** * The interface representing a top-level community object. A community is the primary unit of @@ -318,4 +320,12 @@ public interface VeniceCommunity extends NamedObject, SecureObjectStore public List getServices() throws DatabaseException; + public boolean isUsingService(String namespace, String name) throws DatabaseException; + + public void addService(DynamoUser caller, Request req, String namespace, String name) + throws DatabaseException, DynamoSecurityException, CommunityServiceException; + + public void removeService(DynamoUser caller, Request req, String namespace, String name) + throws DatabaseException, DynamoSecurityException, CommunityServiceException; + } // end interface VeniceCommunity diff --git a/src/venice-base/com/silverwrist/venice/script/LibraryVeniceCast.java b/src/venice-base/com/silverwrist/venice/script/LibraryVeniceCast.java index 7a4ce77..8d01ede 100644 --- a/src/venice-base/com/silverwrist/venice/script/LibraryVeniceCast.java +++ b/src/venice-base/com/silverwrist/venice/script/LibraryVeniceCast.java @@ -23,6 +23,7 @@ import com.silverwrist.dynamo.iface.*; import com.silverwrist.venice.app.AdvancedUserService; import com.silverwrist.venice.community.CategoryService; import com.silverwrist.venice.community.CommunityService; +import com.silverwrist.venice.community.CommunityServiceDescriptor; import com.silverwrist.venice.iface.*; import com.silverwrist.venice.sidebox.SideboxDescriptor; import com.silverwrist.venice.sidebox.SideboxService; @@ -139,6 +140,14 @@ public class LibraryVeniceCast } // end queryUserDefaultPropertyNamespace + public final CommunityServiceDescriptor toCommunityServiceDescriptor(Object obj) + { + if (obj instanceof CommunityServiceDescriptor) + return (CommunityServiceDescriptor)obj; + throw new ClassCastException("LibraryVeniceCast.toCommunityServiceDescriptor: invalid cast"); + + } // end toCommunityServiceDescriptor + public final SideboxDescriptor toSideboxDescriptor(Object obj) { if (obj instanceof SideboxDescriptor) diff --git a/venice-data/scripts/comm/admin/services.js b/venice-data/scripts/comm/admin/services.js new file mode 100644 index 0000000..f65b071 --- /dev/null +++ b/venice-data/scripts/comm/admin/services.js @@ -0,0 +1,64 @@ +// 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.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.content); +importPackage(Packages.com.silverwrist.venice.frame); +importPackage(Packages.com.silverwrist.venice.iface); + +req = bsf.lookupBean("request"); +req_help = bsf.lookupBean("request_help"); +user = vlib.getUser(req); +comm = vlib.getCommunity(req); + +// Make sure we are permitted to be here. +acl = comm.getAcl(); +if (!(acl.testPermission(user,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"manage.services"))) + dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error", + "You are not permitted to modify this community's services.")); + +// Get the community service object. +commsvc = vcast.queryCommunityService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"communities")); + +// Get the currently-defined list of community services. +svclist = commsvc.getAvailableServices(); + +// Use that to create a list of which services we have and which services we don't. +mainlist = new ArrayList(); +it = svclist.iterator(); +while (it.hasNext()) +{ // create list entries and add them + csd = vcast.toCommunityServiceDescriptor(it.next()); + tmp = new HashMap(); + tmp.put("id",cast.toIntegerObject(csd.index)); + tmp.put("descr",csd.description); + tmp.put("using",cast.toBooleanObject(comm.isUsingService(csd.name.namespace,csd.name.name))); + mainlist.add(tmp); + +} // end while + +// Create and return the view. +rc = new VelocityView(comm.name + ": Community Services","comm/admin/services.vm"); +rc.setParameter("community",comm); +rc.setParameter("services",mainlist); +dynamo.scriptOutput(rc); diff --git a/venice-data/scripts/comm/admin/svc_add.js b/venice-data/scripts/comm/admin/svc_add.js new file mode 100644 index 0000000..26cfdd0 --- /dev/null +++ b/venice-data/scripts/comm/admin/svc_add.js @@ -0,0 +1,55 @@ +// 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.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.content); +importPackage(Packages.com.silverwrist.venice.frame); +importPackage(Packages.com.silverwrist.venice.iface); + +req = bsf.lookupBean("request"); +req_help = bsf.lookupBean("request_help"); +user = vlib.getUser(req); +comm = vlib.getCommunity(req); + +// Make sure we are permitted to be here. +acl = comm.getAcl(); +if (!(acl.testPermission(user,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"manage.services"))) + dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error", + "You are not permitted to modify this community's services.")); + +// Get the community service object. +commsvc = vcast.queryCommunityService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"communities")); + +// Get the service index. +ndx = req_help.getParameterInt("id",-1); + +// Work from there to the service descriptor. +csd = commsvc.getServiceForID(ndx); +if (csd==null) + dynamo.scriptReturn(vlib.stdErrorBox(req,"Internal Error","Service descriptor not found.")); + +// Now add the service! +comm.addService(user,req,csd.name.namespace,csd.name.name); + +// Bounce back to the services list. +dynamo.scriptOutput(new Redirect("SERVLET","comm/admin/services.js.vs")); diff --git a/venice-data/scripts/comm/admin/svc_remove.js b/venice-data/scripts/comm/admin/svc_remove.js new file mode 100644 index 0000000..9dc93e9 --- /dev/null +++ b/venice-data/scripts/comm/admin/svc_remove.js @@ -0,0 +1,70 @@ +// 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.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.content); +importPackage(Packages.com.silverwrist.venice.frame); +importPackage(Packages.com.silverwrist.venice.iface); + +req = bsf.lookupBean("request"); +req_help = bsf.lookupBean("request_help"); +user = vlib.getUser(req); +comm = vlib.getCommunity(req); + +// Make sure we are permitted to be here. +acl = comm.getAcl(); +if (!(acl.testPermission(user,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"manage.services"))) + dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error", + "You are not permitted to modify this community's services.")); + +// Get the community service object. +commsvc = vcast.queryCommunityService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"communities")); + +// Get the service index. +ndx = req_help.getParameterInt("id",-1); + +// Work from there to the service descriptor. +csd = commsvc.getServiceForID(ndx); +if (csd==null) + dynamo.scriptReturn(vlib.stdErrorBox(req,"Internal Error","Service descriptor not found.")); + +rc = null; +if (vlib.confirmed(req,"/comm/admin/svc_remove.js.vs","confirmation","confnum")) +{ // remove the service! + comm.removeService(user,req,csd.name.namespace,csd.name.name); + rc = new Redirect("SERVLET","comm/admin/services.js.vs"); + +} // end if +else +{ // create the confirmation dialog + msg = "You are about to remove the service " + csd.name.namespace + "::" + csd.name.name + " from the community '" + + comm.name + "'! This may cause any and all data associated with this service in the community (such as " + + "database table contents) to be DESTROYED AND IRREVOCABLY LOST! Are you really sure you " + + "want to do this?"; + rc = new ConfirmBox(req,"/comm/admin/svc_remove.js.vs","confirmation","confnum","Service Remove Confirmation",msg, + "SERVLET","comm/admin/svc_remove.js.vs?cc=" + comm.getCID() + "&id=" + ndx,"SERVLET", + "comm/admin/services.js.vs"); + +} // end else + +dynamo.scriptOutput(rc); diff --git a/venice-data/velocity/comm/admin/services.vm b/venice-data/velocity/comm/admin/services.vm new file mode 100644 index 0000000..9ee9b70 --- /dev/null +++ b/venice-data/velocity/comm/admin/services.vm @@ -0,0 +1,63 @@ +#* + 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): +*# +#* + Parameters: + community = Community we're displaying the services of. + services = List of all available services, with an indication as to whether we're using them. +*# +#header2( "Community Services", $community.Name ) +

Return to Previous Menu

+#if( $services.isEmpty() ) +

There are no community-level services currently defined.

+#else +

Your community may make use of any or all of the following services. Click the appropriate buttons to + add or remove services for your community.

+
+ + + + + + #set( $cid = $community.getCID() ) + #foreach( $s in $services ) + + + + + + #end +
In Use?Service Description 
+ #if( $s.using ) + Yes + #else +   + #end + + #if( $s.using ) + #encodeHTML( $s.descr ) + #else + #encodeHTML( $s.descr ) + #end + + #if( $s.using ) + #button( "IMAGE" "remove" ) + #else + #button( "IMAGE" "add" ) + #end +
+#end