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

57 lines
2.5 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."));
// Now add the service!
comm.addService(user,req,csd.name.namespace,csd.name.name);
vlib.forceReloadMenu(req);
// Bounce back to the services list.
dynamo.scriptOutput(new Redirect("SERVLET","comm/admin/services.js.vs?cc=" + comm.getCID()));