44 parent::__construct(
'BotPasswords',
'editmyprivateinfo' );
51 return $this->
getConfig()->get(
'EnableBotPasswords' );
63 if ( strlen(
$par ) === 0 ) {
66 throw new ErrorPageError(
'botpasswords',
'botpasswords-bad-appid',
67 [ htmlspecialchars(
$par ) ] );
74 parent::checkExecutePermissions( $user );
76 if ( !$this->
getConfig()->
get(
'EnableBotPasswords' ) ) {
77 throw new ErrorPageError(
'botpasswords',
'botpasswords-disabled' );
81 if ( !$this->userId ) {
82 throw new ErrorPageError(
'botpasswords',
'botpasswords-no-central-id' );
89 if ( $this->par !== null ) {
91 if ( !$this->botPassword ) {
93 'centralId' => $this->userId,
94 'appId' => $this->par,
101 'label-message' =>
'username',
105 if ( $this->botPassword->isSaved() ) {
106 $fields[
'resetPassword'] = [
108 'label-message' =>
'botpasswords-label-resetpassword',
114 $fields[
'grants'] = [
115 'type' =>
'checkmatrix',
116 'label-message' =>
'botpasswords-label-grants',
117 'help-message' =>
'botpasswords-help-grants',
119 $this->
msg(
'botpasswords-label-grants-column' )->escaped() =>
'grant'
121 'rows' => array_combine(
122 array_map(
'MWGrants::getGrantsLink', $showGrants ),
125 'default' => array_map(
129 $this->botPassword->getGrants()
131 'tooltips' => array_combine(
132 array_map(
'MWGrants::getGrantsLink', $showGrants ),
135 return $lang->semicolonList( array_map(
'User::getRightDescription', $rights ) );
140 'force-options-on' => array_map(
148 $fields[
'restrictions'] = [
149 'type' =>
'textarea',
150 'label-message' =>
'botpasswords-label-restrictions',
152 'default' => $this->botPassword->getRestrictions()->toJson(
true ),
154 'validation-callback' =>
function ( $v ) {
158 }
catch ( InvalidArgumentException $ex ) {
159 return $ex->getMessage();
170 [
'bp_user' => $this->userId ],
173 foreach (
$res as $row ) {
175 'section' =>
'existing',
186 'section' =>
'createnew',
187 'type' =>
'textwithbutton',
188 'label-message' =>
'botpasswords-label-appid',
189 'buttondefault' => $this->
msg(
'botpasswords-label-create' )->text(),
190 'buttonflags' => [
'progressive',
'primary' ],
194 'validation-callback' =>
function ( $v ) {
211 $form->
setId(
'mw-botpasswords-form' );
213 $form->
addPreText( $this->
msg(
'botpasswords-summary' )->parseAsBlock() );
216 if ( $this->par !== null ) {
217 if ( $this->botPassword->isSaved() ) {
222 'label-message' =>
'botpasswords-label-update',
223 'flags' => [
'primary',
'progressive' ],
228 'label-message' =>
'botpasswords-label-delete',
229 'flags' => [
'destructive' ],
236 'label-message' =>
'botpasswords-label-create',
237 'flags' => [
'primary',
'constructive' ],
244 'label-message' =>
'botpasswords-label-cancel'
250 $op = $this->
getRequest()->getVal(
'op',
'' );
258 $this->operation =
'insert';
259 return $this->
save( $data );
262 $this->operation =
'update';
263 return $this->
save( $data );
266 $this->operation =
'delete';
283 'centralId' => $this->userId,
284 'appId' => $this->par,
286 'grants' => array_merge(
288 preg_replace(
'/^grant-/',
'', $data[
'grants'] )
292 if ( $this->operation ===
'insert' || !empty( $data[
'resetPassword'] ) ) {
294 max( 32, $this->
getConfig()->
get(
'MinimalPasswordLength' ) )
298 $password = $passwordFactory->newFromPlaintext( $this->password );
303 if ( $bp->save( $this->operation,
$password ) ) {
307 return Status::newFatal(
"botpasswords-{$this->operation}-failed", $this->par );
315 switch ( $this->operation ) {
317 $out->setPageTitle( $this->
msg(
'botpasswords-created-title' )->
text() );
318 $out->addWikiMsg(
'botpasswords-created-body', $this->par,
$username );
322 $out->setPageTitle( $this->
msg(
'botpasswords-updated-title' )->
text() );
323 $out->addWikiMsg(
'botpasswords-updated-body', $this->par,
$username );
327 $out->setPageTitle( $this->
msg(
'botpasswords-deleted-title' )->
text() );
328 $out->addWikiMsg(
'botpasswords-deleted-body', $this->par,
$username );
329 $this->password = null;
333 if ( $this->password !== null ) {
336 'botpasswords-newpassword',
337 htmlspecialchars(
$username . $sep . $this->par ),
338 htmlspecialchars( $this->password )
340 $this->password = null;
static getValidGrants()
List all known grants.
Factory class for creating and checking Password objects.
static getSeparator()
Get the separator for combined user name + app ID.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
the array() calling protocol came about after MediaWiki 1.4rc1.
static getDB($db)
Get a database connection for the bot passwords database.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(!isset($args[0])) $lang
execute($par)
Main execution point.
static generateRandomPasswordString($minLength=10)
Generate a random string suitable for a password.
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
static newFatal($message)
Factory function for fatal errors.
Special page which uses an HTMLForm to handle processing.
static newUnsaved(array $data, $flags=self::READ_NORMAL)
Create an unsaved BotPassword.
static newFromCentralId($centralId, $appId, $flags=self::READ_NORMAL)
Load a BotPassword from the database.
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
static getMain()
Static methods.
static getHiddenGrants()
Get the list of grants that are hidden and should always be granted.
An error page which can definitely be safely rendered using the OutputPage.
static factory($providerId=null)
Fetch a CentralIdLookup.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
string $operation
Operation being performed: create, update, delete.
static newFromJson($json)
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
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 local account $user
BotPassword null $botPassword
Bot password being edited, if any.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
alterForm(HTMLForm $form)
this hook is for auditing only or null if authentication failed before getting that far $username
checkExecutePermissions(User $user)
static getRightsByGrant()
Map all grants to corresponding user rights.
requireLogin($reasonMsg= 'exception-nologin-text', $titleMsg= 'exception-nologin')
If the user is not logged in, throws UserNotLoggedIn error.
getUser()
Shortcut to get the User executing this instance.
string $par
The sub-page of the special page.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
LinkRenderer null $linkRenderer
getRequest()
Get the WebRequest being used for this instance.
string $password
New password set, for communication between onSubmit() and onSuccess()
Let users manage bot passwords.
static newGood($value=null)
Factory function for good results.
int $userId
Central user ID.
getPageTitle($subpage=false)
Get a self-referential title object.