Debian Codegraph @

includes/specials/SpecialDeletedContributions.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 namespace MediaWiki\Specials;
22
23 use MediaWiki\Block\DatabaseBlockStore;
24 use MediaWiki\Cache\LinkBatchFactory;
25 use MediaWiki\CommentFormatter\CommentFormatter;
26 use MediaWiki\Pager\DeletedContribsPager;
27 use MediaWiki\Permissions\PermissionManager;
28 use MediaWiki\Revision\RevisionStore;
29 use MediaWiki\SpecialPage\ContributionsSpecialPage;
30 use MediaWiki\SpecialPage\SpecialPage;
31 use MediaWiki\Title\NamespaceInfo;
32 use MediaWiki\User\Options\UserOptionsLookup;
33 use MediaWiki\User\TempUser\TempUserConfig;
34 use MediaWiki\User\User;
35 use MediaWiki\User\UserFactory;
36 use MediaWiki\User\UserIdentity;
37 use MediaWiki\User\UserIdentityLookup;
38 use MediaWiki\User\UserNamePrefixSearch;
39 use MediaWiki\User\UserNameUtils;
40 use Wikimedia\IPUtils;
41 use Wikimedia\Rdbms\IConnectionProvider;
42
43 /**
44 * Implements Special:DeletedContributions to display archived revisions
45 *
46 * @ingroup SpecialPage
47 */
48 class SpecialDeletedContributions extends ContributionsSpecialPage {
49 private ?DeletedContribsPager $pager = null;
50
51 private RevisionStore $revisionStore;
52 private CommentFormatter $commentFormatter;
53 private LinkBatchFactory $linkBatchFactory;
54 private TempUserConfig $tempUserConfig;
55
56 /**
57 * @param PermissionManager $permissionManager
58 * @param IConnectionProvider $dbProvider
59 * @param RevisionStore $revisionStore
60 * @param NamespaceInfo $namespaceInfo
61 * @param UserNameUtils $userNameUtils
62 * @param UserNamePrefixSearch $userNamePrefixSearch
63 * @param UserOptionsLookup $userOptionsLookup
64 * @param CommentFormatter $commentFormatter
65 * @param LinkBatchFactory $linkBatchFactory
66 * @param UserFactory $userFactory
67 * @param UserIdentityLookup $userIdentityLookup
68 * @param DatabaseBlockStore $blockStore
69 * @param TempUserConfig $tempUserConfig
70 */
71 public function __construct(
72 PermissionManager $permissionManager,
73 IConnectionProvider $dbProvider,
74 RevisionStore $revisionStore,
75 NamespaceInfo $namespaceInfo,
76 UserNameUtils $userNameUtils,
77 UserNamePrefixSearch $userNamePrefixSearch,
78 UserOptionsLookup $userOptionsLookup,
79 CommentFormatter $commentFormatter,
80 LinkBatchFactory $linkBatchFactory,
81 UserFactory $userFactory,
82 UserIdentityLookup $userIdentityLookup,
83 DatabaseBlockStore $blockStore,
84 TempUserConfig $tempUserConfig
85 ) {
86 parent::__construct(
87 $permissionManager,
88 $dbProvider,
89 $namespaceInfo,
90 $userNameUtils,
91 $userNamePrefixSearch,
92 $userOptionsLookup,
93 $userFactory,
94 $userIdentityLookup,
95 $blockStore,
96 'DeletedContributions',
97 'deletedhistory'
98 );
99 $this->revisionStore = $revisionStore;
100 $this->commentFormatter = $commentFormatter;
101 $this->linkBatchFactory = $linkBatchFactory;
102 $this->tempUserConfig = $tempUserConfig;
103 }
104
105 /**
106 * @inheritDoc
107 */
108 protected function getPager( $targetUser ) {
109 if ( $this->pager === null ) {
110 // Fields in the opts property are usually not normalised, mainly
111 // for validations in HTMLForm, especially the 'target' field.
112 $options = $this->opts;
113 unset( $options['target'] );
114
115 $this->pager = new DeletedContribsPager(
116 $this->getHookContainer(),
117 $this->getLinkRenderer(),
118 $this->dbProvider,
119 $this->revisionStore,
120 $this->namespaceInfo,
121 $this->commentFormatter,
122 $this->linkBatchFactory,
123 $this->userFactory,
124 $this->getContext(),
125 $options,
126 $targetUser
127 );
128 }
129
130 return $this->pager;
131 }
132
133 /** @inheritDoc */
134 public function isIncludable() {
135 return false;
136 }
137
138 /**
139 * @inheritDoc
140 */
141 protected function getUserLinks(
142 SpecialPage $sp,
143 User $target
144 ) {
145 $tools = parent::getUserLinks( $sp, $target );
146 $linkRenderer = $sp->getLinkRenderer();
147
148 $contributionsLink = $linkRenderer->makeKnownLink(
149 SpecialPage::getTitleFor( 'Contributions', $target->getName() ),
150 $this->msg( 'sp-deletedcontributions-contribs' )->text()
151 );
152 if ( isset( $tools['deletedcontribs'] ) ) {
153 // Swap out the deletedcontribs link for our contribs one
154 $tools = wfArrayInsertAfter(
155 $tools, [ 'contribs' => $contributionsLink ], 'deletedcontribs' );
156 unset( $tools['deletedcontribs'] );
157 } else {
158 $tools['contribs'] = $contributionsLink;
159 }
160
161 return $tools;
162 }
163
164 /** @inheritDoc */
165 protected function getResultsPageTitleMessageKey( UserIdentity $target ) {
166 // The following messages are generated here:
167 // * deletedcontributions-title
168 // * deletedcontributions-title-for-ip-when-temporary-accounts-enabled
169 $messageKey = 'deletedcontributions-title';
170 if ( $this->tempUserConfig->isEnabled() && IPUtils::isIPAddress( $target->getName() ) ) {
171 $messageKey .= '-for-ip-when-temporary-accounts-enabled';
172 }
173 return $messageKey;
174 }
175 }
176
177 /** @deprecated class alias since 1.41 */
178 class_alias( SpecialDeletedContributions::class, 'SpecialDeletedContributions' );