added community logo support and the logo on top of the community left menu;
fixed some bugs with menu handling
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
<dialog name="community_profile" defaultbutton="update">
|
||||
<title>Edit Community Profile:</title>
|
||||
<action>comm/admin/profile.js.vs</action>
|
||||
<render-param name="cid"/>
|
||||
<hidden name="cc" value=""/>
|
||||
|
||||
<header name="basic_hdr" caption="Basic Information"/>
|
||||
@@ -28,7 +29,7 @@
|
||||
<text name="rules" caption="Rules" size="32" maxlength="254"/>
|
||||
<languagelist name="language" caption="Primary Language" required="true"/>
|
||||
<text name="url" caption="Home Page" size="32" maxlength="254"/>
|
||||
<!-- <communitylogo name="logo" caption="Community Logo" link="comm/photo.js.vs" type="servlet"/> -->
|
||||
<communitylogo name="logo" caption="Community Logo" link="comm/admin/profile_logo.js.vs?cc=${cid}" type="servlet"/>
|
||||
|
||||
<header name="location_hdr" caption="Location"/>
|
||||
<text name="company" caption="Company" size="32" maxlength="254"/>
|
||||
|
||||
@@ -57,7 +57,16 @@ if (req_help.isVerb("GET"))
|
||||
dlg.setValue("rules",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"rules"));
|
||||
dlg.setValue("language",comm.getObject(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"language"));
|
||||
dlg.setValue("url",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.homepage"));
|
||||
// TODO: set community logo here
|
||||
dlg.setValue("logo",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.logo"));
|
||||
if (dlg.getValue("logo")==null)
|
||||
{ // fill in the "no logo" URL
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
url = globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.nologo.url");
|
||||
urltype = globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.nologo.url.type");
|
||||
rewriter = cast.queryURLRewriter(req);
|
||||
dlg.setValue("logo",rewriter.rewriteURL(urltype,url));
|
||||
|
||||
} // end if
|
||||
|
||||
dlg.setValue("company",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,
|
||||
"company.name"));
|
||||
@@ -94,7 +103,7 @@ else
|
||||
comm.setObject(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"language",dlg.getValue("language"));
|
||||
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.homepage",
|
||||
dlg.getValue("url"));
|
||||
// TODO: deal with community logo
|
||||
// N.B.: community logo is handled elsewhere
|
||||
|
||||
PropertyUtils.setOrRemove(comm,user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"company.name",
|
||||
dlg.getValue("company"));
|
||||
@@ -123,7 +132,23 @@ else
|
||||
etype = dynamo.exceptionType(e) + "";
|
||||
logger.error("Caught exception of type " + etype);
|
||||
if (etype.match(/ValidationException/))
|
||||
{ // validation error...
|
||||
dlg.setErrorMessage(dynamo.exceptionMessage(e) + " Please try again.");
|
||||
|
||||
// have to re-prep the community logo
|
||||
dlg.setValue("logo",PropertyUtils.getPropertyNoErr(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,
|
||||
"url.logo"));
|
||||
if (dlg.getValue("logo")==null)
|
||||
{ // fill in the "no logo" URL
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
url = globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.nologo.url");
|
||||
urltype = globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.nologo.url.type");
|
||||
rewriter = cast.queryURLRewriter(req);
|
||||
dlg.setValue("logo",rewriter.rewriteURL(urltype,url));
|
||||
|
||||
} // end if
|
||||
|
||||
} // end if
|
||||
else if (etype.match(/DatabaseException/))
|
||||
rc = new ErrorBox("Database Error",e,"SERVLET",return_URL);
|
||||
else if (etype.match(/DynamoSecurityException/))
|
||||
@@ -140,7 +165,10 @@ else
|
||||
if (rc==null)
|
||||
{ // output dialog if we don't have another value
|
||||
dlg.setSubtitle(comm.getName());
|
||||
dlg.setRenderParam("cid",comm.getCID() + "");
|
||||
rc = new FrameDialog(dlg);
|
||||
rc.menuSelector = "community";
|
||||
|
||||
} // end if
|
||||
|
||||
dynamo.scriptOutput(rc);
|
||||
|
||||
103
venice-data/scripts/comm/admin/profile_logo.js
Normal file
103
venice-data/scripts/comm/admin/profile_logo.js
Normal file
@@ -0,0 +1,103 @@
|
||||
// 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(Packages.com.silverwrist.util);
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importClass(Packages.com.silverwrist.dynamo.db.ImageStore);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
importPackage(Packages.com.silverwrist.venice.iface);
|
||||
|
||||
req = bsf.lookupBean("request");
|
||||
req_help = bsf.lookupBean("request_help");
|
||||
user = vlib.getUser(req);
|
||||
comm = vlib.getCommunity(req);
|
||||
|
||||
return_URL = "comm/admin/profile.js.vs?cc=" + comm.getCID();
|
||||
|
||||
// Make sure we can actually edit the profile logo.
|
||||
acl = comm.getAcl();
|
||||
if (!(acl.testPermission(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"set.property")))
|
||||
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error",
|
||||
"You are not permitted to modify this community's logo."));
|
||||
|
||||
if (req_help.isVerb("GET"))
|
||||
{ // on GET, display the form
|
||||
view = new VelocityView("Set Community Logo","comm/community_logo.vm");
|
||||
view.setParameter("community",comm);
|
||||
dynamo.scriptReturn(view);
|
||||
|
||||
} // end if
|
||||
|
||||
// everything from this point on is a POST operation
|
||||
if (req_help.isImageButtonClicked("cancel"))
|
||||
dynamo.scriptReturn(new Redirect("SERVLET",return_URL));
|
||||
|
||||
// get the image provider object
|
||||
imgprov = cast.queryImageStore(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"images"));
|
||||
|
||||
// figure out which image ID we have
|
||||
imgid = imgprov.findImageID(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"community.logo",comm.getHostGroup());
|
||||
|
||||
selector = req_help.getParameterString("selector") + "";
|
||||
if (selector=="none")
|
||||
{ // take out the image property and the image
|
||||
if (PropertyUtils.hasProperty(comm,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.logo"))
|
||||
comm.removeObject(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.logo");
|
||||
if (imgid!=-1)
|
||||
imgprov.deleteImage(user,imgid);
|
||||
|
||||
} // end if
|
||||
else if (selector=="set")
|
||||
{ // set the image URL directly, delete the image
|
||||
s = req_help.getParameterString("url");
|
||||
if (stringutils.isEmpty(s))
|
||||
dynamo.scriptReturn(new ErrorBox(null,"No logo URL specified.",return_URL));
|
||||
comm.setObject(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.logo",s);
|
||||
if (imgid!=-1)
|
||||
imgprov.deleteImage(user,imgid);
|
||||
|
||||
} // end else if
|
||||
else if (selector=="upload")
|
||||
{ // take the uploaded image, reformat it, and save it off, then set the image URL
|
||||
input_di = req_help.getDataItem("image");
|
||||
if (input_di==null)
|
||||
dynamo.scriptReturn(new ErrorBox(null,"No uploaded logo specified.",return_URL));
|
||||
mtype = input_di.getMimeType();
|
||||
if (!(mtype.startsWith("image/")))
|
||||
dynamo.scriptReturn(new ErrorBox(null,"Uploaded data item is not an image.",return_URL));
|
||||
globals = vcast.getGlobalPropertiesStore(req);
|
||||
width = cast.toInteger(globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.logo.width"));
|
||||
height = cast.toInteger(globals.getObject(VeniceNamespaces.COMMUNITY_GLOBALS_NAMESPACE,"community.logo.height"));
|
||||
di = imgprov.normalizeImage(input_di,width,height,"image/jpeg");
|
||||
if (imgid!=-1)
|
||||
imgprov.replaceImage(user,imgid,di);
|
||||
else
|
||||
imgid = imgprov.saveNewImage(VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"community.logo",comm.getHostGroup(),di);
|
||||
rewriter = cast.queryURLRewriter(req);
|
||||
comm.setObject(user,VeniceNamespaces.COMMUNITY_PROFILE_NAMESPACE,"url.logo",
|
||||
rewriter.rewriteURL("IMAGEDATA",imgid + ""));
|
||||
|
||||
} // end else if
|
||||
else // return a "No Content" and just leave the dialog box up
|
||||
dynamo.scriptReturn(new NoContent());
|
||||
|
||||
vlib.forceReloadMenu(req); // force the menu to be reloaded
|
||||
|
||||
// All done - bounce back to the Profile dialog
|
||||
dynamo.scriptOutput(new Redirect("SERVLET",return_URL));
|
||||
43
venice-data/velocity/comm/community_logo.vm
Normal file
43
venice-data/velocity/comm/community_logo.vm
Normal file
@@ -0,0 +1,43 @@
|
||||
#*
|
||||
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):
|
||||
*#
|
||||
#*
|
||||
Parameters:
|
||||
community = Community we're setting the logo for.
|
||||
*#
|
||||
#header2( "Set Community Logo:" "${community.Name}" )
|
||||
<form method="POST" enctype="multipart/form-data" action="#formatURL( "SERVLET" "comm/admin/profile_logo.js.vs" )">
|
||||
<input type="hidden" name="cc" value="${community.getCID()}" />
|
||||
<table border="0" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td align="center"><input type="radio" name="selector" value="none" /></td>
|
||||
<td align="left">No logo</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><input type="radio" name="selector" value="set" /></td>
|
||||
<td align="left">Set logo URL:</td>
|
||||
<td align="left"><input type="text" name="url" value="" size="64" maxlength="254" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><input type="radio" name="selector" value="upload" /></td>
|
||||
<td align="left">Upload logo:</td>
|
||||
<td align="left"><input type="file" name="image" value="" size="64" maxlength="254" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
#button( "INPUT" "set" ) #button( "INPUT" "cancel" )
|
||||
</form>
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
Contributor(s):
|
||||
*#
|
||||
#*
|
||||
Parameters:
|
||||
target = Target URL.
|
||||
*#
|
||||
#header1( "Set User Photo" )
|
||||
<form method="POST" enctype="multipart/form-data" action="#formatURL( "SERVLET" "profile_photo.js.vs" )">
|
||||
<input type="hidden" name="tgt" value="$target" />
|
||||
|
||||
Reference in New Issue
Block a user