Index: openacs-4/packages/fs-portlet/fs-portlet.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/fs-portlet/fs-portlet.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/fs-portlet/fs-portlet.info 9 Oct 2001 00:40:21 -0000 1.1 @@ -0,0 +1,33 @@ + + + + + File Storage portlet + File Storage Portlets + f + t + + + + oracle + + url="mailto:arjun@openforce.net">Arjun Sanyal + Creates fs datasource for portal portlets. + OpenForce, Inc. + + + + + + + + + + + + + + + + + Index: openacs-4/packages/fs-portlet/sql/oracle/fs-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/fs-portlet/sql/oracle/fs-portlet-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/fs-portlet/sql/oracle/fs-portlet-create.sql 9 Oct 2001 00:40:21 -0000 1.1 @@ -0,0 +1,49 @@ +-- +-- /fs-portlet/sql/oracle/fs-portlet-create.sql +-- + +-- Creates fs portlet + +-- Copyright (C) 2001 OpenForce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @creation-date 2001-30-09 + +-- $Id: fs-portlet-create.sql,v 1.1 2001/10/09 00:40:21 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 => 'fs-portlet', + description => 'Displays the given folder_id ', + content => 'fs_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 => '' + + + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'folder_id', + value => '' +); + +end; +/ +show errors + Index: openacs-4/packages/fs-portlet/sql/oracle/fs-portlet-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/fs-portlet/sql/oracle/fs-portlet-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/fs-portlet/sql/oracle/fs-portlet-drop.sql 9 Oct 2001 00:40:21 -0000 1.1 @@ -0,0 +1,36 @@ +-- +-- /fs-portlet/sql/oracle/fs-portlet-drop.sql +-- + +-- Drops fs portlet + +-- Copyright (C) 2001 Openforce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @creation-date 2001-30-09 + +-- $Id: fs-portlet-drop.sql,v 1.1 2001/10/09 00:40:21 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 = 'fs-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/fs-portlet/tcl/fs-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/fs-portlet/tcl/fs-portlet-procs.tcl 9 Oct 2001 00:40:21 -0000 1.1 @@ -0,0 +1,175 @@ +# fs-portlet/tcl/fs-portlet-procs.tcl + +ad_library { + +Procedures to support the file-storage portlet + +Copyright Openforce, Inc. +Licensed under GNU GPL v2 + +@creation-date September 30 2001 +@author arjun@openforce.net +@cvs-id $Id: fs-portlet-procs.tcl,v 1.1 2001/10/09 00:40:21 oracle Exp $ + +} + +namespace eval fs_portlet { + + ad_proc -private my_name { + } { + return "fs-portlet" + } + + ad_proc -public add_self_to_page { + page_id + folder_id + } { + Adds a fs PE to the given page with the folder_id being + opaque data in the portal configuration. + + @return element_id The new element's id + @param page_id The page to add self to + @param folder_id The folder to show + @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 "folder_id" must be configured + set key "folder_id" + set value [portal::get_element_param $element_id $key] + + portal::set_element_param $element_id $key $folder_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 and folder_id + + # get user_id from the conn at this point + set user_id [ad_conn user_id] + + # a big-time query from file-storage + set query \ " + select i.item_id as file_id, + r.title as name, + i.live_revision, + content_item.get_path(i.item_id,file_storage.get_root_folder($config(community_id))) as path, + r.mime_type as type, + to_char(o.last_modified,'YYYY-MM-DD HH24:MI') as last_modified, + r.content_length as content_size, + 1 as ordering_key + from cr_items i, cr_revisions r, acs_objects o + where i.item_id = o.object_id + and i.live_revision = r.revision_id (+) + and i.parent_id = $config(folder_id) + and acs_permission.permission_p(i.item_id, :user_id, 'read') = 't' + and i.content_type = 'content_revision' + UNION + select i.item_id as file_id, + f.label as name, + 0, + content_item.get_path(f.folder_id) as path, + 'Folder', + NULL, + 0, + 0 + from cr_items i, cr_folders f + where i.item_id = f.folder_id + and i.parent_id = $config(folder_id) + and acs_permission.permission_p($config(folder_id), :user_id, 'read') = 't' + order by ordering_key,name" + + set data "" + set rowcount 0 + + db_foreach select_files_and_folders $query { + append data "$name$path$content_sizetype$last_modified" + incr rowcount + } + + set template " + + + + + + + + + $data +
NameActionSize (bytes)TypeModified
" + + ns_log notice "AKS52 got here $rowcount" + + if {!$rowcount} { + set template "No items in this folder" + } + + set code [template::adp_compile -string $template] + + set output [template::adp_eval code] + ns_log notice "AKS53 got here $output" + + return $output + + } + + ad_proc -public remove_self_from_page { + portal_id + community_id + folder_id + } { + Removes a fs PE from the given page + + @param page_id The page to remove self from + @param community_id + @param folder_id + @author arjun@openforce.net + @creation-date Sept 2001 + } { + # Find out the element_id that corresponds to this community_id + # and folder_id + + if { [db0or1row get_element_id " + select pem.element_id as element_id + from portal_element_parameters pep, portal_element_map pem + where pem.portal_id = $portal_id and + pep.element_id = pem.element_id and + pep.key = 'community_id' and + pep.value = $community_id and + pep.key = 'folder_id' and + pep.value = $folder_id + "] } { + + # delete the params + # delete the element from the map + ns_log Notice "AKS54 fs-portlet-procs delete called" + + } else { + ad_return_complaint 1 "fs_portlet::remove_self_from_page: Invalid portal_id and/or folder_id and/or community_id given." + ad_script_abort + } + + # this call removes the PEs params too + set element_id [portal::remove_element {$portal_id $element_id}] + } + } + + +