Index: trunk/phase3/includes/User.php |
— | — | @@ -253,23 +253,6 @@ |
254 | 254 | } |
255 | 255 | wfProfileOut( __METHOD__ ); |
256 | 256 | } |
257 | | - |
258 | | - protected function callAuthPlugin( $fname /* $args */ ) { |
259 | | - $args = func_get_args(); |
260 | | - array_shift( $args ); |
261 | | - // Load auth plugin conterpart functions for User functions |
262 | | - if( !$this->mAuthLoaded ) { |
263 | | - global $wgAuth; |
264 | | - $this->mAuthCallbacks = array(); |
265 | | - $wgAuth->setUserCallbacks( $this, $this->mAuthCallbacks ); |
266 | | - $this->mAuthLoaded = true; |
267 | | - } |
268 | | - // Try to call the auth plugin version of this function |
269 | | - if( isset($this->mAuthCallbacks[$fname]) && is_callable($this->mAuthCallbacks[$fname]) ) { |
270 | | - return call_user_func_array( $this->mAuthCallbacks[$fname], $args ); |
271 | | - } |
272 | | - return NULL; |
273 | | - } |
274 | 257 | |
275 | 258 | /** |
276 | 259 | * Load user table data, given mId has already been set. |
— | — | @@ -1347,7 +1330,9 @@ |
1348 | 1331 | if( $this->mLocked !== null ) { |
1349 | 1332 | return $this->mLocked; |
1350 | 1333 | } |
1351 | | - $this->mLocked = (bool)$this->callAuthPlugin( __FUNCTION__ ); |
| 1334 | + global $wgAuth; |
| 1335 | + $authUser = $wgAuth->getUserInstance( $this ); |
| 1336 | + $this->mLocked = (bool)$authUser->isLocked(); |
1352 | 1337 | return $this->mLocked; |
1353 | 1338 | } |
1354 | 1339 | |
— | — | @@ -1362,7 +1347,9 @@ |
1363 | 1348 | } |
1364 | 1349 | $this->getBlockedStatus(); |
1365 | 1350 | if( !$this->mHideName ) { |
1366 | | - $this->mHideName = (bool)$this->callAuthPlugin( __FUNCTION__ ); |
| 1351 | + global $wgAuth; |
| 1352 | + $authUser = $wgAuth->getUserInstance( $this ); |
| 1353 | + $this->mHideName = (bool)$authUser->isHidden(); |
1367 | 1354 | } |
1368 | 1355 | return $this->mHideName; |
1369 | 1356 | } |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -17,6 +17,7 @@ |
18 | 18 | 'Article' => 'includes/Article.php', |
19 | 19 | 'AtomFeed' => 'includes/Feed.php', |
20 | 20 | 'AuthPlugin' => 'includes/AuthPlugin.php', |
| 21 | + 'AuthPluginUser' => 'includes/AuthPlugin.php', |
21 | 22 | 'Autopromote' => 'includes/Autopromote.php', |
22 | 23 | 'BagOStuff' => 'includes/BagOStuff.php', |
23 | 24 | 'Block' => 'includes/Block.php', |
Index: trunk/phase3/includes/AuthPlugin.php |
— | — | @@ -38,9 +38,8 @@ |
39 | 39 | * |
40 | 40 | * @param $username String: username. |
41 | 41 | * @return bool |
42 | | - * @public |
43 | 42 | */ |
44 | | - function userExists( $username ) { |
| 43 | + public function userExists( $username ) { |
45 | 44 | # Override this! |
46 | 45 | return false; |
47 | 46 | } |
— | — | @@ -54,9 +53,8 @@ |
55 | 54 | * @param $username String: username. |
56 | 55 | * @param $password String: user password. |
57 | 56 | * @return bool |
58 | | - * @public |
59 | 57 | */ |
60 | | - function authenticate( $username, $password ) { |
| 58 | + public function authenticate( $username, $password ) { |
61 | 59 | # Override this! |
62 | 60 | return false; |
63 | 61 | } |
— | — | @@ -65,9 +63,8 @@ |
66 | 64 | * Modify options in the login template. |
67 | 65 | * |
68 | 66 | * @param $template UserLoginTemplate object. |
69 | | - * @public |
70 | 67 | */ |
71 | | - function modifyUITemplate( &$template ) { |
| 68 | + public function modifyUITemplate( &$template ) { |
72 | 69 | # Override this! |
73 | 70 | $template->set( 'usedomain', false ); |
74 | 71 | } |
— | — | @@ -76,9 +73,8 @@ |
77 | 74 | * Set the domain this plugin is supposed to use when authenticating. |
78 | 75 | * |
79 | 76 | * @param $domain String: authentication domain. |
80 | | - * @public |
81 | 77 | */ |
82 | | - function setDomain( $domain ) { |
| 78 | + public function setDomain( $domain ) { |
83 | 79 | $this->domain = $domain; |
84 | 80 | } |
85 | 81 | |
— | — | @@ -87,9 +83,8 @@ |
88 | 84 | * |
89 | 85 | * @param $domain String: authentication domain. |
90 | 86 | * @return bool |
91 | | - * @public |
92 | 87 | */ |
93 | | - function validDomain( $domain ) { |
| 88 | + public function validDomain( $domain ) { |
94 | 89 | # Override this! |
95 | 90 | return true; |
96 | 91 | } |
— | — | @@ -103,9 +98,8 @@ |
104 | 99 | * forget the & on your function declaration. |
105 | 100 | * |
106 | 101 | * @param User $user |
107 | | - * @public |
108 | 102 | */ |
109 | | - function updateUser( &$user ) { |
| 103 | + public function updateUser( &$user ) { |
110 | 104 | # Override this and do something |
111 | 105 | return true; |
112 | 106 | } |
— | — | @@ -123,9 +117,8 @@ |
124 | 118 | * This is just a question, and shouldn't perform any actions. |
125 | 119 | * |
126 | 120 | * @return bool |
127 | | - * @public |
128 | 121 | */ |
129 | | - function autoCreate() { |
| 122 | + public function autoCreate() { |
130 | 123 | return false; |
131 | 124 | } |
132 | 125 | |
— | — | @@ -134,7 +127,7 @@ |
135 | 128 | * |
136 | 129 | * @return bool |
137 | 130 | */ |
138 | | - function allowPasswordChange() { |
| 131 | + public function allowPasswordChange() { |
139 | 132 | return true; |
140 | 133 | } |
141 | 134 | |
— | — | @@ -149,9 +142,8 @@ |
150 | 143 | * @param $user User object. |
151 | 144 | * @param $password String: password. |
152 | 145 | * @return bool |
153 | | - * @public |
154 | 146 | */ |
155 | | - function setPassword( $user, $password ) { |
| 147 | + public function setPassword( $user, $password ) { |
156 | 148 | return true; |
157 | 149 | } |
158 | 150 | |
— | — | @@ -161,9 +153,8 @@ |
162 | 154 | * |
163 | 155 | * @param $user User object. |
164 | 156 | * @return bool |
165 | | - * @public |
166 | 157 | */ |
167 | | - function updateExternalDB( $user ) { |
| 158 | + public function updateExternalDB( $user ) { |
168 | 159 | return true; |
169 | 160 | } |
170 | 161 | |
— | — | @@ -171,9 +162,8 @@ |
172 | 163 | * Check to see if external accounts can be created. |
173 | 164 | * Return true if external accounts can be created. |
174 | 165 | * @return bool |
175 | | - * @public |
176 | 166 | */ |
177 | | - function canCreateAccounts() { |
| 167 | + public function canCreateAccounts() { |
178 | 168 | return false; |
179 | 169 | } |
180 | 170 | |
— | — | @@ -186,9 +176,8 @@ |
187 | 177 | * @param string $email |
188 | 178 | * @param string $realname |
189 | 179 | * @return bool |
190 | | - * @public |
191 | 180 | */ |
192 | | - function addUser( $user, $password, $email='', $realname='' ) { |
| 181 | + public function addUser( $user, $password, $email='', $realname='' ) { |
193 | 182 | return true; |
194 | 183 | } |
195 | 184 | |
— | — | @@ -200,9 +189,8 @@ |
201 | 190 | * This is just a question, and shouldn't perform any actions. |
202 | 191 | * |
203 | 192 | * @return bool |
204 | | - * @public |
205 | 193 | */ |
206 | | - function strict() { |
| 194 | + public function strict() { |
207 | 195 | return false; |
208 | 196 | } |
209 | 197 | |
— | — | @@ -212,9 +200,8 @@ |
213 | 201 | * |
214 | 202 | * @param $username String: username. |
215 | 203 | * @return bool |
216 | | - * @public |
217 | 204 | */ |
218 | | - function strictUserAuth( $username ) { |
| 205 | + public function strictUserAuth( $username ) { |
219 | 206 | return false; |
220 | 207 | } |
221 | 208 | |
— | — | @@ -228,9 +215,8 @@ |
229 | 216 | * |
230 | 217 | * @param $user User object. |
231 | 218 | * @param $autocreate bool True if user is being autocreated on login |
232 | | - * @public |
233 | 219 | */ |
234 | | - function initUser( &$user, $autocreate=false ) { |
| 220 | + public function initUser( &$user, $autocreate=false ) { |
235 | 221 | # Override this to do something. |
236 | 222 | } |
237 | 223 | |
— | — | @@ -238,14 +224,33 @@ |
239 | 225 | * If you want to munge the case of an account name before the final |
240 | 226 | * check, now is your chance. |
241 | 227 | */ |
242 | | - function getCanonicalName( $username ) { |
| 228 | + public function getCanonicalName( $username ) { |
243 | 229 | return $username; |
244 | 230 | } |
245 | 231 | |
246 | 232 | /** |
247 | | - * Adds any functionality to a User object in context of the auth system |
| 233 | + * Get an instance of a User object |
| 234 | + * |
| 235 | + * @param $user User |
| 236 | + * @public |
248 | 237 | */ |
249 | | - function setUserCallbacks( $user, &$callbacks ) { |
250 | | - return true; |
| 238 | + public function getUserInstance( User &$user ) { |
| 239 | + return new AuthPluginUser( $user ); |
251 | 240 | } |
252 | 241 | } |
| 242 | + |
| 243 | +class AuthPluginUser { |
| 244 | + function __construct( $username ) { |
| 245 | + $this->mName = $username; |
| 246 | + } |
| 247 | + |
| 248 | + public function isLocked() { |
| 249 | + # Override this! |
| 250 | + return false; |
| 251 | + } |
| 252 | + |
| 253 | + public function isHidden() { |
| 254 | + # Override this! |
| 255 | + return false; |
| 256 | + } |
| 257 | +} |
Index: trunk/extensions/CentralAuth/CentralAuthPlugin.php |
— | — | @@ -245,9 +245,7 @@ |
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | | - function setUserCallbacks( $user, &$callbacks ) { |
250 | | - $central = CentralAuthUser::getInstance( $user ); |
251 | | - $callbacks['isLocked'] = array( $central, 'isLocked' ); |
252 | | - $callbacks['isHidden'] = array( $central, 'isHidden' ); |
| 249 | + public function getUserInstance( User &$user ) { |
| 250 | + return CentralAuthUser::getInstance( $user ); |
253 | 251 | } |
254 | 252 | } |
Index: trunk/extensions/CentralAuth/CentralAuthUser.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | |
13 | 13 | */ |
14 | 14 | |
15 | | -class CentralAuthUser { |
| 15 | +class CentralAuthUser extends AuthPluginUser { |
16 | 16 | |
17 | 17 | /** |
18 | 18 | * The username of the current user. |