Debian Codegraph @

includes/specials/SpecialListUsers.php

raw symbols SCIP
1 <?php
2 /**
3 * Copyright © 2004 Brooke Vibber, lcrocker, Tim Starling,
4 * Domas Mituzas, Antoine Musso, Jens Frank, Zhengzhu,
5 * 2006 Rob Church <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
21 *
22 * @file
23 */
24
25 namespace MediaWiki\Specials;
26
27 use MediaWiki\Block\HideUserUtils;
28 use MediaWiki\Cache\LinkBatchFactory;
29 use MediaWiki\Html\Html;
30 use MediaWiki\Pager\UsersPager;
31 use MediaWiki\SpecialPage\IncludableSpecialPage;
32 use MediaWiki\User\UserGroupManager;
33 use MediaWiki\User\UserIdentityLookup;
34 use Wikimedia\Rdbms\IConnectionProvider;
35
36 /**
37 * Implements Special:Listusers
38 *
39 * @ingroup SpecialPage
40 */
41 class SpecialListUsers extends IncludableSpecialPage {
42
43 private LinkBatchFactory $linkBatchFactory;
44 private IConnectionProvider $dbProvider;
45 private UserGroupManager $userGroupManager;
46 private UserIdentityLookup $userIdentityLookup;
47 private HideUserUtils $hideUserUtils;
48
49 /**
50 * @param LinkBatchFactory $linkBatchFactory
51 * @param IConnectionProvider $dbProvider
52 * @param UserGroupManager $userGroupManager
53 * @param UserIdentityLookup $userIdentityLookup
54 * @param HideUserUtils $hideUserUtils
55 */
56 public function __construct(
57 LinkBatchFactory $linkBatchFactory,
58 IConnectionProvider $dbProvider,
59 UserGroupManager $userGroupManager,
60 UserIdentityLookup $userIdentityLookup,
61 HideUserUtils $hideUserUtils
62 ) {
63 parent::__construct( 'Listusers' );
64 $this->linkBatchFactory = $linkBatchFactory;
65 $this->dbProvider = $dbProvider;
66 $this->userGroupManager = $userGroupManager;
67 $this->userIdentityLookup = $userIdentityLookup;
68 $this->hideUserUtils = $hideUserUtils;
69 }
70
71 /**
72 * @param string|null $par A group to list users from
73 */
74 public function execute( $par ) {
75 $this->setHeaders();
76 $this->outputHeader();
77
78 $up = new UsersPager(
79 $this->getContext(),
80 $this->getHookContainer(),
81 $this->linkBatchFactory,
82 $this->dbProvider,
83 $this->userGroupManager,
84 $this->userIdentityLookup,
85 $this->hideUserUtils,
86 $par,
87 $this->including()
88 );
89
90 # getBody() first to check, if empty
91 $usersbody = $up->getBody();
92
93 $s = '';
94 if ( !$this->including() ) {
95 $s = $up->getPageHeader();
96 }
97
98 if ( $usersbody ) {
99 $s .= $up->getNavigationBar();
100 $s .= Html::rawElement( 'ul', [], $usersbody );
101 $s .= $up->getNavigationBar();
102 } else {
103 $s .= $this->msg( 'listusers-noresult' )->parseAsBlock();
104 }
105
106 $out = $this->getOutput();
107 $out->addHTML( $s );
108 $out->addModuleStyles( 'mediawiki.interface.helpers.styles' );
109 }
110
111 /**
112 * Return an array of subpages that this special page will accept.
113 *
114 * @return string[] subpages
115 */
116 public function getSubpagesForPrefixSearch() {
117 return $this->userGroupManager->listAllGroups();
118 }
119
120 protected function getGroupName() {
121 return 'users';
122 }
123 }
124
125 /** @deprecated class alias since 1.41 */
126 class_alias( SpecialListUsers::class, 'SpecialListUsers' );