Index: openacs-4/packages/bboard-portlet/bboard-portlet.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/bboard-portlet/bboard-portlet.info,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/bboard-portlet/bboard-portlet.info 17 Nov 2001 21:55:05 -0000 1.5
+++ openacs-4/packages/bboard-portlet/bboard-portlet.info 19 Jan 2002 18:31:24 -0000 1.6
@@ -21,9 +21,13 @@
+
+
+
+
Index: openacs-4/packages/bboard-portlet/sql/oracle/bboard-admin-portlet-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/bboard-portlet/sql/oracle/bboard-admin-portlet-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/bboard-portlet/sql/oracle/bboard-admin-portlet-create.sql 19 Jan 2002 18:31:25 -0000 1.1
@@ -0,0 +1,197 @@
+--
+-- packages/bboard-portlet/sql/bboard-portlets-create.sql
+--
+
+-- Creates bboard datasources for portal portlets
+
+-- Copyright (C) 2001 OpenForce, Inc.
+-- @author Arjun Sanyal (arjun@openforce.net)
+-- @creation-date 2001-30-09
+
+-- $Id: bboard-admin-portlet-create.sql,v 1.1 2002/01/19 18:31:25 ben Exp $
+
+-- This is free software distributed under the terms of the GNU Public
+-- License version 2 or higher. Full text of the license is available
+-- from the GNU Project: http://www.fsf.org/copyleft/gpl.html
+
+declare
+ ds_id portal_datasources.datasource_id%TYPE;
+begin
+ ds_id := portal_datasource.new(
+ name => 'bboard_admin_portlet',
+ description => 'Displays the bboard_admin'
+ );
+
+ -- 4 defaults procs
+
+ -- shadeable_p
+ portal_datasource.set_def_param (
+ datasource_id => ds_id,
+ config_required_p => 't',
+ configured_p => 't',
+ key => 'shadeable_p',
+ value => 'f'
+);
+
+ -- shaded_p
+ portal_datasource.set_def_param (
+ datasource_id => ds_id,
+ config_required_p => 't',
+ configured_p => 't',
+ key => 'shaded_p',
+ value => 'f'
+);
+
+ -- hideable_p
+ portal_datasource.set_def_param (
+ datasource_id => ds_id,
+ config_required_p => 't',
+ configured_p => 't',
+ key => 'hideable_p',
+ value => 't'
+);
+
+ -- user_editable_p
+ portal_datasource.set_def_param (
+ datasource_id => ds_id,
+ config_required_p => 't',
+ configured_p => 't',
+ key => 'user_editable_p',
+ value => 'f'
+);
+
+ -- link_hideable_p
+ portal_datasource.set_def_param (
+ datasource_id => ds_id,
+ config_required_p => 't',
+ configured_p => 't',
+ key => 'link_hideable_p',
+ value => 't'
+);
+
+
+ -- bboard_admin-specific procs
+
+ -- Instance_id must be configured
+ portal_datasource.set_def_param (
+ datasource_id => ds_id,
+ config_required_p => 't',
+ configured_p => 'f',
+ key => 'instance_id',
+ value => ''
+);
+
+
+end;
+/
+show errors
+
+
+declare
+ foo integer;
+begin
+ -- create the implementation
+ foo := acs_sc_impl.new (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'bboard_admin_portlet'
+ );
+
+end;
+/
+show errors
+
+declare
+ foo integer;
+begin
+
+ -- add all the hooks
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'MyName',
+ 'bboard_admin_portlet::my_name',
+ 'TCL'
+ );
+
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'GetPrettyName',
+ 'bboard_admin_portlet::get_pretty_name',
+ 'TCL'
+ );
+
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'Link',
+ 'bboard_admin_portlet::link',
+ 'TCL'
+ );
+
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'AddSelfToPage',
+ 'bboard_admin_portlet::add_self_to_page',
+ 'TCL'
+ );
+
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'Show',
+ 'bboard_admin_portlet::show',
+ 'TCL'
+ );
+
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'Edit',
+ 'bboard_admin_portlet::edit',
+ 'TCL'
+ );
+
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'RemoveSelfFromPage',
+ 'bboard_admin_portlet::remove_self_from_page',
+ 'TCL'
+ );
+
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'MakeSelfAvailable',
+ 'bboard_admin_portlet::make_self_available',
+ 'TCL'
+ );
+
+ foo := acs_sc_impl.new_alias (
+ 'portal_datasource',
+ 'bboard_admin_portlet',
+ 'MakeSelfUnavailable',
+ 'bboard_admin_portlet::make_self_unavailable',
+ 'TCL'
+ );
+
+end;
+/
+show errors
+
+declare
+ foo integer;
+begin
+
+ -- Add the binding
+ acs_sc_binding.new (
+ contract_name => 'portal_datasource',
+ impl_name => 'bboard_admin_portlet'
+ );
+end;
+/
+show errors
+
Index: openacs-4/packages/bboard-portlet/tcl/bboard-admin-portlet-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/bboard-portlet/tcl/bboard-admin-portlet-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/bboard-portlet/tcl/bboard-admin-portlet-procs.tcl 19 Jan 2002 18:31:25 -0000 1.1
@@ -0,0 +1,209 @@
+# /packages/bboard-portlets/tcl/bboard-portlets-procs.tcl
+ad_library {
+
+Procedures to supports bboard admin portlets
+
+Copyright Openforce, Inc.
+Licensed under GNU GPL v2
+
+@creation-date September 30 2001
+@author arjun@openforce.net
+@cvs-id $Id: bboard-admin-portlet-procs.tcl,v 1.1 2002/01/19 18:31:25 ben Exp $
+
+}
+
+namespace eval bboard_admin_portlet {
+
+ ad_proc -private my_name {
+ } {
+ return "bboard_admin_portlet"
+ }
+
+ ad_proc -public get_pretty_name {
+ } {
+ return "Discussion Forums Administration"
+ }
+
+ ad_proc -public link {
+ } {
+ return "forums"
+ }
+
+ ad_proc -public add_self_to_page {
+ portal_id
+ instance_id
+ args
+ } {
+ Adds a bboard PE to the given page with the instance key being
+ opaque data in the portal configuration.
+
+ @return element_id The new element's id
+ @param portal_id The page to add self to
+ @param instance_id The bboard instace to show
+ @param args an arg string not used
+ @author arjun@openforce.net
+ @creation-date Sept 2001
+ } {
+ # Add some smarts to only add one portlet for now when it's added multiple times (ben)
+ # Find out if bboard already exists
+ set element_id_list [portal::get_element_ids_by_ds $portal_id [my_name]]
+
+ if {[llength $element_id_list] == 0} {
+ # Tell portal to add this element to the page
+ set element_id [portal::add_element $portal_id [my_name]]
+ # There is already a value for the param which must be overwritten
+ portal::set_element_param $element_id instance_id $instance_id
+ set package_id_list [list]
+ } else {
+ set element_id [lindex $element_id_list 0]
+ # There are existing values which should NOT be overwritten
+ portal::add_element_param_value -element_id $element_id -key instance_id -value $instance_id
+ }
+
+ return $element_id
+ }
+
+ ad_proc -public show {
+ cf
+ } {
+ Display the PE
+
+ @return HTML string
+ @param cf A config array
+ @author arjun@openforce.net
+ @creation-date Sept 2001
+ } {
+
+ array set config $cf
+
+ set query "
+ select forum_id, short_name
+ from bboard_forums
+ where bboard_id = :instance_id"
+
+ #
+ # YES, I will clean this up! - aks
+ #
+
+
+ set whole_data ""
+ # Should be a list already! (ben)
+ set list_of_instance_ids $config(instance_id)
+
+ if {[llength $list_of_instance_ids] > 1} {
+ # We have a problem!
+ return -code error "There should be only one instance of bboard for admin purposes"
+ }
+
+ set instance_id [lindex $list_of_instance_ids 0]
+
+ set url [dotlrn_community::get_url_from_package_id -package_id $instance_id]
+
+ # aks fold into site_nodes:: or dotlrn_community
+ set comm_object_id [db_string select_name "select object_id from site_nodes where node_id= (select parent_id from site_nodes where object_id=:instance_id)" ]
+
+ set name [db_string select_pretty_name "
+ select instance_name
+ from apm_packages
+ where package_id= :comm_object_id "]
+
+ # append whole_data " $name forums |
"
+
+ set data ""
+ set rowcount 0
+
+ db_foreach select_forums $query {
+ append data "- $short_name - Administration\n"
+ incr rowcount
+ }
+
+ set template "$data"
+
+ if {!$rowcount} {
+ set template "No discussion forums"
+ }
+
+ append whole_data $template
+
+
+ append whole_data "
+
- New Forum
"
+
+ set code [template::adp_compile -string $whole_data]
+
+ set output [template::adp_eval code]
+
+ return $output
+
+ }
+
+ ad_proc -public edit {
+ element_id
+ } {
+ Display the PE's edit page
+
+ @return HTML string
+ @param cf A config array
+ @author arjun@openforce.net
+ @creation-date Nov 2001
+ } {
+ return ""
+ }
+
+
+ ad_proc -public remove_self_from_page {
+ portal_id
+ instance_id
+ } {
+ Removes a bboard PE from the given page
+
+ @param portal_id The page to remove self from
+ @param instance_id
+ @author arjun@openforce.net
+ @creation-date Sept 2001
+ } {
+ # get the element IDs (could be more than one!)
+ set element_ids [portal::get_element_ids_by_ds $portal_id [my_name]]
+
+ # remove all elements
+ db_transaction {
+ foreach element_id $element_ids {
+ # Highly simplified (ben)
+ portal::remove_element_param_value -element_id $element_id -key instance_id -value $instance_id
+
+ # Check if we should really remove the element
+ if {[llength [portal::get_element_param_list -element_id $element_id -key instance_id]] == 0} {
+ portal::remove_element $element_id
+ }
+ }
+ }
+ }
+
+ ad_proc -public make_self_available {
+ portal_id
+ } {
+ Wrapper for the portal:: proc
+
+ @param portal_id
+ @author arjun@openforce.net
+ @creation-date Nov 2001
+ } {
+ portal::make_datasource_available \
+ $portal_id [portal::get_datasource_id [my_name]]
+ }
+
+ ad_proc -public make_self_unavailable {
+ portal_id
+ } {
+ Wrapper for the portal:: proc
+
+ @param portal_id
+ @author arjun@openforce.net
+ @creation-date Nov 2001
+ } {
+ portal::make_datasource_unavailable \
+ $portal_id [portal::get_datasource_id [my_name]]
+ }
+}
+
+