Index: openacs-4/packages/photo-album/www/photo-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/photo-album/www/photo-add-2.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/photo-album/www/photo-add-2.tcl 12 Feb 2019 17:12:19 -0000 1.12 +++ openacs-4/packages/photo-album/www/photo-add-2.tcl 12 Feb 2019 17:28:59 -0000 1.13 @@ -17,36 +17,36 @@ {story ""} } -validate { valid_album -requires {album_id:integer} { - if [string equal [pa_is_album_p $album_id] "f"] { - ad_complain "The specified album is not valid." - } + if [string equal [pa_is_album_p $album_id] "f"] { + ad_complain "The specified album is not valid." + } } valid_mime_type { - + if { ![parameter::get -parameter ConverttoJpgorPng -package_id [ad_conn package_id] -default 1] } { - - if { [catch {set photo_info [pa_file_info ${upload_file.tmpfile}]} errMsg] } { - ns_log Warning "Error parsing file data Error: $errMsg" - ad_complain "error" - } - - lassign $photo_info base_bytes base_width base_height base_type base_mime base_colors base_quantum base_sha256 - - if {$base_mime eq ""} { - set base_mime invalid - } - - if ![regexp $base_mime [parameter::get -parameter AcceptableUploadMIMETypes -package_id [ad_conn package_id]]] { - ad_complain "[_ photo-album._The_5]" - ad_complain "[_ photo-album._The_6]" - } - } + + if { [catch {set photo_info [pa_file_info ${upload_file.tmpfile}]} errMsg] } { + ns_log Warning "Error parsing file data Error: $errMsg" + ad_complain "error" + } + + lassign $photo_info base_bytes base_width base_height base_type base_mime base_colors base_quantum base_sha256 + + if {$base_mime eq ""} { + set base_mime invalid + } + + if ![regexp $base_mime [parameter::get -parameter AcceptableUploadMIMETypes -package_id [ad_conn package_id]]] { + ad_complain "[_ photo-album._The_5]" + ad_complain "[_ photo-album._The_6]" + } + } } valid_photo_id -requires {photo_id:integer} { - # supplied photo_id must not already exist + # supplied photo_id must not already exist if {[db_string check_photo_id {}]} { - ad_complain "The photo already exists. Check if it is already in the album." - } + ad_complain "The photo already exists. Check if it is already in the album." + } } } @@ -58,16 +58,22 @@ permission::require_permission -object_id $album_id -privilege "pa_create_photo" set new_photo_ids [pa_load_images \ - -remove 1 \ - -client_name $upload_file \ - -description $description \ - -story $story \ - -caption $caption \ - ${upload_file.tmpfile} $album_id $user_id] + -remove 1 \ + -client_name $upload_file \ + -description $description \ + -story $story \ + -caption $caption \ + ${upload_file.tmpfile} $album_id $user_id] pa_flush_photo_in_album_cache $album_id # page used as part of redirect so user returns to the album page containing the newly uploaded photo set page [pa_page_of_photo_in_album [lindex $new_photo_ids 0] $album_id] ad_returnredirect "album?album_id=$album_id&page=$page" + +# Local variables: +# mode: tcl +# tcl-indent-level: 4 +# indent-tabs-mode: nil +# End: