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 'class' =>
'HTMLRestrictionsField',
151 'default' => $this->botPassword->getRestrictions(),
160 [
'bp_user' => $this->userId ],
163 foreach (
$res as $row ) {
165 'section' =>
'existing',
176 'section' =>
'createnew',
177 'type' =>
'textwithbutton',
178 'label-message' =>
'botpasswords-label-appid',
179 'buttondefault' => $this->
msg(
'botpasswords-label-create' )->text(),
180 'buttonflags' => [
'progressive',
'primary' ],
184 'validation-callback' =>
function ( $v ) {
201 $form->
setId(
'mw-botpasswords-form' );
203 $form->
addPreText( $this->
msg(
'botpasswords-summary' )->parseAsBlock() );
206 if ( $this->par !== null ) {
207 if ( $this->botPassword->isSaved() ) {
212 'label-message' =>
'botpasswords-label-update',
213 'flags' => [
'primary',
'progressive' ],
218 'label-message' =>
'botpasswords-label-delete',
219 'flags' => [
'destructive' ],
226 'label-message' =>
'botpasswords-label-create',
227 'flags' => [
'primary',
'progressive' ],
234 'label-message' =>
'botpasswords-label-cancel'
240 $op = $this->
getRequest()->getVal(
'op',
'' );
248 $this->operation =
'insert';
249 return $this->
save( $data );
252 $this->operation =
'update';
253 return $this->
save( $data );
256 $this->operation =
'delete';
273 'centralId' => $this->userId,
274 'appId' => $this->par,
275 'restrictions' => $data[
'restrictions'],
276 'grants' => array_merge(
278 preg_replace(
'/^grant-/',
'', $data[
'grants'] )
282 if ( $this->operation ===
'insert' || !empty( $data[
'resetPassword'] ) ) {
286 $password = $passwordFactory->newFromPlaintext( $this->password );
291 if ( $bp->save( $this->operation,
$password ) ) {
295 return Status::newFatal(
"botpasswords-{$this->operation}-failed", $this->par );
303 switch ( $this->operation ) {
305 $out->setPageTitle( $this->
msg(
'botpasswords-created-title' )->
text() );
306 $out->addWikiMsg(
'botpasswords-created-body', $this->par,
$username );
310 $out->setPageTitle( $this->
msg(
'botpasswords-updated-title' )->
text() );
311 $out->addWikiMsg(
'botpasswords-updated-body', $this->par,
$username );
315 $out->setPageTitle( $this->
msg(
'botpasswords-deleted-title' )->
text() );
316 $out->addWikiMsg(
'botpasswords-deleted-body', $this->par,
$username );
317 $this->password = null;
321 if ( $this->password !== null ) {
324 'botpasswords-newpassword',
325 htmlspecialchars(
$username . $sep . $this->par ),
326 htmlspecialchars( $this->password ),
328 htmlspecialchars( $this->par . $sep . $this->password )
330 $this->password = null;
static getValidGrants()
List all known grants.
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
static newFatal($message)
Factory function for fatal errors.
if(!isset($args[0])) $lang
execute($par)
Main execution point.
msg()
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
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.
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.