Index: openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl 1 Oct 2008 22:19:28 -0000 1.11 +++ openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl 1 Oct 2008 22:59:59 -0000 1.12 @@ -17,10 +17,23 @@ package_key } - PackageMgr ad_instproc first_instance {} { + PackageMgr ad_instproc first_instance {-privilege -party_id} { @return return first mounted instance of this type } { - ::xo::parameter get_package_id_from_package_key -package_key [my package_key] + my instvar package_key + if {[info exists privilege]} { + set sql [::xo::db::sql select -vars package_id \ + -from "apm_packages, acs_object_party_privilege_map ppm" \ + -where { + package_key = :package_key + and ppm.object_id = package_id + and ppm.party_id = :party_id + and ppm.privilege = :privilege + } -limit 1] + db_string get_package_id $sql + } else { + ::xo::parameter get_package_id_from_package_key -package_key $package_key + } } PackageMgr ad_instproc instances {{-include_unmounted false}} {