2015-12-02 17:10:26 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2017-12-04 19:25:31 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2015-12-02 17:10:26 +00:00
|
|
|
*/
|
2021-08-06 19:51:07 +00:00
|
|
|
|
2017-01-18 20:55:20 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2015-12-02 17:10:26 +00:00
|
|
|
|
|
|
|
|
/**
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsInfo and GrantsLocalization instead
|
|
|
|
|
*
|
2015-12-02 17:10:26 +00:00
|
|
|
* A collection of public static functions to deal with grants.
|
|
|
|
|
*/
|
|
|
|
|
class MWGrants {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List all known grants.
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsInfo::getValidGrants() instead
|
2015-12-02 17:10:26 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public static function getValidGrants() {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsInfo()->getValidGrants();
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map all grants to corresponding user rights.
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsInfo::getRightsByGrant() instead
|
2015-12-02 17:10:26 +00:00
|
|
|
* @return array grant => array of rights
|
|
|
|
|
*/
|
|
|
|
|
public static function getRightsByGrant() {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsInfo()->getRightsByGrant();
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-08-06 19:51:07 +00:00
|
|
|
* Fetch the description of the grant
|
|
|
|
|
* @deprecated since 1.38, use GrantsLocalization::getGrantDescription() instead
|
2015-12-02 17:10:26 +00:00
|
|
|
* @param string $grant
|
|
|
|
|
* @param Language|string|null $lang
|
|
|
|
|
* @return string Grant description
|
|
|
|
|
*/
|
|
|
|
|
public static function grantName( $grant, $lang = null ) {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsLocalization()->getGrantDescription( $grant, $lang );
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-08-06 19:51:07 +00:00
|
|
|
* Fetch the descriptions for the grants.
|
|
|
|
|
* @deprecated since 1.38, use GrantsLocalization::getGrantDescriptions() instead
|
2015-12-02 17:10:26 +00:00
|
|
|
* @param string[] $grants
|
|
|
|
|
* @param Language|string|null $lang
|
|
|
|
|
* @return string[] Corresponding grant descriptions
|
|
|
|
|
*/
|
|
|
|
|
public static function grantNames( array $grants, $lang = null ) {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsLocalization()->getGrantDescriptions( $grants, $lang );
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fetch the rights allowed by a set of grants.
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsInfo::getGrantRights() instead
|
2015-12-02 17:10:26 +00:00
|
|
|
* @param string[]|string $grants
|
|
|
|
|
* @return string[]
|
|
|
|
|
*/
|
|
|
|
|
public static function getGrantRights( $grants ) {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsInfo()->getGrantRights( $grants );
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test that all grants in the list are known.
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsInfo::grantsAreValid() instead
|
2015-12-02 17:10:26 +00:00
|
|
|
* @param string[] $grants
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public static function grantsAreValid( array $grants ) {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsInfo()->grantsAreValid( $grants );
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Divide the grants into groups.
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsInfo::getGrantGroups() instead
|
2015-12-02 17:10:26 +00:00
|
|
|
* @param string[]|null $grantsFilter
|
|
|
|
|
* @return array Map of (group => (grant list))
|
|
|
|
|
*/
|
|
|
|
|
public static function getGrantGroups( $grantsFilter = null ) {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsInfo()->getGrantGroups( $grantsFilter );
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the list of grants that are hidden and should always be granted
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsInfo::getHiddenGrants() instead
|
2015-12-02 17:10:26 +00:00
|
|
|
* @return string[]
|
|
|
|
|
*/
|
|
|
|
|
public static function getHiddenGrants() {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsInfo()->getHiddenGrants();
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a link to Special:ListGrants for a particular grant name.
|
|
|
|
|
*
|
|
|
|
|
* This should be used to link end users to a full description of what
|
|
|
|
|
* rights they are giving when they authorize a grant.
|
|
|
|
|
*
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsLocalization::getGrantsLink() instead
|
|
|
|
|
*
|
2015-12-02 17:10:26 +00:00
|
|
|
* @param string $grant the grant name
|
|
|
|
|
* @param Language|string|null $lang
|
|
|
|
|
* @return string (proto-relative) HTML link
|
|
|
|
|
*/
|
|
|
|
|
public static function getGrantsLink( $grant, $lang = null ) {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsLocalization()->getGrantsLink( $grant, $lang );
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate wikitext to display a list of grants
|
2021-08-06 19:51:07 +00:00
|
|
|
* @deprecated since 1.38, use GrantsLocalization::getGrantsWikiText() instead
|
|
|
|
|
*
|
2015-12-02 17:10:26 +00:00
|
|
|
* @param string[]|null $grantsFilter If non-null, only display these grants.
|
|
|
|
|
* @param Language|string|null $lang
|
|
|
|
|
* @return string Wikitext
|
|
|
|
|
*/
|
|
|
|
|
public static function getGrantsWikiText( $grantsFilter, $lang = null ) {
|
2021-08-06 19:51:07 +00:00
|
|
|
return MediaWikiServices::getInstance()->getGrantsLocalization()->getGrantsWikiText( $grantsFilter, $lang );
|
2015-12-02 17:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|