From: Sam Reed Date: Sun, 27 Mar 2011 17:07:14 +0000 (+0000) Subject: Allow changePassword.php to use username or userid X-Git-Tag: 1.31.0-rc.0~31161 X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=commitdiff_plain;h=c084f883703b183fb23af36c8b2a609d67a335a1;p=lhc%2Fweb%2Fwiklou.git Allow changePassword.php to use username or userid --- diff --git a/maintenance/changePassword.php b/maintenance/changePassword.php index 568952b9e2..ef87dfbdb5 100644 --- a/maintenance/changePassword.php +++ b/maintenance/changePassword.php @@ -29,13 +29,20 @@ require_once( dirname( __FILE__ ) . '/Maintenance.php' ); class ChangePassword extends Maintenance { public function __construct() { parent::__construct(); - $this->addOption( "user", "The username to operate on", true, true ); + $this->addOption( "user", "The username to operate on", false, true ); + $this->addOption( "userid", "The user id to operate on", false, true ); $this->addOption( "password", "The password to use", true, true ); $this->mDescription = "Change a user's password"; } public function execute() { - $user = User::newFromName( $this->getOption( 'user' ) ); + if ( $this->hasOption( "user" ) ) { + $user = User::newFromName( $this->getOption( 'user' ) ); + } elseif ( $this->hasOption( "userid" ) ) { + $user = User::newFromId( $this->getOption( 'userid' ) ); + } else { + $this->error( "A \"user\" or \"userid\" must be set to change the password for" , true ); + } if ( !$user->getId() ) { $this->error( "No such user: " . $this->getOption( 'user' ), true ); }