Index: openacs-4/packages/acs-admin/www/apm/version-edit-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/apm/version-edit-2.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-admin/www/apm/version-edit-2.tcl 25 Sep 2003 13:17:39 -0000 1.8 +++ openacs-4/packages/acs-admin/www/apm/version-edit-2.tcl 20 Apr 2004 21:12:28 -0000 1.9 @@ -18,38 +18,35 @@ {auto_mount ""} {release_date ""} { upgrade_p 0 } -} -validate { - version_uri_unique -requires {version_uri} { - if { $upgrade_p && [db_string apm_version_uri_unique_ck { - select decode(count(*), 0, 0, 1) from apm_package_versions - where version_uri = :version_uri - } -default 0] } { - ad_complain "A version with the URL $version_uri already exists." - } - } +} - version_name_ck -requires {version_name} { - if {![regexp {^[0-9]+((\.[0-9]+)+((d|a|b|)[0-9]*)?)$} $version_name match]} { - ad_complain - } - } - version_changed_ck -requires {version_id version_name version_uri} { - # The user has to update the URL if he changes the name. - db_1row old_version_name " - select version_name old_version_name, version_uri old_version_uri - from apm_package_versions - where version_id = $version_id - " - set version_changed_p [string compare $version_name $old_version_name] - if { $version_changed_p && ![string compare $version_uri $old_version_uri] } { - ad_complain - } - } -} -errors { - version_changed_ck {You have changed the version number but not the version URL. When creating - a package for a new version, you must select a new URL for the version.} +if {![regexp {^[0-9]+((\.[0-9]+)+((d|a|b|)[0-9]*)?)$} $version_name match]} { + ad_return_complaint 1 "The version name has invalid characters" + ad_script_abort +} + +# Figure out if we're changing version +db_1row old_version_info {} +set version_changed_p [expr ![string equal $version_name $old_version_name]] + +if { [string equal $old_version_name $version_name] } { + # The version name didn't change, so don't attempt to upgrade + set upgrade_p 0 } +# The user has to update the URL if he changes the name. +if { $version_changed_p && [string equal $version_uri $old_version_uri] } { + ad_return_complaint 1 {You have changed the version number but not the version URL. When creating + a package for a new version, you must select a new URL for the version.} +} + +if { $upgrade_p && [db_string apm_version_uri_unique_ck { + select decode(count(*), 0, 0, 1) from apm_package_versions + where version_uri = :version_uri +} -default 0] } { + ad_return_complaint 1 "A version with the URL $version_uri already exists." +} + db_transaction { set version_id [apm_version_update $version_id $version_name $version_uri \ $summary $description $description_format $vendor $vendor_uri $auto_mount $release_date]