Skip to content

Commit

Permalink
Merge pull request #11 from C4K3/master
Browse files Browse the repository at this point in the history
Fix usernames appearing in all lowercase
  • Loading branch information
Digitalroot committed Aug 17, 2016
2 parents 49ef6a9 + 65dfc4e commit c6cdb2c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Auth_phpbb.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ class Auth_phpBB extends AuthPlugin implements iAuthPlugin
*/
private $_WikiGroupName;

/**
* Whether to set usernames from the
* username_clean (false) colum or username
* (true) column in the phpbb users tables.
* Should be true in most cases, is added for
* legacy support due to previous versions
* setting usernames to lowercase.
*
* @var bool
*/
private $_UseCanonicalCase;

/**
* Constructor
*
Expand All @@ -234,6 +246,13 @@ function __construct($aConfig)
$this->_WikiGroupName = $aConfig['WikiGroupName'];
$this->_LoginMessage = $aConfig['LoginMessage'];

// If undefined (i.e. user is using an old config) set to false
if (isset($aConfig['UseCanonicalCase'])) {
$this->_UseCanonicalCase = $aConfig['UseCanonicalCase'];
} else {
$this->_UseCanonicalCase = false;
}

// Only assign the database values if a external database is used.
if ($this->_UseExtDatabase == true)
{
Expand Down Expand Up @@ -478,10 +497,10 @@ public function getCanonicalName( $username )
$username = $fresMySQLConnection->escape_string($username);

// Check Database for username. We will return the correct casing of the name.
$fstrMySQLQuery = sprintf("SELECT `username_clean`
$fstrMySQLQuery = sprintf("SELECT `%s`
FROM `%s`
WHERE `username_clean` = ?
LIMIT 1", $this->_UserTB);
LIMIT 1", ($this->_UseCanonicalCase ? "username" : "username_clean"), $this->_UserTB);

// Query Database.
$fresStatement = $fresMySQLConnection->prepare($fstrMySQLQuery);
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ Open LocalSettings.php. Put this at the bottom of the file. Edit as needed.
require_once './extensions/Auth_phpbb.php';
$wgAuth_Config = array(); // Clean.

$wgAuth_Config['UseCanonicalCase'] = true; // Setting this to true causes the mediawiki usernames
// to match the casing of the phpbb ones (except with
// the first letter set uppercase.)
// Setting this to false causes usernames to be all
// lowercase except for the first character.
// Before June 2016 this setting was always false,
// changing it to true on an install where it previously
// was false will cause users with uppercase characters
// to appear as separate users from their previous
// all-lowercase account.
$wgAuth_Config['WikiGroupName'] = 'Wiki'; // Name of your PHPBB group
// users need to be a member
Expand Down

0 comments on commit c6cdb2c

Please sign in to comment.