About

It's a macro called UserList that lists all usernames stored in the database. It's invoked just like any other macro: [[UserList]]

Update: small fix to the SQL query to not return the empty username.

Note: This may not be obvious, so I'll state it; the usernames are taken from the page versions. Therefore, you don't get all the usernames ever used, but only those attached to page versions still not expired. If your wiki's expiration period is 2 weeks, you get a user list for all the people who contributen within the latest 2 weeks, nothing more.

Installation

In lib/defaults.php, locate the ViewMacroEngine array and add the entry: 'UserList' => 'view_macro_userlist'. The code should look like the following:


$ViewMacroEngine = array(
                     //...
                     'UserList'         => 'view_macro_userlist'
                   );

Copy and paste the following code into parse/macros.php:


function view_macro_userlist() {
  global $pagestore, $PgTbl;

  $first = true;

  $query = $pagestore->dbh->query("SELECT DISTINCT(`username`) FROM $PgTbl WHERE `username` != '' ORDER BY `username`");

  while (($result = $pagestore->dbh->result($query))) {
    if ($first) {
      $first = false;
      $text = html_ul_start() . "\n";
    }

    $text .= html_li_start() . html_ref($result[0], $result[0]) . html_li_end();
  }

  if ($text) {
    $text .= html_ul_end() . "\n";
  }

  return ($text);
}

Comments

If there's enough demand for it, I can modify the code to include CurlyOptions that customize the output (unless someone else would like to try it). --PaulBernays