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.38 -r1.39
--- openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 21 Nov 2017 11:31:29 -0000 1.38
+++ openacs-4/packages/file-storage/tcl/file-storage-procs-oracle.xql 15 Jun 2018 15:11:04 -0000 1.39
@@ -129,22 +129,6 @@
-
-
- select person.name(o.creation_user) as owner
- from acs_objects o where o.object_id = :item_id
-
-
-
-
-
- select site_node.url(node_id) as path1 from site_nodes
- where object_id = (select package_id
- from fs_root_folders where
- fs_root_folders.folder_id = :root_folder)
-
-
-
select content
@@ -161,15 +145,6 @@
-
-
- begin
- :1 := content_item.get_id ( :name, :folder_id, 'f' );
- end;
-
-
-
-
begin
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.50 -r1.51
--- openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 21 Nov 2017 11:31:29 -0000 1.50
+++ openacs-4/packages/file-storage/tcl/file-storage-procs-postgresql.xql 15 Jun 2018 15:11:04 -0000 1.51
@@ -128,22 +128,6 @@
-
-
- select person__name(o.creation_user) as owner from
- acs_objects o where o.object_id = :item_id
-
-
-
-
-
- select site_node__url(node_id) as path1 from site_nodes
- where object_id = (select package_id
- from fs_root_folders where
- fs_root_folders.folder_id = :root_folder)
-
-
-
select lob
@@ -160,13 +144,6 @@
-
-
- select content_item__get_id ( :name, :folder_id, 'f' )
-
-
-
-
select file_storage__new_file (
@@ -251,26 +228,6 @@
-
-
- select content_revision__new (
- :title, -- title
- :description, -- description
- now(), -- publish_date
- :mime_type, -- mime_type
- null, -- ns_language
- :content_body, -- text
- :item_id, -- item_id
- null,
- now(), -- creation_date
- :creation_user, -- creation_user
- :creation_ip, -- creation_ip
- null,
- :package_id -- package_id
- )
-
-
-
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.82 -r1.83
--- openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 15 Jun 2018 12:28:10 -0000 1.82
+++ openacs-4/packages/file-storage/tcl/file-storage-procs.tcl 15 Jun 2018 15:11:04 -0000 1.83
@@ -43,15 +43,10 @@
Returns 1 if the folder_id corresponds to a folder in the file-storage
system. Returns 0 otherwise.
} {
- if {[db_string object_type {
- select object_type
- from acs_objects
- where object_id = :folder_id
- } -default ""] eq "content_folder"} {
- return 1
- } else {
- return 0
- }
+ return [db_0or1row is_folder {
+ select 1 from acs_objects
+ where object_id = :folder_id
+ and object_type = 'content_folder'}]
}
ad_proc fs_file_p {
@@ -60,15 +55,10 @@
Returns 1 if the file_id corresponds to a file in the file-storage
system. Returns 0 otherwise.
} {
- if {[db_string object_type {
- select object_type
- from acs_objects
- where object_id = :file_id
- } -default ""] eq "content_item"} {
- return 1
- } else {
- return 0
- }
+ return [db_0or1row is_file {
+ select 1 from acs_objects
+ where object_id = :file_id
+ and object_type = 'content_item'}]
}
ad_proc fs_version_p {
@@ -77,15 +67,10 @@
Returns 1 if the version_id corresponds to a version in the file-storage
system. Returns 0 otherwise.
} {
- if {[db_string object_type {
- select object_type
- from acs_objects
- where object_id = :version_id
- } -default ""] eq "file_storage_object"} {
- return 1
- } else {
- return 0
- }
+ return [db_0or1row is_version {
+ select 1 from acs_objects
+ where object_id = :version_id
+ and object_type = 'file_storage_object'}]
}
#
@@ -155,17 +140,15 @@
set start_id [db_string parent_id {
select parent_id from cr_items where item_id = :item_id
}]
- set final [db_exec_plsql title "begin
- :1 := file_storage.get_title(:item_id);
- end;"]
+ set final [db_exec_plsql title {}]
} else {
set start_id $item_id
}
set extra_vars [concat &$extra_vars]
set context_bar [db_list_of_lists context_bar {}]
- if {!($item_id == $root_folder_id)} {
+ if {$item_id != $root_folder_id} {
lappend context_bar $final
}
return $context_bar
@@ -734,10 +717,12 @@
Get the item_id of a file
} {
if {$folder_id eq ""} {
- set package_id [ad_conn package_id]
- set folder_id [fs_get_root_folder -package_id $package_id]
+ set folder_id [fs_get_root_folder -package_id [ad_conn package_id]]
}
- return [db_exec_plsql get_item_id ""]
+ return [content::item::get_id \
+ -item_path $name \
+ -root_folder_id $folder_id \
+ -resolve_index "f"]
}
ad_proc -public fs::add_file {
@@ -1008,7 +993,15 @@
db_dml set_lob_size ""
}
text {
- set revision_id [db_exec_plsql new_text_revision {}]
+ set revision_id [content::revision::new \
+ -item_id $item_id \
+ -title $title \
+ -description $description \
+ -content $content_body \
+ -mime_type $mime_type \
+ -creation_user $creation_user \
+ -creation_ip $creation_ip \
+ -package_id $package_id]
}
}
@@ -1132,9 +1125,13 @@
}
}
- db_exec_plsql delete_file ""
+ fs::do_notifications \
+ -folder_id $parent_id \
+ -filename $version_name \
+ -item_id $item_id \
+ -action "delete_file"
- fs::do_notifications -folder_id $parent_id -filename $version_name -item_id $item_id -action "delete_file"
+ db_exec_plsql delete_file {}
}
ad_proc fs::delete_folder {
@@ -1157,11 +1154,16 @@
}
set version_name [get_object_name -object_id $folder_id]
- db_exec_plsql delete_folder {}
if { !$no_notifications_p } {
- fs::do_notifications -folder_id $parent_id -filename $version_name -item_id $folder_id -action "delete_folder"
+ fs::do_notifications \
+ -folder_id $parent_id \
+ -filename $version_name \
+ -item_id $folder_id \
+ -action "delete_folder"
}
+
+ db_exec_plsql delete_folder {}
}
ad_proc fs::delete_version {
@@ -1247,34 +1249,44 @@
set package_id [lindex $package_and_root 0]
}
- if {$action eq "new_file"} {
- set action_type "[_ file-storage.New_File_Uploaded]"
- } elseif {$action eq "new_url"} {
- set action_type "[_ file-storage.New_URL_Uploaded]"
- } elseif {$action eq "new_version"} {
- set action_type "[_ file-storage.lt_New_version_of_file_u]"
- } elseif {$action eq "delete_file"} {
- set action_type "[_ file-storage.File_deleted]"
- } elseif {$action eq "delete_url"} {
- set action_type "[_ file-storage.URL_deleted]"
- } elseif {$action eq "delete_folder"} {
- set action_type "[_ file-storage.Folder_deleted]"
- } else {
- error "Unknown file-storage notification action: $action"
+ switch $action {
+ "new_file" {
+ set action_type "[_ file-storage.New_File_Uploaded]"
+ }
+ "new_url" {
+ set action_type "[_ file-storage.New_URL_Uploaded]"
+ }
+ "new_version" {
+ set action_type "[_ file-storage.lt_New_version_of_file_u]"
+ }
+ "delete_file" {
+ set action_type "[_ file-storage.File_deleted]"
+ }
+ "delete_url" {
+ set action_type "[_ file-storage.URL_deleted]"
+ }
+ "delete_folder" {
+ set action_type "[_ file-storage.Folder_deleted]"
+ }
+ default {
+ error "Unknown file-storage notification action: $action"
+ }
}
set url "[ad_url]"
set new_content ""
- db_0or1row get_owner_name {}
+ set creation_user [acs_object::get_element \
+ -object_id $item_id \
+ -element creation_user]
+ set owner [acs_user::get_element \
+ -user_id $creation_user \
+ -element name]
- if {$action eq "new_file" || $action eq "new_url" || $action eq "new_version"} {
-
-
+ if {$action in {"new_file" "new_url" "new_version"}} {
+
if {$action eq "new_version"} {
set sql "select description as description from cr_revisions
where cr_revisions.revision_id = :item_id"
- } elseif {[string match "*folder" $action]} {
- set sql "select description from cr_folders where folder_id=:item_id"
} else {
set sql "select description as description from cr_revisions
where cr_revisions.item_id = :item_id"
@@ -1283,7 +1295,12 @@
db_0or1row description $sql
}
- db_1row path1 { }
+ set root_folder_package_id [db_string get_package_id {
+ select package_id from fs_root_folders
+ where folder_id = :root_folder
+ }]
+ set path1 [site_node::get_url_from_object_id \
+ -object_id $root_folder_package_id]
# Set email message body - "text only" for now
set text_version ""
Index: openacs-4/packages/file-storage/www/folder-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/folder-delete.tcl,v
diff -u -r1.14 -r1.15
--- openacs-4/packages/file-storage/www/folder-delete.tcl 3 Nov 2017 15:11:20 -0000 1.14
+++ openacs-4/packages/file-storage/www/folder-delete.tcl 15 Jun 2018 15:11:04 -0000 1.15
@@ -35,13 +35,15 @@
# Check if there are child items they don't have permission to delete
# (Irrelevant at this point because they can't delete folders with
# contents at all.)
-set blocked_p [ad_decode [children_have_permission_p $folder_id delete] 0 t f]
+set blocked_p [expr {![children_have_permission_p $folder_id delete]}]
set folder_name [db_string folder_name {}]
set child_count [db_string child_count {}]
# TODO add child_count to message key
+# Message lookup uses variable folder_name
+set page_title [_ file-storage.folder_delete_page_title]
set context [fs_context_bar_list -final "[_ file-storage.Delete]" $folder_id]
set delete_message "[_ file-storage.delete_folder_and_children]"
@@ -55,46 +57,18 @@
-form {
{delete_message:text(inform) {label ""} {value $delete_message}}
} -on_request {
-
} -on_submit {
- if {$blocked_p == "f"} {
- # they have confirmed that they want to delete the folder
-
- callback fs::folder_delete -package_id [ad_conn package_id] -folder_id $folder_id
- db_1row parent_id "select parent_id from cr_items where item_id = :folder_id"
-
- db_exec_plsql folder_delete ""
- }
-
- ad_returnredirect "index?folder_id=$parent_id"
- ad_script_abort
- } \
- -export {folder_id}
+ # they have confirmed that they want to delete the folder
+ set parent_id [db_string parent_id {}]
+ fs::delete_folder \
+ -parent_id $parent_id \
+ -folder_id $folder_id
+
+ ad_returnredirect "index?folder_id=$parent_id"
+ ad_script_abort
+ } -export {folder_id}
-if { $confirmed_p == "t" && $blocked_p == "f" } {
- # they have confirmed that they want to delete the folder
- fs::delete_folder \
- -folder_id $folder_id
-
- ad_returnredirect "index?folder_id=$parent_id"
- ad_script_abort
-
-} else {
- # they still need to confirm
-
- set folder_name [db_string folder_name {
- select label from cr_folders where folder_id = :folder_id
- }]
- set child_count [db_string child_count {
- select count(ci.item_id) from
- (select item_id from cr_items connect by prior item_id=parent_id start with item_id=:folder_id) ci
- }]
- set context [fs_context_bar_list -final "[_ file-storage.Delete]" $folder_id]
-}
-
-# Message lookup uses variable folder_name
-set page_title [_ file-storage.folder_delete_page_title]
# Local variables:
# mode: tcl
# tcl-indent-level: 4
Index: openacs-4/packages/file-storage/www/version-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/file-storage/www/version-delete.tcl,v
diff -u -r1.16 -r1.17
--- openacs-4/packages/file-storage/www/version-delete.tcl 7 Aug 2017 23:48:11 -0000 1.16
+++ openacs-4/packages/file-storage/www/version-delete.tcl 15 Jun 2018 15:11:04 -0000 1.17
@@ -24,14 +24,11 @@
permission::require_permission -object_id $version_id -privilege delete
-db_1row item_select {
- select item_id
- from cr_revisions
- where revision_id = :version_id
-}
-
-db_1row version_name {
- select i.name as title,r.title as version_name
+db_1row version_info {
+ select i.item_id,
+ i.parent_id,
+ i.name as title,
+ r.title as version_name
from cr_items i,cr_revisions r
where i.item_id = r.item_id
and revision_id = :version_id
@@ -46,23 +43,17 @@
{delete_message:text(inform) {label $delete_message}}
} -on_submit {
- set parent_id [db_exec_plsql delete_version {}]
-
- if {$parent_id > 0} {
-
- # Delete the item if there is no more revision. We do this here only because of PostgreSQL's RI bug
- db_exec_plsql delete_file {}
-
- fs::do_notifications -folder_id $parent_id -filename $version_name -item_id $item_id -action "delete_file"
-
- # Redirect to the folder, instead of the latest revision (which does not exist anymore)
- ad_returnredirect [export_vars -base index {{folder_id $parent_id}}]
-
- } else {
-
- # Ok, we don't have to do anything fancy, just redirect to the last revision of the file
- ad_returnredirect $file_url
- }
+ set parent_id [fs::delete_version \
+ -item_id $item_id \
+ -version_id $version_id]
+ # parent_id > 0 means this was last revision left, therefore file
+ # was deleted as well. Return to the parent instead than to the
+ # non-existing file.
+ set return_url [expr {$parent_id == 0 ?
+ $file_url :
+ [export_vars -base index {{folder_id $parent_id}}]}]
+
+ ad_returnredirect $return_url
ad_script_abort
}