View source with raw comments or as raw
    1:- module(ag_preferences, []).    2
    3:- use_module(library(http/http_session)).    4:- use_module(library(semweb/rdf_db)).    5:- use_module(library(settings)).    6:- use_module(cliopatria(hooks)).    7:- use_module(user(user_db)).    8
    9:- rdf_meta
   10	cliopatria:user_preference_db(r,o),
   11	cliopatria:user_preference_default(r,o),
   12	set_user_preferences(r,o).   13
   14:- if(current_setting(user:lang)).   15% do nothing
   16:- else.   17:- setting(user:lang, atom, en, 'Preferred language').   18:- endif.   19
   20                 /*******************************
   21                 *   USER/SESSION PREFERENCES   *
   22                 *******************************/
 cliopatria:user_preference_db(?Property:atom, ?Value:rdf_object) is nondet
Query properties for the current user/session. This mechanism allows code to access information about the user/session without committing to a particular implementation. The predicate and values are compatible with RDF to allow implementing the user database in RDF, typically using the OpenID as subject.
   32cliopatria:user_preference_db(Property, Value) :-
   33	http_in_session(_),
   34	logged_on(User, anonymous),
   35	http_session_data(rdf(User, Property, Value)).
 cliopatria:user_preference_default(?Property:atom, ?Value:rdf_object) is nondet
Provides defaults for the user_preference/2.
See also
- user_preference_db/2
   43cliopatria:user_preference_default(Prop, literal(Value)) :-
   44	rdf_equal(Prop, user:lang),
   45	setting(user:lang, Value)