From e6e877ed9da812b0ac569d9db0eb472e55682295 Mon Sep 17 00:00:00 2001 From: Gustaf Neumann Date: Sun, 29 Sep 2013 13:40:40 +0000 Subject: [PATCH] - use "lassign" instead of "util_unlist" - replace deprecated "ad_get_user_id" by "ad_conn user_id" - replace deprecated "ad_require_permission" by "permission::require_permission" - replace deprecated "ad_permission_p" by "permission::permission_p" - use "lassign" instead of "foreach ... break" idiom --- lib/assessment.tcl | 2 +- lib/item-show-mc.tcl | 2 +- tcl/as-assessment-procs.tcl | 2 +- tcl/as-item-form-procs.tcl | 2 +- tcl/as-item-procs.tcl | 2 +- tcl/as-item-type-mc-procs.tcl | 4 ++-- tcl/as-item-type-swcat-procs.tcl | 2 +- www/asm-admin/index.tcl | 2 +- www/asm-admin/item-add-mc-choices.tcl | 4 ++-- www/asm-admin/item-add.tcl | 2 +- www/asm-admin/item-create-2.tcl | 4 ++-- www/asm-admin/item-create.tcl | 4 ++-- www/asm-admin/item-edit-general.tcl | 2 +- www/asm-admin/item-edit-mc-choices.tcl | 6 +++--- www/asm-admin/item-edit-mc.tcl | 2 +- www/asm-admin/results-export.tcl | 2 +- www/asm-admin/section-preview.tcl | 2 +- www/index.tcl | 2 +- www/last-session.tcl | 2 +- www/sessions.tcl | 2 +- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/assessment.tcl b/lib/assessment.tcl index 1118e248..e1f730f5 100644 --- a/lib/assessment.tcl +++ b/lib/assessment.tcl @@ -342,7 +342,7 @@ set validate_list [list] set required_count 0 foreach one_item $item_list { - util_unlist $one_item as_item_id name title description subtext required_p max_time_to_complete content_rev_id content_filename content_type as_item_type_id validate_block question_text + lassign $one_item as_item_id name title description subtext required_p max_time_to_complete content_rev_id content_filename content_type as_item_type_id validate_block question_text foreach {check_expr check_message} [split $validate_block \n] { regsub -all {%answer%} $check_expr \$response_to_item($as_item_id) check_expr diff --git a/lib/item-show-mc.tcl b/lib/item-show-mc.tcl index 8d78c58e..51bf0744 100644 --- a/lib/item-show-mc.tcl +++ b/lib/item-show-mc.tcl @@ -20,7 +20,7 @@ set count 0 set choices [db_list_of_lists get_choices {}] set total [llength $choices] foreach one_choice $choices { - util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score sort_order fixed_position answer_value content_rev_id content_filename content_name + lassign $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score sort_order fixed_position answer_value content_rev_id content_filename content_name set title [ad_quotehtml $title] set feedback_text [ad_quotehtml $feedback_text] incr count diff --git a/tcl/as-assessment-procs.tcl b/tcl/as-assessment-procs.tcl index 7c021fef..2e028ec4 100644 --- a/tcl/as-assessment-procs.tcl +++ b/tcl/as-assessment-procs.tcl @@ -367,7 +367,7 @@ ad_proc as::assessment::sections { set count 0 foreach one_section $all_sections { incr count - util_unlist $one_section section_id title + lassign $one_section section_id title lappend section_list $section_id db_dml save_order {} } diff --git a/tcl/as-item-form-procs.tcl b/tcl/as-item-form-procs.tcl index edb366ea..80ece9a9 100644 --- a/tcl/as-item-form-procs.tcl +++ b/tcl/as-item-form-procs.tcl @@ -31,7 +31,7 @@ ad_proc -public as::item_form::add_item_to_form { set item_data [as::item_type_$item(item_type)\::render -type_id $item(item_type_id) -session_id $session_id -section_id $section_id -as_item_id $item_id -default_value $default_value -show_feedback $show_feedback] } - util_unlist $item_data default_value data + lassign $item_data default_value data if {$item(item_type) eq "mc"} { set item(allow_other_p) [as::item_type_mc::allow_other_p -item_type_id $item(item_type_id)] diff --git a/tcl/as-item-procs.tcl b/tcl/as-item-procs.tcl index ea47a0ff..6eea8265 100644 --- a/tcl/as-item-procs.tcl +++ b/tcl/as-item-procs.tcl @@ -202,7 +202,7 @@ ad_proc -public as::item::copy { set subtypes [db_list_of_lists item_subtypes {}] foreach subtype $subtypes { - util_unlist $subtype type_id type + lassign $subtype type_id type set new_type_id [eval as::[string range $type 3 end]::copy -type_id $type_id] as::item_rels::new -item_rev_id $new_item_id -target_rev_id $new_type_id -type "[string range $type 0 end-2]rel" } diff --git a/tcl/as-item-type-mc-procs.tcl b/tcl/as-item-type-mc-procs.tcl index aa19a502..0b0575fa 100644 --- a/tcl/as-item-type-mc-procs.tcl +++ b/tcl/as-item-type-mc-procs.tcl @@ -310,7 +310,7 @@ ad_proc -public as::item_type_mc::render { if {![empty_string_p $session_id]} { set count 0 foreach one_choice $display_choices { - util_unlist $one_choice title choice_id + lassign $one_choice title choice_id incr count db_dml save_order {} } @@ -617,7 +617,7 @@ ad_proc -private as::item_type_mc::add_existing_choices_to_edit_form { set correct_options [list [list "[_ assessment.yes]" t]] set i 0 foreach c $existing_choices { - foreach {value id correct_p} $c {break} + lassign $c value id correct_p if {![string match "__new*" $id]} { if {$i > 0} { ad_form -extend -name $form_id -form \ diff --git a/tcl/as-item-type-swcat-procs.tcl b/tcl/as-item-type-swcat-procs.tcl index ff5981fa..2f1044ca 100644 --- a/tcl/as-item-type-swcat-procs.tcl +++ b/tcl/as-item-type-swcat-procs.tcl @@ -104,7 +104,7 @@ ad_proc -public as::item_type_swcat::render { set tree_id [db_string get_tree_id "" -default ""] set categories [category_tree::get_tree -all $tree_id] foreach cat $categories { - foreach {category_id category_name deprecated_p level} $cat {break} + lassign $cat category_id category_name deprecated_p level lappend display_choices [list $category_name $category_id] } return [list $default $display_choices] diff --git a/www/asm-admin/index.tcl b/www/asm-admin/index.tcl index 1be35fcd..0b6e8039 100755 --- a/www/asm-admin/index.tcl +++ b/www/asm-admin/index.tcl @@ -43,7 +43,7 @@ if { $sw_admin_p && $advanced_options_p } { lappend actions [_ assessment.set_reg_asm] "../admin/set-reg-assessment" [_ assessment.set_reg_asm] } -if {[ad_permission_p [acs_magic_object "security_context_root"] "admin"]} { +if {[permission::permission_p -object_id [acs_magic_object "security_context_root"] -privilege "admin"]} { # lappend actions "[_ assessment.Admin_catalog]" "catalog/" "[_ assessment.Admin_catalog]" } diff --git a/www/asm-admin/item-add-mc-choices.tcl b/www/asm-admin/item-add-mc-choices.tcl index 2919b3b1..1a090114 100755 --- a/www/asm-admin/item-add-mc-choices.tcl +++ b/www/asm-admin/item-add-mc-choices.tcl @@ -52,7 +52,7 @@ set count_correct 0 if { $type == 1} { set max_file_size 10000000 - # [ad_parameter MaxAttachmentSize] + # [parameter::get -parameter MaxAttachmentSize] set pretty_max_size [util_commify_number $max_file_size] set folder_id [as::assessment::folder_id -package_id $package_id] @@ -128,7 +128,7 @@ eval ad_form -extend -name item_add_mc_choices $ad_form_code ad_form -extend -name item_add_mc_choices -edit_request { } -edit_data { set max_file_size 10000000 - # [ad_parameter MaxAttachmentSize] + # [parameter::get -parameter MaxAttachmentSize] set pretty_max_size [util_commify_number $max_file_size] set folder_id [as::assessment::folder_id -package_id $package_id] diff --git a/www/asm-admin/item-add.tcl b/www/asm-admin/item-add.tcl index 9f429495..bd699461 100644 --- a/www/asm-admin/item-add.tcl +++ b/www/asm-admin/item-add.tcl @@ -261,7 +261,7 @@ ad_form -extend -name item-add -new_request { set file_mimetype [lindex $content 2] set n_bytes [file size $tmp_filename] set max_file_size 10000000 - # [ad_parameter MaxAttachmentSize] + # [parameter::get -parameter MaxAttachmentSize] set pretty_max_size [util_commify_number $max_file_size] if { $n_bytes > $max_file_size && $max_file_size > 0 } { diff --git a/www/asm-admin/item-create-2.tcl b/www/asm-admin/item-create-2.tcl index e0edc42f..a61c1e14 100755 --- a/www/asm-admin/item-create-2.tcl +++ b/www/asm-admin/item-create-2.tcl @@ -17,8 +17,8 @@ ad_page_contract { set context [list "Create a new Item"] set package_id [ad_conn package_id] -set user_id [ad_get_user_id] -ad_require_permission $package_id admin +set user_id [ad_conn user_id] +permission::require_permission -object_id $package_id -privilege admin set item_title [db_string item_title {SELECT as_itemsx.title FROM as_itemsx WHERE as_itemsx.as_item_id=:as_item_id1}] diff --git a/www/asm-admin/item-create.tcl b/www/asm-admin/item-create.tcl index 45c5c006..56973408 100755 --- a/www/asm-admin/item-create.tcl +++ b/www/asm-admin/item-create.tcl @@ -14,8 +14,8 @@ ad_page_contract { set context [list "Create a new Item"] set package_id [ad_conn package_id] -set user_id [ad_get_user_id] -ad_require_permission $package_id admin +set user_id [ad_conn user_id] +permission::require_permission -object_id $package_id -privilege admin diff --git a/www/asm-admin/item-edit-general.tcl b/www/asm-admin/item-edit-general.tcl index 047ef463..24789b71 100644 --- a/www/asm-admin/item-edit-general.tcl +++ b/www/asm-admin/item-edit-general.tcl @@ -289,7 +289,7 @@ ad_form -extend -name item_edit_general -edit_request { set file_mimetype [lindex $content 2] set n_bytes [file size $tmp_filename] set max_file_size 10000000 - # [ad_parameter MaxAttachmentSize] + # [parameter::get -parameter MaxAttachmentSize] set pretty_max_size [util_commify_number $max_file_size] if { $n_bytes > $max_file_size && $max_file_size > 0 } { diff --git a/www/asm-admin/item-edit-mc-choices.tcl b/www/asm-admin/item-edit-mc-choices.tcl index 545e63d8..2a6a6984 100644 --- a/www/asm-admin/item-edit-mc-choices.tcl +++ b/www/asm-admin/item-edit-mc-choices.tcl @@ -46,7 +46,7 @@ set ad_form_code "-form \{\n" set count_correct 0 set choices [db_list_of_lists get_choices {}] foreach one_choice $choices { - util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score fixed_position answer_value content_rev_id content_filename content_name + lassign $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score fixed_position answer_value content_rev_id content_filename content_name if {$correct_answer_p == "t"} { append ad_form_code "\{infotxt.$choice_id:text(inform) \{label \"[_ assessment.Choice] $title\"\} \{value \"\"\}\}\n" } else { @@ -84,7 +84,7 @@ eval ad_form -extend -name item_edit_mc_choices $ad_form_code ad_form -extend -name item_edit_mc_choices -edit_request { foreach one_choice $choices { - util_unlist $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score fixed_position answer_value + lassign $one_choice choice_id title correct_answer_p feedback_text selected_p percent_score fixed_position answer_value set feedback($choice_id) $feedback_text set percent($choice_id) $percent_score set fixed_pos($choice_id) $fixed_position @@ -96,7 +96,7 @@ ad_form -extend -name item_edit_mc_choices -edit_request { } -edit_data { db_transaction { set max_file_size 10000000 - # [ad_parameter MaxAttachmentSize] + # [parameter::get -parameter MaxAttachmentSize] set pretty_max_size [util_commify_number $max_file_size] set folder_id [as::assessment::folder_id -package_id $package_id] diff --git a/www/asm-admin/item-edit-mc.tcl b/www/asm-admin/item-edit-mc.tcl index 31fd00cd..7b2b8e67 100644 --- a/www/asm-admin/item-edit-mc.tcl +++ b/www/asm-admin/item-edit-mc.tcl @@ -70,7 +70,7 @@ set count 0 set validate_list [list] set count_correct [array exists correct] foreach one_choice $choices { - util_unlist $one_choice choice_title choice_id choice_correct_p + lassign $one_choice choice_title choice_id choice_correct_p incr count if {![info exists choice($choice_id)]} { set choice($choice_id) $choice_title diff --git a/www/asm-admin/results-export.tcl b/www/asm-admin/results-export.tcl index 82682427..41587752 100644 --- a/www/asm-admin/results-export.tcl +++ b/www/asm-admin/results-export.tcl @@ -80,7 +80,7 @@ ad_form -name assessment_export -action results-export -form { set section_list [db_list_of_lists all_sections {}] foreach one_section $section_list { - util_unlist $one_section section_id section_item_id + lassign $one_section section_id section_item_id set mc_item_list [list] db_foreach all_section_items {} { lappend item_list $section_id $as_item_id diff --git a/www/asm-admin/section-preview.tcl b/www/asm-admin/section-preview.tcl index 0298f499..94048d64 100644 --- a/www/asm-admin/section-preview.tcl +++ b/www/asm-admin/section-preview.tcl @@ -41,7 +41,7 @@ ad_form -name section_preview_form -action section-preview -html {enctype multip multirow create items as_item_id name title description subtext required_p max_time_to_complete presentation_type html content as_item_type_id choice_orientation next_title foreach one_item $item_list { - util_unlist $one_item as_item_id name title description subtext required_p max_time_to_complete content_rev_id content_filename content_type as_item_type_id + lassign $one_item as_item_id name title description subtext required_p max_time_to_complete content_rev_id content_filename content_type as_item_type_id set presentation_type [as::item_form::add_item_to_form -name section_preview_form -session_id "" -section_id $section_id -item_id $as_item_id -default_value "" -required_p $required_p] diff --git a/www/index.tcl b/www/index.tcl index 7bca5321..ee530968 100644 --- a/www/index.tcl +++ b/www/index.tcl @@ -67,6 +67,6 @@ db_multirow -extend { session } sessions answered_asssessments {} { set session [_ assessment.Sessions] } -set admin_p [ad_permission_p $package_id create] +set admin_p [permission::permission_p -object_id $package_id -privilege create] ad_return_template diff --git a/www/last-session.tcl b/www/last-session.tcl index 9faeda9d..3432f0b7 100644 --- a/www/last-session.tcl +++ b/www/last-session.tcl @@ -106,7 +106,7 @@ if {$assessment_data(survey_p) == "t"} { #if the user is admin he will display all sessions from all subjects -if {[ad_permission_p [acs_magic_object "security_context_root"] "admin"]} { +if {[permission::permission_p -object_id [acs_magic_object "security_context_root"] -privilege "admin"]} { set query "sessions_of_assessment_of_subject" } else { set query "sessions_of_assessment" diff --git a/www/sessions.tcl b/www/sessions.tcl index 2312f542..60391120 100644 --- a/www/sessions.tcl +++ b/www/sessions.tcl @@ -29,7 +29,7 @@ if {![info exists assessment_data(assessment_id)]} { } set assessment_rev_id $assessment_data(assessment_rev_id) -set admin_p [ad_permission_p $assessment_id admin] +set admin_p [permission::permission_p -object_id $assessment_id -privilege admin] #if the user is admin he will display all sessions from all subjects if {$admin_p && [empty_string_p $subject_id]} {