From 9b3711e58bce5bf581fae9e4bf9e059c8c777b3d Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 19 May 2009 16:23:58 +0000 Subject: [PATCH] Per code review: Redo these allowBlah() functions (except allowPasswordChange) into a general allowPropChange(), update Preferences to use this. Checked extensions in SVN using AuthPlugin and none have implemented any of the allow*() functions, so nothing should break. --- includes/AuthPlugin.php | 28 ++++++---------------------- includes/Preferences.php | 6 +++--- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/includes/AuthPlugin.php b/includes/AuthPlugin.php index 29be2def31..3632dbfd95 100644 --- a/includes/AuthPlugin.php +++ b/includes/AuthPlugin.php @@ -123,38 +123,22 @@ class AuthPlugin { } /** - * Can users change their passwords? - * - * @return bool - */ - public function allowPasswordChange() { - return true; - } - - /** - * Can users change their Real Name? + * Allow a property change? Properties are the same as preferences + * and use the same keys. 'Realname' 'Emailaddress' and 'Nickname' + * all reference this. * * @return bool */ - public function allowRealNameChange() { + public function allowPropChange( $prop = '' ) { return true; } /** - * Can users change their email address? - * - * @return bool - */ - public function allowEmailChange() { - return true; - } - - /** - * Can users change their Nickname? + * Can users change their passwords? * * @return bool */ - public function allowNickChange() { + public function allowPasswordChange() { return true; } diff --git a/includes/Preferences.php b/includes/Preferences.php index e076b3fec7..1c35910a0c 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -142,7 +142,7 @@ class Preferences { if ($wgAllowRealName) { $defaultPreferences['realname'] = array( - 'type' => $wgAuth->allowRealNameChange() ? 'text' : 'info', + 'type' => $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', @@ -252,7 +252,7 @@ class Preferences { global $wgMaxSigChars; $defaultPreferences['nickname'] = array( - 'type' => $wgAuth->allowNickChange() ? 'text' : 'info', + 'type' => $wgAuth->allowPropChange( 'nickname' ) ? 'text' : 'info', 'maxlength' => $wgMaxSigChars, 'label-message' => 'yournick', 'validation-callback' => @@ -273,7 +273,7 @@ class Preferences { $defaultPreferences['emailaddress'] = array( - 'type' => $wgAuth->allowEmailChange() ? 'text' : 'info', + 'type' => $wgAuth->allowPropChange( 'emailaddress' ) ? 'text' : 'info', 'default' => $user->getEmail(), 'section' => 'personal/email', 'label-message' => 'youremail', -- 2.20.1