Index: openacs.org-dev/www/bboard-migr/subs-thread-migr.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs.org-dev/www/bboard-migr/subs-thread-migr.tcl,v diff -u -r1.1 -r1.2 --- openacs.org-dev/www/bboard-migr/subs-thread-migr.tcl 10 Jul 2002 19:29:04 -0000 1.1 +++ openacs.org-dev/www/bboard-migr/subs-thread-migr.tcl 30 Jul 2002 21:00:12 -0000 1.2 @@ -1,7 +1,11 @@ #hardcode if you're not in the correct package instance... +# which package are we using +#set bboard_package "bboard" +set bboard_package "forums" + #set package_id [ad_conn package_id] -set package_id 3189 +set package_id 3061 set olddb [ns_db gethandle acs32] @@ -26,61 +30,95 @@ #note: no migr_map neccessary for subscriptions # or even possible -- covered by user and topic map -set mapped_subs_sql " -select thread_id || '-' || subscriber_id as new_map_id - from bboard_thread_subscribers -where thread_id = :new_thread_id -and subscriber_id = :new_user_id" +if {[string equal $bboard_package "bboard"]} { -set map_subs_sql " -insert into bboard_thread_subscribers -(thread_id, subscriber_id) values -(:new_thread_id, :new_user_id)" + set mapped_subs_sql " + select thread_id || '-' || subscriber_id as new_map_id + from bboard_thread_subscribers + where thread_id = :new_thread_id + and subscriber_id = :new_user_id" + + set map_subs_sql " + insert into bboard_thread_subscribers + (thread_id, subscriber_id) values + (:new_thread_id, :new_user_id)" + set id_description "thread-user" + +} else { + # assume it's the new "forums" package + + set type_id [notification::type::get_type_id -short_name forums_message_notif] + set delivery_method_id [notification::get_delivery_method_id -name "email"] + set interval_id [notification::get_interval_id -name "instant"] + + set mapped_subs_sql " + select request_id as new_map_id + from notification_requests + where type_id = :type_id + and user_id = :new_user_id + and object_id = :new_thread_id +" + + set id_description "request_id" +} + set nil [set new [list]] set output "" -db_transaction { while { [ns_db getrow $olddb $selection] } { set_variables_after_query - #also lookup thread and user mapping - db_1row q $thread_mapping_sql - db_1row q $user_mapping_sql + db_transaction { + #also lookup thread and user mapping + db_1row q $thread_mapping_sql + db_1row q $user_mapping_sql - incr n_tried_old + incr n_tried_old - if [db_0or1row r $mapped_subs_sql] { - ##already mapped, sets new_map_id - set new_id $new_map_id - set action "nil" - } else { - #it's new; insert it. - db_dml q $map_subs_sql - set new_id "$new_thread_id-$new_user_id" - set action "new" - } + if [db_0or1row r $mapped_subs_sql] { + ##already mapped, sets new_map_id + set new_id $new_map_id + set action "nil" + } else { + #it's new; insert it. + if {[string equal $bboard_package "bboard"]} { + db_dml q $map_subs_sql + } else { + # assume it's the new "forums" package - set html " - thread-user: $new_id -
" + set request_id [notification::request::new -type_id $type_id \ + -user_id $new_user_id -object_id $new_thread_id \ + -interval_id $interval_id \ + -delivery_method_id $delivery_method_id -format "text"] - lappend $action $html - - append output "$action: $html" - + + } + + set new_id "$new_thread_id-$new_user_id" + set action "new" + } + + set html " + $id_description: $new_id +
" + + lappend $action $html + + append output "$action: $html" + + } on_error { + set output "

Error:

$errmsg


$output" + } } -} on_error { - set output "

Error:

$errmsg


$output" -} ns_db releasehandle $olddb - + ns_return 200 text/html " -Migratonisubscripforum -

Migrating Forum Subscrtiptions

+Migratonisubscrimessage +

Migrating Message Subscrtiptions

Unsorted Output:

$output

Sorted Output:

-

[llength $nil] nil -- categorys already created & mapped

[join $nil]

+

[llength $nil] nil -- subscriptions already created & mapped

[join $nil]

[llength $new] new -- uncreated and unmapped

[join $new]

"