Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -30,6 +30,7 @@ |
31 | 31 | $wgExtensionFunctions[] = 'efLoadReviewMessages'; |
32 | 32 | |
33 | 33 | # Load promotion UI |
| 34 | +include_once('SpecialMakevalidate.php'); |
34 | 35 | # Load review UI |
35 | 36 | extAddSpecialPage( dirname(__FILE__) . '/FlaggedRevsPage.body.php', 'Revisionreview', 'Revisionreview' ); |
36 | 37 | # Load stableversions UI |
— | — | @@ -92,20 +93,6 @@ |
93 | 94 | 'style' => array('review' => 3), |
94 | 95 | ); |
95 | 96 | |
96 | | - |
97 | | -# Allow sysops to grant and revoke 'editor' status. |
98 | | -$wgGroupPermissions['sysop']['userrights'] = true; |
99 | | - |
100 | | -if (isset($wgAddGroups['sysop'])) |
101 | | - array_push( $wgAddGroups['sysop'], 'editor' ); |
102 | | -else |
103 | | - $wgAddGroups['sysop'] = array( 'editor' ); |
104 | | - |
105 | | -if (isset($wgRemoveGroups['sysop'])) |
106 | | - array_push( $wgRemoveGroups['sysop'], 'editor' ); |
107 | | -else |
108 | | - $wgRemoveGroups['sysop'] = array( 'editor' ); |
109 | | - |
110 | 97 | # Use RC Patrolling to check for vandalism |
111 | 98 | # When revisions are flagged, they count as patrolled |
112 | 99 | $wgUseRCPatrol = true; |
— | — | @@ -798,7 +785,7 @@ |
799 | 786 | $fname = 'FlaggedRevs::autoPromoteUser'; |
800 | 787 | |
801 | 788 | # Do not re-add status if it was previously removed... |
802 | | - $dbw = wfGetDB( DB_MASTER ); |
| 789 | + $db = wfGetDB( DB_SLAVE ); |
803 | 790 | $dbr = $dbw->selectRow( 'logging', 'log_params', |
804 | 791 | array( |
805 | 792 | 'log_type' => 'rights', |
— | — | @@ -1439,4 +1426,4 @@ |
1440 | 1427 | $wgHooks['BeforeParserMakeImageLinkObj'][] = array( $flaggedRevsModifier, 'parserMakeStableImageLink'); |
1441 | 1428 | // Additional parser versioning |
1442 | 1429 | $wgHooks['ParserAfterTidy'][] = array( $flaggedRevsModifier, 'parserInjectImageTimestamps'); |
1443 | | -$wgHooks['OutputPageParserOutput'][] = array( $flaggedRevsModifier, 'outputInjectImageTimestamps'); |
| 1430 | +$wgHooks['OutputPageParserOutput'][] = array( $flaggedRevsModifier, 'outputInjectImageTimestamps'); |
\ No newline at end of file |
Index: trunk/extensions/FlaggedRevs/Makevalidate.body.php |
— | — | @@ -1,235 +1,237 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -global $IP;
|
5 | | -require_once( "$IP/includes/LogPage.php" );
|
6 | | -require_once( "$IP/includes/SpecialLog.php" );
|
7 | | -
|
8 | | -class MakeValidate extends SpecialPage {
|
9 | | -
|
10 | | - var $target = '';
|
11 | | -
|
12 | | - /**
|
13 | | - * Constructor
|
14 | | - */
|
15 | | - function MakeValidate() {
|
16 | | - SpecialPage::SpecialPage( 'Makevalidate', 'makereview' );
|
17 | | - }
|
18 | | -
|
19 | | - /**
|
20 | | - * Main execution function
|
21 | | - * @param $par Parameters passed to the page
|
22 | | - */
|
23 | | - function execute( $par ) {
|
24 | | - global $wgRequest, $wgOut, $wgmakevalidatePrivileged, $wgUser;
|
25 | | -
|
26 | | - if( !$wgUser->isAllowed( 'makereview' ) ) {
|
27 | | - $wgOut->permissionRequired( 'makereview' );
|
28 | | - return;
|
29 | | - }
|
30 | | -
|
31 | | - $this->setHeaders();
|
32 | | -
|
33 | | - $this->target = $par
|
34 | | - ? $par
|
35 | | - : $wgRequest->getText( 'username', '' );
|
36 | | -
|
37 | | - $wgOut->addWikiText( wfMsgNoTrans( 'makevalidate-header' ) );
|
38 | | - $wgOut->addHtml( $this->makeSearchForm() );
|
39 | | -
|
40 | | - if( $this->target != '' ) {
|
41 | | - $wgOut->addHtml( wfElement( 'p', NULL, NULL ) );
|
42 | | - $user = User::newFromName( $this->target );
|
43 | | - if( is_object( $user ) && !is_null( $user ) ) {
|
44 | | - global $wgVersion;
|
45 | | - if( version_compare( $wgVersion, '1.9alpha' ) < 0 ) {
|
46 | | - $user->loadFromDatabase();
|
47 | | - } else {
|
48 | | - $user->load();
|
49 | | - }
|
50 | | - # Valid username, check existence
|
51 | | - if( $user->getID() ) {
|
52 | | - if( $wgRequest->getCheck( 'dosearch' ) || !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ), 'makevalidate' ) ) {
|
53 | | - # Exists, check editor & reviewer status
|
54 | | - # We never just assigned reviewer status alone
|
55 | | - if( in_array( 'editor', $user->mGroups ) && in_array( 'reviewer', $user->mGroups ) ) {
|
56 | | - # Has a reviewer flag
|
57 | | - $wgOut->addWikiText( wfMsg( 'makevalidate-iseditor', $user->getName() ) );
|
58 | | - $wgOut->addWikiText( wfMsg( 'makevalidate-isvalidator', $user->getName() ) );
|
59 | | - $wgOut->addHtml( $this->makeGrantForm( MW_MAKEVALIDATE_REVOKE_REVOKE ) );
|
60 | | - } else if( in_array( 'editor', $user->mGroups ) ) {
|
61 | | - # Has a editor flag
|
62 | | - $wgOut->addWikiText( wfMsg( 'makevalidate-iseditor', $user->getName() ) );
|
63 | | - $wgOut->addHtml( $this->makeGrantForm( MW_MAKEVALIDATE_REVOKE_GRANT ) );
|
64 | | - } else if( in_array( 'reviewer', $user->mGroups ) ) {
|
65 | | - # This shouldn't happen...
|
66 | | - $wgOut->addHtml( $this->makeGrantForm( MW_MAKEVALIDATE_GRANT_REVOKE ) );
|
67 | | - } else {
|
68 | | - # Not a reviewer; show the grant form
|
69 | | - $wgOut->addHtml( $this->makeGrantForm( MW_MAKEVALIDATE_GRANT_GRANT ) );
|
70 | | - }
|
71 | | - } elseif( $wgRequest->getCheck( 'grant2' ) ) {
|
72 | | - # Permission check
|
73 | | - if( !$wgUser->isAllowed( 'makevalidate' ) ) {
|
74 | | - $wgOut->permissionRequired( 'makevalidate' ); return;
|
75 | | - }
|
76 | | - # Grant the flag
|
77 | | - if( !in_array( 'editor', $user->mGroups ) )
|
78 | | - $user->addGroup( 'editor' );
|
79 | | - # All reviewers are editors too
|
80 | | - if( !in_array( 'reviewer', $user->mGroups ) )
|
81 | | - $user->addGroup( 'reviewer' );
|
82 | | - $this->addLogItem( 'grant2', $user, trim( $wgRequest->getText( 'comment' ) ) );
|
83 | | - $wgOut->addWikiText( wfMsg( 'makevalidate-granted-r', $user->getName() ) );
|
84 | | - } elseif( $wgRequest->getCheck( 'revoke2' ) ) {
|
85 | | - # Permission check
|
86 | | - if( !$wgUser->isAllowed( 'makevalidate' ) ) {
|
87 | | - $wgOut->permissionRequired( 'makevalidate' ); return;
|
88 | | - }
|
89 | | - # Revoke the flag
|
90 | | - if ( in_array( 'reviewer', $user->mGroups ) )
|
91 | | - $user->removeGroup( 'reviewer' );
|
92 | | - $this->addLogItem( 'revoke2', $user, trim( $wgRequest->getText( 'comment' ) ) );
|
93 | | - $wgOut->addWikiText( wfMsg( 'makevalidate-revoked-r', $user->getName() ) );
|
94 | | - } elseif( $wgRequest->getCheck( 'grant1' ) ) {
|
95 | | - # Grant the flag
|
96 | | - if( !in_array( 'editor', $user->mGroups ) )
|
97 | | - $user->addGroup( 'editor' );
|
98 | | - $this->addLogItem( 'grant1', $user, trim( $wgRequest->getText( 'comment' ) ) );
|
99 | | - $wgOut->addWikiText( wfMsg( 'makevalidate-granted-e', $user->getName() ) );
|
100 | | - } elseif( $wgRequest->getCheck( 'revoke1' ) ) {
|
101 | | - if( in_array( 'reviewer', $user->mGroups ) ) {
|
102 | | - # Permission check
|
103 | | - if( !$wgUser->isAllowed( 'makevalidate' ) ) {
|
104 | | - $wgOut->permissionRequired( 'makevalidate' ); return;
|
105 | | - }
|
106 | | - # Reviewer flag falls of too
|
107 | | - $user->removeGroup( 'reviewer' );
|
108 | | - } else if( in_array( 'editor', $user->mGroups ) ) {
|
109 | | - # Revoke the flag
|
110 | | - $user->removeGroup( 'editor' );
|
111 | | - }
|
112 | | - $this->addLogItem( 'revoke1', $user, trim( $wgRequest->getText( 'comment' ) ) );
|
113 | | - $wgOut->addWikiText( wfMsg( 'makevalidate-revoked-e', $user->getName() ) );
|
114 | | - }
|
115 | | - # Show log entries
|
116 | | - $this->showLogEntries( $user );
|
117 | | - } else {
|
118 | | - # Doesn't exist
|
119 | | - $wgOut->addWikiText( wfMsg( 'nosuchusershort', htmlspecialchars( $this->target ) ) );
|
120 | | - }
|
121 | | - } else {
|
122 | | - # Invalid username
|
123 | | - $wgOut->addWikiText( wfMsg( 'noname' ) );
|
124 | | - }
|
125 | | - }
|
126 | | -
|
127 | | - }
|
128 | | -
|
129 | | - /**
|
130 | | - * Produce a form to allow for entering a username
|
131 | | - * @return string
|
132 | | - */
|
133 | | - function makeSearchForm() {
|
134 | | - $thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() );
|
135 | | - $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $thisTitle->getLocalUrl() ) );
|
136 | | - $form .= wfElement( 'label', array( 'for' => 'username' ), wfMsg( 'makevalidate-username' ) ) . ' ';
|
137 | | - $form .= wfElement( 'input', array( 'type' => 'text', 'name' => 'username', 'id' => 'username', 'value' => $this->target ) ) . ' ';
|
138 | | - $form .= wfElement( 'input', array( 'type' => 'submit', 'name' => 'dosearch', 'value' => wfMsg( 'makevalidate-search' ) ) );
|
139 | | - $form .= wfCloseElement( 'form' );
|
140 | | - return $form;
|
141 | | - }
|
142 | | -
|
143 | | - /**
|
144 | | - * Produce a form to allow granting or revocation of the flag
|
145 | | - * @param $type Either MW_makevalidate_GRANT or MW_makevalidate_REVOKE
|
146 | | - * where the trailing name refers to what's enabled
|
147 | | - * @return string
|
148 | | - */
|
149 | | - function makeGrantForm( $type ) {
|
150 | | - global $wgUser;
|
151 | | - $thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() );
|
152 | | - if( $type == MW_MAKEVALIDATE_GRANT_GRANT ) {
|
153 | | - $grant1 = true; $revoke1 = false;
|
154 | | - $grant2 = true; $revoke2 = false;
|
155 | | - } else if ( $type == MW_MAKEVALIDATE_REVOKE_GRANT ) {
|
156 | | - $grant1 = false; $revoke1 = true;
|
157 | | - $grant2 = true; $revoke2 = false;
|
158 | | - } else if ( $type == MW_MAKEVALIDATE_REVOKE_REVOKE ) {
|
159 | | - $grant1 = false; $revoke1 = $wgUser->isAllowed('makevalidate');
|
160 | | - $grant2 = false; $revoke2 = true;
|
161 | | - } else {
|
162 | | - // OK, this one should never happen
|
163 | | - $grant1 = true; $revoke1 = $wgUser->isAllowed('makevalidate');
|
164 | | - $grant2 = false; $revoke2 = true;
|
165 | | - }
|
166 | | -
|
167 | | - # Start the table
|
168 | | - $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $thisTitle->getLocalUrl() ) );
|
169 | | - $form .= '<fieldset><legend>' . wfMsg('makevalidate-legend') . '</legend>';
|
170 | | - $form .= wfOpenElement( 'table' ) . wfOpenElement( 'tr' );
|
171 | | - # Grant/revoke buttons
|
172 | | - $form .= wfElement( 'td', array( 'align' => 'right' ), wfMsg( 'makevalidate-change-e' ) );
|
173 | | - $form .= wfOpenElement( 'td' );
|
174 | | - foreach( array( 'grant1', 'revoke1' ) as $button ) {
|
175 | | - $attribs = array( 'type' => 'submit', 'name' => $button, 'value' => wfMsg( 'makevalidate-' . $button ) );
|
176 | | - if( !$$button )
|
177 | | - $attribs['disabled'] = 'disabled';
|
178 | | - $form .= wfElement( 'input', $attribs );
|
179 | | - }
|
180 | | - $form .= wfCloseElement( 'td' ) . wfCloseElement( 'tr' );
|
181 | | - // Check permissions
|
182 | | - if ( $wgUser->isAllowed('makevalidate') ) {
|
183 | | - $form .= wfElement( 'td', array( 'align' => 'right' ), wfMsg( 'makevalidate-change-r' ) );
|
184 | | - $form .= wfOpenElement( 'td' );
|
185 | | - foreach( array( 'grant2', 'revoke2' ) as $button ) {
|
186 | | - $attribs = array( 'type' => 'submit', 'name' => $button, 'value' => wfMsg( 'makevalidate-' . $button ) );
|
187 | | - if( !$$button )
|
188 | | - $attribs['disabled'] = 'disabled';
|
189 | | - $form .= wfElement( 'input', $attribs );
|
190 | | - }
|
191 | | - $form .= wfCloseElement( 'td' ) . wfCloseElement( 'tr' );
|
192 | | - }
|
193 | | - # Comment field
|
194 | | - $form .= wfOpenElement( 'td', array( 'align' => 'right' ) );
|
195 | | - $form .= wfElement( 'label', array( 'for' => 'comment' ), wfMsg( 'makevalidate-comment' ) );
|
196 | | - $form .= wfOpenElement( 'td' );
|
197 | | - $form .= wfElement( 'input', array( 'type' => 'text', 'name' => 'comment', 'id' => 'comment', 'size' => 45 ) );
|
198 | | - $form .= wfCloseElement( 'td' ) . wfCloseElement( 'tr' );
|
199 | | - # End table
|
200 | | - $form .= wfCloseElement( 'table' );
|
201 | | - # Username
|
202 | | - $form .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'username', 'value' => $this->target ) );
|
203 | | - # Edit token
|
204 | | - $form .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'token', 'value' => $wgUser->editToken( 'makevalidate' ) ) );
|
205 | | - $form .= '</fieldset>';
|
206 | | - $form .= wfCloseElement( 'form' );
|
207 | | - return $form;
|
208 | | - }
|
209 | | -
|
210 | | - /**
|
211 | | - * Add logging entries for the specified action
|
212 | | - * @param $type Either grant or revoke
|
213 | | - * @param $target User receiving the action
|
214 | | - * @param $comment Comment for the log item
|
215 | | - */
|
216 | | - function addLogItem( $type, &$target, $comment = '' ) {
|
217 | | - $log = new LogPage( 'validate' );
|
218 | | - $targetPage = $target->getUserPage();
|
219 | | - $log->addEntry( $type, $targetPage, $comment );
|
220 | | - }
|
221 | | -
|
222 | | - /**
|
223 | | - * Show the bot status log entries for the specified user
|
224 | | - * @param $user User to show the log for
|
225 | | - */
|
226 | | - function showLogEntries( &$user ) {
|
227 | | - global $wgOut;
|
228 | | - $title = $user->getUserPage();
|
229 | | - $wgOut->addHtml( wfElement( 'h2', NULL, htmlspecialchars( LogPage::logName( 'validate' ) ) ) );
|
230 | | - $logViewer = new LogViewer( new LogReader( new FauxRequest( array( 'page' => $title->getPrefixedText(), 'type' => 'validate' ) ) ) );
|
231 | | - $logViewer->showList( $wgOut );
|
232 | | - }
|
233 | | -
|
234 | | -}
|
235 | | -
|
| 2 | +<?php |
236 | 3 | |
| 4 | +global $IP; |
| 5 | +require_once( "$IP/includes/LogPage.php" ); |
| 6 | +require_once( "$IP/includes/SpecialLog.php" ); |
| 7 | + |
| 8 | +class MakeValidate extends SpecialPage { |
| 9 | + |
| 10 | + var $target = ''; |
| 11 | + |
| 12 | + /** |
| 13 | + * Constructor |
| 14 | + */ |
| 15 | + function MakeValidate() { |
| 16 | + SpecialPage::SpecialPage( 'Makevalidate', 'makereview' ); |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * Main execution function |
| 21 | + * @param $par Parameters passed to the page |
| 22 | + */ |
| 23 | + function execute( $par ) { |
| 24 | + global $wgRequest, $wgOut, $wgmakevalidatePrivileged, $wgUser; |
| 25 | + |
| 26 | + if( !$wgUser->isAllowed( 'makereview' ) ) { |
| 27 | + $wgOut->permissionRequired( 'makereview' ); |
| 28 | + return; |
| 29 | + } |
| 30 | + |
| 31 | + $this->setHeaders(); |
| 32 | + |
| 33 | + $this->target = $par |
| 34 | + ? $par |
| 35 | + : $wgRequest->getText( 'username', '' ); |
| 36 | + |
| 37 | + $wgOut->addWikiText( wfMsgNoTrans( 'makevalidate-header' ) ); |
| 38 | + $wgOut->addHtml( $this->makeSearchForm() ); |
| 39 | + |
| 40 | + if( $this->target != '' ) { |
| 41 | + $wgOut->addHtml( wfElement( 'p', NULL, NULL ) ); |
| 42 | + $user = User::newFromName( $this->target ); |
| 43 | + if( is_object( $user ) && !is_null( $user ) ) { |
| 44 | + global $wgVersion; |
| 45 | + if( version_compare( $wgVersion, '1.9alpha' ) < 0 ) { |
| 46 | + $user->loadFromDatabase(); |
| 47 | + } else { |
| 48 | + $user->load(); |
| 49 | + } |
| 50 | + # Valid username, check existence |
| 51 | + if( $user->getID() ) { |
| 52 | + $oldgroups = $user->getGroups(); |
| 53 | + if( $wgRequest->getCheck( 'dosearch' ) || !$wgRequest->wasPosted() || !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ), 'makevalidate' ) ) { |
| 54 | + # Exists, check editor & reviewer status |
| 55 | + # We never just assigned reviewer status alone |
| 56 | + if( in_array( 'editor', $user->mGroups ) && in_array( 'reviewer', $user->mGroups ) ) { |
| 57 | + # Has a reviewer flag |
| 58 | + $wgOut->addWikiText( wfMsg( 'makevalidate-iseditor', $user->getName() ) ); |
| 59 | + $wgOut->addWikiText( wfMsg( 'makevalidate-isvalidator', $user->getName() ) ); |
| 60 | + $wgOut->addHtml( $this->makeGrantForm( MW_MAKEVALIDATE_REVOKE_REVOKE ) ); |
| 61 | + } else if( in_array( 'editor', $user->mGroups ) ) { |
| 62 | + # Has a editor flag |
| 63 | + $wgOut->addWikiText( wfMsg( 'makevalidate-iseditor', $user->getName() ) ); |
| 64 | + $wgOut->addHtml( $this->makeGrantForm( MW_MAKEVALIDATE_REVOKE_GRANT ) ); |
| 65 | + } else if( in_array( 'reviewer', $user->mGroups ) ) { |
| 66 | + # This shouldn't happen... |
| 67 | + $wgOut->addHtml( $this->makeGrantForm( MW_MAKEVALIDATE_GRANT_REVOKE ) ); |
| 68 | + } else { |
| 69 | + # Not a reviewer; show the grant form |
| 70 | + $wgOut->addHtml( $this->makeGrantForm( MW_MAKEVALIDATE_GRANT_GRANT ) ); |
| 71 | + } |
| 72 | + } elseif( $wgRequest->getCheck( 'grant2' ) ) { |
| 73 | + # Permission check |
| 74 | + if( !$wgUser->isAllowed( 'makevalidate' ) ) { |
| 75 | + $wgOut->permissionRequired( 'makevalidate' ); return; |
| 76 | + } |
| 77 | + # Grant the flag |
| 78 | + if( !in_array( 'editor', $user->mGroups ) ) |
| 79 | + $user->addGroup( 'editor' ); |
| 80 | + # All reviewers are editors too |
| 81 | + if( !in_array( 'reviewer', $user->mGroups ) ) |
| 82 | + $user->addGroup( 'reviewer' ); |
| 83 | + $this->addLogItem( 'grant2', $user, trim( $wgRequest->getText( 'comment' ) ), $oldgroups); |
| 84 | + $wgOut->addWikiText( wfMsg( 'makevalidate-granted-r', $user->getName() ) ); |
| 85 | + } elseif( $wgRequest->getCheck( 'revoke2' ) ) { |
| 86 | + # Permission check |
| 87 | + if( !$wgUser->isAllowed( 'makevalidate' ) ) { |
| 88 | + $wgOut->permissionRequired( 'makevalidate' ); return; |
| 89 | + } |
| 90 | + # Revoke the flag |
| 91 | + if ( in_array( 'reviewer', $user->mGroups ) ) |
| 92 | + $user->removeGroup( 'reviewer' ); |
| 93 | + $this->addLogItem( 'revoke2', $user, trim( $wgRequest->getText( 'comment' ) ), $oldgroups ); |
| 94 | + $wgOut->addWikiText( wfMsg( 'makevalidate-revoked-r', $user->getName() ) ); |
| 95 | + } elseif( $wgRequest->getCheck( 'grant1' ) ) { |
| 96 | + # Grant the flag |
| 97 | + if( !in_array( 'editor', $user->mGroups ) ) |
| 98 | + $user->addGroup( 'editor' ); |
| 99 | + $this->addLogItem( 'grant1', $user, trim( $wgRequest->getText( 'comment' ) ), $oldgroups ); |
| 100 | + $wgOut->addWikiText( wfMsg( 'makevalidate-granted-e', $user->getName() ) ); |
| 101 | + } elseif( $wgRequest->getCheck( 'revoke1' ) ) { |
| 102 | + if( in_array( 'reviewer', $user->mGroups ) ) { |
| 103 | + # Permission check |
| 104 | + if( !$wgUser->isAllowed( 'makevalidate' ) ) { |
| 105 | + $wgOut->permissionRequired( 'makevalidate' ); return; |
| 106 | + } |
| 107 | + # Reviewer flag falls of too |
| 108 | + $user->removeGroup( 'reviewer' ); |
| 109 | + } else if( in_array( 'editor', $user->mGroups ) ) { |
| 110 | + # Revoke the flag |
| 111 | + $user->removeGroup( 'editor' ); |
| 112 | + } |
| 113 | + $this->addLogItem( 'revoke1', $user, trim( $wgRequest->getText( 'comment' ) ), $oldgroups ); |
| 114 | + $wgOut->addWikiText( wfMsg( 'makevalidate-revoked-e', $user->getName() ) ); |
| 115 | + } |
| 116 | + # Show log entries |
| 117 | + $this->showLogEntries( $user ); |
| 118 | + } else { |
| 119 | + # Doesn't exist |
| 120 | + $wgOut->addWikiText( wfMsg( 'nosuchusershort', htmlspecialchars( $this->target ) ) ); |
| 121 | + } |
| 122 | + } else { |
| 123 | + # Invalid username |
| 124 | + $wgOut->addWikiText( wfMsg( 'noname' ) ); |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * Produce a form to allow for entering a username |
| 132 | + * @return string |
| 133 | + */ |
| 134 | + function makeSearchForm() { |
| 135 | + $thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() ); |
| 136 | + $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $thisTitle->getLocalUrl() ) ); |
| 137 | + $form .= wfElement( 'label', array( 'for' => 'username' ), wfMsg( 'makevalidate-username' ) ) . ' '; |
| 138 | + $form .= wfElement( 'input', array( 'type' => 'text', 'name' => 'username', 'id' => 'username', 'value' => $this->target ) ) . ' '; |
| 139 | + $form .= wfElement( 'input', array( 'type' => 'submit', 'name' => 'dosearch', 'value' => wfMsg( 'makevalidate-search' ) ) ); |
| 140 | + $form .= wfCloseElement( 'form' ); |
| 141 | + return $form; |
| 142 | + } |
| 143 | + |
| 144 | + /** |
| 145 | + * Produce a form to allow granting or revocation of the flag |
| 146 | + * @param $type Either MW_makevalidate_GRANT or MW_makevalidate_REVOKE |
| 147 | + * where the trailing name refers to what's enabled |
| 148 | + * @return string |
| 149 | + */ |
| 150 | + function makeGrantForm( $type ) { |
| 151 | + global $wgUser; |
| 152 | + $thisTitle = Title::makeTitle( NS_SPECIAL, $this->getName() ); |
| 153 | + if( $type == MW_MAKEVALIDATE_GRANT_GRANT ) { |
| 154 | + $grant1 = true; $revoke1 = false; |
| 155 | + $grant2 = true; $revoke2 = false; |
| 156 | + } else if ( $type == MW_MAKEVALIDATE_REVOKE_GRANT ) { |
| 157 | + $grant1 = false; $revoke1 = true; |
| 158 | + $grant2 = true; $revoke2 = false; |
| 159 | + } else if ( $type == MW_MAKEVALIDATE_REVOKE_REVOKE ) { |
| 160 | + $grant1 = false; $revoke1 = $wgUser->isAllowed('makevalidate'); |
| 161 | + $grant2 = false; $revoke2 = true; |
| 162 | + } else { |
| 163 | + // OK, this one should never happen |
| 164 | + $grant1 = true; $revoke1 = $wgUser->isAllowed('makevalidate'); |
| 165 | + $grant2 = false; $revoke2 = true; |
| 166 | + } |
| 167 | + |
| 168 | + # Start the table |
| 169 | + $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $thisTitle->getLocalUrl() ) ); |
| 170 | + $form .= '<fieldset><legend>' . wfMsg('makevalidate-legend') . '</legend>'; |
| 171 | + $form .= wfOpenElement( 'table' ) . wfOpenElement( 'tr' ); |
| 172 | + # Grant/revoke buttons |
| 173 | + $form .= wfElement( 'td', array( 'align' => 'right' ), wfMsg( 'makevalidate-change-e' ) ); |
| 174 | + $form .= wfOpenElement( 'td' ); |
| 175 | + foreach( array( 'grant1', 'revoke1' ) as $button ) { |
| 176 | + $attribs = array( 'type' => 'submit', 'name' => $button, 'value' => wfMsg( 'makevalidate-' . $button ) ); |
| 177 | + if( !$$button ) |
| 178 | + $attribs['disabled'] = 'disabled'; |
| 179 | + $form .= wfElement( 'input', $attribs ); |
| 180 | + } |
| 181 | + $form .= wfCloseElement( 'td' ) . wfCloseElement( 'tr' ); |
| 182 | + // Check permissions |
| 183 | + if ( $wgUser->isAllowed('makevalidate') ) { |
| 184 | + $form .= wfElement( 'td', array( 'align' => 'right' ), wfMsg( 'makevalidate-change-r' ) ); |
| 185 | + $form .= wfOpenElement( 'td' ); |
| 186 | + foreach( array( 'grant2', 'revoke2' ) as $button ) { |
| 187 | + $attribs = array( 'type' => 'submit', 'name' => $button, 'value' => wfMsg( 'makevalidate-' . $button ) ); |
| 188 | + if( !$$button ) |
| 189 | + $attribs['disabled'] = 'disabled'; |
| 190 | + $form .= wfElement( 'input', $attribs ); |
| 191 | + } |
| 192 | + $form .= wfCloseElement( 'td' ) . wfCloseElement( 'tr' ); |
| 193 | + } |
| 194 | + # Comment field |
| 195 | + $form .= wfOpenElement( 'td', array( 'align' => 'right' ) ); |
| 196 | + $form .= wfElement( 'label', array( 'for' => 'comment' ), wfMsg( 'makevalidate-comment' ) ); |
| 197 | + $form .= wfOpenElement( 'td' ); |
| 198 | + $form .= wfElement( 'input', array( 'type' => 'text', 'name' => 'comment', 'id' => 'comment', 'size' => 45 ) ); |
| 199 | + $form .= wfCloseElement( 'td' ) . wfCloseElement( 'tr' ); |
| 200 | + # End table |
| 201 | + $form .= wfCloseElement( 'table' ); |
| 202 | + # Username |
| 203 | + $form .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'username', 'value' => $this->target ) ); |
| 204 | + # Edit token |
| 205 | + $form .= wfElement( 'input', array( 'type' => 'hidden', 'name' => 'token', 'value' => $wgUser->editToken( 'makevalidate' ) ) ); |
| 206 | + $form .= '</fieldset>'; |
| 207 | + $form .= wfCloseElement( 'form' ); |
| 208 | + return $form; |
| 209 | + } |
| 210 | + |
| 211 | + /** |
| 212 | + * Add logging entries for the specified action |
| 213 | + * @param $type Either grant or revoke |
| 214 | + * @param $target User receiving the action |
| 215 | + * @param $comment Comment for the log item |
| 216 | + */ |
| 217 | + function addLogItem( $type, &$target, $comment = '', $oldgroups ) { |
| 218 | + global $wgUser; |
| 219 | + $log = new LogPage( 'rights' ); |
| 220 | + $targetPage = $target->getUserPage(); |
| 221 | + $log->addEntry( 'rights', $targetPage, $comment, array( |
| 222 | + implode( ', ', $oldgroups ), |
| 223 | + implode( ', ', $target->getGroups() ) ) ); |
| 224 | + } |
| 225 | + |
| 226 | + /** |
| 227 | + * Show the bot status log entries for the specified user |
| 228 | + * @param $user User to show the log for |
| 229 | + */ |
| 230 | + function showLogEntries( &$user ) { |
| 231 | + global $wgOut; |
| 232 | + $title = $user->getUserPage(); |
| 233 | + $wgOut->addHtml( wfElement( 'h2', NULL, htmlspecialchars( LogPage::logName( 'rights' ) ) ) ); |
| 234 | + $logViewer = new LogViewer( new LogReader( new FauxRequest( array( 'page' => $title->getPrefixedText(), 'type' => 'rights' ) ) ) ); |
| 235 | + $logViewer->showList( $wgOut ); |
| 236 | + } |
| 237 | + |
| 238 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/FlaggedRevs/Makevalidate.body.php |
___________________________________________________________________ |
Added: svn:eol-style |
237 | 239 | + LF |
Index: trunk/extensions/FlaggedRevs/SpecialMakevalidate.php |
— | — | @@ -42,17 +42,10 @@ |
43 | 43 | * Populate the message cache and set up the auditing |
44 | 44 | */ |
45 | 45 | function efMakeValidate() { |
46 | | - global $wgMessageCache, $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions; |
| 46 | + global $wgMessageCache; |
47 | 47 | require_once( dirname( __FILE__ ) . '/Makevalidate.i18n.php' ); |
48 | 48 | foreach( efMakeValidateMessages() as $lang => $messages ) |
49 | 49 | $wgMessageCache->addMessages( $messages, $lang ); |
50 | | - $wgLogTypes[] = 'validate'; |
51 | | - $wgLogNames['validate'] = 'makevalidate-logpage'; |
52 | | - $wgLogHeaders['validate'] = 'makevalidate-logpagetext'; |
53 | | - $wgLogActions['validate/grant1'] = 'makevalidate-logentrygrant-e'; |
54 | | - $wgLogActions['validate/revoke1'] = 'makevalidate-logentryrevoke-e'; |
55 | | - $wgLogActions['validate/grant2'] = 'makevalidate-logentrygrant-r'; |
56 | | - $wgLogActions['validate/revoke2'] = 'makevalidate-logentryrevoke-r'; |
57 | 50 | } |
58 | 51 | |
59 | 52 | } else { |