From a3cccc85e64b6ce83625310b8e8e632a4e1f967a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 20 Apr 2011 14:50:50 +0000 Subject: [PATCH] - web: show "logged in as" info on every page; remove funky "log out" link from user page - web: go to home page on logout, not dorky "you are logged out" page svn path=/trunk/boinc/; revision=23387 --- checkin_notes | 18 +++++++++++++++++- html/inc/user.inc | 1 - html/inc/util.inc | 26 ++++++++++++++++++++------ html/project.sample/project.inc | 6 +----- html/user/logout.php | 2 ++ html/user/sample_index.php | 8 ++++++++ 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/checkin_notes b/checkin_notes index 721643a77b..d6fdc30a6f 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2337,7 +2337,7 @@ David 19 Apr 2011 sched_types.cpp David 19 Apr 2011 - - admin web: all specifying an SVN config dir in the web config file, + - admin web: allow specifying an SVN config dir in the web config file, in case your svn requires a proxy or something. From Boris Dayma. @@ -2346,3 +2346,19 @@ David 19 Apr 2011 index.php project.sample/ project.inc + +David 20 Apr 2011 + - web: show "logged in as" info on every page; + remove funky "log out" link from user page + - web: go to home page on logout, + not dorky "you are logged out" page + + html/ + inc/ + user.inc + util.inc + user/ + sample_index.php + logout.php + project.sample/ + project.inc diff --git a/html/inc/user.inc b/html/inc/user.inc index 9060d9c5a3..8982bb393a 100644 --- a/html/inc/user.inc +++ b/html/inc/user.inc @@ -211,7 +211,6 @@ function show_user_info_private($user) { | ".tra("password")." | ".tra("other account info")."" ); - row2("", "".tra("Log out").""); row2(tra("User ID")."
".tra("Used in community functions")."", $user->id); if (!no_computing()) { row2(tra("Account key")."
".tra("Provides full access to your account")."", $user->authenticator); diff --git a/html/inc/util.inc b/html/inc/util.inc index b19f336632..24275f2ff5 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -72,10 +72,11 @@ function get_user_from_id($id) { } $g_logged_in_user = null; +$got_logged_in_user = false; function get_logged_in_user($must_be_logged_in=true) { - global $g_logged_in_user; - if ($g_logged_in_user) return $g_logged_in_user; + global $g_logged_in_user, $got_logged_in_user;; + if ($got_logged_in_user) return $g_logged_in_user; check_web_stopped(); @@ -101,13 +102,23 @@ function get_logged_in_user($must_be_logged_in=true) { return $g_logged_in_user; } -function show_login($user) { +function show_login_info() { + $user = get_logged_in_user(false); + echo " + + + +
+ "; if ($user) { - echo tra("Logged in as %1.", $user->name)."\n"; - echo "
".tra("Log in as someone else.")."\n"; + $url_tokens = url_tokens($user->authenticator); + echo "$user->name | ".tra("log out").""; } else { - echo tra("Not logged in."); + echo "".tra("log in").""; } + echo " +
+ "; } $cache_control_extra=""; @@ -154,7 +165,10 @@ function page_head( echo ""; } display_cvs_versions(); + project_banner($title, $prefix); + show_login_info(); + } } diff --git a/html/project.sample/project.inc b/html/project.sample/project.inc index 27038db220..5e782281c8 100644 --- a/html/project.sample/project.inc +++ b/html/project.sample/project.inc @@ -40,11 +40,7 @@ function project_banner($title, $prefix) { // Put your project title and logo here // If you include any links, prepend URL with $prefix - echo " -

-

$title
-

- "; + echo "

$title
"; } function project_footer($show_return, $show_date, $prefix) { diff --git a/html/user/logout.php b/html/user/logout.php index b98bc98058..2e896f3f44 100644 --- a/html/user/logout.php +++ b/html/user/logout.php @@ -26,6 +26,8 @@ $user = get_logged_in_user(); if ($user) { check_tokens($user->authenticator); clear_cookie('auth'); + $g_logged_in_user = null; + header("Location: index.php"); page_head("Logged out"); echo "You are now logged out"; page_tail(); diff --git a/html/user/sample_index.php b/html/user/sample_index.php index c82f8c4a97..03e5260203 100644 --- a/html/user/sample_index.php +++ b/html/user/sample_index.php @@ -98,6 +98,14 @@ include 'schedulers.txt'; echo "
".PROJECT."
+"; + +if (!$stopped) { + get_logged_in_user(false); + show_login_info(); +} + +echo "
";