ad_scope_sql { table_name " " }What it does:
if scope is not set in the topmost environment then public scope is assumed. if scope=group it assumes group_id is set in the topmost environment, if scope=user it assumes that user_id is set in topmost environment and if scope=table it assumes on_which_table and on_what_id are set in topmost environment. ad_scope_sql returns portion of sql query resolving scope. e.g. if scope=group this proc will return scope=group and group_id=Defined in: /web/philip/tcl/ad-scope.tcl. to avoid naming conflicts you may specify a table name (or table alias name) of the table for which we are checking the scope. (e.g if table_name=news, then nnews.scope will be used instead of just scope)
Source code:
if { [uplevel [ad_scope_upvar_level] {info exists scope}] } { upvar [ad_scope_upvar_level] scope scope } else { set scope public } if { [empty_string_p $table_name] } { switch $scope { public { return "scope='public'" } group { upvar [ad_scope_upvar_level] group_id group_id return "scope='group' and group_id=$group_id" } user { upvar [ad_scope_upvar_level] user_id user_id return "scope='user' and user_id=$user_id" } table { upvar [ad_scope_upvar_level] on_which_table on_which_table upvar [ad_scope_upvar_level] on_what_id on_what_id return "scope='table' and on_which_table='$on_which_table' and on_what_id=$on_what_id" } } } else { switch $scope { public { return "$table_name\.scope='public'" } group { upvar [ad_scope_upvar_level] group_id group_id return "$table_name\.scope='group' and $table_name\.group_id=$group_id" } user { upvar [ad_scope_upvar_level] user_id user_id return "$table_name\.scope='user' and $table_name\.user_id=$user_id" } table { upvar [ad_scope_upvar_level] on_which_table on_which_table upvar [ad_scope_upvar_level] on_what_id on_what_id return "$table_name\.scope='table' and $table_name\.on_which_table='$on_which_table' and $table_name\.on_what_id=$on_what_id" } } }