// Page tools
'ComparePages' => 'SpecialComparePages',
'Export' => 'SpecialExport',
- 'GlobalFileUsage' => 'SpecialGlobalFileUsage',
- 'GlobalTemplateUsage' => 'SpecialGlobalTemplateUsage',
'Import' => 'SpecialImport',
'Undelete' => 'SpecialUndelete',
'Whatlinkshere' => 'SpecialWhatlinkshere',
/**
* Add a page to a certain display group for Special:SpecialPages
*
- * @param $page SpecialPage|string
+ * @param $page Mixed: SpecialPage or string
* @param $group String
*/
public static function setGroup( $page, $group ) {
* Get the group that the special page belongs in on Special:SpecialPage
*
* @param $page SpecialPage
- *
- * @return string
*/
public static function getGroup( &$page ) {
$name = $page->getName();
* Return categorised listable special pages which are available
* for the current user, and everyone.
*
+ * @param $user User object to check permissions, $wgUser will be used
+ * if not provided
* @return Array( String => Specialpage )
*/
- public static function getUsablePages() {
- global $wgUser;
+ public static function getUsablePages( User $user = null ) {
$pages = array();
+ if ( $user === null ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
foreach ( self::getList() as $name => $rec ) {
$page = self::getPage( $name );
- if ( $page->isListed()
- && (
- !$page->isRestricted()
- || $page->userCanExecute( $wgUser )
- )
+ if ( $page // not null
+ && $page->isListed()
+ && ( !$page->isRestricted() || $page->userCanExecute( $user ) )
) {
$pages[$name] = $page;
}