Index: openacs-4/packages/news-portlet/news-portlet.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/news-portlet.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news-portlet/news-portlet.info 11 Nov 2001 18:22:59 -0000 1.1 @@ -0,0 +1,33 @@ + + + + + News portlet + News Portlets + f + t + + + + oracle + + url="mailto:arjun@openforce.net">Arjun Sanyal + Creates news datasource for portal portlets. + OpenForce, Inc. + + + + + + + + + + + + + + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news-portlet/sql/oracle/news-portlet-create.sql 11 Nov 2001 18:22:59 -0000 1.1 @@ -0,0 +1,51 @@ +-- +-- /news-portlet/sql/oracle/news-portlet-create.sql +-- + +-- Creates news portlet + +-- Copyright (C) 2001 OpenForce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @creation-date 2001-30-09 + +-- $Id: news-portlet-create.sql,v 1.1 2001/11/11 18:22:59 oracle 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( + data_type => 'tcl_proc', + mime_type => 'text/html', + name => 'news-portlet', + link => 'news', + description => 'News ', + content => 'news_portlet::show', + configurable_p => 't' + ); + + -- 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 => '' +); + + -- shaded_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shaded_p', + value => 'f' +); + +end; +/ +show errors + Index: openacs-4/packages/news-portlet/sql/oracle/news-portlet-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/sql/oracle/news-portlet-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news-portlet/sql/oracle/news-portlet-drop.sql 11 Nov 2001 18:22:59 -0000 1.1 @@ -0,0 +1,36 @@ +-- +-- /news-portlet/sql/oracle/news-portlet-drop.sql +-- + +-- Drops news portlet + +-- Copyright (C) 2001 Openforce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @creation-date 2001-30-09 + +-- $Id: news-portlet-drop.sql,v 1.1 2001/11/11 18:22:59 oracle 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 + + begin + select datasource_id into ds_id + from portal_datasources + where name = 'news-portlet'; + exception when no_data_found then + ds_id := null; + end; + + if ds_id is not null then + portal_datasource.delete(ds_id); + end if; + +end; +/ +show errors; + Index: openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/news-portlet/tcl/news-portlet-procs.tcl 11 Nov 2001 18:22:59 -0000 1.1 @@ -0,0 +1,159 @@ +# news-portlet/tcl/news-portlet-procs.tcl + +ad_library { + +Procedures to support the file-storage portlet + +Copyright Openforce, Inc. +Licensed under GNU GPL v2 + +@creation-date Nov 2001 +@author arjun@openforce.net +@cvs-id $Id: news-portlet-procs.tcl,v 1.1 2001/11/11 18:22:59 oracle Exp $ + +} + +namespace eval news_portlet { + + ad_proc -private my_name { + } { + return "news-portlet" + } + + ad_proc -public get_pretty_name { + } { + return "News" + } + + ad_proc -public add_self_to_page { + page_id + community_id + } { + Adds a news PE to the given page with the community_id. + + @return element_id The new element's id + @param page_id The page to add self to + @param community_id The community with the folder + @author arjun@openforce.net + @creation-date Sept 2001 + } { + # Tell portal to add this element to the page + set element_id [portal::add_element $page_id [my_name]] + + # The default param "community_id" must be configured + set key "community_id" + portal::set_element_param $element_id $key $community_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 + + # things we need in the config + # community_id + + # get user_id from the conn at this point + set user_id [ad_conn user_id] + + # a modified query from news/www/index.tcl + set query " + select item_id, + package_id, + publish_title, + publish_date + from news_items_approved + where publish_date < sysdate + and (archive_date is null or archive_date > sysdate) + and package_id = $config(community_id) + order by publish_date desc, item_id desc" + + set data "" + set rowcount 0 + + if { $config(shaded_p) == "f" } { + + db_foreach select_news_items $query { + append data "
  • @news_items.publish_date@: @news_items.publish_title@" + incr rowcount + } + + set template "" + + if {!$rowcount} { + set template "No news items available

    more..." + } + + } else { + # shaded + set template "" + } + + set code [template::adp_compile -string $template] + + set output [template::adp_eval code] + return $output + + } + + ad_proc -public remove_self_from_page { + portal_id + community_id + } { + Removes a news PE from the given page + + @param page_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 { + page_id + } { + Wrapper for the portal:: proc + + @param page_id + @author arjun@openforce.net + @creation-date Nov 2001 + } { + portal::make_datasource_available \ + $page_id [portal::get_datasource_id [my_name]] + } + + ad_proc -public make_self_unavailable { + page_id + } { + Wrapper for the portal:: proc + + @param page_id + @author arjun@openforce.net + @creation-date Nov 2001 + } { + portal::make_datasource_unavailable \ + $page_id [portal::get_datasource_id [my_name]] + } +} + + +