Index: openacs-4/packages/file-storage/file-storage.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/file-storage.info,v diff -u -r1.12 -r1.13 --- openacs-4/packages/file-storage/file-storage.info 24 Apr 2002 20:06:25 -0000 1.12 +++ openacs-4/packages/file-storage/file-storage.info 26 Apr 2002 21:07:10 -0000 1.13 @@ -26,14 +26,20 @@ + + + + + + @@ -88,6 +94,8 @@ + + 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.12 -r1.13 --- openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 4 Apr 2002 03:01:06 -0000 1.12 +++ openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 26 Apr 2002 21:07:10 -0000 1.13 @@ -39,7 +39,7 @@ - + select fs_objects.object_id, fs_objects.name, @@ -59,87 +59,73 @@ - - - - begin - :1 := file_storage.get_folder_name(:folder_id); - end; + + + + - - + + + begin + :1 := file_storage.get_folder_name(:folder_id); + end; + + - - - - - select count(*) - from cr_items - where item_id in (select item_id - from cr_items - connect by prior item_id = parent_id - start with item_id = :item_id) - and acs_permission.permission_p(item_id,:user_id,:privilege) = 'f' + + + select count(*) + from cr_items + where item_id in (select item_id + from cr_items + connect by prior item_id = parent_id + start with item_id = :item_id) + and acs_permission.permission_p(item_id, :user_id, :privilege) = 'f' + + - - + + + select item_id as child_item_id + from cr_items + connect by prior item_id = parent_id + start with item_id = :item_id + + - - - - - select item_id as child_item_id - from cr_items - connect by prior item_id = parent_id - start with item_id = :item_id - - - + + + select count(*) + from cr_revisions + where item_id = :child_item_id + and acs_permission.permission_p(revision_id, :user_id, :privilege) = 'f' + + - - - - - select count(*) - from cr_revisions - where item_id = :child_item_id - and acs_permission.permission_p(revision_id,:user_id,:privilege) = 'f' + + + begin + :1 := file_storage.get_title(:item_id); + end; + + - - + + + select case when file_storage.get_content_type(i.item_id) = 'content_folder' + then 'index?folder_id=' + else 'file?file_id=' + end || i.item_id, + file_storage.get_title(i.item_id) + from cr_items i + where item_id not in (select i2.item_id + from cr_items i2 + connect by prior i2.parent_id = i2.item_id + start with i2.item_id = file_storage.get_root_folder([ad_conn package_id])) + connect by prior i.parent_id = i.item_id + start with item_id = :start_id + order by level desc + + - - - - - begin - :1 := file_storage.get_title(:item_id); - end; - - - - - - - - - select case when file_storage.get_content_type(i.item_id) = 'content_folder' - then 'index?folder_id=' - else 'file?file_id=' - end || i.item_id, - file_storage.get_title(i.item_id) - from cr_items i - where item_id not in ( - select i2.item_id - from cr_items i2 - connect by prior i2.parent_id = i2.item_id - start with i2.item_id = - file_storage.get_root_folder([ad_conn package_id])) - connect by prior i.parent_id = i.item_id - start with item_id = :start_id - order by level desc - - - - Index: openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql,v diff -u -r1.18 -r1.19 --- openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 4 Apr 2002 03:01:06 -0000 1.18 +++ openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 26 Apr 2002 21:07:10 -0000 1.19 @@ -31,7 +31,7 @@ - + select fs_objects.object_id, fs_objects.name, @@ -51,85 +51,66 @@ - - + + + + - select file_storage__get_folder_name(:folder_id); + + + select file_storage__get_folder_name(:folder_id); + + - - + + + select count(*) + from cr_items c1, cr_items c2 + where c2.item_id = :item_id + and c1.tree_sortkey between c2.tree_sortkey and tree_right(c2.tree_sortkey) + and not acs_permission__permission_p(c1.item_id, :user_id, :privilege) + + - - - + + + select c1.item_id as child_item_id + from cr_items c1, cr_items c2 + where c2.item_id = :item_id + and c1.tree_sortkey between c2.tree_sortkey and tree_right(c2.tree_sortkey) + order by c1.tree_sortkey + + - select count(*) - from cr_items c1, cr_items c2 - where c2.item_id = :item_id - and c1.tree_sortkey between c2.tree_sortkey and tree_right(c2.tree_sortkey) - and not acs_permission__permission_p(c1.item_id,:user_id,:privilege) + + + select count(*) + from cr_revisions + where item_id = :child_item_id + and acs_permission__permission_p(revision_id, :user_id, :privilege) = 'f' + + - - + + + select file_storage__get_title(:item_id) + + - - - + + + select (case when file_storage__get_content_type(i.item_id) = 'content_folder' + then 'index?folder_id=' + else 'file?file_id=' + end) || i.item_id, + file_storage__get_title(i.item_id) + from (select tree_ancestor_keys(cr_items_get_tree_sortkey(:start_id)) as tree_sortkey) parents, + (select tree_sortkey from cr_items where item_id = file_storage__get_root_folder([ad_conn package_id])) root, + cr_items i + where i.tree_sortkey = parents.tree_sortkey + and i.tree_sortkey > root.tree_sortkey + order by i.tree_sortkey asc + + - select c1.item_id as child_item_id - from cr_items c1, cr_items c2 - where c2.item_id = :item_id - and c1.tree_sortkey between c2.tree_sortkey and tree_right(c2.tree_sortkey) - order by c1.tree_sortkey - - - - - - - - - select count(*) - from cr_revisions - where item_id = :child_item_id - and acs_permission__permission_p(revision_id,:user_id,:privilege) = 'f' - - - - - - - - - select file_storage__get_title(:item_id) - - - - - - - - - select (case when file_storage__get_content_type(i.item_id) = 'content_folder' - then 'index?folder_id=' - else 'file?file_id=' - end) || i.item_id, - file_storage__get_title(i.item_id) - from (select tree_ancestor_keys(cr_items_get_tree_sortkey(:start_id)) as tree_sortkey) parents, - (select tree_sortkey from cr_items where item_id = file_storage__get_root_folder([ad_conn package_id])) root, - cr_items i - where i.tree_sortkey = parents.tree_sortkey - and i.tree_sortkey > root.tree_sortkey - order by i.tree_sortkey asc - - - - - - - - - - - Index: openacs-4/packages/file-storage/tcl/file-storage-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 2 Apr 2002 06:21:24 -0000 1.10 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 26 Apr 2002 21:07:10 -0000 1.11 @@ -228,7 +228,7 @@ namespace eval fs { ad_proc -public new_root_folder { - {-package_id:required} + {-package_id ""} {-pretty_name ""} {-description ""} } { @@ -238,18 +238,26 @@ @return folder_id of the new root folder } { + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + return [db_exec_plsql new_root_folder {}] } ad_proc -public get_root_folder { - {-package_id:required} + {-package_id ""} } { Get the root folder of a package instance. @param package_id Package instance of the root folder to retrieve @return folder_id of the root folder retrieved } { + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + return [db_exec_plsql get_root_folder {}] } @@ -282,6 +290,24 @@ return [db_exec_plsql new_folder {}] } + ad_proc -public get_folder_name { + {-folder_id:required} + } { + Select the name of this folder. + } { + return [db_string select_folder_name {} -default $folder_id] + } + + ad_proc -public folder_p { + {-object_id:required} + } { + Is this object a folder? + + @return true if object_id is a folder + } { + return [db_string select_folder_p {} -default 0] + } + ad_proc -public get_folder { {-name:required} {-parent_id:required} @@ -295,12 +321,12 @@ @return folder_id of the folder, or null if no folder was found by that name } { - return [db_string get_folder {} -default ""] + return [db_string select_folder {} -default ""] } ad_proc -public get_folder_contents { - {-folder_id:required} - {-user_id ""} + {-folder_id ""} + !{-user_id ""} {-n_past_days "-1"} } { Retrieve the contents of the specified folder in the form of a list @@ -315,15 +341,19 @@ permission) @param n_past_days Mark files that are newer than the past N days as new } { + if {[empty_string_p $folder_id]} { + set folder_id [fs::get_root_folder -package_id [ad_conn package_id]] + } + if {[empty_string_p $user_id]} { set user_id [acs_magic_object "the_public"] } - return [db_list_of_ns_sets get_folder_contents {}] + return [db_list_of_ns_sets select_folder_contents {}] } ad_proc -public get_folder_contents_count { - {-folder_id:required} + {-folder_id ""} {-user_id ""} } { Retrieve the count of contents of the specified folder. @@ -332,11 +362,42 @@ @param user_id The viewer of the contents (to make sure they have permission) } { + if {[empty_string_p $folder_id]} { + set folder_id [fs::get_root_folder -package_id [ad_conn package_id]] + } + if {[empty_string_p $user_id]} { set user_id [acs_magic_object "the_public"] } - return [db_string get_folder_contents_count {}] + return [db_string select_folder_contents_count {}] } + ad_proc -public get_folder_items_recursive { + {-folder_id ""} + {-user_id ""} + {-n_past_days "-1"} + } { + Retrieve the contents of a folder and any of its child folders. + Returns a list of ns_sets, one for each row, with the following keys: + + file_id, name, live_revision, type, + last_modified, content_size, sort_key + + @param folder_id The folder for which to retrieve contents + @param user_id The viewer of the contents (to make sure they have + permission) + @param n_past_days Mark files that are newer than the past N days as new + } { + if {[empty_string_p $folder_id]} { + set folder_id [fs::get_root_folder -package_id [ad_conn package_id]] + } + + if {[empty_string_p $user_id]} { + set user_id [acs_magic_object "the_public"] + } + + return [db_list_of_ns_sets select_folder_items_recursive {}] + } + } Index: openacs-4/packages/file-storage/tcl/file-storage-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/tcl/file-storage-procs.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/file-storage/tcl/file-storage-procs.xql 4 Apr 2002 03:01:06 -0000 1.4 +++ openacs-4/packages/file-storage/tcl/file-storage-procs.xql 26 Apr 2002 21:07:10 -0000 1.5 @@ -1,46 +1,40 @@ - - + + + select object_type + from acs_objects + where object_id = :folder_id + + - select object_type - from acs_objects - where object_id = :folder_id + + + select parent_id + from cr_items + where item_id = :item_id + + - - + + + select count(*) + from cr_mime_types + where mime_type = :mime_type + + - - + + + insert into cr_mime_types + (mime_type, file_extension) + values + (:mime_type, :extension) + + - select parent_id from cr_items where item_id = :item_id - - - - - - - - select count(*) from cr_mime_types - where mime_type = :mime_type - - - - - - - - - insert into cr_mime_types - (mime_type, file_extension) - values - (:mime_type, :extension) - - - - - + select item_id from cr_items @@ -49,17 +43,30 @@ - + - select (select count(*) - from cr_items - where cr_items.parent_id = :folder_id) - + - (select count(*) - from fs_simple_objects - where fs_simple_objects.folder_id = :folder_id) + select name + from fs_folders + where folder_id = :folder_id + + + + + + select count(*) from dual + where exists (select 1 + from fs_folders + where folder_id = :object_id) + + + select count(*) + from fs_folders + where folder_id = :folder_id + + + Index: openacs-4/packages/file-storage/www/folder-contents.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/folder-contents.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/www/folder-contents.adp 26 Apr 2002 21:07:10 -0000 1.1 @@ -0,0 +1,33 @@ + +@folder_name@ +@folder_name@ +@context_bar@ + + + + + + + + + + +
  • + INot including items from subfolders + ( + + exclude + + + include + + ) +
  • + + Showing files modified within the past days. + +
    + +
    + +@table@ Index: openacs-4/packages/file-storage/www/folder-contents.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/folder-contents.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/file-storage/www/folder-contents.tcl 26 Apr 2002 21:07:10 -0000 1.1 @@ -0,0 +1,112 @@ +# file-storage/www/folder-contents.tcl + +ad_page_contract { + @author yon (yon@openforce.net) + @creation-date Apr 25, 2002 + @version $Id: folder-contents.tcl,v 1.1 2002/04/26 21:07:10 yon Exp $ +} -query { + {folder_id:integer {[fs::get_root_folder]}} + {recurse_p:boolean 0} + {n_past_days:integer 999999} + {orderby "fs_objects.name"} +} -validate { + valid_folder -requires {folder_id:integer} { + if {[empty_string_p $folder_id] || ![fs::folder_p -object_id $folder_id]} { + ad_complain + } + } +} -errors { + valid_folder {No valid folder was found} +} -properties { + folder_id:onevalue + folder_name:onevalue + context_bar:onevalue + recurse_p:onevalue + n_past_days:onevalue + orderby:onevalue + table:onevalue +} + +form create n_past_days_form + +set options {{All 999999} {1 1} {2 2} {3 3} {7 7} {14 14} {30 30}} +element create n_past_days_form n_past_days \ + -label "" \ + -datatype text \ + -widget select \ + -options $options \ + -html {onChange document.n_past_days_form.submit()} \ + -value $n_past_days + +element create n_past_days_form folder_id \ + -label "Folder ID" \ + -datatype text \ + -widget hidden \ + -value $folder_id + +element create n_past_days_form recurse_p \ + -label "RecurseP" \ + -datatype text \ + -widget hidden \ + -value $recurse_p + +element create n_past_days_form orderby \ + -label "Order By" \ + -datatype text \ + -widget hidden \ + -value $orderby + +if {[form is_valid n_past_days_form]} { + form get_values n_past_days_form \ + n_past_days folder_id recurse_p orderby +} + +set table_def [list] + +lappend table_def [list name Name {fs_objects.name $order} "\$name"] +lappend table_def [list folder_name Folder {} "\$folder_name"] +lappend table_def {type Type {fs_objects.type $order} {c}} +lappend table_def {size Size {fs_objects.content_size $order} {[ad_decode $type Folder "$content_size item[ad_decode $content_size 1 {} s]" URL {} "$content_size byte[ad_decode $content_size 1 {} s]"]}} +lappend table_def {last_modified {Last Modified} {fs_objects.last_modified $order} {[util_AnsiDatetoPrettyDate $last_modified]}} + +if {$recurse_p} { + set sql " + select fs_objects.*, + fs_folders.name as folder_name + from fs_objects, + fs_folders + where fs_objects.object_id in (select acs_objects.object_id + from acs_objects + connect by acs_objects.context_id = prior acs_objects.object_id + start with acs_objects.context_id = :folder_id) + and fs_objects.parent_id = fs_folders.folder_id + and fs_objects.type <> 'Folder' + and fs_objects.last_modified >= (sysdate - :n_past_days) + [ad_order_by_from_sort_spec $orderby $table_def] + " +} else { + set sql " + select fs_objects.*, + fs_folders.name as folder_name + from fs_objects, + fs_folders + where fs_objects.parent_id = :folder_id + and fs_folders.folder_id = :folder_id + and fs_objects.last_modified >= (sysdate - :n_past_days) + [ad_order_by_from_sort_spec $orderby $table_def] + " +} + +set table [ad_table \ + -Torderby $orderby \ + -Tmissing_text "
    Folder [fs::get_folder_name -folder_id $folder_id] is empty.
    " \ + -Ttable_extra_html {width="95%"} \ + select_folder_contents \ + $sql \ + $table_def +] + +set folder_name [fs::get_folder_name -folder_id $folder_id] +set context_bar [fs_context_bar_list $folder_id] + +ad_return_template