From: Andrew Dolgov Date: Thu, 18 Sep 2008 04:53:36 +0000 (+0100) Subject: move user details to pref-users; code cleanup X-Git-Tag: 1.2.27~4 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=5a437c88d78ab42fa17ba29176be58e46561b4c6;p=tt-rss.git move user details to pref-users; code cleanup --- diff --git a/backend.php b/backend.php index d5f9741a..fa116458 100644 --- a/backend.php +++ b/backend.php @@ -417,126 +417,6 @@ "; break; // globalUpdateFeeds - case "user-details": - - if (WEB_DEMO_MODE || $_SESSION["access_level"] < 10) { - return; - } - - /* - print " - Tiny Tiny RSS : User Details - - - "; - */ - - $uid = sprintf("%d", $_GET["id"]); - - print "
User details
"; - - print "
"; - - $result = db_query($link, "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 (db_num_rows($result) == 0) { - print "

User not found

"; - return; - } - - // print "

User Details

"; - - $login = db_fetch_result($result, 0, "login"); - - // print "

$login

"; - - print ""; - - $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), - strtotime(db_fetch_result($result, 0, "last_login"))); - - $created = date(get_pref($link, 'LONG_DATE_FORMAT'), - strtotime(db_fetch_result($result, 0, "created"))); - - $access_level = db_fetch_result($result, 0, "access_level"); - $stored_articles = db_fetch_result($result, 0, "stored_articles"); - - // print ""; - // print ""; - print ""; - print ""; - print ""; - - $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds - WHERE owner_uid = '$uid'"); - - $num_feeds = db_fetch_result($result, 0, "num_feeds"); - - print ""; - - /* - $result = db_query($link, "SELECT - SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size - FROM ttrss_user_entries,ttrss_entries - WHERE owner_uid = '$uid' AND ref_id = id"); - - $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); - - print ""; - */ - - print "
Username$login
Access level$access_level
".__('Registered')."$created
".__('Last logged in')."$last_login
".__('Stored articles')."$stored_articles
".__('Subscribed feeds count')."$num_feeds
Approx. used DB size$db_size KBytes
"; - - print "

".__('Subscribed feeds')."

"; - - $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds - WHERE owner_uid = '$uid' ORDER BY title"); - - print ""; - - print "
"; - - print "
-
"; - - // print ""; - - break; // user-details - case "pref-feed-browser": module_pref_feed_browser($link); break; // pref-feed-browser diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index e54e7458..f86dd3db 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -452,7 +452,6 @@ } print ""; - print ""; print "
"; diff --git a/modules/pref-users.php b/modules/pref-users.php index 7d6c369f..06192703 100644 --- a/modules/pref-users.php +++ b/modules/pref-users.php @@ -10,6 +10,113 @@ $subop = $_GET["subop"]; + if ($subop == "user-details") { + + $uid = sprintf("%d", $_GET["id"]); + + print "
User details
"; + + print "
"; + + $result = db_query($link, "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 (db_num_rows($result) == 0) { + print "

User not found

"; + return; + } + + // print "

User Details

"; + + $login = db_fetch_result($result, 0, "login"); + + // print "

$login

"; + + print ""; + + $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'), + strtotime(db_fetch_result($result, 0, "last_login"))); + + $created = date(get_pref($link, 'LONG_DATE_FORMAT'), + strtotime(db_fetch_result($result, 0, "created"))); + + $access_level = db_fetch_result($result, 0, "access_level"); + $stored_articles = db_fetch_result($result, 0, "stored_articles"); + + // print ""; + // print ""; + print ""; + print ""; + print ""; + + $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds + WHERE owner_uid = '$uid'"); + + $num_feeds = db_fetch_result($result, 0, "num_feeds"); + + print ""; + + /* + $result = db_query($link, "SELECT + SUM(LENGTH(content)+LENGTH(title)+LENGTH(link)+LENGTH(guid)) AS db_size + FROM ttrss_user_entries,ttrss_entries + WHERE owner_uid = '$uid' AND ref_id = id"); + + $db_size = round(db_fetch_result($result, 0, "db_size") / 1024); + + print ""; + */ + + print "
Username$login
Access level$access_level
".__('Registered')."$created
".__('Last logged in')."$last_login
".__('Stored articles')."$stored_articles
".__('Subscribed feeds count')."$num_feeds
Approx. used DB size$db_size KBytes
"; + + print "

".__('Subscribed feeds')."

"; + + $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds + WHERE owner_uid = '$uid' ORDER BY title"); + + print "
    "; + + $row_class = "odd"; + + while ($line = db_fetch_assoc($result)) { + + $icon_file = ICONS_URL."/".$line["id"].".ico"; + + if (file_exists($icon_file) && filesize($icon_file) > 0) { + $feed_icon = ""; + } else { + $feed_icon = ""; + } + + print "
  • $feed_icon ".$line["title"]."
  • "; + + $row_class = toggleEvenOdd($row_class); + + } + + if (db_num_rows($result) < $num_feeds) { + // FIXME - add link to show ALL subscribed feeds here somewhere + print "
  •  ...
  • "; + } + + print "
"; + + print "
+
"; + + print "
"; + + return; + } + if ($subop == "edit") { $id = db_escape_string($_GET["id"]); diff --git a/prefs.js b/prefs.js index 4f315297..ca205237 100644 --- a/prefs.js +++ b/prefs.js @@ -1113,7 +1113,7 @@ function selectedUserDetails() { var id = rows[0]; - xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true); + xmlhttp.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id, true); xmlhttp.onreadystatechange=infobox_callback; xmlhttp.send(null);