This patch displays a user list on the logon screen. This is quite useful as people do tend to forget their 4-digit usemod user account ID. However, once they set a UserName?, they can recover the UserId? from this user list. This eliminates a lot of duplicate user ID's, and prevents the user database from growing too large. -- UngarPeter
--- wiki.pl 2005-09-17 10:17:20.000000000 +0200 +++ UserList.pl 2005-10-07 16:56:11.000000000 +0200 @@ -2577,15 +2577,23 @@ } sub LoadUserData { - my ($data, $status); - - %UserData = (); - ($status, $data) = &ReadFile(&UserDataFilename($UserID)); - if (!$status) { + %UserData = LoadUserDataById($UserID); + if ( 0 == scalar %UserData) { $UserID = 112; # Could not open file. Consider warning message? return; } - %UserData = split(/$FS1/, $data, -1); # -1 keeps trailing null fields +} + +sub LoadUserDataById { + my ($id) = @_; + my ($data, $status, %userdata); + + %userdata = (); + ($status, $data) = &ReadFile(&UserDataFilename($id)); + if ($status) { + %userdata = split(/$FS1/, $data, -1); # -1 keeps trailing null fields + } + return %userdata; } sub UserDataFilename { @@ -3111,6 +3119,8 @@ &DoEditLinks(); } elsif ($action eq "login") { &DoEnterLogin(); + } elsif ($action eq "userlist") { + &DoUserList(); } elsif ($action eq "newlogin") { $UserID = 0; &DoEditPrefs(); # Also creates new ID @@ -3599,6 +3609,26 @@ print &GetCommonFooter(); } +sub GetAllUsersTable() { + my ($result, $i, %userdata); + + $result = "<table border=0>\n"; + for ($i= $StartUID; ; ++$i) { + %userdata = &LoadUserDataById($i); + last unless scalar %userdata; + $result .= "<tr><td>$i </td> <td>$userdata{username}</td></tr>\n" if $userdata{username}; + } + $result .= "</table>\n"; + return $result; +} + +sub DoUserList { + print &GetHeader('', T('List of all users'), ''); + print '<br>'; + print &GetAllUsersTable(); + print &GetCommonFooter(); +} + # Create a new user file/cookie pair sub DoNewLogin { # Consider warning if cookie already exists @@ -3630,6 +3660,7 @@ print "<hr class=wikilinefooter>\n"; print &GetGotoBar(''); print $q->endform; + print &GetAllUsersTable(); print &GetMinimumFooter(); }