Index: openacs-4/packages/faq-portlet/faq-portlet.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/faq-portlet.info,v diff -u -r1.3 -r1.4 --- openacs-4/packages/faq-portlet/faq-portlet.info 9 Oct 2001 06:19:03 -0000 1.3 +++ openacs-4/packages/faq-portlet/faq-portlet.info 19 Jan 2002 20:31:05 -0000 1.4 @@ -7,23 +7,24 @@ f t - + oracle + postgresql - url="mailto:arjun@openforce.net">Arjun Sanyal + url="mailto:arjun@openforce.net">Arjun Sanyal Creates faq datasource for portal portlets. OpenForce, Inc. - - + + Index: openacs-4/packages/faq-portlet/sql/oracle/faq-admin-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/sql/oracle/faq-admin-portlet-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq-portlet/sql/oracle/faq-admin-portlet-create.sql 19 Jan 2002 20:31:05 -0000 1.1 @@ -0,0 +1,196 @@ +-- +-- /faq-portlet/sql/oracle/faq-portlet-create.sql +-- + +-- Creates faq portlet + +-- Copyright (C) 2001 OpenForce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @author Ben Adida (ben@openforce) +-- @creation-date 2002-01-19 + +-- $Id: faq-admin-portlet-create.sql,v 1.1 2002/01/19 20:31:05 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 => 'faq_admin_portlet', + description => 'Displays the given folder_id' + ); + + -- the standard 4 params + + -- shadeable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shadeable_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 => 'f' +); + + -- 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' +); + + -- shaded_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shaded_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' +); + +-- package_id must be configured + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'package_id', + value => '' +); + + +end; +/ +show errors + + +declare + foo integer; +begin + -- create the implementation + foo := acs_sc_impl.new ( + 'portal_datasource', + 'faq_admin_portlet', + 'faq_admin_portlet' + ); + +end; +/ +show errors + +declare + foo integer; +begin + + -- add all the hooks + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'MyName', + 'faq_admin_portlet::my_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'GetPrettyName', + 'faq_admin_portlet::get_pretty_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'Link', + 'faq_admin_portlet::link', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'AddSelfToPage', + 'faq_admin_portlet::add_self_to_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'Show', + 'faq_admin_portlet::show', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'Edit', + 'faq_admin_portlet::edit', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'RemoveSelfFromPage', + 'faq_admin_portlet::remove_self_from_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'MakeSelfAvailable', + 'faq_admin_portlet::make_self_available', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'faq_admin_portlet', + 'MakeSelfUnavailable', + 'faq_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 => 'faq_admin_portlet' + ); +end; +/ +show errors + Index: openacs-4/packages/faq-portlet/sql/oracle/faq-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/sql/oracle/faq-portlet-create.sql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/faq-portlet/sql/oracle/faq-portlet-create.sql 17 Jan 2002 22:01:55 -0000 1.8 +++ openacs-4/packages/faq-portlet/sql/oracle/faq-portlet-create.sql 19 Jan 2002 20:31:05 -0000 1.9 @@ -193,3 +193,4 @@ / show errors +@faq-admin-portlet-create.sql Index: openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl 19 Jan 2002 20:31:05 -0000 1.1 @@ -0,0 +1,157 @@ +# faq-portlet/tcl/faq-admin-portlet-procs.tcl + +ad_library { + +Procedures to support the file-storage portlet + +Copyright Openforce, Inc. +Licensed under GNU GPL v2 + +@creation-date January 19 2002 +@author arjun@openforce.net +@author ben@openforce.net +@cvs-id $Id: faq-admin-portlet-procs.tcl,v 1.1 2002/01/19 20:31:05 ben Exp $ + +} + +namespace eval faq_admin_portlet { + + ad_proc -private my_name { + } { + return "faq_admin_portlet" + } + + ad_proc -public get_pretty_name { + } { + return "FAQ Administration" + } + + ad_proc -private my_package_key { + } { + return "faq-portlet" + } + + ad_proc -public link { + } { + return "faq" + } + + ad_proc -public add_self_to_page { + portal_id + package_id + } { + Adds a faq PE to the given page with the package_id + 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 package_id the id of the faq package for this community + @author arjun@openforce.net + @creation-date Sept 2001 + } { + # Find out if faq already exists on this portal page + 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 package_id $package_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 package_id \ + -value $package_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 + } { + # no return call required with the helper proc + portal::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "faq-admin-portlet" + + } + + + ad_proc -public edit { + nothing here + } { + return "" + } + + ad_proc -public remove_self_from_page { + portal_id + package_id + } { + Removes a faq PE from the given page + + @param portal_id The page to remove self from + @param package_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]] + + db_transaction { + foreach element_id $element_ids { + # Highly simplified (ben) + portal::remove_element_param_value -element_id $element_id -key package_id -value $package_id + + # Check if we should really remove the element + if {[llength [portal::get_element_param_list -element_id $element_id -key package_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]] + } + +} + + + + + Index: openacs-4/packages/faq-portlet/www/faq-admin-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/www/faq-admin-portlet.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq-portlet/www/faq-admin-portlet.adp 19 Jan 2002 20:31:05 -0000 1.1 @@ -0,0 +1,15 @@ + + +No FAQs + + + + +

+New FAQ + + Index: openacs-4/packages/faq-portlet/www/faq-admin-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/www/faq-admin-portlet.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/faq-portlet/www/faq-admin-portlet.tcl 19 Jan 2002 20:31:05 -0000 1.1 @@ -0,0 +1,30 @@ +ad_page_contract { + The display logic for the FAQ admin portlet + + @author Ben Adida (ben@openforce) + @cvs_id $Id: faq-admin-portlet.tcl,v 1.1 2002/01/19 20:31:05 ben Exp $ +} -properties { + +} + +# Configuration +array set config $cf + +# Should be a list already! +set list_of_package_ids $config(package_id) + +if {[llength $list_of_package_ids] > 1} { + # We have a problem! + return -code error "There should be only one instance of FAQ for admin purposes" +} + +set package_id [lindex $list_of_package_ids 0] + +db_multirow faqs select_faqs "select f.faq_id, +f.faq_name from +faqs f, acs_objects o +where faq_id= object_id and context_id = :package_id" + +set url [dotlrn_community::get_url_from_package_id -package_id $package_id] + +ad_return_template