aboutsummaryrefslogtreecommitdiffstats
path: root/includes/MWGrants.php
blob: 2f4d1baa8ed320ba631db40d1aa32ac18121724d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?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
 *
 * @file
 */

use MediaWiki\MediaWikiServices;

/**
 * @deprecated since 1.38, hard deprecated since 1.39
 * Use GrantsInfo and GrantsLocalization instead
 *
 * A collection of public static functions to deal with grants.
 */
class MWGrants {

	/**
	 * List all known grants.
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsInfo::getValidGrants() instead
	 * @return array
	 */
	public static function getValidGrants() {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsInfo()->getValidGrants();
	}

	/**
	 * Map all grants to corresponding user rights.
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsInfo::getRightsByGrant() instead
	 * @return array grant => array of rights
	 */
	public static function getRightsByGrant() {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsInfo()->getRightsByGrant();
	}

	/**
	 * Fetch the description of the grant
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsLocalization::getGrantDescription() instead
	 * @param string $grant
	 * @param Language|string|null $lang
	 * @return string Grant description
	 */
	public static function grantName( $grant, $lang = null ) {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsLocalization()->getGrantDescription( $grant, $lang );
	}

	/**
	 * Fetch the descriptions for the grants.
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsLocalization::getGrantDescriptions() instead
	 * @param string[] $grants
	 * @param Language|string|null $lang
	 * @return string[] Corresponding grant descriptions
	 */
	public static function grantNames( array $grants, $lang = null ) {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsLocalization()->getGrantDescriptions( $grants, $lang );
	}

	/**
	 * Fetch the rights allowed by a set of grants.
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsInfo::getGrantRights() instead
	 * @param string[]|string $grants
	 * @return string[]
	 */
	public static function getGrantRights( $grants ) {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsInfo()->getGrantRights( $grants );
	}

	/**
	 * Test that all grants in the list are known.
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsInfo::grantsAreValid() instead
	 * @param string[] $grants
	 * @return bool
	 */
	public static function grantsAreValid( array $grants ) {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsInfo()->grantsAreValid( $grants );
	}

	/**
	 * Divide the grants into groups.
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsInfo::getGrantGroups() instead
	 * @param string[]|null $grantsFilter
	 * @return array Map of (group => (grant list))
	 */
	public static function getGrantGroups( $grantsFilter = null ) {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsInfo()->getGrantGroups( $grantsFilter );
	}

	/**
	 * Get the list of grants that are hidden and should always be granted
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsInfo::getHiddenGrants() instead
	 * @return string[]
	 */
	public static function getHiddenGrants() {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsInfo()->getHiddenGrants();
	}

	/**
	 * 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.
	 *
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsLocalization::getGrantsLink() instead
	 *
	 * @param string $grant the grant name
	 * @param Language|string|null $lang
	 * @return string (proto-relative) HTML link
	 */
	public static function getGrantsLink( $grant, $lang = null ) {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsLocalization()->getGrantsLink( $grant, $lang );
	}

	/**
	 * Generate wikitext to display a list of grants
	 * @deprecated since 1.38, hard deprecated since 1.39
	 * Use GrantsLocalization::getGrantsWikiText() instead
	 *
	 * @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 ) {
		wfDeprecated( __METHOD__, '1.38' );
		return MediaWikiServices::getInstance()->getGrantsLocalization()->getGrantsWikiText( $grantsFilter, $lang );
	}

}