xo::PackageMgr instproc first_instance (public)

 <instance of xo::PackageMgr[i]> first_instance \
    [ -privilege privilege ] [ -party_id party_id ]

Defined in 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

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) xo::PackageMgr instproc first_instance xo::PackageMgr instproc first_instance test_create_form_with_form_instance->xo::PackageMgr instproc first_instance test_xowiki_test_cases xowiki_test_cases (test xowiki) test_xowiki_test_cases->xo::PackageMgr instproc first_instance db_driverkey db_driverkey (public) xo::PackageMgr instproc first_instance->db_driverkey

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
[ hide source ] | [ make this the default ]
Show another procedure: