X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FPreferences.php;h=3083a8d2155820ef67e6ebb77fb7331800aa3e48;hb=cb68ff02309f090bd297e0a49fc81727c4bd3371;hp=ad97f1960b83f0b3d90b459937af029371f20dbe;hpb=d7de1f8c322afebbc79689f83064f806954ea0cd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Preferences.php b/includes/Preferences.php index ad97f1960b..3083a8d215 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -19,6 +19,8 @@ * * @file */ +use MediaWiki\Auth\AuthManager; +use MediaWiki\Auth\PasswordAuthenticationRequest; /** * We're now using the HTMLForm object with some customisation to generate the @@ -205,7 +207,7 @@ class Preferences { * @return void */ static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) { - global $wgAuth, $wgContLang, $wgParser; + global $wgAuth, $wgContLang, $wgParser, $wgDisableAuthManager; $config = $context->getConfig(); // retrieving user name for GENDER and misc. @@ -281,16 +283,21 @@ class Preferences { $canEditPrivateInfo = $user->isAllowed( 'editmyprivateinfo' ); // Actually changeable stuff + $realnameChangeAllowed = $wgDisableAuthManager ? $wgAuth->allowPropChange( 'realname' ) + : AuthManager::singleton()->allowsPropertyChange( 'realname' ); $defaultPreferences['realname'] = [ // (not really "private", but still shouldn't be edited without permission) - 'type' => $canEditPrivateInfo && $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info', + 'type' => $canEditPrivateInfo && $realnameChangeAllowed ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname', ]; - if ( $canEditPrivateInfo && $wgAuth->allowPasswordChange() ) { + $allowPasswordChange = $wgDisableAuthManager ? $wgAuth->allowPasswordChange() + : AuthManager::singleton()->allowsAuthenticationDataChange( + new PasswordAuthenticationRequest(), false )->isGood(); + if ( $canEditPrivateInfo && $allowPasswordChange ) { $link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ), $context->msg( 'prefs-resetpass' )->escaped(), [], [ 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ] ); @@ -411,8 +418,10 @@ class Preferences { 'default' => $oldsigHTML, 'section' => 'personal/signature', ]; + $nicknameChangeAllowed = $wgDisableAuthManager ? $wgAuth->allowPropChange( 'nickname' ) + : AuthManager::singleton()->allowsPropertyChange( 'nickname' ); $defaultPreferences['nickname'] = [ - 'type' => $wgAuth->allowPropChange( 'nickname' ) ? 'text' : 'info', + 'type' => $nicknameChangeAllowed ? 'text' : 'info', 'maxlength' => $config->get( 'MaxSigChars' ), 'label-message' => 'yournick', 'validation-callback' => [ 'Preferences', 'validateSignature' ], @@ -441,7 +450,9 @@ class Preferences { } $emailAddress = $user->getEmail() ? htmlspecialchars( $user->getEmail() ) : ''; - if ( $canEditPrivateInfo && $wgAuth->allowPropChange( 'emailaddress' ) ) { + $emailChangeAllowed = $wgDisableAuthManager ? $wgAuth->allowPropChange( 'emailaddress' ) + : AuthManager::singleton()->allowsPropertyChange( 'emailaddress' ); + if ( $canEditPrivateInfo && $emailChangeAllowed ) { $link = Linker::link( SpecialPage::getTitleFor( 'ChangeEmail' ), $context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->escaped(), @@ -1044,10 +1055,14 @@ class Preferences { $watchTypes['rollback'] = 'watchrollback'; } + if ( $user->isAllowed( 'upload' ) ) { + $watchTypes['upload'] = 'watchuploads'; + } + foreach ( $watchTypes as $action => $pref ) { if ( $user->isAllowed( $action ) ) { // Messages: - // tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations + // tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations, tog-watchuploads // tog-watchrollback $defaultPreferences[$pref] = [ 'type' => 'toggle', @@ -1406,8 +1421,6 @@ class Preferences { * @return bool|Status|string */ static function tryFormSubmit( $formData, $form ) { - global $wgAuth; - $user = $form->getModifiedUser(); $hiddenPrefs = $form->getConfig()->get( 'HiddenPrefs' ); $result = true; @@ -1426,6 +1439,7 @@ class Preferences { // Fortunately, the realname field is MUCH simpler // (not really "private", but still shouldn't be edited without permission) + if ( !in_array( 'realname', $hiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) && array_key_exists( 'realname', $formData ) @@ -1458,7 +1472,7 @@ class Preferences { Hooks::run( 'PreferencesFormPreSave', [ $formData, $form, $user, &$result ] ); } - $wgAuth->updateExternalDB( $user ); + MediaWiki\Auth\AuthManager::callLegacyAuthPlugin( 'updateExternalDB', [ $user ] ); $user->saveSettings(); return $result;