diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index ca702191f..cb309c567 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -17,7 +17,11 @@ class entryController extends ActionController { public function lastAction () { $ajax = Request::param ('ajax'); if (!$ajax) { - Request::forward (array (), true); + Request::forward (array ( + 'c' => 'index', + 'a' => 'index', + 'params' => $this->params + ), true); } else { Request::_param ('ajax'); } @@ -26,6 +30,7 @@ class entryController extends ActionController { public function readAction () { $id = Request::param ('id'); $is_read = Request::param ('is_read'); + $get = Request::param ('get'); if ($is_read) { $is_read = true; @@ -33,18 +38,27 @@ class entryController extends ActionController { $is_read = false; } - $values = array ( - 'is_read' => $is_read, - ); - $entryDAO = new EntryDAO (); if ($id == false) { - $entryDAO->updateEntries ($values); + if (!$get) { + $entryDAO->markReadEntries ($is_read); + } else { + $typeGet = $get[0]; + $get = substr ($get, 2); + + if ($typeGet == 'c') { + $entryDAO->markReadCat ($get, $is_read); + $this->params = array ('get' => 'c_' . $get); + } elseif ($typeGet == 'f') { + $entryDAO->markReadFeed ($get, $is_read); + $this->params = array ('get' => 'f_' . $get); + } + } // notif $notif = array ( 'type' => 'good', - 'content' => 'Tous les flux ont été marqués comme lu' + 'content' => 'Les flux ont été marqués comme lu' ); Session::_param ('notification', $notif); } else { diff --git a/app/models/Entry.php b/app/models/Entry.php index b1d7b8880..001f76b5a 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -171,6 +171,43 @@ class EntryDAO extends Model_pdo { } } + public function markReadEntries ($read) { + $sql = 'UPDATE entry SET is_read = ?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($read); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + return false; + } + } + public function markReadCat ($id, $read) { + $sql = 'UPDATE entry e INNER JOIN feed f ON e.id_feed = f.id SET is_read = ? WHERE category = ?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($read, $id); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + return false; + } + } + public function markReadFeed ($id, $read) { + $sql = 'UPDATE entry SET is_read = ? WHERE id_feed = ?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($read, $id); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + return false; + } + } + public function updateEntries ($valuesTmp) { if (isset ($valuesTmp['content'])) { $valuesTmp['content'] = base64_encode (gzdeflate (serialize ($valuesTmp['content']))); diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index df222b5d0..3e213d076 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -1,16 +1,28 @@ partial ('aside_flux'); ?> diff --git a/public/theme/icons/down.svg b/public/theme/icons/down.svg new file mode 100644 index 000000000..06d031fae --- /dev/null +++ b/public/theme/icons/down.svg @@ -0,0 +1,31 @@ + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + + + + Gnome Symbolic Icon Theme + + + + + + + + + + + + + + diff --git a/public/theme/icons/up.svg b/public/theme/icons/up.svg new file mode 100644 index 000000000..dab31a20d --- /dev/null +++ b/public/theme/icons/up.svg @@ -0,0 +1,31 @@ + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + + + + Gnome Symbolic Icon Theme + + + + + + + + + + + + + +