Im working on the phpbb Single-Signon extension and I wanted to amke it so that users who are moderators are automatically made sysops on the wiki.
Other than modifying the database, is there any way in code to make a user a sysop (without having it done by a bureaucrat)?
It looks like the way to do it would be to run a query like so:
$user = User::newFromName( $userName );
$dbw = wfGetDB( DB_MASTER );
$dbw->insert( 'user_groups', array( 'ug_user' => $user->getID(), 'ug_group' => 'bot', ), 'User::addGroup', array( 'IGNORE' ) );
But if I am not logged in, this does not seem to work.
Any ideas?
On Jun 19, 2011, at 8:55 PM, Adam Meyer wrote:
Im working on the phpbb Single-Signon extension and I wanted to amke it so that users who are moderators are automatically made sysops on the wiki.
Other than modifying the database, is there any way in code to make a user a sysop (without having it done by a bureaucrat)? _______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
On Mon, Jun 20, 2011 at 5:29 AM, Adam Meyer meyer7@mindspring.com wrote:
It looks like the way to do it would be to run a query like so:
$user = User::newFromName( $userName );
$dbw = wfGetDB( DB_MASTER );
$dbw->insert( 'user_groups', array( 'ug_user' => $user->getID(), 'ug_group' => 'bot', ), 'User::addGroup', array( 'IGNORE' ) );
Never run queries on the database when you can use wrapper methods. Use this instead:
$user = User::newFromName( $name ); $user->addGroup( 'sysop' );
This is actually what I tried first.
The problem is that User::addGroup does security checks and checks a "addable" array that is a list of groups you are allowed to add someone too. So non sysops can not add add themselves to the sysop group.
On Jun 20, 2011, at 6:52 AM, Łukasz Garczewski wrote:
On Mon, Jun 20, 2011 at 5:29 AM, Adam Meyer meyer7@mindspring.com wrote:
It looks like the way to do it would be to run a query like so:
$user = User::newFromName( $userName );
$dbw = wfGetDB( DB_MASTER );
$dbw->insert( 'user_groups', array( 'ug_user' => $user->getID(), 'ug_group' => 'bot', ), 'User::addGroup', array( 'IGNORE' ) );
Never run queries on the database when you can use wrapper methods. Use this instead:
$user = User::newFromName( $name ); $user->addGroup( 'sysop' );
-- Lucas 'TOR' Garczewski Community Engineer tor@wikia-inc.com
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org