Index: openacs-4/packages/calendar/tcl/calendar-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/calendar-callback-procs.tcl,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/tcl/calendar-callback-procs.tcl 19 Jul 2005 16:49:36 -0000 1.5.2.2 @@ -0,0 +1,83 @@ +ad_library { + Callbacks for the search package. + + @author Dirk Gomez + @creation-date 2005-06-12 + @cvs-id $Id: calendar-callback-procs.tcl,v 1.5.2.2 2005/07/19 16:49:36 enriquec Exp $ +} + +ad_proc -callback merge::MergeShowUserInfo -impl calendar { + -user_id:required +} { + Shows the calendar tables user info +} { + set msg "Calendars of user_id: $user_id" + set return_msg [list $msg] + + set cals [db_list get_calendars {*SQL*} ] + if { [empty_string_p $cals ] } { + lappend return_msg "none" + } else { + lappend return_msg $cals + } + + return $return_msg +} + +ad_proc -callback merge::MergePackageUser -impl calendar { + -from_user_id:required + -to_user_id:required +} { + Merge the calendars of two users. + The from_user_id is the user_id of the user + that will be deleted and all the calendar elements + of this user will be mapped to the to_user_id. +} { + set msg "Merging calendar" + ns_log Notice $msg + set return_msg [list $msg] + + set from_calendars [db_list_of_lists get_from_calendars {*SQL*} ] + db_transaction { + ns_log Notice " Entering to calendar transaction" + foreach calendar $from_calendars { + # l_* vars will represent + # each item of the from_user_id list of lists + set l_cal_id [lindex $calendar 0] + set l_pkg_id [lindex $calendar 1] + + # if the pkg_id of this cal_id is the + # the same for some to_user_id cal + # we have to delete it, else we must + # change the items from one cal to the other one + if { [db_string get_repeated_pkgs {*SQL*} ] } { + # We will move the cal items if the + # calendars are of the same type (package_id) + set to_cal_id [db_string gettocalid {*SQL*} ] + + db_dml calendar_items_upd { *SQL* } + + # ns_log Notice " Deleting calendar" + # TODO: calendar::delete -calendar_id $l_cal_i is broken + # so, we will delete directly from the calendars table + db_dml del_from_cal { *SQL* } + + } else { + ns_log Notice " Change owner of $calendar" + # change the owner + db_dml calendars_upd { *SQL* } + } + } + set msg " Calendar merge is done" + ns_log Notice $msg + lappend return_msg $msg + } + # I commented this section to avoid partial merges + # If something is wrong the merge should be stopped. + # on_error { + # set msg " I couldn't merge calendar. The error was $errmsg" + # ns_log Notice $msg + # lappend return_msg $msg + # } + return $return_msg +} Index: openacs-4/packages/calendar/tcl/calendar-callback-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/calendar-callback-procs.xql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/tcl/calendar-callback-procs.xql 19 Jul 2005 16:49:36 -0000 1.1.2.1 @@ -0,0 +1,64 @@ + + + + + + select calendar_name + from calendars + where owner_id = :user_id + + + + + + select calendar_id,package_id + from calendars + where owner_id = :from_user_id + + + + + + select count(*) + from calendars + where owner_id = :to_user_id + and package_id = :l_pkg_id + + + + + + update calendars + set owner_id = :to_user_id + where owner_id = :from_user_id + and calendar_id = :l_cal_id + + + + + + select calendar_id + from calendars + where package_id = :l_pkg_id + and owner_id = :to_user_id + + + + + + update cal_items + set on_which_calendar = :to_cal_id + where on_which_calendar = :l_cal_id + + + + + + delete + from calendars + where calendar_id = :l_cal_id + + + + + Index: openacs-4/packages/calendar/tcl/calendar-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/calendar-procs.tcl,v diff -u -N -r1.25.2.4 -r1.25.2.5 --- openacs-4/packages/calendar/tcl/calendar-procs.tcl 7 Jul 2005 23:00:17 -0000 1.25.2.4 +++ openacs-4/packages/calendar/tcl/calendar-procs.tcl 19 Jul 2005 16:49:36 -0000 1.25.2.5 @@ -15,82 +15,6 @@ namespace eval calendar {} namespace eval calendar::notification {} -ad_proc -callback merge::MergeShowUserInfo -impl calendar { - -user_id:required -} { - Shows the calendar tables user info -} { - set msg "Calendars of user_id: $user_id" - set return_msg [list $msg] - - set cals [db_list get_calendars {*SQL*} ] - if { [empty_string_p $cals ] } { - lappend return_msg "none" - } else { - lappend return_msg $cals - } - - return $return_msg -} - -ad_proc -callback merge::MergePackageUser -impl calendar { - -from_user_id:required - -to_user_id:required -} { - Merge the calendars of two users. - The from_user_id is the user_id of the user - that will be deleted and all the calendar elements - of this user will be mapped to the to_user_id. -} { - set msg "Merging calendar" - ns_log Notice $msg - set return_msg [list $msg] - - set from_calendars [db_list_of_lists get_from_calendars {*SQL*} ] - db_transaction { - ns_log Notice " Entering to calendar transaction" - foreach calendar $from_calendars { - # l_* vars will represent - # each item of the from_user_id list of lists - set l_cal_id [lindex $calendar 0] - set l_pkg_id [lindex $calendar 1] - - # if the pkg_id of this cal_id is the - # the same for some to_user_id cal - # we have to delete it, else we must - # change the items from one cal to the other one - if { [db_string get_repeated_pkgs {*SQL*} ] } { - # We will move the cal items if the - # calendars are of the same type (package_id) - set to_cal_id [db_string gettocalid {*SQL*} ] - - db_dml calendar_items_upd { *SQL* } - - # ns_log Notice " Deleting calendar" - # TODO: calendar::delete -calendar_id $l_cal_i is broken - # so, we will delete directly from the calendars table - db_dml del_from_cal { *SQL* } - - } else { - ns_log Notice " Change owner of $calendar" - # change the owner - db_dml calendars_upd { *SQL* } - } - } - set msg " Calendar merge is done" - ns_log Notice $msg - lappend return_msg $msg - } - # I commented this section to avoid partial merges - # If something is wrong the merge should be stopped. - # on_error { - # set msg " I couldn't merge calendar. The error was $errmsg" - # ns_log Notice $msg - # lappend return_msg $msg - # } - return $return_msg -} - ad_proc calendar::make_datetime { event_date {event_time ""} Index: openacs-4/packages/calendar/tcl/calendar-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/calendar-procs.xql,v diff -u -N -r1.6.6.3 -r1.6.6.4 --- openacs-4/packages/calendar/tcl/calendar-procs.xql 23 Jun 2005 16:44:06 -0000 1.6.6.3 +++ openacs-4/packages/calendar/tcl/calendar-procs.xql 19 Jul 2005 16:49:36 -0000 1.6.6.4 @@ -82,63 +82,5 @@ - - - select calendar_name - from calendars - where owner_id = :user_id - - - - - - select calendar_id,package_id - from calendars - where owner_id = :from_user_id - - - - - - select count(*) - from calendars - where owner_id = :to_user_id - and package_id = :l_pkg_id - - - - - - update calendars - set owner_id = :to_user_id - where owner_id = :from_user_id - and calendar_id = :l_cal_id - - - - - - select calendar_id - from calendars - where package_id = :l_pkg_id - and owner_id = :to_user_id - - - - - - update cal_items - set on_which_calendar = :to_cal_id - where on_which_calendar = :l_cal_id - - - - - - delete - from calendars - where calendar_id = :l_cal_id - -