Index: trunk/extensions/AbuseFilter/Views/AbuseFilterViewHistory.php |
— | — | @@ -21,9 +21,17 @@ |
22 | 22 | $wgOut->setPageTitle( wfMsg( 'abusefilter-history', $filter ) ); |
23 | 23 | else |
24 | 24 | $wgOut->setPageTitle( wfMsg( 'abusefilter-filter-log' ) ); |
| 25 | + |
| 26 | + ## Check perms |
| 27 | + if ( $filter && |
| 28 | + !$wgUser->isAllowed( 'abusefilter-modify' ) && |
| 29 | + AbuseFilter::filterHidden( $filter ) ) { |
| 30 | + $wgOut->addWikiMsg( 'abusefilter-history-error-hidden' ); |
| 31 | + return; |
| 32 | + } |
25 | 33 | |
| 34 | + ## Useful links |
26 | 35 | $sk = $wgUser->getSkin(); |
27 | | - |
28 | 36 | $links = array(); |
29 | 37 | if ($filter) |
30 | 38 | $links['abusefilter-history-backedit'] = $this->getTitle( $filter ); |
— | — | @@ -35,12 +43,14 @@ |
36 | 44 | $backlinks = $wgLang->pipeList( $links ); |
37 | 45 | $wgOut->addHTML( Xml::tags( 'p', null, $backlinks ) ); |
38 | 46 | |
| 47 | + ## For user |
39 | 48 | $user = $wgRequest->getText( 'user' ); |
40 | 49 | if ($user) { |
41 | 50 | $wgOut->setSubtitle( |
42 | 51 | wfMsg( |
43 | 52 | 'abusefilter-history-foruser', |
44 | | - $sk->userLink( 1 /* We don't really need to get a user ID */, $user ) |
| 53 | + $sk->userLink( 1 /* We don't really need to get a user ID */, $user ), |
| 54 | + $user // For GENDER |
45 | 55 | ) |
46 | 56 | ); |
47 | 57 | } |
— | — | @@ -187,31 +197,47 @@ |
188 | 198 | |
189 | 199 | function getQueryInfo() { |
190 | 200 | $info = array( |
191 | | - 'tables' => 'abuse_filter_history', |
| 201 | + 'tables' => array( 'abuse_filter_history', 'abuse_filter' ), |
192 | 202 | 'fields' => array( |
193 | | - 'afh_filter', |
194 | | - 'afh_timestamp', |
195 | | - 'afh_user_text', |
196 | | - 'afh_public_comments', |
197 | | - 'afh_flags', |
198 | | - 'afh_comments', |
199 | | - 'afh_actions', |
200 | | - 'afh_id', |
201 | | - 'afh_user', |
202 | | - 'afh_changed_fields', |
203 | | - 'afh_pattern', |
204 | | - 'afh_id' ), |
| 203 | + 'afh_filter', |
| 204 | + 'afh_timestamp', |
| 205 | + 'afh_user_text', |
| 206 | + 'afh_public_comments', |
| 207 | + 'afh_flags', |
| 208 | + 'afh_comments', |
| 209 | + 'afh_actions', |
| 210 | + 'afh_id', |
| 211 | + 'afh_user', |
| 212 | + 'afh_changed_fields', |
| 213 | + 'afh_pattern', |
| 214 | + 'afh_id', |
| 215 | + 'af_hidden' |
| 216 | + ), |
205 | 217 | 'conds' => array(), |
| 218 | + 'join_conds' => array( |
| 219 | + 'abuse_filter' => |
| 220 | + array( |
| 221 | + 'LEFT JOIN', |
| 222 | + 'afh_filter=af_id', |
| 223 | + ), |
| 224 | + ), |
206 | 225 | ); |
207 | 226 | |
208 | | - global $wgRequest; |
| 227 | + global $wgRequest, $wgUser; |
| 228 | + |
209 | 229 | if ($this->mUser) { |
210 | 230 | $info['conds']['afh_user_text'] = $this->mUser; |
211 | 231 | } |
| 232 | + |
212 | 233 | if ( $this->mFilter ) { |
213 | 234 | $info['conds']['afh_filter'] = $this->mFilter; |
214 | 235 | } |
215 | 236 | |
| 237 | + if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) { |
| 238 | + // Hide data the user can't see. |
| 239 | + $info['conds']['af_hidden'] = 0; |
| 240 | + } |
| 241 | + |
216 | 242 | return $info; |
217 | 243 | } |
218 | 244 | |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -202,6 +202,16 @@ |
203 | 203 | |
204 | 204 | return strval($row->af_pattern); |
205 | 205 | } |
| 206 | + |
| 207 | + public static function filterHidden( $filter ) { |
| 208 | + $dbr = wfGetDB( DB_SLAVE ); |
| 209 | + $hidden = $dbr->selectField( 'abuse_filter', |
| 210 | + 'af_hidden', |
| 211 | + array( 'af_id' => $filter ), |
| 212 | + __METHOD__ |
| 213 | + ); |
| 214 | + return $hidden ? true : false; |
| 215 | + } |
206 | 216 | |
207 | 217 | public static function ajaxCheckFilterWithVars( $filter, $vars ) { |
208 | 218 | global $wgUser; |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -301,6 +301,7 @@ |
302 | 302 | 'abusefilter-history-select-user' => 'User:', |
303 | 303 | 'abusefilter-history-select-submit' => 'Refine', |
304 | 304 | 'abusefilter-history-diff' => 'Changes', |
| 305 | + 'abusefilter-history-error-hidden' => 'The filter you requested is hidden, and you cannot view its history.', |
305 | 306 | |
306 | 307 | // Exceptions |
307 | 308 | 'abusefilter-exception-unexpectedatend' => 'Unexpected "$2" at character $1.', |