X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=modules%2Ferl%2Feuphorik_minichat_conversation.erl;h=3c88caa073183f1ea17ccf06c4f5109e2dee5b5a;hb=de1974f6e7ffcb18f0f4378ade72fe154dab4bba;hp=2530327541b0f937f66bd2fc1ac146ecf799fb22;hpb=886e51257b3d610ee0e4f7576d720495914ae9ec;p=euphorik.git diff --git a/modules/erl/euphorik_minichat_conversation.erl b/modules/erl/euphorik_minichat_conversation.erl index 2530327..3c88caa 100755 --- a/modules/erl/euphorik_minichat_conversation.erl +++ b/modules/erl/euphorik_minichat_conversation.erl @@ -1,4 +1,21 @@ -% coding: utf-8 +% coding: utf-8 +% Copyright 2008 Grégory Burri +% +% This file is part of Euphorik. +% +% Euphorik is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Euphorik is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Euphorik. If not, see . +% % Ce module permet la gestion des conversations du minichat d'euphorik. % Un message (enfant) peut répondre à des messages (ses parents). % Un message (parent) peut avoir plusieurs réponses (enfants) @@ -7,15 +24,14 @@ % @type Message() = {integer(), [integer()]} % @type Conversation_detailee() = {[integer()], [integer()], [integer()], bool()} % @type Conversation = {[Message()] , bool()} bool() : si true alors il y a encore des messages dans les pages suivantes. + -module(euphorik_minichat_conversation). -export([ conversations/4 ]). - -include("euphorik_bd.hrl"). -include_lib("stdlib/include/qlc.hrl"). - -import(lists, [reverse/1, any/2, map/2, sublist/3, filter/2]). -import(euphorik_bd, [resultat_transaction/1]). -import(qlc, [e/1, q/1, keysort/3]). @@ -161,16 +177,16 @@ conversation(R, N, D, P) -> % Renvoie un tuple {C, X} où C est la conversation complète et X les messages répondant à des mess qui ne font pas partie de la conversation % Attention : les messages de C et de X sont ordrés du plus grand Id au plus petit. % @spec conversation([integer()], [integer()], [integer()]) -> {} -conversation(Messages, [M | Reste], X) -> - Est_deja_traite = any(fun(E) -> E =:= M end, Messages), +conversation(Conv, [M | Reste], X) -> + Est_deja_traite = any(fun(E) -> E =:= M end, Conv), if Est_deja_traite -> - conversation(Messages, Reste, X); + conversation(Conv, Reste, X); true -> Enfants = enfants(M), Parents = parents(M), % un message est dit externe si un de ses parent ne fait pas partie de la conversation ou si un de ses parents fait partie de X - Est_message_externe = Parents -- Messages =/= [] orelse intersection(Parents, X) =/= [], - conversation([M | Messages], lists:merge(Reste, Enfants), if Est_message_externe -> [M | X]; true -> X end) + Est_message_externe = Parents -- Conv =/= [] orelse intersection(Parents, X) =/= [], + conversation([M | Conv], lists:merge(Reste, Enfants), if Est_message_externe -> [M | X]; true -> X end) end; conversation(Messages, [], X) -> {Messages, X}.