Index: trunk/extensions/Makesysop/SpecialMakesysop_body.php |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | * @addtogroup SpecialPage |
55 | 55 | */ |
56 | 56 | class MakesysopForm { |
57 | | - var $mTarget, $mAction, $mRights, $mUser, $mSubmit, $mSetBureaucrat; |
| 57 | + var $mTarget, $mAction, $mRights, $mUser, $mReason, $mSubmit, $mSetBureaucrat; |
58 | 58 | |
59 | 59 | function MakesysopForm( &$request ) { |
60 | 60 | global $wgUser; |
— | — | @@ -61,6 +61,7 @@ |
62 | 62 | $this->mAction = $request->getText( 'action' ); |
63 | 63 | $this->mRights = $request->getVal( 'wpRights' ); |
64 | 64 | $this->mUser = $request->getText( 'wpMakesysopUser' ); |
| 65 | + $this->mReason = htmlspecialchars( $request->getText( 'wpMakesysopReason' ) ); |
65 | 66 | $this->mSubmit = $request->getBool( 'wpMakesysopSubmit' ) && |
66 | 67 | $request->wasPosted() && |
67 | 68 | $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) ); |
— | — | @@ -87,39 +88,34 @@ |
88 | 89 | $encUser = ""; |
89 | 90 | } |
90 | 91 | |
91 | | - $wgOut->addHTML( " |
92 | | - <form id=\"makesysop\" method=\"post\" action=\"{$action}\"> |
93 | | - <table border='0'> |
| 92 | + $reason = wfMsg( "makesysopreason" ); |
| 93 | + $makebureaucrat = wfMsg( "setbureaucratflag" ); |
| 94 | + $mss = wfMsg( "set_user_rights" ); |
| 95 | + $token = htmlspecialchars( $wgUser->editToken() ); |
| 96 | + |
| 97 | + $wgOut->addHTML( |
| 98 | + Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'makesysop' ) ) . |
| 99 | + Xml::openElement( 'fieldset' ) . |
| 100 | + Xml::element( 'legend', array(), wfMsg( 'makesysoptitle' ) ) . |
| 101 | + "<table border='0'> |
94 | 102 | <tr> |
95 | 103 | <td align='right'>$namedesc</td> |
96 | | - <td align='left'> |
97 | | - <input type='text' size='40' name=\"wpMakesysopUser\" value=\"$encUser\" /> |
98 | | - </td> |
99 | | - </tr>" |
100 | | - ); |
101 | | - |
102 | | - $makeburo = wfMsg( "setbureaucratflag" ); |
103 | | - $wgOut->addHTML( |
104 | | - "<tr> |
| 104 | + <td align='left'>" . Xml::input( 'wpMakesysopUser', 40, $encUser ) . "</td> |
| 105 | + </tr><tr> |
| 106 | + <td align='right'>$reason</td> |
| 107 | + <td align='left'>" . Xml::input( 'wpMakesysopReason', 40, $this->mReason ) . "</td> |
| 108 | + </tr><tr> |
105 | 109 | <td> </td> |
106 | | - <td align='left'> |
107 | | - <input type='checkbox' name='wpSetBureaucrat' value='1'>$makeburo</input> |
108 | | - </td> |
109 | | - </tr>" |
| 110 | + <td align='left'>" . Xml::checkLabel( $makebureaucrat, 'wpSetBureaucrat', 'wpSetBureaucrat', $this->mSetBureaucrat ) . "</td> |
| 111 | + </tr><tr> |
| 112 | + <td> </td> |
| 113 | + <td align='left'>" . Xml::submitButton( $mss, array( 'name' => 'wpMakesysopSubmit' ) ) . "</td> |
| 114 | + </tr> |
| 115 | + </table>" . |
| 116 | + Xml::hidden( 'wpEditToken', $token ) . |
| 117 | + Xml::closeElement( 'fieldset' ) . |
| 118 | + Xml::closeElement( 'form' ) . "\n" |
110 | 119 | ); |
111 | | - |
112 | | - |
113 | | - $mss = wfMsg( "set_user_rights" ); |
114 | | - |
115 | | - $token = htmlspecialchars( $wgUser->editToken() ); |
116 | | - $wgOut->addHTML( |
117 | | - "<tr> |
118 | | - <td> </td><td align='left'> |
119 | | - <input type='submit' name=\"wpMakesysopSubmit\" value=\"{$mss}\" /> |
120 | | - </td></tr></table> |
121 | | - <input type='hidden' name='wpEditToken' value=\"{$token}\" /> |
122 | | - </form>\n" |
123 | | - ); |
124 | 120 | } |
125 | 121 | |
126 | 122 | function doSubmit() { |
— | — | @@ -127,7 +123,7 @@ |
128 | 124 | global $wgDBname, $wgMemc, $wgLocalDatabases, $wgSharedDB; |
129 | 125 | |
130 | 126 | $fname = 'MakesysopForm::doSubmit'; |
131 | | - |
| 127 | + |
132 | 128 | $dbw =& wfGetDB( DB_MASTER ); |
133 | 129 | $user_groups = $dbw->tableName( 'user_groups' ); |
134 | 130 | $usertable = $dbw->tableName( 'user' ); |
— | — | @@ -141,7 +137,7 @@ |
142 | 138 | return; |
143 | 139 | } |
144 | 140 | $username = $t->getText(); |
145 | | - |
| 141 | + |
146 | 142 | if ( $username{0} == "#" ) { |
147 | 143 | $id = intval( substr( $username, 1 ) ); |
148 | 144 | } else { |
— | — | @@ -187,13 +183,13 @@ |
188 | 184 | } else { |
189 | 185 | $wgMemc->delete( "$wgDBname:user:id:$id" ); |
190 | 186 | } |
191 | | - |
| 187 | + |
192 | 188 | $newGroups = array_merge($newGroups, $addedGroups); |
193 | | - |
| 189 | + |
194 | 190 | $log = new LogPage( 'rights' ); |
195 | | - $log->addEntry( 'rights', Title::makeTitle( NS_USER, $username ), '', |
| 191 | + $log->addEntry( 'rights', Title::makeTitle( NS_USER, $username ), $this->mReason, |
196 | 192 | array( $this->makeGroupNameList( $oldGroups ), $this->makeGroupNameList( $newGroups ) ) ); |
197 | | - |
| 193 | + |
198 | 194 | $this->showSuccess(); |
199 | 195 | } |
200 | 196 | |
— | — | @@ -202,6 +198,9 @@ |
203 | 199 | |
204 | 200 | $wgOut->setPagetitle( wfMsg( "makesysoptitle" ) ); |
205 | 201 | $text = wfMsg( "makesysopok", $this->mUser ); |
| 202 | + if ( $this->mSetBureaucrat ) { |
| 203 | + $text .= "<br />" . wfMsg( "makebureaucratok", $this->mUser ); |
| 204 | + } |
206 | 205 | $text .= "\n\n"; |
207 | 206 | $wgOut->addWikiText( $text ); |
208 | 207 | $this->showForm(); |
— | — | @@ -230,10 +229,10 @@ |
231 | 230 | $this->mPosted = $request->wasPosted(); |
232 | 231 | $this->mRequest =& $request; |
233 | 232 | $this->mName = 'userrights'; |
234 | | - |
| 233 | + $this->mReason = htmlspecialchars( $request->getText( 'wpMakesysopReason' ) ); |
235 | 234 | $titleObj = Title::makeTitle( NS_SPECIAL, 'Makesysop' ); |
236 | 235 | $this->action = $titleObj->escapeLocalURL(); |
237 | | - |
| 236 | + |
238 | 237 | $this->db = null; |
239 | 238 | } |
240 | 239 | |
— | — | @@ -243,7 +242,7 @@ |
244 | 243 | $wgOut->addWikiText( wfMsg( 'makesysop-nodatabase', $split->getMessage() ) ); |
245 | 244 | return; |
246 | 245 | } |
247 | | - |
| 246 | + |
248 | 247 | list( $database, $name ) = $split; |
249 | 248 | $this->db =& $this->getDB( $database ); |
250 | 249 | $userid = $this->getUserId( $database, $name ); |
— | — | @@ -251,11 +250,11 @@ |
252 | 251 | if( $userid == 0) { |
253 | 252 | $wgOut->addWikiText( wfMsg( 'nosuchusershort', wfEscapeWikiText( $username ) ) ); |
254 | 253 | return; |
255 | | - } |
| 254 | + } |
256 | 255 | |
257 | 256 | $oldGroups = $this->getUserGroups( $database, $userid ); |
258 | 257 | $newGroups = $oldGroups; |
259 | | - $logcomment = ' '; |
| 258 | + $logcomment = $this->mReason; |
260 | 259 | // remove then add groups |
261 | 260 | if(isset($removegroup)) { |
262 | 261 | $newGroups = array_diff($newGroups, $removegroup); |
— | — | @@ -270,15 +269,15 @@ |
271 | 270 | } |
272 | 271 | } |
273 | 272 | $newGroups = array_unique( $newGroups ); |
274 | | - |
| 273 | + |
275 | 274 | // Ensure that caches are cleared |
276 | 275 | $this->touchUser( $database, $userid ); |
277 | | - |
| 276 | + |
278 | 277 | wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) ); |
279 | 278 | wfDebug( 'newGroups: ' . print_r( $newGroups, true ) ); |
280 | 279 | |
281 | 280 | $log = new LogPage( 'rights' ); |
282 | | - $log->addEntry( 'rights', Title::makeTitle( NS_USER, $username ), '', array( $this->makeGroupNameList( $oldGroups ), |
| 281 | + $log->addEntry( 'rights', Title::makeTitle( NS_USER, $username ), $logcomment, array( $this->makeGroupNameList( $oldGroups ), |
283 | 282 | $this->makeGroupNameList( $newGroups ) ) ); |
284 | 283 | } |
285 | 284 | |
— | — | @@ -294,7 +293,7 @@ |
295 | 294 | $wgOut->addWikiText( wfMsg( 'makesysop-nodatabase', $split->getMessage() ) ); |
296 | 295 | return; |
297 | 296 | } |
298 | | - |
| 297 | + |
299 | 298 | list( $database, $name ) = $split; |
300 | 299 | $this->db =& $this->getDB( $database ); |
301 | 300 | $userid = $this->getUserId( $database, $name ); |
— | — | @@ -302,48 +301,47 @@ |
303 | 302 | if( $userid == 0) { |
304 | 303 | $wgOut->addWikiText( wfMsg( 'nosuchusershort', wfEscapeWikiText( $username ) ) ); |
305 | 304 | return; |
306 | | - } |
307 | | - |
| 305 | + } |
| 306 | + |
308 | 307 | $groups = $this->getUserGroups( $database, $userid ); |
309 | 308 | |
310 | | - $wgOut->addHTML( "<form name=\"editGroup\" action=\"$this->action\" method=\"post\">\n". |
311 | | - wfElement( 'input', array( |
312 | | - 'type' => 'hidden', |
313 | | - 'name' => 'user-editname', |
314 | | - 'value' => $username ) ) . |
315 | | - wfElement( 'input', array( |
316 | | - 'type' => 'hidden', |
317 | | - 'name' => 'wpEditToken', |
318 | | - 'value' => $wgUser->editToken( $username ) ) ) . |
319 | | - $this->fieldset( 'editusergroup', |
320 | | - $wgOut->parse( wfMsg('editing', $username ) ) . |
321 | | - '<table border="0" align="center"><tr><td>'. |
322 | | - HTMLSelectGroups('member', $this->mName.'-groupsmember', $groups,true,6). |
323 | | - '</td><td>'. |
324 | | - HTMLSelectGroups('available', $this->mName.'-groupsavailable', $groups,true,6,true). |
325 | | - '</td></tr></table>'."\n". |
| 309 | + $wgOut->addHTML( |
| 310 | + Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->action, 'name' => 'editGroup' ) ) . |
| 311 | + Xml::hidden( 'user-editname', $username ) . |
| 312 | + Xml::hidden( 'wpEditToken', $wgUser->editToken( $username ) ) . |
| 313 | + Xml::openElement( 'fieldset' ) . |
| 314 | + Xml::element( 'legend', array(), wfMsg( 'userrights-editusergroup' ) ) . |
| 315 | + $wgOut->parse( wfMsg( 'editinguser', $username ) ) . |
| 316 | + "<table border='0' align='center'> |
| 317 | + <tr> |
| 318 | + <td>" . HTMLSelectGroups( 'member', $this->mName.'-groupsmember', $groups, true, 6 ) . "</td> |
| 319 | + <td align='right'>" . HTMLSelectGroups( 'available', $this->mName.'-groupsavailable', $groups, true, 6, true) . "</td> |
| 320 | + </tr><tr> |
| 321 | + <td>" . $wgOut->parse( wfMsg( 'makesysopreason' ) ) . "</td> |
| 322 | + <td align='right'>" . Xml::input( 'wpMakesysopReason', 30 ) . "</td> |
| 323 | + </tr> |
| 324 | + </table> \n" . |
326 | 325 | $wgOut->parse( wfMsg('userrights-groupshelp') ) . |
327 | | - wfElement( 'input', array( |
328 | | - 'type' => 'submit', |
329 | | - 'name' => 'saveusergroups', |
330 | | - 'value' => wfMsg( 'saveusergroups' ) ) ) |
331 | | - )); |
332 | | - $wgOut->addHTML( "</form>\n" ); |
| 326 | + Xml::submitButton( wfMsg( 'saveusergroups' ), array( 'name' => 'saveusergroups' ) ) . |
| 327 | + Xml::closeElement( 'fieldset' ) . |
| 328 | + Xml::closeElement( 'form' ) . "\n" |
| 329 | + ); |
| 330 | + |
333 | 331 | } |
334 | | - |
| 332 | + |
335 | 333 | function splitUsername( $username ) { |
336 | 334 | $parts = explode( '@', $username ); |
337 | 335 | if( count( $parts ) < 2 ) { |
338 | 336 | return array( '', $username ); |
339 | 337 | } |
340 | 338 | list( $name, $database ) = $parts; |
341 | | - |
| 339 | + |
342 | 340 | global $wgLocalDatabases; |
343 | 341 | return array_search( $database, $wgLocalDatabases ) !== false |
344 | 342 | ? array( $database, $name ) |
345 | 343 | : new WikiError( 'Bogus database suffix "' . wfEscapeWikiText( $database ) . '"' ); |
346 | 344 | } |
347 | | - |
| 345 | + |
348 | 346 | /** |
349 | 347 | * Open a database connection to work on for the requested user. |
350 | 348 | * This may be a new connection to another database for remote users. |
— | — | @@ -371,7 +369,7 @@ |
372 | 370 | } |
373 | 371 | return $wgDBserver; |
374 | 372 | } |
375 | | - |
| 373 | + |
376 | 374 | function getUserId( $database, $name ) { |
377 | 375 | if( $name === '' ) |
378 | 376 | return 0; |
— | — | @@ -382,7 +380,7 @@ |
383 | 381 | array( 'user_name' => $name ), |
384 | 382 | 'MakesysopStewardForm::getUserId' ) ); |
385 | 383 | } |
386 | | - |
| 384 | + |
387 | 385 | function getUserGroups( $database, $userid ) { |
388 | 386 | $res = $this->db->select( 'user_groups', |
389 | 387 | array( 'ug_group' ), |
— | — | @@ -394,7 +392,7 @@ |
395 | 393 | } |
396 | 394 | return $groups; |
397 | 395 | } |
398 | | - |
| 396 | + |
399 | 397 | function addUserGroup( $database, $userid, $group ) { |
400 | 398 | $this->db->insert( 'user_groups', |
401 | 399 | array( |
— | — | @@ -404,7 +402,7 @@ |
405 | 403 | 'MakesysopStewardForm::addUserGroup', |
406 | 404 | array( 'IGNORE' ) ); |
407 | 405 | } |
408 | | - |
| 406 | + |
409 | 407 | function removeUserGroup( $database, $userid, $group ) { |
410 | 408 | $this->db->delete( 'user_groups', |
411 | 409 | array( |
— | — | @@ -413,7 +411,7 @@ |
414 | 412 | ), |
415 | 413 | 'MakesysopStewardForm::addUserGroup' ); |
416 | 414 | } |
417 | | - |
| 415 | + |
418 | 416 | function touchUser( $database, $userid ) { |
419 | 417 | $this->db->update( 'user', |
420 | 418 | array( 'user_touched' => $this->db->timestamp() ), |
— | — | @@ -430,5 +428,4 @@ |
431 | 429 | } |
432 | 430 | } |
433 | 431 | |
434 | | - |
435 | 432 | ?> |
Index: trunk/extensions/Makesysop/SpecialMakesysop.i18n.php |
— | — | @@ -13,7 +13,9 @@ |
14 | 14 | 'makesysopname' => 'Name of the user:', |
15 | 15 | 'makesysopsubmit' => 'Make this user into a sysop', |
16 | 16 | 'makesysopok' => "<b>User \"$1\" is now a sysop</b>", |
| 17 | + 'makebureaucratok' => "<b>User \"$1\" is now a bureaucrat</b>", |
17 | 18 | 'makesysopfail' => "<b>User \"$1\" could not be made into a sysop. (Did you enter the name correctly?)</b>", |
| 19 | + 'makesysopreason' => 'Reason:', |
18 | 20 | 'setbureaucratflag' => 'Set bureaucrat flag', |
19 | 21 | 'rights' => 'Rights:', |
20 | 22 | 'set_user_rights' => 'Set user rights', |
— | — | @@ -27,14 +29,6 @@ |
28 | 30 | 'group-steward-member' => 'Steward', |
29 | 31 | 'grouppage-steward' => '{{ns:project}}:Stewards', |
30 | 32 | ); |
31 | | -$wgMakesysopMessages['ar'] = array( |
32 | | - 'setbureaucratflag' => 'ضع علامة بيروقراط', |
33 | | - 'rights' => 'صلاحيات:', |
34 | | - 'set_user_rights' => 'اضبط صلاحيات مستخدم', |
35 | | - 'set_rights_fail' => '<b>لم يتم ضبط الصلاحيات للمستخدم "$1". (هل أدخلت الاسم بصورة صحيحة?)</b>', |
36 | | - 'already_sysop' => 'هذا المستخدم بالفعل إداري', |
37 | | - 'already_bureaucrat' => 'هذا المستخدم بالفعل بيروقراط', |
38 | | -); |
39 | 33 | $wgMakesysopMessages['az'] = array( |
40 | 34 | 'already_sysop' => 'Bu istifadəçi hazirdə idarəçidir', |
41 | 35 | 'already_bureaucrat' => 'Bu istifadəçi hazirdə bürokratdı', |
— | — | @@ -168,16 +162,18 @@ |
169 | 163 | ); |
170 | 164 | $wgMakesysopMessages['de'] = array( |
171 | 165 | 'makesysoptitle' => 'Mache einen Benutzer zum Administrator', |
172 | | - 'makesysoptext' => 'Diese Maske wird von Bürokraten benutzt, um normale Benutzer zu Administratoren zu machen.', |
| 166 | + 'makesysoptext' => 'Mit diesem Formular können Bürokraten normale Benutzer zu Administratoren machen.', |
173 | 167 | 'makesysopname' => 'Benutzername:', |
174 | 168 | 'makesysopsubmit' => 'Mache diesen Benutzer zu einem Administrator', |
175 | 169 | 'makesysopok' => '<b>Benutzer „$1“ ist nun ein Administrator.</b>', |
176 | | - 'makesysopfail' => '<b>Benutzer „$1“ konnte nicht zu einem Administrator gemacht werden. (Haben Sie den Namen richtig geschrieben?)</b>', |
| 170 | + 'makebureaucratok' => '<b>Benutzer „$1“ ist nun ein Bürokrat.</b>', |
| 171 | + 'makesysopfail' => '<b>Benutzer „$1“ existiert nicht.</b>', |
| 172 | + 'makesysopreason' => 'Grund:', |
177 | 173 | 'setbureaucratflag' => 'Mache Benutzer zum Bürokraten', |
178 | 174 | 'rights' => 'Rechte:', |
179 | 175 | 'set_user_rights' => 'Benutzerrechte setzen', |
180 | 176 | 'user_rights_set' => '<b>Benutzerrechte für „$1“ aktualisiert</b>', |
181 | | - 'set_rights_fail' => '<b>Benutzerrechte für „$1“ konnten nicht gesetzt werden. (Haben Sie den Namen korrekt eingegeben?)</b>', |
| 177 | + 'set_rights_fail' => '<b>Benutzerrechte für „$1“ konnten nicht gesetzt werden. Haben Sie den Namen korrekt eingegeben?</b>', |
182 | 178 | 'makesysop' => 'Mache einen Benutzer zum Administrator', |
183 | 179 | 'already_sysop' => 'Dieser Benutzer ist bereits ein Administrator.', |
184 | 180 | 'already_bureaucrat' => 'Dieser Benutzer ist bereits ein Bürokrat.', |
— | — | @@ -645,23 +641,6 @@ |
646 | 642 | 'group-steward-member' => 'Steward', |
647 | 643 | 'grouppage-steward' => '{{ns:project}}:Stewards', |
648 | 644 | ); |
649 | | -$wgMakesysopMessages['oc'] = array( |
650 | | - 'makesysoptitle' => 'Balhar los dreches d’administrator a un utilizaire', |
651 | | - 'makesysoptext' => 'Aqueste formulari es utilizat pels burocratas per balhar los dreches d’administrator a un utilizaire ordinari. Inscrivissètz lo nom de l’utilizaire dins lo quadre e clicatz sul boton per balhar los dreches en question.', |
652 | | - 'makesysopname' => 'Nom de l\'utilizaire:', |
653 | | - 'makesysopsubmit' => 'Balhar los dreches d’administrator a aqueste utilizaire', |
654 | | - 'makesysopok' => '<b>D’ara enlà, l\'utilizaire « $1 » es administrator.</b>', |
655 | | - 'makesysopfail' => '<b>L’utilizaire « $1 » pòt pas èsser nomenat administrator. (Avètz picat corrèctament lo nom ?)</b>', |
656 | | - 'setbureaucratflag' => 'Ajustar l\'estatut de burocrata', |
657 | | - 'rights' => 'Dreches:', |
658 | | - 'set_user_rights' => 'Aplicar los dreches a l’utilizaire', |
659 | | - 'user_rights_set' => '<b>Los dreches de l’utilizaire « $1 » son estats meses a jorn.</b>', |
660 | | - 'set_rights_fail' => '<b>Los dreches de l’utilizaire « $1 » an pas pogut èsser meses a jorn. (Avètz picat lo nom corrèctament ?)<b>', |
661 | | - 'makesysop' => 'Balhar los dreches d’administrator a un utilizaire', |
662 | | - 'already_sysop' => 'Aqueste utilizaire ja es administrator', |
663 | | - 'already_bureaucrat' => 'Aqueste utilizaire ja es burocrata', |
664 | | - 'makesysop-nodatabase' => 'Marrit nom d’utilizaire interwiki : $1', |
665 | | -); |
666 | 645 | $wgMakesysopMessages['pl'] = array( |
667 | 646 | 'makesysoptitle' => 'Nadaj użytkownikowi uprawnienia administratora', |
668 | 647 | 'makesysoptext' => 'Ten formularz jest wykorzystywany przez użytkowników o statusie biurokraty do przyznawania innym użytkownikom praw administratora. Aby to uczynić, wpisz nazwę użytkownika i kliknij na przycisk.', |