venice-dynamo-rewrite/venice-data/scripts/comm/admin/svc_remove.js

72 lines
3.3 KiB
JavaScript
Raw Permalink Normal View History

// 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.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);
vlib.forceReloadMenu(req);
rc = new Redirect("SERVLET","comm/admin/services.js.vs?cc=" + comm.getCID());
} // end if
else
{ // create the confirmation dialog
msg = "You are about to remove the service " + stringutils.encodeHTML(csd.name.namespace) + "::"
+ stringutils.encodeHTML(csd.name.name) + " from the community '" + stringutils.encodeHTML(comm.name)
+ "'! This may cause any and all data associated with this service in the community (such as database table "
+ "contents) to be <b>DESTROYED AND IRREVOCABLY LOST!</b> Are you <em>really</em> 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?cc=" + comm.getCID());
} // end else
dynamo.scriptOutput(rc);