Index: openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl,v diff -u -r1.17 -r1.18 --- openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 7 Feb 2005 10:29:14 -0000 1.17 +++ openacs-4/packages/acs-api-browser/tcl/acs-api-documentation-procs.tcl 27 Feb 2005 22:45:38 -0000 1.18 @@ -316,6 +316,8 @@ ad_proc -public api_type_documentation { type } { + @return html fragment of the api docs. +} { array set doc_elements [nsv_get doc_type_doc $type] append out "

$type

\n" Index: openacs-4/packages/acs-authentication/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/apm-callback-procs.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/acs-authentication/tcl/apm-callback-procs.tcl 13 Jan 2005 13:54:42 -0000 1.14 +++ openacs-4/packages/acs-authentication/tcl/apm-callback-procs.tcl 27 Feb 2005 22:45:39 -0000 1.15 @@ -66,17 +66,19 @@ } } -ad_proc -public auth::after_upgrade { +ad_proc -private auth::after_upgrade { {-from_version_name:required} {-to_version_name:required} } { + After upgrade callback. +} { apm_upgrade_logic \ -from_version_name $from_version_name \ -to_version_name $to_version_name \ -spec { 5.0a1 5.0a2 { db_transaction { - + # Delete and recreate contract auth::process_doc::delete_contract auth::process_doc::create_contract Index: openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl,v diff -u -r1.70 -r1.71 --- openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl 13 Jan 2005 13:54:42 -0000 1.70 +++ openacs-4/packages/acs-authentication/tcl/authentication-procs.tcl 27 Feb 2005 22:45:39 -0000 1.71 @@ -66,25 +66,24 @@ if { ![string equal [ad_conn auth_level] "expired"] } { return [ad_conn user_id] } - # The -return switch causes the URL to return to the current page ad_returnredirect [ad_get_login_url -return] ad_script_abort } ad_proc -public auth::self_registration {} { - #Check AllowSelfRegister parameter - + Check AllowSelfRegister parameter and set user message if + self registration not allowed. +} { if { [string is false [parameter::get_from_package_key \ -package_key acs-authentication \ -parameter AllowSelfRegister]] } { util_user_message -message "Self registration is not allowed" ad_maybe_redirect_for_registration } -} +} - ad_proc -public auth::get_user_id { {-level ok} {-account_status ok} @@ -94,17 +93,16 @@ high security level, return 0. @return user_id of user, if the user is logged in, 0 otherwise. - @see ad_script_abort } { set untrusted_user_id [ad_conn untrusted_user_id] - + # Do we have any user_id at all? if { $untrusted_user_id == 0 } { return 0 } - + # Check account status if { [string equal $account_status "ok"] && ![string equal [ad_conn account_status] "ok"] } { return 0 Index: openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl,v diff -u -r1.32 -r1.33 --- openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 24 Feb 2004 13:45:29 -0000 1.32 +++ openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 27 Feb 2005 22:45:39 -0000 1.33 @@ -1019,6 +1019,8 @@ namespace eval aa_test {} ad_proc -public aa_test::xml_report_dir {} { + returns the package parameter XMLReportDir. +} { return [parameter::get -parameter XMLReportDir] } Index: openacs-4/packages/acs-content-repository/tcl/filter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/tcl/filter-procs.tcl,v diff -u -r1.26 -r1.27 --- openacs-4/packages/acs-content-repository/tcl/filter-procs.tcl 24 Feb 2005 13:32:59 -0000 1.26 +++ openacs-4/packages/acs-content-repository/tcl/filter-procs.tcl 27 Feb 2005 22:45:39 -0000 1.27 @@ -12,20 +12,25 @@ } -# Find the directory in the file system where templates are stored. -# There are a variety of ways in which this can be set. The proc -# looks for that directory in the following places in this order: -# (1) the TemplateRoot parameter of the package for which the request is -# made, i.e., [ad_conn package_id] -# (2) the TemplateRoot parameter of the acs-content-repository -# If it is not found in any of these places, it defaults to -# [acs_root_dir]/templates -# -# If the value resulting from the search does not start with a '/' -# it is taken to be relative to [acs_root_dir] + ad_proc -public content::get_template_root {} { + Find the directory in the file system where templates are stored. + There are a variety of ways in which this can be set. The proc + looks for that directory in the following places in this order: + (1) the TemplateRoot parameter of the package for which the request is + made, i.e., [ad_conn package_id] + (2) the TemplateRoot parameter of the acs-content-repository + If it is not found in any of these places, it defaults to + + [acs_root_dir]/templates + + If the value resulting from the search does not start with a '/' + it is taken to be relative to [acs_root_dir] + + @return the template root (full path from /) +} { # Look for package-defined root set package_id [ad_conn package_id] set template_root \ @@ -48,24 +53,32 @@ } -# return true if the request has content associated with it ad_proc -public content::has_content {} { + return true if the request has content associated with it + @return 1 if ::content::item_id is defined +} { variable item_id return [info exists item_id] } ad_proc -public content::get_item_id {} { + @return current value of ::content::item_id +} { variable item_id return $item_id } ad_proc -public content::get_content { { content_type {} } } { + sets the content in the array "content" in the callers scope + assumes item_id or revision_id is set in the ::content namespace. + @param content_type +} { variable item_id variable revision_id @@ -113,21 +126,22 @@ ns_log notice "content::get_content: No data found for item $item_id, revision $revision_id" return 0 } - } ad_proc -public content::get_template_url {} { - + @return current value of ::content::template_url +} { variable template_url return $template_url } -# Set a data source in the calling frame with folder URL and label -# Useful for generating a context bar ad_proc -public content::get_folder_labels { { varname "folders" } } { + Set a data source in the calling frame with folder URL and label + Useful for generating a context bar +} { variable item_id @@ -142,7 +156,8 @@ } ad_proc -public content::get_content_value { revision_id } { - + @return content element corresponding to the provided revision_id +} { db_transaction { db_exec_plsql gcv_get_revision_id { begin @@ -170,7 +185,10 @@ {rev_id ""} {content_type ""} } { - + Initialize the namespace variables for the ::content procs and + figures out which template to use and set up the template + for the required content type etc. +} { upvar $urlvar url $rootvar root_path variable root_folder_id variable item_id @@ -188,17 +206,17 @@ -resolve_index "f"] set item_info(content_type) [::content::item::get_content_type \ -item_id $item_info(item_id)] - + # No item found, so do not handle this request - if { [string equal "" $item_info(item_id)] } { + if { [string equal "" $item_info(item_id)] } { set item_info(item_id) [::content::item::get_id -item_path $url \ -root_folder_id $content_root \ -resolve_index "f"] set item_info(content_type) [::content::item::get_content_type \ -item_id $item_info(item_id)] - if { [string equal "" $item_info(item_id)] } { + if { [string equal "" $item_info(item_id)] } { ns_log notice "content::init: no content found for url $url" - return 0 + return 0 } } @@ -289,10 +307,12 @@ return 1 } -# render the template and write it to the file system -ad_proc -public content::deploy { url_stub } { +ad_proc -public content::deploy { url_stub } { + render the template and write it to the file system + with template::util::write_file +} { set output_path [ns_info pageroot]$url_stub init url_stub root_path Index: openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl,v diff -u -r1.44 -r1.45 --- openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 26 Feb 2005 16:00:09 -0000 1.44 +++ openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 27 Feb 2005 22:45:39 -0000 1.45 @@ -8,7 +8,7 @@ http://www.fsf.org/copyleft/gpl.html @creation-date 10 September 2000 - @author Jeff Davis (davis@arsdigita.com) + @author Jeff Davis (davis@xarg.net) @author Bruno Mattarollo (bruno.mattarollo@ams.greenpeace.org) @author Peter Marklund (peter@collaboraid.biz) @author Lars Pind (lars@collaboraid.biz) @@ -703,7 +703,7 @@ Useful if you're not using this message in the page itself, but e.g. for localization data or for the list of messages on the page. - @author Jeff Davis (davis@arsdigita.com) + @author Jeff Davis (davis@xarg.net) @author Henry Minsky (hqm@arsdigita.com) @author Peter Marklund (peter@collaboraid.biz) @@ -878,7 +878,7 @@ package_key.message_key - @author Jeff Davis (davis@arsdigita.com) + @author Jeff Davis (davis@xarg.net) @param locale Abbreviation for language of the message or the locale. @param key Unique identifier for this message. Will be the same identifier @@ -921,7 +921,7 @@ @return A localized message - @author Jeff Davis (davis@arsdigita.com) + @author Jeff Davis (davis@xarg.net) @author Peter Marklund (peter@collaboraid.biz) @author Christian Hvid (chvid@collaboraid.biz) Index: openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl,v diff -u -r1.35 -r1.36 --- openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl 26 Feb 2005 16:00:09 -0000 1.35 +++ openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl 27 Feb 2005 22:45:39 -0000 1.36 @@ -9,7 +9,7 @@ http://www.fsf.org/copyleft/gpl.html @creation-date 10 September 2000 - @author Jeff Davis (davis@arsdigita.com) + @author Jeff Davis (davis@xarg.net) @author Bruno Mattarollo (bruno.mattarollo@ams.greenpeace.org) @author Peter Marklund (peter@collaboraid.biz) @author Lars Pind (lars@collaboraid.biz) @@ -32,7 +32,7 @@ insert into lang_testsort values ('lzim'); - @author Jeff Davis (davis@arsdigita.com) + @author Jeff Davis (davis@xarg.net) @param field Name of Oracle column @param locale Locale for sorting. Index: openacs-4/packages/acs-lang/tcl/locale-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/locale-procs.tcl,v diff -u -r1.30 -r1.31 --- openacs-4/packages/acs-lang/tcl/locale-procs.tcl 26 Feb 2005 16:00:09 -0000 1.30 +++ openacs-4/packages/acs-lang/tcl/locale-procs.tcl 27 Feb 2005 22:45:39 -0000 1.31 @@ -53,12 +53,14 @@ ad_proc -private lang::system::package_level_locale_not_cached { package_id } { - return [db_string get_system_locale {} -default {}] + return [db_string get_package_locale {} -default {}] } ad_proc -public lang::system::package_level_locale { package_id } { + @return empty string if not use_package_level_locales_p, or the package locale from apm_packages table. +} { if { ![use_package_level_locales_p] } { return {} } Index: openacs-4/packages/acs-lang/tcl/locale-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/locale-procs.xql,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-lang/tcl/locale-procs.xql 14 Dec 2003 13:52:39 -0000 1.9 +++ openacs-4/packages/acs-lang/tcl/locale-procs.xql 27 Feb 2005 22:45:39 -0000 1.10 @@ -1,7 +1,7 @@ - + select default_locale from apm_packages Index: openacs-4/packages/acs-subsite/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/apm-callback-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-subsite/tcl/apm-callback-procs.tcl 22 Jan 2005 18:05:03 -0000 1.3 +++ openacs-4/packages/acs-subsite/tcl/apm-callback-procs.tcl 27 Feb 2005 22:45:39 -0000 1.4 @@ -16,10 +16,12 @@ } -ad_proc -public subsite::after_upgrade { +ad_proc -private subsite::after_upgrade { {-from_version_name:required} {-to_version_name:required} } { + After upgrade callback for acs-subsite. +} { apm_upgrade_logic \ -from_version_name $from_version_name \ -to_version_name $to_version_name \ Index: openacs-4/packages/acs-subsite/tcl/group-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/group-procs.tcl,v diff -u -r1.24 -r1.25 --- openacs-4/packages/acs-subsite/tcl/group-procs.tcl 28 Jun 2004 19:35:02 -0000 1.24 +++ openacs-4/packages/acs-subsite/tcl/group-procs.tcl 27 Feb 2005 22:45:39 -0000 1.25 @@ -416,7 +416,6 @@ @param group_id The ID of the group for which to get options. @param object_type The object type which must occupy side two of the relationship. Typically 'person' or 'group'. - @return a list of lists with label (role two pretty name) and ID (rel_type) } { # LARS: @@ -433,6 +432,8 @@ {-group_id:required} {-user_id:required} } { + @return 1 if user_id is in teh admin_rel for group_id +} { set admin_rel_id [relation::get_id \ -object_id_one $group_id \ -object_id_two $user_id \ @@ -450,20 +451,20 @@ {-rel_type ""} {-member_state ""} } { - Adds a user to a group, checking that the rel_type is permissible given the user's privileges, + Adds a user to a group, checking that the rel_type is permissible given the user's privileges, Can default both the rel_type and the member_state to their relevant values. -} { +} { set admin_p [permission::permission_p -object_id $group_id -privilege "admin"] - + # Only admins can add non-membership_rel members if { [empty_string_p $rel_type] || \ (!$no_perm_check_p && ![empty_string_p $rel_type] && ![string equal $rel_type "membership_rel"] && \ ![permission::permission_p -object_id $group_id -privilege "admin"]) } { set rel_type "membership_rel" } - + group::get -group_id $group_id -array group - + if { !$no_perm_check_p } { set create_p [group::permission_p -privilege create $group_id] if { [string equal $group(join_policy) "closed"] && !$create_p } { Index: openacs-4/packages/acs-subsite/tcl/subsite-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/subsite-procs.tcl,v diff -u -r1.30 -r1.31 --- openacs-4/packages/acs-subsite/tcl/subsite-procs.tcl 23 Feb 2005 13:14:01 -0000 1.30 +++ openacs-4/packages/acs-subsite/tcl/subsite-procs.tcl 27 Feb 2005 22:45:39 -0000 1.31 @@ -309,16 +309,15 @@ } } -ad_proc subsite::util::sub_type_exists_p { +ad_proc -public subsite::util::sub_type_exists_p { object_type } { - returns 1 if object_type has sub types, or 0 otherwise + @param object_type + @return 1 if object_type has sub types, or 0 otherwise + @author Oumi Mehrotra (oumi@arsdigita.com) @creation-date 2000-02-07 - - @param object_type - } { return [db_string sub_type_exists_p { @@ -334,11 +333,11 @@ } -ad_proc subsite::util::object_type_path_list { +ad_proc -public subsite::util::object_type_path_list { object_type {ancestor_type acs_object} } { - + @return the object type heirarchy for the given object type from ancestor_type to object_type } { set path_list [list] @@ -360,7 +359,7 @@ } -ad_proc subsite::util::object_type_pretty_name { +ad_proc -public subsite::util::object_type_pretty_name { object_type } { returns pretty name of object. We need this so often that I thought @@ -377,7 +376,7 @@ }] } -ad_proc subsite::util::return_url_stack { +ad_proc -public subsite::util::return_url_stack { return_url_list } { Given a list of return_urls, we recursively encode them into one @@ -408,17 +407,17 @@ } -ad_proc subsite::define_pageflow { +ad_proc -public subsite::define_pageflow { {-sections_multirow "sections"} {-subsections_multirow "subsections"} {-section ""} } { Defines the page flow of the subsite + + TODO: add an image + TODO: add link_p/selected_p for subsections } { set pageflow [get_pageflow_struct] - - # TODO: add an image - # TODO: add link_p/selected_p for subsections set base_url [subsite::get_element -element url] @@ -467,7 +466,7 @@ } -ad_proc subsite::add_section_row { +ad_proc -public subsite::add_section_row { {-array:required} {-base_url:required} {-multirow:required} @@ -527,6 +526,9 @@ {-array "section_info"} {-sections_multirow "sections"} } { + Takes the sections_multirow and sets the passed array name + with the elements label and url of the selected section. +} { upvar $array row # Find the label of the selected section @@ -544,7 +546,7 @@ } } -ad_proc subsite::get_pageflow_struct {} { +ad_proc -public subsite::get_pageflow_struct {} { # This is where the page flow structure is defined set subsections [list] lappend subsections home { @@ -593,8 +595,10 @@ set user_id [ad_conn user_id] - set admin_p [permission::permission_p -object_id \ - [site_node_closest_ancestor_package "acs-subsite"] -privilege admin -party_id [ad_conn untrusted_user_id]] + set admin_p [permission::permission_p \ + -object_id [site_node_closest_ancestor_package "acs-subsite"] \ + -privilege admin \ + -party_id [ad_conn untrusted_user_id]] set show_member_list_to [parameter::get -parameter "ShowMembersListTo" -package_id $subsite_id -default 2] if { $admin_p || ($user_id != 0 && $show_member_list_to == 1) || \ Index: openacs-4/packages/acs-tcl/tcl/ad-functional-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/ad-functional-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-tcl/tcl/ad-functional-procs.tcl 26 Feb 2005 17:52:20 -0000 1.4 +++ openacs-4/packages/acs-tcl/tcl/ad-functional-procs.tcl 27 Feb 2005 22:45:39 -0000 1.5 @@ -718,6 +718,8 @@ # -------------------------------------------------------------------------------- ad_proc -public factorial {n} { + compute n! +} { product [enum_from_to 1 $n] } @@ -739,6 +741,8 @@ } ad_proc -public prime_p {n} { + @return 1 if n is prime +} { if { $n<2 } { return 0 } if { $n==2 } { return 1 } if { [even_p $n] } { return 0 } Index: openacs-4/packages/acs-tcl/tcl/defs-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/defs-procs.tcl,v diff -u -r1.48 -r1.49 --- openacs-4/packages/acs-tcl/tcl/defs-procs.tcl 29 Jan 2005 18:43:28 -0000 1.48 +++ openacs-4/packages/acs-tcl/tcl/defs-procs.tcl 27 Feb 2005 22:45:39 -0000 1.49 @@ -97,6 +97,8 @@ } ad_proc -public ad_pvt_home_link {} { + @return the html fragment for the /pvt link +} { return "[ad_pvt_home_name]" } Index: openacs-4/packages/acs-tcl/tcl/openacs-kernel-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/openacs-kernel-procs.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-tcl/tcl/openacs-kernel-procs.tcl 1 Nov 2003 08:45:37 -0000 1.6 +++ openacs-4/packages/acs-tcl/tcl/openacs-kernel-procs.tcl 27 Feb 2005 22:45:39 -0000 1.7 @@ -7,134 +7,147 @@ @cvs-id $Id$ } -namespace eval oacs_util { +namespace eval oacs_util {} - ad_proc -public process_objects_csv { - {-object_type:required} - {-file:required} - {-header_line 1} - {-override_headers {}} - {-constants ""} - } { - This processes a CVS of objects - } { - # FIXME: We should catch the error here - set csv_stream [open $file r] +ad_proc -public oacs_util::process_objects_csv { + {-object_type:required} + {-file:required} + {-header_line 1} + {-override_headers {}} + {-constants ""} +} { + This processes a CSV of objects, taking the csv and calling package_instantiate_object + for each one. - # Check if there are headers - if {![empty_string_p $override_headers]} { - set headers $override_headers - } else { - if {!$header_line} { - return -code error "There is no header!" - } + @return a list of the created object_ids +} { + # FIXME: We should catch the error here + set csv_stream [open $file r] - # get the headers - ns_getcsv $csv_stream headers + # Check if there are headers + if {![empty_string_p $override_headers]} { + set headers $override_headers + } else { + if {!$header_line} { + return -code error "There is no header!" } - set list_of_object_ids [list] - - # Process the file - db_transaction { - while {1} { - # Get a line - set n_fields [ns_getcsv $csv_stream one_line] - - # end of things - if {$n_fields == -1} { - break - } - - # Process the row - set extra_vars [ns_set create] - for {set i 0} {$i < $n_fields} {incr i} { - set varname [string tolower [lindex $headers $i]] - set varvalue [lindex $one_line $i] - - # Set the value - ns_log debug "oacs_util::process_objects_csv: setting $varname to $varvalue" - ns_set put $extra_vars $varname $varvalue - } - - # Add in the constants - if {![empty_string_p $constants]} { - # This modifies extra_vars, without touching constants - ns_set merge $constants $extra_vars - } - - # Create object and go for it - set object_id [package_instantiate_object -extra_vars $extra_vars $object_type] - lappend list_of_object_ids $object_id - - # Clean Up - ns_set free $extra_vars - } - } - - # Return the list of objects - return $list_of_object_ids + # get the headers + ns_getcsv $csv_stream headers } - ad_proc -public csv_foreach { - {-file:required} - {-header_line 1} - {-override_headers {}} - {-array_name:required} - code_block - } { - # FIXME: We should catch the error here - set csv_stream [open $file r] + set list_of_object_ids [list] - # Check if there are headers - if {![empty_string_p $override_headers]} { - set headers $override_headers - } else { - if {!$header_line} { - return -code error "There is no header!" - } - - # get the headers - ns_getcsv $csv_stream headers - } - - # Upvar Magic! - upvar 1 $array_name row_array - + # Process the file + db_transaction { while {1} { # Get a line set n_fields [ns_getcsv $csv_stream one_line] - + # end of things if {$n_fields == -1} { break } - + # Process the row + set extra_vars [ns_set create] for {set i 0} {$i < $n_fields} {incr i} { set varname [string tolower [lindex $headers $i]] set varvalue [lindex $one_line $i] - set row_array($varname) $varvalue + + # Set the value + ns_log debug "oacs_util::process_objects_csv: setting $varname to $varvalue" + ns_set put $extra_vars $varname $varvalue } - # Now we are ready to process the code block - set errno [catch { uplevel 1 $code_block } error] - - # Error? - if {$errno > 0} { - return -code $error + # Add in the constants + if {![empty_string_p $constants]} { + # This modifies extra_vars, without touching constants + ns_set merge $constants $extra_vars } + + # Create object and go for it + set object_id [package_instantiate_object -extra_vars $extra_vars $object_type] + lappend list_of_object_ids $object_id + + # Clean Up + ns_set free $extra_vars } } - ad_proc -public vars_to_ns_set { - {-ns_set:required} - {-var_list:required} - } { - foreach var $var_list { - upvar $var one_var - ns_set put $ns_set $var $one_var - } + # Return the list of objects + return $list_of_object_ids +} + +ad_proc -public oacs_util::csv_foreach { + {-file:required} + {-header_line 1} + {-override_headers {}} + {-array_name:required} + code_block +} { + reads a csv and executes code block for each row in the csv. + + @param file the csv file to read. + @param header_line the line with the list of var names + @param override_headers the list of variables in the csv + @param array_name the name of the array to set with the values from the csv as each line is read. +} { + # FIXME: We should catch the error here + set csv_stream [open $file r] + + # Check if there are headers + if {![empty_string_p $override_headers]} { + set headers $override_headers + } else { + if {!$header_line} { + return -code error "There is no header!" + } + + # get the headers + ns_getcsv $csv_stream headers } + # Upvar Magic! + upvar 1 $array_name row_array + + while {1} { + # Get a line + set n_fields [ns_getcsv $csv_stream one_line] + + # end of things + if {$n_fields == -1} { + break + } + + # Process the row + for {set i 0} {$i < $n_fields} {incr i} { + set varname [string tolower [lindex $headers $i]] + set varvalue [lindex $one_line $i] + set row_array($varname) $varvalue + } + + # Now we are ready to process the code block + set errno [catch { uplevel 1 $code_block } error] + + # Error? + if {$errno > 0} { + return -code $error + } + } } + +ad_proc -public oacs_util::vars_to_ns_set { + {-ns_set:required} + {-var_list:required} +} { + Does an ns_set put on each variable named in var_list + + @param var_list list of variable names in the calling scope + @param ns_set an ns_set id that already exists. +} { + foreach var $var_list { + upvar $var one_var + ns_set put $ns_set $var $one_var + } +} Index: openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 25 Feb 2005 16:30:59 -0000 1.12 +++ openacs-4/packages/acs-tcl/tcl/parameter-procs.tcl 27 Feb 2005 22:45:39 -0000 1.13 @@ -8,154 +8,157 @@ } -namespace eval parameter { +namespace eval parameter {} - ad_proc -public set_value { - {-package_id ""} - {-parameter:required} - {-value:required} - } { - set a parameter +ad_proc -public parameter::set_value { + {-package_id ""} + {-parameter:required} + {-value:required} +} { + set a parameter - @param package_id what package to set the parameter in. defaults to - [ad_conn package_id] - @param parameter which parameter's value to set - @param value what value to set said parameter to - } { - if {[empty_string_p $package_id]} { - ::set package_id [ad_requested_object_id] - } - - db_exec_plsql set_parameter_value {} - - return [ad_parameter_cache -set $value $package_id $parameter] + @param package_id what package to set the parameter in. defaults to + [ad_conn package_id] + @param parameter which parameter's value to set + @param value what value to set said parameter to +} { + if {[empty_string_p $package_id]} { + set package_id [ad_requested_object_id] } - ad_proc -public get { - -localize:boolean - -boolean:boolean - {-package_id ""} - {-parameter:required} - {-default ""} - } { - Get the value of a package parameter. + db_exec_plsql set_parameter_value {} - @param package_id what package to get the parameter from. defaults to - [ad_conn package_id] - @param parameter which parameter's value to get - @param default what to return if we don't find a value. Defaults to returning the empty string. + return [ad_parameter_cache -set $value $package_id $parameter] +} - @return The string trimmed (leading and trailing spaces removed) parameter value - } { +ad_proc -public parameter::get { + -localize:boolean + -boolean:boolean + {-package_id ""} + {-parameter:required} + {-default ""} +} { + Get the value of a package parameter. - if {[empty_string_p $package_id]} { - ::set package_id [ad_requested_object_id] - } + @param package_id what package to get the parameter from. defaults to + [ad_conn package_id] + @param parameter which parameter's value to get + @param default what to return if we don't find a value. Defaults to returning the empty string. - ::set package_key "" - ::set value "" - if {![empty_string_p $package_id]} { - # This can fail at server startup--OpenACS calls parameter::get to - # get the size of the util_memoize cache so it can setup the cache. - # apm_package_key_from_id needs that cache, but on server start - # when the toolkit tries to get the parameter for the cache size - # the cache doesn't exist yet, so apm_package_key_from_id fails - catch { - ::set package_key [apm_package_key_from_id $package_id] - } - } + @return The string trimmed (leading and trailing spaces removed) parameter value +} { - # If I convert the package_id to a package_key, is there a parameter by this - # name in the parameter file? If so, it takes precedence. - # 1. use the parameter file - if {![empty_string_p $package_key]} { - ::set value [ad_parameter_from_file $parameter $package_key] - } + if {[empty_string_p $package_id]} { + set package_id [ad_requested_object_id] + } - # 2. check the parameter cache - if {[empty_string_p $value]} { - ::set value [ad_parameter_cache $package_id $parameter] - } - # 3. use the default value - if {[empty_string_p $value]} { - ::set value $default + set package_key "" + set value "" + if {![empty_string_p $package_id]} { + # This can fail at server startup--OpenACS calls parameter::get to + # get the size of the util_memoize cache so it can setup the cache. + # apm_package_key_from_id needs that cache, but on server start + # when the toolkit tries to get the parameter for the cache size + # the cache doesn't exist yet, so apm_package_key_from_id fails + catch { + set package_key [apm_package_key_from_id $package_id] } + } - if { $localize_p } { - # Replace message keys in hash marks with localized texts - set value [lang::util::localize $value] - } + # If I convert the package_id to a package_key, is there a parameter by this + # name in the parameter file? If so, it takes precedence. + # 1. use the parameter file + if {![empty_string_p $package_key]} { + set value [ad_parameter_from_file $parameter $package_key] + } - # Trimming the value as people may have accidentally put in trailing spaces - set value [string trim $value] + # 2. check the parameter cache + if {[empty_string_p $value]} { + set value [ad_parameter_cache $package_id $parameter] + } + # 3. use the default value + if {[empty_string_p $value]} { + set value $default + } - # Special parsing for boolean parameters, true and false can be written - # in many different ways - if { $boolean_p } { - if { [catch { - if { [template::util::is_true $value] } { - set value 1 - } else { - set value 0 - } - } errmsg] } { - global errorInfo - ns_log Error "Parameter $parameter not a boolean:\n$errorInfo" - set value $default + if { $localize_p } { + # Replace message keys in hash marks with localized texts + set value [lang::util::localize $value] + } + + # Trimming the value as people may have accidentally put in trailing spaces + set value [string trim $value] + + # Special parsing for boolean parameters, true and false can be written + # in many different ways + if { $boolean_p } { + if { [catch { + if { [template::util::is_true $value] } { + set value 1 + } else { + set value 0 } + } errmsg] } { + global errorInfo + ns_log Error "Parameter $parameter not a boolean:\n$errorInfo" + set value $default } - - return $value } - ad_proc -public set_from_package_key { - {-package_key:required} - {-parameter:required} - {-value:required} - } { - set_value \ - -package_id [apm_package_id_from_key $package_key] \ - -parameter $parameter \ - -value $value - } + return $value +} - ad_proc -public get_from_package_key { - -localize:boolean - -boolean:boolean - {-package_key:required} - {-parameter:required} - {-default ""} - } { - get a parameter +ad_proc -public parameter::set_from_package_key { + {-package_key:required} + {-parameter:required} + {-value:required} +} { + sets a parameter for the package corresponding to package_key + note that this makes the assumption that the package is a singleton + and does not set the value for all packages corresponding to package_key - @param package_key what package to get the parameter from. we will try - to get the package_id from the package_key. this - may cause an error if there are more than one - instance of this package - @param parameter which parameter's value to get - @param default what to return if we don't find a value - } { - # 1. check to see if this parameter is being set in the server's - # configuration file; this value has highest precedence - ::set value [ad_parameter_from_file $parameter $package_key] +} { + parameter::set_value \ + -package_id [apm_package_id_from_key $package_key] \ + -parameter $parameter \ + -value $value +} - # 2. try to get a package_id for this package_key and use the standard - # parameter::get function to get the value - if {[empty_string_p $value]} { - with_catch errmsg { - ::set value [get \ - -localize=$localize_p \ - -boolean=$boolean_p \ - -package_id [apm_package_id_from_key $package_key] \ - -parameter $parameter \ - -default $default \ - ] - } { - ::set value $default - } - } +ad_proc -public parameter::get_from_package_key { + -localize:boolean + -boolean:boolean + {-package_key:required} + {-parameter:required} + {-default ""} +} { + get a parameter - return $value + @param package_key what package to get the parameter from. we will try + to get the package_id from the package_key. this + may cause an error if there are more than one + instance of this package + @param parameter which parameter's value to get + @param default what to return if we don't find a value +} { + # 1. check to see if this parameter is being set in the server's + # configuration file; this value has highest precedence + set value [ad_parameter_from_file $parameter $package_key] + + # 2. try to get a package_id for this package_key and use the standard + # parameter::get function to get the value + if {[empty_string_p $value]} { + with_catch errmsg { + set value [parameter::get \ + -localize=$localize_p \ + -boolean=$boolean_p \ + -package_id [apm_package_id_from_key $package_key] \ + -parameter $parameter \ + -default $default \ + ] + } { + set value $default + } } + return $value } Index: openacs-4/packages/acs-tcl/tcl/site-node-object-map-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/site-node-object-map-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-tcl/tcl/site-node-object-map-procs.tcl 10 Sep 2002 22:22:14 -0000 1.2 +++ openacs-4/packages/acs-tcl/tcl/site-node-object-map-procs.tcl 27 Feb 2005 22:45:39 -0000 1.3 @@ -8,37 +8,44 @@ @cvs-id $Id$ } -namespace eval site_node_object_map { +namespace eval site_node_object_map {} - ad_proc -public new { - {-object_id:required} - {-node_id:required} - } { - db_exec_plsql set_node_mapping {} - } +ad_proc -public site_node_object_map::new { + {-object_id:required} + {-node_id:required} +} { + map object object_id to site_node node_id in table site_node_object_mappings +} { + db_exec_plsql set_node_mapping {} +} - ad_proc -public del { - {-object_id:required} - } { - db_exec_plsql unset_node_mapping {} - } +ad_proc -public site_node_object_map::del { + {-object_id:required} +} { + unmap object object_id from site_node node_id in table site_node_object_mappings +} { + db_exec_plsql unset_node_mapping {} +} - ad_proc -public get_node_id { - {-object_id:required} - } { - return [db_string select_node_mapping {} -default ""] - } +ad_proc -public site_node_object_map::get_node_id { + {-object_id:required} +} { + @return the node_id of the site_node of the passed object_id +} { + return [db_string select_node_mapping {} -default ""] +} - ad_proc -public get_url { - {-object_id:required} - } { - set node_id [get_node_id -object_id $object_id] +ad_proc -public site_node_object_map::get_url { + {-object_id:required} +} { + @return the url corresponding to the site_node to which the passed object_id is mapped. +} { + set node_id [site_node_object_map::get_node_id -object_id $object_id] - if {[empty_string_p $node_id]} { - return $node_id - } - - return [site_node::get_url -node_id $node_id] + if {[empty_string_p $node_id]} { + return {} } + return [site_node::get_url -node_id $node_id] } + Index: openacs-4/packages/acs-tcl/tcl/test/file-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/file-test-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-tcl/tcl/test/file-test-procs.tcl 27 Feb 2005 20:04:28 -0000 1.3 +++ openacs-4/packages/acs-tcl/tcl/test/file-test-procs.tcl 27 Feb 2005 22:45:40 -0000 1.4 @@ -55,7 +55,7 @@ set startdir [acs_root_dir]/packages aa_log "Checks starting from $startdir" - + set count 0 #inspect every tcl file in the directory tree starting with $startdir foreach file [ad_find_all_files -check_file_func ::tcl_p $startdir] { @@ -64,9 +64,12 @@ close $fp if {![regexp {/packages/acs-tcl/tcl/test/acs-tcl-test-procs\.tcl$} $file match]} { - aa_true "$file should not contain '@returns'. @returns is probably a typo of @return" [expr [string first @returns $data] == -1] + if {[string first @returns $data] < 0} { + aa_log_result fail "$file should not contain '@returns'. @returns is probably a typo of @return" + } } } + aa_log "Checked $count tcl files" } aa_register_case -cats {smoke production_safe} files__check_info_files { Index: openacs-4/packages/acs-templating/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/apm-callback-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-templating/tcl/apm-callback-procs.tcl 22 Sep 2003 18:03:48 -0000 1.1 +++ openacs-4/packages/acs-templating/tcl/apm-callback-procs.tcl 27 Feb 2005 22:45:40 -0000 1.2 @@ -9,17 +9,19 @@ namespace eval template {} namespace eval template::apm {} -ad_proc -public template::apm::before_upgrade { +ad_proc -private template::apm::before_upgrade { {-from_version_name:required} {-to_version_name:required} } { + before upgrade apm callback for acs-templating. +} { apm_upgrade_logic \ -from_version_name $from_version_name \ -to_version_name $to_version_name \ -spec { 4.6.4 5.0d1 { db_transaction { - + # Change 'standard-lars' to 'standard' set package_id [apm_package_id_from_key "acs-templating"] @@ -42,15 +44,14 @@ set DefaultFormStyle [parameter::get \ -package_id $package_id \ -parameter DefaultFormStyle] - + if { [string equal $DefaultFormStyle "standard-lars"] } { parameter::set_value \ -package_id $package_id \ -parameter DefaultFormStyle \ -value "standard" } } - } } } Index: openacs-4/packages/acs-templating/tcl/currency-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/currency-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/acs-templating/tcl/currency-procs.tcl 12 Jul 2004 14:49:50 -0000 1.9 +++ openacs-4/packages/acs-templating/tcl/currency-procs.tcl 27 Feb 2005 22:45:40 -0000 1.10 @@ -43,7 +43,10 @@ } ad_proc -public template::data::validate::currency { value_ref message_ref } { + form validation for currency type. + Should validate according to locale for example, the following forms: "$2.03" "Rs 50.42" "12.52L" "Y5,13c" +} { upvar 2 $message_ref message $value_ref value # a currency is a 6 element list supporting, for example, the following forms: "$2.03" "Rs 50.42" "12.52L" "Y5,13c" @@ -71,9 +74,9 @@ } else { return 1 } -} +} -ad_proc -public template::data::transform::currency { element_ref } { +ad_proc -private template::data::transform::currency { element_ref } { upvar $element_ref element set element_id $element(id) @@ -84,7 +87,7 @@ } # a currency is a 6 element list supporting, for example, the following forms: "$2.03" "Rs 50.42" "12.52L" "Y5,13c" - + set have_values 0 for { set i 0 } { $i <= 4 } { incr i } { @@ -237,9 +240,8 @@ ad_proc -public template::widget::currency { element_reference tag_attributes {mode edit} } { - upvar $element_reference element - + if { [info exists element(html)] } { array set attributes $element(html) } @@ -279,4 +281,3 @@ return $output } - Index: openacs-4/packages/acs-templating/tcl/filter-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/filter-procs.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/acs-templating/tcl/filter-procs.tcl 29 Dec 2003 20:08:52 -0000 1.13 +++ openacs-4/packages/acs-templating/tcl/filter-procs.tcl 27 Feb 2005 22:45:40 -0000 1.14 @@ -19,24 +19,23 @@ @see ad_cache_returnredirect } { - # DRB: The code that was here before didn't preserve the protocol, always - # using HTTP even if HTTPS was used to establish the connection. Besides - # which ad_returnredirect has funky checks for even funkier browsers, and - # is therefore not only the standard way to redirect in OpenACS 4 but - # more robust as well. + # DRB: The code that was here before didn't preserve the protocol, always + # using HTTP even if HTTPS was used to establish the connection. Besides + # which ad_returnredirect has funky checks for even funkier browsers, and + # is therefore not only the standard way to redirect in OpenACS 4 but + # more robust as well. - set cache_p [lindex $args 0] + set cache_p [lindex $args 0] - if { [string equal $cache_p "t"] } { - set persistent_p [lindex $args 1] + if { [string equal $cache_p "t"] } { + set persistent_p [lindex $args 1] set excluded_vars [lindex $args 2] - ad_cache_returnredirect $url $persistent_p $excluded_vars - } else { + ad_cache_returnredirect $url $persistent_p $excluded_vars + } else { ad_returnredirect $url - } - - ad_script_abort + } + ad_script_abort } ad_proc -public template::filter { command args } { @@ -45,22 +44,22 @@ a reference (not the value) to a variable containing the URL of the template to parse. The filter procedure may modify this. } { - variable filter_list + variable filter_list - set arg1 [lindex $args 0] - set arg2 [lindex $args 1] + set arg1 [lindex $args 0] + set arg2 [lindex $args 1] - switch -exact $command { + switch -exact $command { - add { lappend filter_list $arg1 } + add { lappend filter_list $arg1 } - exec { - upvar $arg1 url $arg2 root_path - foreach proc_name $filter_list { $proc_name url root_path } - } + exec { + upvar $arg1 url $arg2 root_path + foreach proc_name $filter_list { $proc_name url root_path } + } - default { error "Invalid filter command: must be add or exec" } - } + default { error "Invalid filter command: must be add or exec" } + } } # DRB: The following debugging filters weren't integrated with OpenACS. @@ -73,56 +72,55 @@ ad_proc -public cmp_page_filter { why } { Show the compiled template (for debugging) } { - if { [catch { - set url [ns_conn url] - regsub {.cmp} $url {} url_stub - regexp {^/([^/]*)(.*)} $url_stub all package_key rest - set file_stub "[acs_root_dir]/packages/$package_key/www$rest" + if { [catch { + set url [ns_conn url] + regsub {.cmp} $url {} url_stub + regexp {^/([^/]*)(.*)} $url_stub all package_key rest + set file_stub "[acs_root_dir]/packages/$package_key/www$rest" - set beginTime [clock clicks -milliseconds] + set beginTime [clock clicks -milliseconds] - set output "
[ns_quotehtml \
-      [template::adp_compile -file $file_stub.adp]]
" + set output "
[ns_quotehtml [template::adp_compile -file $file_stub.adp]]
" - set timeElapsed [expr ([clock clicks -milliseconds] - $beginTime)] - ns_log debug "cmp_page_filter: Time elapsed: $timeElapsed" + set timeElapsed [expr ([clock clicks -milliseconds] - $beginTime)] + ns_log debug "cmp_page_filter: Time elapsed: $timeElapsed" - } errMsg] } { - global errorInfo - set output
$errorInfo
- } + } errMsg] } { + global errorInfo + set output
[ad_quotehtml $errorInfo]
+ } - ns_return 200 text/html $output + ns_return 200 text/html $output - return filter_return + return filter_return } ad_proc -public dat_page_filter { why } { Show the comments for the template (for designer) } { - if { [catch { - set url [ns_conn url] - regsub {.dat} $url {} url_stub - regexp {^/([^/]*)(.*)} $url_stub all package_key rest - set code_stub "[acs_root_dir]/packages/$package_key/www$rest" + if { [catch { + set url [ns_conn url] + regsub {.dat} $url {} url_stub + regexp {^/([^/]*)(.*)} $url_stub all package_key rest + set code_stub "[acs_root_dir]/packages/$package_key/www$rest" - set beginTime [clock clicks -milliseconds] + set beginTime [clock clicks -milliseconds] - set file_stub [template::get_resource_path]/messages/datasources + set file_stub [template::get_resource_path]/messages/datasources - set output [template::adp_parse $file_stub [list code_stub $code_stub]] + set output [template::adp_parse $file_stub [list code_stub $code_stub]] - set timeElapsed [expr ([clock clicks -milliseconds] - $beginTime)] - ns_log debug " dat_page_filter: Time elapsed: $timeElapsed" + set timeElapsed [expr ([clock clicks -milliseconds] - $beginTime)] + ns_log debug " dat_page_filter: Time elapsed: $timeElapsed" - } errMsg] } { - global errorInfo - set output
$errorInfo
- } + } errMsg] } { + global errorInfo + set output
$errorInfo
+ } - ns_return 200 text/html $output + ns_return 200 text/html $output - return filter_return + return filter_return } # Return the auto-generated template for a form @@ -135,42 +133,41 @@ originally handled inline but doing so screwed up the query processor. } { - set url [ns_conn url] - regsub {.frm} $url {} url_stub - regexp {^/([^/]*)(.*)} $url_stub all package_key rest - set __adp_stub "[acs_root_dir]/packages/$package_key/www$rest" + set url [ns_conn url] + regsub {.frm} $url {} url_stub + regexp {^/([^/]*)(.*)} $url_stub all package_key rest + set __adp_stub "[acs_root_dir]/packages/$package_key/www$rest" - # Set the parse level - variable parse_level - lappend parse_level [info level] + # Set the parse level + variable parse_level + lappend parse_level [info level] - # execute the code to prepare the form(s) for a template - adp_prepare + # execute the code to prepare the form(s) for a template + adp_prepare - # get the form template - return [form::template [ns_queryget form_id] [ns_queryget form_style]] + # get the form template + return [form::template [ns_queryget form_id] [ns_queryget form_style]] } } -ad_proc -public frm_page_filter { why } { +ad_proc -private frm_page_filter { why } { + Return the form data for a request for .frm +} { if { [catch { - set beginTime [clock clicks -milliseconds] + set beginTime [clock clicks -milliseconds] - set output [template::frm_page_handler] + set output [template::frm_page_handler] - set timeElapsed [expr ([clock clicks -milliseconds] - $beginTime)] - ns_log debug "frm_page_filter: Time elapsed: $timeElapsed" + set timeElapsed [expr ([clock clicks -milliseconds] - $beginTime)] + ns_log debug "frm_page_filter: Time elapsed: $timeElapsed" } errMsg] } { - global errorInfo - set output $errorInfo + global errorInfo + set output $errorInfo } - ns_return 200 text/html " - -
[ns_quotehtml $output]
- " + ns_return 200 text/html "
[ns_quotehtml $output]
" - return filter_return + return filter_return } Index: openacs-4/packages/acs-templating/tcl/list-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/list-procs.tcl,v diff -u -r1.23 -r1.24 --- openacs-4/packages/acs-templating/tcl/list-procs.tcl 7 Feb 2005 10:30:33 -0000 1.23 +++ openacs-4/packages/acs-templating/tcl/list-procs.tcl 27 Feb 2005 22:45:40 -0000 1.24 @@ -667,6 +667,8 @@ ad_proc -public template::list::csv_quote { string } { + Quote a string for inclusion as a csv element +} { regsub -all {\"} $string {""} result return $result } @@ -1671,6 +1673,8 @@ {-list_name:required} {-element_name:required} } { + @return the name used for the list element properties array. +} { return "$list_name:element:$element_name:properties" } @@ -1680,11 +1684,13 @@ {-local_name "element_properties"} {-create:boolean} } { + upvar the list element to the callers scope as $local_name +} { # Check that the list exists template::list::get_reference -name $list_name set refname [get_refname -list_name $list_name -element_name $element_name] - + if { !$create_p && ![uplevel \#[template::adp_level] [list info exists $refname]] } { error "Element '$element_name' not found in list '$list_name'" } @@ -1698,6 +1704,8 @@ {-element_name:required} {-property:required} } { + @return the element property in the named list. +} { get_reference \ -list_name $list_name \ -element_name $element_name Index: openacs-4/packages/acs-templating/tcl/mime-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/mime-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/acs-templating/tcl/mime-procs.tcl 15 Oct 2003 12:35:51 -0000 1.5 +++ openacs-4/packages/acs-templating/tcl/mime-procs.tcl 27 Feb 2005 22:45:40 -0000 1.6 @@ -1,46 +1,53 @@ namespace eval template {} ad_library { - Provides procedures needed to determine mime type required for the -client browser, as - well as other additional header information. + client browser, as well as other additional header information. @author Shan Shan Huang (shuang@arsdigita.com) @creation-date 12 January 2001 @cvs-id $Id$ -} +} -ad_proc -public template::register_mime_type { mime_type file_extension -header_preamble } { - if { [info exists template_extension($mime_type)] } { - nsv_unset template_extension($mime_type) - } - if { [info exists template_header_preamble($mime_type)] } { - unset template_header_preamble($mime_type) - } +ad_proc -public template::register_mime_type { mime_type file_extension header_preamble } { + sets the template_extension and template_header_preamble nsv's with the + provided data. +} { + if { [info exists template_extension($mime_type)] } { + nsv_unset template_extension($mime_type) + } + if { [info exists template_header_preamble($mime_type)] } { + unset template_header_preamble($mime_type) + } - nsv_set template_extension $mime_type $file_extension - nsv_set template_header_preamble $mime_type $header_preamble + nsv_set template_extension $mime_type $file_extension + nsv_set template_header_preamble $mime_type $header_preamble } ad_proc -public template::get_mime_template_extension { mime_type } { - if { [nsv_exists template_extension $mime_type] } { - return [nsv_get template_extension $mime_type] - } else { - return "adp" - } + @return the template extension associated with mime_type (default "adp") +} { + if { [nsv_exists template_extension $mime_type] } { + return [nsv_get template_extension $mime_type] + } else { + return "adp" + } } ad_proc -public template::get_mime_header_preamble { mime_type } { - if { [nsv_exists template_header_preamble $mime_type] } { - return [nsv_get template_header_preamble $mime_type] - } else { - return "" - } + @return the mime_header preamble if exists otherwise "" +} { + if { [nsv_exists template_header_preamble $mime_type] } { + return [nsv_get template_header_preamble $mime_type] + } else { + return "" + } } ad_proc -public template::get_mime_type {} { + gets the mimetype from the outputheaders and if missing guesses + text/html +} { if {[ns_conn isconnected]} { set mime_type [ns_set iget [ns_conn outputheaders] "content-type"] } else { Index: openacs-4/packages/acs-templating/tcl/tag-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/tag-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/acs-templating/tcl/tag-procs.tcl 24 Feb 2005 13:33:02 -0000 1.12 +++ openacs-4/packages/acs-templating/tcl/tag-procs.tcl 27 Feb 2005 22:45:40 -0000 1.13 @@ -11,7 +11,7 @@ # License. Full text of the license is available from the GNU Project: # http://www.fsf.org/copyleft/gpl.html -ad_proc -public template_tag_if_condition { chunk params condition_type } { +ad_proc -private template_tag_if_condition { chunk params condition_type } { set condition "$condition_type \{" Index: openacs-4/packages/acs-templating/tcl/widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/widget-procs.tcl,v diff -u -r1.35 -r1.36 --- openacs-4/packages/acs-templating/tcl/widget-procs.tcl 24 Feb 2005 13:33:02 -0000 1.35 +++ openacs-4/packages/acs-templating/tcl/widget-procs.tcl 27 Feb 2005 22:45:40 -0000 1.36 @@ -60,12 +60,13 @@ for groups or persons. @author Tilmann Singer + } { upvar $element_reference element if { ![info exists element(options)] } { - + # initial submission or no data (no options): a text box set output [input text element $tag_attributes] @@ -77,7 +78,7 @@ if { ![info exists element(confirmed_p)] } { append output "" } - + append output [select $element_reference $tag_attributes] } return $output @@ -87,8 +88,7 @@ return 1 } -ad_proc -public template::data::transform::party_search { element_ref } { - +ad_proc -private template::data::transform::party_search { element_ref } { upvar $element_ref element set element_id $element(id) @@ -109,7 +109,7 @@ template::element::set_error $element(form_id) $element_id "Please enter a search string." return [list] } - + if { [ns_queryexists $element_id:search_string] } { # request comes from a page with a select widget and the # search string has been passed as hidden value @@ -173,18 +173,35 @@ ad_proc -public template::widget::search { element_reference tag_attributes } { + Here is an example of using the search widget with ad_form: +
+    ad_form -name test -form {
+        {user:search,optional
+            {result_datatype integer}
+            {label "Email"}
+            {help_text "Search for a user by email address"}
+            {search_query {
+                select email from cc_users where lower(email) like '%'||lower(:value)||'%'
+            }}
+        }
+    }
+
+ Can be either a select widget initially if options supplied + or a text box which on submit changes to a select widget. + +} { upvar $element_reference element if { ! [info exists element(options)] } { - + # initial submission or no data (no options): a text box set output [input text element $tag_attributes] } else { # options provided so use a select list - # include an extra hidden element to indicate that the + # include an extra hidden element to indicate that the # value is being selected as opposed to entered set output "\n" @@ -231,7 +248,7 @@ return $output } -ad_proc -public template::widget::textarea_internal { +ad_proc -private template::widget::textarea_internal { name attribute_reference {value {}} Index: openacs-4/packages/news/tcl/test/news-db-test-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/news/tcl/test/news-db-test-init.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/news/tcl/test/news-db-test-init.tcl 26 Feb 2005 17:58:09 -0000 1.6 +++ openacs-4/packages/news/tcl/test/news-db-test-init.tcl 27 Feb 2005 22:45:40 -0000 1.7 @@ -5,12 +5,12 @@ ################################################################################ ad_library { - acs-automated-testing test definitions for the news package to be sourced on - server startup. + acs-automated-testing test definitions for the news package to be sourced on + server startup. - @author peter.harper@open-msg.com - @creation-date 2001-11-18 - @cvs-id $Id$ + @author peter.harper@open-msg.com + @creation-date 2001-11-18 + @cvs-id $Id$ } @@ -25,92 +25,92 @@ # Init Class mount-news-package # aa_register_init_class "mount-news-package" { - Mounts a copy of the news package in "/_test/news". + Mounts a copy of the news package in "/_test/news". } { - # Constructor - # Export variables we want to be visible to the testcase and the destructor. - aa_export_vars {_root_node_id _test_node_id _news_node_id _news_package_id - _news_package_mounted_p _news_package_mounted_err} + # Constructor + # Export variables we want to be visible to the testcase and the destructor. + aa_export_vars {_root_node_id _test_node_id _news_node_id _news_package_id + _news_package_mounted_p _news_package_mounted_err} - # - # Firstly, make sure the mount point "/_test/news" exists. - # - set _news_node_id -1 - set _test_node_id -1 - set _root_node_id -1 - set _news_package_id -1 - db_foreach get-site-nodes { - select node_id, object_id, site_node.url(node_id) as url from site_nodes - } { - switch [string trim $url] { - "/_test/news/" { - set _news_node_id $node_id - if {$object_id != ""} { - set _news_package_id $object_id + # + # Firstly, make sure the mount point "/_test/news" exists. + # + set _news_node_id -1 + set _test_node_id -1 + set _root_node_id -1 + set _news_package_id -1 + db_foreach get-site-nodes { + select node_id, object_id, site_node.url(node_id) as url from site_nodes + } { + switch [string trim $url] { + "/_test/news/" { + set _news_node_id $node_id + if {$object_id != ""} { + set _news_package_id $object_id + } + } + "/_test/" { + set _test_node_id $node_id + } + "/" { + set _root_node_id $node_id + } } - } - "/_test/" { - set _test_node_id $node_id - } - "/" { - set _root_node_id $node_id - } } - } - set _news_package_mounted_p 1 - if {[catch { - # Create the _test directory if it doesn't already exist. -aa_log "here" - if {$_test_node_id == -1} { - set _test_node_id [site_node::new \ - -name "_test" \ - -parent_id $_root_node_id ] - } - # If an old news package exists, delete it. - if {$_news_node_id != -1} { - aa_log "Deleting existing node instance." - site_map_unmount_application -delete_p t -sync_p t $_news_node_id - if {$_news_package_id != -1} { - aa_log "Deleting existing package instance." - set p_package_id $_news_package_id - db_exec_plsql package-delete { - begin - apm_package.del(:p_package_id); - end; + set _news_package_mounted_p 1 + if {[catch { + # Create the _test directory if it doesn't already exist. + aa_log "here" + if {$_test_node_id == -1} { + set _test_node_id [site_node::new \ + -name "_test" \ + -parent_id $_root_node_id ] } - } - } + # If an old news package exists, delete it. + if {$_news_node_id != -1} { + aa_log "Deleting existing node instance." + site_map_unmount_application -delete_p t -sync_p t $_news_node_id + if {$_news_package_id != -1} { + aa_log "Deleting existing package instance." + set p_package_id $_news_package_id + db_exec_plsql package-delete { + begin + apm_package.del(:p_package_id); + end; + } + } + } - # Mount the new news package and lookup the new node_id. - set _news_package_id [site_node::instantiate_and_mount \ - -parent_node_id $_test_node_id \ - -node_name news \ - -package_name "News test" \ - -package_key news] + # Mount the new news package and lookup the new node_id. + set _news_package_id [site_node::instantiate_and_mount \ + -parent_node_id $_test_node_id \ + -node_name news \ + -package_name "News test" \ + -package_key news] - set _news_node_id [site_node_id "/_test/news/"] - } _news_package_mounted_err]} { - set _news_node_id -1 - set _test_node_id -1 - set _root_node_id -1 - set _news_package_mounted_p 0 - } + set _news_node_id [site_node_id "/_test/news/"] + } _news_package_mounted_err]} { + set _news_node_id -1 + set _test_node_id -1 + set _root_node_id -1 + set _news_package_mounted_p 0 + } } { - # Destructor + # Destructor - # - # Unmount the news package and delete its directory. - # - if {$_news_package_mounted_p} { - site_map_unmount_application -delete_p t $_news_node_id - site_node::delete -node_id $_test_node_id - set p_package_id $_news_package_id - db_exec_plsql package-delete { - begin - apm_package.del(:p_package_id) + # + # Unmount the news package and delete its directory. + # + if {$_news_package_mounted_p} { + site_map_unmount_application -delete_p t $_news_node_id + site_node::delete -node_id $_test_node_id + set p_package_id $_news_package_id + db_exec_plsql package-delete { + begin + apm_package.del(:p_package_id) + } } - } } @@ -125,19 +125,19 @@ # Component db-news-globals # aa_register_component "db-news-globals" { - Sets up general information regarding the news package -
- Exports:
- _news_cr_root_folder_id
- _news_cr_news_root_folder_id + Sets up general information regarding the news package +
+ Exports:
+ _news_cr_root_folder_id
+ _news_cr_news_root_folder_id } { - aa_export_vars {_news_cr_root_folder_id _news_cr_news_root_folder_id} - - set _news_cr_root_folder_id [db_string get-cr-root-folder { - select content_item.get_root_folder from dual + aa_export_vars {_news_cr_root_folder_id _news_cr_news_root_folder_id} + + set _news_cr_root_folder_id [db_string get-cr-root-folder { + select content_item.get_root_folder from dual }] - set p_parent_id $_news_cr_root_folder_id - set _news_cr_news_root_folder_id [db_string get-cr-news-root-folder { + set p_parent_id $_news_cr_root_folder_id + set _news_cr_news_root_folder_id [db_string get-cr-news-root-folder { select item_id from cr_items where parent_id = :p_parent_id @@ -150,352 +150,352 @@ # Component db-news-item-create # aa_register_component "db-news-item-create" { - Creates a news item. Expects the following variables to be populated:
- p_title
- p_text
- p_package_id
- p_is_live
- p_full_details
-

- Populates:
- news_id + Creates a news item. Expects the following variables to be populated:
+ p_title
+ p_text
+ p_package_id
+ p_is_live
+ p_full_details
+

+ Populates:
+ news_id } { - aa_export_vars {p_full_details p_title p_text p_package_id p_is_live - p_approval_user p_approval_ip p_approval_date p_archive_date - news_id} - if {$p_full_details == "t"} { - set p_approval_user [ad_conn "user_id"] - set p_approval_ip [ad_conn "peeraddr"] - set p_approval_date [dt_sysdate] - set p_archive_date [dt_sysdate] - } else { - set p_approval_user [db_null] - set p_approval_ip [db_null] - set p_approval_date [db_null] - set p_archive_date [db_null] - } - set news_id [db_exec_plsql item-create { - begin - :1 := news.new( - text => :p_text, - title => :p_title, - package_id => :p_package_id, - archive_date => :p_archive_date, - approval_user => :p_approval_user, - approval_date => :p_approval_date, - approval_ip => :p_approval_ip, - is_live_p => :p_is_live - ); - end; - }] + aa_export_vars {p_full_details p_title p_text p_package_id p_is_live + p_approval_user p_approval_ip p_approval_date p_archive_date + news_id} + if {$p_full_details == "t"} { + set p_approval_user [ad_conn "user_id"] + set p_approval_ip [ad_conn "peeraddr"] + set p_approval_date [dt_sysdate] + set p_archive_date [dt_sysdate] + } else { + set p_approval_user [db_null] + set p_approval_ip [db_null] + set p_approval_date [db_null] + set p_archive_date [db_null] + } + set news_id [db_exec_plsql item-create { + begin + :1 := news.new( + text => :p_text, + title => :p_title, + package_id => :p_package_id, + archive_date => :p_archive_date, + approval_user => :p_approval_user, + approval_date => :p_approval_date, + approval_ip => :p_approval_ip, + is_live_p => :p_is_live + ); + end; + }] } ################################################################################ # # Component db-news-item-delete # aa_register_component "db-news-item-delete" { - Deletes a news item. Expects the following variables to be populated:
- p_news_id
+ Deletes a news item. Expects the following variables to be populated:
+ p_news_id
} { - aa_export_vars {p_item_id} - db_exec_plsql item-delete { - begin - news.del(:p_item_id); - end; - } + aa_export_vars {p_item_id} + db_exec_plsql item-delete { + begin + news.del(:p_item_id); + end; + } } ################################################################################ # # Component db-news-revision-create # aa_register_component "db-news-revision-create" { - Creates a news item revision. Expects the following variables to be populated:
- p_title
- p_text
- p_description
- p_package_id
- p_make_active_revision_p
- p_full_details
-

- Populates:
- revision_id + Creates a news item revision. Expects the following variables to be populated:
+ p_title
+ p_text
+ p_description
+ p_package_id
+ p_make_active_revision_p
+ p_full_details
+

+ Populates:
+ revision_id } { - aa_export_vars {p_item_id - p_full_details p_title p_text p_package_id p_make_active_revision_p - p_description - p_approval_user p_approval_ip p_approval_date p_archive_date - revision_id} - if {$p_full_details == "t"} { - set p_approval_user [ad_conn "user_id"] - set p_approval_ip [ad_conn "peeraddr"] - set p_approval_date [dt_sysdate] - set p_archive_date [dt_sysdate] - } else { - set p_approval_user [db_null] - set p_approval_ip [db_null] - set p_approval_date [db_null] - set p_archive_date [db_null] - } - set revision_id [db_exec_plsql revision-create { - begin - :1 := news.revision_new( - item_id => :p_item_id, - text => :p_text, - title => :p_title, - package_id => :p_package_id, - archive_date => :p_archive_date, - approval_user => :p_approval_user, - approval_date => :p_approval_date, - approval_ip => :p_approval_ip, - make_active_revision_p => :p_make_active_revision_p - ); - end; - }] + aa_export_vars {p_item_id + p_full_details p_title p_text p_package_id p_make_active_revision_p + p_description + p_approval_user p_approval_ip p_approval_date p_archive_date + revision_id} + if {$p_full_details == "t"} { + set p_approval_user [ad_conn "user_id"] + set p_approval_ip [ad_conn "peeraddr"] + set p_approval_date [dt_sysdate] + set p_archive_date [dt_sysdate] + } else { + set p_approval_user [db_null] + set p_approval_ip [db_null] + set p_approval_date [db_null] + set p_archive_date [db_null] + } + set revision_id [db_exec_plsql revision-create { + begin + :1 := news.revision_new( + item_id => :p_item_id, + text => :p_text, + title => :p_title, + package_id => :p_package_id, + archive_date => :p_archive_date, + approval_user => :p_approval_user, + approval_date => :p_approval_date, + approval_ip => :p_approval_ip, + make_active_revision_p => :p_make_active_revision_p + ); + end; + }] } ################################################################################ # # Component db-news-get-live-revision # aa_register_component "db-news-get-live-revision" { - Retrieves the id of the live revision of an item_id - p_item_id
- Provides
- live_revision_id + Retrieves the id of the live revision of an item_id + p_item_id
+ Provides
+ live_revision_id } { - aa_export_vars {p_item_id live_revision_id} - set live_revision_id [db_exec_plsql get-live-revision { - begin - :1 := content_item.get_live_revision(:p_item_id); - end; - }] + aa_export_vars {p_item_id live_revision_id} + set live_revision_id [db_exec_plsql get-live-revision { + begin + :1 := content_item.get_live_revision(:p_item_id); + end; + }] } ################################################################################ # # Component db-news-get-latest-revision # aa_register_component "db-news-get-latest-revision" { - Retrieves the id of the latest revision of an item_id - p_item_id
- Provides
- latest_revision_id + Retrieves the id of the latest revision of an item_id + p_item_id
+ Provides
+ latest_revision_id } { - aa_export_vars {p_item_id latest_revision_id} - set latest_revision_id [db_exec_plsql get-latest-revision { - begin - :1 := content_item.get_latest_revision(:p_item_id); - end; - }] + aa_export_vars {p_item_id latest_revision_id} + set latest_revision_id [db_exec_plsql get-latest-revision { + begin + :1 := content_item.get_latest_revision(:p_item_id); + end; + }] } ################################################################################ # # Component db-news-set-approve # aa_register_component "db-news-set-approve" { - Sets or removes the approved status on a news article
- Expects
- p_revision_id
- p_approve_p
- p_publish_date (if p_approve_p == 't')
- p_archive_date (if p_approve_p == 't')
- p_approval_user (if p_approve_p == 't')
- p_approval_date (if p_approve_p == 't')
- p_approval_ip (if p_approve_p == 't')
- p_live_revision_p (if p_approve_p == 't')
+ Sets or removes the approved status on a news article
+ Expects
+ p_revision_id
+ p_approve_p
+ p_publish_date (if p_approve_p == 't')
+ p_archive_date (if p_approve_p == 't')
+ p_approval_user (if p_approve_p == 't')
+ p_approval_date (if p_approve_p == 't')
+ p_approval_ip (if p_approve_p == 't')
+ p_live_revision_p (if p_approve_p == 't')
} { - aa_export_vars {p_revision_id - p_approve_p p_publish_date p_archive_date - p_approval_user p_approval_date p_approval_ip - p_live_revision_p} + aa_export_vars {p_revision_id + p_approve_p p_publish_date p_archive_date + p_approval_user p_approval_date p_approval_ip + p_live_revision_p} - if {$p_approve_p == "f"} { - db_exec_plsql set-approve-default { - begin - content_item.set_approve-default(revision_id => :p_revision_id, - approve_p => :p_approve_p); - end; + if {$p_approve_p == "f"} { + db_exec_plsql set-approve-default { + begin + content_item.set_approve-default(revision_id => :p_revision_id, + approve_p => :p_approve_p); + end; + } + } else { + db_exec_plsql set-approve { + begin + content_item.set_approve(revision_id => :p_revision_id, + approve_p => :p_approve_p, + publish_date => :p_publish_date + archive_date => :p_archive_date, + approval_user => :p_approval_user, + approval_date => :p_approval_date, + approvel_ip => :p_approval_id, + live_revision_p => :p_live_revision_ip); + end; + } } - } else { - db_exec_plsql set-approve { - begin - content_item.set_approve(revision_id => :p_revision_id, - approve_p => :p_approve_p, - publish_date => :p_publish_date - archive_date => :p_archive_date, - approval_user => :p_approval_user, - approval_date => :p_approval_date, - approvel_ip => :p_approval_id, - live_revision_p => :p_live_revision_ip); - end; - } - } } ################################################################################ # # Component db-news-revision-set-active # aa_register_component "db-news-revision-set-active" { - Sets a specific revision as the live version of the item - Requires:
- p_revision_id
+ Sets a specific revision as the live version of the item + Requires:
+ p_revision_id
} { - aa_export_vars {p_revision_id} - db_exec_plsql revision-set-active { - begin - news.revision_set_active(:p_revision_id); - end; - } + aa_export_vars {p_revision_id} + db_exec_plsql revision-set-active { + begin + news.revision_set_active(:p_revision_id); + end; + } } ################################################################################ # # Component db-news-revision-delete # aa_register_component "db-news-revision-delete" { - Deletes a news revision. Expects the following variables to be populated:
- p_revision_id
+ Deletes a news revision. Expects the following variables to be populated:
+ p_revision_id
} { - aa_export_vars {p_revision_id} - db_exec_plsql revision-delete { - begin - news.revision_delete(:p_revision_id); - end; - } + aa_export_vars {p_revision_id} + db_exec_plsql revision-delete { + begin + news.revision_delete(:p_revision_id); + end; + } } ################################################################################ # # Component db-get-cr-news-row # aa_register_component "db-get-cr-news-row" { - Retrieves the cr_news row information for the given news_id: - Expects:
- p_news_id
- In addition to the actual row data, populates:
- retrieval_ok_p
+ Retrieves the cr_news row information for the given news_id: + Expects:
+ p_news_id
+ In addition to the actual row data, populates:
+ retrieval_ok_p
} { - aa_export_vars {p_news_id - package_id archive_date approval_user approval_date approval_ip - retrieval_ok_p} - set retrieval_ok_p 1 - if {![db_0or1row get-cr-news-row { - select package_id, archive_date, - approval_user, approval_date, approval_ip - from cr_news - where news_id = :p_news_id + aa_export_vars {p_news_id + package_id archive_date approval_user approval_date approval_ip + retrieval_ok_p} + set retrieval_ok_p 1 + if {![db_0or1row get-cr-news-row { + select package_id, archive_date, + approval_user, approval_date, approval_ip + from cr_news + where news_id = :p_news_id }]} { - set retrieval_ok_p 0 - } + set retrieval_ok_p 0 + } } ################################################################################ # # Component db-get-cr-revisions-row # aa_register_component "db-get-cr-revisions-row" { - Retrieves the cr_revisions row information for the given news_id: - Expects:
- p_revision_id
- In addition to the actual row data, populates:
- retrieval_ok_p
+ Retrieves the cr_revisions row information for the given news_id: + Expects:
+ p_revision_id
+ In addition to the actual row data, populates:
+ retrieval_ok_p
} { - aa_export_vars {p_revision_id - item_id title description publish_date mime_type nls_language - content content_length - retrieval_ok_p} - set retrieval_ok_p 1 - if {![db_0or1row get-cr-revisions-row { - select item_id, title, description, publish_date, mime_type, - nls_language, content, content_length - from cr_revisions - where revision_id = :p_revision_id + aa_export_vars {p_revision_id + item_id title description publish_date mime_type nls_language + content content_length + retrieval_ok_p} + set retrieval_ok_p 1 + if {![db_0or1row get-cr-revisions-row { + select item_id, title, description, publish_date, mime_type, + nls_language, content, content_length + from cr_revisions + where revision_id = :p_revision_id }]} { - set retrieval_ok_p 0 - } + set retrieval_ok_p 0 + } } ################################################################################ # # Component db-get-cr-items-row # aa_register_component "db-get-cr-items-row" { - Retrieves the cr_revisions row information for the given news_id: - Expects:
- p_revision_id
- In addition to the actual row data, populates:
- retrieval_ok_p
+ Retrieves the cr_revisions row information for the given news_id: + Expects:
+ p_revision_id
+ In addition to the actual row data, populates:
+ retrieval_ok_p
} { - aa_export_vars {p_item_id - parent_id name live_revision latest_revision publish_status content_type - retrieval_ok_p} - set retrieval_ok_p 1 - if {![db_0or1row get-cr-items-row { - select parent_id, name, live_revision, latest_revision, - publish_status, content_type - from cr_items - where item_id = :p_item_id - }]} { - set retrieval_ok_p 0 - } + aa_export_vars {p_item_id + parent_id name live_revision latest_revision publish_status content_type + retrieval_ok_p} + set retrieval_ok_p 1 + if {![db_0or1row get-cr-items-row { + select parent_id, name, live_revision, latest_revision, + publish_status, content_type + from cr_items + where item_id = :p_item_id + }]} { + set retrieval_ok_p 0 + } } ################################################################################ # # Component db-news-make-permanent # aa_register_component "db-news-make-permanent" { - Calls the news packages make_permanent function. - p_item_id
+ Calls the news packages make_permanent function. + p_item_id
} { - aa_export_vars {p_item_id} - db_exec_plsql make-permanent { - begin - news.make_permanent(:p_item_id); - end; - } + aa_export_vars {p_item_id} + db_exec_plsql make-permanent { + begin + news.make_permanent(:p_item_id); + end; + } } ################################################################################ # # Component db-news-archive # aa_register_component "db-news-archive" { - Calls the news packages archive function. - p_item_id
- p_archive_date
+ Calls the news packages archive function. + p_item_id
+ p_archive_date
} { - aa_export_vars {p_item_id p_archive_date} - if {$p_archive_date == ""} { - db_exec_plsql archive-default { - begin - news.archive(:p_item_id, null); - end; + aa_export_vars {p_item_id p_archive_date} + if {$p_archive_date == ""} { + db_exec_plsql archive-default { + begin + news.archive(:p_item_id, null); + end; + } + } else { + db_exec_plsql archive { + begin + news.archive(:p_item_id, :p_archive_date); + end; + } } - } else { - db_exec_plsql archive { - begin - news.archive(:p_item_id, :p_archive_date); - end; - } - } } ################################################################################ # # Component db-news-status # aa_register_component "db-news-status" { - Calls the news packages status function. - p_news_id
+ Calls the news packages status function. + p_news_id
} { - aa_export_vars {p_publish_date p_archive_date status} + aa_export_vars {p_publish_date p_archive_date status} - set status [db_exec_plsql get-status {}] + set status [db_exec_plsql get-status {}] } @@ -510,60 +510,60 @@ # Testcase check-permissions # aa_register_case -cats { - db - config + db + config } -on_error { - At least some of the news permission privileges aren't present, or have incorrect - configurations. The most probable cause of this is that the news package datamodel - hasn't been installed. + At least some of the news permission privileges aren't present, or have incorrect + configurations. The most probable cause of this is that the news package datamodel + hasn't been installed. } "check-permissions" { - Checks the news related permissions. - Checks that the permissions exist, and that they have the correct - heirachy. + Checks the news related permissions. + Checks that the permissions exist, and that they have the correct + heirachy. } { - # - # Extract the list of all privileges and privilege heirachies. - # - set priv_list {} - db_foreach "get-privileges" { - select privilege from acs_privileges - } { - lappend priv_list $privilege - } + # + # Extract the list of all privileges and privilege heirachies. + # + set priv_list {} + db_foreach "get-privileges" { + select privilege from acs_privileges + } { + lappend priv_list $privilege + } - set priv_h_list {} - db_foreach "get-privilege-heirarchys" { - select privilege, child_privilege from acs_privilege_hierarchy - } { - lappend priv_h_list "$privilege,$child_privilege" - } + set priv_h_list {} + db_foreach "get-privilege-heirarchys" { + select privilege, child_privilege from acs_privilege_hierarchy + } { + lappend priv_h_list "$privilege,$child_privilege" + } - aa_log "Check the news privileges exist" - foreach priv {news_read news_create news_delete news_admin} { - aa_true "Check $priv privilege exists" {[lsearch $priv_list $priv] != -1} - } + aa_log "Check the news privileges exist" + foreach priv {news_read news_create news_delete news_admin} { + aa_true "Check $priv privilege exists" {[lsearch $priv_list $priv] != -1} + } - aa_log "Check the news privilege heirachies are correct" - foreach priv_pair {"read,news_read" - "delete,news_delete" - "news_admin,news_read" - "news_admin,news_create" - "news_admin,news_delete" - "admin,news_admin"} { - aa_true "Check $priv_pair privilege exists" {[lsearch $priv_h_list $priv_pair] != -1} - } + aa_log "Check the news privilege heirachies are correct" + foreach priv_pair {"read,news_read" + "delete,news_delete" + "news_admin,news_read" + "news_admin,news_create" + "news_admin,news_delete" + "admin,news_admin"} { + aa_true "Check $priv_pair privilege exists" {[lsearch $priv_h_list $priv_pair] != -1} + } - # - # Now check that correct groups have the right privileges. - # - set registered_users_id [acs_magic_object registered_users] - set the_public_id [acs_magic_object the_public] + # + # Now check that correct groups have the right privileges. + # + set registered_users_id [acs_magic_object registered_users] + set the_public_id [acs_magic_object the_public] - aa_log "Check the correct groups have the right privileges." - aa_true "Check public have news_read privilege" \ - [ad_permission_p $the_public_id news_read] - aa_true "Check registered_users have news_create privilege" \ - [ad_permission_p $registered_users_id news_read] + aa_log "Check the correct groups have the right privileges." + aa_true "Check public have news_read privilege" \ + [ad_permission_p $the_public_id news_read] + aa_true "Check registered_users have news_create privilege" \ + [ad_permission_p $registered_users_id news_read] } @@ -572,83 +572,83 @@ # Testcase check-views # aa_register_case -cats { - db - config + db + config } -on_error { } "check-views" { - Checks the news related views. - Checks that the views are valid by performing a select from each of them. + Checks the news related views. + Checks that the views are valid by performing a select from each of them. } { - aa_log "Check the news_items_approved view." - set error_p 0 - db_transaction { - db_1row select-from-news-items-approved { - select count(*) from news_items_approved + aa_log "Check the news_items_approved view." + set error_p 0 + db_transaction { + db_1row select-from-news-items-approved { + select count(*) from news_items_approved + } + } on_error { + set error_p 1 } - } on_error { - set error_p 1 - } - aa_false "Select from news_items_approved view okay" {$error_p} + aa_false "Select from news_items_approved view okay" {$error_p} - aa_log "Check the news_items_live_or_submitted view." - set error_p 0 - db_transaction { - db_1row select-from-news-items-live-or-submitted { - select count(*) from news_items_live_or_submitted + aa_log "Check the news_items_live_or_submitted view." + set error_p 0 + db_transaction { + db_1row select-from-news-items-live-or-submitted { + select count(*) from news_items_live_or_submitted + } + } on_error { + set error_p 1 } - } on_error { - set error_p 1 - } - aa_false "Select from news_items_live_or_submitted view okay" {$error_p} + aa_false "Select from news_items_live_or_submitted view okay" {$error_p} - aa_log "Check the news_items_unapproved view." - set error_p 0 - db_transaction { - db_1row select-from-news-items-unapproved { - select count(*) from news_items_unapproved + aa_log "Check the news_items_unapproved view." + set error_p 0 + db_transaction { + db_1row select-from-news-items-unapproved { + select count(*) from news_items_unapproved + } + } on_error { + set error_p 1 } - } on_error { - set error_p 1 - } - aa_false "Select from news_items_unapproved view okay" {$error_p} + aa_false "Select from news_items_unapproved view okay" {$error_p} - aa_log "Check the news_item_revisions view." - set error_p 0 - db_transaction { - db_1row select-from-news-item-revisions { - select count(*) from news_item_revisions + aa_log "Check the news_item_revisions view." + set error_p 0 + db_transaction { + db_1row select-from-news-item-revisions { + select count(*) from news_item_revisions + } + } on_error { + set error_p 1 } - } on_error { - set error_p 1 - } - aa_false "Select from news_item_revisions view okay" {$error_p} + aa_false "Select from news_item_revisions view okay" {$error_p} - aa_log "Check the news_item_unapproved view." - set error_p 0 - db_transaction { - db_1row select-from-news-item-unapproved { - select count(*) from news_item_unapproved + aa_log "Check the news_item_unapproved view." + set error_p 0 + db_transaction { + db_1row select-from-news-item-unapproved { + select count(*) from news_item_unapproved + } + } on_error { + set error_p 1 } - } on_error { - set error_p 1 - } - aa_false "Select from news_item_unapproved view okay" {$error_p} + aa_false "Select from news_item_unapproved view okay" {$error_p} - aa_log "Check the news_item_full_active view." - set error_p 0 - db_transaction { - db_1row select-from-news-item-full-active { - select count(*) from news_item_full_active + aa_log "Check the news_item_full_active view." + set error_p 0 + db_transaction { + db_1row select-from-news-item-full-active { + select count(*) from news_item_full_active + } + } on_error { + set error_p 1 } - } on_error { - set error_p 1 - } - aa_false "Select from news_item_full_active view okay" {$error_p} + aa_false "Select from news_item_full_active view okay" {$error_p} } @@ -657,69 +657,69 @@ # Testcase check-object-type # aa_register_case -cats { - db - config + db + config } -on_error { - The "news" object type doesn't exist, or has isn't configured correctly. - The most probable cause of this is that the news package datamodel hasn't been - installed. + The "news" object type doesn't exist, or has isn't configured correctly. + The most probable cause of this is that the news package datamodel hasn't been + installed. } "check-object-type" { - Checks the news object type. + Checks the news object type. } { - set news_type_exists_p [db_0or1row "get-news-type-info" { - select supertype - from acs_object_types - where object_type = 'news' - }] + set news_type_exists_p [db_0or1row "get-news-type-info" { + select supertype + from acs_object_types + where object_type = 'news' + }] - aa_true "Check news object type exists" {$news_type_exists_p} + aa_true "Check news object type exists" {$news_type_exists_p} - if {$news_type_exists_p} { - aa_equals "Check the supertype is content_revision" $supertype "content_revision" + if {$news_type_exists_p} { + aa_equals "Check the supertype is content_revision" $supertype "content_revision" - db_foreach "get-news-type-attribs" { - select attribute_name - from acs_attributes - where object_type = 'news' - } { - lappend attribs $attribute_name - } - aa_log "Check the news object attributes exist" - foreach attribute_name {"archive_date" - "approval_user" - "approval_date" - "approval_ip"} { - aa_true "Check $attribute_name exists" {[lsearch $attribs $attribute_name] != -1} - } + db_foreach "get-news-type-attribs" { + select attribute_name + from acs_attributes + where object_type = 'news' + } { + lappend attribs $attribute_name + } + aa_log "Check the news object attributes exist" + foreach attribute_name {"archive_date" + "approval_user" + "approval_date" + "approval_ip"} { + aa_true "Check $attribute_name exists" {[lsearch $attribs $attribute_name] != -1} + } - set news_folder_exists_p [db_0or1row "get-news-cr-folder" { - select folder_id - from cr_folders - where label = 'news' - }] - aa_true "Check news content_repository folder exists" {$news_folder_exists_p} - } + set news_folder_exists_p [db_0or1row "get-news-cr-folder" { + select folder_id + from cr_folders + where label = 'news' + }] + aa_true "Check news content_repository folder exists" {$news_folder_exists_p} + } } ################################################################################ # # Testcase check-package-mount # aa_register_case -cats { - db + db } -init_classes { - mount-news-package + mount-news-package } -on_error { } "check-package-mount" { - Checks the mountability of the news package. + Checks the mountability of the news package. } { - aa_true "Check that the news package mount properly" $_news_package_mounted_p - if {$_news_package_mounted_p} { - aa_log "News node_id :$_news_node_id" - aa_log "News package_id :$_news_package_id" - } else { - aa_error "Error from initialiser: $_news_package_mounted_err" - } + aa_true "Check that the news package mount properly" $_news_package_mounted_p + if {$_news_package_mounted_p} { + aa_log "News node_id :$_news_node_id" + aa_log "News package_id :$_news_package_id" + } else { + aa_error "Error from initialiser: $_news_package_mounted_err" + } } @@ -728,121 +728,121 @@ # Testcase db-check-news_create # aa_register_case -cats { - db + db } -init_classes { - mount-news-package + mount-news-package } "db-check-news-create" { - Creates and deletes a simple news article. Checks contents of cr_news, - cr_items and cr_revisions table after insert. Calls the news name function to retrieve - the article name. Tests news.new, news.delete and news.name. + Creates and deletes a simple news article. Checks contents of cr_news, + cr_items and cr_revisions table after insert. Calls the news name function to retrieve + the article name. Tests news.new, news.delete and news.name. } { - set news_id -1 + set news_id -1 - if {!$_news_package_mounted_p} { - aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" - } else { - # - # Attempt to create the article - # - set p_title "My title" - set p_text "My text" - set p_package_id $_news_package_id - set p_is_live "t" - set p_full_details "t" - aa_call_component db-news-globals - aa_call_component db-news-item-create - } -} { - aa_true "Check the news_id is populated" {$news_id != -1} - set item_id -1 - if {$news_id != -1} { - aa_log "News id: $news_id" - # - # Retrieve the row from cr_news table and check its contents. Notice that we - # only check the date portion of the date strings. - # - aa_log "Retrieve cr_news row and check its contents" - set p_news_id $news_id - aa_call_component db-get-cr-news-row - if {!$retrieval_ok_p} { - aa_error "cr_news column not found for news_id $news_id" + if {!$_news_package_mounted_p} { + aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" } else { - aa_equals "Check package_id correct" $package_id $_news_package_id - aa_equals "Check archive_date correct" \ - [string range $archive_date 0 [expr [string length $p_archive_date]-1]] \ - $p_archive_date - aa_equals "Check approval_user correct" $approval_user $p_approval_user - aa_equals "Check approval_date correct" \ - [string range $approval_date 0 [expr [string length $p_approval_date] - 1]] \ - $p_approval_date - aa_equals "Check approval_ip correct" $approval_ip $p_approval_ip + # + # Attempt to create the article + # + set p_title "My title" + set p_text "My text" + set p_package_id $_news_package_id + set p_is_live "t" + set p_full_details "t" + aa_call_component db-news-globals + aa_call_component db-news-item-create } - - # - # Retrieve the row from cr_revisions table and check its contents. - # NB: The get_cr_revisions_row populates item_id - # - aa_log "Retrieve cr_revisions row and check its contents" - set p_revision_id $news_id - aa_call_component db-get-cr-revisions-row - if {!$retrieval_ok_p} { - aa_error "cr_revisions row not found for news_id (revision_id) $news_id" - } else { - aa_equals "Check title correct" $title $p_title - aa_equals "Check description correct" $description "initial submission" - aa_equals "Check mime_type correct" $mime_type "text/plain" - - # - # Retrieve the row from cr_items table and check its contents. - # - aa_log "Retrieve cr_items row and check its contents" - set p_item_id $item_id - aa_call_component db-get-cr-items-row - if {!$retrieval_ok_p} { - aa_error "cr_items row not found for item_id (revision_id) $news_id" - } else { - aa_equals "Check parent_id correct" $parent_id $_news_cr_news_root_folder_id - aa_equals "Check live_revision correct" $live_revision $news_id - aa_equals "Check latest_revision correct" $latest_revision $news_id - aa_equals "Check publish_status correct" $publish_status "ready" - aa_equals "Check content_type correct" $content_type "news" - +} { + aa_true "Check the news_id is populated" {$news_id != -1} + set item_id -1 + if {$news_id != -1} { + aa_log "News id: $news_id" # - # Call the news.name function to retrieve the item name. + # Retrieve the row from cr_news table and check its contents. Notice that we + # only check the date portion of the date strings. # - aa_log "Call news.name function to retrieve title of content revision" + aa_log "Retrieve cr_news row and check its contents" set p_news_id $news_id - set name [db_exec_plsql news-name { - begin - :1 := news.name(news_id => :p_news_id); - end; - }] - aa_equals "Check the return from news.name is correct" $name $p_title - } + aa_call_component db-get-cr-news-row + if {!$retrieval_ok_p} { + aa_error "cr_news column not found for news_id $news_id" + } else { + aa_equals "Check package_id correct" $package_id $_news_package_id + aa_equals "Check archive_date correct" \ + [string range $archive_date 0 [expr [string length $p_archive_date]-1]] \ + $p_archive_date + aa_equals "Check approval_user correct" $approval_user $p_approval_user + aa_equals "Check approval_date correct" \ + [string range $approval_date 0 [expr [string length $p_approval_date] - 1]] \ + $p_approval_date + aa_equals "Check approval_ip correct" $approval_ip $p_approval_ip + } + + # + # Retrieve the row from cr_revisions table and check its contents. + # NB: The get_cr_revisions_row populates item_id + # + aa_log "Retrieve cr_revisions row and check its contents" + set p_revision_id $news_id + aa_call_component db-get-cr-revisions-row + if {!$retrieval_ok_p} { + aa_error "cr_revisions row not found for news_id (revision_id) $news_id" + } else { + aa_equals "Check title correct" $title $p_title + aa_equals "Check description correct" $description "initial submission" + aa_equals "Check mime_type correct" $mime_type "text/plain" + + # + # Retrieve the row from cr_items table and check its contents. + # + aa_log "Retrieve cr_items row and check its contents" + set p_item_id $item_id + aa_call_component db-get-cr-items-row + if {!$retrieval_ok_p} { + aa_error "cr_items row not found for item_id (revision_id) $news_id" + } else { + aa_equals "Check parent_id correct" $parent_id $_news_cr_news_root_folder_id + aa_equals "Check live_revision correct" $live_revision $news_id + aa_equals "Check latest_revision correct" $latest_revision $news_id + aa_equals "Check publish_status correct" $publish_status "ready" + aa_equals "Check content_type correct" $content_type "news" + + # + # Call the news.name function to retrieve the item name. + # + aa_log "Call news.name function to retrieve title of content revision" + set p_news_id $news_id + set name [db_exec_plsql news-name { + begin + :1 := news.name(news_id => :p_news_id); + end; + }] + aa_equals "Check the return from news.name is correct" $name $p_title + } + } } - } } { - # - # Delete the item. - # - if {$item_id != -1} { - aa_log "Deleting the item." - set p_item_id $item_id - aa_call_component db-news-item-delete + # + # Delete the item. + # + if {$item_id != -1} { + aa_log "Deleting the item." + set p_item_id $item_id + aa_call_component db-news-item-delete - aa_log "Checking all table data removed." - set p_news_id $news_id - aa_call_component db-get-cr-news-row - aa_false "Check the cr_news row was deleted" {$retrieval_ok_p} + aa_log "Checking all table data removed." + set p_news_id $news_id + aa_call_component db-get-cr-news-row + aa_false "Check the cr_news row was deleted" {$retrieval_ok_p} - set p_item_id $item_id - aa_call_component db-get-cr-items-row - aa_false "Check the cr_items row was deleted" {$retrieval_ok_p} - - set p_revision_id $news_id - aa_call_component db-get-cr-revisions-row - aa_false "Check the cr_revisions row was deleted" {$retrieval_ok_p} - } + set p_item_id $item_id + aa_call_component db-get-cr-items-row + aa_false "Check the cr_items row was deleted" {$retrieval_ok_p} + + set p_revision_id $news_id + aa_call_component db-get-cr-revisions-row + aa_false "Check the cr_revisions row was deleted" {$retrieval_ok_p} + } } @@ -851,263 +851,263 @@ # Testcase check-news-revision # aa_register_case -cats { - db + db } -init_classes { - mount-news-package + mount-news-package } -on_error { - This test may have failed because of a bug in the - content_item.get_latest_revision - database function; where two revisions are created so quickly that they - have the same creation_date value associated with them. This breaks the - logic of the get latest revision function. This problem was found in the - Alpha release of the OpenACS, and may have been fixed in later releases. -

- A posting - here at the OpenACS bboard was started concerning this problem. + This test may have failed because of a bug in the + content_item.get_latest_revision + database function; where two revisions are created so quickly that they + have the same creation_date value associated with them. This breaks the + logic of the get latest revision function. This problem was found in the + Alpha release of the OpenACS, and may have been fixed in later releases. +

+ A posting + here at the OpenACS bboard was started concerning this problem. } "db-check-news-revision" { - Checks the news database functions for revision creation, deletion and management. - Tests news.revison_new, news.revision_delete, - news.revision_set_active functions. + Checks the news database functions for revision creation, deletion and management. + Tests news.revison_new, news.revision_delete, + news.revision_set_active functions. } { - set news_id -1 + set news_id -1 - if {!$_news_package_mounted_p} { - aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" - } else { - # - # Create the article - # - set p_title "My title" - set p_text "My text" - set p_package_id $_news_package_id - set p_is_live "t" - set p_full_details "t" - aa_call_component db-news-globals - aa_call_component db-news-item-create - } -} { - aa_true "Check the news_id is populated" {$news_id != -1} - set item_id -1 - set revision1_id -1 - set revision2_id -1 - if {$news_id != -1} { - aa_log "News id: $news_id" - # - # Retrieve the row from cr_revisions table to get item_id - # - set p_revision_id $news_id - aa_call_component db-get-cr-revisions-row - set revision1_id $news_id - - # - # Check the first revision is the latest, and is live. - # - set p_item_id $item_id - aa_call_component db-news-get-live-revision - aa_call_component db-news-get-latest-revision - aa_equals "Confirm that the initial revision of the article is the latest" \ - $latest_revision_id $revision1_id - aa_equals "Confirm that the initial revision of the article is live" \ - $live_revision_id $revision1_id - - # - # Create a new revision of the news article. - # - set p_item_id $item_id - set p_title "My title 2" - set p_text "My text 2" - set p_description "Description 2" - set p_package_id $_news_package_id - set p_full_details "t" - set p_make_active_revision_p "t" - aa_call_component db-news-revision-create - set revision2_id $revision_id - - # - # Retrieve the cr_news column for the new revision - # - set p_news_id $revision2_id - aa_call_component db-get-cr-news-row - if {!$retrieval_ok_p} { - aa_error "cr_news row not found for new revision news_id $revision2_id" + if {!$_news_package_mounted_p} { + aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" } else { - aa_log "Check the cr_news fields for the second revision" - aa_equals "Check package_id correct" $package_id $_news_package_id - aa_equals "Check archive_date correct" \ - [string range $archive_date 0 [expr [string length $p_archive_date]-1]] \ - $p_archive_date - aa_equals "Check approval_user correct" $approval_user $p_approval_user - aa_equals "Check approval_date correct" \ - [string range $approval_date 0 [expr [string length $p_approval_date] - 1]] \ - $p_approval_date - aa_equals "Check approval_ip correct" $approval_ip $p_approval_ip - - # - # Retrieve the row from cr_revisions table to get item_id - # - set p_revision_id $revision2_id - aa_call_component db-get-cr-revisions-row - if {!$retrieval_ok_p} { - aa_error "cr_revisions row not found for new revision revision_id $revision2_id" - } else { - aa_equals "Check revision2 title correct" $title "My title 2" - aa_equals "Check revision2 description correct" $description "Description 2" - aa_equals "Check revision2 mime_type correct" $mime_type "text/plain" - # - # Check the second revision is now the latest, and is live. + # Create the article # - set p_item_id $item_id - aa_call_component db-news-get-live-revision - aa_call_component db-news-get-latest-revision - aa_equals "Confirm that the second revision of the article is the latest" \ - $latest_revision_id $revision2_id - aa_equals "Confirm that the second revision of the article is live" \ - $live_revision_id $revision2_id - + set p_title "My title" + set p_text "My text" + set p_package_id $_news_package_id + set p_is_live "t" + set p_full_details "t" + aa_call_component db-news-globals + aa_call_component db-news-item-create + } +} { + aa_true "Check the news_id is populated" {$news_id != -1} + set item_id -1 + set revision1_id -1 + set revision2_id -1 + if {$news_id != -1} { + aa_log "News id: $news_id" # - # Okay, lets set the original revision as active. + # Retrieve the row from cr_revisions table to get item_id # - aa_log "Reset the first revision as live" - set p_revision_id $revision1_id - aa_call_component db-news-revision-set-active + set p_revision_id $news_id + aa_call_component db-get-cr-revisions-row + set revision1_id $news_id # - # Check the second revision is still the latest, but the first one is live. + # Check the first revision is the latest, and is live. # set p_item_id $item_id aa_call_component db-news-get-live-revision aa_call_component db-news-get-latest-revision - aa_equals "Confirm that the second revision of the article is still the latest" \ - $latest_revision_id $revision2_id - aa_equals "Confirm that the first revision of the article is now live" \ - $live_revision_id $revision1_id + aa_equals "Confirm that the initial revision of the article is the latest" \ + $latest_revision_id $revision1_id + aa_equals "Confirm that the initial revision of the article is live" \ + $live_revision_id $revision1_id # - # Delete the second revision + # Create a new revision of the news article. # - aa_log "Delete the second revision" - set p_revision_id $revision2_id - aa_call_component db-news-revision-delete + set p_item_id $item_id + set p_title "My title 2" + set p_text "My text 2" + set p_description "Description 2" + set p_package_id $_news_package_id + set p_full_details "t" + set p_make_active_revision_p "t" + aa_call_component db-news-revision-create + set revision2_id $revision_id # - # Retrieve the row from cr_revisions table to get item_id + # Retrieve the cr_news column for the new revision # - set p_revision_id $revision2_id - aa_call_component db-get-cr-revisions-row - aa_false "Check the revision row was deleted" $retrieval_ok_p - } + set p_news_id $revision2_id + aa_call_component db-get-cr-news-row + if {!$retrieval_ok_p} { + aa_error "cr_news row not found for new revision news_id $revision2_id" + } else { + aa_log "Check the cr_news fields for the second revision" + aa_equals "Check package_id correct" $package_id $_news_package_id + aa_equals "Check archive_date correct" \ + [string range $archive_date 0 [expr [string length $p_archive_date]-1]] \ + $p_archive_date + aa_equals "Check approval_user correct" $approval_user $p_approval_user + aa_equals "Check approval_date correct" \ + [string range $approval_date 0 [expr [string length $p_approval_date] - 1]] \ + $p_approval_date + aa_equals "Check approval_ip correct" $approval_ip $p_approval_ip + + # + # Retrieve the row from cr_revisions table to get item_id + # + set p_revision_id $revision2_id + aa_call_component db-get-cr-revisions-row + if {!$retrieval_ok_p} { + aa_error "cr_revisions row not found for new revision revision_id $revision2_id" + } else { + aa_equals "Check revision2 title correct" $title "My title 2" + aa_equals "Check revision2 description correct" $description "Description 2" + aa_equals "Check revision2 mime_type correct" $mime_type "text/plain" + + # + # Check the second revision is now the latest, and is live. + # + set p_item_id $item_id + aa_call_component db-news-get-live-revision + aa_call_component db-news-get-latest-revision + aa_equals "Confirm that the second revision of the article is the latest" \ + $latest_revision_id $revision2_id + aa_equals "Confirm that the second revision of the article is live" \ + $live_revision_id $revision2_id + + # + # Okay, lets set the original revision as active. + # + aa_log "Reset the first revision as live" + set p_revision_id $revision1_id + aa_call_component db-news-revision-set-active + + # + # Check the second revision is still the latest, but the first one is live. + # + set p_item_id $item_id + aa_call_component db-news-get-live-revision + aa_call_component db-news-get-latest-revision + aa_equals "Confirm that the second revision of the article is still the latest" \ + $latest_revision_id $revision2_id + aa_equals "Confirm that the first revision of the article is now live" \ + $live_revision_id $revision1_id + + # + # Delete the second revision + # + aa_log "Delete the second revision" + set p_revision_id $revision2_id + aa_call_component db-news-revision-delete + + # + # Retrieve the row from cr_revisions table to get item_id + # + set p_revision_id $revision2_id + aa_call_component db-get-cr-revisions-row + aa_false "Check the revision row was deleted" $retrieval_ok_p + } + } } - } } { - # - # Delete the item. - # - if {$item_id != -1} { - aa_log "Deleting item." - set p_item_id $item_id - aa_call_component db-news-item-delete - } + # + # Delete the item. + # + if {$item_id != -1} { + aa_log "Deleting item." + set p_item_id $item_id + aa_call_component db-news-item-delete + } } ################################################################################ # # Testcase check-news-archive # aa_register_case -cats { - db + db } -init_classes { - mount-news-package + mount-news-package } "db-check-news-archive" { - Checks the news database functions make_permanent and news_archive. + Checks the news database functions make_permanent and news_archive. } { - set news_id -1 + set news_id -1 - if {!$_news_package_mounted_p} { - aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" - } else { - # - # Attempt to create the article - # - set p_title "My title" - set p_text "My text" - set p_package_id $_news_package_id - set p_is_live "t" - set p_full_details "t" - aa_call_component db-news-globals - aa_call_component db-news-item-create - } + if {!$_news_package_mounted_p} { + aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" + } else { + # + # Attempt to create the article + # + set p_title "My title" + set p_text "My text" + set p_package_id $_news_package_id + set p_is_live "t" + set p_full_details "t" + aa_call_component db-news-globals + aa_call_component db-news-item-create + } } { - aa_true "Check the news_id is populated" {$news_id != -1} - set item_id -1 - if {$news_id != -1} { - aa_log "News id: $news_id" - # - # Retrieve the row from cr_revisions table to get item_id - # - set p_revision_id $news_id - aa_call_component db-get-cr-revisions-row + aa_true "Check the news_id is populated" {$news_id != -1} + set item_id -1 + if {$news_id != -1} { + aa_log "News id: $news_id" + # + # Retrieve the row from cr_revisions table to get item_id + # + set p_revision_id $news_id + aa_call_component db-get-cr-revisions-row - # - # Call make_permanent to nullify the archive_date. - # - set p_item_id $item_id - aa_call_component db-news-make-permanent + # + # Call make_permanent to nullify the archive_date. + # + set p_item_id $item_id + aa_call_component db-news-make-permanent - # - # Retrieve the news row to check its archive date. - # - set p_news_id $news_id - aa_call_component db-get-cr-news-row - aa_equals "Check the archive_date is null" $archive_date [db_null] + # + # Retrieve the news row to check its archive date. + # + set p_news_id $news_id + aa_call_component db-get-cr-news-row + aa_equals "Check the archive_date is null" $archive_date [db_null] - # - # Set the archive period, providing an explicit archive date. - # - set p_item_id $item_id - set p_archive_date "2005-11-05" - aa_call_component db-news-archive + # + # Set the archive period, providing an explicit archive date. + # + set p_item_id $item_id + set p_archive_date "2005-11-05" + aa_call_component db-news-archive - # - # Retrieve the news row to check its archive date. - # - set p_news_id $news_id - aa_call_component db-get-cr-news-row - aa_equals "Check the explicitly set archive_date is $p_archive_date" \ - [string range $archive_date 0 [expr [string length $p_archive_date] - 1]] \ - $p_archive_date + # + # Retrieve the news row to check its archive date. + # + set p_news_id $news_id + aa_call_component db-get-cr-news-row + aa_equals "Check the explicitly set archive_date is $p_archive_date" \ + [string range $archive_date 0 [expr [string length $p_archive_date] - 1]] \ + $p_archive_date - # - # Set the archive period, relying on the overloaded "default" function for - # archive_date. - # - set p_item_id $item_id - set p_archive_date "" - aa_call_component db-news-archive + # + # Set the archive period, relying on the overloaded "default" function for + # archive_date. + # + set p_item_id $item_id + set p_archive_date "" + aa_call_component db-news-archive + # + # Retrieve the news row to check its archive date. + # + # Note, this could potentially fail if for some reason it executes over + # midnight...... + # + set p_news_id $news_id + aa_call_component db-get-cr-news-row + aa_true "Check the cr_news row was found" $retrieval_ok_p + set todays_date [clock format [clock seconds] -format "%Y-%m-%d"] + aa_equals "Check the explicitly set archive_date is $todays_date" \ + [string range $archive_date 0 [expr [string length $todays_date] - 1]] \ + $todays_date + } +} { # - # Retrieve the news row to check its archive date. + # Delete the item. # - # Note, this could potentially fail if for some reason it executes over - # midnight...... - # - set p_news_id $news_id - aa_call_component db-get-cr-news-row - aa_true "Check the cr_news row was found" $retrieval_ok_p - set todays_date [clock format [clock seconds] -format "%Y-%m-%d"] - aa_equals "Check the explicitly set archive_date is $todays_date" \ - [string range $archive_date 0 [expr [string length $todays_date] - 1]] \ - $todays_date - } -} { - # - # Delete the item. - # - if {$item_id != -1} { - aa_log "Deleting the item." - set p_item_id $item_id - aa_call_component db-news-item-delete - } + if {$item_id != -1} { + aa_log "Deleting the item." + set p_item_id $item_id + aa_call_component db-news-item-delete + } } @@ -1116,152 +1116,152 @@ # Testcase check-news-set-approve # aa_register_case -cats { - db + db } -init_classes { - mount-news-package + mount-news-package } "db-check-news-set-approve" { - Checks the news database function for approving/unapproving news articles. - Tests news.set_approve function. + Checks the news database function for approving/unapproving news articles. + Tests news.set_approve function. } { - set news_id -1 + set news_id -1 - if {!$_news_package_mounted_p} { - aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" - } else { - # - # Create the article - # - set p_title "My title" - set p_text "My text" - set p_package_id $_news_package_id - set p_is_live "t" - set p_full_details "t" - aa_call_component db-news-globals - aa_call_component db-news-item-create - } + if {!$_news_package_mounted_p} { + aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" + } else { + # + # Create the article + # + set p_title "My title" + set p_text "My text" + set p_package_id $_news_package_id + set p_is_live "t" + set p_full_details "t" + aa_call_component db-news-globals + aa_call_component db-news-item-create + } } { - aa_true "Check the news_id is populated" {$news_id != -1} - set item_id -1 - set revision1_id -1 - set revision2_id -1 - if {$news_id != -1} { - # - # Retrieve the row from cr_revisions table to get item_id - # - set p_revision_id $news_id - aa_call_component db-get-cr-revisions-row - set revision1_id $news_id + aa_true "Check the news_id is populated" {$news_id != -1} + set item_id -1 + set revision1_id -1 + set revision2_id -1 + if {$news_id != -1} { + # + # Retrieve the row from cr_revisions table to get item_id + # + set p_revision_id $news_id + aa_call_component db-get-cr-revisions-row + set revision1_id $news_id - # - # Create a new revision of the news article. - # - set p_item_id $item_id - set p_title "My title 2" - set p_text "My text 2" - set p_description "Description 2" - set p_package_id $_news_package_id - set p_full_details "t" - set p_make_active_revision_p "t" - aa_call_component db-news-revision-create - set revision2_id $revision_id + # + # Create a new revision of the news article. + # + set p_item_id $item_id + set p_title "My title 2" + set p_text "My text 2" + set p_description "Description 2" + set p_package_id $_news_package_id + set p_full_details "t" + set p_make_active_revision_p "t" + aa_call_component db-news-revision-create + set revision2_id $revision_id - # - # Unapprove revision2. - # - set p_revision_id $revision2_id - set p_approve_p "f" - aa_call_component db-news-set-approve + # + # Unapprove revision2. + # + set p_revision_id $revision2_id + set p_approve_p "f" + aa_call_component db-news-set-approve - # - # Retrieve the cr_news column for revision 2 - # - set p_news_id $revision2_id - aa_call_component db-get-cr-news-row - if {!$retrieval_ok_p} { - aa_error "cr_news row not found for new revision news_id $revision2_id" - } else { - aa_equals "Check the archive_date is null" $archive_date [db_null] - aa_equals "Check the approval_date is null" $approval_date [db_null] - aa_equals "Check the aprroval_user is null" $approval_user [db_null] - aa_equals "Check the approval_ip is null" $approval_ip [db_null] - } + # + # Retrieve the cr_news column for revision 2 + # + set p_news_id $revision2_id + aa_call_component db-get-cr-news-row + if {!$retrieval_ok_p} { + aa_error "cr_news row not found for new revision news_id $revision2_id" + } else { + aa_equals "Check the archive_date is null" $archive_date [db_null] + aa_equals "Check the approval_date is null" $approval_date [db_null] + aa_equals "Check the aprroval_user is null" $approval_user [db_null] + aa_equals "Check the approval_ip is null" $approval_ip [db_null] + } - # - # Retrieve the row from cr_revisions table to check publish date. - # - set p_revision_id $revision2_id - aa_call_component db-get-cr-revisions-row - if {!$retrieval_ok_p} { - aa_error "cr_revisions row not found for new revision revision_id $revision2_id" - } else { - aa_equals "Check revision 2 publish_date is null" $publish_date [db_null] - } + # + # Retrieve the row from cr_revisions table to check publish date. + # + set p_revision_id $revision2_id + aa_call_component db-get-cr-revisions-row + if {!$retrieval_ok_p} { + aa_error "cr_revisions row not found for new revision revision_id $revision2_id" + } else { + aa_equals "Check revision 2 publish_date is null" $publish_date [db_null] + } - # - # Approve revision 1 and set it as the live revision. - # - set p_revision_id $revision1_id - set p_approve_p "t" - set p_publish_date "2001-11-01" - set p_archive_date "2001-11-02" - set p_approval_user [ad_conn "user_id"] - set p_approval_date "2001-11-03" - set p_approval_ip [ad_conn "peeraddr"] - set p_live_revision_p "t" - aa_call_component db-news-set-approve + # + # Approve revision 1 and set it as the live revision. + # + set p_revision_id $revision1_id + set p_approve_p "t" + set p_publish_date "2001-11-01" + set p_archive_date "2001-11-02" + set p_approval_user [ad_conn "user_id"] + set p_approval_date "2001-11-03" + set p_approval_ip [ad_conn "peeraddr"] + set p_live_revision_p "t" + aa_call_component db-news-set-approve - # - # Check the second revision is now live. - # - set p_item_id $item_id - aa_call_component db-news-get-live-revision - aa_equals "Confirm that revision 1 of the article is now live" \ - $live_revision_id $revision1_id + # + # Check the second revision is now live. + # + set p_item_id $item_id + aa_call_component db-news-get-live-revision + aa_equals "Confirm that revision 1 of the article is now live" \ + $live_revision_id $revision1_id - # - # Retrieve the cr_news column for revision 1 - # - set p_news_id $revision1_id - aa_call_component db-get-cr-news-row - if {!$retrieval_ok_p} { - aa_error "cr_news row not found for new revision news_id $revision1_id" - } else { - aa_equals "Check the archive_date is correct" \ - [string range $archive_date 0 [expr [string length $p_archive_date]-1]] \ - $p_archive_date - aa_equals "Check the approval_date is correct" \ - [string range $approval_date 0 [expr [string length $p_approval_date]-1]] \ - $p_approval_date - aa_equals "Check the aprroval_user is correct" \ - [string range $approval_user 0 [expr [string length $p_approval_user]-1]] \ - $p_approval_user - aa_equals "Check the approval_ip is correct" \ - [string range $approval_ip 0 [expr [string length $p_approval_ip]-1]] \ - $p_approval_ip - } + # + # Retrieve the cr_news column for revision 1 + # + set p_news_id $revision1_id + aa_call_component db-get-cr-news-row + if {!$retrieval_ok_p} { + aa_error "cr_news row not found for new revision news_id $revision1_id" + } else { + aa_equals "Check the archive_date is correct" \ + [string range $archive_date 0 [expr [string length $p_archive_date]-1]] \ + $p_archive_date + aa_equals "Check the approval_date is correct" \ + [string range $approval_date 0 [expr [string length $p_approval_date]-1]] \ + $p_approval_date + aa_equals "Check the aprroval_user is correct" \ + [string range $approval_user 0 [expr [string length $p_approval_user]-1]] \ + $p_approval_user + aa_equals "Check the approval_ip is correct" \ + [string range $approval_ip 0 [expr [string length $p_approval_ip]-1]] \ + $p_approval_ip + } + # + # Retrieve the row from cr_revisions table to check publish date. + # + set p_revision_id $revision1_id + aa_call_component db-get-cr-revisions-row + if {!$retrieval_ok_p} { + aa_error "cr_revisions row not found for new revision revision_id $revision1_id" + } else { + aa_equals "Check revision 1 publish_date is null" \ + [string range $publish_date 0 [expr [string length $p_publish_date]-1]] \ + $p_publish_date + } + } +} { # - # Retrieve the row from cr_revisions table to check publish date. + # Delete the item. # - set p_revision_id $revision1_id - aa_call_component db-get-cr-revisions-row - if {!$retrieval_ok_p} { - aa_error "cr_revisions row not found for new revision revision_id $revision1_id" - } else { - aa_equals "Check revision 1 publish_date is null" \ - [string range $publish_date 0 [expr [string length $p_publish_date]-1]] \ - $p_publish_date + if {$item_id != -1} { + aa_log "Deleting item." + set p_item_id $item_id + aa_call_component db-news-item-delete } - } -} { - # - # Delete the item. - # - if {$item_id != -1} { - aa_log "Deleting item." - set p_item_id $item_id - aa_call_component db-news-item-delete - } } @@ -1270,176 +1270,176 @@ # Testcase check-news-status # aa_register_case -cats { - db + db } -init_classes { - mount-news-package + mount-news-package } "db-check-news-status" { - Checks the news database function that returns information about a news article publish - and archive status. - Tests news.status function. + Checks the news database function that returns information about a news article publish + and archive status. + Tests news.status function. } { - set news_id -1 + set news_id -1 - if {!$_news_package_mounted_p} { - aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" - } else { - # - # Create the article - # - set p_title "My title" - set p_text "My text" - set p_package_id $_news_package_id - set p_is_live "t" - set p_full_details "t" - aa_call_component db-news-globals - aa_call_component db-news-item-create - } + if {!$_news_package_mounted_p} { + aa_error "News package not mounted, error from initialiser: $_news_package_mounted_err" + } else { + # + # Create the article + # + set p_title "My title" + set p_text "My text" + set p_package_id $_news_package_id + set p_is_live "t" + set p_full_details "t" + aa_call_component db-news-globals + aa_call_component db-news-item-create + } } { - aa_true "Check the news_id is populated" {$news_id != -1} - set item_id -1 - set revision1_id -1 - set revision2_id -1 - if {$news_id != -1} { - # - # Retrieve the row from cr_revisions table to get item_id - # - set p_revision_id $news_id - aa_call_component db-get-cr-revisions-row - set revision1_id $news_id + aa_true "Check the news_id is populated" {$news_id != -1} + set item_id -1 + set revision1_id -1 + set revision2_id -1 + if {$news_id != -1} { + # + # Retrieve the row from cr_revisions table to get item_id + # + set p_revision_id $news_id + aa_call_component db-get-cr-revisions-row + set revision1_id $news_id - # - # Unapprove revision 1 and set it as the live revision. - # - aa_log "Unapproving revision 1, setting publish_date null, archive_date null" - set p_revision_id $revision1_id - set p_approve_p "t" - set p_publish_date [db_null] - set p_archive_date [db_null] - set p_approval_user [ad_conn "user_id"] - set p_approval_date [db_null] - set p_approval_ip [ad_conn "peeraddr"] - set p_live_revision_p "t" - aa_call_component db-news-set-approve + # + # Unapprove revision 1 and set it as the live revision. + # + aa_log "Unapproving revision 1, setting publish_date null, archive_date null" + set p_revision_id $revision1_id + set p_approve_p "t" + set p_publish_date [db_null] + set p_archive_date [db_null] + set p_approval_user [ad_conn "user_id"] + set p_approval_date [db_null] + set p_approval_ip [ad_conn "peeraddr"] + set p_live_revision_p "t" + aa_call_component db-news-set-approve - # - # Check the status of revision 1. - # - set p_news_id $revision1_id - aa_call_component db-news-status - aa_equals "Unapproved status" $status unapproved + # + # Check the status of revision 1. + # + set p_news_id $revision1_id + aa_call_component db-news-status + aa_equals "Unapproved status" $status unapproved - # - # Approve revision 1 and set it as the live revision. - # - aa_log "Approving revision 1, setting archive date as null" - set p_revision_id $revision1_id - set p_approve_p "t" - set p_publish_date "2005-11-01" - set p_archive_date [db_null] - set p_approval_user [ad_conn "user_id"] - set p_approval_date "2001-11-03" - set p_approval_ip [ad_conn "peeraddr"] - set p_live_revision_p "t" - aa_call_component db-news-set-approve + # + # Approve revision 1 and set it as the live revision. + # + aa_log "Approving revision 1, setting archive date as null" + set p_revision_id $revision1_id + set p_approve_p "t" + set p_publish_date "2005-11-01" + set p_archive_date [db_null] + set p_approval_user [ad_conn "user_id"] + set p_approval_date "2001-11-03" + set p_approval_ip [ad_conn "peeraddr"] + set p_live_revision_p "t" + aa_call_component db-news-set-approve - # - # Check the status of revision 1. - # - set p_news_id $revision1_id - aa_call_component db-news-status - aa_equals "Going live no archive status" $status going_live_no_archive + # + # Check the status of revision 1. + # + set p_news_id $revision1_id + aa_call_component db-news-status + aa_equals "Going live no archive status" $status going_live_no_archive - # - # Approve revision 1 and set it as the live revision. - # - aa_log "Approving revision 1, setting archive date as future value" - set p_revision_id $revision1_id - set p_approve_p "t" - set p_publish_date "2005-11-01" - set p_archive_date "2005-11-10" - set p_approval_user [ad_conn "user_id"] - set p_approval_date "2001-11-03" - set p_approval_ip [ad_conn "peeraddr"] - set p_live_revision_p "t" - aa_call_component db-news-set-approve + # + # Approve revision 1 and set it as the live revision. + # + aa_log "Approving revision 1, setting archive date as future value" + set p_revision_id $revision1_id + set p_approve_p "t" + set p_publish_date "2005-11-01" + set p_archive_date "2005-11-10" + set p_approval_user [ad_conn "user_id"] + set p_approval_date "2001-11-03" + set p_approval_ip [ad_conn "peeraddr"] + set p_live_revision_p "t" + aa_call_component db-news-set-approve - # - # Check the status of revision 1. - # - set p_news_id $revision1_id - aa_call_component db-news-status - aa_equals "Going live scheduled for archive status" $status going_live_with_archive + # + # Check the status of revision 1. + # + set p_news_id $revision1_id + aa_call_component db-news-status + aa_equals "Going live scheduled for archive status" $status going_live_with_archive - # - # Approve revision 1 and set it as the live revision. - # - aa_log "Approving revision 1, setting publish date in past, archive date null" - set p_revision_id $revision1_id - set p_approve_p "t" - set p_publish_date "2000-11-01" - set p_archive_date [db_null] - set p_approval_user [ad_conn "user_id"] - set p_approval_date "2001-11-03" - set p_approval_ip [ad_conn "peeraddr"] - set p_live_revision_p "t" - aa_call_component db-news-set-approve + # + # Approve revision 1 and set it as the live revision. + # + aa_log "Approving revision 1, setting publish date in past, archive date null" + set p_revision_id $revision1_id + set p_approve_p "t" + set p_publish_date "2000-11-01" + set p_archive_date [db_null] + set p_approval_user [ad_conn "user_id"] + set p_approval_date "2001-11-03" + set p_approval_ip [ad_conn "peeraddr"] + set p_live_revision_p "t" + aa_call_component db-news-set-approve - # - # Check the status of revision 1. - # - set p_news_id $revision1_id - aa_call_component db-news-status - aa_equals "Published no archive status" $status published_no_archive + # + # Check the status of revision 1. + # + set p_news_id $revision1_id + aa_call_component db-news-status + aa_equals "Published no archive status" $status published_no_archive - # - # Approve revision 1 and set it as the live revision. - # - aa_log "Approving revision 1, setting publish date in past, archive date in past" - set p_revision_id $revision1_id - set p_approve_p "t" - set p_publish_date "2000-11-01" - set p_archive_date "2000-11-01" - set p_approval_user [ad_conn "user_id"] - set p_approval_date "2001-11-03" - set p_approval_ip [ad_conn "peeraddr"] - set p_live_revision_p "t" - aa_call_component db-news-set-approve + # + # Approve revision 1 and set it as the live revision. + # + aa_log "Approving revision 1, setting publish date in past, archive date in past" + set p_revision_id $revision1_id + set p_approve_p "t" + set p_publish_date "2000-11-01" + set p_archive_date "2000-11-01" + set p_approval_user [ad_conn "user_id"] + set p_approval_date "2001-11-03" + set p_approval_ip [ad_conn "peeraddr"] + set p_live_revision_p "t" + aa_call_component db-news-set-approve - # - # Check the status of revision 1. - # - set p_news_id $revision1_id - aa_call_component db-news-status - aa_equals "Archived status" $status archived + # + # Check the status of revision 1. + # + set p_news_id $revision1_id + aa_call_component db-news-status + aa_equals "Archived status" $status archived - # - # Approve revision 1 and set it as the live revision. - # - aa_log "Approving revision 1, setting publish date in past, archive date in future" - set p_revision_id $revision1_id - set p_approve_p "t" - set p_publish_date "2000-11-01" - set p_archive_date "2005-11-01" - set p_approval_user [ad_conn "user_id"] - set p_approval_date "2001-11-03" - set p_approval_ip [ad_conn "peeraddr"] - set p_live_revision_p "t" - aa_call_component db-news-set-approve + # + # Approve revision 1 and set it as the live revision. + # + aa_log "Approving revision 1, setting publish date in past, archive date in future" + set p_revision_id $revision1_id + set p_approve_p "t" + set p_publish_date "2000-11-01" + set p_archive_date "2005-11-01" + set p_approval_user [ad_conn "user_id"] + set p_approval_date "2001-11-03" + set p_approval_ip [ad_conn "peeraddr"] + set p_live_revision_p "t" + aa_call_component db-news-set-approve + # + # Check the status of revision 1. + # + set p_news_id $revision1_id + aa_call_component db-news-status + aa_equals "Published with archive" $status published_with_archive + } +} { # - # Check the status of revision 1. + # Delete the item. # - set p_news_id $revision1_id - aa_call_component db-news-status - aa_equals "Published with archive" $status published_with_archive - } -} { - # - # Delete the item. - # - if {$item_id != -1} { - aa_log "Deleting item." - set p_item_id $item_id - aa_call_component db-news-item-delete - } + if {$item_id != -1} { + aa_log "Deleting item." + set p_item_id $item_id + aa_call_component db-news-item-delete + } }