fs::get_folder_contents (public, deprecated)

 fs::get_folder_contents [ -folder_id folder_id ] [ -user_id user_id ] \
    [ -n_past_days n_past_days ]

Defined in packages/file-storage/tcl/file-storage-procs.tcl

Deprecated. Invoking this procedure generates a warning.

WARNING: This proc is not scalable because it does too many permission checks. DRB: Not so true now that permissions are fast. However, it is now only used to clone files in dotLRN and for the somewhat brain-damaged syllabus package. At minimum the permission checks returned by the code can be removed. Most of the other fields as well. Oh well ... REMOVE WHEN SYLLABUS IS REWRITTEN TO FIND ITS FILE INTELLIGENTLY Retrieve the contents of the specified folder in the form of a list of ns_sets, one for each row returned. The keys for each row are as follows: object_id, name, live_revision, type, last_modified, new_p, content_size, file_upload_name write_p, delete_p, admin_p, DEPRECATED: this proc has been evidently the subject of controversy over the years. To this day (2023-03-17) no package seems to be using it. One can either query the database directly or use other existing apis to retrieve the folder children and then fetch the needed metadata via other means.

Switches:
-folder_id (optional)
The folder for which to retrieve contents
-user_id (optional)
The viewer of the contents (to make sure they have permission)
-n_past_days (optional, defaults to "99999")
Mark files that are newer than the past N days as new
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 acs_magic_object acs_magic_object (public) ad_conn ad_conn (public) ad_log_deprecated ad_log_deprecated (public) db_list_of_ns_sets db_list_of_ns_sets (public) fs::get_root_folder fs::get_root_folder (public) fs::get_folder_contents fs::get_folder_contents fs::get_folder_contents->acs_magic_object fs::get_folder_contents->ad_conn fs::get_folder_contents->ad_log_deprecated fs::get_folder_contents->db_list_of_ns_sets fs::get_folder_contents->fs::get_root_folder

Testcases:
No testcase defined.
Source code:
ad_log_deprecated proc fs::get_folder_contents
    if {$folder_id eq ""} {
        set folder_id [get_root_folder -package_id [ad_conn package_id]]
    }

    if {$user_id eq ""} {
        set user_id [acs_magic_object the_public]
    }

    set list_of_ns_sets [db_list_of_ns_sets select_folder_contents [subst {
           select fs_objects.object_id,
           fs_objects.name,
           fs_objects.title,
           fs_objects.live_revision,
           fs_objects.type,
           to_char(fs_objects.last_modified, 'YYYY-MM-DD HH24:MI:SS') as last_modified_ansi,
           fs_objects.content_size,
           fs_objects.url,
           fs_objects.key,
           fs_objects.sort_key,
           fs_objects.file_upload_name,
           fs_objects.title,
           fs_objects.last_modified >= (current_timestamp - cast('$n_past_days days' as interval)) as new_p,
           acs_permission.permission_p(fs_objects.object_id, :user_id, 'admin') as admin_p,
           acs_permission.permission_p(fs_objects.object_id, :user_id, 'delete') as delete_p,
           acs_permission.permission_p(fs_objects.object_id, :user_id, 'write') as write_p
           from fs_objects
           where fs_objects.parent_id = :folder_id
           and acs_permission.permission_p(fs_objects.object_id, :user_id, 'read') = 't'
           order by fs_objects.sort_key, fs_objects.name
    }]]

    foreach set $list_of_ns_sets {
        # in plain Tcl:
        # set last_modified_ansi [lc_time_system_to_conn $last_modified_ansi]
        ns_set put $set last_modified_ansi [lc_time_system_to_conn [ns_set get $set last_modified_ansi]]

        # in plain Tcl:
        # set last_modified [lc_time_fmt $last_modified_ansi "%x %X"]
        ns_set put $set last_modified [lc_time_fmt [ns_set get $set last_modified_ansi] "%x %X"]

        # set content_size_pretty [lc_numeric $content_size]
        ns_set put $set content_size_pretty [lc_numeric [ns_set get $set content_size]]
    }

    return $list_of_ns_sets
Generic XQL file:
packages/file-storage/tcl/file-storage-procs.xql

PostgreSQL XQL file:
packages/file-storage/tcl/file-storage-procs-postgresql.xql

Oracle XQL file:
packages/file-storage/tcl/file-storage-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: