* @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later * @ingroup Maintenance */ 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( "password", "The password to use", true, true ); $this->mDescription = "Change a user's password"; } public function execute() { $user = User::newFromName( $this->getOption('user') ); if( !$user->getId() ) { $this->error( "No such user: " . $this->getOption('user'), true ); } try { $user->setPassword( $this->getOption('password') ); $user->saveSettings(); $this->output( "Password set for " . $user->getName() . "\n" ); } catch( PasswordError $pwe ) { $this->error( $pwe->getText(), true ); } } } $maintClass = "ChangePassword"; require_once( DO_MAINTENANCE );