note preview
[grauphel.git] / lib / notestorage.php
index fb6803029f780b8a00b31c8f6b54685d40daf435..7ecf049af02a21fb3e351201c65e4ebcc91d5995 100644 (file)
@@ -245,6 +245,28 @@ class NoteStorage
         return $this->noteFromRow($row);
     }
 
+    /**
+     * Load a GUID of a note by the note title
+     *
+     * @param string  $title Note title
+     *
+     * @return string GUID, NULL if note could not be found
+     */
+    public function loadGuidByTitle($title)
+    {
+        $row = \OC_DB::executeAudited(
+            'SELECT note_guid FROM `*PREFIX*grauphel_notes`'
+            . ' WHERE `note_user` = ? AND `note_title` = ?',
+            array($this->username, $title)
+        )->fetchRow();
+
+        if ($row === false) {
+            return null;
+        }
+
+        return $row['note_guid'];
+    }
+
     /**
      * Save a note into storage.
      *