noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 01/30: Task #1118 - Partage de notes via le


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 01/30: Task #1118 - Partage de notes via le Pense-bête #1118 : partage de note Correction bug
Date: Tue, 02 Jun 2015 22:29:01 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 1c8ed723962ae9e085d1fa1270d80d89974e3616
Author: Dany De Bontridder <address@hidden>
Date:   Wed May 27 20:14:15 2015 +0200

    Task #1118 - Partage de notes via le Pense-bête
    #1118 : partage de note
    Correction bug
---
 html/ajax_todo_list.php |   45 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/html/ajax_todo_list.php b/html/ajax_todo_list.php
index 3c4641e..05b310b 100644
--- a/html/ajax_todo_list.php
+++ b/html/ajax_todo_list.php
@@ -90,14 +90,23 @@ $ac=HtmlInput::default_value_get('act', 'save');
 
////////////////////////////////////////////////////////////////////////////////
 if ($ac == 'save')
 {
+    
     $cn=new Database(dossier::id());
     $todo=new Todo_List($cn);
-    $todo->set_parameter("id", HtmlInput::default_value_get("id", 0));
+     $id=HtmlInput::default_value_get("id", 0);
+    $todo->set_parameter("id",$id);
+    if ($id <> 0 ) { $todo->load(); }
+    else
+    {
+        $todo->set_parameter("owner", $_SESSION['g_user']);
+    }
+    
     $todo->set_parameter("date", HtmlInput::default_value_get("p_date_todo", 
""));
     $todo->set_parameter("title", HtmlInput::default_value_get("p_title", ""));
     $todo->set_parameter("desc", HtmlInput::default_value_get("p_desc", ""));
     $todo->set_is_public(HtmlInput::default_value_get("p_public", "N"));
-    $todo->save();
+    
+    if ( $todo->get_parameter('owner') == $_SESSION['g_user'] ) $todo->save();
     $todo->load();
      header('Content-type: text/xml; charset=UTF-8');
     $dom=new DOMDocument('1.0','UTF-8');
@@ -223,4 +232,36 @@ if ( $ac=="set_share")
         // remove a share from the user
         $todo->remove_share($p_login);
     }
+}
+////////////////////////////////////////////////////////////////////////////////
+// Remove the share of a note which the connected user doesn't own
+// 
+////////////////////////////////////////////////////////////////////////////////
+if ( $ac=="remove_share") 
+{
+    $id=HtmlInput::default_value_get("todo_id", 0);
+    $p_login=HtmlInput::default_value_get("login","");
+    // If note_id is not correct then give an error
+    if ($id==0||isNumber($id)==0  || trim ($p_login)=="")
+    {
+        header('Content-type: text/xml; charset=UTF-8');
+        $dom=new DOMDocument('1.0', 'UTF-8');
+        $status=$dom->createElement('status', "nok");
+        $tl_id=$dom->createElement('content', _("Erreur : paramètre 
invalide"));
+        $dom->appendChild($status);
+        $dom->appendChild($tl_id);
+        echo $dom->saveXML();
+        return;
+    }
+    $todo=new Todo_List($cn);
+    $todo->set_parameter("id", $id);
+    $todo->load();
+    $todo->remove_share($p_login);
+    
+    header('Content-type: text/xml; charset=UTF-8');
+    $dom=new DOMDocument('1.0', 'UTF-8');
+    $status=$dom->createElement('status', "ok");
+    $dom->appendChild($status);
+    echo $dom->saveXML();
+    return;
 }
\ No newline at end of file



reply via email to

[Prev in Thread] Current Thread [Next in Thread]