-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathProfile.php
117 lines (106 loc) · 3.74 KB
/
Profile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* @author Tom Needham <tom@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <icewind@owncloud.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @copyright Copyright (c) 2018, ownCloud GmbH
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OC\Settings\Panels\Personal;
use OC\Helper\LocaleHelper;
use OCP\Settings\ISettings;
use OCP\Template;
use OCP\IGroupManager;
use OCP\IUserSession;
use OCP\IConfig;
use OCP\L10N\IFactory;
class Profile implements ISettings {
/* @var IConfig */
protected $config;
/* @var IGroupManager */
protected $groupManager;
/* @var IUserSession */
protected $userSession;
/** @var IFactory */
protected $lfactory;
/**
* @var LocaleHelper
*/
private $localeHelper;
/**
* Profile constructor.
*
* @param IConfig $config
* @param IGroupManager $groupManager
* @param IUserSession $userSession
* @param IFactory $lfactory
* @param LocaleHelper $localeHelper
*/
public function __construct(
IConfig $config,
IGroupManager $groupManager,
IUserSession $userSession,
IFactory $lfactory,
LocaleHelper $localeHelper
) {
$this->config = $config;
$this->groupManager = $groupManager;
$this->userSession = $userSession;
$this->lfactory = $lfactory;
$this->localeHelper = $localeHelper;
}
public function getPriority() {
return 100;
}
public function getPanel() {
$activeLangCode = $this->config->getUserValue(
$this->userSession->getUser()->getUID(),
'core',
'lang',
$this->lfactory->findLanguage()
);
list($userLang, $commonLanguages, $languages) = $this->localeHelper->getNormalizedLanguages(
$this->lfactory,
$activeLangCode
);
$selector = new Template('settings', 'language');
$selector->assign('selectName', 'lang');
$selector->assign('selectId', 'languageinput');
$selector->assign('activelanguage', $userLang);
$selector->assign('commonlanguages', $commonLanguages);
$selector->assign('languages', $languages);
$tmpl = new Template('settings', 'panels/personal/profile');
$tmpl->assign('email', $this->userSession->getUser()->getEMailAddress());
$tmpl->assign('displayName', $this->userSession->getUser()->getDisplayName());
$tmpl->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true) === true);
$tmpl->assign('avatarChangeSupported', $this->userSession->getUser()->canChangeAvatar());
$tmpl->assign('displayNameChangeSupported', $this->userSession->getUser()->canChangeDisplayName());
$tmpl->assign('mailAddressChangeSupported', $this->userSession->getUser()->canChangeMailAddress());
$tmpl->assign('passwordChangeSupported', $this->userSession->getUser()->canChangePassword());
$groups = $this->groupManager->getUserGroups($this->userSession->getUser());
$tmpl->assign('groups', $groups);
$tmpl->assign('username', $this->userSession->getUser()->getUID());
$tmpl->assign('languageSelector', $selector->fetchPage());
$tmpl->assign('legal_privacy_policy', $this->config->getAppValue('core', 'legal.privacy_policy_url'));
$tmpl->assign('legal_imprint', $this->config->getAppValue('core', 'legal.imprint_url'));
return $tmpl;
}
public function getSectionID() {
return 'general';
}
}