Go to the documentation of this file.
26 require_once __DIR__ .
'/Maintenance.php';
38 parent::__construct();
39 $this->mDescription =
"Create a new user account and/or grant it additional rights";
40 $this->
addOption(
"force",
"If acccount exists already, just grant it rights or change password." );
41 foreach ( self::$permitRoles
as $role ) {
42 $this->
addOption( $role,
"Add the account to the {$role} group" );
44 $this->
addArg(
"username",
"Username of new user" );
45 $this->
addArg(
"password",
"Password to set (not required if --force is used)",
false );
49 $username = $this->
getArg( 0 );
55 if ( !is_object(
$user ) ) {
56 $this->
error(
"invalid username.",
true );
59 $exists = ( 0 !==
$user->idForName() );
61 if ( $exists && !$force ) {
62 $this->
error(
"Account exists. Perhaps you want the --force option?",
true );
64 $this->
error(
"Argument <password> required!",
false );
66 } elseif ( $exists ) {
67 $inGroups =
$user->getGroups();
70 $promotions = array_diff( array_filter( self::$permitRoles,
array( $this,
'hasOption' ) ), $inGroups );
72 if ( $exists && !
$password && count( $promotions ) === 0 ) {
73 $this->
output(
"Account exists and nothing to do.\n" );
75 } elseif ( count( $promotions ) !== 0 ) {
76 $promoText =
"User:{$username} into " . implode(
', ', $promotions ) .
"...\n";
80 $this->
output(
wfWikiID() .
": Creating and promoting $promoText" );
85 # Try to set the password
89 $this->
output(
"Password set.\n" );
90 $user->saveSettings();
98 # Insert the account into the database
99 $user->addToDatabase();
100 $user->saveSettings();
104 array_map(
array(
$user,
'addGroup' ), $promotions );
107 # Increment site_stats.ss_users
112 $this->
output(
"done.\n" );
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
maybeHelp( $force=false)
Maybe show the help.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
require_once RUN_MAINTENANCE_IF_MAIN
Thrown by User::setPassword() on error.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
getText()
Get the text to display when reporting the error on the command line.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Class for handling updates to the site_stats table.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks this Boolean value will be checked to determine if the password was valid return false to implement your own hashing method & $password
addArg( $arg, $description, $required=true)
Add some args that are needed.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular param exists.
getArg( $argId=0, $default=null)
Get an argument.