ad_page_contract {

    Curriculum add-published-curriculums-to-bar page

    @author Ola Hansson (ola@polyxena.net)
    @creation-date 2003-05-31
    @cvs-id $Id: add-to-bar.tcl,v 1.3 2003/06/13 11:44:33 olah Exp $

} {
    curriculum_id:optional
    {return_url "."}
    refresh_p:optional
}

if { [info exists refresh_p] } {
    set return_url "start-over?[export_vars -url curriculum_id]"
}
set package_id [curriculum::conn package_id]

# Adding is actually obtained by deleting one or more rows from the table
# "cu_user_curriculum_map", which holds the row(s) the user DOESN'T want.

if { [info exists curriculum_id] } {
    # Just add one particular curriculum.
    set extra_where_clause { and curriculum_id = :curriculum_id }
} else {
    # Add all the curriculums there is.
    set extra_where_clause {}
}

if [set user_id [ad_conn user_id]] {    

    db_transaction {
	db_dml add_published_curriculums_to_bar {*SQL*}

	# Force the bat to update.
	curriculum::elements_flush
    }

}

ns_returnredirect $return_url
