1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-12-18 05:32:23 -05:00

[add] method to mark an entry as read

This commit is contained in:
Nicolas Lœuillet 2014-01-09 15:24:57 +01:00
parent 58f3a1dfd2
commit 01ac894b74
2 changed files with 14 additions and 2 deletions

View File

@ -19,6 +19,10 @@ class EntryApi
return $this->entryRepository->getEntryById($id);
}
public function markAsRead($id) {
return $this->entryRepository->markAsRead($id);
}
public function createEntryFromUrl($url) {
//TODO: Fetch all what we need, fill the title, content …

View File

@ -12,7 +12,7 @@ class EntryRepository
//TODO don't hardcode the user ;)
public function getEntries($userId = 1) {
$sql = "SELECT * FROM entries where user_id = ? ORDER BY id DESC";
$sql = "SELECT * FROM entries where user_id = ? AND status = 'unread' ORDER BY id DESC";
$entries = $this->db->fetchAll($sql, array($userId));
return $entries ? $entries : array();
@ -21,7 +21,7 @@ class EntryRepository
//TODO don't hardcode the user ;)
public function saveEntry($entry, $userId = 1) {
return $this->db->insert('entries', array_merge($entry, array('user_id' => $userId)));
return $this->db->insert('entries', array_merge($entry, array('user_id' => $userId, 'status' => 'unread')));
}
//TODO don't hardcode the user ;)
@ -31,5 +31,13 @@ class EntryRepository
return $entry ? $entry : array();
}
//TODO don't hardcode the user ;)
public function markAsRead($id, $userId = 1) {
$sql = "UPDATE entries SET status = 'read' where id = ? AND user_id = ?";
$entry = $this->db->fetchAll($sql, array($id, $userId));
return $entry ? true : false;
}
}