Index: openacs-4/packages/news-portlet/sql/oracle/news-admin-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/sql/oracle/news-admin-portlet-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news-portlet/sql/oracle/news-admin-portlet-create.sql 19 Jan 2002 20:03:05 -0000 1.1 @@ -0,0 +1,194 @@ +-- +-- /news-portlet/sql/oracle/news-admin-portlet-create.sql +-- + +-- Creates news admin portlet + +-- Copyright (C) 2001 OpenForce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @author Ben Adida (Ben@openforce.net) +-- @creation-date 2002-01-19 + +-- $Id: news-admin-portlet-create.sql,v 1.1 2002/01/19 20:03: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 => 'news_admin_portlet', + description => 'News Admin portlet' + ); + + -- 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' +); + +-- news_admin-specific params + + -- community_id must be configured + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'community_id', + value => '' +); + + +end; +/ +show errors + +declare + foo integer; +begin + -- create the implementation + foo := acs_sc_impl.new ( + 'portal_datasource', + 'news_admin_portlet', + 'news_admin_portlet' + ); + +end; +/ +show errors + +declare + foo integer; +begin + -- add all the hooks + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'MyName', + 'news_admin_portlet::my_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'GetPrettyName', + 'news_admin_portlet::get_pretty_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'Link', + 'news_admin_portlet::link', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'AddSelfToPage', + 'news_admin_portlet::add_self_to_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'Show', + 'news_admin_portlet::show', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'Edit', + 'news_admin_portlet::edit', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'RemoveSelfFromPage', + 'news_admin_portlet::remove_self_from_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'MakeSelfAvailable', + 'news_admin_portlet::make_self_available', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'news_admin_portlet', + 'MakeSelfUnavailable', + 'news_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 => 'news_admin_portlet' + ); +end; +/ +show errors + Index: openacs-4/packages/news-portlet/sql/oracle/news-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/sql/oracle/news-portlet-create.sql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/news-portlet/sql/oracle/news-portlet-create.sql 17 Jan 2002 22:02:17 -0000 1.6 +++ openacs-4/packages/news-portlet/sql/oracle/news-portlet-create.sql 19 Jan 2002 20:03:05 -0000 1.7 @@ -191,3 +191,5 @@ / show errors + +@news-admin-portlet-create.sql Index: openacs-4/packages/news-portlet/tcl/news-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/tcl/news-admin-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news-portlet/tcl/news-admin-portlet-procs.tcl 19 Jan 2002 20:03:05 -0000 1.1 @@ -0,0 +1,146 @@ +# news-portlet/tcl/news-portlet-procs.tcl + +ad_library { + +Procedures to support the news admin portlet + +Copyright Openforce, Inc. +Licensed under GNU GPL v2 + +@creation-date Jan 2002 +@author ben@openforce.net +@cvs-id $Id: news-admin-portlet-procs.tcl,v 1.1 2002/01/19 20:03:05 ben Exp $ + +} + +namespace eval news_admin_portlet { + + ad_proc -private my_name { + } { + return "news_admin_portlet" + } + + ad_proc -public get_pretty_name { + } { + return "News Administration" + } + + ad_proc -private my_package_key { + } { + return "news-portlet" + } + + ad_proc -public link { + } { + return "news" + } + + ad_proc -public add_self_to_page { + portal_id + instance_id + } { + Adds a news PE to the given page with the community_id. + + @return element_id The new element's id + @param portal_id The page to add self to + @param community_id The community with the folder + @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 community_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 community_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 + } { + + # no return call required with the helper proc + portal::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "news-admin-portlet" + + } + + ad_proc -public edit { + } { + return "" + } + + ad_proc -public remove_self_from_page { + portal_id + community_id + } { + Removes a news PE from the given page + + @param portal_id The page to remove self from + @param community_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 { + 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/news-portlet/www/news-admin-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/www/news-admin-portlet.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news-portlet/www/news-admin-portlet.adp 19 Jan 2002 20:03:05 -0000 1.1 @@ -0,0 +1,5 @@ + Index: openacs-4/packages/news-portlet/www/news-admin-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/www/news-admin-portlet.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news-portlet/www/news-admin-portlet.tcl 19 Jan 2002 20:03:05 -0000 1.1 @@ -0,0 +1,26 @@ +# www/news-portlet.tcl +ad_page_contract { + The display logic for the news portlet + + @author Arjun Sanyal (arjun@openforce.net) + @author Ben Adida (ben@openforce) + @cvs_id $Id: news-admin-portlet.tcl,v 1.1 2002/01/19 20:03:05 ben Exp $ +} -properties { + +} + +array set config $cf +set user_id [ad_conn user_id] + +set list_of_package_ids $config(community_id) + +if {[llength $list_of_package_ids] > 1} { + # We have a problem! + return -code error "There should be only one instance of news for admin purposes" +} + +set package_id [lindex $list_of_package_ids 0] + +set url [dotlrn_community::get_url_from_package_id -package_id $package_id] + +ad_return_template