From bf9cc9ad9526471551b057e6390f6c040599e531 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 12 Aug 2015 20:19:38 +0300 Subject: [PATCH] combine user edit & user details --- classes/pref/users.php | 172 +++++++++++++++++++++-------------------- js/functions.js | 21 ----- js/prefs.js | 1 - 3 files changed, 87 insertions(+), 107 deletions(-) diff --git a/classes/pref/users.php b/classes/pref/users.php index 89554ba6..a10404d0 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -17,89 +17,16 @@ class Pref_Users extends Handler_Protected { return array_search($method, $csrf_ignored) !== false; } - function userdetails() { - - $uid = sprintf("%d", $_REQUEST["id"]); - - $result = $this->dbh->query("SELECT login, - ".SUBSTRING_FOR_DATE."(last_login,1,16) AS last_login, - access_level, - (SELECT COUNT(int_id) FROM ttrss_user_entries - WHERE owner_uid = id) AS stored_articles, - ".SUBSTRING_FOR_DATE."(created,1,16) AS created - FROM ttrss_users - WHERE id = '$uid'"); - - if ($this->dbh->num_rows($result) == 0) { - print "

".__('User not found')."

"; - return; - } - - print ""; - - $last_login = make_local_datetime( - $this->dbh->fetch_result($result, 0, "last_login"), true); - - $created = make_local_datetime( - $this->dbh->fetch_result($result, 0, "created"), true); - - $stored_articles = $this->dbh->fetch_result($result, 0, "stored_articles"); - - print ""; - print ""; - - $result = $this->dbh->query("SELECT COUNT(id) as num_feeds FROM ttrss_feeds - WHERE owner_uid = '$uid'"); - - $num_feeds = $this->dbh->fetch_result($result, 0, "num_feeds"); - - print ""; - print ""; - - print "
".__('Registered')."$created
".__('Last logged in')."$last_login
".__('Subscribed feeds count')."$num_feeds
".__('Stored articles')."$stored_articles
"; - - print "

".__('Subscribed feeds')."

"; - - $result = $this->dbh->query("SELECT id,title,site_url FROM ttrss_feeds - WHERE owner_uid = '$uid' ORDER BY title"); - - print ""; - - print "
-
"; - - return; - } - function edit() { global $access_level_names; - $id = $this->dbh->escape_string($_REQUEST["id"]); + print '
+
'; + print "
"; + $id = (int) $this->dbh->escape_string($_REQUEST["id"]); + print ""; print ""; print ""; @@ -121,7 +48,7 @@ class Pref_Users extends Handler_Protected { print ""; print "
"; @@ -142,7 +69,7 @@ class Pref_Users extends Handler_Protected { print "
"; - print ""; print "
"; @@ -150,7 +77,7 @@ class Pref_Users extends Handler_Protected { print "
".__("Options")."
"; print "
"; - print ""; print "
"; @@ -159,15 +86,92 @@ class Pref_Users extends Handler_Protected { print ""; + print ''; #tab + print "
"; + + print '
'; + print ''; + print "
+ __('Save')."
"; + __('Cancel').""; return; } + function userdetails() { + $id = (int) $this->dbh->escape_string($_REQUEST["id"]); + + $result = $this->dbh->query("SELECT login, + ".SUBSTRING_FOR_DATE."(last_login,1,16) AS last_login, + access_level, + (SELECT COUNT(int_id) FROM ttrss_user_entries + WHERE owner_uid = id) AS stored_articles, + ".SUBSTRING_FOR_DATE."(created,1,16) AS created + FROM ttrss_users + WHERE id = '$id'"); + + if ($this->dbh->num_rows($result) == 0) { + print "

".__('User not found')."

"; + return; + } + + print ""; + + $last_login = make_local_datetime( + $this->dbh->fetch_result($result, 0, "last_login"), true); + + $created = make_local_datetime( + $this->dbh->fetch_result($result, 0, "created"), true); + + $stored_articles = $this->dbh->fetch_result($result, 0, "stored_articles"); + + print ""; + print ""; + + $result = $this->dbh->query("SELECT COUNT(id) as num_feeds FROM ttrss_feeds + WHERE owner_uid = '$id'"); + + $num_feeds = $this->dbh->fetch_result($result, 0, "num_feeds"); + + print ""; + print ""; + + print "
".__('Registered')."$created
".__('Last logged in')."$last_login
".__('Subscribed feeds count')."$num_feeds
".__('Stored articles')."$stored_articles
"; + + print "

".__('Subscribed feeds')."

"; + + $result = $this->dbh->query("SELECT id,title,site_url FROM ttrss_feeds + WHERE owner_uid = '$id' ORDER BY title"); + + print ""; + } + function editSave() { $login = $this->dbh->escape_string(trim($_REQUEST["login"])); $uid = $this->dbh->escape_string($_REQUEST["id"]); @@ -338,8 +342,6 @@ class Pref_Users extends Handler_Protected { print ""; print " -