aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2019-12-03 22:32:17 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-12-03 22:32:17 +0100
commit0de7e84380dff5222e6728aacbbb42abaac51dd9 (patch)
tree07eba3a6070f11fd966c9f257aa652b6f6242eed /app/Models
parent68c006b7ad61d0730a3aa8f75c6232c00d0f14e1 (diff)
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
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/FeedDAO.php33
-rw-r--r--app/Models/FeedDAOSQLite.php1
2 files changed, 33 insertions, 1 deletions
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;
}
-
}