Index: openacs-4/packages/acs-tcl/tcl/acs-permissions-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/acs-permissions-procs-oracle.xql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-tcl/tcl/acs-permissions-procs-oracle.xql 5 Jul 2002 23:14:47 -0000 1.8 +++ openacs-4/packages/acs-tcl/tcl/acs-permissions-procs-oracle.xql 20 Sep 2002 21:45:10 -0000 1.9 @@ -29,7 +29,7 @@ - + select 1 from dual Index: openacs-4/packages/acs-tcl/tcl/acs-permissions-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/acs-permissions-procs-postgresql.xql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/acs-tcl/tcl/acs-permissions-procs-postgresql.xql 5 Jul 2002 23:14:47 -0000 1.8 +++ openacs-4/packages/acs-tcl/tcl/acs-permissions-procs-postgresql.xql 20 Sep 2002 21:45:10 -0000 1.9 @@ -22,7 +22,7 @@ - + select 1 where 't' = acs_permission__permission_p(:object_id, :party_id, :privilege) Index: openacs-4/packages/acs-tcl/tcl/acs-permissions-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/acs-permissions-procs.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/acs-tcl/tcl/acs-permissions-procs.tcl 15 Sep 2002 22:10:50 -0000 1.10 +++ openacs-4/packages/acs-tcl/tcl/acs-permissions-procs.tcl 20 Sep 2002 21:45:10 -0000 1.11 @@ -10,6 +10,16 @@ namespace eval permission { + # define cache_p to be 0 here. Note that it is redefined on init to be + # the value of the PermissionCacheP kernel parameter. + # see request-processor-init.tcl + ad_proc cache_p {} { + returns 0 or 1 depending if permission_p caching is enabled or disabled. + by default caching is disabled. + } { + return 0 + } + ad_proc -public grant { {-party_id:required} {-object_id:required} @@ -18,6 +28,7 @@ grant privilege Y to party X on object Z } { db_exec_plsql grant_permission {} + util_memoize_flush "permission::permission_p_not_cached -party_id $party_id -object_id $object_id -privilege $privilege" } ad_proc -public revoke { @@ -28,19 +39,49 @@ revoke privilege Y from party X on object Z } { db_exec_plsql revoke_permission {} + util_memoize_flush "permission::permission_p_not_cached -party_id $party_id -object_id $object_id -privilege $privilege" } + # args to permission_p and permission_p_no_cache must match ad_proc -public permission_p { + {-no_cache:boolean} {-party_id ""} {-object_id:required} {-privilege:required} } { does party X have privilege Y on object Z + + @param nocache force loading from db even if cached (flushes cache as well) + @param party_id if null then it is the current user_id } { if {[empty_string_p $party_id]} { set party_id [ad_conn user_id] } + if { $no_cache_p || ![permission::cache_p] } { + util_memoize_flush "permission::permission_p_not_cached -party_id $party_id -object_id $object_id -privilege $privilege" + permission::permission_p_not_cached -party_id $party_id -object_id $object_id -privilege $privilege + } else { + return [util_memoize "permission::permission_p_not_cached -party_id $party_id -object_id $object_id -privilege $privilege"] + } + } + + # accepts nocache to match permission_p arguments + # since we alias it to permission::permission_p if + # caching disabled. + ad_proc -private permission_p_not_cached { + {-no_cache:boolean} + {-party_id ""} + {-object_id:required} + {-privilege:required} + } { + does party X have privilege Y on object Z + + @see permission::permission_p + } { + if {[empty_string_p $party_id]} { + set party_id [ad_conn user_id] + } return [db_0or1row select_permission_p {}] }