Debian Codegraph @

includes/specials/redirects/SpecialMylog.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\Redirects;
22
23 use LogPage;
24 use MediaWiki\SpecialPage\RedirectSpecialPage;
25 use MediaWiki\SpecialPage\SpecialPage;
26 use MediaWiki\Title\Title;
27 use MediaWiki\User\TempUser\TempUserConfig;
28
29 /**
30 * Redirect to Special:Log for the current user's name or IP.
31 *
32 * @ingroup SpecialPage
33 */
34 class SpecialMylog extends RedirectSpecialPage {
35
36 private TempUserConfig $tempUserConfig;
37
38 /**
39 * @param TempUserConfig $tempUserConfig
40 */
41 public function __construct( TempUserConfig $tempUserConfig ) {
42 parent::__construct( 'Mylog' );
43
44 $this->tempUserConfig = $tempUserConfig;
45
46 $this->mAllowedRedirectParams = [ 'type', 'subtype', 'page', 'pattern',
47 'tagfilter', 'tagInvert', 'offset', 'dir', 'offender',
48 'year', 'month', 'day' ];
49 }
50
51 /**
52 * @param string|null $subpage
53 * @return Title
54 */
55 public function getRedirect( $subpage ) {
56 // Redirect to login for anon users when temp accounts are enabled.
57 if ( $this->tempUserConfig->isEnabled() && $this->getUser()->isAnon() ) {
58 $this->requireLogin();
59 }
60
61 if ( $subpage === null || $subpage === '' ) {
62 return SpecialPage::getSafeTitleFor( 'Log', $this->getUser()->getName() );
63 }
64
65 return SpecialPage::getSafeTitleFor( 'Log', $subpage . '/' . $this->getUser()->getName() );
66 }
67
68 /**
69 * Target identifies a specific User. See T109724.
70 *
71 * @return bool
72 */
73 public function personallyIdentifiableTarget() {
74 return true;
75 }
76
77 /**
78 * Return an array of subpages that this special page will accept.
79 *
80 * @return string[] subpages
81 */
82 public function getSubpagesForPrefixSearch() {
83 $subpages = LogPage::validTypes();
84 $subpages[] = 'all';
85 sort( $subpages );
86 return $subpages;
87 }
88 }
89
90 /**
91 * Retain the old class name for backwards compatibility.
92 * @deprecated since 1.41
93 */
94 class_alias( SpecialMylog::class, 'SpecialMylog' );