Index: openacs-4/packages/file-storage/www/file-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file-add.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/file-storage/www/file-add.tcl 11 Dec 2003 21:40:04 -0000 1.5
+++ openacs-4/packages/file-storage/www/file-add.tcl 15 Dec 2003 11:18:45 -0000 1.6
@@ -5,36 +5,133 @@
@creation-date 6 Nov 2000
@cvs-id $Id$
} {
- folder_id:integer,notnull
+ file_id:integer,optional,notnull
+ folder_id:integer,optional,notnull
+ upload_file:trim,optional
+ upload_file.tmpfile:tmpfile,optional
{title ""}
- {lock_title_p 0}
-} -validate {
- valid_folder -requires {folder_id:integer} {
- if ![fs_folder_p $folder_id] {
- ad_complain "[_ file-storage.lt_The_specified_parent_]"
- }
- }
+ {lock_title_p 1}
+
} -properties {
folder_id:onevalue
context:onevalue
title:onevalue
lock_title_p:onevalue
+} -validate {
+ file_id_or_folder_id {
+ if {[exists_and_not_null file_id] && ![exists_and_not_null folder_id]} {
+ set folder_id [db_string get_folder_id "" -default ""]
+ }
+ if {![fs_folder_p $folder_id]} {
+ ad_complain "The specified parent folder is not valid."
+ }
+ }
+ max_size -requires {upload_file} {
+ set n_bytes [file size ${upload_file.tmpfile}]
+ set max_bytes [ad_parameter "MaximumFileSize"]
+ if { $n_bytes > $max_bytes } {
+ ad_complain "Your file is larger than the maximum file size allowed on this system ([util_commify_number $max_bytes] bytes)"
+ }
+ }
}
-# check for write permission on the folder
+set user_id [ad_conn user_id]
+set package_id [ad_conn package_id]
+# check for write permission on the folder or item
-ad_require_permission $folder_id write
+permission::require_permission \
+ -object_id $folder_id \
+ -party_id $user_id \
+ -privilege "write"
-# set templating datasources
+if {![ad_form_new_p -key file_id]} {
+ permission::require_permission \
+ -object_id $file_id \
+ -party_id $user_id \
+ -privilege "write"
+set context [fs_context_bar_list -final "[_ file-storage.Add_Revision]" $folder_id]
+
+} else {
+ set context [fs_context_bar_list -final "[_ file-storage.Add_File]" $folder_id]
+}
+# if title isn't passed in ignore lock_title_p
+if {[empty_string_p $title]} {
+ set lock_title_p 0
+}
-set context [fs_context_bar_list -final "[_ file-storage.Add_File]" $folder_id]
+ad_form -html { enctype multipart/form-data } -export { folder_id } -form {
+ file_id:key
+ {upload_file:file {label "Upload File"} {html "size 30"}}
+}
-# Should probably generate the item_id and version_id now for
-# double-click protection
+if {$lock_title_p} {
+ ad_form -extend -form {
+ {title_display:text(inform) {label [_ file-storage.Title]} }
+ {title:text(hidden) {value $title}}
+ }
+} else {
+ ad_form -extend -form {
+ {title:text,optional {label \#file-storage.Title\#} {html {size 30}} }
+ }
+}
+ad_form -extend -form {
+ {description:text(textarea),optional {label \#file-storage.Description\#} {html "rows 5 cols 35"}}
+} -select_query_name {get_file} -new_data {
+ # upload a new file
+ # if the user choose upload from the folder view
+ # and the file with the same name already exists
+ # we create a new revision
+ set name [template::util::file::get_property filename $upload_file]
+ if {[string equal $title ""]} {
+ set title $name
+ }
+ set existing_item_id [fs::get_item_id -name $name -folder_id $folder_id]
+ if {![empty_string_p $existing_item_id]} {
+ # file with the same name already exists
+ # in this folder, create a new revision
+ set file_id $existing_item_id
+ permission::require_permission \
+ -object_id $file_id \
+ -party_id $user_id \
+ -privilege $write
+ }
+
+ fs::add_file \
+ -name [template::util::file::get_property filename $upload_file] \
+ -item_id $file_id \
+ -parent_id $folder_id \
+ -tmp_filename [template::util::file::get_property tmp_filename $upload_file] \
+ -creation_user $user_id \
+ -creation_ip [ad_conn peeraddr] \
+ -title $title \
+ -description $description \
+ -package_id $package_id
+
+ ad_returnredirect "."
+ ad_script_abort
+} -edit_data {
+
+ fs::add_version \
+ -name [template::util::file::get_property filename $upload_file] \
+ -tmp_filename [template::util::file::get_property tmp_filename $upload_file] \
+ -item_id $file_id \
+ -parent_id $folder_id \
+ -creation_user $user_id \
+ -creation_ip [ad_conn peeraddr] \
+ -title $title \
+ -description $description \
+ -package_id $package_id
+
+ ad_returnredirect "."
+ ad_script_abort
+}
+
# if title isn't passed in ignore lock_title_p
if {[empty_string_p $title]} {
set lock_title_p 0
}
set unpack_available_p [expr ![empty_string_p [string trim [parameter::get -parameter UnzipBinary]]]]
+
+ad_return_template
\ No newline at end of file
Index: openacs-4/packages/file-storage/www/file-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/Attic/file-postgresql.xql,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/file-storage/www/file-postgresql.xql 11 Dec 2003 21:40:04 -0000 1.10
+++ openacs-4/packages/file-storage/www/file-postgresql.xql 15 Dec 2003 11:18:45 -0000 1.11
@@ -18,7 +18,7 @@
acs_permission__permission_p(:file_id,:user_id,'write') as write_p,
acs_permission__permission_p(:file_id,:user_id,'delete') as delete_p,
acs_permission__permission_p(:file_id,:user_id,'admin') as admin_p,
- content_item__get_path(o.object_id, :root_folder_id) as file_url
+ content_item__get_path(o.object_id, :root_folder_id) as file_url, i.live_revision
from acs_objects o, cr_revisions r, cr_items i
where o.object_id = :file_id
and i.item_id = o.object_id
Index: openacs-4/packages/file-storage/www/file.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file.adp,v
diff -u -r1.17 -r1.18
--- openacs-4/packages/file-storage/www/file.adp 11 Dec 2003 21:40:04 -0000 1.17
+++ openacs-4/packages/file-storage/www/file.adp 15 Dec 2003 11:18:45 -0000 1.18
@@ -3,94 +3,13 @@
@title;noquote@
@context;noquote@
-
-
-#file-storage.back_to_folder_view#
-
-
-
-
- #file-storage.lt_All_Versions_of_title#
- #file-storage.lt_Live_version_of_title#.
- |
-
-
- #file-storage.Version_filename# |
- #file-storage.Author# |
- #file-storage.Size_bytes# |
- #file-storage.Type# |
- #file-storage.Modified# |
- #file-storage.Version_Notes# |
- #file-storage.Actions_1# |
-
-
-
-
-
-
-
- @version.title@
-
-
- @version.title@
-
- |
- @version.author@ |
- @version.content_size_pretty@ |
- @version.type@ |
- @version.last_modified_pretty@ |
- @version.description@ |
-
-
- #file-storage.delete#
- |
-
-
- #file-storage.lt_administer_permission#
-
- |
-
-
-
-
-
- #file-storage.lt_There_are_no_versions# |
-
-
-
-
-
-
+
+
Index: openacs-4/packages/file-storage/www/file.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/file.tcl,v
diff -u -r1.16 -r1.17
--- openacs-4/packages/file-storage/www/file.tcl 11 Dec 2003 21:40:04 -0000 1.16
+++ openacs-4/packages/file-storage/www/file.tcl 15 Dec 2003 11:18:45 -0000 1.17
@@ -33,26 +33,63 @@
set context [fs_context_bar_list $file_id]
set show_administer_permissions_link_p [ad_parameter "ShowAdministerPermissionsLinkP"]
-
set root_folder_id [fs::get_root_folder]
+db_1row file_info ""
-db_1row file_info {}
-
# We use the new db_map here
if {[string equal $show_all_versions_p "t"]} {
-# append sql "
-#and r.item_id = :file_id"
set show_versions [db_map show_all_versions]
} else {
-# append sql "
-#and r.revision_id = (select live_revision from cr_items where item_id = :file_id)"
set show_versions [db_map show_live_version]
}
+set actions [list "Upload Revision" version-add?[export_vars file_id] "Upload a new version of this file" \
+ "Rename File" file-edit?[export_vars file_id] "Rename file" \
+ "Copy File" file-copy?[export_vars file_id] "Copy file" \
+ "Move File" file-move?[export_vars file_id] "Move file" \
+ "Delete File" file-delete?[export_vars file_id] "Delete file"]
-db_multirow -unclobber -extend { last_modified_pretty content_size_pretty } version version_info {} {
+if {[string equal $delete_p "t"]} {
+ lappend actions [_ file-storage.Set_Permissions] "/permissions/one?[export_vars {{object_id $file_id}}]" [_ file-storage.lt_Modify_permissions_on]
+}
+
+template::list::create \
+ -name version \
+ -no_data [_ file-storage.lt_There_are_no_versions] \
+ -multirow version \
+ -actions $actions \
+ -elements {
+ title {
+ label \#file-storage.Title\#
+ link_url_col version_url
+ }
+ author { label \#file-storage.Author\#}
+ content_size {
+ label \#file-storage.Size\#
+ display_col content_size_pretty
+ }
+ type { label \#file-storage.Type\#}
+ last_modified_ansi {
+ label \#file-storage.Last_Modified\#
+ display_col last_modified_pretty
+ }
+ description { label \#file-storage.Version_Notes\#}
+ version_delete {label "" link_url_col version_delete_url}
+ }
+
+db_multirow -unclobber -extend { last_modified_pretty content_size_pretty version_url version_delete version_delete_url} version version_info {} {
set last_modified_ansi [lc_time_system_to_conn $last_modified_ansi]
set last_modified_pretty [lc_time_fmt $last_modified_ansi "%x %X"]
- set content_size_pretty [lc_numeric $content_size]
+ set content_size_pretty "[lc_numeric $content_size] [_ file-storage.bytes]"
+ if {[string equal $title ""]} {
+ set title "[_ file-storage.untitled]"
+ }
+ if {[string equal $version_id $live_revision]} {
+ set version_url "view/${file_url}?[export_vars {{revision_id $version_id}}]"
+ } else {
+ set version_url "view/${file_url}"
+ }
+ set version_delete [_ file-storage.Delete_Version]
+ set version_delete_url "version-delete?[export_vars version_id]"
}
set return_url "[ad_conn url]?file_id=$file_id"
Index: openacs-4/packages/file-storage/www/folder-chunk-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-chunk-postgresql.xql,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/file-storage/www/folder-chunk-postgresql.xql 13 Aug 2003 13:30:53 -0000 1.8
+++ openacs-4/packages/file-storage/www/folder-chunk-postgresql.xql 15 Dec 2003 11:18:45 -0000 1.9
@@ -33,8 +33,7 @@
where m.object_id = fs_objects.object_id
and m.party_id = :viewing_user_id
and m.privilege = 'read')
- order by fs_objects.sort_key, fs_objects.name
-
+ $orderby
Index: openacs-4/packages/file-storage/www/folder-chunk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-chunk.tcl,v
diff -u -r1.15 -r1.16
--- openacs-4/packages/file-storage/www/folder-chunk.tcl 3 Oct 2003 14:00:13 -0000 1.15
+++ openacs-4/packages/file-storage/www/folder-chunk.tcl 15 Dec 2003 11:18:45 -0000 1.16
@@ -5,6 +5,7 @@
@creation-date Feb 22, 2002
@cvs-id $Id$
} -query {
+ {orderby:optional}
} -properties {
folder_name:onevalue
contents:multirow
@@ -32,12 +33,64 @@
set root_folder_id [fs::get_root_folder]
-db_multirow -extend { last_modified_pretty content_size_pretty } contents select_folder_contents {} {
+set actions [list]
+set actions [list "Upload File" file-add?[export_vars folder_id] "Upload a file in this folder" "Add Link" simple-add?[export_vars folder_id] "Add a link to a web page" "\#file-storage.New_Folder\#" folder-create?[export_vars {{parent_id $folder_id}}] "\#file-storage.Create_a_new_folder\#" ]
+
+#if {$delete_p} {
+# lappend actions "Delete Folder" folder-delete "Delete folder and all contents"
+#}
+
+#set n_past_filter_values [list [list "Yesterday" 1] [list [_ file-storage.last_week] 7] [list [_ file-storage.last_month] 30]]
+set elements [list icon \
+ [list label "" \
+ display_template {}] \
+ name \
+ [list label [_ file-storage.Name] \
+ link_url_col file_url \
+ orderby_desc {fs_objects.name desc} \
+ orderby_asc {fs_objects.name asc}] \
+ content_size_pretty \
+ [list label [_ file-storage.Size] \
+ orderby_desc {content_size desc} \
+ orderby_asc {content_size asc}] \
+ type [list label [_ file-storage.Type] \
+ orderby_desc {type desc} \
+ orderby_asc {type asc}] \
+ last_modified_pretty \
+ [list label [_ file-storage.Last_Modified] \
+ orderby_desc {last_modified_ansi desc} \
+ orderby_asc {last_modified_ansi asc}] \
+ properties_link \
+ [list label "" \
+ link_url_col properties_url]
+ ]
+
+template::list::create \
+ -name contents \
+ -multirow contents \
+ -key object_id \
+ -actions $actions \
+ -filters {
+ folder_id {hide_p 1}
+ } \
+ -elements $elements
+
+set orderby [template::list::orderby_clause -orderby -name contents]
+
+if {[string equal $orderby ""]} {
+ set orderby " order by fs_objects.sort_key, fs_objects.name asc"
+}
+
+db_multirow -extend { icon last_modified_pretty content_size_pretty properties_link properties_url} contents select_folder_contents {} {
set last_modified_ansi [lc_time_system_to_conn $last_modified_ansi]
set last_modified_pretty [lc_time_fmt $last_modified_ansi "%x %X"]
-
set content_size_pretty [lc_numeric $content_size]
+ if {[string equal $type "folder"]} {
+ append content_size_pretty " [_ file-storage.items]"
+ } else {
+ append content_size_pretty " [_ file-storage.bytes]"
+ }
set file_upload_name [fs::remove_special_file_system_characters -string $file_upload_name]
@@ -46,6 +99,18 @@
}
set name [lang::util::localize $name]
+ if {![string equal $type folder]} {
+ set properties_link [_ file-storage.properties]
+ set properties_url "file?[export_vars {{file_id $object_id}}]"
+ set icon "/resources/file-storage/file.gif"
+ set file_url "view/${file_url}"
+ } else {
+ set properties_link ""
+ set properties_url ""
+ set icon "/resources/file-storage/folder.gif"
+ set file_url "index?[export_vars {{folder_id $object_id}}]"
+ }
+
}
ad_return_template
Index: openacs-4/packages/file-storage/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/index.adp,v
diff -u -r1.22 -r1.23
--- openacs-4/packages/file-storage/www/index.adp 13 Oct 2003 17:16:08 -0000 1.22
+++ openacs-4/packages/file-storage/www/index.adp 15 Dec 2003 11:18:45 -0000 1.23
@@ -2,52 +2,9 @@
@folder_name;noquote@
@folder_name;noquote@
@context;noquote@
+
+ #file-storage.index_page_navigate_up_folder#
+
-
-
-
-
Index: openacs-4/packages/file-storage/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/index.tcl,v
diff -u -r1.20 -r1.21
--- openacs-4/packages/file-storage/www/index.tcl 17 May 2003 10:39:54 -0000 1.20
+++ openacs-4/packages/file-storage/www/index.tcl 15 Dec 2003 11:18:45 -0000 1.21
@@ -8,6 +8,7 @@
} {
{folder_id:integer [fs_get_root_folder]}
{n_past_days:integer "99999"}
+ {orderby:optional}
} -validate {
valid_folder -requires {folder_id:integer} {
if {![fs_folder_p $folder_id]} {
@@ -80,9 +81,14 @@
set context [fs_context_bar_list $folder_id]
set up_url {}
-if { [llength $context] > 1 } {
- set up_url [lindex [lindex $context end-1] 0]
- set up_name [lindex [lindex $context end-1] 1]
+if { !${root_folder_p}} {
+ if {[llength $context] == 1} {
+ set up_url [ad_conn package_url]
+ set up_name [ad_conn instance_name]
+ } else {
+ set up_url [lindex [lindex $context end-1] 0]
+ set up_name [lindex [lindex $context end-1] 1]
+ }
}
ad_return_template