Index: openacs-4/packages/ajax-filestorage-ui/lib/folder-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/lib/Attic/folder-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/lib/folder-postgresql.xql 13 Dec 2006 10:51:30 -0000 1.1 @@ -0,0 +1,32 @@ +<?xml version="1.0"?> + +<queryset> + <rdbms><type>postgresql</type><version>7.1</version></rdbms> + <fullquery name="get_fs_instances"> + <querytext> + select package_id, instance_name, + (select file_storage__get_root_folder(package_id)) as root_folder + from apm_packages where package_key='file-storage' + and exists (select 1 + from acs_object_party_privilege_map m + where m.object_id = fs_objects.object_id + and m.party_id = :viewing_user_id + and m.privilege = 'read') + ${exclude_sql} + order by instance_name + </querytext> + </fullquery> + + <fullquery name="countcontent"> + <querytext> + select count(*) from fs_objects + where parent_id = :root_folder and type='folder' + and exists (select 1 + from acs_object_party_privilege_map m + where m.object_id = fs_objects.object_id + and m.party_id = :viewing_user_id + and m.privilege = 'read') + </querytext> + </fullquery> + +</queryset> \ No newline at end of file Index: openacs-4/packages/ajax-filestorage-ui/lib/folder.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/lib/Attic/folder.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/lib/folder.adp 13 Dec 2006 10:51:30 -0000 1.1 @@ -0,0 +1,18 @@ + +<if @admin_button_url@ not nil><a href="@admin_button_url;noquote@" style="padding:5px; color:#ffffff; background-color:#3a26b1; border:1px solid #cccccc; width:100px;">Classic View</a></if> + +<div id="page"> + <div id="foldercontainer"> + <div class="subheader"><table border=0 cellpadding=0 cellspacing=0 width="100%"><tr><td>Folders</td><td align="right"><a href="javascript:tree.collapseAll();" style="font-size:10px;">Collapse All </a></td></tr></table></div> + <div id="folders"><br /><br /><br /><div class="filemsg">No folders found.</div></div> + </div> + <div id="filecontainer"> + <div class="subheader"><table border=0 cellpadding=0 cellspacing=0 width="100%"><tr><td width="55%" align="center">File/Folder</td><td width="20%" align="center">Size</td><td width="25%" align="center">Last Modified</td></tr></table></div> + <div id="files"><br /><br /><br /><div class="filemsg">Click on an item in the file tree to view its contents here.</div></div> + </div> +</div> + +<form><input type="hidden" id="lastfolder" name="lastfolder" value="" /></form> +<iframe id='talk' name='target_upload' src='' style='width:1px;height:1px;border:0;clear:both;'></iframe> + +@js_script;noquote@ Index: openacs-4/packages/ajax-filestorage-ui/lib/folder.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ajax-filestorage-ui/lib/Attic/folder.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ajax-filestorage-ui/lib/folder.tcl 13 Dec 2006 10:51:30 -0000 1.1 @@ -0,0 +1,66 @@ +# ajax-filestorage-ui/www/index.tcl + +ad_page_contract { + + Ajax Based File Manager using OpenACS File Storage and Yahoo's Tree View Control. + Optionally specify a the package_id of the file storage instance you wish to manage + or optionally specify a folder_id in the query string to tell which folder to open + + @author Hamilton Chua (ham@solutiongrove.com) + @creation-date 2006-02-04 +} { + {package_ids:integer,multiple,optional } + {folder_id:integer,optional } +} + +# declare some variables +set page_title "Ajax File Storage" + +# load yahoo events sources +# this is needed for functions inside ajaxfs.js +set js_sources [ah::yui::js_sources -source "connection"] + +# where is afs mounted +set afs_url [afs::get_url] + +# who is viewing, used to check permissions +set viewing_user_id [auth::require_login] + +# holds counter for number of folders +set count_folders 0 + +# variable name for the tree view control +set treevarname "tree" + +# refine query +set exclude_sql "" +# did we get a package_id from querystring +if { [exists_and_not_null package_ids] } { + set package_ids_list [join $package_ids ","] + set exclude_sql "and package_id in ($package_ids_list)" +} + +# create the nodes for our tree +set nodes [list] +db_foreach "get_fs_instances" "" { + + # verify if the folder has contents + if { [db_string "countcontent" ""] > 0 } { + set dyn_load_script "loadDataForNode" + } else { + set dyn_load_script "" + } + + # create the node + lappend nodes [list "$root_folder" "$instance_name" "$treevarname" "javascript:showFolderContents('${root_folder}',$treevarname)" "" "${dyn_load_script}"] + + incr count_folders + +} + +set js_script [ah::yui::create_tree -element "folders" \ + -nodes $nodes \ + -varname "tree" \ + -css "/resources/ajax-filestorage-ui/tree.css" ] + +set js_script [ah::enclose_in_script -script $js_script] \ No newline at end of file