attachments::get_all_attachments (public)

 attachments::get_all_attachments -object_id object_id \
    [ -base_url base_url ] [ -return_url return_url ] \
    [ -approved_only ] [ -add_detach_url ]

Defined in packages/attachments/tcl/attachments-procs.tcl

Switches:
-object_id (required)
object to check for attachments.
-base_url (optional)
URL path that will be prepended to generated URLs.
-return_url (optional)
only meaningful if we are also generating detach_url, is the location we will return to after detaching.
-approved_only (optional, boolean)
flag deciding if we want to return only attachments that have been approved. All attachments will be returned when this is not specified.
-add_detach_url (optional, boolean)
flag deciding whether we want to generate also detach_url in the result.
Returns:
a list representing attachments and their UI URLs.
list of lists in the format {item_id name url} or {item_id name url detach_url} when add_detach_url is specified.

Partial Call Graph (max 5 caller/called nodes):
%3 test_attachments_basic_api attachments_basic_api (test attachments) attachments::get_all_attachments attachments::get_all_attachments test_attachments_basic_api->attachments::get_all_attachments attachments::detach_url attachments::detach_url (public) attachments::get_all_attachments->attachments::detach_url attachments::get_title attachments::get_title (public) attachments::get_all_attachments->attachments::get_title attachments::goto_attachment_url attachments::goto_attachment_url (public) attachments::get_all_attachments->attachments::goto_attachment_url db_list_of_lists db_list_of_lists (public) attachments::get_all_attachments->db_list_of_lists attachments::get_attachments attachments::get_attachments (public) attachments::get_attachments->attachments::get_all_attachments

Testcases:
attachments_basic_api
Source code:
        set lst_with_urls [list]

        foreach item_id [db_list_of_lists select_attachments {
            select item_id from attachments
             where object_id = :object_id
               and (not :approved_only_p or approved_p)}] {
            #
            # Set the attachment 'label'
            #
            set label [attachments::get_title -attachment_id $item_id]
            #
            # Set the attachment URL
            #
            set url [goto_attachment_url  -object_id     $object_id  -attachment_id $item_id  -base_url      $base_url]
            set element [list $item_id $label $url]
            if {$add_detach_url_p} {
                lappend element [detach_url  -object_id     $object_id  -attachment_id $item_id  -base_url      $base_url  -return_url    $return_url]
            }
            lappend lst_with_urls $element
        }

        return $lst_with_urls
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/attachments/tcl/attachments-procs.xql

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