Go to the documentation of this file.
24 require_once __DIR__ .
'/Maintenance.php';
33 parent::__construct();
34 $this->mDescription =
"Protect or unprotect a page from the command line.";
35 $this->
addOption(
'unprotect',
'Removes protection' );
36 $this->
addOption(
'semiprotect',
'Adds semi-protection' );
37 $this->
addOption(
'cascade',
'Add cascading protection' );
38 $this->
addOption(
'user',
'Username to protect with',
false,
true,
'u' );
39 $this->
addOption(
'reason',
'Reason for un/protection',
false,
true,
'r' );
40 $this->
addArg(
'title',
'Title to protect',
true );
44 $userName = $this->
getOption(
'u',
'Maintenance script' );
49 $protection =
"sysop";
50 if ( $this->
hasOption(
'semiprotect' ) ) {
51 $protection =
"autoconfirmed";
52 } elseif ( $this->
hasOption(
'unprotect' ) ) {
58 $this->
error(
"Invalid username",
true );
62 $restrictions =
array(
'edit' => $protection,
'move' => $protection );
66 $this->
error(
"Invalid title",
true );
69 $restrictions =
array();
70 foreach (
$t->getRestrictionTypes()
as $type ) {
71 $restrictions[
$type] = $protection;
74 # un/protect the article
75 $this->
output(
"Updating protection status... " );
78 $status = $page->doUpdateRestrictions( $restrictions,
array(), $cascade, $reason,
$user );
80 if ( $status->isOK() ) {
83 $this->
output(
"failed\n" );
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Maintenance script that protects or unprotects a page.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
execute()
Do the actual work.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
require_once RUN_MAINTENANCE_IF_MAIN
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
getOption( $name, $default=null)
Get an option, or return the default.
addArg( $arg, $description, $required=true)
Add some args that are needed.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
__construct()
Default constructor.
hasOption( $name)
Checks to see if a particular param exists.
getArg( $argId=0, $default=null)
Get an argument.