xo::PackageMgr instproc first_instance (public)
<instance of xo::PackageMgr> first_instance \ [ -privilege privilege ] [ -party_id party_id ]
Defined in /var/www/openacs.org/packages/xotcl-core/tcl/06-package-procs.tcl
Returns the first mounted instance of this Package. When a privilege and a party are specified, will return the first instance where the party has such privilege.
- Switches:
- -privilege (optional)
- -party_id (optional)
- the party we are checking the privilege for
- Returns:
- integer package_id, empty string when none is found
- Testcases:
- xowiki_test_cases, create_form_with_form_instance
Source code: set package_key ${:package_key} if {![info exists privilege]} { return [::xo::dc get_value -prepare text get_first_package_id { select min(package_id) from apm_packages, site_nodes s where package_key = :package_key and s.object_id = package_id }] } elseif {[db_driverkey ""] eq "postgresql"} { # On Postgres we can use a recursive database function to check # for permissions on many objects more efficiently. set sql { select min(orig_object_id) from acs_permission.permission_p_recursive_array(array( select package_id from apm_packages, site_nodes s where package_key = :package_key and s.object_id = package_id ), :party_id, :privilege) } } else { set sql { select min(package_id) from apm_packages, site_nodes s where package_key = :package_key and s.object_id = package_id and acs_permission.permission_p(package_id, :party_id, :privilege) = 't' } } return [::xo::dc get_value -prepare {text integer text} get_first_package_id_with_privilege $sql]XQL Not present: Generic, PostgreSQL, Oracle