Index: trunk/extensions/AbuseFilter/special/SpecialAbuseLog.php |
— | — | @@ -199,7 +199,10 @@ |
200 | 200 | } |
201 | 201 | |
202 | 202 | if ( $this->mSearchFilter ) { |
203 | | - $conds['afl_filter'] = $this->mSearchFilter; |
| 203 | + // if the filter is hidden, users who can't view private filters should not be able to find log entries generated by it |
| 204 | + if ( !AbuseFilter::filterHidden( $this->mSearchFilter ) || AbuseFilterView::canViewPrivate() ) { |
| 205 | + $conds['afl_filter'] = $this->mSearchFilter; |
| 206 | + } |
204 | 207 | } |
205 | 208 | |
206 | 209 | $searchTitle = Title::newFromText( $this->mSearchTitle ); |
— | — | @@ -222,10 +225,6 @@ |
223 | 226 | |
224 | 227 | function showDetails( $id ) { |
225 | 228 | $out = $this->getOutput(); |
226 | | - if ( !self::canSeeDetails() ) { |
227 | | - $out->addWikiMsg( 'abusefilter-log-cannot-see-details' ); |
228 | | - return; |
229 | | - } |
230 | 229 | |
231 | 230 | $dbr = wfGetDB( DB_SLAVE ); |
232 | 231 | |
— | — | @@ -242,6 +241,17 @@ |
243 | 242 | return; |
244 | 243 | } |
245 | 244 | |
| 245 | + if ( AbuseFilter::decodeGlobalName( $row->afl_filter ) ) { |
| 246 | + $filter_hidden = null; |
| 247 | + } else { |
| 248 | + $filter_hidden = $row->af_hidden; |
| 249 | + } |
| 250 | + |
| 251 | + if ( !self::canSeeDetails( $row->afl_filter, $filter_hidden ) ) { |
| 252 | + $out->addWikiMsg( 'abusefilter-log-cannot-see-details' ); |
| 253 | + return; |
| 254 | + } |
| 255 | + |
246 | 256 | if ( $row->afl_deleted && !self::canSeeHidden() ) { |
247 | 257 | $out->addWikiMsg( 'abusefilter-log-details-hidden' ); |
248 | 258 | return; |
— | — | @@ -325,8 +335,18 @@ |
326 | 336 | /** |
327 | 337 | * @return bool |
328 | 338 | */ |
329 | | - static function canSeeDetails() { |
| 339 | + static function canSeeDetails( $filter_id = null, $filter_hidden = null ) { |
330 | 340 | global $wgUser; |
| 341 | + |
| 342 | + if ( $filter_id !== null ) { |
| 343 | + if ( $filter_hidden === null ) { |
| 344 | + $filter_hidden = AbuseFilter::filterHidden( $filter_id ); |
| 345 | + } |
| 346 | + if ( $filter_hidden ) { |
| 347 | + return $wgUser->isAllowed( 'abusefilter-log-detail' ) && AbuseFilterView::canViewPrivate(); |
| 348 | + } |
| 349 | + } |
| 350 | + |
331 | 351 | return $wgUser->isAllowed( 'abusefilter-log-detail' ); |
332 | 352 | } |
333 | 353 | |
— | — | @@ -392,11 +412,13 @@ |
393 | 413 | // Pull global filter description |
394 | 414 | $parsed_comments = |
395 | 415 | $wgOut->parseInline( AbuseFilter::getGlobalFilterDescription( $globalIndex ) ); |
| 416 | + $filter_hidden = null; |
396 | 417 | } else { |
397 | 418 | $parsed_comments = $wgOut->parseInline( $row->af_public_comments ); |
| 419 | + $filter_hidden = $row->af_hidden; |
398 | 420 | } |
399 | 421 | |
400 | | - if ( self::canSeeDetails() ) { |
| 422 | + if ( self::canSeeDetails( $row->afl_filter, $filter_hidden ) ) { |
401 | 423 | $examineTitle = SpecialPage::getTitleFor( 'AbuseFilter', 'examine/log/' . $row->afl_id ); |
402 | 424 | $detailsLink = $sk->makeKnownLinkObj( |
403 | 425 | $this->getTitle($row->afl_id), |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewList.php |
— | — | @@ -225,11 +225,15 @@ |
226 | 226 | $lang->formatNum( $value ) |
227 | 227 | ); |
228 | 228 | // @todo FIXME: makeKnownLinkObj() is deprecated. |
229 | | - $link = Linker::makeKnownLinkObj( |
230 | | - SpecialPage::getTitleFor( 'AbuseLog' ), |
231 | | - $count_display, |
232 | | - 'wpSearchFilter=' . $row->af_id |
233 | | - ); |
| 229 | + if ( SpecialAbuseLog::canSeeDetails( $row->af_id, $row->af_hidden ) ) { |
| 230 | + $link = Linker::makeKnownLinkObj( |
| 231 | + SpecialPage::getTitleFor( 'AbuseLog' ), |
| 232 | + $count_display, |
| 233 | + 'wpSearchFilter=' . $row->af_id |
| 234 | + ); |
| 235 | + } else { |
| 236 | + $link = ""; |
| 237 | + } |
234 | 238 | return $link; |
235 | 239 | case 'af_timestamp': |
236 | 240 | $userLink = |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterView.php |
— | — | @@ -22,9 +22,10 @@ |
23 | 23 | abstract function show(); |
24 | 24 | |
25 | 25 | /** |
| 26 | + * @static |
26 | 27 | * @return bool |
27 | 28 | */ |
28 | | - function canEdit() { |
| 29 | + static function canEdit() { |
29 | 30 | global $wgUser; |
30 | 31 | static $canEdit = null; |
31 | 32 | |
— | — | @@ -36,14 +37,15 @@ |
37 | 38 | } |
38 | 39 | |
39 | 40 | /** |
| 41 | + * @static |
40 | 42 | * @return bool |
41 | 43 | */ |
42 | | - function canViewPrivate() { |
| 44 | + static function canViewPrivate() { |
43 | 45 | global $wgUser; |
44 | 46 | static $canView = null; |
45 | 47 | |
46 | 48 | if ( is_null( $canView ) ) { |
47 | | - $canView = $this->canEdit() || $wgUser->isAllowed( 'abusefilter-view-private' ); |
| 49 | + $canView = self::canEdit() || $wgUser->isAllowed( 'abusefilter-view-private' ); |
48 | 50 | } |
49 | 51 | |
50 | 52 | return $canView; |
Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewExamine.php |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | self::$examineType = 'log'; |
108 | 108 | self::$examineId = $logid; |
109 | 109 | |
110 | | - if ( !SpecialAbuseLog::canSeeDetails() ) { |
| 110 | + if ( !SpecialAbuseLog::canSeeDetails( $row->afl_filter ) ) { |
111 | 111 | $this->getOutput()->addWikiMsg( 'abusefilter-log-cannot-see-details' ); |
112 | 112 | return; |
113 | 113 | } |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -206,7 +206,17 @@ |
207 | 207 | } |
208 | 208 | |
209 | 209 | public static function filterHidden( $filter ) { |
210 | | - $dbr = wfGetDB( DB_SLAVE ); |
| 210 | + $globalIndex = self::decodeGlobalName( $filter ); |
| 211 | + if ( $globalIndex ) { |
| 212 | + global $wgAbuseFilterCentralDB; |
| 213 | + if ( !$wgAbuseFilterCentralDB ) { |
| 214 | + return false; |
| 215 | + } |
| 216 | + $dbr = wfGetDB( DB_SLAVE, array(), $wgAbuseFilterCentralDB ); |
| 217 | + $filter = $globalIndex; |
| 218 | + } else { |
| 219 | + $dbr = wfGetDB( DB_SLAVE ); |
| 220 | + } |
211 | 221 | $hidden = $dbr->selectField( |
212 | 222 | 'abuse_filter', |
213 | 223 | 'af_hidden', |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | 'abusefilter-log-linkoncontribs-text' => 'Abuse log for this user', |
106 | 106 | 'abusefilter-log-hidden' => '(entry hidden)', |
107 | 107 | 'abusefilter-log-hide' => 'hide or unhide', // @todo FIXME: Message unused? |
108 | | - 'abusefilter-log-cannot-see-details' => 'You do not have permission to see details of any entries.', |
| 108 | + 'abusefilter-log-cannot-see-details' => 'You do not have permission to see details of this entry.', |
109 | 109 | 'abusefilter-log-details-hidden' => 'You cannot view the details for this entry because it is hidden from public view.', |
110 | 110 | |
111 | 111 | // Hiding log entries |
— | — | @@ -581,7 +581,7 @@ |
582 | 582 | 'abusefilter-log-linkoncontribs-text' => 'Title for link added on [[Special:Contributions]] and other relevant special pages.', |
583 | 583 | 'abusefilter-log-hidden' => 'Text for a hidden log entry.', |
584 | 584 | 'abusefilter-log-hide' => 'This message may be unused.', |
585 | | - 'abusefilter-log-cannot-see-details' => 'Message show instead of the log row for users without permissions to see any details.', |
| 585 | + 'abusefilter-log-cannot-see-details' => 'Message show instead of log row details for users without permissions to see them.', |
586 | 586 | 'abusefilter-log-details-hidden' => 'Message shown instead of log row details when those are hidden.', |
587 | 587 | 'abusefilter-log-hide-legend' => 'Legend for form to hide a log entry.', |
588 | 588 | 'abusefilter-log-hide-id' => 'Field label in form to hide a log entry.', |