Index: trunk/extensions/CheckUser/CheckUser_body.php |
— | — | @@ -69,8 +69,10 @@ |
70 | 70 | $checktype = $wgRequest->getVal( 'checktype' ); |
71 | 71 | $period = $wgRequest->getInt( 'period' ); |
72 | 72 | $users = $wgRequest->getArray( 'users' ); |
73 | | - $tag = $wgRequest->getBool( 'usetag' ) ? trim( $wgRequest->getVal( 'tag' ) ) : ''; |
74 | | - $talkTag = $wgRequest->getBool( 'usettag' ) ? trim( $wgRequest->getVal( 'talktag' ) ) : ''; |
| 73 | + $tag = $wgRequest->getBool( 'usetag' ) ? |
| 74 | + trim( $wgRequest->getVal( 'tag' ) ) : ''; |
| 75 | + $talkTag = $wgRequest->getBool( 'usettag' ) ? |
| 76 | + trim( $wgRequest->getVal( 'talktag' ) ) : ''; |
75 | 77 | |
76 | 78 | # An IPv4? An IPv6? CIDR included? |
77 | 79 | if ( IP::isIPAddress( $user ) ) { |
— | — | @@ -90,6 +92,7 @@ |
91 | 93 | } |
92 | 94 | |
93 | 95 | $this->doForm( $user, $reason, $checktype, $ip, $xff, $name, $period ); |
| 96 | + |
94 | 97 | # Perform one of the various submit operations... |
95 | 98 | if ( $wgRequest->wasPosted() ) { |
96 | 99 | if ( $wgRequest->getVal( 'action' ) === 'block' ) { |
— | — | @@ -98,16 +101,16 @@ |
99 | 102 | $wgOut->addWikiMsg( 'checkuser-noreason' ); |
100 | 103 | } elseif ( $checktype == 'subuserips' ) { |
101 | 104 | $this->doUserIPsRequest( $name, $reason, $period ); |
102 | | - } elseif ( $xff && $checktype == 'subipedits' ) { |
| 105 | + } elseif ( $xff && $checktype == 'subedits' ) { |
103 | 106 | $this->doIPEditsRequest( $xff, true, $reason, $period ); |
104 | | - } elseif ( $checktype == 'subipedits' ) { |
| 107 | + } elseif ( $ip && $checktype == 'subedits' ) { |
105 | 108 | $this->doIPEditsRequest( $ip, false, $reason, $period ); |
| 109 | + } elseif ( $name && $checktype == 'subedits' ) { |
| 110 | + $this->doUserEditsRequest( $user, $reason, $period ); |
106 | 111 | } elseif ( $xff && $checktype == 'subipusers' ) { |
107 | 112 | $this->doIPUsersRequest( $xff, true, $reason, $period, $tag, $talkTag ); |
108 | 113 | } elseif ( $checktype == 'subipusers' ) { |
109 | 114 | $this->doIPUsersRequest( $ip, false, $reason, $period, $tag, $talkTag ); |
110 | | - } elseif ( $checktype == 'subuseredits' ) { |
111 | | - $this->doUserEditsRequest( $user, $reason, $period ); |
112 | 115 | } |
113 | 116 | } |
114 | 117 | # Add CIDR calculation convenience form |
— | — | @@ -139,18 +142,16 @@ |
140 | 143 | global $wgOut, $wgUser; |
141 | 144 | $action = $this->getTitle()->escapeLocalUrl(); |
142 | 145 | # Fill in requested type if it makes sense |
143 | | - $encipusers = $encipedits = $encuserips = $encuseredits = 0; |
| 146 | + $encipusers = $encedits = $encuserips = 0; |
144 | 147 | if ( $checktype == 'subipusers' && ( $ip || $xff ) ) { |
145 | 148 | $encipusers = 1; |
146 | | - } elseif ( $checktype == 'subipedits' && ( $ip || $xff ) ) { |
147 | | - $encipedits = 1; |
148 | 149 | } elseif ( $checktype == 'subuserips' && $name ) { |
149 | 150 | $encuserips = 1; |
150 | | - } elseif ( $checktype == 'subuseredits' && $name ) { |
151 | | - $encuseredits = 1; |
| 151 | + } elseif ( $checktype == 'subedits' ) { |
| 152 | + $encedits = 1; |
152 | 153 | # Defaults otherwise |
153 | 154 | } elseif ( $ip || $xff ) { |
154 | | - $encipedits = 1; |
| 155 | + $encedits = 1; |
155 | 156 | } else { |
156 | 157 | $encuserips = 1; |
157 | 158 | } |
— | — | @@ -173,12 +174,10 @@ |
174 | 175 | $form .= '<td></td><td class="checkuserradios"><table border="0" cellpadding="3"><tr>'; |
175 | 176 | $form .= '<td>' . Xml::radio( 'checktype', 'subuserips', $encuserips, array( 'id' => 'subuserips' ) ); |
176 | 177 | $form .= ' ' . Xml::label( wfMsg( 'checkuser-ips' ), 'subuserips' ) . '</td>'; |
177 | | - $form .= '<td>' . Xml::radio( 'checktype', 'subipedits', $encipedits, array( 'id' => 'subipedits' ) ); |
178 | | - $form .= ' ' . Xml::label( wfMsg( 'checkuser-edits' ), 'subipedits' ) . '</td>'; |
| 178 | + $form .= '<td>' . Xml::radio( 'checktype', 'subedits', $encedits, array( 'id' => 'subedits' ) ); |
| 179 | + $form .= ' ' . Xml::label( wfMsg( 'checkuser-edits' ), 'subedits' ) . '</td>'; |
179 | 180 | $form .= '<td>' . Xml::radio( 'checktype', 'subipusers', $encipusers, array( 'id' => 'subipusers' ) ); |
180 | 181 | $form .= ' ' . Xml::label( wfMsg( 'checkuser-users' ), 'subipusers' ) . '</td>'; |
181 | | - $form .= '<td>' . Xml::radio( 'checktype', 'subuseredits', $encuseredits, array( 'id' => 'subuseredits' ) ); |
182 | | - $form .= ' ' . Xml::label( wfMsg( 'checkuser-account' ), 'subuseredits' ) . '</td>'; |
183 | 182 | $form .= '</tr></table></td>'; |
184 | 183 | $form .= '</tr><tr>'; |
185 | 184 | $form .= '<td>' . wfMsgHtml( 'checkuser-reason' ) . '</td>'; |
— | — | @@ -259,41 +258,43 @@ |
260 | 259 | } |
261 | 260 | } |
262 | 261 | |
263 | | - protected function noMatchesMessage( $userName ) { |
| 262 | + // Give a "no matches found for X" message. |
| 263 | + // If $checkLast, then mention the last edit by this user or IP. |
| 264 | + protected function noMatchesMessage( $userName, $checkLast = true ) { |
264 | 265 | global $wgLang; |
265 | | - $dbr = wfGetDB( DB_SLAVE ); |
266 | | - $user_id = User::idFromName( $userName ); |
267 | | - if ( $user_id ) { |
268 | | - $revEdit = $dbr->selectField( 'revision', |
269 | | - 'rev_timestamp', |
270 | | - array( 'rev_user' => $user_id ), |
271 | | - __METHOD__, |
272 | | - array( 'ORDER BY' => 'rev_timestamp DESC' ) |
273 | | - ); |
274 | | - } else { |
275 | | - $revEdit = $dbr->selectField( 'revision', |
276 | | - 'rev_timestamp', |
277 | | - array( 'rev_user_text' => $userName ), |
278 | | - __METHOD__, |
279 | | - array( 'ORDER BY' => 'rev_timestamp DESC' ) |
280 | | - ); |
| 266 | + if ( $checkLast ) { |
| 267 | + $dbr = wfGetDB( DB_SLAVE ); |
| 268 | + $user_id = User::idFromName( $userName ); |
| 269 | + if ( $user_id ) { |
| 270 | + $revEdit = $dbr->selectField( 'revision', |
| 271 | + 'rev_timestamp', |
| 272 | + array( 'rev_user' => $user_id ), |
| 273 | + __METHOD__, |
| 274 | + array( 'ORDER BY' => 'rev_timestamp DESC' ) |
| 275 | + ); |
| 276 | + $logEdit = $dbr->selectField( 'logging', |
| 277 | + 'log_timestamp', |
| 278 | + array( 'log_user' => $user_id ), |
| 279 | + __METHOD__, |
| 280 | + array( 'ORDER BY' => 'log_timestamp DESC' ) |
| 281 | + ); |
| 282 | + } else { |
| 283 | + $revEdit = $dbr->selectField( 'revision', |
| 284 | + 'rev_timestamp', |
| 285 | + array( 'rev_user_text' => $userName ), |
| 286 | + __METHOD__, |
| 287 | + array( 'ORDER BY' => 'rev_timestamp DESC' ) |
| 288 | + ); |
| 289 | + $logEdit = false; // no log_user_text index |
| 290 | + } |
| 291 | + $lastEdit = max( $revEdit, $logEdit ); |
| 292 | + if ( $lastEdit ) { |
| 293 | + $lastEditDate = $wgLang->date( wfTimestamp( TS_MW, $lastEdit ), true ); |
| 294 | + $lastEditTime = $wgLang->time( wfTimestamp( TS_MW, $lastEdit ), true ); |
| 295 | + // FIXME: don't pass around parsed messages |
| 296 | + return wfMsgExt( 'checkuser-nomatch-edits', 'parse', $lastEditDate, $lastEditTime ); |
| 297 | + } |
281 | 298 | } |
282 | | - $logEdit = 0; |
283 | | - if ( $user_id ) { |
284 | | - $logEdit = $dbr->selectField( 'logging', |
285 | | - 'log_timestamp', |
286 | | - array( 'log_user' => $user_id ), |
287 | | - __METHOD__, |
288 | | - array( 'ORDER BY' => 'log_timestamp DESC' ) |
289 | | - ); |
290 | | - } |
291 | | - $lastEdit = max( $revEdit, $logEdit ); |
292 | | - if ( $lastEdit ) { |
293 | | - $lastEditDate = $wgLang->date( wfTimestamp( TS_MW, $lastEdit ), true ); |
294 | | - $lastEditTime = $wgLang->time( wfTimestamp( TS_MW, $lastEdit ), true ); |
295 | | - // FIXME: don't pass around parsed messages |
296 | | - return wfMsgExt( 'checkuser-nomatch-edits', 'parse', $lastEditDate, $lastEditTime ); |
297 | | - } |
298 | 299 | return wfMsgExt( 'checkuser-nomatch', 'parse' ); |
299 | 300 | } |
300 | 301 | |
— | — | @@ -538,7 +539,7 @@ |
539 | 540 | $wgOut->addHTML( $s ); |
540 | 541 | return; |
541 | 542 | } elseif ( isset( $rangecount ) && !$rangecount ) { |
542 | | - $s = $this->noMatchesMessage( $ip ) . "\n"; |
| 543 | + $s = $this->noMatchesMessage( $ip, !$xfor ) . "\n"; |
543 | 544 | $wgOut->addHTML( $s ); |
544 | 545 | return; |
545 | 546 | } |
— | — | @@ -550,7 +551,7 @@ |
551 | 552 | $ret = $dbr->query( $sql, __METHOD__ ); |
552 | 553 | |
553 | 554 | if ( !$dbr->numRows( $ret ) ) { |
554 | | - $s = $this->noMatchesMessage( $ip ) . "\n"; |
| 555 | + $s = $this->noMatchesMessage( $ip, !$xfor ) . "\n"; |
555 | 556 | } else { |
556 | 557 | # Cache common messages |
557 | 558 | $this->preCacheMessages(); |
— | — | @@ -799,7 +800,7 @@ |
800 | 801 | $wgOut->addHTML( $s ); |
801 | 802 | return; |
802 | 803 | } elseif ( isset( $rangecount ) && !$rangecount ) { |
803 | | - $s = $this->noMatchesMessage( $ip ) . "\n"; |
| 804 | + $s = $this->noMatchesMessage( $ip, !$xfor ) . "\n"; |
804 | 805 | $wgOut->addHTML( $s ); |
805 | 806 | return; |
806 | 807 | } |
— | — | @@ -814,7 +815,7 @@ |
815 | 816 | |
816 | 817 | $users_first = $users_last = $users_edits = $users_ids = array(); |
817 | 818 | if ( !$dbr->numRows( $ret ) ) { |
818 | | - $s = $this->noMatchesMessage( $ip ) . "\n"; |
| 819 | + $s = $this->noMatchesMessage( $ip, !$xfor ) . "\n"; |
819 | 820 | } else { |
820 | 821 | global $wgAuth; |
821 | 822 | while ( ( $row = $dbr->fetchObject( $ret ) ) != false ) { |
Index: trunk/extensions/CheckUser/CheckUser.i18n.php |
— | — | @@ -32,9 +32,8 @@ |
33 | 33 | 'checkuser-query' => 'Query recent changes', |
34 | 34 | 'checkuser-target' => 'IP address or username:', |
35 | 35 | 'checkuser-users' => 'Get users', |
36 | | - 'checkuser-edits' => 'Get edits from IP address', |
| 36 | + 'checkuser-edits' => 'Get edits', |
37 | 37 | 'checkuser-ips' => 'Get IP addresses', |
38 | | - 'checkuser-account' => 'Get account edits', |
39 | 38 | 'checkuser-search' => 'Search', |
40 | 39 | 'checkuser-period' => 'Duration:', |
41 | 40 | 'checkuser-week-1' => 'last week', |