Index: openacs-4/packages/acs-subsite/tcl/subsite-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/subsite-callback-procs.tcl,v diff -u -N -r1.10.2.1 -r1.10.2.2 --- openacs-4/packages/acs-subsite/tcl/subsite-callback-procs.tcl 16 May 2019 09:27:52 -0000 1.10.2.1 +++ openacs-4/packages/acs-subsite/tcl/subsite-callback-procs.tcl 17 Dec 2019 12:00:23 -0000 1.10.2.2 @@ -10,7 +10,31 @@ } -ad_proc -public subsite_callback { +ad_proc -deprecated subsite_callback args { + Executes any registered callbacks for this object. +

+ Example: +

+    # Execute any callbacks registered for this object type or one of
+    # its parent object types
+    subsite_callback -object_type $object_type $object_id
+    
+ + + @author Michael Bryzek (mbryzek@arsdigita.com) + @creation-date 12/2000 + + @param object_type The object's type. We look this up in the db if + not specified + + DEPRECATED: does not comply with OpenACS naming convention + + @see subsite::callback +} { + return [subsite::callback {*}$args] +} + +ad_proc -public subsite::callback { { -object_type "" } event_type object_id @@ -21,7 +45,7 @@
     # Execute any callbacks registered for this object type or one of
     # its parent object types
-    subsite_callback -object_type $object_type $object_id
+    subsite::callback -object_type $object_type $object_id
     
@@ -31,29 +55,34 @@ @param object_type The object's type. We look this up in the db if not specified } { + set node_id [ad_conn node_id] + set package_id [ad_conn package_id] - if { $object_type eq "" } { - db_1row select_object_type { - select object_type - from acs_objects - where object_id = :object_id - } - } - # Check to see if we have any callbacks registered for this object # type or one of its parent object types. Put the callbacks into # a list as each callback may itself require a database # handle. Note that we need the distinct in case two callbacks are # registered for an object and its parent object type. + db_foreach get_callbacks { + with recursive object_hierarchy as ( + select object_type, supertype + from acs_object_types + where object_type = coalesce(:object_type, (select object_type + from acs_objects + where object_id = :object_id)) - set callback_list [db_list_of_lists select_callbacks {}] + union all - set node_id [ad_conn node_id] - set package_id [ad_conn package_id] - - foreach row $callback_list { - lassign $row callback type - + select t.object_type, t.supertype + from acs_object_types t, + object_hierarchy s + where t.object_type = s.supertype + ) + select distinct callback, callback_type as type + from subsite_callbacks + where event_type = :event_type + and object_type in (select object_type from object_hierarchy) + } { switch -- $type { tcl { # Execute the Tcl procedure