9604: notes are visible even if they have is_deleted = 1
authorsstamer <s.stamer@metaways.de>
Fri, 4 Apr 2014 08:21:06 +0000 (10:21 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 25 Jul 2014 12:43:46 +0000 (14:43 +0200)
https://forge.tine20.org/mantisbt/view.php?id=9604
- don't get deleted notes
- add test

Change-Id: Ifae5989dd79112853f609df3a87c47f1f990a1b8
Reviewed-on: http://gerrit.tine20.com/customers/459
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Tinebase/NotesTest.php
tine20/Tinebase/Notes.php

index fb381c4..ad0c6eb 100644 (file)
@@ -197,6 +197,23 @@ class Tinebase_NotesTest extends PHPUnit_Framework_TestCase
     }
     
     /**
+     * try to search for deleted notes
+     */
+    public function testDoNotGetDeletedNotes()
+    {
+        $filter = new Tinebase_Model_NoteFilter(array(array(
+            'field' => 'query',
+            'operator' => 'contains',
+            'value' => 'phpunit'
+        )));
+        $notes = $this->_instance->searchNotes($filter, new Tinebase_Model_Pagination());
+        $notesCount = $this->_instance->searchNotesCount($filter);
+        
+        $this->assertEquals(0, $notes->count());
+        $this->assertEquals(0, $notesCount);
+    }
+    
+    /**
      * try to delete a note type
      *
      */
index ecabd50..578e7e3 100644 (file)
@@ -156,7 +156,8 @@ class Tinebase_Notes implements Tinebase_Backend_Sql_Interface
     public function searchNotes(Tinebase_Model_NoteFilter $_filter, Tinebase_Model_Pagination $_pagination = NULL, $ignoreACL = true)
     {
         $select = $this->_db->select()
-            ->from(array('notes' => SQL_TABLE_PREFIX . 'notes'));
+            ->from(array('notes' => SQL_TABLE_PREFIX . 'notes'))
+            ->where($this->_db->quoteIdentifier('is_deleted') . ' = 0');
         
         if (! $ignoreACL) {
             $this->_checkFilterACL($_filter);
@@ -214,7 +215,8 @@ class Tinebase_Notes implements Tinebase_Backend_Sql_Interface
     public function searchNotesCount(Tinebase_Model_NoteFilter $_filter, $ignoreACL = true)
     {
         $select = $this->_db->select()
-            ->from(array('notes' => SQL_TABLE_PREFIX . 'notes'), array('count' => 'COUNT(' . $this->_db->quoteIdentifier('id') . ')'));
+            ->from(array('notes' => SQL_TABLE_PREFIX . 'notes'), array('count' => 'COUNT(' . $this->_db->quoteIdentifier('id') . ')'))
+            ->where($this->_db->quoteIdentifier('is_deleted') . ' = 0');
         
         if (! $ignoreACL) {
             $this->_checkFilterACL($_filter);