Add link from Special:Preferences to manage OATH

Change-Id: I281f08a363bbfb7eab6003513b8326d468a8c85a
This commit is contained in:
Ryan Lane 2013-03-08 16:44:17 -08:00
parent f5498babf5
commit 967a12654b
3 changed files with 21 additions and 0 deletions

View file

@ -44,6 +44,8 @@ $messages['en'] = array(
'oathauth-failedtoresetoath' => 'Failed to reset two factor credentials.', 'oathauth-failedtoresetoath' => 'Failed to reset two factor credentials.',
'oathauth-notloggedin' => 'Login required', 'oathauth-notloggedin' => 'Login required',
'oathauth-mustbeloggedin' => 'You must be logged in to perform this action.', 'oathauth-mustbeloggedin' => 'You must be logged in to perform this action.',
'oathauth-prefs-label' => 'Two-factor authentication:',
'oathauth-prefs-manage' => 'Manage two-factor authentication',
); );
/** Message documentation (Message documentation) /** Message documentation (Message documentation)
@ -82,6 +84,8 @@ Extension name, found on Special:Version',
'oathauth-notloggedin' => 'Page title seen on Special:OATH when a user is not logged in. 'oathauth-notloggedin' => 'Page title seen on Special:OATH when a user is not logged in.
{{Identical|Login required}}', {{Identical|Login required}}',
'oathauth-mustbeloggedin' => 'Plain text seen on Special:OATH when a user is not logged in.', 'oathauth-mustbeloggedin' => 'Plain text seen on Special:OATH when a user is not logged in.',
'oathauth-prefs-label' => 'Plain text label seen on Special:Preferences',
'oathauth-prefs-manage' => 'Link to Special:OATH from Special:Preferences',
); );
/** Breton (brezhoneg) /** Breton (brezhoneg)

View file

@ -54,6 +54,7 @@ $wgHooks['ChangePasswordForm'][] = 'OATHUser::ChangePasswordForm';
$wgHooks['TwoFactorIsEnabled'][] = 'OATHUser::TwoFactorIsEnabled'; $wgHooks['TwoFactorIsEnabled'][] = 'OATHUser::TwoFactorIsEnabled';
# Schema updates # Schema updates
$wgHooks['LoadExtensionSchemaUpdates'][] = 'efOATHAuthSchemaUpdates'; $wgHooks['LoadExtensionSchemaUpdates'][] = 'efOATHAuthSchemaUpdates';
$wgHooks['GetPreferences'][] = 'OATHUser::manageOATH';
/** /**
* @param $updater DatabaseUpdater * @param $updater DatabaseUpdater

View file

@ -346,4 +346,20 @@ class OATHUser {
} }
} }
public static function manageOATH( User $user, array &$preferences ) {
$link = Linker::link( SpecialPage::getTitleFor( 'OATH' ),
wfMessage( 'oathauth-prefs-manage' )->escaped(),
array(),
array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() )
);
$preferences['oath'] = array(
'type' => 'info',
'raw' => 'true',
'default' => $link,
'label-message' => 'oathauth-prefs-label',
'section' => 'personal/info',
);
return true;
}
} }