Passed
Push — master ( 4ec39a...24c59a )
by
unknown
15:04
created

BackendUser::setDbMountPoints()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace TYPO3\CMS\Beuser\Domain\Model;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use TYPO3\CMS\Backend\Authentication\PasswordReset;
18
use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20
/**
21
 * Model for backend user
22
 * @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
23
 */
24
class BackendUser extends \TYPO3\CMS\Extbase\Domain\Model\BackendUser
25
{
26
    /**
27
     * Comma separated list of uids in multi-select
28
     * Might retrieve the labels from TCA/DataMapper
29
     *
30
     * @var string
31
     */
32
    protected $allowedLanguages = '';
33
34
    /**
35
     * @var string
36
     */
37
    protected $dbMountPoints = '';
38
39
    /**
40
     * @var string
41
     */
42
    protected $description;
43
44
    /**
45
     * @var string
46
     */
47
    protected $fileMountPoints = '';
48
49
    /**
50
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup>
51
     */
52
    protected $backendUserGroups;
53
54
    /**
55
     * @param string $allowedLanguages
56
     */
57
    public function setAllowedLanguages($allowedLanguages)
58
    {
59
        $this->allowedLanguages = $allowedLanguages;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getAllowedLanguages()
66
    {
67
        return $this->allowedLanguages;
68
    }
69
70
    /**
71
     * @param string $dbMountPoints
72
     */
73
    public function setDbMountPoints($dbMountPoints)
74
    {
75
        $this->dbMountPoints = $dbMountPoints;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getDbMountPoints()
82
    {
83
        return $this->dbMountPoints;
84
    }
85
86
    /**
87
     * @param string $fileMountPoints
88
     */
89
    public function setFileMountPoints($fileMountPoints)
90
    {
91
        $this->fileMountPoints = $fileMountPoints;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getFileMountPoints()
98
    {
99
        return $this->fileMountPoints;
100
    }
101
102
    /**
103
     * Check if user is active, not disabled
104
     *
105
     * @return bool
106
     */
107
    public function isActive()
108
    {
109
        if ($this->getIsDisabled()) {
110
            return false;
111
        }
112
        $now = new \DateTime('now');
113
        return !$this->getStartDateAndTime() && !$this->getEndDateAndTime() || $this->getStartDateAndTime() <= $now && (!$this->getEndDateAndTime() || $this->getEndDateAndTime() > $now);
114
    }
115
116
    /**
117
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $backendUserGroups
118
     */
119
    public function setBackendUserGroups($backendUserGroups)
120
    {
121
        $this->backendUserGroups = $backendUserGroups;
122
    }
123
124
    /**
125
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
126
     */
127
    public function getBackendUserGroups()
128
    {
129
        return $this->backendUserGroups;
130
    }
131
132
    /**
133
     * Check if user is currently logged in
134
     *
135
     * @return bool
136
     */
137
    public function isCurrentlyLoggedIn()
138
    {
139
        return $this->getUid() === (int)$this->getBackendUser()->user['uid'];
140
    }
141
142
    /**
143
     * Check if the user (not the currently logged in user) is allowed to trigger a password reset
144
     *
145
     * @return bool
146
     */
147
    public function isPasswordResetEnabled(): bool
148
    {
149
        return !$this->isCurrentlyLoggedIn() && GeneralUtility::makeInstance(PasswordReset::class)->isEnabledForUser((int)$this->getUid());
150
    }
151
152
    /**
153
     * Gets the currently logged in backend user
154
     *
155
     * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
156
     */
157
    public function getBackendUser()
158
    {
159
        return $GLOBALS['BE_USER'];
160
    }
161
}
162