- Bugfix: fixed usernames being shown in the "Who is online" block after

you logged out.  Patch by Jeremy.

- Bugfix: fixed the authmap table in the MSSQL scheme.  Patch by Moshe.

- Bugfix: properly themes some error messages in the user module.  Patch
  by Moshe.
4.3.x
Dries Buytaert 2003-10-28 19:27:52 +00:00
parent fa37f47d0b
commit cf92958f3c
5 changed files with 39 additions and 83 deletions

View File

@ -20,7 +20,7 @@ CREATE TABLE [dbo].[accesslog] (
GO GO
CREATE TABLE [dbo].[authmap] ( CREATE TABLE [dbo].[authmap] (
[aid] [numeric](10, 0) NULL , [aid] [numeric](10, 0) IDENTITY NULL ,
[uid] [int] NOT NULL , [uid] [int] NOT NULL ,
[authname] [varchar] (128) NOT NULL , [authname] [varchar] (128) NOT NULL ,
[module] [varchar] (128) NOT NULL [module] [varchar] (128) NOT NULL

View File

@ -668,56 +668,32 @@ function statistics_display_online_block() {
/* count users with activity in the past defined period */ /* count users with activity in the past defined period */
$time_period = variable_get("statistics_block_online_time", 2700); $time_period = variable_get("statistics_block_online_time", 2700);
/* $guests = db_fetch_object(db_query("SELECT COUNT(DISTINCT sid) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0", time() - $time_period));
** This call gathers all the info we need on users/guests in a single $users = db_query("SELECT DISTINCT uid, MAX(timestamp) AS max_timestamp FROM {sessions} WHERE timestamp >= %d AND uid != 0 GROUP BY uid ORDER BY max_timestamp DESC", time() - $time_period );
** database call, thus is quite efficient. $total_users = db_affected_rows();
*/
$result = db_query("SELECT COUNT(DISTINCT hostname) AS count, uid, MAX(timestamp) AS max_timestamp FROM {accesslog} WHERE timestamp >= %d GROUP BY uid ORDER BY max_timestamp DESC", (time() - $time_period));
$users = $guests = 0;
/* Count number of users & guests currently online based on db query */
while ($users_online = db_fetch_array($result)) {
if ($users_online["uid"]) {
/* Has uid, so is a registered user */
$user_list[$users] = $users_online[uid];
$users++;
}
else {
/*
** There's only going to be one return with a uid of 0, and that's
** the guest(s). Hence, the count of this field is the total number
** of guests currently online.
*/
$guests = $users_online["count"];
}
}
/* format the output with proper grammar */ /* format the output with proper grammar */
if ($users == 1 && $guests == 1) { if ($total_users == 1 && $guests->count == 1) {
$output .= t("There is currently %members and %visitors online.", array("%members" => format_plural($users, "1 user", "%count users"), "%visitors" => format_plural($guests, "1 guest", "%count guests"))); $output .= t("There is currently %members and %visitors online.", array("%members" => format_plural($total_users, "1 user", "%count users"), "%visitors" => format_plural($guests->count, "1 guest", "%count guests")));
} }
else { else {
$output .= t("There are currently %members and %visitors online.", array("%members" => format_plural($users, "1 user", "%count users"), "%visitors" => format_plural($guests, "1 guest", "%count guests"))); $output .= t("There are currently %members and %visitors online.", array("%members" => format_plural($total_users, "1 user", "%count users"), "%visitors" => format_plural($guests->count, "1 guest", "%count guests")));
} }
if (user_access("access userlist") && $users) { if (user_access("access userlist") && $total_users) {
/* Display a list of currently online users */ /* Display a list of currently online users */
$max_users = variable_get("statistics_block_online_max_cnt", 10); $max_users = variable_get("statistics_block_online_max_cnt", 10);
$uid = reset($user_list); $items = array();
while (($uid) && ($max_users)) { while ($uid = db_fetch_object($users)) {
$user = user_load(array("uid" => $uid)); $user = user_load(array("uid" => $uid->uid));
/* When displaying name, be sure it's not more than defined max length */ /* Display only max_length characters of username */
$items[] = format_name($user); $items[] = format_name($user);
$uid = next($user_list);
/*
** When $max_users reaches zero, we break out even if there are
** more online (as defined by the admin)
*/
$max_users--;
} }
$output .= "<br /><br />"; if ($items) {
$output .= theme("theme_item_list", $items, variable_get("statistics_block_online_subtitle", "Online users:")); $output .= "<br /><br />";
$output .= theme("theme_item_list", $items, variable_get("statistics_block_online_subtitle", "Online users:"));
}
} }
} }
else { else {

View File

@ -668,56 +668,32 @@ function statistics_display_online_block() {
/* count users with activity in the past defined period */ /* count users with activity in the past defined period */
$time_period = variable_get("statistics_block_online_time", 2700); $time_period = variable_get("statistics_block_online_time", 2700);
/* $guests = db_fetch_object(db_query("SELECT COUNT(DISTINCT sid) AS count FROM {sessions} WHERE timestamp >= %d AND uid = 0", time() - $time_period));
** This call gathers all the info we need on users/guests in a single $users = db_query("SELECT DISTINCT uid, MAX(timestamp) AS max_timestamp FROM {sessions} WHERE timestamp >= %d AND uid != 0 GROUP BY uid ORDER BY max_timestamp DESC", time() - $time_period );
** database call, thus is quite efficient. $total_users = db_affected_rows();
*/
$result = db_query("SELECT COUNT(DISTINCT hostname) AS count, uid, MAX(timestamp) AS max_timestamp FROM {accesslog} WHERE timestamp >= %d GROUP BY uid ORDER BY max_timestamp DESC", (time() - $time_period));
$users = $guests = 0;
/* Count number of users & guests currently online based on db query */
while ($users_online = db_fetch_array($result)) {
if ($users_online["uid"]) {
/* Has uid, so is a registered user */
$user_list[$users] = $users_online[uid];
$users++;
}
else {
/*
** There's only going to be one return with a uid of 0, and that's
** the guest(s). Hence, the count of this field is the total number
** of guests currently online.
*/
$guests = $users_online["count"];
}
}
/* format the output with proper grammar */ /* format the output with proper grammar */
if ($users == 1 && $guests == 1) { if ($total_users == 1 && $guests->count == 1) {
$output .= t("There is currently %members and %visitors online.", array("%members" => format_plural($users, "1 user", "%count users"), "%visitors" => format_plural($guests, "1 guest", "%count guests"))); $output .= t("There is currently %members and %visitors online.", array("%members" => format_plural($total_users, "1 user", "%count users"), "%visitors" => format_plural($guests->count, "1 guest", "%count guests")));
} }
else { else {
$output .= t("There are currently %members and %visitors online.", array("%members" => format_plural($users, "1 user", "%count users"), "%visitors" => format_plural($guests, "1 guest", "%count guests"))); $output .= t("There are currently %members and %visitors online.", array("%members" => format_plural($total_users, "1 user", "%count users"), "%visitors" => format_plural($guests->count, "1 guest", "%count guests")));
} }
if (user_access("access userlist") && $users) { if (user_access("access userlist") && $total_users) {
/* Display a list of currently online users */ /* Display a list of currently online users */
$max_users = variable_get("statistics_block_online_max_cnt", 10); $max_users = variable_get("statistics_block_online_max_cnt", 10);
$uid = reset($user_list); $items = array();
while (($uid) && ($max_users)) { while ($uid = db_fetch_object($users)) {
$user = user_load(array("uid" => $uid)); $user = user_load(array("uid" => $uid->uid));
/* When displaying name, be sure it's not more than defined max length */ /* Display only max_length characters of username */
$items[] = format_name($user); $items[] = format_name($user);
$uid = next($user_list);
/*
** When $max_users reaches zero, we break out even if there are
** more online (as defined by the admin)
*/
$max_users--;
} }
$output .= "<br /><br />"; if ($items) {
$output .= theme("theme_item_list", $items, variable_get("statistics_block_online_subtitle", "Online users:")); $output .= "<br /><br />";
$output .= theme("theme_item_list", $items, variable_get("statistics_block_online_subtitle", "Online users:"));
}
} }
} }
else { else {

View File

@ -549,6 +549,7 @@ function user_get_authmaps($authname = NULL) {
} }
function user_set_authmaps($account, $authmaps) { function user_set_authmaps($account, $authmaps) {
foreach ($authmaps as $key => $value) { foreach ($authmaps as $key => $value) {
$module = explode("_", $key, 2); $module = explode("_", $key, 2);
if ($value) { if ($value) {
@ -1535,10 +1536,11 @@ function user_admin_edit($edit = array()) {
if ($edit["status"] == 0) { if ($edit["status"] == 0) {
db_query("DELETE FROM {users} WHERE uid = %d", $account->uid); db_query("DELETE FROM {users} WHERE uid = %d", $account->uid);
db_query("DELETE FROM {authmap} WHERE uid = %d", $account->uid); db_query("DELETE FROM {authmap} WHERE uid = %d", $account->uid);
$output .= t("The account has been deleted."); $output .= status(t("the account has been deleted."));
} }
else { else {
$output .= t("Failed to delete account: the account has to be blocked first."); $error = t("Failed to delete account: the account has to be blocked first.");
$output .= theme("theme_error", $error);
} }
} }

View File

@ -549,6 +549,7 @@ function user_get_authmaps($authname = NULL) {
} }
function user_set_authmaps($account, $authmaps) { function user_set_authmaps($account, $authmaps) {
foreach ($authmaps as $key => $value) { foreach ($authmaps as $key => $value) {
$module = explode("_", $key, 2); $module = explode("_", $key, 2);
if ($value) { if ($value) {
@ -1535,10 +1536,11 @@ function user_admin_edit($edit = array()) {
if ($edit["status"] == 0) { if ($edit["status"] == 0) {
db_query("DELETE FROM {users} WHERE uid = %d", $account->uid); db_query("DELETE FROM {users} WHERE uid = %d", $account->uid);
db_query("DELETE FROM {authmap} WHERE uid = %d", $account->uid); db_query("DELETE FROM {authmap} WHERE uid = %d", $account->uid);
$output .= t("The account has been deleted."); $output .= status(t("the account has been deleted."));
} }
else { else {
$output .= t("Failed to delete account: the account has to be blocked first."); $error = t("Failed to delete account: the account has to be blocked first.");
$output .= theme("theme_error", $error);
} }
} }