MediaWiki  REL1_22
undelete.php
Go to the documentation of this file.
00001 <?php
00024 require_once __DIR__ . '/Maintenance.php';
00025 
00026 class Undelete extends Maintenance {
00027     public function __construct() {
00028         parent::__construct();
00029         $this->mDescription = "Undelete a page";
00030         $this->addOption( 'user', 'The user to perform the undeletion', false, true, 'u' );
00031         $this->addOption( 'reason', 'The reason to undelete', false, true, 'r' );
00032         $this->addArg( 'pagename', 'Page to undelete' );
00033     }
00034 
00035     public function execute() {
00036         global $wgUser;
00037 
00038         $user = $this->getOption( 'user', 'Command line script' );
00039         $reason = $this->getOption( 'reason', '' );
00040         $pageName = $this->getArg();
00041 
00042         $title = Title::newFromText( $pageName );
00043         if ( !$title ) {
00044             $this->error( "Invalid title", true );
00045         }
00046         $wgUser = User::newFromName( $user );
00047         if ( !$wgUser ) {
00048             $this->error( "Invalid username", true );
00049         }
00050         $archive = new PageArchive( $title );
00051         $this->output( "Undeleting " . $title->getPrefixedDBkey() . '...' );
00052         $archive->undelete( array(), $reason );
00053         $this->output( "done\n" );
00054     }
00055 }
00056 
00057 $maintClass = "Undelete";
00058 require_once RUN_MAINTENANCE_IF_MAIN;