Alexander Nicolaysen Sørnes : note: Delete all links to a note when deleting it

Alexander Nicolaysen Sørnes asornes at winehq.org
Sun Apr 24 18:47:43 CDT 2011


Module: appdb
Branch: master
Commit: 2a1258ae22b45274705d62f65bb4e8832b422662
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=2a1258ae22b45274705d62f65bb4e8832b422662

Author: Alexander Nicolaysen Sørnes <alexsornes at gmail.com>
Date:   Mon Apr 25 01:47:23 2011 +0200

note: Delete all links to a note when deleting it

---

 include/note.php |    3 +++
 include/tag.php  |   12 +++++++++++-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/include/note.php b/include/note.php
index c156b24..96cfcbb 100644
--- a/include/note.php
+++ b/include/note.php
@@ -188,6 +188,9 @@ class Note {
         if(!$hResult)
             return FALSE;
 
+        $oTag = new TagNoteVersion($this->iVersionId);
+        $oTag->deleteAssignments($this->iNoteId);
+
         return TRUE;
     }
 
diff --git a/include/tag.php b/include/tag.php
index c9fac08..3970b01 100644
--- a/include/tag.php
+++ b/include/tag.php
@@ -55,6 +55,16 @@ abstract class Tag extends ObjectManagerBase
         return $this->objectGetSQLTable().'_assignments';
     }
 
+    public function deleteAssignments($iId)
+    {
+        $hResult = query_parameters("UPDATE ? SET state = 'deleted' WHERE taggedId = '?'", $this->getSQLTableForAssignments(), $iId);
+        
+        if(!$hResult)
+            return false;
+        
+        return true;
+    }
+
     public function removeAssignment($iId)
     {
         $hResult = query_parameters("DELETE FROM ? WHERE tagId = '?' AND taggedId = '?'", $this->getSQLTableForAssignments(), $this->iId, $iId);
@@ -98,7 +108,7 @@ abstract class Tag extends ObjectManagerBase
 
     public function getTaggedEntries()
     {
-        $hResult = query_parameters("SELECT taggedId FROM ? WHERE tagId = '?'", $this->getSQLTableForAssignments(), $this->iId);
+        $hResult = query_parameters("SELECT taggedId FROM ? WHERE tagId = '?' AND state = 'accepted'", $this->getSQLTableForAssignments(), $this->iId);
 
         if(!$hResult)
             return array();




More information about the wine-cvs mailing list