r21607 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21606‎ | r21607 | r21608 >
Date:09:27, 26 April 2007
Author:raymond
Status:old
Tags:
Comment:
* (bug 9693) Add comment box for user right change to Special:Makesysop
* Input forms in proper XML
* Add success message if bureaucrats are making bureaucrats in MakesysopForm
* Removing Whitespaces
Modified paths:
  • /trunk/extensions/Makesysop/SpecialMakesysop.i18n.php (modified) (history)
  • /trunk/extensions/Makesysop/SpecialMakesysop_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Makesysop/SpecialMakesysop_body.php
@@ -53,7 +53,7 @@
5454 * @addtogroup SpecialPage
5555 */
5656 class MakesysopForm {
57 - var $mTarget, $mAction, $mRights, $mUser, $mSubmit, $mSetBureaucrat;
 57+ var $mTarget, $mAction, $mRights, $mUser, $mReason, $mSubmit, $mSetBureaucrat;
5858
5959 function MakesysopForm( &$request ) {
6060 global $wgUser;
@@ -61,6 +61,7 @@
6262 $this->mAction = $request->getText( 'action' );
6363 $this->mRights = $request->getVal( 'wpRights' );
6464 $this->mUser = $request->getText( 'wpMakesysopUser' );
 65+ $this->mReason = htmlspecialchars( $request->getText( 'wpMakesysopReason' ) );
6566 $this->mSubmit = $request->getBool( 'wpMakesysopSubmit' ) &&
6667 $request->wasPosted() &&
6768 $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
@@ -87,39 +88,34 @@
8889 $encUser = "";
8990 }
9091
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'>
94102 <tr>
95103 <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>
105109 <td>&nbsp;</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>&nbsp;</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"
110119 );
111 -
112 -
113 - $mss = wfMsg( "set_user_rights" );
114 -
115 - $token = htmlspecialchars( $wgUser->editToken() );
116 - $wgOut->addHTML(
117 - "<tr>
118 - <td>&nbsp;</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 - );
124120 }
125121
126122 function doSubmit() {
@@ -127,7 +123,7 @@
128124 global $wgDBname, $wgMemc, $wgLocalDatabases, $wgSharedDB;
129125
130126 $fname = 'MakesysopForm::doSubmit';
131 -
 127+
132128 $dbw =& wfGetDB( DB_MASTER );
133129 $user_groups = $dbw->tableName( 'user_groups' );
134130 $usertable = $dbw->tableName( 'user' );
@@ -141,7 +137,7 @@
142138 return;
143139 }
144140 $username = $t->getText();
145 -
 141+
146142 if ( $username{0} == "#" ) {
147143 $id = intval( substr( $username, 1 ) );
148144 } else {
@@ -187,13 +183,13 @@
188184 } else {
189185 $wgMemc->delete( "$wgDBname:user:id:$id" );
190186 }
191 -
 187+
192188 $newGroups = array_merge($newGroups, $addedGroups);
193 -
 189+
194190 $log = new LogPage( 'rights' );
195 - $log->addEntry( 'rights', Title::makeTitle( NS_USER, $username ), '',
 191+ $log->addEntry( 'rights', Title::makeTitle( NS_USER, $username ), $this->mReason,
196192 array( $this->makeGroupNameList( $oldGroups ), $this->makeGroupNameList( $newGroups ) ) );
197 -
 193+
198194 $this->showSuccess();
199195 }
200196
@@ -202,6 +198,9 @@
203199
204200 $wgOut->setPagetitle( wfMsg( "makesysoptitle" ) );
205201 $text = wfMsg( "makesysopok", $this->mUser );
 202+ if ( $this->mSetBureaucrat ) {
 203+ $text .= "<br />" . wfMsg( "makebureaucratok", $this->mUser );
 204+ }
206205 $text .= "\n\n";
207206 $wgOut->addWikiText( $text );
208207 $this->showForm();
@@ -230,10 +229,10 @@
231230 $this->mPosted = $request->wasPosted();
232231 $this->mRequest =& $request;
233232 $this->mName = 'userrights';
234 -
 233+ $this->mReason = htmlspecialchars( $request->getText( 'wpMakesysopReason' ) );
235234 $titleObj = Title::makeTitle( NS_SPECIAL, 'Makesysop' );
236235 $this->action = $titleObj->escapeLocalURL();
237 -
 236+
238237 $this->db = null;
239238 }
240239
@@ -243,7 +242,7 @@
244243 $wgOut->addWikiText( wfMsg( 'makesysop-nodatabase', $split->getMessage() ) );
245244 return;
246245 }
247 -
 246+
248247 list( $database, $name ) = $split;
249248 $this->db =& $this->getDB( $database );
250249 $userid = $this->getUserId( $database, $name );
@@ -251,11 +250,11 @@
252251 if( $userid == 0) {
253252 $wgOut->addWikiText( wfMsg( 'nosuchusershort', wfEscapeWikiText( $username ) ) );
254253 return;
255 - }
 254+ }
256255
257256 $oldGroups = $this->getUserGroups( $database, $userid );
258257 $newGroups = $oldGroups;
259 - $logcomment = ' ';
 258+ $logcomment = $this->mReason;
260259 // remove then add groups
261260 if(isset($removegroup)) {
262261 $newGroups = array_diff($newGroups, $removegroup);
@@ -270,15 +269,15 @@
271270 }
272271 }
273272 $newGroups = array_unique( $newGroups );
274 -
 273+
275274 // Ensure that caches are cleared
276275 $this->touchUser( $database, $userid );
277 -
 276+
278277 wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) );
279278 wfDebug( 'newGroups: ' . print_r( $newGroups, true ) );
280279
281280 $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 ),
283282 $this->makeGroupNameList( $newGroups ) ) );
284283 }
285284
@@ -294,7 +293,7 @@
295294 $wgOut->addWikiText( wfMsg( 'makesysop-nodatabase', $split->getMessage() ) );
296295 return;
297296 }
298 -
 297+
299298 list( $database, $name ) = $split;
300299 $this->db =& $this->getDB( $database );
301300 $userid = $this->getUserId( $database, $name );
@@ -302,48 +301,47 @@
303302 if( $userid == 0) {
304303 $wgOut->addWikiText( wfMsg( 'nosuchusershort', wfEscapeWikiText( $username ) ) );
305304 return;
306 - }
307 -
 305+ }
 306+
308307 $groups = $this->getUserGroups( $database, $userid );
309308
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" .
326325 $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+
333331 }
334 -
 332+
335333 function splitUsername( $username ) {
336334 $parts = explode( '@', $username );
337335 if( count( $parts ) < 2 ) {
338336 return array( '', $username );
339337 }
340338 list( $name, $database ) = $parts;
341 -
 339+
342340 global $wgLocalDatabases;
343341 return array_search( $database, $wgLocalDatabases ) !== false
344342 ? array( $database, $name )
345343 : new WikiError( 'Bogus database suffix "' . wfEscapeWikiText( $database ) . '"' );
346344 }
347 -
 345+
348346 /**
349347 * Open a database connection to work on for the requested user.
350348 * This may be a new connection to another database for remote users.
@@ -371,7 +369,7 @@
372370 }
373371 return $wgDBserver;
374372 }
375 -
 373+
376374 function getUserId( $database, $name ) {
377375 if( $name === '' )
378376 return 0;
@@ -382,7 +380,7 @@
383381 array( 'user_name' => $name ),
384382 'MakesysopStewardForm::getUserId' ) );
385383 }
386 -
 384+
387385 function getUserGroups( $database, $userid ) {
388386 $res = $this->db->select( 'user_groups',
389387 array( 'ug_group' ),
@@ -394,7 +392,7 @@
395393 }
396394 return $groups;
397395 }
398 -
 396+
399397 function addUserGroup( $database, $userid, $group ) {
400398 $this->db->insert( 'user_groups',
401399 array(
@@ -404,7 +402,7 @@
405403 'MakesysopStewardForm::addUserGroup',
406404 array( 'IGNORE' ) );
407405 }
408 -
 406+
409407 function removeUserGroup( $database, $userid, $group ) {
410408 $this->db->delete( 'user_groups',
411409 array(
@@ -413,7 +411,7 @@
414412 ),
415413 'MakesysopStewardForm::addUserGroup' );
416414 }
417 -
 415+
418416 function touchUser( $database, $userid ) {
419417 $this->db->update( 'user',
420418 array( 'user_touched' => $this->db->timestamp() ),
@@ -430,5 +428,4 @@
431429 }
432430 }
433431
434 -
435432 ?>
Index: trunk/extensions/Makesysop/SpecialMakesysop.i18n.php
@@ -13,7 +13,9 @@
1414 'makesysopname' => 'Name of the user:',
1515 'makesysopsubmit' => 'Make this user into a sysop',
1616 'makesysopok' => "<b>User \"$1\" is now a sysop</b>",
 17+ 'makebureaucratok' => "<b>User \"$1\" is now a bureaucrat</b>",
1718 'makesysopfail' => "<b>User \"$1\" could not be made into a sysop. (Did you enter the name correctly?)</b>",
 19+ 'makesysopreason' => 'Reason:',
1820 'setbureaucratflag' => 'Set bureaucrat flag',
1921 'rights' => 'Rights:',
2022 'set_user_rights' => 'Set user rights',
@@ -27,14 +29,6 @@
2830 'group-steward-member' => 'Steward',
2931 'grouppage-steward' => '{{ns:project}}:Stewards',
3032 );
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 -);
3933 $wgMakesysopMessages['az'] = array(
4034 'already_sysop' => 'Bu istifadəçi hazirdə idarəçidir',
4135 'already_bureaucrat' => 'Bu istifadəçi hazirdə bürokratdı',
@@ -168,16 +162,18 @@
169163 );
170164 $wgMakesysopMessages['de'] = array(
171165 '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.',
173167 'makesysopname' => 'Benutzername:',
174168 'makesysopsubmit' => 'Mache diesen Benutzer zu einem Administrator',
175169 '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:',
177173 'setbureaucratflag' => 'Mache Benutzer zum Bürokraten',
178174 'rights' => 'Rechte:',
179175 'set_user_rights' => 'Benutzerrechte setzen',
180176 '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>',
182178 'makesysop' => 'Mache einen Benutzer zum Administrator',
183179 'already_sysop' => 'Dieser Benutzer ist bereits ein Administrator.',
184180 'already_bureaucrat' => 'Dieser Benutzer ist bereits ein Bürokrat.',
@@ -645,23 +641,6 @@
646642 'group-steward-member' => 'Steward',
647643 'grouppage-steward' => '{{ns:project}}:Stewards',
648644 );
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 -);
666645 $wgMakesysopMessages['pl'] = array(
667646 'makesysoptitle' => 'Nadaj użytkownikowi uprawnienia administratora',
668647 '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.',

Follow-up revisions

RevisionCommit summaryAuthorDate
r21683* (Bug 9693) fix regression, broken since r21658raymond15:36, 28 April 2007