ADD le slap
authorGreg Burri <greg.burri@gmail.com>
Sun, 11 May 2008 08:41:36 +0000 (08:41 +0000)
committerGreg Burri <greg.burri@gmail.com>
Sun, 11 May 2008 08:41:36 +0000 (08:41 +0000)
doc/protocole3.txt
js/euphorik.js
js/pageMinichat.js
modules/erl/euphorik_bd.erl
modules/erl/euphorik_protocole.erl
modules/erl/euphorik_requests.erl
modules/include/euphorik_bd.hrl

index 6c1032e..99776a4 100644 (file)
@@ -225,6 +225,21 @@ ou
    <error>
 
 
    <error>
 
 
+=== Slapage ===
+
+c -> s
+   {
+      "action" : "slap",
+      "cookie" :  "LKJDLAKSJBFLKASN",
+      "user_id" : 67
+   }
+   
+s -> c
+   <ok>
+ou
+   <error>
+   
+
 === Bannissement ===
 
 c -> s
 === Bannissement ===
 
 c -> s
index 2b885ab..7bab324 100755 (executable)
@@ -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
 Client.prototype.ban = function(userId, minutes)
 {
    var thisClient = this
index 792caf9..6b7b340 100755 (executable)
@@ -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()
                   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)
                      {
                   $("#kick", outils).click(
                      function(e)
                      {
index 87dab2f..eb6f1d4 100755 (executable)
@@ -100,6 +100,7 @@ create_tables() ->
    ]),
    mnesia:create_table(troll, [
       {attributes, record_info(fields, troll)},
    ]),
    mnesia:create_table(troll, [
       {attributes, record_info(fields, troll)},
+      {index, [date_post]},
       {disc_copies, [node()]}
    ]).
    
       {disc_copies, [node()]}
    ]).
    
index c1bc376..c2342ca 100755 (executable)
@@ -12,6 +12,7 @@
    wait_event/1,
    put_message/1,
    ban/1,
    wait_event/1,
    put_message/1,
    ban/1,
+   slap/1,
    erreur/1
 ]).\r
 
    erreur/1
 ]).\r
 
@@ -271,6 +272,36 @@ ban(
       end.
       
 
       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) ->
    {
 % Construit une erreur
 erreur(Message) ->
    {
index 4af2f7e..a7e2ae1 100755 (executable)
@@ -56,5 +56,7 @@ traiter_action("wait_event", JSON, _) ->
 traiter_action("put_message", JSON, _) ->
    euphorik_protocole:put_message(JSON);
 traiter_action("ban", 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
  
\ No newline at end of file
index 3a8da91..f1a2241 100755 (executable)
@@ -66,8 +66,8 @@
    {
       id,
       id_user,
    {
       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
    }).
    
\ No newline at end of file