Selaa lähdekoodia

Corrige bug marquer tous les favoris comme lus

Corrige https://github.com/marienfressinaud/FreshRSS/issues/270
Alexandre Alapetite 12 vuotta sitten
vanhempi
commit
018273e272
3 muutettua tiedostoa jossa 27 lisäystä ja 12 poistoa
  1. 14 7
      app/controllers/entryController.php
  2. 6 4
      app/layout/nav_menu.phtml
  3. 7 1
      app/models/Entry.php

+ 14 - 7
app/controllers/entryController.php

@@ -47,14 +47,21 @@ class entryController extends ActionController {
 			} else {
 				$typeGet = $get[0];
 				$get = substr ($get, 2);
-
-				if ($typeGet == 'c') {
-					$entryDAO->markReadCat ($get, $idMax);
-					$this->params = array ('get' => $nextGet); 
-				} elseif ($typeGet == 'f') {
-					$entryDAO->markReadFeed ($get, $idMax);
-					$this->params = array ('get' => $nextGet);
+				switch ($typeGet) {
+					case 'c':
+						$entryDAO->markReadCat ($get, $idMax);
+						break;
+					case 'f':
+						$entryDAO->markReadFeed ($get, $idMax);
+						break;
+					case 's':
+						$entryDAO->markReadEntries ($idMax, true);
+						break;
+					case 'a':
+						$entryDAO->markReadEntries ($idMax);
+						break;
 				}
+				$this->params = array ('get' => $nextGet);
 			}
 
 			$notif = array (

+ 6 - 4
app/layout/nav_menu.phtml

@@ -10,10 +10,12 @@
 		if ($this->get_f) {
 			$get = 'f_' . $this->get_f;
 			$string_mark = Translate::t ('mark_feed_read');
-		} elseif ($this->get_c &&
-		          $this->get_c != 'a' &&
-		          $this->get_c != 's') {
-			$get = 'c_' . $this->get_c;
+		} elseif ($this->get_c && $this->get_c != 'a') {
+			if ($this->get_c === 's') {
+				$get = 's';
+			} else {
+				$get = 'c_' . $this->get_c;
+			}
 			$string_mark = Translate::t ('mark_cat_read');
 		}
 		$nextGet = $get;

+ 7 - 1
app/models/Entry.php

@@ -257,11 +257,14 @@ class EntryDAO extends Model_pdo {
 			return false;
 		}
 	}
-	public function markReadEntries ($idMax = 0) {
+	public function markReadEntries ($idMax = 0, $onlyFavorites = false) {
 		if ($idMax === 0) {
 			$sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
 			     . 'SET e.is_read = 1, f.cache_nbUnreads=0 '
 			     . 'WHERE e.is_read = 0 AND f.priority > 0';
+			if ($onlyFavorites) {
+				$sql .= ' AND e.is_favorite = 1';
+			}
 			$stm = $this->bd->prepare ($sql);
 			if ($stm && $stm->execute ()) {
 				return $stm->rowCount();
@@ -276,6 +279,9 @@ class EntryDAO extends Model_pdo {
 			$sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
 			     . 'SET e.is_read = 1 '
 			     . 'WHERE e.is_read = 0 AND e.id <= ? AND f.priority > 0';
+			if ($onlyFavorites) {
+				$sql .= ' AND e.is_favorite = 1';
+			}
 			$values = array ($idMax);
 			$stm = $this->bd->prepare ($sql);
 			if (!($stm && $stm->execute ($values))) {