Auth_PHPBB: My modification

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php|uber.leet Forum Index // General
View previous topic :: View next topic  
Author Message
Miguelon



Joined: 15 Mar 2009
Posts: 1

PostPosted: Sun Mar 15, 2009 4:52 pm    Post subject: Auth_PHPBB: My modification Reply with quote
Hi, (first, sorry for my English, i'm spanish)

I have made some modifications to make Auth_phpBB to add user to sysop's groups if the user is Moderator or Administrator at phpBB

In LocalSettings.php file:
After the line containing $wgAuth_Config['WikiAdminGroupName'] add this:

Code:
$wgAuth_Config['WikiAdminGroupName'] = array('GLOBAL_MODERATORS', 'ADMINISTRATORS'); // default phpBB's Admin and moderator groups, you can add your own groups


Then, in Auth_phpBB.php file:

* After the line containing private $_WikiGroupName add this:
Code:
private $_WikiAdminGroupName;


* Into function __construct($aConfig) add this:
Code:
$this->_WikiAdminGroupName   = $aConfig['WikiAdminGroupName'];


* Modify function initUser, after this:
Code:
while($faryMySQLResult = mysql_fetch_array($fresMySQLResult))
{
    $user->mEmail       = $faryMySQLResult['user_email']; // Set Email Address.
    $user->mRealName    = 'I need to Update My Profile';  // Set Real Name.
}

add this:
Code:
$username = mysql_real_escape_string($username, $fresMySQLConnection); // Clean username.

// If not an array make this an array.
if (!is_array($this->_WikiAdminGroupName))
{
    $this->_WikiAdminGroupName = array($this->_WikiAdminGroupName);
}

foreach ($this->_WikiAdminGroupName as $WikiAdminGrpName)
{
    // Get UserId
    mysql_query('SELECT @userId := `user_id` FROM `' . $this->_UserTB .
                '` WHERE `username_clean` = \'' . $username . '\';', $fresMySQLConnection)
                or die($this->mySQLError('Unable to get userID.'));

    // Get WikiId
    mysql_query('SELECT @wikiId := `group_id` FROM `' . $this->_GroupsTB .
                '` WHERE `group_name` = \'' . $WikiAdminGrpName . '\';', $fresMySQLConnection)
                or die($this->mySQLError('Unable to get wikiID.'));

    // Check UserId and WikiId
    mysql_query('SELECT @isThere := COUNT( * ) FROM `' . $this->_User_GroupTB .
                '` WHERE `user_id` = @userId AND `group_id` = @wikiId and `user_pending` = 0;', $fresMySQLConnection)
                or die($this->mySQLError('Unable to get validate user group.'));

    // Return Result.
    $fstrMySQLQuery = 'SELECT IF(@isThere > 0, \'true\', \'false\') AS `result`;';

    // Query Database.
    $fresMySQLResult = mysql_query($fstrMySQLQuery, $fresMySQLConnection)
        or die($this->mySQLError('Unable to view external table'));

    // Check for a true or false response.
    while($faryMySQLResult = mysql_fetch_array($fresMySQLResult))
    {
        if ($faryMySQLResult['result'] == 'true')
        {
            $user->addGroup('sysop'); // Add User to Wiki Admin group.
            //$user->addGroup('bureaucrat'); // Add User to Wiki Admin group (UNSECURE, this group is Superadmin group).
        }
    }
}


And that's all, after this modification, when a user that it's not on wiki DB and it's at the phpBB groups specified in $wgAuth_Config['WikiAdminGroupName'], Auth_phpBB add the user to Admin groups.

I hope that this can help to you, thanks for this Extension, i's great
Back to top
View user's profile Send private message
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php|uber.leet Forum Index // General All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

alexisBlue v1.2 // Theme Created By: Andrew Charron and Web Hosting Bluebook
Powered by phpBB © 2001, 2002 phpBB Group