Index: openacs-4/packages/file-storage/sql/oracle/file-storage-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/oracle/file-storage-create.sql,v diff -u -r1.11 -r1.12 --- openacs-4/packages/file-storage/sql/oracle/file-storage-create.sql 2 Apr 2002 06:13:29 -0000 1.11 +++ openacs-4/packages/file-storage/sql/oracle/file-storage-create.sql 2 Apr 2002 07:00:53 -0000 1.12 @@ -43,6 +43,8 @@ unique ); + + -- To enable site-wide search to distinguish CR items as File Storage items -- we create an item subtype of content_item in the ACS Object Model begin @@ -55,6 +57,7 @@ id_column => 'folder_id', name_method => 'file_storage.get_title' ); + end; / show errors; @@ -758,3 +761,7 @@ fs_files.parent_id, 1 as sort_key from fs_files; + + +@file-storage-simple-create.sql +@file-storage-simple-package-create.sql Index: openacs-4/packages/file-storage/sql/oracle/file-storage-simple-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/oracle/Attic/file-storage-simple-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/sql/oracle/file-storage-simple-create.sql 2 Apr 2002 07:00:53 -0000 1.1 @@ -0,0 +1,66 @@ + +-- +-- File Storage NonVersioned (Simple) Objects +-- +-- This is to get away from the CR pain when dealing with file-storage of +-- "other" objects +-- +-- @author Ben Adida (ben@openforce) +-- @creation-date 01 April 2002 +-- @cvs-id $Id: file-storage-simple-create.sql,v 1.1 2002/04/02 07:00:53 ben Exp $ +-- + + +-- Non-versioned objects +create table fs_simple_objects ( + object_id integer + constraint fs_simp_obj_id_fk + references acs_objects(object_id) + constraint fs_simp_obj_id_pk + primary key, + folder_id integer + constraint fs_simp_folder_id_fk + references cr_folders(folder_id), + name varchar(250) not null, + description varchar(4000) +); + + +create table fs_urls ( + url_id integer + constraint fs_url_url_id_fk + references fs_simple_objects(object_id) + constraint fs_url_url_id_pk + primary key, + url varchar(250) not null +); + + +create view fs_urls_full as +select * from fs_urls, fs_simple_objects +where url_id = object_id; + +begin + -- stuff for non-versioned file-storage objects + acs_object_type.create_type ( + supertype => 'acs_object', + object_type => 'fs_simple_object', + pretty_name => 'File Storage Simple Object', + pretty_plural => 'File Storage Simple Objects', + table_name => 'fs_simple_objects', + id_column => 'object_id' + ); + + -- links + acs_object_type.create_type ( + supertype => 'fs_simple_object', + object_type => 'fs_url', + pretty_name => 'File Storage URL', + pretty_plural => 'File Storage URLs', + table_name => 'fs_urls', + id_column => 'url_id' + ); +end; +/ +show errors; + Index: openacs-4/packages/file-storage/sql/oracle/file-storage-simple-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/oracle/Attic/file-storage-simple-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/sql/oracle/file-storage-simple-package-create.sql 2 Apr 2002 07:00:53 -0000 1.1 @@ -0,0 +1,157 @@ + +-- +-- File Storage NonVersioned (simple) Objects +-- +-- This is to get away from the CR pain when dealing with file-storage of +-- "other" objects +-- +-- @author Ben Adida (ben@openforce) +-- @creation-date 01 April 2002 +-- @cvs-id $Id: file-storage-simple-package-create.sql,v 1.1 2002/04/02 07:00:53 ben Exp $ +-- + +create or replace package fs_simple_object +as + function new ( + object_id in fs_simple_objects.object_id%TYPE default NULL, + object_type in acs_objects.object_type%TYPE default 'fs_simple_object', + folder_id in fs_simple_objects.folder_id%TYPE, + name in fs_simple_objects.name%TYPE, + description in fs_simple_objects.description%TYPE, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE, + creation_ip in acs_objects.creation_ip%TYPE, + context_id in acs_objects.context_id%TYPE + ) return fs_simple_objects.object_id%TYPE; + + procedure delete ( + object_id in fs_simple_objects.object_id%TYPE + ); +end fs_simple_object; +/ +show errors + + + +create or replace package body fs_simple_object +as + function new ( + object_id in fs_simple_objects.object_id%TYPE default NULL, + object_type in acs_objects.object_type%TYPE default 'fs_simple_object', + folder_id in fs_simple_objects.folder_id%TYPE, + name in fs_simple_objects.name%TYPE, + description in fs_simple_objects.description%TYPE, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE, + creation_ip in acs_objects.creation_ip%TYPE, + context_id in acs_objects.context_id%TYPE + ) return fs_simple_objects.object_id%TYPE + is + v_object_id acs_objects.object_id%TYPE; + begin + v_object_id:= acs_object.new ( + object_id => object_id, + object_type => object_type, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id + ); + + insert into fs_simple_objects + (object_id, folder_id, name, description) values + (v_object_id, folder_id, name, description); + + return v_object_id; + end new; + + procedure delete ( + object_id in fs_simple_objects.object_id%TYPE + ) + is + begin + acs_object.delete(object_id); + end delete; + +end fs_simple_object; +/ +show errors + + + + +create or replace package fs_url +as + function new ( + url_id in fs_urls.url_id%TYPE default NULL, + object_type in acs_objects.object_type%TYPE default 'fs_url', + url in fs_urls.url%TYPE, + folder_id in fs_simple_objects.folder_id%TYPE, + name in fs_simple_objects.name%TYPE, + description in fs_simple_objects.description%TYPE, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE, + creation_ip in acs_objects.creation_ip%TYPE, + context_id in acs_objects.context_id%TYPE + ) return fs_urls.url_id%TYPE; + + procedure delete ( + url_id in fs_urls.url_id%TYPE + ); +end fs_url; +/ +show errors + + + +create or replace package body fs_url +as + function new ( + url_id in fs_urls.url_id%TYPE default NULL, + object_type in acs_objects.object_type%TYPE default 'fs_url', + url in fs_urls.url%TYPE, + folder_id in fs_simple_objects.folder_id%TYPE, + name in fs_simple_objects.name%TYPE, + description in fs_simple_objects.description%TYPE, + creation_date in acs_objects.creation_date%TYPE default sysdate, + creation_user in acs_objects.creation_user%TYPE, + creation_ip in acs_objects.creation_ip%TYPE, + context_id in acs_objects.context_id%TYPE + ) return fs_urls.url_id%TYPE + is + v_url_id fs_simple_objects.object_id%TYPE; + begin + v_url_id:= fs_simple_object.new ( + object_id => url_id, + object_type => object_type, + folder_id => folder_id, + name => name, + description => description, + creation_date => creation_date, + creation_user => creation_user, + creation_ip => creation_ip, + context_id => context_id + ); + + insert into fs_urls + (url_id, url) values + (v_url_id, url); + + return v_url_id; + end new; + + procedure delete ( + url_id in fs_urls.url_id%TYPE + ) + is + begin + delete from fs_urls where url_id= fs_url.delete.url_id; + + fs_simple_object.delete(url_id); + end delete; + +end fs_url; +/ +show errors + + Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-simple-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/Attic/file-storage-simple-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-simple-create.sql 2 Apr 2002 07:00:53 -0000 1.1 @@ -0,0 +1,71 @@ + +-- +-- File Storage NonVersioned (Simple) Objects +-- +-- This is to get away from the CR pain when dealing with file-storage of +-- "other" objects +-- +-- @author Ben Adida (ben@openforce) +-- @creation-date 01 April 2002 +-- @cvs-id $Id: file-storage-simple-create.sql,v 1.1 2002/04/02 07:00:53 ben Exp $ +-- + + +-- Non-versioned objects +create table fs_simple_objects ( + object_id integer + constraint fs_simp_obj_id_fk + references acs_objects(object_id) + constraint fs_simp_obj_id_pk + primary key, + folder_id integer + constraint fs_simp_folder_id_fk + references cr_folders(folder_id), + name varchar(250) not null, + description varchar(4000) +); + + +create table fs_urls ( + url_id integer + constraint fs_url_url_id_fk + references fs_simple_objects(object_id) + constraint fs_url_url_id_pk + primary key, + url varchar(250) not null +); + + +create view fs_urls_full as +select * from fs_urls, fs_simple_objects +where url_id = object_id; + + +-- stuff for non-versioned file-storage objects +select acs_object_type__create_type ( + 'fs_simple_object', + 'File Storage Simple Object', + 'File Storage Simple Objects', + 'acs_object', + 'fs_simple_objects', + 'object_id', + NULL, + 'f', + NULL, + NULL +); + +-- links +select acs_object_type__create_type ( + 'fs_url', + 'File Storage URL', + 'File Storage URLs', + 'fs_simple_object', + 'fs_urls', + 'url_id', + NULL, + 'f', + NULL, + NULL +); + Index: openacs-4/packages/file-storage/sql/postgresql/file-storage-simple-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/sql/postgresql/Attic/file-storage-simple-package-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/sql/postgresql/file-storage-simple-package-create.sql 2 Apr 2002 07:00:53 -0000 1.1 @@ -0,0 +1,121 @@ + +-- +-- File Storage NonVersioned (simple) Objects +-- +-- This is to get away from the CR pain when dealing with file-storage of +-- "other" objects +-- +-- @author Ben Adida (ben@openforce) +-- @creation-date 01 April 2002 +-- @cvs-id $Id: file-storage-simple-package-create.sql,v 1.1 2002/04/02 07:00:53 ben Exp $ +-- + + +select define_function_args('fs_simple_object__new','object_id,object_type;fs_simple_object,folder_id,name,description,creation_date,creation_user,creation_ip,context_id'); + +select define_function_args('fs_simple_object__delete','object_id'); + + +create function fs_simple_object__new(integer,varchar,integer,varchar,varchar,timestamp,integer,varchar,integer) +returns integer as ' +DECLARE + p_object_id alias for $1; + p_object_type alias for $2; + p_folder_id alias for $3; + p_name alias for $4; + p_description alias for $5; + p_creation_date alias for $6; + p_creation_user alias for $7; + p_creation_ip alias for $8; + p_context_id alias for $9; + v_object_id integer; +BEGIN + v_object_id:= acs_object__new ( + p_object_id, + p_object_type, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id + ); + + insert into fs_simple_objects + (object_id, folder_id, name, description) values + (v_object_id, p_folder_id, p_name, p_description); + + return v_object_id; + +END; +' language 'plpgsql'; + + + +create function fs_simple_object__delete(integer) +returns integer as ' +DECLARE + p_object_id alias for $1; +BEGIN + PERFORM acs_object__delete(p_object_id); + + return 0; +END; +' language 'plpgsql'; + + + +select define_function_args('fs_url__new','url_id,object_type;fs_url,url,folder_id,name,description,creation_date,creation_user,creation_ip,context_id'); + +select define_function_args('fs_url__delete','url_id'); + + +create function fs_url__new(integer,varchar,varchar,integer,varchar,varchar,timestamp,integer,varchar,integer) +returns integer as ' +DECLARE + p_url_id alias for $1; + p_object_type alias for $2; + p_url alias for $3; + p_folder_id alias for $4; + p_name alias for $5; + p_description alias for $6; + p_creation_date alias for $7; + p_creation_user alias for $8; + p_creation_ip alias for $9; + p_context_id alias for $10; + v_url_id integer; +BEGIN + v_url_id:= fs_simple_object__new ( + p_url_id, + p_object_type, + p_folder_id, + p_name, + p_description, + p_creation_date, + p_creation_user, + p_creation_ip, + p_context_id + ); + + insert into fs_urls + (url_id, url) values + (v_url_id, p_url); + + return v_url_id; +END; +' language 'plpgsql'; + + +create function fs_url__delete(integer) +returns integer as ' +DECLARE + p_url_id alias for $1; +BEGIN + delete from fs_urls where url_id= p_url_id; + + PERFORM fs_simple_object__delete(p_url_id); + + return 0; +END; +' language 'plpgsql'; + + + Index: openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 2 Apr 2002 06:21:24 -0000 1.10 +++ openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 2 Apr 2002 07:00:53 -0000 1.11 @@ -41,7 +41,9 @@ - select fs_folders_and_files.file_id, + (select fs_folders_and_files.file_id, + 'f' as url_p, + 't' as versioned_p, fs_folders_and_files.name, fs_folders_and_files.live_revision, fs_folders_and_files.type, @@ -53,9 +55,25 @@ decode(acs_permission.permission_p(fs_folders_and_files.file_id, :user_id, 'admin'), 'f', 0, 1) as admin_p from fs_folders_and_files where fs_folders_and_files.parent_id = :folder_id - and 't' = acs_permission.permission_p(fs_folders_and_files.file_id, :user_id, 'read') - order by fs_folders_and_files.sort_key, - fs_folders_and_files.name + and 't' = acs_permission.permission_p(fs_folders_and_files.file_id, :user_id, 'read')) + union + (select fs_simple_objects.object_id as file_id, + 't' as url_p, + 'f' as versioned_p, + fs_simple_objects.name, + 0 as live_revision, + 'url' as type, + NULL as last_modified, + 0 as new_p, + 0 as content_size, + decode(acs_permission.permission_p(fs_simple_objects.object_id, :user_id, 'write'), 'f', 0,1) as write_p, + decode(acs_permission.permission_p(fs_simple_objects.object_id, :user_id, 'delete'), 'f', 0, 1) as delete_p, + decode(acs_permission.permission_p(fs_simple_objects.object_id, :user_id, 'admin'), 'f', 0, 1) as admin_p + from fs_simple_objects + where folder_id= :folder_id + and 't' = acs_permission.permission_p(fs_simple_objects.object_id, :user_id, 'read')) + + order by name Index: openacs-4/packages/file-storage/tcl/fs-simple-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/Attic/fs-simple-procs-oracle.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/tcl/fs-simple-procs-oracle.xql 2 Apr 2002 07:00:53 -0000 1.1 @@ -0,0 +1,15 @@ + + + + oracle8.1.6 + + + +declare +begin +fs_simple_object.delete(:object_id); +end; + + + + Index: openacs-4/packages/file-storage/tcl/fs-simple-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/Attic/fs-simple-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/tcl/fs-simple-procs-postgresql.xql 2 Apr 2002 07:00:53 -0000 1.1 @@ -0,0 +1,12 @@ + + + + postgresql7.1 + + + +select fs_simple_object__delete(:object_id); + + + + Index: openacs-4/packages/file-storage/tcl/fs-simple-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/Attic/fs-simple-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/tcl/fs-simple-procs.tcl 2 Apr 2002 07:00:53 -0000 1.1 @@ -0,0 +1,78 @@ +ad_library { + TCL library for the file-storage system (v.4) + extensions for non-versioned (simple) items + + @author Ben Adida (ben@openforce) + @creation-date 01 April 2002 + @version $Id: fs-simple-procs.tcl,v 1.1 2002/04/02 07:00:53 ben Exp $ +} + +namespace eval fs { + + ad_proc -public simple_get_types {} { + return { + {fs_url "URL"} + } + } + + ad_proc -public simple_get_type_pretty_name { + {-type:required} + } { + set lst [simple_get_types] + foreach item $lst { + if {$type == [lindex $item 0]} { + return [lindex $item 1] + } + } + + return "" + } + + ad_proc -public url_new { + {-url_id ""} + {-name:required} + {-description ""} + {-url:required} + {-folder_id:required} + } { + Create a new URL + } { + # Context + set context_id $folder_id + + set extra_vars [ns_set create] + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {url_id name url folder_id description context_id} + + # Instantiate and return + set url_id [package_instantiate_object -extra_vars $extra_vars fs_url] + return $url_id + } + + ad_proc -public url_edit { + {-url_id:required} + {-name:required} + {-description ""} + {-url:required} + } { + # Perform the update + db_transaction { + db_dml update_simple {} + db_dml update_url {} + } + } + + ad_proc -public simple_object_move { + {-object_id:required} + {-folder_id:required} + } { + # Update the location + db_dml update_folder{} + } + + ad_proc -public simple_delete { + {-object_id:required} + } { + # delete the item + db_exec_plsql delete_item {} + } +} Index: openacs-4/packages/file-storage/tcl/fs-simple-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/Attic/fs-simple-procs.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/tcl/fs-simple-procs.xql 2 Apr 2002 07:00:53 -0000 1.1 @@ -0,0 +1,29 @@ + + + + + +update fs_simple_objects set +name= :name, +description= :description +where object_id= :url_id + + + + + +update fs_urls set +url= :url +where url_id= :url_id + + + + + +update fs_simple_objects set +folder_id= :folder_id +where url_id= :url_id + + + +