Index: openacs-4/packages/acs-authentication/tcl/authority-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/tcl/authority-procs.tcl,v diff -u -N -r1.39 -r1.39.2.1 --- openacs-4/packages/acs-authentication/tcl/authority-procs.tcl 3 Nov 2018 19:47:34 -0000 1.39 +++ openacs-4/packages/acs-authentication/tcl/authority-procs.tcl 10 Apr 2019 20:38:38 -0000 1.39.2.1 @@ -156,39 +156,47 @@ return $authority_id } - ad_proc -public auth::authority::get { - {-authority_id:required} - {-array:required} + {-authority_id ""} + {-array} } { - Get info about an authority, either by authority_id, user_id, or authority short_name. + Get info about an authority and return the authority_id. If no authority is specified, then + return - @param authority_id The authority you want to get. - - @param array Name of an array into which you want the attributes delivered. - + @param authority_id The authority you want to get. + If not specified, return the default authority + @param array Name of an array into which the detailed attributes + should be delivered @return authority_id @author Lars Pind (lars@collaboraid.biz) } { - upvar $array row - array set row [util_memoize [list auth::authority::get_not_cached $authority_id]] + if {$authority_id eq ""} { + # + # Get the default authority (in future probably for the + # specified or current subsite). + # + set authority_id [lindex [auth::authority::get_authority_options] 0 1] + } + if {[info exists array]} { + upvar $array row + array set row [util_memoize [list auth::authority::get_not_cached $authority_id]] + } + return $authority_id } ad_proc -public auth::authority::get_element { - {-authority_id:required} + {-authority_id ""} {-element:required} } { Return a specific element of the auth_authority data table. - Does a complete database query each time. Should not be used multiple times in a row. - Use auth::authority::get instead. @see auth::authority::get } { - if { [lsearch [get_select_columns] $element] == -1 } { + if { $element ni [get_select_columns] } { error "Column '$element' not found in the auth_authority data source." } @@ -515,21 +523,24 @@ } { set columns [get_columns] - lappend columns "(select impl_pretty_name from acs_sc_impls where impl_id = auth_impl_id) as auth_impl_name" - lappend columns "(select impl_pretty_name from acs_sc_impls where impl_id = pwd_impl_id) as pwd_impl_name" - lappend columns "(select impl_pretty_name from acs_sc_impls where impl_id = register_impl_id) as register_impl_name" - lappend columns "(select impl_pretty_name from acs_sc_impls where impl_id = user_info_impl_id) as user_info_impl_name" + lappend columns \ + "(select impl_pretty_name from acs_sc_impls where impl_id = auth_impl_id) as auth_impl_name" \ + "(select impl_pretty_name from acs_sc_impls where impl_id = pwd_impl_id) as pwd_impl_name" \ + "(select impl_pretty_name from acs_sc_impls where impl_id = register_impl_id) as register_impl_name" \ + "(select impl_pretty_name from acs_sc_impls where impl_id = user_info_impl_id) as user_info_impl_name" + if {[apm_version_names_compare [ad_acs_version] 5.5.0] > -1} { lappend columns "(select impl_pretty_name from acs_sc_impls where impl_id = search_impl_id) as search_impl_name" } - lappend columns "(select impl_pretty_name from acs_sc_impls where impl_id = get_doc_impl_id) as get_doc_impl_name" - lappend columns "(select impl_pretty_name from acs_sc_impls where impl_id = process_doc_impl_id) as process_doc_impl_name" + lappend columns \ + "(select impl_pretty_name from acs_sc_impls where impl_id = get_doc_impl_id) as get_doc_impl_name" \ + "(select impl_pretty_name from acs_sc_impls where impl_id = process_doc_impl_id) as process_doc_impl_name" - db_1row select_authority " + db_1row select_authority [subst { select [join $columns ",\n "] from auth_authorities where authority_id = :authority_id - " -column_array row + } -column_array row return [array get row] } @@ -552,8 +563,8 @@ Get authority_id by short_name. Not cached. } { return [db_string select_authority_id { - select authority_id - from auth_authorities + select authority_id + from auth_authorities where short_name = :short_name } -default {}] }