Index: openacs-4/packages/acs-tcl/tcl/object-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/object-procs.tcl,v diff -u -r1.14.2.5 -r1.14.2.6 --- openacs-4/packages/acs-tcl/tcl/object-procs.tcl 6 Mar 2021 16:58:14 -0000 1.14.2.5 +++ openacs-4/packages/acs-tcl/tcl/object-procs.tcl 14 Jul 2022 16:55:16 -0000 1.14.2.6 @@ -179,6 +179,38 @@ return [db_string object_exists {} -default 0] } +ad_proc -private acs_object::is_type_p { + -object_id:required + -object_types:required + -no_hierarchy:boolean +} { + Returns whether an object is of a given object type. +} { + set object_types [ns_dbquotelist $object_types] + set no_hierarchy_p [expr {$no_hierarchy_p ? "t" : "f"}] + return [db_0or1row check_types [subst -nocommands { + with recursive hierarchy as + ( + select o.object_type, t.supertype + from acs_objects o, acs_object_types t + where o.object_id = :object_id + and o.object_type = t.object_type + + union + + select t.object_type, t.supertype + from acs_object_types t, + hierarchy h + where :no_hierarchy_p = 'f' + and t.object_type = h.supertype + and h.object_type not in ($object_types) + ) + select 1 from hierarchy + where object_type in ($object_types) + fetch first 1 rows only + }]] +} + ad_proc -public acs_object::set_context_id { {-object_id:required} {-context_id:required} Index: openacs-4/packages/acs-tcl/tcl/tcl-documentation-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/tcl-documentation-procs.tcl,v diff -u -r1.61.2.25 -r1.61.2.26 --- openacs-4/packages/acs-tcl/tcl/tcl-documentation-procs.tcl 14 Jul 2022 15:17:09 -0000 1.61.2.25 +++ openacs-4/packages/acs-tcl/tcl/tcl-documentation-procs.tcl 14 Jul 2022 16:55:16 -0000 1.61.2.26 @@ -1831,7 +1831,31 @@ return 0 } +ad_page_contract_filter object_type { name object_id types } { + Checks whether the supplied object_id is an acs_object of one of + the types specified in the flag parameters. + + The check will take the object_type hierarchy into account + e.g. will always succeed if one of the types is "acs_object". In + this case the filter will just behave as an existance check. + +} { + # First make sure the object_id formally correct + if { ![ad_page_contract_filter_proc_object_id $name object_id] } { + return 0 + } + + if { ![acs_object::is_type_p \ + -object_id $object_id \ + -object_types $types] } { + ad_complain [_ acs-tcl.lt_invalid_object_type] + return 0 + } + + return 1 +} + ad_page_contract_filter range { name value range } { Checks whether the value falls between the specified range. Range must be a list of two elements: min and max.