Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.189.2.150 -r1.189.2.151 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 28 Sep 2022 08:20:27 -0000 1.189.2.150 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 11 Oct 2022 09:04:57 -0000 1.189.2.151 @@ -1768,7 +1768,7 @@ if { !$html_p } { set message [ns_quotehtml $message] } - lappend messages $message + dict incr messages $message } ad_set_client_property "acs-kernel" "general_messages" $messages } @@ -1800,7 +1800,10 @@ ad_set_client_property "acs-kernel" "general_messages" {} } template::multirow create $multirow message - foreach message $messages { + foreach {message count} $messages { + if {$count > 1} { + append message " ($count)" + } template::multirow append $multirow $message } } Index: openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl,v diff -u -r1.1.2.11 -r1.1.2.12 --- openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 18 Feb 2022 12:37:53 -0000 1.1.2.11 +++ openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 11 Oct 2022 09:04:58 -0000 1.1.2.12 @@ -350,6 +350,88 @@ } } +aa_register_case -cats { + api + smoke +} -procs { + util_user_message + util_get_user_messages + template::multirow +} util_user_messages { + Test api to provide user messages +} { + aa_section "Replacing existing messages" + + util_user_message -message ciao + util_user_message -message ciao + util_user_message -message ciao + util_user_message -message miao + util_user_message -message ciao + + util_user_message -replace -message test + + util_get_user_messages -multirow test_util_get_user_messages + + aa_equals "We have only one message" \ + [template::multirow size test_util_get_user_messages] 1 + aa_equals "Message is the last one" \ + [template::multirow get test_util_get_user_messages 1 message] test + + + aa_section "Quoting HTML in messages" + + util_user_message -html -message
ciao
+ util_user_message -message
ciao
+ + util_get_user_messages -multirow test_util_get_user_messages + + aa_equals "We have only one message" \ + [template::multirow size test_util_get_user_messages] 2 + aa_equals "First message was NOT quoted" \ + [template::multirow get test_util_get_user_messages 1 message]
ciao
+ aa_equals "Second message was quoted" \ + [template::multirow get test_util_get_user_messages 2 message] [ns_quotehtml
ciao
] + + + aa_section "Repeating messages" + + util_user_message -message ciao + util_user_message -message ciao + util_user_message -message ciao + util_user_message -message miao + util_user_message -message ciao + + util_get_user_messages -multirow test_util_get_user_messages + + aa_equals "We have 2 messages" \ + [template::multirow size test_util_get_user_messages] 2 + aa_equals "Repeated message includes a counter" \ + [template::multirow get test_util_get_user_messages 1 message] "ciao (4)" + aa_equals "Single message is unchanged" \ + [template::multirow get test_util_get_user_messages 2 message] miao + + + aa_section "Keeping messages" + + util_user_message -message ciao + util_user_message -message ciao + util_user_message -message ciao + util_user_message -message miao + util_user_message -message ciao + + util_get_user_messages -keep -multirow test_util_get_user_messages + + aa_equals "We have 2 messages" \ + [template::multirow size test_util_get_user_messages] 2 + + aa_log "Creating multirow" + util_get_user_messages -multirow test_util_get_user_messages + + aa_equals "We have 2 messages again" \ + [template::multirow size test_util_get_user_messages] 2 +} + + # Local variables: # mode: tcl # tcl-indent-level: 4