mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-24 08:14:56 -04:00
Typing function checkToken (#4561)
* Typing function checkToken * Typing function and rename Co-authored-by: Luc SANCHEZ <luc.sanchez@zol.fr>
This commit is contained in:
@@ -265,7 +265,7 @@ SQL;
|
||||
return $categories;
|
||||
}
|
||||
|
||||
uasort($categories, function ($a, $b) {
|
||||
uasort($categories, static function ($a, $b) {
|
||||
$aPosition = $a->attributes('position');
|
||||
$bPosition = $b->attributes('position');
|
||||
if ($aPosition === $bPosition) {
|
||||
@@ -310,9 +310,9 @@ SQL;
|
||||
}
|
||||
|
||||
/** @return array<FreshRSS_Category> */
|
||||
public function listCategoriesOrderUpdate(int $defaultCacheDuration = 86400, int $limit = 0) {
|
||||
public function listCategoriesOrderUpdate(int $defaultCacheDuration = 86400, int $limit = 0): array {
|
||||
$sql = 'SELECT * FROM `_category` WHERE kind = :kind AND `lastUpdate` < :lu ORDER BY `lastUpdate`'
|
||||
. ($limit < 1 ? '' : ' LIMIT ' . intval($limit));
|
||||
. ($limit < 1 ? '' : ' LIMIT ' . $limit);
|
||||
$stm = $this->pdo->prepare($sql);
|
||||
if ($stm &&
|
||||
$stm->bindValue(':kind', FreshRSS_Category::KIND_DYNAMIC_OPML, PDO::PARAM_INT) &&
|
||||
@@ -387,7 +387,7 @@ SQL;
|
||||
return $res[0]['count'];
|
||||
}
|
||||
|
||||
public function countFeed($id) {
|
||||
public function countFeed(int $id) {
|
||||
$sql = 'SELECT COUNT(*) AS count FROM `_feed` WHERE category=:id';
|
||||
$stm = $this->pdo->prepare($sql);
|
||||
$stm->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
@@ -396,7 +396,7 @@ SQL;
|
||||
return $res[0]['count'];
|
||||
}
|
||||
|
||||
public function countNotRead($id) {
|
||||
public function countNotRead(int $id) {
|
||||
$sql = 'SELECT COUNT(*) AS count FROM `_entry` e INNER JOIN `_feed` f ON e.id_feed=f.id WHERE category=:id AND e.is_read=0';
|
||||
$stm = $this->pdo->prepare($sql);
|
||||
$stm->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
@@ -409,7 +409,7 @@ SQL;
|
||||
* @param array<FreshRSS_Category> $categories
|
||||
* @param int $feed_id
|
||||
*/
|
||||
public static function findFeed($categories, $feed_id) {
|
||||
public static function findFeed(array $categories, int $feed_id) {
|
||||
foreach ($categories as $category) {
|
||||
foreach ($category->feeds() as $feed) {
|
||||
if ($feed->id() === $feed_id) {
|
||||
@@ -422,9 +422,8 @@ SQL;
|
||||
|
||||
/**
|
||||
* @param array<FreshRSS_Category> $categories
|
||||
* @param int $minPriority
|
||||
*/
|
||||
public static function CountUnreads($categories, $minPriority = 0) {
|
||||
public static function countUnread(array $categories, int $minPriority = 0): int {
|
||||
$n = 0;
|
||||
foreach ($categories as $category) {
|
||||
foreach ($category->feeds() as $feed) {
|
||||
|
||||
@@ -163,7 +163,7 @@ class FreshRSS_Context {
|
||||
// Update number of read / unread variables.
|
||||
$entryDAO = FreshRSS_Factory::createEntryDao();
|
||||
self::$total_starred = $entryDAO->countUnreadReadFavorites();
|
||||
self::$total_unread = FreshRSS_CategoryDAO::CountUnreads(
|
||||
self::$total_unread = FreshRSS_CategoryDAO::countUnread(
|
||||
self::$categories, 1
|
||||
);
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ function token($conf) {
|
||||
exit();
|
||||
}
|
||||
|
||||
function checkToken($conf, $token) {
|
||||
function checkToken(FreshRSS_UserConfiguration $conf, string $token) {
|
||||
//http://code.google.com/p/google-reader-api/wiki/ActionToken
|
||||
$user = Minz_Session::param('currentUser', '_');
|
||||
if ($user !== '_' && ( //TODO: Check security consequences
|
||||
|
||||
Reference in New Issue
Block a user