xo::ConnectionContext instproc permission (public)

 <instance of xo::ConnectionContext[i]> permission \
    -object_id object_id  -privilege privilege  [ -party_id party_id ]

Defined in /var/www/openacs.org/packages/xotcl-core/tcl/context-procs.tcl

Call ::permission::permission_p but avoid multiple calls in the same request through caching in the connection context

Switches:
-object_id (required, integer)
-privilege (required)
-party_id (optional, integer)

Testcases:
xowiki_test_cases
Source code:
if {![info exists party_id]} {
  set party_id ${:user_id}
}
# :log "--  context permission user_id=$party_id uid=[::xo::cc user_id]"  "untrusted=[::xo::cc set untrusted_user_id]"
if {$party_id == 0} {
  set granted [permission::permission_p -no_login -party_id $party_id  -object_id $object_id  -privilege $privilege]
  #:msg "--p lookup $key ==> $granted uid=${:user_id} uuid=${:untrusted_user_id}"
  if {$granted || ${:user_id} == ${:untrusted_user_id}} {
    return $granted
  }
  # The permission is not granted for the public.
  # We force the user to login
  #:log "-- require login"
  #auth::require_login
  return 0
}

#:msg "--p lookup $key"
return [permission::permission_p -no_login  -party_id $party_id  -object_id $object_id  -privilege $privilege]
#:log "--  context return [set :$key]"
#set :$key
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: