Index: trunk/extensions/FilterListUsers/FilterListUsers.i18n.php |
— | — | @@ -0,0 +1,33 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalization file for the FilterListUsers extension. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Jack Phoenix <jack@countervandalism.net> |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'listusers-showall' => 'Show all users, including those with less than 5 edits', |
| 17 | + 'right-viewallusers' => 'View all users in [[Special:ListUsers|the user list]]' |
| 18 | +); |
| 19 | + |
| 20 | +/** Finnish (Suomi) |
| 21 | + * @author Jack Phoenix <jack@countervandalism.net> |
| 22 | + */ |
| 23 | +$messages['fi'] = array( |
| 24 | + 'listusers-showall' => 'Näytä kaikki käyttäjät, mukaanlukien ne, joilla on alle viisi muokkausta', |
| 25 | + 'right-viewallusers' => 'Katsoa kaikki käyttäjät [[Special:ListUsers|käyttäjälistassa]]' |
| 26 | +); |
| 27 | + |
| 28 | +/** Dutch (Nederlands) |
| 29 | + * @author Mitchel Corstjens |
| 30 | + */ |
| 31 | +$messages['nl'] = array( |
| 32 | + 'listusers-showall' => 'Geef alle gebruikers weer, ook gebruikers met minder dan 5 bewerkingen', |
| 33 | + 'right-viewallusers' => 'Bekijk alle gebruikers in de [[Special:ListUsers|gebruikers lijst]]' |
| 34 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/FilterListUsers/FilterListUsers.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 35 | + native |
Index: trunk/extensions/FilterListUsers/FilterListUsers.php |
— | — | @@ -0,0 +1,90 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * FilterListUsers -- filters out users that haven't edited from Special:ListUsers |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * @version 1.0 |
| 9 | + * @date February 22, 2010 |
| 10 | + * @author Jack Phoenix <jack@countervandalism.net> |
| 11 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 12 | + */ |
| 13 | + |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 15 | + die( "This is not a valid entry point.\n" ); |
| 16 | +} |
| 17 | + |
| 18 | +// Extension credits that will show up on Special:Version |
| 19 | +$wgExtensionCredits['other'][] = array( |
| 20 | + 'name' => 'FilterListUsers', |
| 21 | + 'version' => '1.0', |
| 22 | + 'author' => 'Jack Phoenix', |
| 23 | + 'description' => "Filters out users that haven't edited from [[Special:ListUsers]]", |
| 24 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:FilterListUsers', |
| 25 | +); |
| 26 | + |
| 27 | +// New user right, required to view all users in Special:ListUsers |
| 28 | +$wgAvailableRights[] = 'viewallusers'; |
| 29 | +$wgGroupPermissions['sysop']['viewallusers'] = true; |
| 30 | + |
| 31 | +// i18n file |
| 32 | +$dir = dirname( __FILE__ ) . '/'; |
| 33 | +$wgExtensionMessagesFiles['FilterListUsers'] = $dir . 'FilterListUsers.i18n.php'; |
| 34 | + |
| 35 | +$wgHooks['SpecialListusersQueryInfo'][] = 'efFilterListUsersAlterQuery'; |
| 36 | +/** |
| 37 | + * Alters the SQL query so that when there is no "showall" parameter in the URL |
| 38 | + * or when the user isn't privileged, only users with 5 (or more) edits will be |
| 39 | + * shown. |
| 40 | + * |
| 41 | + * @param $usersPager Object: instance of UsersPager |
| 42 | + * @param $query Array: SQL query parameters |
| 43 | + * @return Boolean: true |
| 44 | + */ |
| 45 | +function efFilterListUsersAlterQuery( $usersPager, &$query ) { |
| 46 | + global $wgRequest, $wgUser; |
| 47 | + |
| 48 | + // Members of these groups will always be shown if the user selects this |
| 49 | + // group from the dropdown menu, no matter if they haven't edited the wiki |
| 50 | + // at all |
| 51 | + $exemptGroups = array( |
| 52 | + 'sysop', 'bureaucrat', 'steward', 'staff', 'globalbot' |
| 53 | + ); |
| 54 | + |
| 55 | + if ( |
| 56 | + !$wgRequest->getVal( 'showall' ) && !in_array( $usersPager->requestedGroup, $exemptGroups ) || |
| 57 | + !$wgUser->isAllowed( 'viewallusers' ) && !in_array( $usersPager->requestedGroup, $exemptGroups ) |
| 58 | + ) |
| 59 | + { |
| 60 | + $dbr = wfGetDB( DB_SLAVE ); |
| 61 | + $revisionTable = $dbr->tableName( 'revision' ); |
| 62 | + $query['tables'] .= " JOIN (SELECT rev_user, COUNT(*) AS cnt FROM {$revisionTable} GROUP BY rev_user HAVING cnt > 5) AS tmp ON user_id = rev_user "; |
| 63 | + } |
| 64 | + |
| 65 | + return true; |
| 66 | +} |
| 67 | + |
| 68 | +$wgHooks['SpecialListusersHeaderForm'][] = 'efFilterListUsersHeaderForm'; |
| 69 | +/** |
| 70 | + * Adds the "Show all users" checkbox for privileged users. |
| 71 | + * |
| 72 | + * @param $usersPager Object: instance of UsersPager |
| 73 | + * @param $out String: HTML output |
| 74 | + * @return Boolean: true |
| 75 | + */ |
| 76 | +function efFilterListUsersHeaderForm( $usersPager, &$out ) { |
| 77 | + global $wgRequest, $wgUser; |
| 78 | + |
| 79 | + // Show this checkbox only to privileged users |
| 80 | + if ( $wgUser->isAllowed( 'viewallusers' ) ) { |
| 81 | + $out .= Xml::checkLabel( |
| 82 | + wfMsg( 'listusers-showall' ), |
| 83 | + 'showall', |
| 84 | + 'showall', |
| 85 | + $wgRequest->getVal( 'showall' ) |
| 86 | + ); |
| 87 | + $out .= ' '; |
| 88 | + } |
| 89 | + |
| 90 | + return true; |
| 91 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/FilterListUsers/FilterListUsers.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 92 | + native |