Index: openacs-4/packages/photo-album/www/photo.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/www/photo.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/photo-album/www/photo.tcl 12 Jun 2003 06:55:45 -0000 1.2 +++ openacs-4/packages/photo-album/www/photo.tcl 18 Nov 2003 18:27:53 -0000 1.3 @@ -2,20 +2,16 @@ ad_page_contract { - Photo display page. + Photo display page and allows user to move a photo from one album to another album in the same folder @author Tom Baginski (bags@arsdigita.com) @creation-date 12/10/2000 @cvs-id $Id$ } { - photo_id:integer,notnull + {latest_revision 0} + {photo_id:integer 0} {collection_id:integer,optional {}} -} -validate { - valid_photo -requires {photo_id:integer} { - if [string equal [pa_is_photo_p $photo_id] "f"] { - ad_complain "The specified photo is not valid." - } - } + {show_html_p 0"} } -properties { context:onevalue title:onevalue @@ -32,30 +28,135 @@ page_num:onevalue show_base_link:onevalue clipboards:multirow +} -validate { + valid_photo -requires {photo_id:integer} { + if { [string equal $photo_id 0] && ![string equal $latest_revision 0] } { + set photo_id $latest_revision + } + if [string equal [pa_is_photo_p $photo_id] "f"] { + ad_complain "The specified photo is not valid." + } + } } ad_require_permission $photo_id "read" - set user_id [ad_conn user_id] set context [pa_context_bar_list $photo_id] +set root_folder_id [pa_get_root_folder] +# to move a photo need write on photo, and old parent album +# and pa_create_photo on new parent album (which is check in the is_valid block) + + +set old_album_id [db_string get_parent_album {}] + +ad_require_permission $photo_id write +ad_require_permission $old_album_id write + + +# These lines are to uncache the image in Netscape, Mozilla. +# IE6 & Safari (mac) have a bug with the images cache +ns_set put [ns_conn outputheaders] "Expires" "-" +ns_set put [ns_conn outputheaders] "Last-Modified" "-" +ns_set put [ns_conn outputheaders] "Pragma" "no-cache" +ns_set put [ns_conn outputheaders] "Cache-Control" "no-cache" + + # this is handled with a parameter rather than a permission on the # individual photo so admin can turn access on and off for entire # subsite at once. A permission would allow greater flexability, but # to shut down access to base photos an admin would need to search through # database and revoke all such permissions. + set show_base_link [ad_parameter AllowBasePhotoAccessP] # query all the photo and permission info with a single trip to database -if {![db_0or1row get_photo_info {}]} { - ad_return_complaint 1 "
$errmsg" + } + + ad_script_abort + } + pa_flush_photo_in_album_cache $old_album_id + pa_flush_photo_in_album_cache $new_album_id + + + #page used to redirect user to the page of new album containing moved photos + set page [pa_page_of_photo_in_album $photo_id $new_album_id] + + ad_returnredirect "album?album_id=$new_album_id&page=$page" + ad_script_abort + + } +} + # to delete a photo need delete on photo and write on parent album set delete_p [expr $photo_delete_p && $album_write_p] @@ -68,11 +169,5 @@ #proc pa_clipboards_get -photo_id $photo_id -multirow clipped -db_multirow clipped get_clips { -SELECT c.collection_id, c.title - FROM pa_collections c, pa_collection_photo_map m - WHERE m.photo_id = :photo_id - and m.collection_id = c.collection_id - and owner_id = :user_id - ORDER BY c.title -} +db_multirow clipped get_clips { *SQL* } +