X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=maintenance%2Fundelete.php;h=ea8b0c4bab25e76c28bd72c24743be56cfe181c9;hb=289c4079577a676bff59a91d5b6e5bccc7d487d3;hp=f722eaf8e63077424c69edb086a2ae96f6788bc2;hpb=68d10fa70d280cfbf6fe6310949b6fa36f3d41e0;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/undelete.php b/maintenance/undelete.php index f722eaf8e6..ea8b0c4bab 100644 --- a/maintenance/undelete.php +++ b/maintenance/undelete.php @@ -1,33 +1,58 @@ ] [-r ] +require_once( __DIR__ . '/Maintenance.php' ); -EOT; +class Undelete extends Maintenance { + public function __construct() { + parent::__construct(); + $this->mDescription = "Undelete a page"; + $this->addOption( 'user', 'The user to perform the undeletion', false, true, 'u' ); + $this->addOption( 'reason', 'The reason to undelete', false, true, 'r' ); + $this->addArg( 'pagename', 'Page to undelete' ); + } -$optionsWithArgs = array( 'u', 'r' ); -require_once( 'commandLine.inc' ); + public function execute() { + global $wgUser; -$user = 'Command line script'; -$reason = ''; + $user = $this->getOption( 'user', 'Command line script' ); + $reason = $this->getOption( 'reason', '' ); + $pageName = $this->getArg(); -if ( isset( $options['u'] ) ) { - $user = $options['u']; + $title = Title::newFromText( $pageName ); + if ( !$title ) { + $this->error( "Invalid title", true ); + } + $wgUser = User::newFromName( $user ); + if ( !$wgUser ) { + $this->error( "Invalid username", true ); + } + $archive = new PageArchive( $title ); + $this->output( "Undeleting " . $title->getPrefixedDBkey() . '...' ); + $archive->undelete( array(), $reason ); + $this->output( "done\n" ); + } } -if ( isset( $options['r'] ) ) { - $reason = $options['r']; -} -$pageName = @$args[0]; -$title = Title::newFromText( $pageName ); -if ( !$title ) { - echo $usage; - exit( 1 ); -} -$wgUser = User::newFromName( $user ); -$archive = new PageArchive( $title ); -echo "Undeleting " . $title->getPrefixedDBkey() . '...'; -$archive->undelete( array(), $reason ); -echo "done\n"; -?> +$maintClass = "Undelete"; +require_once( RUN_MAINTENANCE_IF_MAIN );