photo_album::photo::get (public)

 photo_album::photo::get -photo_id photo_id -array array \
    [ -user_id user_id ]

Defined in packages/photo-album/tcl/photo-album-procs.tcl

return an array with the photo data. elements are: photo_delete_p admin_p write_p album_write_p album_id caption description photo_id story title image_types (list of available related images "base" "viewer" "thumb") For each image type there is (eg viewer here): viewer_content viewer_content_length viewer_height viewer_image_id viewer_latest_revision viewer_live_revision viewer_name viewer_relation_tag viewer_width

Switches:
-photo_id (required)
-array (required)
-user_id (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 photo_album::search::photo::datasource photo_album::search::photo::datasource (private) photo_album::photo::get photo_album::photo::get photo_album::search::photo::datasource->photo_album::photo::get ad_conn ad_conn (public) photo_album::photo::get->ad_conn db_1row db_1row (public) photo_album::photo::get->db_1row db_foreach db_foreach (public) photo_album::photo::get->db_foreach

Testcases:
No testcase defined.
Source code:
    upvar $array row

    if {$user_id eq ""} {
        if {[ad_conn isconnected]} { 
            set user_id [ad_conn user_id]
        } else {
            set user_id 0
        }
    }

    db_1row basic {} -column_array row

    db_foreach images {} -column_set img {
        set rel [ns_set iget $img relation_tag]
        lappend row(image_types) $rel
        for { set i 0 } { $i < [ns_set size $img] } { incr i } {
            set row(${rel}_[ns_set key $img $i]) [ns_set value $img $i]
        }
    }
Generic XQL file:
<fullquery name="photo_album::photo::get.images">
    <querytext>
    SELECT ccr.relation_tag, image_items.name, image_items.live_revision, image_items.latest_revision, i.*, image_revs.content, image_revs.content_length
      FROM cr_items photo,
           cr_items image_items,
           cr_revisions image_revs,
           cr_child_rels ccr,
           images i
     WHERE ccr.parent_id = photo.item_id
       and image_items.item_id = ccr.child_id
       and image_items.live_revision = i.image_id
       and image_revs.revision_id = image_items.live_revision
       and photo.item_id = :photo_id
     </querytext>
</fullquery>
packages/photo-album/tcl/photo-album-procs.xql

PostgreSQL XQL file:
<fullquery name="photo_album::photo::get.basic">
    <querytext>
      SELECT
        ci.item_id as photo_id,
        u.user_id,
        u.first_names || ' ' || u.last_name as username,
        pp.caption,
        pp.story,
        cr.title,
        cr.description,
        ci.parent_id as album_id,
        to_char(o.creation_date,'YYYY-MM-DD HH24:MI:SS') as created_ansi,
        case when acs_permission__permission_p(ci.item_id, :user_id, 'admin') ='t' then 1 else 0 end as admin_p,
        case when acs_permission__permission_p(ci.item_id, :user_id, 'write') = 't' then 1 else 0 end as write_p,
        case when acs_permission__permission_p(ci.parent_id, :user_id, 'write') = 't' then 1 else 0 end as album_write_p,
        case when acs_permission__permission_p(ci.item_id, :user_id, 'delete') = 't' then 1 else 0 end as photo_delete_p
      FROM cr_items ci,
           cr_revisions cr,
           pa_photos pp,
           acs_objects o,
           acs_users_all u
      WHERE cr.revision_id = pp.pa_photo_id
        and ci.live_revision = cr.revision_id
        and o.object_id = ci.item_id
        and u.user_id = o.creation_user 
        and ci.item_id = :photo_id
    </querytext>
</fullquery>
packages/photo-album/tcl/photo-album-procs-postgresql.xql

Oracle XQL file:
<fullquery name="photo_album::photo::get.basic">
    <querytext>
      SELECT
        ci.item_id as photo_id,
        u.user_id,
        u.first_names || ' ' || u.last_name as username,
        pp.caption,
        pp.story,
        cr.title,
        cr.description,
        ci.parent_id as album_id,
        to_char(o.creation_date,'YYYY-MM-DD HH24:MI:SS') as created_ansi,
        case when acs_permission.permission_p(ci.item_id, :user_id, 'admin') ='t' then 1 else 0 end as admin_p,
        case when acs_permission.permission_p(ci.item_id, :user_id, 'write') = 't' then 1 else 0 end as write_p,
        case when acs_permission.permission_p(ci.parent_id, :user_id, 'write') = 't' then 1 else 0 end as album_write_p,
        case when acs_permission.permission_p(ci.item_id, :user_id, 'delete') = 't' then 1 else 0 end as photo_delete_p
      FROM cr_items ci,
           cr_revisions cr,
           pa_photos pp,
           acs_objects o,
           acs_users_all u
      WHERE cr.revision_id = pp.pa_photo_id
        and ci.live_revision = cr.revision_id
        and o.object_id = ci.item_id
        and u.user_id = o.creation_user 
        and ci.item_id = :photo_id
    </querytext>
</fullquery>
packages/photo-album/tcl/photo-album-procs-oracle.xql

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