lang::user::set_locale (public)

 lang::user::set_locale [ -package_id package_id ] [ -user_id user_id ] \
    locale

Defined in packages/acs-lang/tcl/locale-procs.tcl

Set user locale setting for a given package instance.

Switches:
-package_id (optional)
The package for which you want to set the locale setting, if you want to set it for a specific package, as opposed to a site-wide setting.
-user_id (optional)
Parameters:
locale (required)
The new locale that you want to use as your system locale.

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_numeric create_form_with_numeric (test xowiki) lang::user::set_locale lang::user::set_locale test_create_form_with_numeric->lang::user::set_locale test_lang_test__lang_user_site_wide_locale lang_test__lang_user_site_wide_locale (test acs-lang) test_lang_test__lang_user_site_wide_locale->lang::user::set_locale test_test_get_locales test_get_locales (test acs-lang) test_test_get_locales->lang::user::set_locale ad_conn ad_conn (public) lang::user::set_locale->ad_conn ad_set_cookie ad_set_cookie (public) lang::user::set_locale->ad_set_cookie db_dml db_dml (public) lang::user::set_locale->db_dml db_string db_string (public) lang::user::set_locale->db_string security::cookie_name security::cookie_name (public) lang::user::set_locale->security::cookie_name acs::test::user::create acs::test::user::create (public) acs::test::user::create->lang::user::set_locale packages/acs-lang/www/change-locale-include.tcl packages/acs-lang/ www/change-locale-include.tcl packages/acs-lang/www/change-locale-include.tcl->lang::user::set_locale packages/acs-lang/www/change-locale.tcl packages/acs-lang/ www/change-locale.tcl packages/acs-lang/www/change-locale.tcl->lang::user::set_locale packages/acs-subsite/lib/user-info.tcl packages/acs-subsite/ lib/user-info.tcl packages/acs-subsite/lib/user-info.tcl->lang::user::set_locale packages/acs-subsite/lib/user-new.tcl packages/acs-subsite/ lib/user-new.tcl packages/acs-subsite/lib/user-new.tcl->lang::user::set_locale

Testcases:
lang_test__lang_user_site_wide_locale, test_get_locales, create_form_with_numeric
Source code:
    if { $user_id eq "" } {
        set user_id [ad_conn user_id]
    }

    if { $user_id == 0 } {
        # Not logged in, use a cookie-based client locale
        set cookie_name [security::cookie_name locale]
        ad_set_cookie -replace t -max_age inf -samesite strict $cookie_name $locale

        # Flush the site-wide user preference cache
        util_memoize_flush [list lang::user::site_wide_locale_not_cached $user_id]
        return
    }

    if { $package_id eq "" } {
        # Set site-wide locale in user_preferences table
        db_dml set_user_site_wide_locale {}

        # Flush the site-wide user preference cache
        util_memoize_flush [list lang::user::site_wide_locale_not_cached $user_id]
        return
    }

    # The rest is for package level locale settings only
    # Even if package level locales are disabled, we'll still do this

    set user_locale_exists_p [db_string user_locale_exists_p {}]
    if { $user_locale_exists_p } {
        if { $locale ne "" } {
            db_dml update_user_locale {}
        } else {
            db_dml delete_user_locale {}
        }
    } else {
        if { $locale ne "" } {
            db_dml insert_user_locale {}
        }
    }

    # Flush the user locale preference cache
    util_memoize_flush [list lang::user::package_level_locale_not_cached $user_id $package_id]
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
<fullquery name="lang::user::set_locale.set_user_site_wide_locale">
    <querytext>
        update user_preferences
        set    locale = :locale
        where  user_id = :user_id
      </querytext>
</fullquery>

<fullquery name="lang::user::set_locale.user_locale_exists_p">
    <querytext>
        select count(*) 
        from   ad_locale_user_prefs 
        where  user_id = :user_id
        and    package_id = :package_id
      </querytext>
</fullquery>

<fullquery name="lang::user::set_locale.update_user_locale">
    <querytext>
        update ad_locale_user_prefs 
        set    locale = :locale 
        where  user_id = :user_id 
        and    package_id = :package_id
      </querytext>
</fullquery>

<fullquery name="lang::user::set_locale.insert_user_locale">
    <querytext>
         insert into ad_locale_user_prefs (user_id, package_id, locale) 
        values (:user_id, :package_id, :locale)
      </querytext>
</fullquery>

<fullquery name="lang::user::set_locale.delete_user_locale">
    <querytext>
        delete 
        from   ad_locale_user_prefs 
        where  user_id = :user_id 
        and    package_id = :package_id
      </querytext>
</fullquery>
packages/acs-lang/tcl/locale-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: