From: Greg Burri Date: Sun, 11 May 2008 08:41:36 +0000 (+0000) Subject: ADD le slap X-Git-Tag: 1.0.0^2~87 X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=commitdiff_plain;h=eae50232e73fca26d6f631c8177cbea649e5036e ADD le slap --- diff --git a/doc/protocole3.txt b/doc/protocole3.txt index 6c1032e..99776a4 100644 --- a/doc/protocole3.txt +++ b/doc/protocole3.txt @@ -225,6 +225,21 @@ ou +=== Slapage === + +c -> s + { + "action" : "slap", + "cookie" : "LKJDLAKSJBFLKASN", + "user_id" : 67 + } + +s -> c + +ou + + + === Bannissement === c -> s diff --git a/js/euphorik.js b/js/euphorik.js index 2b885ab..7bab324 100755 --- a/js/euphorik.js +++ b/js/euphorik.js @@ -771,6 +771,31 @@ Client.prototype.majMenu = function() } } + +Client.prototype.slap = function(userId) +{ + var thisClient = this + + jQuery.ajax({ + type: "POST", + url: "request", + dataType: "json", + data: this.util.jsonVersAction( + { + "action" : "slap", + "cookie" : thisClient.cookie, + "user_id" : userId + }), + success: + function(data) + { + if (data["reply"] == "error") + thisClient.util.messageDialogue(data["error_message"]) + } + }) +} + + Client.prototype.ban = function(userId, minutes) { var thisClient = this diff --git a/js/pageMinichat.js b/js/pageMinichat.js index 792caf9..6b7b340 100755 --- a/js/pageMinichat.js +++ b/js/pageMinichat.js @@ -548,6 +548,12 @@ Conversation.prototype.flush = function(funClickOuvrirConv) var offset = element.offset() var outils = $("#outilsBan").css("top", offset.top - 2).css("left", offset.left - 2).height(h < 16 ? 16 : h).width(element.width() + 16 * 3 + 4).show() $("img", outils).unbind() + $("#slap", outils).click( + function(e) + { + thisConversation.client.slap(userId) + } + ) $("#kick", outils).click( function(e) { diff --git a/modules/erl/euphorik_bd.erl b/modules/erl/euphorik_bd.erl index 87dab2f..eb6f1d4 100755 --- a/modules/erl/euphorik_bd.erl +++ b/modules/erl/euphorik_bd.erl @@ -100,6 +100,7 @@ create_tables() -> ]), mnesia:create_table(troll, [ {attributes, record_info(fields, troll)}, + {index, [date_post]}, {disc_copies, [node()]} ]). diff --git a/modules/erl/euphorik_protocole.erl b/modules/erl/euphorik_protocole.erl index c1bc376..c2342ca 100755 --- a/modules/erl/euphorik_protocole.erl +++ b/modules/erl/euphorik_protocole.erl @@ -12,6 +12,7 @@ wait_event/1, put_message/1, ban/1, + slap/1, erreur/1 ]). @@ -271,6 +272,36 @@ ban( end. +% slapage d'un user (avertissement) +slap( + [ + {cookie, Cookie}, + {user_id, User_id} + ]) -> + % controle que l'utilisateur est un admin + case euphorik_bd:user_by_cookie(Cookie) of + {ok, User1 = #user{ek_master = true}} -> + case euphorik_bd:user_by_id(User_id) of + {ok, User1} -> + euphorik_bd:nouveau_message_sys(lists:flatten(io_lib:format("~s s'auto slap (et il aime ça)", [User1#user.pseudo]))); + {ok, User2 = #user{ek_master = false}} -> + euphorik_bd:nouveau_message_sys(lists:flatten(io_lib:format("~s se fait slaper par ~s", + [ + User2#user.pseudo, + User1#user.pseudo + ] + ))), + json_reponse_ok(); + {ok, _} -> + erreur("L'utilisateur est lui même un ekMaster"); + _ -> + erreur("Utilisateur à slaper inconnu") + end; + _ -> + erreur("Utilisateur inconnu ou non ek master") + end. + + % Construit une erreur erreur(Message) -> { diff --git a/modules/erl/euphorik_requests.erl b/modules/erl/euphorik_requests.erl index 4af2f7e..a7e2ae1 100755 --- a/modules/erl/euphorik_requests.erl +++ b/modules/erl/euphorik_requests.erl @@ -56,5 +56,7 @@ traiter_action("wait_event", JSON, _) -> traiter_action("put_message", JSON, _) -> euphorik_protocole:put_message(JSON); traiter_action("ban", JSON, _) -> - euphorik_protocole:ban(JSON). + euphorik_protocole:ban(JSON); +traiter_action("slap", JSON, _) -> + euphorik_protocole:slap(JSON). \ No newline at end of file diff --git a/modules/include/euphorik_bd.hrl b/modules/include/euphorik_bd.hrl index 3a8da91..f1a2241 100755 --- a/modules/include/euphorik_bd.hrl +++ b/modules/include/euphorik_bd.hrl @@ -66,8 +66,8 @@ { id, id_user, - date, % erlang:now() - contenu, % chaine de caractère - date_choosen % la date à laquelle le troll est mis sur la page principale + date_create, % erlang:now() + date_post = undefined, % date à laquelle le troll est affiché sur la page principale. undefined initialement puis erlang:now() quand affiché + contenu % chaine de caractère }). \ No newline at end of file