Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
ManageMyGrantsPager | |
0.00% |
0 / 25 |
|
0.00% |
0 / 7 |
132 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
getTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
formatRow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getStartBody | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getEndBody | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getQueryInfo | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
getIndexField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\OAuth\Frontend\Pagers; |
4 | |
5 | /** |
6 | * (c) Aaron Schulz 2013, GPL |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU General Public License along |
19 | * with this program; if not, write to the Free Software Foundation, Inc., |
20 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | * http://www.gnu.org/copyleft/gpl.html |
22 | */ |
23 | |
24 | use MediaWiki\Extension\OAuth\Backend\Utils; |
25 | use MediaWiki\Extension\OAuth\Frontend\SpecialPages\SpecialMWOAuthManageMyGrants; |
26 | use MediaWiki\MediaWikiServices; |
27 | use MediaWiki\Pager\ReverseChronologicalPager; |
28 | use MediaWiki\Title\Title; |
29 | use stdClass; |
30 | |
31 | /** |
32 | * Query to list out consumers that have an access token for this user |
33 | */ |
34 | class ManageMyGrantsPager extends ReverseChronologicalPager { |
35 | /** @var SpecialMWOAuthManageMyGrants */ |
36 | public $mForm; |
37 | /** @var array */ |
38 | public $mConds; |
39 | |
40 | /** |
41 | * @param SpecialMWOAuthManageMyGrants $form |
42 | * @param array $conds |
43 | * @param int $centralUserId |
44 | */ |
45 | public function __construct( $form, $conds, $centralUserId ) { |
46 | $this->mForm = $form; |
47 | $this->mConds = $conds; |
48 | $this->mConds[] = 'oaac_consumer_id = oarc_id'; |
49 | $this->mConds['oaac_user_id'] = $centralUserId; |
50 | |
51 | $permissionManager = MediaWikiServices::getInstance()->getPermissionManager(); |
52 | if ( !$permissionManager->userHasRight( $this->getUser(), 'mwoauthviewsuppressed' ) ) { |
53 | $this->mConds['oarc_deleted'] = 0; |
54 | } |
55 | |
56 | $this->mDb = Utils::getCentralDB( DB_REPLICA ); |
57 | parent::__construct(); |
58 | |
59 | # Treat 20 as the default limit, since each entry takes up 5 rows. |
60 | $urlLimit = $this->mRequest->getInt( 'limit' ); |
61 | $this->mLimit = $urlLimit ?: 20; |
62 | } |
63 | |
64 | /** |
65 | * @return Title |
66 | */ |
67 | public function getTitle() { |
68 | return $this->mForm->getFullTitle(); |
69 | } |
70 | |
71 | /** |
72 | * @param stdClass $row |
73 | * @return string |
74 | */ |
75 | public function formatRow( $row ) { |
76 | return $this->mForm->formatRow( $this->mDb, $row ); |
77 | } |
78 | |
79 | /** |
80 | * @return string |
81 | */ |
82 | public function getStartBody() { |
83 | if ( $this->getNumRows() ) { |
84 | return '<ul>'; |
85 | } else { |
86 | return ''; |
87 | } |
88 | } |
89 | |
90 | /** |
91 | * @return string |
92 | */ |
93 | public function getEndBody() { |
94 | if ( $this->getNumRows() ) { |
95 | return '</ul>'; |
96 | } else { |
97 | return ''; |
98 | } |
99 | } |
100 | |
101 | /** |
102 | * @return array |
103 | */ |
104 | public function getQueryInfo() { |
105 | return [ |
106 | 'tables' => [ 'oauth_accepted_consumer', 'oauth_registered_consumer' ], |
107 | 'fields' => [ '*' ], |
108 | 'conds' => $this->mConds |
109 | ]; |
110 | } |
111 | |
112 | /** |
113 | * @return string |
114 | */ |
115 | public function getIndexField() { |
116 | return 'oaac_consumer_id'; |
117 | } |
118 | } |