added the functionality required to power the Sidebox Configure button on
the Front Page
This commit is contained in:
parent
d6bff8a745
commit
c5e689483d
|
@ -313,8 +313,9 @@ CREATE TABLE sbox_master (
|
||||||
sb_name VARCHAR(255) BINARY NOT NULL, # name of the sidebox
|
sb_name VARCHAR(255) BINARY NOT NULL, # name of the sidebox
|
||||||
type_nsid INT NOT NULL, # namespace ID of the type of the sidebox
|
type_nsid INT NOT NULL, # namespace ID of the type of the sidebox
|
||||||
type_name VARCHAR(255) BINARY NOT NULL, # name of the type of the sidebox
|
type_name VARCHAR(255) BINARY NOT NULL, # name of the type of the sidebox
|
||||||
descr TINYTEXT NOT NULL, # description of the sidebox
|
descr VARCHAR(255) NOT NULL, # description of the sidebox
|
||||||
UNIQUE INDEX by_name (sb_nsid, sb_name)
|
UNIQUE INDEX by_name (sb_nsid, sb_name),
|
||||||
|
INDEX by_descr (descr)
|
||||||
);
|
);
|
||||||
|
|
||||||
# This table indicates in what contexts a sidebox may be used.
|
# This table indicates in what contexts a sidebox may be used.
|
||||||
|
@ -414,6 +415,8 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
|
||||||
(6, 'std.button.height', 'I24' ),
|
(6, 'std.button.height', 'I24' ),
|
||||||
(6, 'bn.0transparent', '!transparent.gif' ),
|
(6, 'bn.0transparent', '!transparent.gif' ),
|
||||||
(6, 'bnc.0transparent', '!' ),
|
(6, 'bnc.0transparent', '!' ),
|
||||||
|
(6, 'bn.add', '!add.jpg' ),
|
||||||
|
(6, 'bnc.add', '!Add' ),
|
||||||
(6, 'bn.cancel', '!cancel.jpg' ),
|
(6, 'bn.cancel', '!cancel.jpg' ),
|
||||||
(6, 'bnc.cancel', '!Cancel' ),
|
(6, 'bnc.cancel', '!Cancel' ),
|
||||||
(6, 'bn.configure', '!configure.jpg' ),
|
(6, 'bn.configure', '!configure.jpg' ),
|
||||||
|
|
|
@ -24,6 +24,7 @@ import com.silverwrist.venice.app.AdvancedUserService;
|
||||||
import com.silverwrist.venice.community.CategoryService;
|
import com.silverwrist.venice.community.CategoryService;
|
||||||
import com.silverwrist.venice.community.CommunityService;
|
import com.silverwrist.venice.community.CommunityService;
|
||||||
import com.silverwrist.venice.iface.*;
|
import com.silverwrist.venice.iface.*;
|
||||||
|
import com.silverwrist.venice.sidebox.SideboxDescriptor;
|
||||||
import com.silverwrist.venice.sidebox.SideboxService;
|
import com.silverwrist.venice.sidebox.SideboxService;
|
||||||
|
|
||||||
public class LibraryVeniceCast
|
public class LibraryVeniceCast
|
||||||
|
@ -138,4 +139,12 @@ public class LibraryVeniceCast
|
||||||
|
|
||||||
} // end queryUserDefaultPropertyNamespace
|
} // end queryUserDefaultPropertyNamespace
|
||||||
|
|
||||||
|
public final SideboxDescriptor toSideboxDescriptor(Object obj)
|
||||||
|
{
|
||||||
|
if (obj instanceof SideboxDescriptor)
|
||||||
|
return (SideboxDescriptor)obj;
|
||||||
|
throw new ClassCastException("LibraryVeniceCast.toSideboxDescriptor: invalid cast");
|
||||||
|
|
||||||
|
} // end toSideboxDescriptor
|
||||||
|
|
||||||
} // end class LibraryVeniceCast
|
} // end class LibraryVeniceCast
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* 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):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.venice.sidebox;
|
||||||
|
|
||||||
|
public class SideboxDescriptor
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private int m_sbid;
|
||||||
|
private String m_descr;
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
SideboxDescriptor(int sbid, String descr)
|
||||||
|
{
|
||||||
|
m_sbid = sbid;
|
||||||
|
m_descr = descr;
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Public getters
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public int getID()
|
||||||
|
{
|
||||||
|
return m_sbid;
|
||||||
|
|
||||||
|
} // end getID
|
||||||
|
|
||||||
|
public String getDescription()
|
||||||
|
{
|
||||||
|
return m_descr;
|
||||||
|
|
||||||
|
} // end getDescription
|
||||||
|
|
||||||
|
} // end class SideboxDescriptor
|
|
@ -357,4 +357,52 @@ public class SideboxManager implements NamedObject, ComponentInitialize, Compone
|
||||||
|
|
||||||
} // end getSideboxes
|
} // end getSideboxes
|
||||||
|
|
||||||
|
public List getSideboxDescriptors(DynamoUser user, String context_namespace, String context_name,
|
||||||
|
Object context_param) throws DatabaseException
|
||||||
|
{
|
||||||
|
List rc = m_ops.getSideboxDescriptors(user.getUID(),m_ns_cache.namespaceNameToId(context_namespace),context_name,
|
||||||
|
context_param);
|
||||||
|
if (rc.isEmpty())
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
return Collections.unmodifiableList(rc);
|
||||||
|
|
||||||
|
} // end getSideboxDescriptors
|
||||||
|
|
||||||
|
public List getAllSideboxDescriptors(String context_namespace, String context_name) throws DatabaseException
|
||||||
|
{
|
||||||
|
List rc = m_ops.getAllSideboxDescriptors(m_ns_cache.namespaceNameToId(context_namespace),context_name);
|
||||||
|
if (rc.isEmpty())
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
return Collections.unmodifiableList(rc);
|
||||||
|
|
||||||
|
} // end getAllSideboxDescriptors
|
||||||
|
|
||||||
|
public void moveSideboxItemToPosition(DynamoUser user, String context_namespace, String context_name,
|
||||||
|
Object context_param, int sbid, int new_pos) throws DatabaseException
|
||||||
|
{
|
||||||
|
m_ops.moveSideboxItemToPosition(user.getUID(),m_ns_cache.namespaceNameToId(context_namespace),context_name,
|
||||||
|
context_param,sbid,new_pos);
|
||||||
|
|
||||||
|
} // end moveSideboxItemToPosition
|
||||||
|
|
||||||
|
public void removeSidebox(DynamoUser user, String context_namespace, String context_name, Object context_param,
|
||||||
|
int sbid) throws DatabaseException
|
||||||
|
{
|
||||||
|
m_ops.removeSidebox(user.getUID(),m_ns_cache.namespaceNameToId(context_namespace),context_name,context_param,sbid);
|
||||||
|
|
||||||
|
} // end removeSidebox
|
||||||
|
|
||||||
|
public void addSidebox(DynamoUser user, String context_namespace, String context_name, Object context_param,
|
||||||
|
int sbid) throws DatabaseException
|
||||||
|
{
|
||||||
|
m_ops.addSidebox(user.getUID(),m_ns_cache.namespaceNameToId(context_namespace),context_name,context_param,sbid);
|
||||||
|
|
||||||
|
} // end addSidebox
|
||||||
|
|
||||||
|
public void copyUserConfig(DynamoUser from, DynamoUser to) throws DatabaseException
|
||||||
|
{
|
||||||
|
m_ops.copyUserConfig(from.getUID(),to.getUID());
|
||||||
|
|
||||||
|
} // end copyUserConfig
|
||||||
|
|
||||||
} // end class SideboxManager
|
} // end class SideboxManager
|
||||||
|
|
|
@ -19,3 +19,6 @@ context.param.ser=Unable to serialize context parameter of class {0}.
|
||||||
no.sidebox=Unable to find definition for sidebox with ID #{0}.
|
no.sidebox=Unable to find definition for sidebox with ID #{0}.
|
||||||
property.deserialize=The value of property "{0}" could not be deserialized.
|
property.deserialize=The value of property "{0}" could not be deserialized.
|
||||||
no.sbtype=Unable to find sidebox type factory for type namespace {0}, name {1}.
|
no.sbtype=Unable to find sidebox type factory for type namespace {0}, name {1}.
|
||||||
|
sbox.not.in.list=The sidebox with ID #{0} does not exist in the current list.
|
||||||
|
sbox.already.in.list=The sidebox with ID #{0} already exists in the current list.
|
||||||
|
sbox.impermissible=The sidebox with ID #{0} is not permitted in the current list.
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package com.silverwrist.venice.sidebox;
|
package com.silverwrist.venice.sidebox;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
import com.silverwrist.dynamo.db.OpsBase;
|
import com.silverwrist.dynamo.db.OpsBase;
|
||||||
import com.silverwrist.dynamo.except.*;
|
import com.silverwrist.dynamo.except.*;
|
||||||
import com.silverwrist.dynamo.iface.*;
|
import com.silverwrist.dynamo.iface.*;
|
||||||
|
@ -49,6 +50,22 @@ abstract class SideboxOps extends OpsBase
|
||||||
|
|
||||||
abstract Object getSideboxProperty(int sbid, PropertyKey key) throws DatabaseException;
|
abstract Object getSideboxProperty(int sbid, PropertyKey key) throws DatabaseException;
|
||||||
|
|
||||||
|
abstract List getSideboxDescriptors(int uid, int context_nsid, String context_name, Object context_param)
|
||||||
|
throws DatabaseException;
|
||||||
|
|
||||||
|
abstract List getAllSideboxDescriptors(int context_nsid, String context_name) throws DatabaseException;
|
||||||
|
|
||||||
|
abstract void moveSideboxItemToPosition(int uid, int context_nsid, String context_name, Object context_param,
|
||||||
|
int sbid, int new_pos) throws DatabaseException;
|
||||||
|
|
||||||
|
abstract void removeSidebox(int uid, int context_nsid, String context_name, Object context_param, int sbid)
|
||||||
|
throws DatabaseException;
|
||||||
|
|
||||||
|
abstract void addSidebox(int uid, int context_nsid, String context_name, Object context_param, int sbid)
|
||||||
|
throws DatabaseException;
|
||||||
|
|
||||||
|
abstract void copyUserConfig(int uid_from, int uid_to) throws DatabaseException;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* External static operations
|
* External static operations
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
|
|
|
@ -301,4 +301,560 @@ public class SideboxOps_mysql extends SideboxOps
|
||||||
|
|
||||||
} // end getSideboxProperty
|
} // end getSideboxProperty
|
||||||
|
|
||||||
|
List getSideboxDescriptors(int uid, int context_nsid, String context_name, Object context_param)
|
||||||
|
throws DatabaseException
|
||||||
|
{
|
||||||
|
String context_param_ser = serializeContextParam(context_param);
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{ // get a connection
|
||||||
|
conn = getConnection();
|
||||||
|
|
||||||
|
// create and execute the statement
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("SELECT m.sbid, m.descr FROM sbox_deploy d, sbox_master m WHERE m.sbid = d.sbid "
|
||||||
|
+ "AND d.uid = ? AND d.ctx_nsid = ? AND d.ctx_name = ? AND d.param IS NULL "
|
||||||
|
+ "ORDER BY d.seq;");
|
||||||
|
else
|
||||||
|
{ // use the version with the parameter
|
||||||
|
stmt = conn.prepareStatement("SELECT m.sbid, m.descr FROM sbox_deploy d, sbox_master m WHERE m.sbid = d.sbid "
|
||||||
|
+ "AND d.uid = ? AND d.ctx_nsid = ? AND d.ctx_name = ? AND d.param = ? "
|
||||||
|
+ "ORDER BY d.seq;");
|
||||||
|
stmt.setString(4,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,uid);
|
||||||
|
stmt.setInt(2,context_nsid);
|
||||||
|
stmt.setString(3,context_name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
// Build the return list.
|
||||||
|
ArrayList rc = new ArrayList();
|
||||||
|
while (rs.next())
|
||||||
|
rc.add(new SideboxDescriptor(rs.getInt(1),rs.getString(2)));
|
||||||
|
rc.trimToSize();
|
||||||
|
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 getSideboxDescriptors
|
||||||
|
|
||||||
|
List getAllSideboxDescriptors(int context_nsid, String context_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 m.sbid, m.descr FROM sbox_master m, sbox_context c WHERE m.sbid = c.sbid "
|
||||||
|
+ "AND c.ctx_nsid = ? AND c.ctx_name = ? ORDER BY m.descr");
|
||||||
|
stmt.setInt(1,context_nsid);
|
||||||
|
stmt.setString(2,context_name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
// Build the return list.
|
||||||
|
ArrayList rc = new ArrayList();
|
||||||
|
while (rs.next())
|
||||||
|
rc.add(new SideboxDescriptor(rs.getInt(1),rs.getString(2)));
|
||||||
|
rc.trimToSize();
|
||||||
|
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 getAllSideboxDescriptors
|
||||||
|
|
||||||
|
void moveSideboxItemToPosition(int uid, int context_nsid, String context_name, Object context_param, int sbid,
|
||||||
|
int new_pos) throws DatabaseException
|
||||||
|
{
|
||||||
|
String context_param_ser = serializeContextParam(context_param);
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
Statement stmt2 = null;
|
||||||
|
PreparedStatement stmt_ren = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{ // get a connection
|
||||||
|
conn = getConnection();
|
||||||
|
|
||||||
|
// lock the deploy table
|
||||||
|
stmt2 = conn.createStatement();
|
||||||
|
stmt2.executeUpdate("LOCK TABLES sbox_deploy WRITE;");
|
||||||
|
|
||||||
|
// locate the current position of the sidebox in the list
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("SELECT seq FROM sbox_deploy WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // add context parameter to statement
|
||||||
|
stmt = conn.prepareStatement("SELECT seq FROM sbox_deploy WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(5,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,sbid);
|
||||||
|
stmt.setInt(2,uid);
|
||||||
|
stmt.setInt(3,context_nsid);
|
||||||
|
stmt.setString(4,context_name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
if (!(rs.next()))
|
||||||
|
{ // sidebox does not exist here - throw exception
|
||||||
|
DatabaseException de = new DatabaseException(SideboxOps_mysql.class,"SideboxMessages","sbox.not.in.list");
|
||||||
|
de.setParameter(0,String.valueOf(sbid));
|
||||||
|
throw de;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
int old_pos = rs.getInt(1);
|
||||||
|
if (old_pos==new_pos)
|
||||||
|
return; // this is a no-op
|
||||||
|
|
||||||
|
SQLUtils.shutdown(rs); // prep for next statement
|
||||||
|
rs = null;
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
|
||||||
|
if (new_pos<0)
|
||||||
|
new_pos = 0; // range-check on low end
|
||||||
|
else
|
||||||
|
{ // need to range-check on high end - create statement to get max index
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("SELECT MAX(seq) FROM sbox_deploy WHERE uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // add context parameter to statement
|
||||||
|
stmt = conn.prepareStatement("SELECT MAX(seq) FROM sbox_deploy WHERE uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(4,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,uid);
|
||||||
|
stmt.setInt(2,context_nsid);
|
||||||
|
stmt.setString(3,context_name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
int max_pos = SQLUtils.getReturnCountInt(rs,1);
|
||||||
|
SQLUtils.shutdown(rs); // prep for next statement
|
||||||
|
rs = null;
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
if (new_pos>max_pos)
|
||||||
|
new_pos = max_pos;
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
// Start by renumbering the original item to index -1, normally unused.
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt_ren = conn.prepareStatement("UPDATE sbox_deploy SET seq = ? WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // include the context parameter
|
||||||
|
stmt_ren = conn.prepareStatement("UPDATE sbox_deploy SET seq = ? WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt_ren.setString(6,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt_ren.setInt(1,-1);
|
||||||
|
stmt_ren.setInt(2,sbid);
|
||||||
|
stmt_ren.setInt(3,uid);
|
||||||
|
stmt_ren.setInt(4,context_nsid);
|
||||||
|
stmt_ren.setString(5,context_name);
|
||||||
|
stmt_ren.executeUpdate();
|
||||||
|
|
||||||
|
// Now renumber the items in between the new position and the old position.
|
||||||
|
if (new_pos<old_pos)
|
||||||
|
{ // prepare statement to shift some items down
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("UPDATE sbox_deploy SET seq = seq + 1 WHERE seq >= ? AND seq <= ? AND uid = ? "
|
||||||
|
+ "AND ctx_nsid = ? AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // include the context parameter
|
||||||
|
stmt = conn.prepareStatement("UPDATE sbox_deploy SET seq = seq + 1 WHERE seq >= ? AND seq <= ? AND uid = ? "
|
||||||
|
+ "AND ctx_nsid = ? AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(6,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,new_pos);
|
||||||
|
stmt.setInt(2,old_pos);
|
||||||
|
stmt.setInt(3,uid);
|
||||||
|
stmt.setInt(4,context_nsid);
|
||||||
|
stmt.setString(5,context_name);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
else
|
||||||
|
{ // prepare statement to shift some items up
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("UPDATE sbox_deploy SET seq = seq - 1 WHERE seq >= ? AND seq <= ? AND uid = ? "
|
||||||
|
+ "AND ctx_nsid = ? AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // include the context parameter
|
||||||
|
stmt = conn.prepareStatement("UPDATE sbox_deploy SET seq = seq - 1 WHERE seq >= ? AND seq <= ? AND uid = ? "
|
||||||
|
+ "AND ctx_nsid = ? AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(6,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,old_pos);
|
||||||
|
stmt.setInt(2,new_pos);
|
||||||
|
stmt.setInt(3,uid);
|
||||||
|
stmt.setInt(4,context_nsid);
|
||||||
|
stmt.setString(5,context_name);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
// Now move the old element back into place in its new position, using the statement we've already prepared
|
||||||
|
// and just changing its parameters.
|
||||||
|
stmt_ren.setInt(1,new_pos);
|
||||||
|
stmt_ren.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_ren);
|
||||||
|
SQLUtils.shutdown(stmt2);
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
SQLUtils.shutdown(conn);
|
||||||
|
|
||||||
|
} // end finally
|
||||||
|
|
||||||
|
} // end moveSideboxItemToPosition
|
||||||
|
|
||||||
|
void removeSidebox(int uid, int context_nsid, String context_name, Object context_param, int sbid)
|
||||||
|
throws DatabaseException
|
||||||
|
{
|
||||||
|
String context_param_ser = serializeContextParam(context_param);
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
Statement stmt2 = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{ // get a connection
|
||||||
|
conn = getConnection();
|
||||||
|
|
||||||
|
// lock the deploy table
|
||||||
|
stmt2 = conn.createStatement();
|
||||||
|
stmt2.executeUpdate("LOCK TABLES sbox_deploy WRITE;");
|
||||||
|
|
||||||
|
// look for the item in the list, and get its old position
|
||||||
|
// locate the current position of the sidebox in the list
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("SELECT seq FROM sbox_deploy WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // add context parameter to statement
|
||||||
|
stmt = conn.prepareStatement("SELECT seq FROM sbox_deploy WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(5,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,sbid);
|
||||||
|
stmt.setInt(2,uid);
|
||||||
|
stmt.setInt(3,context_nsid);
|
||||||
|
stmt.setString(4,context_name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
if (!(rs.next()))
|
||||||
|
{ // sidebox does not exist here - throw exception
|
||||||
|
DatabaseException de = new DatabaseException(SideboxOps_mysql.class,"SideboxMessages","sbox.not.in.list");
|
||||||
|
de.setParameter(0,String.valueOf(sbid));
|
||||||
|
throw de;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
int old_pos = rs.getInt(1);
|
||||||
|
|
||||||
|
SQLUtils.shutdown(rs); // prep for next statement
|
||||||
|
rs = null;
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
|
||||||
|
// Erase this row from the table.
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("DELETE FROM sbox_deploy WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // include the context parameter
|
||||||
|
stmt = conn.prepareStatement("DELETE FROM sbox_deploy WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(5,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,sbid);
|
||||||
|
stmt.setInt(2,uid);
|
||||||
|
stmt.setInt(3,context_nsid);
|
||||||
|
stmt.setString(4,context_name);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
// Now renumber all the following rows to close the gap.
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("UPDATE sbox_deploy SET seq = seq - 1 WHERE seq >= ? AND uid = ? "
|
||||||
|
+ "AND ctx_nsid = ? AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // include the context parameter
|
||||||
|
stmt = conn.prepareStatement("UPDATE sbox_deploy SET seq = seq - 1 WHERE seq >= ? AND uid = ? "
|
||||||
|
+ "AND ctx_nsid = ? AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(5,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,old_pos);
|
||||||
|
stmt.setInt(2,uid);
|
||||||
|
stmt.setInt(3,context_nsid);
|
||||||
|
stmt.setString(4,context_name);
|
||||||
|
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(stmt2);
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
SQLUtils.shutdown(conn);
|
||||||
|
|
||||||
|
} // end finally
|
||||||
|
|
||||||
|
} // end removeSidebox
|
||||||
|
|
||||||
|
void addSidebox(int uid, int context_nsid, String context_name, Object context_param, int sbid)
|
||||||
|
throws DatabaseException
|
||||||
|
{
|
||||||
|
String context_param_ser = serializeContextParam(context_param);
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
Statement stmt2 = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{ // get a connection
|
||||||
|
conn = getConnection();
|
||||||
|
|
||||||
|
// lock the deploy table
|
||||||
|
stmt2 = conn.createStatement();
|
||||||
|
stmt2.executeUpdate("LOCK TABLES sbox_deploy WRITE, sbox_context READ;");
|
||||||
|
|
||||||
|
// see if the given sidebox is already in the list
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("SELECT seq FROM sbox_deploy WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // add context parameter to statement
|
||||||
|
stmt = conn.prepareStatement("SELECT seq FROM sbox_deploy WHERE sbid = ? AND uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(5,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,sbid);
|
||||||
|
stmt.setInt(2,uid);
|
||||||
|
stmt.setInt(3,context_nsid);
|
||||||
|
stmt.setString(4,context_name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
if (rs.next())
|
||||||
|
{ // already in list - throw exception
|
||||||
|
DatabaseException de = new DatabaseException(SideboxOps_mysql.class,"SideboxMessages","sbox.already.in.list");
|
||||||
|
de.setParameter(0,String.valueOf(sbid));
|
||||||
|
throw de;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
SQLUtils.shutdown(rs); // prep for next statement
|
||||||
|
rs = null;
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
|
||||||
|
// Make sure this sidebox is permissible in this context.
|
||||||
|
stmt = conn.prepareStatement("SELECT sbid FROM sbox_context WHERE sbid = ? AND ctx_nsid = ? AND ctx_name = ?;");
|
||||||
|
stmt.setInt(1,sbid);
|
||||||
|
stmt.setInt(2,context_nsid);
|
||||||
|
stmt.setString(3,context_name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
if (!(rs.next()))
|
||||||
|
{ // impermissible in this list - throw an exception
|
||||||
|
DatabaseException de = new DatabaseException(SideboxOps_mysql.class,"SideboxMessages","sbox.impermissible");
|
||||||
|
de.setParameter(0,String.valueOf(sbid));
|
||||||
|
throw de;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
SQLUtils.shutdown(rs); // prep for next statement
|
||||||
|
rs = null;
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
|
||||||
|
// Get the number of items we already have in the list, which is also the index of the new item (as
|
||||||
|
// elements start numbering with 0).
|
||||||
|
if (context_param_ser==null)
|
||||||
|
stmt = conn.prepareStatement("SELECT COUNT(*) FROM sbox_deploy WHERE uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param IS NULL;");
|
||||||
|
else
|
||||||
|
{ // add context parameter to statement
|
||||||
|
stmt = conn.prepareStatement("SELECT COUNT(*) FROM sbox_deploy WHERE uid = ? AND ctx_nsid = ? "
|
||||||
|
+ "AND ctx_name = ? AND param = ?;");
|
||||||
|
stmt.setString(4,context_param_ser);
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
stmt.setInt(1,uid);
|
||||||
|
stmt.setInt(2,context_nsid);
|
||||||
|
stmt.setString(3,context_name);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
int new_seq = SQLUtils.getReturnCountInt(rs,1);
|
||||||
|
|
||||||
|
SQLUtils.shutdown(rs); // prep for next statement
|
||||||
|
rs = null;
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
|
||||||
|
// Insert the new sidebox into the table.
|
||||||
|
stmt = conn.prepareStatement("INSERT INTO sbox_deploy (uid, ctx_nsid, ctx_name, param, seq, sbid) "
|
||||||
|
+ "VALUES (?, ?, ?, ?, ?, ?);");
|
||||||
|
stmt.setInt(1,uid);
|
||||||
|
stmt.setInt(2,context_nsid);
|
||||||
|
stmt.setString(3,context_name);
|
||||||
|
stmt.setString(4,context_param_ser);
|
||||||
|
stmt.setInt(5,new_seq);
|
||||||
|
stmt.setInt(6,sbid);
|
||||||
|
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(stmt2);
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
SQLUtils.shutdown(conn);
|
||||||
|
|
||||||
|
} // end finally
|
||||||
|
|
||||||
|
} // end addSidebox
|
||||||
|
|
||||||
|
void copyUserConfig(int uid_from, int uid_to) throws DatabaseException
|
||||||
|
{
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
Statement stmt2 = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{ // get a connection
|
||||||
|
conn = getConnection();
|
||||||
|
|
||||||
|
// lock the deploy table
|
||||||
|
stmt2 = conn.createStatement();
|
||||||
|
stmt2.executeUpdate("LOCK TABLES sbox_deploy WRITE;");
|
||||||
|
|
||||||
|
// start by getting the configuration for the existing user
|
||||||
|
stmt = conn.prepareStatement("SELECT ctx_nsid, ctx_name, param, seq, sbid FROM sbox_deploy WHERE uid = ?;");
|
||||||
|
stmt.setInt(1,uid_from);
|
||||||
|
rs = stmt.executeQuery();
|
||||||
|
LinkedList items = new LinkedList();
|
||||||
|
while (rs.next())
|
||||||
|
{ // save in a cheap and simple fashion
|
||||||
|
Object[] tmp = new Object[5];
|
||||||
|
tmp[0] = rs.getObject(1);
|
||||||
|
tmp[1] = rs.getObject(2);
|
||||||
|
tmp[2] = rs.getObject(3);
|
||||||
|
tmp[3] = rs.getObject(4);
|
||||||
|
tmp[4] = rs.getObject(5);
|
||||||
|
items.addLast(tmp);
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
SQLUtils.shutdown(rs); // prep for next statement
|
||||||
|
rs = null;
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
|
||||||
|
// erase existing config for destination user
|
||||||
|
stmt = conn.prepareStatement("DELETE FROM sbox_deploy WHERE uid = ?;");
|
||||||
|
stmt.setInt(1,uid_to);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
// now copy over the configuration
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
stmt = conn.prepareStatement("INSERT INTO sbox_deploy (uid, ctx_nsid, ctx_name, param, seq, sbid) "
|
||||||
|
+ "VALUES (?, ?, ?, ?, ?, ?);");
|
||||||
|
stmt.setInt(1,uid_to);
|
||||||
|
while (!(items.isEmpty()))
|
||||||
|
{ // add the items in, one at a time
|
||||||
|
Object[] tmp = (Object[])(items.removeFirst());
|
||||||
|
stmt.setObject(2,tmp[0],Types.INTEGER);
|
||||||
|
stmt.setObject(3,tmp[1],Types.VARCHAR);
|
||||||
|
stmt.setObject(4,tmp[2],Types.VARCHAR);
|
||||||
|
stmt.setObject(5,tmp[3],Types.INTEGER);
|
||||||
|
stmt.setObject(6,tmp[4],Types.INTEGER);
|
||||||
|
stmt.executeUpdate();
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
} // 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(stmt2);
|
||||||
|
SQLUtils.shutdown(stmt);
|
||||||
|
SQLUtils.shutdown(conn);
|
||||||
|
|
||||||
|
} // end finally
|
||||||
|
|
||||||
|
} // end copyUserConfig
|
||||||
|
|
||||||
} // end class SideboxOps_mysql
|
} // end class SideboxOps_mysql
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
package com.silverwrist.venice.sidebox;
|
package com.silverwrist.venice.sidebox;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import com.silverwrist.dynamo.except.DatabaseException;
|
||||||
import com.silverwrist.dynamo.except.DynamoException;
|
import com.silverwrist.dynamo.except.DynamoException;
|
||||||
|
import com.silverwrist.dynamo.iface.DynamoUser;
|
||||||
import com.silverwrist.dynamo.iface.Request;
|
import com.silverwrist.dynamo.iface.Request;
|
||||||
|
|
||||||
public interface SideboxService
|
public interface SideboxService
|
||||||
|
@ -26,4 +28,20 @@ public interface SideboxService
|
||||||
public List getSideboxes(Request req, String context_namespace, String context_name, Object context_param)
|
public List getSideboxes(Request req, String context_namespace, String context_name, Object context_param)
|
||||||
throws DynamoException;
|
throws DynamoException;
|
||||||
|
|
||||||
|
public List getSideboxDescriptors(DynamoUser user, String context_namespace, String context_name,
|
||||||
|
Object context_param) throws DatabaseException;
|
||||||
|
|
||||||
|
public List getAllSideboxDescriptors(String context_namespace, String context_name) throws DatabaseException;
|
||||||
|
|
||||||
|
public void moveSideboxItemToPosition(DynamoUser user, String context_namespace, String context_name,
|
||||||
|
Object context_param, int sbid, int new_pos) throws DatabaseException;
|
||||||
|
|
||||||
|
public void removeSidebox(DynamoUser user, String context_namespace, String context_name, Object context_param,
|
||||||
|
int sbid) throws DatabaseException;
|
||||||
|
|
||||||
|
public void addSidebox(DynamoUser user, String context_namespace, String context_name, Object context_param,
|
||||||
|
int sbid) throws DatabaseException;
|
||||||
|
|
||||||
|
public void copyUserConfig(DynamoUser from, DynamoUser to) throws DatabaseException;
|
||||||
|
|
||||||
} // end interface SideboxService
|
} // end interface SideboxService
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
//
|
//
|
||||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
// 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
|
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
// Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Contributor(s):
|
// Contributor(s):
|
||||||
|
|
||||||
|
@ -115,6 +115,11 @@ if (op=="create")
|
||||||
udpns = vcast.queryUserDefaultPropertyNamespace(req);
|
udpns = vcast.queryUserDefaultPropertyNamespace(req);
|
||||||
umgmt.loadUserDefaults(new_user,udpns.getDefaultPropertyNamespaces());
|
umgmt.loadUserDefaults(new_user,udpns.getDefaultPropertyNamespaces());
|
||||||
|
|
||||||
|
// Copy the default sidebox configuration for this user.
|
||||||
|
sideboxes = vcast.querySideboxService(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||||
|
"venice-sidebox"));
|
||||||
|
sideboxes.copyUserConfig(umgmt.getAnonymousUser(),new_user);
|
||||||
|
|
||||||
// Set the "profile last updated" date for the user.
|
// Set the "profile last updated" date for the user.
|
||||||
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"last.update",new_user.getCreationDate());
|
temp_profile.setObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"last.update",new_user.getCreationDate());
|
||||||
|
|
||||||
|
|
71
venice-data/scripts/sidebox_config.js
Normal file
71
venice-data/scripts/sidebox_config.js
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
// 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.util);
|
||||||
|
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||||
|
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);
|
||||||
|
importPackage(Packages.com.silverwrist.venice.sidebox);
|
||||||
|
|
||||||
|
req = bsf.lookupBean("request"); // get request
|
||||||
|
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||||
|
user = vlib.getUser(req); // get user
|
||||||
|
|
||||||
|
// Get the list of the user's sideboxes.
|
||||||
|
sideboxes = vcast.querySideboxService(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-sidebox"));
|
||||||
|
list = sideboxes.getSideboxDescriptors(user,VeniceNamespaces.SIDEBOX_CONTEXT_NAMESPACE,"top",null);
|
||||||
|
|
||||||
|
// Create a set that contains all the IDs of the sideboxes.
|
||||||
|
matchset = new HashSet();
|
||||||
|
it = list.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{ // add the IDs to the set
|
||||||
|
d = vcast.toSideboxDescriptor(it.next());
|
||||||
|
matchset.add(cast.toIntegerObject(d.getID()));
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
// Get the list of all possible sideboxes.
|
||||||
|
all_list = sideboxes.getAllSideboxDescriptors(VeniceNamespaces.SIDEBOX_CONTEXT_NAMESPACE,"top");
|
||||||
|
|
||||||
|
// Use that list and the match set to generate the "not list".
|
||||||
|
not_list = null;
|
||||||
|
if (list.size()==all_list.size())
|
||||||
|
not_list = Collections.EMPTY_LIST;
|
||||||
|
else if (list.size()==0)
|
||||||
|
not_list = all_list;
|
||||||
|
else
|
||||||
|
{ // need to generate the "not list"
|
||||||
|
not_list = new ArrayList(all_list.size());
|
||||||
|
it = all_list.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{ // check the list...
|
||||||
|
d = vcast.toSideboxDescriptor(it.next());
|
||||||
|
if (!(matchset.contains(cast.toIntegerObject(d.getID()))))
|
||||||
|
not_list.add(d);
|
||||||
|
|
||||||
|
} // end while
|
||||||
|
|
||||||
|
} // end else
|
||||||
|
|
||||||
|
// Generate the output object.
|
||||||
|
rc = new VelocityView("Your Sidebox Configuration: Front Page","sidebox_config.vm");
|
||||||
|
rc.setParameter("list",list);
|
||||||
|
rc.setParameter("notlist",not_list);
|
||||||
|
dynamo.scriptOutput(rc);
|
36
venice-data/scripts/sidebox_config_add.js
Normal file
36
venice-data/scripts/sidebox_config_add.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// 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):
|
||||||
|
|
||||||
|
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||||
|
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||||
|
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||||
|
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||||
|
importPackage(Packages.com.silverwrist.venice.iface);
|
||||||
|
importPackage(Packages.com.silverwrist.venice.sidebox);
|
||||||
|
|
||||||
|
req = bsf.lookupBean("request"); // get request
|
||||||
|
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||||
|
user = vlib.getUser(req); // get user
|
||||||
|
|
||||||
|
// Get the parameters.
|
||||||
|
sbid = rhelp.getParameterInt("sbid",-1);
|
||||||
|
|
||||||
|
// Execute the operation.
|
||||||
|
sideboxes = vcast.querySideboxService(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-sidebox"));
|
||||||
|
sideboxes.addSidebox(user,VeniceNamespaces.SIDEBOX_CONTEXT_NAMESPACE,"top",null,sbid);
|
||||||
|
|
||||||
|
// Redisplay the standard context display.
|
||||||
|
dynamo.scriptOutput(dynamo.exec("/scripts/sidebox_config.js"));
|
36
venice-data/scripts/sidebox_config_del.js
Normal file
36
venice-data/scripts/sidebox_config_del.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
// 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):
|
||||||
|
|
||||||
|
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||||
|
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||||
|
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||||
|
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||||
|
importPackage(Packages.com.silverwrist.venice.iface);
|
||||||
|
importPackage(Packages.com.silverwrist.venice.sidebox);
|
||||||
|
|
||||||
|
req = bsf.lookupBean("request"); // get request
|
||||||
|
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||||
|
user = vlib.getUser(req); // get user
|
||||||
|
|
||||||
|
// Get the parameters.
|
||||||
|
sbid = rhelp.getParameterInt("sbid",-1);
|
||||||
|
|
||||||
|
// Execute the operation.
|
||||||
|
sideboxes = vcast.querySideboxService(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-sidebox"));
|
||||||
|
sideboxes.removeSidebox(user,VeniceNamespaces.SIDEBOX_CONTEXT_NAMESPACE,"top",null,sbid);
|
||||||
|
|
||||||
|
// Redisplay the standard context display.
|
||||||
|
dynamo.scriptOutput(dynamo.exec("/scripts/sidebox_config.js"));
|
37
venice-data/scripts/sidebox_config_move.js
Normal file
37
venice-data/scripts/sidebox_config_move.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// 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):
|
||||||
|
|
||||||
|
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||||
|
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||||
|
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||||
|
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||||
|
importPackage(Packages.com.silverwrist.venice.iface);
|
||||||
|
importPackage(Packages.com.silverwrist.venice.sidebox);
|
||||||
|
|
||||||
|
req = bsf.lookupBean("request"); // get request
|
||||||
|
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||||
|
user = vlib.getUser(req); // get user
|
||||||
|
|
||||||
|
// Get the parameters.
|
||||||
|
sbid = rhelp.getParameterInt("sbid",-1);
|
||||||
|
new_pos = rhelp.getParameterInt("to",-1);
|
||||||
|
|
||||||
|
// Execute the operation.
|
||||||
|
sideboxes = vcast.querySideboxService(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-sidebox"));
|
||||||
|
sideboxes.moveSideboxItemToPosition(user,VeniceNamespaces.SIDEBOX_CONTEXT_NAMESPACE,"top",null,sbid,new_pos);
|
||||||
|
|
||||||
|
// Redisplay the standard context display.
|
||||||
|
dynamo.scriptOutput(dynamo.exec("/scripts/sidebox_config.js"));
|
|
@ -64,8 +64,8 @@ rc.pageTitle = globals.getObject(VeniceNamespaces.FRAME_LAF_NAMESPACE,"frontpage
|
||||||
rc.pageQID = "top";
|
rc.pageQID = "top";
|
||||||
if (!(user.isAnonymous()))
|
if (!(user.isAnonymous()))
|
||||||
{ // they only get to configure if they're logged in
|
{ // they only get to configure if they're logged in
|
||||||
rc.configureURL = "TODO";
|
rc.configureURL = "sidebox_config.js.vs";
|
||||||
rc.configureURLType = "ABSOLUTE";
|
rc.configureURLType = "SERVLET";
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
|
|
109
venice-data/velocity/sidebox_config.vm
Normal file
109
venice-data/velocity/sidebox_config.vm
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
#*
|
||||||
|
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:
|
||||||
|
list = List of sidebox descriptors on our front page
|
||||||
|
notlist = List of sidebox descriptors not on our Front Page
|
||||||
|
*#
|
||||||
|
#header2( "Your Sidebox Configuration:" "Front Page" )
|
||||||
|
<div align="left">
|
||||||
|
<a href="#formatURL( "SERVLET" "top.js.vs" )">Return to Front Page</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
#if( $list.size() > 0 )
|
||||||
|
#comment( "List of sideboxes" )
|
||||||
|
<p align="center"><table border="0" cellpadding="0" cellspacing="3">
|
||||||
|
#set( $max_i = $list.size() - 1 )
|
||||||
|
#set( $i = 0 )
|
||||||
|
#foreach( $d in $list )
|
||||||
|
<tr valign="middle">
|
||||||
|
<td align="center" width="16">
|
||||||
|
#if( $i < $max_i )
|
||||||
|
#set( $ix = $i + 1 )
|
||||||
|
<a href="#formatURL( "SERVLET" "sidebox_config_move.js.vs?sbid=${d.getID()}&to=$ix" )"><img
|
||||||
|
src="#formatURL( "IMAGE" "icn_down.gif" )" alt="[Down]" title="[Down]" width="16" height="16"
|
||||||
|
border="0" /></a>
|
||||||
|
#else
|
||||||
|
|
||||||
|
#end
|
||||||
|
</td>
|
||||||
|
<td align="center" width="16">
|
||||||
|
#if( $i > 0 )
|
||||||
|
#set( $ix = $i - 1 )
|
||||||
|
<a href="#formatURL( "SERVLET" "sidebox_config_move.js.vs?sbid=${d.getID()}&to=$ix" )"><img
|
||||||
|
src="#formatURL( "IMAGE" "icn_up.gif" )" alt="[Up]" title="[Up]" width="16" height="16"
|
||||||
|
border="0" /></a>
|
||||||
|
#else
|
||||||
|
|
||||||
|
#end
|
||||||
|
</td>
|
||||||
|
<td align="center" width="16">
|
||||||
|
<a href="#formatURL( "SERVLET" "sidebox_config_del.js.vs?sbid=${d.getID()}" )"><img
|
||||||
|
src="#formatURL( "IMAGE" "icn_x.gif" )" alt="[Remove]" title="[Remove]" width="16" height="16"
|
||||||
|
border="0" /></a>
|
||||||
|
</td>
|
||||||
|
<td align="left" class="content"><b>#encodeHTML( ${d.getDescription()} )</b></td>
|
||||||
|
</tr>
|
||||||
|
#set( $i = $i + 1 )
|
||||||
|
#end
|
||||||
|
</table></p>
|
||||||
|
|
||||||
|
#comment( "Explanation of the sidebox icons" )
|
||||||
|
<p><table border="0" cellpadding="2" cellspacing="0">
|
||||||
|
<tr valign="middle">
|
||||||
|
<td align="center" width="16">
|
||||||
|
<img src="#formatURL( "IMAGE" "icn_down.gif" )" alt="[Down]" title="[Down]" width="16" height="16"
|
||||||
|
border="0" />
|
||||||
|
</td>
|
||||||
|
<td align="left" class="content">
|
||||||
|
Click this symbol to move the specified sidebox down on your Front Page.
|
||||||
|
<td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="middle">
|
||||||
|
<td align="center" width="16">
|
||||||
|
<img src="#formatURL( "IMAGE" "icn_up.gif" )" alt="[Up]" title="[Up]" width="16" height="16" border="0" />
|
||||||
|
</td>
|
||||||
|
<td align="left" class="content">
|
||||||
|
Click this symbol to move the specified sidebox up on your Front Page.
|
||||||
|
<td>
|
||||||
|
</tr>
|
||||||
|
<tr valign="middle">
|
||||||
|
<td align="center" width="16">
|
||||||
|
<img src="#formatURL( "IMAGE" "icn_x.gif" )" alt="[Remove]" title="[Remove]" width="16" height="16"
|
||||||
|
border="0" />
|
||||||
|
</td>
|
||||||
|
<td align="left" class="content">
|
||||||
|
Click this symbol to remove the specified sidebox from your Front Page.
|
||||||
|
<td>
|
||||||
|
</tr>
|
||||||
|
</table></p>
|
||||||
|
#else
|
||||||
|
<p align="center"><em>No sideboxes currently defined.</em></p>
|
||||||
|
#end
|
||||||
|
|
||||||
|
#if( $notlist.size() > 0 )
|
||||||
|
<div align="left"><form method="POST" action="#formatURL( "SERVLET" "sidebox_config_add.js.vs" )">
|
||||||
|
<b>Add new sidebox:</b>
|
||||||
|
<select name="sbid" size="1">
|
||||||
|
#foreach( $d in $notlist )
|
||||||
|
<option value="${d.getID()}">#encodeHTML( $d.getDescription() )</option>
|
||||||
|
#end
|
||||||
|
</select>
|
||||||
|
#button( "INPUT" "add" )
|
||||||
|
</form></div>
|
||||||
|
#end
|
BIN
venice-web/images/icn_down.gif
Normal file
BIN
venice-web/images/icn_down.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 B |
BIN
venice-web/images/icn_up.gif
Normal file
BIN
venice-web/images/icn_up.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 B |
BIN
venice-web/images/icn_x.gif
Normal file
BIN
venice-web/images/icn_x.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 96 B |
Loading…
Reference in New Issue
Block a user