summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-03-16 22:19:27 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-03-16 22:19:27 +0100
commit8c2b3bfc30caa22258b9569b8a228db0adc90618 (patch)
tree9d4ea433e309bf5bb7a2275f365dcc28bf14f8df /app
parent9daa4c14636ca6b70031344f812ac99947b3a2b0 (diff)
Fix bug #27 : le marquer comme lu s'adapte si on ne regarde qu'une catégorie ou qu'un flux
Diffstat (limited to 'app')
-rwxr-xr-xapp/controllers/entryController.php28
-rwxr-xr-xapp/models/Entry.php37
-rw-r--r--app/views/index/index.phtml20
3 files changed, 74 insertions, 11 deletions
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 @@
<?php $this->partial ('aside_flux'); ?>
<div class="nav_menu stick">
- <a class="btn" href="<?php echo Url::display (array ('c' => 'feed', 'a' => 'actualize')); ?>"><i class="icon i_refresh"></i></a>
+ <a class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><i class="icon i_refresh"></i></a>
+
+ <?php
+ $get = false;
+ $string_mark = 'Tout marquer comme lu';
+ if ($this->get_f) {
+ $get = 'f_' . $this->get_f;
+ $string_mark = 'Marquer le flux comme lu';
+ } elseif ($this->get_c) {
+ $get = 'c_' . $this->get_c;
+ $string_mark = 'Marquer la catégorie comme lue';
+ }
+ ?>
<?php if (!login_is_conf ($this->conf) || is_logged ()) { ?>
- <a class="read_all btn" href="<?php echo Url::display (array ('c' => 'entry', 'a' => 'read', 'params' => array ('is_read' => 1))); ?>">Tout marquer comme lu</a>
+ <a class="read_all btn" href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get); ?>"><?php echo $string_mark; ?></a>
<?php } ?>
<?php if ($this->mode == 'not_read') { ?>
- <a class="print_all btn" href="<?php echo Url::display (array ('a' => 'changeMode', 'params' => array ('mode' => 'all'))); ?>">Tout afficher</a>
+ <a class="print_all btn" href="<?php echo _url ('index', 'changeMode', 'mode', 'all'); ?>">Tout afficher</a>
<?php } else { ?>
- <a class="print_non_read btn" href="<?php echo Url::display (array ('a' => 'changeMode', 'params' => array ('mode' => 'not_read'))); ?>">Afficher les non lus</a>
+ <a class="print_non_read btn" href="<?php echo _url ('index', 'changeMode', 'mode', 'not_read'); ?>">Afficher les non lus</a>
<?php } ?>
</div>