From 0de7e84380dff5222e6728aacbbb42abaac51dd9 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Tue, 3 Dec 2019 22:32:17 +0100 Subject: Upgrade user management page (#2417) Before, the use of the user management page was a little bit tedious when there was many users. One must select a user to view some metrics, to update it, or to delete it. Now, the view is clearer because it shows all users at once with their metrics. I introduced a detail page that repeats the metrics but also allow to purge the user's feeds, to update or delete the user. This is the first step to make that page more useful and user-friendly. I have in mind to add a pager for when there is a lot of users, a metric to know when was the last time the user was using the application, and a flag to know if the user has admin rights. See #2096 and #2504 for ideas and inspiration --- app/Models/FeedDAO.php | 33 +++++++++++++++++++++++++++++++++ app/Models/FeedDAOSQLite.php | 1 - 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'app/Models') diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 2bff50d52..417b37773 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -421,6 +421,29 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $affected; } + public function purge() { + $sql = 'DELETE FROM `_entry`'; + $stm = $this->pdo->prepare($sql); + $this->pdo->beginTransaction(); + if (!($stm && $stm->execute())) { + $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + Minz_Log::error('SQL error truncate: ' . $info[2]); + $this->pdo->rollBack(); + return false; + } + + $sql = 'UPDATE `_feed` SET `cache_nbEntries` = 0, `cache_nbUnreads` = 0'; + $stm = $this->pdo->prepare($sql); + if (!($stm && $stm->execute())) { + $info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo(); + Minz_Log::error('SQL error truncate: ' . $info[2]); + $this->pdo->rollBack(); + return false; + } + + $this->pdo->commit(); + } + public static function daoToFeed($listDAO, $catID = null) { $list = array(); @@ -481,4 +504,14 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $stm->execute(array(':new_value' => -3600, ':old_value' => -1)); } } + + public function count() { + $sql = 'SELECT COUNT(e.id) AS count FROM `_feed` e'; + $stm = $this->pdo->query($sql); + if ($stm == false) { + return false; + } + $res = $stm->fetchAll(PDO::FETCH_COLUMN, 0); + return isset($res[0]) ? $res[0] : 0; + } } diff --git a/app/Models/FeedDAOSQLite.php b/app/Models/FeedDAOSQLite.php index 0f685867a..397b69941 100644 --- a/app/Models/FeedDAOSQLite.php +++ b/app/Models/FeedDAOSQLite.php @@ -13,5 +13,4 @@ class FreshRSS_FeedDAOSQLite extends FreshRSS_FeedDAO { } return false; } - } -- cgit v1.2.3