mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-08-06 22:27:42 +02:00
Use ORM in remaining parts of 'Pref_Users'.
This commit is contained in:
parent
cdd48bb1fa
commit
adf71f09a9
@ -6,7 +6,7 @@ class Pref_Users extends Handler_Administrative {
|
|||||||
|
|
||||||
function edit(): void {
|
function edit(): void {
|
||||||
$user = ORM::for_table('ttrss_users')
|
$user = ORM::for_table('ttrss_users')
|
||||||
->select_expr("id,login,access_level,email,full_name,otp_enabled")
|
->select_many('id', 'login', 'access_level', 'email', 'full_name', 'otp_enabled')
|
||||||
->find_one((int)$_REQUEST["id"])
|
->find_one((int)$_REQUEST["id"])
|
||||||
->as_array();
|
->as_array();
|
||||||
|
|
||||||
@ -23,30 +23,25 @@ class Pref_Users extends Handler_Administrative {
|
|||||||
function userdetails(): void {
|
function userdetails(): void {
|
||||||
$id = (int) clean($_REQUEST["id"]);
|
$id = (int) clean($_REQUEST["id"]);
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT login,
|
$user = ORM::for_table('ttrss_users')
|
||||||
SUBSTRING_FOR_DATE(last_login,1,16) AS last_login,
|
->table_alias('u')
|
||||||
access_level,
|
->select_many('u.login', 'u.access_level')
|
||||||
(SELECT COUNT(int_id) FROM ttrss_user_entries
|
->select_many_expr([
|
||||||
WHERE owner_uid = id) AS stored_articles,
|
'created' => 'SUBSTRING_FOR_DATE(u.created,1,16)',
|
||||||
SUBSTRING_FOR_DATE(created,1,16) AS created
|
'last_login' => 'SUBSTRING_FOR_DATE(u.last_login,1,16)',
|
||||||
FROM ttrss_users
|
'stored_articles' => '(SELECT COUNT(ue.int_id) FROM ttrss_user_entries ue WHERE ue.owner_uid = u.id)',
|
||||||
WHERE id = ?");
|
])
|
||||||
$sth->execute([$id]);
|
->find_one($id);
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
if ($user) {
|
||||||
|
$created = TimeHelper::make_local_datetime($user->created);
|
||||||
|
$last_login = TimeHelper::make_local_datetime($user->last_login);
|
||||||
|
|
||||||
$last_login = TimeHelper::make_local_datetime($row['last_login']);
|
$user_owned_feeds = ORM::for_table('ttrss_feeds')
|
||||||
|
->select_many('id', 'title', 'site_url')
|
||||||
$created = TimeHelper::make_local_datetime($row['created']);
|
->where('owner_uid', $id)
|
||||||
|
->order_by_expr('LOWER(title)')
|
||||||
$stored_articles = $row["stored_articles"];
|
->find_many();
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("SELECT COUNT(id) as num_feeds FROM ttrss_feeds
|
|
||||||
WHERE owner_uid = ?");
|
|
||||||
$sth->execute([$id]);
|
|
||||||
$row = $sth->fetch();
|
|
||||||
|
|
||||||
$num_feeds = $row["num_feeds"];
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -62,31 +57,25 @@ class Pref_Users extends Handler_Administrative {
|
|||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label><?= __('Subscribed feeds') ?>:</label>
|
<label><?= __('Subscribed feeds') ?>:</label>
|
||||||
<?= $num_feeds ?>
|
<?= count($user_owned_feeds) ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label><?= __('Stored articles') ?>:</label>
|
<label><?= __('Stored articles') ?>:</label>
|
||||||
<?= $stored_articles ?>
|
<?= $user->stored_articles ?>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<?php
|
|
||||||
$sth = $this->pdo->prepare("SELECT id,title,site_url FROM ttrss_feeds
|
|
||||||
WHERE owner_uid = ? ORDER BY title");
|
|
||||||
$sth->execute([$id]);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<ul class="panel panel-scrollable list list-unstyled">
|
<ul class="panel panel-scrollable list list-unstyled">
|
||||||
<?php while ($row = $sth->fetch()) { ?>
|
<?php foreach ($user_owned_feeds as $feed) { ?>
|
||||||
<li>
|
<li>
|
||||||
<?php
|
<?php
|
||||||
$icon_url = Feeds::_get_icon_url($row['id'], 'images/blank_icon.gif');
|
$icon_url = Feeds::_get_icon_url($feed->id, 'images/blank_icon.gif');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<img class="icon" src="<?= htmlspecialchars($icon_url) ?>">
|
<img class="icon" src="<?= htmlspecialchars($icon_url) ?>">
|
||||||
|
|
||||||
<a target="_blank" href="<?= htmlspecialchars($row["site_url"]) ?>">
|
<a target="_blank" href="<?= htmlspecialchars($feed->site_url) ?>">
|
||||||
<?= htmlspecialchars($row["title"]) ?>
|
<?= htmlspecialchars($feed->title) ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -134,14 +123,9 @@ class Pref_Users extends Handler_Administrative {
|
|||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
if ($id != $_SESSION["uid"] && $id != 1) {
|
if ($id != $_SESSION["uid"] && $id != 1) {
|
||||||
$sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE owner_uid = ?");
|
ORM::for_table('ttrss_tags')->where('owner_uid', $id)->delete_many();
|
||||||
$sth->execute([$id]);
|
ORM::for_table('ttrss_feeds')->where('owner_uid', $id)->delete_many();
|
||||||
|
ORM::for_table('ttrss_users')->where('id', $id)->delete_many();
|
||||||
$sth = $this->pdo->prepare("DELETE FROM ttrss_feeds WHERE owner_uid = ?");
|
|
||||||
$sth->execute([$id]);
|
|
||||||
|
|
||||||
$sth = $this->pdo->prepare("DELETE FROM ttrss_users WHERE id = ?");
|
|
||||||
$sth->execute([$id]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user