00001 <?php 00026 require_once( dirname(__FILE__) . '/Maintenance.php' ); 00027 00028 class ChangePassword extends Maintenance { 00029 public function __construct() { 00030 parent::__construct(); 00031 $this->addOption( "user", "The username to operate on", true, true ); 00032 $this->addOption( "password", "The password to use", true, true ); 00033 $this->mDescription = "Change a user's password"; 00034 } 00035 00036 public function execute() { 00037 $user = User::newFromName( $this->getOption('user') ); 00038 if( !$user->getId() ) { 00039 $this->error( "No such user: " . $this->getOption('user'), true ); 00040 } 00041 try { 00042 $user->setPassword( $this->getOption('password') ); 00043 $user->saveSettings(); 00044 $this->output( "Password set for " . $user->getName() . "\n" ); 00045 } catch( PasswordError $pwe ) { 00046 $this->error( $pwe->getText(), true ); 00047 } 00048 } 00049 } 00050 00051 $maintClass = "ChangePassword"; 00052 require_once( DO_MAINTENANCE );