X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=modules%2Ferl%2Feuphorik_bd.erl;h=bef8b1f3a754050bdd6f48a71ac094149805f4db;hp=921bac5e67b796b55e2b4de9e0e2f07c4764b19f;hb=c6a3cf5c036c651fbe9d4d7c0e0ce34d991d3509;hpb=bd9caeefe3cfc9b4194c31052b0ddd4da26f604c diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl index 921bac5..bef8b1f 100755 --- a/modules/erl/euphorik_bd.erl +++ b/modules/erl/euphorik_bd.erl @@ -24,6 +24,10 @@ -module(euphorik_bd). -export([ + % texte : + get_texte/1, + get_texte/2, + % users : nouveau_user/2, nouveau_user/4, @@ -85,6 +89,20 @@ -include_lib("stdlib/include/qlc.hrl"). +get_texte(Id) -> + get_texte(Id, fr). + + +% TODO : généraliser la langue +get_texte(Id, _Lang = fr) -> + resultat_transaction(mnesia:transaction(fun() -> + case mnesia:read({texte, Id}) of + [#texte{fr = Texte}] -> Texte; + _ -> "Message " ++ integer_to_list(Id) ++ " unknown" + end + end)). + + % Ajoute un nouveau user et le renvoie nouveau_user(Cookie, Profile) -> F = fun() -> @@ -294,7 +312,7 @@ nouveau_message(Mess, Auteur_id, Repond_A_ids) -> % est-ce que l'auteur à trop floodé ? if Auteur#user.indice_flood =/= ?INDICE_SPAM_MAX, Auteur_maj#user.indice_flood =:= ?INDICE_SPAM_MAX, Delta =< ?DUREE_BLOCAGE_SPAM -> mnesia:write(Auteur#user{indice_flood = Auteur_maj#user.indice_flood}), - nouveau_message_sys("''" ++ Profile#profile.pseudo ++ if Auteur#user.login =/= [] -> " (" ++ Auteur#user.login ++ ")"; true -> "" end ++ "'' est bloqué pour " ++ integer_to_list(trunc(?DUREE_BLOCAGE_SPAM / 1000)) ++ " secondes pour cause de flood."); + nouveau_message_sys("\"" ++ Profile#profile.pseudo ++ if Auteur#user.login =/= [] -> " (" ++ Auteur#user.login ++ ")"; true -> "" end ++ "\" est bloqué pour " ++ integer_to_list(trunc(?DUREE_BLOCAGE_SPAM / 1000)) ++ " secondes pour cause de flood."); Auteur#user.indice_flood =:= ?INDICE_SPAM_MAX, Delta =< ?DUREE_BLOCAGE_SPAM -> {erreur, "Bloqué pour cause de flood"}; true ->