From c084f883703b183fb23af36c8b2a609d67a335a1 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 27 Mar 2011 17:07:14 +0000 Subject: [PATCH] Allow changePassword.php to use username or userid --- maintenance/changePassword.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 ); } -- 2.20.1