@@ -35,102 +35,102 @@ |
||
35 | 35 | * @package OCA\LookupServerConnector |
36 | 36 | */ |
37 | 37 | class UpdateLookupServer { |
38 | - /** @var AccountManager */ |
|
39 | - private $accountManager; |
|
40 | - /** @var IClientService */ |
|
41 | - private $clientService; |
|
42 | - /** @var Signer */ |
|
43 | - private $signer; |
|
44 | - /** @var IJobList */ |
|
45 | - private $jobList; |
|
46 | - /** @var string URL point to lookup server */ |
|
47 | - private $lookupServer = 'https://lookup.nextcloud.com'; |
|
38 | + /** @var AccountManager */ |
|
39 | + private $accountManager; |
|
40 | + /** @var IClientService */ |
|
41 | + private $clientService; |
|
42 | + /** @var Signer */ |
|
43 | + private $signer; |
|
44 | + /** @var IJobList */ |
|
45 | + private $jobList; |
|
46 | + /** @var string URL point to lookup server */ |
|
47 | + private $lookupServer = 'https://lookup.nextcloud.com'; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param AccountManager $accountManager |
|
51 | - * @param IClientService $clientService |
|
52 | - * @param Signer $signer |
|
53 | - * @param IJobList $jobList |
|
54 | - * @param string $lookupServer if nothing is given we use the default lookup server |
|
55 | - */ |
|
56 | - public function __construct(AccountManager $accountManager, |
|
57 | - IClientService $clientService, |
|
58 | - Signer $signer, |
|
59 | - IJobList $jobList, |
|
60 | - $lookupServer = '') { |
|
61 | - $this->accountManager = $accountManager; |
|
62 | - $this->clientService = $clientService; |
|
63 | - $this->signer = $signer; |
|
64 | - $this->jobList = $jobList; |
|
65 | - if ($lookupServer !== '') { |
|
66 | - $this->lookupServer = $lookupServer; |
|
67 | - } |
|
68 | - $this->lookupServer = rtrim($this->lookupServer, '/'); |
|
69 | - $this->lookupServer .= '/users'; |
|
70 | - } |
|
49 | + /** |
|
50 | + * @param AccountManager $accountManager |
|
51 | + * @param IClientService $clientService |
|
52 | + * @param Signer $signer |
|
53 | + * @param IJobList $jobList |
|
54 | + * @param string $lookupServer if nothing is given we use the default lookup server |
|
55 | + */ |
|
56 | + public function __construct(AccountManager $accountManager, |
|
57 | + IClientService $clientService, |
|
58 | + Signer $signer, |
|
59 | + IJobList $jobList, |
|
60 | + $lookupServer = '') { |
|
61 | + $this->accountManager = $accountManager; |
|
62 | + $this->clientService = $clientService; |
|
63 | + $this->signer = $signer; |
|
64 | + $this->jobList = $jobList; |
|
65 | + if ($lookupServer !== '') { |
|
66 | + $this->lookupServer = $lookupServer; |
|
67 | + } |
|
68 | + $this->lookupServer = rtrim($this->lookupServer, '/'); |
|
69 | + $this->lookupServer .= '/users'; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param IUser $user |
|
74 | - */ |
|
75 | - public function userUpdated(IUser $user) { |
|
76 | - $userData = $this->accountManager->getUser($user); |
|
77 | - $publicData = []; |
|
72 | + /** |
|
73 | + * @param IUser $user |
|
74 | + */ |
|
75 | + public function userUpdated(IUser $user) { |
|
76 | + $userData = $this->accountManager->getUser($user); |
|
77 | + $publicData = []; |
|
78 | 78 | |
79 | - foreach ($userData as $key => $data) { |
|
80 | - if ($data['scope'] === AccountManager::VISIBILITY_PUBLIC) { |
|
81 | - $publicData[$key] = $data; |
|
82 | - } |
|
83 | - } |
|
79 | + foreach ($userData as $key => $data) { |
|
80 | + if ($data['scope'] === AccountManager::VISIBILITY_PUBLIC) { |
|
81 | + $publicData[$key] = $data; |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | - $this->sendToLookupServer($user, $publicData); |
|
86 | - } |
|
85 | + $this->sendToLookupServer($user, $publicData); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * send public user data to the lookup server |
|
90 | - * |
|
91 | - * @param IUser $user |
|
92 | - * @param array $publicData |
|
93 | - */ |
|
94 | - protected function sendToLookupServer(IUser $user, array $publicData) { |
|
88 | + /** |
|
89 | + * send public user data to the lookup server |
|
90 | + * |
|
91 | + * @param IUser $user |
|
92 | + * @param array $publicData |
|
93 | + */ |
|
94 | + protected function sendToLookupServer(IUser $user, array $publicData) { |
|
95 | 95 | |
96 | - $dataArray = ['federationId' => $user->getCloudId()]; |
|
96 | + $dataArray = ['federationId' => $user->getCloudId()]; |
|
97 | 97 | |
98 | - if (!empty($publicData)) { |
|
99 | - $dataArray['name'] = isset($publicData[AccountManager::PROPERTY_DISPLAYNAME]) ? $publicData[AccountManager::PROPERTY_DISPLAYNAME]['value'] : ''; |
|
100 | - $dataArray['email'] = isset($publicData[AccountManager::PROPERTY_EMAIL]) ? $publicData[AccountManager::PROPERTY_EMAIL]['value'] : ''; |
|
101 | - $dataArray['address'] = isset($publicData[AccountManager::PROPERTY_ADDRESS]) ? $publicData[AccountManager::PROPERTY_ADDRESS]['value'] : ''; |
|
102 | - $dataArray['website'] = isset($publicData[AccountManager::PROPERTY_WEBSITE]) ? $publicData[AccountManager::PROPERTY_WEBSITE]['value'] : ''; |
|
103 | - $dataArray['twitter'] = isset($publicData[AccountManager::PROPERTY_TWITTER]) ? $publicData[AccountManager::PROPERTY_TWITTER]['value'] : ''; |
|
104 | - $dataArray['phone'] = isset($publicData[AccountManager::PROPERTY_PHONE]) ? $publicData[AccountManager::PROPERTY_PHONE]['value'] : ''; |
|
105 | - } |
|
98 | + if (!empty($publicData)) { |
|
99 | + $dataArray['name'] = isset($publicData[AccountManager::PROPERTY_DISPLAYNAME]) ? $publicData[AccountManager::PROPERTY_DISPLAYNAME]['value'] : ''; |
|
100 | + $dataArray['email'] = isset($publicData[AccountManager::PROPERTY_EMAIL]) ? $publicData[AccountManager::PROPERTY_EMAIL]['value'] : ''; |
|
101 | + $dataArray['address'] = isset($publicData[AccountManager::PROPERTY_ADDRESS]) ? $publicData[AccountManager::PROPERTY_ADDRESS]['value'] : ''; |
|
102 | + $dataArray['website'] = isset($publicData[AccountManager::PROPERTY_WEBSITE]) ? $publicData[AccountManager::PROPERTY_WEBSITE]['value'] : ''; |
|
103 | + $dataArray['twitter'] = isset($publicData[AccountManager::PROPERTY_TWITTER]) ? $publicData[AccountManager::PROPERTY_TWITTER]['value'] : ''; |
|
104 | + $dataArray['phone'] = isset($publicData[AccountManager::PROPERTY_PHONE]) ? $publicData[AccountManager::PROPERTY_PHONE]['value'] : ''; |
|
105 | + } |
|
106 | 106 | |
107 | - $dataArray = $this->signer->sign('lookupserver', $dataArray, $user); |
|
108 | - $httpClient = $this->clientService->newClient(); |
|
109 | - try { |
|
110 | - if (empty($publicData)) { |
|
111 | - $httpClient->delete($this->lookupServer, |
|
112 | - [ |
|
113 | - 'body' => json_encode($dataArray), |
|
114 | - 'timeout' => 10, |
|
115 | - 'connect_timeout' => 3, |
|
116 | - ] |
|
117 | - ); |
|
118 | - } else { |
|
119 | - $httpClient->post($this->lookupServer, |
|
120 | - [ |
|
121 | - 'body' => json_encode($dataArray), |
|
122 | - 'timeout' => 10, |
|
123 | - 'connect_timeout' => 3, |
|
124 | - ] |
|
125 | - ); |
|
126 | - } |
|
127 | - } catch (\Exception $e) { |
|
128 | - $this->jobList->add(RetryJob::class, |
|
129 | - [ |
|
130 | - 'dataArray' => $dataArray, |
|
131 | - 'retryNo' => 0, |
|
132 | - ] |
|
133 | - ); |
|
134 | - } |
|
135 | - } |
|
107 | + $dataArray = $this->signer->sign('lookupserver', $dataArray, $user); |
|
108 | + $httpClient = $this->clientService->newClient(); |
|
109 | + try { |
|
110 | + if (empty($publicData)) { |
|
111 | + $httpClient->delete($this->lookupServer, |
|
112 | + [ |
|
113 | + 'body' => json_encode($dataArray), |
|
114 | + 'timeout' => 10, |
|
115 | + 'connect_timeout' => 3, |
|
116 | + ] |
|
117 | + ); |
|
118 | + } else { |
|
119 | + $httpClient->post($this->lookupServer, |
|
120 | + [ |
|
121 | + 'body' => json_encode($dataArray), |
|
122 | + 'timeout' => 10, |
|
123 | + 'connect_timeout' => 3, |
|
124 | + ] |
|
125 | + ); |
|
126 | + } |
|
127 | + } catch (\Exception $e) { |
|
128 | + $this->jobList->add(RetryJob::class, |
|
129 | + [ |
|
130 | + 'dataArray' => $dataArray, |
|
131 | + 'retryNo' => 0, |
|
132 | + ] |
|
133 | + ); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | } |
@@ -22,26 +22,26 @@ |
||
22 | 22 | $dispatcher = \OC::$server->getEventDispatcher(); |
23 | 23 | |
24 | 24 | $dispatcher->addListener('OC\AccountManager::userUpdated', function(\Symfony\Component\EventDispatcher\GenericEvent $event) { |
25 | - $user = $event->getSubject(); |
|
25 | + $user = $event->getSubject(); |
|
26 | 26 | |
27 | - $keyManager = new \OC\Security\IdentityProof\Manager( |
|
28 | - \OC::$server->getAppDataDir('identityproof'), |
|
29 | - \OC::$server->getCrypto() |
|
30 | - ); |
|
27 | + $keyManager = new \OC\Security\IdentityProof\Manager( |
|
28 | + \OC::$server->getAppDataDir('identityproof'), |
|
29 | + \OC::$server->getCrypto() |
|
30 | + ); |
|
31 | 31 | |
32 | - $config = \OC::$server->getConfig(); |
|
33 | - $lookupServer = $config->getSystemValue('lookup_server', ''); |
|
32 | + $config = \OC::$server->getConfig(); |
|
33 | + $lookupServer = $config->getSystemValue('lookup_server', ''); |
|
34 | 34 | |
35 | - $updateLookupServer = new \OCA\LookupServerConnector\UpdateLookupServer( |
|
36 | - new \OC\Accounts\AccountManager(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()), |
|
37 | - \OC::$server->getHTTPClientService(), |
|
38 | - new \OC\Security\IdentityProof\Signer( |
|
39 | - $keyManager, |
|
40 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
41 | - \OC::$server->getUserManager() |
|
42 | - ), |
|
43 | - \OC::$server->getJobList(), |
|
44 | - $lookupServer |
|
45 | - ); |
|
46 | - $updateLookupServer->userUpdated($user); |
|
35 | + $updateLookupServer = new \OCA\LookupServerConnector\UpdateLookupServer( |
|
36 | + new \OC\Accounts\AccountManager(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()), |
|
37 | + \OC::$server->getHTTPClientService(), |
|
38 | + new \OC\Security\IdentityProof\Signer( |
|
39 | + $keyManager, |
|
40 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
41 | + \OC::$server->getUserManager() |
|
42 | + ), |
|
43 | + \OC::$server->getJobList(), |
|
44 | + $lookupServer |
|
45 | + ); |
|
46 | + $updateLookupServer->userUpdated($user); |
|
47 | 47 | }); |
@@ -141,19 +141,19 @@ |
||
141 | 141 | $websiteVerified = isset($oldData[self::PROPERTY_WEBSITE]['verified']) && $oldData[self::PROPERTY_WEBSITE]['verified'] === self::VERIFIED; |
142 | 142 | $emailVerified = isset($oldData[self::PROPERTY_EMAIL]['verified']) && $oldData[self::PROPERTY_EMAIL]['verified'] === self::VERIFIED; |
143 | 143 | |
144 | - if($twitterVerified && |
|
144 | + if ($twitterVerified && |
|
145 | 145 | $oldData[self::PROPERTY_TWITTER]['value'] !== $newData[self::PROPERTY_TWITTER]['value'] |
146 | 146 | ) { |
147 | 147 | $newData[self::PROPERTY_TWITTER]['value']['verified'] = self::NOT_VERIFIED; |
148 | 148 | } |
149 | 149 | |
150 | - if($websiteVerified && |
|
150 | + if ($websiteVerified && |
|
151 | 151 | $oldData[self::PROPERTY_WEBSITE]['value'] !== $newData[self::PROPERTY_WEBSITE]['value'] |
152 | 152 | ) { |
153 | 153 | $newData[self::PROPERTY_WEBSITE]['value']['verified'] = self::NOT_VERIFIED; |
154 | 154 | } |
155 | 155 | |
156 | - if($emailVerified && |
|
156 | + if ($emailVerified && |
|
157 | 157 | $oldData[self::PROPERTY_EMAIL]['value'] !== $newData[self::PROPERTY_EMAIL]['value'] |
158 | 158 | ) { |
159 | 159 | $newData[self::PROPERTY_EMAIL]['value']['verified'] = self::NOT_VERIFIED; |
@@ -38,216 +38,216 @@ |
||
38 | 38 | */ |
39 | 39 | class AccountManager { |
40 | 40 | |
41 | - /** nobody can see my account details */ |
|
42 | - const VISIBILITY_PRIVATE = 'private'; |
|
43 | - /** only contacts, especially trusted servers can see my contact details */ |
|
44 | - const VISIBILITY_CONTACTS_ONLY = 'contacts'; |
|
45 | - /** every body ca see my contact detail, will be published to the lookup server */ |
|
46 | - const VISIBILITY_PUBLIC = 'public'; |
|
47 | - |
|
48 | - const PROPERTY_AVATAR = 'avatar'; |
|
49 | - const PROPERTY_DISPLAYNAME = 'displayname'; |
|
50 | - const PROPERTY_PHONE = 'phone'; |
|
51 | - const PROPERTY_EMAIL = 'email'; |
|
52 | - const PROPERTY_WEBSITE = 'website'; |
|
53 | - const PROPERTY_ADDRESS = 'address'; |
|
54 | - const PROPERTY_TWITTER = 'twitter'; |
|
55 | - |
|
56 | - const NOT_VERIFIED = '0'; |
|
57 | - const VERIFICATION_IN_PROGRESS = '1'; |
|
58 | - const VERIFIED = '2'; |
|
59 | - |
|
60 | - /** @var IDBConnection database connection */ |
|
61 | - private $connection; |
|
62 | - |
|
63 | - /** @var string table name */ |
|
64 | - private $table = 'accounts'; |
|
65 | - |
|
66 | - /** @var EventDispatcherInterface */ |
|
67 | - private $eventDispatcher; |
|
68 | - |
|
69 | - /** |
|
70 | - * AccountManager constructor. |
|
71 | - * |
|
72 | - * @param IDBConnection $connection |
|
73 | - * @param EventDispatcherInterface $eventDispatcher |
|
74 | - */ |
|
75 | - public function __construct(IDBConnection $connection, EventDispatcherInterface $eventDispatcher) { |
|
76 | - $this->connection = $connection; |
|
77 | - $this->eventDispatcher = $eventDispatcher; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * update user record |
|
82 | - * |
|
83 | - * @param IUser $user |
|
84 | - * @param $data |
|
85 | - */ |
|
86 | - public function updateUser(IUser $user, $data) { |
|
87 | - $userData = $this->getUser($user); |
|
88 | - $updated = true; |
|
89 | - if (empty($userData)) { |
|
90 | - $this->insertNewUser($user, $data); |
|
91 | - } elseif ($userData !== $data) { |
|
92 | - $data = $this->updateVerifyStatus($userData, $data); |
|
93 | - $this->updateExistingUser($user, $data); |
|
94 | - } else { |
|
95 | - // nothing needs to be done if new and old data set are the same |
|
96 | - $updated = false; |
|
97 | - } |
|
98 | - |
|
99 | - if ($updated) { |
|
100 | - $this->eventDispatcher->dispatch( |
|
101 | - 'OC\AccountManager::userUpdated', |
|
102 | - new GenericEvent($user, $data) |
|
103 | - ); |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * get stored data from a given user |
|
109 | - * |
|
110 | - * @param IUser $user |
|
111 | - * @return array |
|
112 | - */ |
|
113 | - public function getUser(IUser $user) { |
|
114 | - $uid = $user->getUID(); |
|
115 | - $query = $this->connection->getQueryBuilder(); |
|
116 | - $query->select('data')->from($this->table) |
|
117 | - ->where($query->expr()->eq('uid', $query->createParameter('uid'))) |
|
118 | - ->setParameter('uid', $uid); |
|
119 | - $query->execute(); |
|
120 | - $result = $query->execute()->fetchAll(); |
|
121 | - |
|
122 | - if (empty($result)) { |
|
123 | - $userData = $this->buildDefaultUserRecord($user); |
|
124 | - $this->insertNewUser($user, $userData); |
|
125 | - return $userData; |
|
126 | - } |
|
127 | - |
|
128 | - return json_decode($result[0]['data'], true); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * reset verification status if personal data changed |
|
133 | - * |
|
134 | - * @param array $oldData |
|
135 | - * @param array $newData |
|
136 | - * @return array |
|
137 | - */ |
|
138 | - protected function updateVerifyStatus($oldData, $newData) { |
|
139 | - |
|
140 | - $twitterVerified = isset($oldData[self::PROPERTY_TWITTER]['verified']) && $oldData[self::PROPERTY_TWITTER]['verified'] === self::VERIFIED; |
|
141 | - $websiteVerified = isset($oldData[self::PROPERTY_WEBSITE]['verified']) && $oldData[self::PROPERTY_WEBSITE]['verified'] === self::VERIFIED; |
|
142 | - $emailVerified = isset($oldData[self::PROPERTY_EMAIL]['verified']) && $oldData[self::PROPERTY_EMAIL]['verified'] === self::VERIFIED; |
|
143 | - |
|
144 | - if($twitterVerified && |
|
145 | - $oldData[self::PROPERTY_TWITTER]['value'] !== $newData[self::PROPERTY_TWITTER]['value'] |
|
146 | - ) { |
|
147 | - $newData[self::PROPERTY_TWITTER]['value']['verified'] = self::NOT_VERIFIED; |
|
148 | - } |
|
149 | - |
|
150 | - if($websiteVerified && |
|
151 | - $oldData[self::PROPERTY_WEBSITE]['value'] !== $newData[self::PROPERTY_WEBSITE]['value'] |
|
152 | - ) { |
|
153 | - $newData[self::PROPERTY_WEBSITE]['value']['verified'] = self::NOT_VERIFIED; |
|
154 | - } |
|
155 | - |
|
156 | - if($emailVerified && |
|
157 | - $oldData[self::PROPERTY_EMAIL]['value'] !== $newData[self::PROPERTY_EMAIL]['value'] |
|
158 | - ) { |
|
159 | - $newData[self::PROPERTY_EMAIL]['value']['verified'] = self::NOT_VERIFIED; |
|
160 | - } |
|
161 | - |
|
162 | - return $newData; |
|
163 | - |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * add new user to accounts table |
|
168 | - * |
|
169 | - * @param IUser $user |
|
170 | - * @param array $data |
|
171 | - */ |
|
172 | - protected function insertNewUser(IUser $user, $data) { |
|
173 | - $uid = $user->getUID(); |
|
174 | - $jsonEncodedData = json_encode($data); |
|
175 | - $query = $this->connection->getQueryBuilder(); |
|
176 | - $query->insert($this->table) |
|
177 | - ->values( |
|
178 | - [ |
|
179 | - 'uid' => $query->createNamedParameter($uid), |
|
180 | - 'data' => $query->createNamedParameter($jsonEncodedData), |
|
181 | - ] |
|
182 | - ) |
|
183 | - ->execute(); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * update existing user in accounts table |
|
188 | - * |
|
189 | - * @param IUser $user |
|
190 | - * @param array $data |
|
191 | - */ |
|
192 | - protected function updateExistingUser(IUser $user, $data) { |
|
193 | - $uid = $user->getUID(); |
|
194 | - $jsonEncodedData = json_encode($data); |
|
195 | - $query = $this->connection->getQueryBuilder(); |
|
196 | - $query->update($this->table) |
|
197 | - ->set('data', $query->createNamedParameter($jsonEncodedData)) |
|
198 | - ->where($query->expr()->eq('uid', $query->createNamedParameter($uid))) |
|
199 | - ->execute(); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * build default user record in case not data set exists yet |
|
204 | - * |
|
205 | - * @param IUser $user |
|
206 | - * @return array |
|
207 | - */ |
|
208 | - protected function buildDefaultUserRecord(IUser $user) { |
|
209 | - return [ |
|
210 | - self::PROPERTY_DISPLAYNAME => |
|
211 | - [ |
|
212 | - 'value' => $user->getDisplayName(), |
|
213 | - 'scope' => self::VISIBILITY_CONTACTS_ONLY, |
|
214 | - 'verified' => '0', |
|
215 | - ], |
|
216 | - self::PROPERTY_ADDRESS => |
|
217 | - [ |
|
218 | - 'value' => '', |
|
219 | - 'scope' => self::VISIBILITY_PRIVATE, |
|
220 | - 'verified' => '0', |
|
221 | - ], |
|
222 | - self::PROPERTY_WEBSITE => |
|
223 | - [ |
|
224 | - 'value' => '', |
|
225 | - 'scope' => self::VISIBILITY_PRIVATE, |
|
226 | - 'verified' => '0', |
|
227 | - ], |
|
228 | - self::PROPERTY_EMAIL => |
|
229 | - [ |
|
230 | - 'value' => $user->getEMailAddress(), |
|
231 | - 'scope' => self::VISIBILITY_CONTACTS_ONLY, |
|
232 | - 'verified' => '0', |
|
233 | - ], |
|
234 | - self::PROPERTY_AVATAR => |
|
235 | - [ |
|
236 | - 'scope' => self::VISIBILITY_CONTACTS_ONLY |
|
237 | - ], |
|
238 | - self::PROPERTY_PHONE => |
|
239 | - [ |
|
240 | - 'value' => '', |
|
241 | - 'scope' => self::VISIBILITY_PRIVATE, |
|
242 | - 'verified' => '0', |
|
243 | - ], |
|
244 | - self::PROPERTY_TWITTER => |
|
245 | - [ |
|
246 | - 'value' => '', |
|
247 | - 'scope' => self::VISIBILITY_PRIVATE, |
|
248 | - 'verified' => '0', |
|
249 | - ], |
|
250 | - ]; |
|
251 | - } |
|
41 | + /** nobody can see my account details */ |
|
42 | + const VISIBILITY_PRIVATE = 'private'; |
|
43 | + /** only contacts, especially trusted servers can see my contact details */ |
|
44 | + const VISIBILITY_CONTACTS_ONLY = 'contacts'; |
|
45 | + /** every body ca see my contact detail, will be published to the lookup server */ |
|
46 | + const VISIBILITY_PUBLIC = 'public'; |
|
47 | + |
|
48 | + const PROPERTY_AVATAR = 'avatar'; |
|
49 | + const PROPERTY_DISPLAYNAME = 'displayname'; |
|
50 | + const PROPERTY_PHONE = 'phone'; |
|
51 | + const PROPERTY_EMAIL = 'email'; |
|
52 | + const PROPERTY_WEBSITE = 'website'; |
|
53 | + const PROPERTY_ADDRESS = 'address'; |
|
54 | + const PROPERTY_TWITTER = 'twitter'; |
|
55 | + |
|
56 | + const NOT_VERIFIED = '0'; |
|
57 | + const VERIFICATION_IN_PROGRESS = '1'; |
|
58 | + const VERIFIED = '2'; |
|
59 | + |
|
60 | + /** @var IDBConnection database connection */ |
|
61 | + private $connection; |
|
62 | + |
|
63 | + /** @var string table name */ |
|
64 | + private $table = 'accounts'; |
|
65 | + |
|
66 | + /** @var EventDispatcherInterface */ |
|
67 | + private $eventDispatcher; |
|
68 | + |
|
69 | + /** |
|
70 | + * AccountManager constructor. |
|
71 | + * |
|
72 | + * @param IDBConnection $connection |
|
73 | + * @param EventDispatcherInterface $eventDispatcher |
|
74 | + */ |
|
75 | + public function __construct(IDBConnection $connection, EventDispatcherInterface $eventDispatcher) { |
|
76 | + $this->connection = $connection; |
|
77 | + $this->eventDispatcher = $eventDispatcher; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * update user record |
|
82 | + * |
|
83 | + * @param IUser $user |
|
84 | + * @param $data |
|
85 | + */ |
|
86 | + public function updateUser(IUser $user, $data) { |
|
87 | + $userData = $this->getUser($user); |
|
88 | + $updated = true; |
|
89 | + if (empty($userData)) { |
|
90 | + $this->insertNewUser($user, $data); |
|
91 | + } elseif ($userData !== $data) { |
|
92 | + $data = $this->updateVerifyStatus($userData, $data); |
|
93 | + $this->updateExistingUser($user, $data); |
|
94 | + } else { |
|
95 | + // nothing needs to be done if new and old data set are the same |
|
96 | + $updated = false; |
|
97 | + } |
|
98 | + |
|
99 | + if ($updated) { |
|
100 | + $this->eventDispatcher->dispatch( |
|
101 | + 'OC\AccountManager::userUpdated', |
|
102 | + new GenericEvent($user, $data) |
|
103 | + ); |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * get stored data from a given user |
|
109 | + * |
|
110 | + * @param IUser $user |
|
111 | + * @return array |
|
112 | + */ |
|
113 | + public function getUser(IUser $user) { |
|
114 | + $uid = $user->getUID(); |
|
115 | + $query = $this->connection->getQueryBuilder(); |
|
116 | + $query->select('data')->from($this->table) |
|
117 | + ->where($query->expr()->eq('uid', $query->createParameter('uid'))) |
|
118 | + ->setParameter('uid', $uid); |
|
119 | + $query->execute(); |
|
120 | + $result = $query->execute()->fetchAll(); |
|
121 | + |
|
122 | + if (empty($result)) { |
|
123 | + $userData = $this->buildDefaultUserRecord($user); |
|
124 | + $this->insertNewUser($user, $userData); |
|
125 | + return $userData; |
|
126 | + } |
|
127 | + |
|
128 | + return json_decode($result[0]['data'], true); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * reset verification status if personal data changed |
|
133 | + * |
|
134 | + * @param array $oldData |
|
135 | + * @param array $newData |
|
136 | + * @return array |
|
137 | + */ |
|
138 | + protected function updateVerifyStatus($oldData, $newData) { |
|
139 | + |
|
140 | + $twitterVerified = isset($oldData[self::PROPERTY_TWITTER]['verified']) && $oldData[self::PROPERTY_TWITTER]['verified'] === self::VERIFIED; |
|
141 | + $websiteVerified = isset($oldData[self::PROPERTY_WEBSITE]['verified']) && $oldData[self::PROPERTY_WEBSITE]['verified'] === self::VERIFIED; |
|
142 | + $emailVerified = isset($oldData[self::PROPERTY_EMAIL]['verified']) && $oldData[self::PROPERTY_EMAIL]['verified'] === self::VERIFIED; |
|
143 | + |
|
144 | + if($twitterVerified && |
|
145 | + $oldData[self::PROPERTY_TWITTER]['value'] !== $newData[self::PROPERTY_TWITTER]['value'] |
|
146 | + ) { |
|
147 | + $newData[self::PROPERTY_TWITTER]['value']['verified'] = self::NOT_VERIFIED; |
|
148 | + } |
|
149 | + |
|
150 | + if($websiteVerified && |
|
151 | + $oldData[self::PROPERTY_WEBSITE]['value'] !== $newData[self::PROPERTY_WEBSITE]['value'] |
|
152 | + ) { |
|
153 | + $newData[self::PROPERTY_WEBSITE]['value']['verified'] = self::NOT_VERIFIED; |
|
154 | + } |
|
155 | + |
|
156 | + if($emailVerified && |
|
157 | + $oldData[self::PROPERTY_EMAIL]['value'] !== $newData[self::PROPERTY_EMAIL]['value'] |
|
158 | + ) { |
|
159 | + $newData[self::PROPERTY_EMAIL]['value']['verified'] = self::NOT_VERIFIED; |
|
160 | + } |
|
161 | + |
|
162 | + return $newData; |
|
163 | + |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * add new user to accounts table |
|
168 | + * |
|
169 | + * @param IUser $user |
|
170 | + * @param array $data |
|
171 | + */ |
|
172 | + protected function insertNewUser(IUser $user, $data) { |
|
173 | + $uid = $user->getUID(); |
|
174 | + $jsonEncodedData = json_encode($data); |
|
175 | + $query = $this->connection->getQueryBuilder(); |
|
176 | + $query->insert($this->table) |
|
177 | + ->values( |
|
178 | + [ |
|
179 | + 'uid' => $query->createNamedParameter($uid), |
|
180 | + 'data' => $query->createNamedParameter($jsonEncodedData), |
|
181 | + ] |
|
182 | + ) |
|
183 | + ->execute(); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * update existing user in accounts table |
|
188 | + * |
|
189 | + * @param IUser $user |
|
190 | + * @param array $data |
|
191 | + */ |
|
192 | + protected function updateExistingUser(IUser $user, $data) { |
|
193 | + $uid = $user->getUID(); |
|
194 | + $jsonEncodedData = json_encode($data); |
|
195 | + $query = $this->connection->getQueryBuilder(); |
|
196 | + $query->update($this->table) |
|
197 | + ->set('data', $query->createNamedParameter($jsonEncodedData)) |
|
198 | + ->where($query->expr()->eq('uid', $query->createNamedParameter($uid))) |
|
199 | + ->execute(); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * build default user record in case not data set exists yet |
|
204 | + * |
|
205 | + * @param IUser $user |
|
206 | + * @return array |
|
207 | + */ |
|
208 | + protected function buildDefaultUserRecord(IUser $user) { |
|
209 | + return [ |
|
210 | + self::PROPERTY_DISPLAYNAME => |
|
211 | + [ |
|
212 | + 'value' => $user->getDisplayName(), |
|
213 | + 'scope' => self::VISIBILITY_CONTACTS_ONLY, |
|
214 | + 'verified' => '0', |
|
215 | + ], |
|
216 | + self::PROPERTY_ADDRESS => |
|
217 | + [ |
|
218 | + 'value' => '', |
|
219 | + 'scope' => self::VISIBILITY_PRIVATE, |
|
220 | + 'verified' => '0', |
|
221 | + ], |
|
222 | + self::PROPERTY_WEBSITE => |
|
223 | + [ |
|
224 | + 'value' => '', |
|
225 | + 'scope' => self::VISIBILITY_PRIVATE, |
|
226 | + 'verified' => '0', |
|
227 | + ], |
|
228 | + self::PROPERTY_EMAIL => |
|
229 | + [ |
|
230 | + 'value' => $user->getEMailAddress(), |
|
231 | + 'scope' => self::VISIBILITY_CONTACTS_ONLY, |
|
232 | + 'verified' => '0', |
|
233 | + ], |
|
234 | + self::PROPERTY_AVATAR => |
|
235 | + [ |
|
236 | + 'scope' => self::VISIBILITY_CONTACTS_ONLY |
|
237 | + ], |
|
238 | + self::PROPERTY_PHONE => |
|
239 | + [ |
|
240 | + 'value' => '', |
|
241 | + 'scope' => self::VISIBILITY_PRIVATE, |
|
242 | + 'verified' => '0', |
|
243 | + ], |
|
244 | + self::PROPERTY_TWITTER => |
|
245 | + [ |
|
246 | + 'value' => '', |
|
247 | + 'scope' => self::VISIBILITY_PRIVATE, |
|
248 | + 'verified' => '0', |
|
249 | + ], |
|
250 | + ]; |
|
251 | + } |
|
252 | 252 | |
253 | 253 | } |
@@ -55,815 +55,815 @@ |
||
55 | 55 | * @package OC\Settings\Controller |
56 | 56 | */ |
57 | 57 | class UsersController extends Controller { |
58 | - /** @var IL10N */ |
|
59 | - private $l10n; |
|
60 | - /** @var IUserSession */ |
|
61 | - private $userSession; |
|
62 | - /** @var bool */ |
|
63 | - private $isAdmin; |
|
64 | - /** @var IUserManager */ |
|
65 | - private $userManager; |
|
66 | - /** @var IGroupManager */ |
|
67 | - private $groupManager; |
|
68 | - /** @var IConfig */ |
|
69 | - private $config; |
|
70 | - /** @var ILogger */ |
|
71 | - private $log; |
|
72 | - /** @var IMailer */ |
|
73 | - private $mailer; |
|
74 | - /** @var bool contains the state of the encryption app */ |
|
75 | - private $isEncryptionAppEnabled; |
|
76 | - /** @var bool contains the state of the admin recovery setting */ |
|
77 | - private $isRestoreEnabled = false; |
|
78 | - /** @var IAvatarManager */ |
|
79 | - private $avatarManager; |
|
80 | - /** @var AccountManager */ |
|
81 | - private $accountManager; |
|
82 | - /** @var ISecureRandom */ |
|
83 | - private $secureRandom; |
|
84 | - /** @var NewUserMailHelper */ |
|
85 | - private $newUserMailHelper; |
|
86 | - /** @var ITimeFactory */ |
|
87 | - private $timeFactory; |
|
88 | - /** @var ICrypto */ |
|
89 | - private $crypto; |
|
90 | - /** @var Manager */ |
|
91 | - private $keyManager; |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * @param string $appName |
|
96 | - * @param IRequest $request |
|
97 | - * @param IUserManager $userManager |
|
98 | - * @param IGroupManager $groupManager |
|
99 | - * @param IUserSession $userSession |
|
100 | - * @param IConfig $config |
|
101 | - * @param bool $isAdmin |
|
102 | - * @param IL10N $l10n |
|
103 | - * @param ILogger $log |
|
104 | - * @param IMailer $mailer |
|
105 | - * @param IURLGenerator $urlGenerator |
|
106 | - * @param IAppManager $appManager |
|
107 | - * @param IAvatarManager $avatarManager |
|
108 | - * @param AccountManager $accountManager |
|
109 | - * @param ISecureRandom $secureRandom |
|
110 | - * @param NewUserMailHelper $newUserMailHelper |
|
111 | - * @param ITimeFactory $timeFactory |
|
112 | - * @param ICrypto $crypto |
|
113 | - * @param Manager $keyManager |
|
114 | - */ |
|
115 | - public function __construct($appName, |
|
116 | - IRequest $request, |
|
117 | - IUserManager $userManager, |
|
118 | - IGroupManager $groupManager, |
|
119 | - IUserSession $userSession, |
|
120 | - IConfig $config, |
|
121 | - $isAdmin, |
|
122 | - IL10N $l10n, |
|
123 | - ILogger $log, |
|
124 | - IMailer $mailer, |
|
125 | - IURLGenerator $urlGenerator, |
|
126 | - IAppManager $appManager, |
|
127 | - IAvatarManager $avatarManager, |
|
128 | - AccountManager $accountManager, |
|
129 | - ISecureRandom $secureRandom, |
|
130 | - NewUserMailHelper $newUserMailHelper, |
|
131 | - ITimeFactory $timeFactory, |
|
132 | - ICrypto $crypto, |
|
133 | - Manager $keyManager) { |
|
134 | - parent::__construct($appName, $request); |
|
135 | - $this->userManager = $userManager; |
|
136 | - $this->groupManager = $groupManager; |
|
137 | - $this->userSession = $userSession; |
|
138 | - $this->config = $config; |
|
139 | - $this->isAdmin = $isAdmin; |
|
140 | - $this->l10n = $l10n; |
|
141 | - $this->log = $log; |
|
142 | - $this->mailer = $mailer; |
|
143 | - $this->avatarManager = $avatarManager; |
|
144 | - $this->accountManager = $accountManager; |
|
145 | - $this->secureRandom = $secureRandom; |
|
146 | - $this->newUserMailHelper = $newUserMailHelper; |
|
147 | - $this->timeFactory = $timeFactory; |
|
148 | - $this->crypto = $crypto; |
|
149 | - $this->keyManager = $keyManager; |
|
150 | - |
|
151 | - // check for encryption state - TODO see formatUserForIndex |
|
152 | - $this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption'); |
|
153 | - if($this->isEncryptionAppEnabled) { |
|
154 | - // putting this directly in empty is possible in PHP 5.5+ |
|
155 | - $result = $config->getAppValue('encryption', 'recoveryAdminEnabled', 0); |
|
156 | - $this->isRestoreEnabled = !empty($result); |
|
157 | - } |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * @param IUser $user |
|
162 | - * @param array $userGroups |
|
163 | - * @return array |
|
164 | - */ |
|
165 | - private function formatUserForIndex(IUser $user, array $userGroups = null) { |
|
166 | - |
|
167 | - // TODO: eliminate this encryption specific code below and somehow |
|
168 | - // hook in additional user info from other apps |
|
169 | - |
|
170 | - // recovery isn't possible if admin or user has it disabled and encryption |
|
171 | - // is enabled - so we eliminate the else paths in the conditional tree |
|
172 | - // below |
|
173 | - $restorePossible = false; |
|
174 | - |
|
175 | - if ($this->isEncryptionAppEnabled) { |
|
176 | - if ($this->isRestoreEnabled) { |
|
177 | - // check for the users recovery setting |
|
178 | - $recoveryMode = $this->config->getUserValue($user->getUID(), 'encryption', 'recoveryEnabled', '0'); |
|
179 | - // method call inside empty is possible with PHP 5.5+ |
|
180 | - $recoveryModeEnabled = !empty($recoveryMode); |
|
181 | - if ($recoveryModeEnabled) { |
|
182 | - // user also has recovery mode enabled |
|
183 | - $restorePossible = true; |
|
184 | - } |
|
185 | - } |
|
186 | - } else { |
|
187 | - // recovery is possible if encryption is disabled (plain files are |
|
188 | - // available) |
|
189 | - $restorePossible = true; |
|
190 | - } |
|
191 | - |
|
192 | - $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user); |
|
193 | - foreach($subAdminGroups as $key => $subAdminGroup) { |
|
194 | - $subAdminGroups[$key] = $subAdminGroup->getGID(); |
|
195 | - } |
|
196 | - |
|
197 | - $displayName = $user->getEMailAddress(); |
|
198 | - if (is_null($displayName)) { |
|
199 | - $displayName = ''; |
|
200 | - } |
|
201 | - |
|
202 | - $avatarAvailable = false; |
|
203 | - try { |
|
204 | - $avatarAvailable = $this->avatarManager->getAvatar($user->getUID())->exists(); |
|
205 | - } catch (\Exception $e) { |
|
206 | - //No avatar yet |
|
207 | - } |
|
208 | - |
|
209 | - return [ |
|
210 | - 'name' => $user->getUID(), |
|
211 | - 'displayname' => $user->getDisplayName(), |
|
212 | - 'groups' => (empty($userGroups)) ? $this->groupManager->getUserGroupIds($user) : $userGroups, |
|
213 | - 'subadmin' => $subAdminGroups, |
|
214 | - 'quota' => $user->getQuota(), |
|
215 | - 'storageLocation' => $user->getHome(), |
|
216 | - 'lastLogin' => $user->getLastLogin() * 1000, |
|
217 | - 'backend' => $user->getBackendClassName(), |
|
218 | - 'email' => $displayName, |
|
219 | - 'isRestoreDisabled' => !$restorePossible, |
|
220 | - 'isAvatarAvailable' => $avatarAvailable, |
|
221 | - ]; |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * @param array $userIDs Array with schema [$uid => $displayName] |
|
226 | - * @return IUser[] |
|
227 | - */ |
|
228 | - private function getUsersForUID(array $userIDs) { |
|
229 | - $users = []; |
|
230 | - foreach ($userIDs as $uid => $displayName) { |
|
231 | - $users[$uid] = $this->userManager->get($uid); |
|
232 | - } |
|
233 | - return $users; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * @NoAdminRequired |
|
238 | - * |
|
239 | - * @param int $offset |
|
240 | - * @param int $limit |
|
241 | - * @param string $gid GID to filter for |
|
242 | - * @param string $pattern Pattern to search for in the username |
|
243 | - * @param string $backend Backend to filter for (class-name) |
|
244 | - * @return DataResponse |
|
245 | - * |
|
246 | - * TODO: Tidy up and write unit tests - code is mainly static method calls |
|
247 | - */ |
|
248 | - public function index($offset = 0, $limit = 10, $gid = '', $pattern = '', $backend = '') { |
|
249 | - // FIXME: The JS sends the group '_everyone' instead of no GID for the "all users" group. |
|
250 | - if($gid === '_everyone') { |
|
251 | - $gid = ''; |
|
252 | - } |
|
253 | - |
|
254 | - // Remove backends |
|
255 | - if(!empty($backend)) { |
|
256 | - $activeBackends = $this->userManager->getBackends(); |
|
257 | - $this->userManager->clearBackends(); |
|
258 | - foreach($activeBackends as $singleActiveBackend) { |
|
259 | - if($backend === get_class($singleActiveBackend)) { |
|
260 | - $this->userManager->registerBackend($singleActiveBackend); |
|
261 | - break; |
|
262 | - } |
|
263 | - } |
|
264 | - } |
|
265 | - |
|
266 | - $users = []; |
|
267 | - if ($this->isAdmin) { |
|
268 | - |
|
269 | - if($gid !== '') { |
|
270 | - $batch = $this->getUsersForUID($this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset)); |
|
271 | - } else { |
|
272 | - $batch = $this->userManager->search($pattern, $limit, $offset); |
|
273 | - } |
|
274 | - |
|
275 | - foreach ($batch as $user) { |
|
276 | - $users[] = $this->formatUserForIndex($user); |
|
277 | - } |
|
278 | - |
|
279 | - } else { |
|
280 | - $subAdminOfGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser()); |
|
281 | - // New class returns IGroup[] so convert back |
|
282 | - $gids = []; |
|
283 | - foreach ($subAdminOfGroups as $group) { |
|
284 | - $gids[] = $group->getGID(); |
|
285 | - } |
|
286 | - $subAdminOfGroups = $gids; |
|
287 | - |
|
288 | - // Set the $gid parameter to an empty value if the subadmin has no rights to access a specific group |
|
289 | - if($gid !== '' && !in_array($gid, $subAdminOfGroups)) { |
|
290 | - $gid = ''; |
|
291 | - } |
|
292 | - |
|
293 | - // Batch all groups the user is subadmin of when a group is specified |
|
294 | - $batch = []; |
|
295 | - if($gid === '') { |
|
296 | - foreach($subAdminOfGroups as $group) { |
|
297 | - $groupUsers = $this->groupManager->displayNamesInGroup($group, $pattern, $limit, $offset); |
|
298 | - |
|
299 | - foreach($groupUsers as $uid => $displayName) { |
|
300 | - $batch[$uid] = $displayName; |
|
301 | - } |
|
302 | - } |
|
303 | - } else { |
|
304 | - $batch = $this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset); |
|
305 | - } |
|
306 | - $batch = $this->getUsersForUID($batch); |
|
307 | - |
|
308 | - foreach ($batch as $user) { |
|
309 | - // Only add the groups, this user is a subadmin of |
|
310 | - $userGroups = array_values(array_intersect( |
|
311 | - $this->groupManager->getUserGroupIds($user), |
|
312 | - $subAdminOfGroups |
|
313 | - )); |
|
314 | - $users[] = $this->formatUserForIndex($user, $userGroups); |
|
315 | - } |
|
316 | - } |
|
317 | - |
|
318 | - return new DataResponse($users); |
|
319 | - } |
|
320 | - |
|
321 | - /** |
|
322 | - * @NoAdminRequired |
|
323 | - * @PasswordConfirmationRequired |
|
324 | - * |
|
325 | - * @param string $username |
|
326 | - * @param string $password |
|
327 | - * @param array $groups |
|
328 | - * @param string $email |
|
329 | - * @return DataResponse |
|
330 | - */ |
|
331 | - public function create($username, $password, array $groups=array(), $email='') { |
|
332 | - if($email !== '' && !$this->mailer->validateMailAddress($email)) { |
|
333 | - return new DataResponse( |
|
334 | - array( |
|
335 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
336 | - ), |
|
337 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
338 | - ); |
|
339 | - } |
|
340 | - |
|
341 | - $currentUser = $this->userSession->getUser(); |
|
342 | - |
|
343 | - if (!$this->isAdmin) { |
|
344 | - if (!empty($groups)) { |
|
345 | - foreach ($groups as $key => $group) { |
|
346 | - $groupObject = $this->groupManager->get($group); |
|
347 | - if($groupObject === null) { |
|
348 | - unset($groups[$key]); |
|
349 | - continue; |
|
350 | - } |
|
351 | - |
|
352 | - if (!$this->groupManager->getSubAdmin()->isSubAdminofGroup($currentUser, $groupObject)) { |
|
353 | - unset($groups[$key]); |
|
354 | - } |
|
355 | - } |
|
356 | - } |
|
357 | - |
|
358 | - if (empty($groups)) { |
|
359 | - return new DataResponse( |
|
360 | - array( |
|
361 | - 'message' => $this->l10n->t('No valid group selected'), |
|
362 | - ), |
|
363 | - Http::STATUS_FORBIDDEN |
|
364 | - ); |
|
365 | - } |
|
366 | - } |
|
367 | - |
|
368 | - if ($this->userManager->userExists($username)) { |
|
369 | - return new DataResponse( |
|
370 | - array( |
|
371 | - 'message' => (string)$this->l10n->t('A user with that name already exists.') |
|
372 | - ), |
|
373 | - Http::STATUS_CONFLICT |
|
374 | - ); |
|
375 | - } |
|
376 | - |
|
377 | - $generatePasswordResetToken = false; |
|
378 | - if ($password === '') { |
|
379 | - if ($email === '') { |
|
380 | - return new DataResponse( |
|
381 | - array( |
|
382 | - 'message' => (string)$this->l10n->t('To send a password link to the user an email address is required.') |
|
383 | - ), |
|
384 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
385 | - ); |
|
386 | - } |
|
387 | - |
|
388 | - $password = $this->secureRandom->generate(32); |
|
389 | - $generatePasswordResetToken = true; |
|
390 | - } |
|
391 | - |
|
392 | - try { |
|
393 | - $user = $this->userManager->createUser($username, $password); |
|
394 | - } catch (\Exception $exception) { |
|
395 | - $message = $exception->getMessage(); |
|
396 | - if (!$message) { |
|
397 | - $message = $this->l10n->t('Unable to create user.'); |
|
398 | - } |
|
399 | - return new DataResponse( |
|
400 | - array( |
|
401 | - 'message' => (string) $message, |
|
402 | - ), |
|
403 | - Http::STATUS_FORBIDDEN |
|
404 | - ); |
|
405 | - } |
|
406 | - |
|
407 | - if($user instanceof IUser) { |
|
408 | - if($groups !== null) { |
|
409 | - foreach($groups as $groupName) { |
|
410 | - $group = $this->groupManager->get($groupName); |
|
411 | - |
|
412 | - if(empty($group)) { |
|
413 | - $group = $this->groupManager->createGroup($groupName); |
|
414 | - } |
|
415 | - $group->addUser($user); |
|
416 | - } |
|
417 | - } |
|
418 | - /** |
|
419 | - * Send new user mail only if a mail is set |
|
420 | - */ |
|
421 | - if($email !== '') { |
|
422 | - $user->setEMailAddress($email); |
|
423 | - try { |
|
424 | - $emailTemplate = $this->newUserMailHelper->generateTemplate($user, $generatePasswordResetToken); |
|
425 | - $this->newUserMailHelper->sendMail($user, $emailTemplate); |
|
426 | - } catch(\Exception $e) { |
|
427 | - $this->log->error("Can't send new user mail to $email: " . $e->getMessage(), array('app' => 'settings')); |
|
428 | - } |
|
429 | - } |
|
430 | - // fetch users groups |
|
431 | - $userGroups = $this->groupManager->getUserGroupIds($user); |
|
432 | - |
|
433 | - return new DataResponse( |
|
434 | - $this->formatUserForIndex($user, $userGroups), |
|
435 | - Http::STATUS_CREATED |
|
436 | - ); |
|
437 | - } |
|
438 | - |
|
439 | - return new DataResponse( |
|
440 | - array( |
|
441 | - 'message' => (string)$this->l10n->t('Unable to create user.') |
|
442 | - ), |
|
443 | - Http::STATUS_FORBIDDEN |
|
444 | - ); |
|
445 | - |
|
446 | - } |
|
447 | - |
|
448 | - /** |
|
449 | - * @NoAdminRequired |
|
450 | - * @PasswordConfirmationRequired |
|
451 | - * |
|
452 | - * @param string $id |
|
453 | - * @return DataResponse |
|
454 | - */ |
|
455 | - public function destroy($id) { |
|
456 | - $userId = $this->userSession->getUser()->getUID(); |
|
457 | - $user = $this->userManager->get($id); |
|
458 | - |
|
459 | - if($userId === $id) { |
|
460 | - return new DataResponse( |
|
461 | - array( |
|
462 | - 'status' => 'error', |
|
463 | - 'data' => array( |
|
464 | - 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
465 | - ) |
|
466 | - ), |
|
467 | - Http::STATUS_FORBIDDEN |
|
468 | - ); |
|
469 | - } |
|
470 | - |
|
471 | - if(!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) { |
|
472 | - return new DataResponse( |
|
473 | - array( |
|
474 | - 'status' => 'error', |
|
475 | - 'data' => array( |
|
476 | - 'message' => (string)$this->l10n->t('Authentication error') |
|
477 | - ) |
|
478 | - ), |
|
479 | - Http::STATUS_FORBIDDEN |
|
480 | - ); |
|
481 | - } |
|
482 | - |
|
483 | - if($user) { |
|
484 | - if($user->delete()) { |
|
485 | - return new DataResponse( |
|
486 | - array( |
|
487 | - 'status' => 'success', |
|
488 | - 'data' => array( |
|
489 | - 'username' => $id |
|
490 | - ) |
|
491 | - ), |
|
492 | - Http::STATUS_NO_CONTENT |
|
493 | - ); |
|
494 | - } |
|
495 | - } |
|
496 | - |
|
497 | - return new DataResponse( |
|
498 | - array( |
|
499 | - 'status' => 'error', |
|
500 | - 'data' => array( |
|
501 | - 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
502 | - ) |
|
503 | - ), |
|
504 | - Http::STATUS_FORBIDDEN |
|
505 | - ); |
|
506 | - } |
|
507 | - |
|
508 | - /** |
|
509 | - * @NoAdminRequired |
|
510 | - * @NoSubadminRequired |
|
511 | - * @PasswordConfirmationRequired |
|
512 | - * |
|
513 | - * @param string $account |
|
514 | - * @return DataResponse |
|
515 | - */ |
|
516 | - public function getVerificationCode($account) { |
|
517 | - |
|
518 | - $user = $this->userSession->getUser(); |
|
519 | - |
|
520 | - if ($user === null) { |
|
521 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
522 | - } |
|
523 | - |
|
524 | - $accountData = $this->accountManager->getUser($user); |
|
525 | - $cloudId = $user->getCloudId(); |
|
526 | - $message = "Use my Federated Cloud ID to share with me: " . $cloudId; |
|
527 | - $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
|
528 | - openssl_sign(json_encode($message), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
|
529 | - $signatureBase64 = base64_encode($signature); |
|
530 | - |
|
531 | - $code = $message . ' ' . $signatureBase64; |
|
532 | - $codeMd5 = $message . ' ' . md5($signatureBase64); |
|
533 | - |
|
534 | - switch ($account) { |
|
535 | - case 'verify-twitter': |
|
536 | - $accountData[AccountManager::PROPERTY_TWITTER]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; |
|
537 | - $msg = $this->l10n->t('In order to verify your Twitter account post following tweet on Twitter:'); |
|
538 | - $code = $codeMd5; |
|
539 | - break; |
|
540 | - case 'verify-website': |
|
541 | - $accountData[AccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; |
|
542 | - $msg = $this->l10n->t('In order to verify your Website store following content in your webroot at \'CloudIdVerificationCode.txt\':'); |
|
543 | - break; |
|
544 | - default: |
|
545 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
546 | - } |
|
547 | - |
|
548 | - $this->accountManager->updateUser($user, $accountData); |
|
549 | - |
|
550 | - return new DataResponse(['msg' => $msg, 'code' => $code]); |
|
551 | - } |
|
552 | - |
|
553 | - /** |
|
554 | - * @NoAdminRequired |
|
555 | - * @NoSubadminRequired |
|
556 | - * @PasswordConfirmationRequired |
|
557 | - * |
|
558 | - * @param string $avatarScope |
|
559 | - * @param string $displayname |
|
560 | - * @param string $displaynameScope |
|
561 | - * @param string $phone |
|
562 | - * @param string $phoneScope |
|
563 | - * @param string $email |
|
564 | - * @param string $emailScope |
|
565 | - * @param string $website |
|
566 | - * @param string $websiteScope |
|
567 | - * @param string $address |
|
568 | - * @param string $addressScope |
|
569 | - * @param string $twitter |
|
570 | - * @param string $twitterScope |
|
571 | - * @return DataResponse |
|
572 | - */ |
|
573 | - public function setUserSettings($avatarScope, |
|
574 | - $displayname, |
|
575 | - $displaynameScope, |
|
576 | - $phone, |
|
577 | - $phoneScope, |
|
578 | - $email, |
|
579 | - $emailScope, |
|
580 | - $website, |
|
581 | - $websiteScope, |
|
582 | - $address, |
|
583 | - $addressScope, |
|
584 | - $twitter, |
|
585 | - $twitterScope |
|
586 | - ) { |
|
587 | - |
|
588 | - if(!empty($email) && !$this->mailer->validateMailAddress($email)) { |
|
589 | - return new DataResponse( |
|
590 | - array( |
|
591 | - 'status' => 'error', |
|
592 | - 'data' => array( |
|
593 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
594 | - ) |
|
595 | - ), |
|
596 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
597 | - ); |
|
598 | - } |
|
599 | - |
|
600 | - $data = [ |
|
601 | - AccountManager::PROPERTY_AVATAR => ['scope' => $avatarScope], |
|
602 | - AccountManager::PROPERTY_DISPLAYNAME => ['value' => $displayname, 'scope' => $displaynameScope], |
|
603 | - AccountManager::PROPERTY_EMAIL=> ['value' => $email, 'scope' => $emailScope], |
|
604 | - AccountManager::PROPERTY_WEBSITE => ['value' => $website, 'scope' => $websiteScope], |
|
605 | - AccountManager::PROPERTY_ADDRESS => ['value' => $address, 'scope' => $addressScope], |
|
606 | - AccountManager::PROPERTY_PHONE => ['value' => $phone, 'scope' => $phoneScope], |
|
607 | - AccountManager::PROPERTY_TWITTER => ['value' => $twitter, 'scope' => $twitterScope] |
|
608 | - ]; |
|
609 | - |
|
610 | - $user = $this->userSession->getUser(); |
|
611 | - |
|
612 | - try { |
|
613 | - $this->saveUserSettings($user, $data); |
|
614 | - return new DataResponse( |
|
615 | - array( |
|
616 | - 'status' => 'success', |
|
617 | - 'data' => array( |
|
618 | - 'userId' => $user->getUID(), |
|
619 | - 'avatarScope' => $avatarScope, |
|
620 | - 'displayname' => $displayname, |
|
621 | - 'displaynameScope' => $displaynameScope, |
|
622 | - 'email' => $email, |
|
623 | - 'emailScope' => $emailScope, |
|
624 | - 'website' => $website, |
|
625 | - 'websiteScope' => $websiteScope, |
|
626 | - 'address' => $address, |
|
627 | - 'addressScope' => $addressScope, |
|
628 | - 'message' => (string)$this->l10n->t('Settings saved') |
|
629 | - ) |
|
630 | - ), |
|
631 | - Http::STATUS_OK |
|
632 | - ); |
|
633 | - } catch (ForbiddenException $e) { |
|
634 | - return new DataResponse([ |
|
635 | - 'status' => 'error', |
|
636 | - 'data' => [ |
|
637 | - 'message' => $e->getMessage() |
|
638 | - ], |
|
639 | - ]); |
|
640 | - } |
|
641 | - |
|
642 | - } |
|
643 | - |
|
644 | - |
|
645 | - /** |
|
646 | - * update account manager with new user data |
|
647 | - * |
|
648 | - * @param IUser $user |
|
649 | - * @param array $data |
|
650 | - * @throws ForbiddenException |
|
651 | - */ |
|
652 | - protected function saveUserSettings(IUser $user, $data) { |
|
653 | - |
|
654 | - // keep the user back-end up-to-date with the latest display name and email |
|
655 | - // address |
|
656 | - $oldDisplayName = $user->getDisplayName(); |
|
657 | - $oldDisplayName = is_null($oldDisplayName) ? '' : $oldDisplayName; |
|
658 | - if (isset($data[AccountManager::PROPERTY_DISPLAYNAME]['value']) |
|
659 | - && $oldDisplayName !== $data[AccountManager::PROPERTY_DISPLAYNAME]['value'] |
|
660 | - ) { |
|
661 | - $result = $user->setDisplayName($data[AccountManager::PROPERTY_DISPLAYNAME]['value']); |
|
662 | - if ($result === false) { |
|
663 | - throw new ForbiddenException($this->l10n->t('Unable to change full name')); |
|
664 | - } |
|
665 | - } |
|
666 | - |
|
667 | - $oldEmailAddress = $user->getEMailAddress(); |
|
668 | - $oldEmailAddress = is_null($oldEmailAddress) ? '' : $oldEmailAddress; |
|
669 | - if (isset($data[AccountManager::PROPERTY_EMAIL]['value']) |
|
670 | - && $oldEmailAddress !== $data[AccountManager::PROPERTY_EMAIL]['value'] |
|
671 | - ) { |
|
672 | - // this is the only permission a backend provides and is also used |
|
673 | - // for the permission of setting a email address |
|
674 | - if (!$user->canChangeDisplayName()) { |
|
675 | - throw new ForbiddenException($this->l10n->t('Unable to change email address')); |
|
676 | - } |
|
677 | - $user->setEMailAddress($data[AccountManager::PROPERTY_EMAIL]['value']); |
|
678 | - } |
|
679 | - |
|
680 | - $this->accountManager->updateUser($user, $data); |
|
681 | - } |
|
682 | - |
|
683 | - /** |
|
684 | - * Count all unique users visible for the current admin/subadmin. |
|
685 | - * |
|
686 | - * @NoAdminRequired |
|
687 | - * |
|
688 | - * @return DataResponse |
|
689 | - */ |
|
690 | - public function stats() { |
|
691 | - $userCount = 0; |
|
692 | - if ($this->isAdmin) { |
|
693 | - $countByBackend = $this->userManager->countUsers(); |
|
694 | - |
|
695 | - if (!empty($countByBackend)) { |
|
696 | - foreach ($countByBackend as $count) { |
|
697 | - $userCount += $count; |
|
698 | - } |
|
699 | - } |
|
700 | - } else { |
|
701 | - $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser()); |
|
702 | - |
|
703 | - $uniqueUsers = []; |
|
704 | - foreach ($groups as $group) { |
|
705 | - foreach($group->getUsers() as $uid => $displayName) { |
|
706 | - $uniqueUsers[$uid] = true; |
|
707 | - } |
|
708 | - } |
|
709 | - |
|
710 | - $userCount = count($uniqueUsers); |
|
711 | - } |
|
712 | - |
|
713 | - return new DataResponse( |
|
714 | - [ |
|
715 | - 'totalUsers' => $userCount |
|
716 | - ] |
|
717 | - ); |
|
718 | - } |
|
719 | - |
|
720 | - |
|
721 | - /** |
|
722 | - * Set the displayName of a user |
|
723 | - * |
|
724 | - * @NoAdminRequired |
|
725 | - * @NoSubadminRequired |
|
726 | - * @PasswordConfirmationRequired |
|
727 | - * @todo merge into saveUserSettings |
|
728 | - * |
|
729 | - * @param string $username |
|
730 | - * @param string $displayName |
|
731 | - * @return DataResponse |
|
732 | - */ |
|
733 | - public function setDisplayName($username, $displayName) { |
|
734 | - $currentUser = $this->userSession->getUser(); |
|
735 | - $user = $this->userManager->get($username); |
|
736 | - |
|
737 | - if ($user === null || |
|
738 | - !$user->canChangeDisplayName() || |
|
739 | - ( |
|
740 | - !$this->groupManager->isAdmin($currentUser->getUID()) && |
|
741 | - !$this->groupManager->getSubAdmin()->isUserAccessible($currentUser, $user) && |
|
742 | - $currentUser->getUID() !== $username |
|
743 | - |
|
744 | - ) |
|
745 | - ) { |
|
746 | - return new DataResponse([ |
|
747 | - 'status' => 'error', |
|
748 | - 'data' => [ |
|
749 | - 'message' => $this->l10n->t('Authentication error'), |
|
750 | - ], |
|
751 | - ]); |
|
752 | - } |
|
753 | - |
|
754 | - $userData = $this->accountManager->getUser($user); |
|
755 | - $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'] = $displayName; |
|
756 | - |
|
757 | - |
|
758 | - try { |
|
759 | - $this->saveUserSettings($user, $userData); |
|
760 | - return new DataResponse([ |
|
761 | - 'status' => 'success', |
|
762 | - 'data' => [ |
|
763 | - 'message' => $this->l10n->t('Your full name has been changed.'), |
|
764 | - 'username' => $username, |
|
765 | - 'displayName' => $displayName, |
|
766 | - ], |
|
767 | - ]); |
|
768 | - } catch (ForbiddenException $e) { |
|
769 | - return new DataResponse([ |
|
770 | - 'status' => 'error', |
|
771 | - 'data' => [ |
|
772 | - 'message' => $e->getMessage(), |
|
773 | - 'displayName' => $user->getDisplayName(), |
|
774 | - ], |
|
775 | - ]); |
|
776 | - } |
|
777 | - } |
|
778 | - |
|
779 | - /** |
|
780 | - * Set the mail address of a user |
|
781 | - * |
|
782 | - * @NoAdminRequired |
|
783 | - * @NoSubadminRequired |
|
784 | - * @PasswordConfirmationRequired |
|
785 | - * |
|
786 | - * @param string $id |
|
787 | - * @param string $mailAddress |
|
788 | - * @return DataResponse |
|
789 | - */ |
|
790 | - public function setEMailAddress($id, $mailAddress) { |
|
791 | - $user = $this->userManager->get($id); |
|
792 | - if (!$this->isAdmin |
|
793 | - && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user) |
|
794 | - ) { |
|
795 | - return new DataResponse( |
|
796 | - array( |
|
797 | - 'status' => 'error', |
|
798 | - 'data' => array( |
|
799 | - 'message' => (string)$this->l10n->t('Forbidden') |
|
800 | - ) |
|
801 | - ), |
|
802 | - Http::STATUS_FORBIDDEN |
|
803 | - ); |
|
804 | - } |
|
805 | - |
|
806 | - if($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) { |
|
807 | - return new DataResponse( |
|
808 | - array( |
|
809 | - 'status' => 'error', |
|
810 | - 'data' => array( |
|
811 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
812 | - ) |
|
813 | - ), |
|
814 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
815 | - ); |
|
816 | - } |
|
817 | - |
|
818 | - if (!$user) { |
|
819 | - return new DataResponse( |
|
820 | - array( |
|
821 | - 'status' => 'error', |
|
822 | - 'data' => array( |
|
823 | - 'message' => (string)$this->l10n->t('Invalid user') |
|
824 | - ) |
|
825 | - ), |
|
826 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
827 | - ); |
|
828 | - } |
|
829 | - // this is the only permission a backend provides and is also used |
|
830 | - // for the permission of setting a email address |
|
831 | - if (!$user->canChangeDisplayName()) { |
|
832 | - return new DataResponse( |
|
833 | - array( |
|
834 | - 'status' => 'error', |
|
835 | - 'data' => array( |
|
836 | - 'message' => (string)$this->l10n->t('Unable to change mail address') |
|
837 | - ) |
|
838 | - ), |
|
839 | - Http::STATUS_FORBIDDEN |
|
840 | - ); |
|
841 | - } |
|
842 | - |
|
843 | - $userData = $this->accountManager->getUser($user); |
|
844 | - $userData[AccountManager::PROPERTY_EMAIL]['value'] = $mailAddress; |
|
845 | - |
|
846 | - try { |
|
847 | - $this->saveUserSettings($user, $userData); |
|
848 | - return new DataResponse( |
|
849 | - array( |
|
850 | - 'status' => 'success', |
|
851 | - 'data' => array( |
|
852 | - 'username' => $id, |
|
853 | - 'mailAddress' => $mailAddress, |
|
854 | - 'message' => (string)$this->l10n->t('Email saved') |
|
855 | - ) |
|
856 | - ), |
|
857 | - Http::STATUS_OK |
|
858 | - ); |
|
859 | - } catch (ForbiddenException $e) { |
|
860 | - return new DataResponse([ |
|
861 | - 'status' => 'error', |
|
862 | - 'data' => [ |
|
863 | - 'message' => $e->getMessage() |
|
864 | - ], |
|
865 | - ]); |
|
866 | - } |
|
867 | - } |
|
58 | + /** @var IL10N */ |
|
59 | + private $l10n; |
|
60 | + /** @var IUserSession */ |
|
61 | + private $userSession; |
|
62 | + /** @var bool */ |
|
63 | + private $isAdmin; |
|
64 | + /** @var IUserManager */ |
|
65 | + private $userManager; |
|
66 | + /** @var IGroupManager */ |
|
67 | + private $groupManager; |
|
68 | + /** @var IConfig */ |
|
69 | + private $config; |
|
70 | + /** @var ILogger */ |
|
71 | + private $log; |
|
72 | + /** @var IMailer */ |
|
73 | + private $mailer; |
|
74 | + /** @var bool contains the state of the encryption app */ |
|
75 | + private $isEncryptionAppEnabled; |
|
76 | + /** @var bool contains the state of the admin recovery setting */ |
|
77 | + private $isRestoreEnabled = false; |
|
78 | + /** @var IAvatarManager */ |
|
79 | + private $avatarManager; |
|
80 | + /** @var AccountManager */ |
|
81 | + private $accountManager; |
|
82 | + /** @var ISecureRandom */ |
|
83 | + private $secureRandom; |
|
84 | + /** @var NewUserMailHelper */ |
|
85 | + private $newUserMailHelper; |
|
86 | + /** @var ITimeFactory */ |
|
87 | + private $timeFactory; |
|
88 | + /** @var ICrypto */ |
|
89 | + private $crypto; |
|
90 | + /** @var Manager */ |
|
91 | + private $keyManager; |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * @param string $appName |
|
96 | + * @param IRequest $request |
|
97 | + * @param IUserManager $userManager |
|
98 | + * @param IGroupManager $groupManager |
|
99 | + * @param IUserSession $userSession |
|
100 | + * @param IConfig $config |
|
101 | + * @param bool $isAdmin |
|
102 | + * @param IL10N $l10n |
|
103 | + * @param ILogger $log |
|
104 | + * @param IMailer $mailer |
|
105 | + * @param IURLGenerator $urlGenerator |
|
106 | + * @param IAppManager $appManager |
|
107 | + * @param IAvatarManager $avatarManager |
|
108 | + * @param AccountManager $accountManager |
|
109 | + * @param ISecureRandom $secureRandom |
|
110 | + * @param NewUserMailHelper $newUserMailHelper |
|
111 | + * @param ITimeFactory $timeFactory |
|
112 | + * @param ICrypto $crypto |
|
113 | + * @param Manager $keyManager |
|
114 | + */ |
|
115 | + public function __construct($appName, |
|
116 | + IRequest $request, |
|
117 | + IUserManager $userManager, |
|
118 | + IGroupManager $groupManager, |
|
119 | + IUserSession $userSession, |
|
120 | + IConfig $config, |
|
121 | + $isAdmin, |
|
122 | + IL10N $l10n, |
|
123 | + ILogger $log, |
|
124 | + IMailer $mailer, |
|
125 | + IURLGenerator $urlGenerator, |
|
126 | + IAppManager $appManager, |
|
127 | + IAvatarManager $avatarManager, |
|
128 | + AccountManager $accountManager, |
|
129 | + ISecureRandom $secureRandom, |
|
130 | + NewUserMailHelper $newUserMailHelper, |
|
131 | + ITimeFactory $timeFactory, |
|
132 | + ICrypto $crypto, |
|
133 | + Manager $keyManager) { |
|
134 | + parent::__construct($appName, $request); |
|
135 | + $this->userManager = $userManager; |
|
136 | + $this->groupManager = $groupManager; |
|
137 | + $this->userSession = $userSession; |
|
138 | + $this->config = $config; |
|
139 | + $this->isAdmin = $isAdmin; |
|
140 | + $this->l10n = $l10n; |
|
141 | + $this->log = $log; |
|
142 | + $this->mailer = $mailer; |
|
143 | + $this->avatarManager = $avatarManager; |
|
144 | + $this->accountManager = $accountManager; |
|
145 | + $this->secureRandom = $secureRandom; |
|
146 | + $this->newUserMailHelper = $newUserMailHelper; |
|
147 | + $this->timeFactory = $timeFactory; |
|
148 | + $this->crypto = $crypto; |
|
149 | + $this->keyManager = $keyManager; |
|
150 | + |
|
151 | + // check for encryption state - TODO see formatUserForIndex |
|
152 | + $this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption'); |
|
153 | + if($this->isEncryptionAppEnabled) { |
|
154 | + // putting this directly in empty is possible in PHP 5.5+ |
|
155 | + $result = $config->getAppValue('encryption', 'recoveryAdminEnabled', 0); |
|
156 | + $this->isRestoreEnabled = !empty($result); |
|
157 | + } |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * @param IUser $user |
|
162 | + * @param array $userGroups |
|
163 | + * @return array |
|
164 | + */ |
|
165 | + private function formatUserForIndex(IUser $user, array $userGroups = null) { |
|
166 | + |
|
167 | + // TODO: eliminate this encryption specific code below and somehow |
|
168 | + // hook in additional user info from other apps |
|
169 | + |
|
170 | + // recovery isn't possible if admin or user has it disabled and encryption |
|
171 | + // is enabled - so we eliminate the else paths in the conditional tree |
|
172 | + // below |
|
173 | + $restorePossible = false; |
|
174 | + |
|
175 | + if ($this->isEncryptionAppEnabled) { |
|
176 | + if ($this->isRestoreEnabled) { |
|
177 | + // check for the users recovery setting |
|
178 | + $recoveryMode = $this->config->getUserValue($user->getUID(), 'encryption', 'recoveryEnabled', '0'); |
|
179 | + // method call inside empty is possible with PHP 5.5+ |
|
180 | + $recoveryModeEnabled = !empty($recoveryMode); |
|
181 | + if ($recoveryModeEnabled) { |
|
182 | + // user also has recovery mode enabled |
|
183 | + $restorePossible = true; |
|
184 | + } |
|
185 | + } |
|
186 | + } else { |
|
187 | + // recovery is possible if encryption is disabled (plain files are |
|
188 | + // available) |
|
189 | + $restorePossible = true; |
|
190 | + } |
|
191 | + |
|
192 | + $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user); |
|
193 | + foreach($subAdminGroups as $key => $subAdminGroup) { |
|
194 | + $subAdminGroups[$key] = $subAdminGroup->getGID(); |
|
195 | + } |
|
196 | + |
|
197 | + $displayName = $user->getEMailAddress(); |
|
198 | + if (is_null($displayName)) { |
|
199 | + $displayName = ''; |
|
200 | + } |
|
201 | + |
|
202 | + $avatarAvailable = false; |
|
203 | + try { |
|
204 | + $avatarAvailable = $this->avatarManager->getAvatar($user->getUID())->exists(); |
|
205 | + } catch (\Exception $e) { |
|
206 | + //No avatar yet |
|
207 | + } |
|
208 | + |
|
209 | + return [ |
|
210 | + 'name' => $user->getUID(), |
|
211 | + 'displayname' => $user->getDisplayName(), |
|
212 | + 'groups' => (empty($userGroups)) ? $this->groupManager->getUserGroupIds($user) : $userGroups, |
|
213 | + 'subadmin' => $subAdminGroups, |
|
214 | + 'quota' => $user->getQuota(), |
|
215 | + 'storageLocation' => $user->getHome(), |
|
216 | + 'lastLogin' => $user->getLastLogin() * 1000, |
|
217 | + 'backend' => $user->getBackendClassName(), |
|
218 | + 'email' => $displayName, |
|
219 | + 'isRestoreDisabled' => !$restorePossible, |
|
220 | + 'isAvatarAvailable' => $avatarAvailable, |
|
221 | + ]; |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * @param array $userIDs Array with schema [$uid => $displayName] |
|
226 | + * @return IUser[] |
|
227 | + */ |
|
228 | + private function getUsersForUID(array $userIDs) { |
|
229 | + $users = []; |
|
230 | + foreach ($userIDs as $uid => $displayName) { |
|
231 | + $users[$uid] = $this->userManager->get($uid); |
|
232 | + } |
|
233 | + return $users; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * @NoAdminRequired |
|
238 | + * |
|
239 | + * @param int $offset |
|
240 | + * @param int $limit |
|
241 | + * @param string $gid GID to filter for |
|
242 | + * @param string $pattern Pattern to search for in the username |
|
243 | + * @param string $backend Backend to filter for (class-name) |
|
244 | + * @return DataResponse |
|
245 | + * |
|
246 | + * TODO: Tidy up and write unit tests - code is mainly static method calls |
|
247 | + */ |
|
248 | + public function index($offset = 0, $limit = 10, $gid = '', $pattern = '', $backend = '') { |
|
249 | + // FIXME: The JS sends the group '_everyone' instead of no GID for the "all users" group. |
|
250 | + if($gid === '_everyone') { |
|
251 | + $gid = ''; |
|
252 | + } |
|
253 | + |
|
254 | + // Remove backends |
|
255 | + if(!empty($backend)) { |
|
256 | + $activeBackends = $this->userManager->getBackends(); |
|
257 | + $this->userManager->clearBackends(); |
|
258 | + foreach($activeBackends as $singleActiveBackend) { |
|
259 | + if($backend === get_class($singleActiveBackend)) { |
|
260 | + $this->userManager->registerBackend($singleActiveBackend); |
|
261 | + break; |
|
262 | + } |
|
263 | + } |
|
264 | + } |
|
265 | + |
|
266 | + $users = []; |
|
267 | + if ($this->isAdmin) { |
|
268 | + |
|
269 | + if($gid !== '') { |
|
270 | + $batch = $this->getUsersForUID($this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset)); |
|
271 | + } else { |
|
272 | + $batch = $this->userManager->search($pattern, $limit, $offset); |
|
273 | + } |
|
274 | + |
|
275 | + foreach ($batch as $user) { |
|
276 | + $users[] = $this->formatUserForIndex($user); |
|
277 | + } |
|
278 | + |
|
279 | + } else { |
|
280 | + $subAdminOfGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser()); |
|
281 | + // New class returns IGroup[] so convert back |
|
282 | + $gids = []; |
|
283 | + foreach ($subAdminOfGroups as $group) { |
|
284 | + $gids[] = $group->getGID(); |
|
285 | + } |
|
286 | + $subAdminOfGroups = $gids; |
|
287 | + |
|
288 | + // Set the $gid parameter to an empty value if the subadmin has no rights to access a specific group |
|
289 | + if($gid !== '' && !in_array($gid, $subAdminOfGroups)) { |
|
290 | + $gid = ''; |
|
291 | + } |
|
292 | + |
|
293 | + // Batch all groups the user is subadmin of when a group is specified |
|
294 | + $batch = []; |
|
295 | + if($gid === '') { |
|
296 | + foreach($subAdminOfGroups as $group) { |
|
297 | + $groupUsers = $this->groupManager->displayNamesInGroup($group, $pattern, $limit, $offset); |
|
298 | + |
|
299 | + foreach($groupUsers as $uid => $displayName) { |
|
300 | + $batch[$uid] = $displayName; |
|
301 | + } |
|
302 | + } |
|
303 | + } else { |
|
304 | + $batch = $this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset); |
|
305 | + } |
|
306 | + $batch = $this->getUsersForUID($batch); |
|
307 | + |
|
308 | + foreach ($batch as $user) { |
|
309 | + // Only add the groups, this user is a subadmin of |
|
310 | + $userGroups = array_values(array_intersect( |
|
311 | + $this->groupManager->getUserGroupIds($user), |
|
312 | + $subAdminOfGroups |
|
313 | + )); |
|
314 | + $users[] = $this->formatUserForIndex($user, $userGroups); |
|
315 | + } |
|
316 | + } |
|
317 | + |
|
318 | + return new DataResponse($users); |
|
319 | + } |
|
320 | + |
|
321 | + /** |
|
322 | + * @NoAdminRequired |
|
323 | + * @PasswordConfirmationRequired |
|
324 | + * |
|
325 | + * @param string $username |
|
326 | + * @param string $password |
|
327 | + * @param array $groups |
|
328 | + * @param string $email |
|
329 | + * @return DataResponse |
|
330 | + */ |
|
331 | + public function create($username, $password, array $groups=array(), $email='') { |
|
332 | + if($email !== '' && !$this->mailer->validateMailAddress($email)) { |
|
333 | + return new DataResponse( |
|
334 | + array( |
|
335 | + 'message' => (string)$this->l10n->t('Invalid mail address') |
|
336 | + ), |
|
337 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
338 | + ); |
|
339 | + } |
|
340 | + |
|
341 | + $currentUser = $this->userSession->getUser(); |
|
342 | + |
|
343 | + if (!$this->isAdmin) { |
|
344 | + if (!empty($groups)) { |
|
345 | + foreach ($groups as $key => $group) { |
|
346 | + $groupObject = $this->groupManager->get($group); |
|
347 | + if($groupObject === null) { |
|
348 | + unset($groups[$key]); |
|
349 | + continue; |
|
350 | + } |
|
351 | + |
|
352 | + if (!$this->groupManager->getSubAdmin()->isSubAdminofGroup($currentUser, $groupObject)) { |
|
353 | + unset($groups[$key]); |
|
354 | + } |
|
355 | + } |
|
356 | + } |
|
357 | + |
|
358 | + if (empty($groups)) { |
|
359 | + return new DataResponse( |
|
360 | + array( |
|
361 | + 'message' => $this->l10n->t('No valid group selected'), |
|
362 | + ), |
|
363 | + Http::STATUS_FORBIDDEN |
|
364 | + ); |
|
365 | + } |
|
366 | + } |
|
367 | + |
|
368 | + if ($this->userManager->userExists($username)) { |
|
369 | + return new DataResponse( |
|
370 | + array( |
|
371 | + 'message' => (string)$this->l10n->t('A user with that name already exists.') |
|
372 | + ), |
|
373 | + Http::STATUS_CONFLICT |
|
374 | + ); |
|
375 | + } |
|
376 | + |
|
377 | + $generatePasswordResetToken = false; |
|
378 | + if ($password === '') { |
|
379 | + if ($email === '') { |
|
380 | + return new DataResponse( |
|
381 | + array( |
|
382 | + 'message' => (string)$this->l10n->t('To send a password link to the user an email address is required.') |
|
383 | + ), |
|
384 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
385 | + ); |
|
386 | + } |
|
387 | + |
|
388 | + $password = $this->secureRandom->generate(32); |
|
389 | + $generatePasswordResetToken = true; |
|
390 | + } |
|
391 | + |
|
392 | + try { |
|
393 | + $user = $this->userManager->createUser($username, $password); |
|
394 | + } catch (\Exception $exception) { |
|
395 | + $message = $exception->getMessage(); |
|
396 | + if (!$message) { |
|
397 | + $message = $this->l10n->t('Unable to create user.'); |
|
398 | + } |
|
399 | + return new DataResponse( |
|
400 | + array( |
|
401 | + 'message' => (string) $message, |
|
402 | + ), |
|
403 | + Http::STATUS_FORBIDDEN |
|
404 | + ); |
|
405 | + } |
|
406 | + |
|
407 | + if($user instanceof IUser) { |
|
408 | + if($groups !== null) { |
|
409 | + foreach($groups as $groupName) { |
|
410 | + $group = $this->groupManager->get($groupName); |
|
411 | + |
|
412 | + if(empty($group)) { |
|
413 | + $group = $this->groupManager->createGroup($groupName); |
|
414 | + } |
|
415 | + $group->addUser($user); |
|
416 | + } |
|
417 | + } |
|
418 | + /** |
|
419 | + * Send new user mail only if a mail is set |
|
420 | + */ |
|
421 | + if($email !== '') { |
|
422 | + $user->setEMailAddress($email); |
|
423 | + try { |
|
424 | + $emailTemplate = $this->newUserMailHelper->generateTemplate($user, $generatePasswordResetToken); |
|
425 | + $this->newUserMailHelper->sendMail($user, $emailTemplate); |
|
426 | + } catch(\Exception $e) { |
|
427 | + $this->log->error("Can't send new user mail to $email: " . $e->getMessage(), array('app' => 'settings')); |
|
428 | + } |
|
429 | + } |
|
430 | + // fetch users groups |
|
431 | + $userGroups = $this->groupManager->getUserGroupIds($user); |
|
432 | + |
|
433 | + return new DataResponse( |
|
434 | + $this->formatUserForIndex($user, $userGroups), |
|
435 | + Http::STATUS_CREATED |
|
436 | + ); |
|
437 | + } |
|
438 | + |
|
439 | + return new DataResponse( |
|
440 | + array( |
|
441 | + 'message' => (string)$this->l10n->t('Unable to create user.') |
|
442 | + ), |
|
443 | + Http::STATUS_FORBIDDEN |
|
444 | + ); |
|
445 | + |
|
446 | + } |
|
447 | + |
|
448 | + /** |
|
449 | + * @NoAdminRequired |
|
450 | + * @PasswordConfirmationRequired |
|
451 | + * |
|
452 | + * @param string $id |
|
453 | + * @return DataResponse |
|
454 | + */ |
|
455 | + public function destroy($id) { |
|
456 | + $userId = $this->userSession->getUser()->getUID(); |
|
457 | + $user = $this->userManager->get($id); |
|
458 | + |
|
459 | + if($userId === $id) { |
|
460 | + return new DataResponse( |
|
461 | + array( |
|
462 | + 'status' => 'error', |
|
463 | + 'data' => array( |
|
464 | + 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
465 | + ) |
|
466 | + ), |
|
467 | + Http::STATUS_FORBIDDEN |
|
468 | + ); |
|
469 | + } |
|
470 | + |
|
471 | + if(!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) { |
|
472 | + return new DataResponse( |
|
473 | + array( |
|
474 | + 'status' => 'error', |
|
475 | + 'data' => array( |
|
476 | + 'message' => (string)$this->l10n->t('Authentication error') |
|
477 | + ) |
|
478 | + ), |
|
479 | + Http::STATUS_FORBIDDEN |
|
480 | + ); |
|
481 | + } |
|
482 | + |
|
483 | + if($user) { |
|
484 | + if($user->delete()) { |
|
485 | + return new DataResponse( |
|
486 | + array( |
|
487 | + 'status' => 'success', |
|
488 | + 'data' => array( |
|
489 | + 'username' => $id |
|
490 | + ) |
|
491 | + ), |
|
492 | + Http::STATUS_NO_CONTENT |
|
493 | + ); |
|
494 | + } |
|
495 | + } |
|
496 | + |
|
497 | + return new DataResponse( |
|
498 | + array( |
|
499 | + 'status' => 'error', |
|
500 | + 'data' => array( |
|
501 | + 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
502 | + ) |
|
503 | + ), |
|
504 | + Http::STATUS_FORBIDDEN |
|
505 | + ); |
|
506 | + } |
|
507 | + |
|
508 | + /** |
|
509 | + * @NoAdminRequired |
|
510 | + * @NoSubadminRequired |
|
511 | + * @PasswordConfirmationRequired |
|
512 | + * |
|
513 | + * @param string $account |
|
514 | + * @return DataResponse |
|
515 | + */ |
|
516 | + public function getVerificationCode($account) { |
|
517 | + |
|
518 | + $user = $this->userSession->getUser(); |
|
519 | + |
|
520 | + if ($user === null) { |
|
521 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
522 | + } |
|
523 | + |
|
524 | + $accountData = $this->accountManager->getUser($user); |
|
525 | + $cloudId = $user->getCloudId(); |
|
526 | + $message = "Use my Federated Cloud ID to share with me: " . $cloudId; |
|
527 | + $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
|
528 | + openssl_sign(json_encode($message), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
|
529 | + $signatureBase64 = base64_encode($signature); |
|
530 | + |
|
531 | + $code = $message . ' ' . $signatureBase64; |
|
532 | + $codeMd5 = $message . ' ' . md5($signatureBase64); |
|
533 | + |
|
534 | + switch ($account) { |
|
535 | + case 'verify-twitter': |
|
536 | + $accountData[AccountManager::PROPERTY_TWITTER]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; |
|
537 | + $msg = $this->l10n->t('In order to verify your Twitter account post following tweet on Twitter:'); |
|
538 | + $code = $codeMd5; |
|
539 | + break; |
|
540 | + case 'verify-website': |
|
541 | + $accountData[AccountManager::PROPERTY_WEBSITE]['verified'] = AccountManager::VERIFICATION_IN_PROGRESS; |
|
542 | + $msg = $this->l10n->t('In order to verify your Website store following content in your webroot at \'CloudIdVerificationCode.txt\':'); |
|
543 | + break; |
|
544 | + default: |
|
545 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
546 | + } |
|
547 | + |
|
548 | + $this->accountManager->updateUser($user, $accountData); |
|
549 | + |
|
550 | + return new DataResponse(['msg' => $msg, 'code' => $code]); |
|
551 | + } |
|
552 | + |
|
553 | + /** |
|
554 | + * @NoAdminRequired |
|
555 | + * @NoSubadminRequired |
|
556 | + * @PasswordConfirmationRequired |
|
557 | + * |
|
558 | + * @param string $avatarScope |
|
559 | + * @param string $displayname |
|
560 | + * @param string $displaynameScope |
|
561 | + * @param string $phone |
|
562 | + * @param string $phoneScope |
|
563 | + * @param string $email |
|
564 | + * @param string $emailScope |
|
565 | + * @param string $website |
|
566 | + * @param string $websiteScope |
|
567 | + * @param string $address |
|
568 | + * @param string $addressScope |
|
569 | + * @param string $twitter |
|
570 | + * @param string $twitterScope |
|
571 | + * @return DataResponse |
|
572 | + */ |
|
573 | + public function setUserSettings($avatarScope, |
|
574 | + $displayname, |
|
575 | + $displaynameScope, |
|
576 | + $phone, |
|
577 | + $phoneScope, |
|
578 | + $email, |
|
579 | + $emailScope, |
|
580 | + $website, |
|
581 | + $websiteScope, |
|
582 | + $address, |
|
583 | + $addressScope, |
|
584 | + $twitter, |
|
585 | + $twitterScope |
|
586 | + ) { |
|
587 | + |
|
588 | + if(!empty($email) && !$this->mailer->validateMailAddress($email)) { |
|
589 | + return new DataResponse( |
|
590 | + array( |
|
591 | + 'status' => 'error', |
|
592 | + 'data' => array( |
|
593 | + 'message' => (string)$this->l10n->t('Invalid mail address') |
|
594 | + ) |
|
595 | + ), |
|
596 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
597 | + ); |
|
598 | + } |
|
599 | + |
|
600 | + $data = [ |
|
601 | + AccountManager::PROPERTY_AVATAR => ['scope' => $avatarScope], |
|
602 | + AccountManager::PROPERTY_DISPLAYNAME => ['value' => $displayname, 'scope' => $displaynameScope], |
|
603 | + AccountManager::PROPERTY_EMAIL=> ['value' => $email, 'scope' => $emailScope], |
|
604 | + AccountManager::PROPERTY_WEBSITE => ['value' => $website, 'scope' => $websiteScope], |
|
605 | + AccountManager::PROPERTY_ADDRESS => ['value' => $address, 'scope' => $addressScope], |
|
606 | + AccountManager::PROPERTY_PHONE => ['value' => $phone, 'scope' => $phoneScope], |
|
607 | + AccountManager::PROPERTY_TWITTER => ['value' => $twitter, 'scope' => $twitterScope] |
|
608 | + ]; |
|
609 | + |
|
610 | + $user = $this->userSession->getUser(); |
|
611 | + |
|
612 | + try { |
|
613 | + $this->saveUserSettings($user, $data); |
|
614 | + return new DataResponse( |
|
615 | + array( |
|
616 | + 'status' => 'success', |
|
617 | + 'data' => array( |
|
618 | + 'userId' => $user->getUID(), |
|
619 | + 'avatarScope' => $avatarScope, |
|
620 | + 'displayname' => $displayname, |
|
621 | + 'displaynameScope' => $displaynameScope, |
|
622 | + 'email' => $email, |
|
623 | + 'emailScope' => $emailScope, |
|
624 | + 'website' => $website, |
|
625 | + 'websiteScope' => $websiteScope, |
|
626 | + 'address' => $address, |
|
627 | + 'addressScope' => $addressScope, |
|
628 | + 'message' => (string)$this->l10n->t('Settings saved') |
|
629 | + ) |
|
630 | + ), |
|
631 | + Http::STATUS_OK |
|
632 | + ); |
|
633 | + } catch (ForbiddenException $e) { |
|
634 | + return new DataResponse([ |
|
635 | + 'status' => 'error', |
|
636 | + 'data' => [ |
|
637 | + 'message' => $e->getMessage() |
|
638 | + ], |
|
639 | + ]); |
|
640 | + } |
|
641 | + |
|
642 | + } |
|
643 | + |
|
644 | + |
|
645 | + /** |
|
646 | + * update account manager with new user data |
|
647 | + * |
|
648 | + * @param IUser $user |
|
649 | + * @param array $data |
|
650 | + * @throws ForbiddenException |
|
651 | + */ |
|
652 | + protected function saveUserSettings(IUser $user, $data) { |
|
653 | + |
|
654 | + // keep the user back-end up-to-date with the latest display name and email |
|
655 | + // address |
|
656 | + $oldDisplayName = $user->getDisplayName(); |
|
657 | + $oldDisplayName = is_null($oldDisplayName) ? '' : $oldDisplayName; |
|
658 | + if (isset($data[AccountManager::PROPERTY_DISPLAYNAME]['value']) |
|
659 | + && $oldDisplayName !== $data[AccountManager::PROPERTY_DISPLAYNAME]['value'] |
|
660 | + ) { |
|
661 | + $result = $user->setDisplayName($data[AccountManager::PROPERTY_DISPLAYNAME]['value']); |
|
662 | + if ($result === false) { |
|
663 | + throw new ForbiddenException($this->l10n->t('Unable to change full name')); |
|
664 | + } |
|
665 | + } |
|
666 | + |
|
667 | + $oldEmailAddress = $user->getEMailAddress(); |
|
668 | + $oldEmailAddress = is_null($oldEmailAddress) ? '' : $oldEmailAddress; |
|
669 | + if (isset($data[AccountManager::PROPERTY_EMAIL]['value']) |
|
670 | + && $oldEmailAddress !== $data[AccountManager::PROPERTY_EMAIL]['value'] |
|
671 | + ) { |
|
672 | + // this is the only permission a backend provides and is also used |
|
673 | + // for the permission of setting a email address |
|
674 | + if (!$user->canChangeDisplayName()) { |
|
675 | + throw new ForbiddenException($this->l10n->t('Unable to change email address')); |
|
676 | + } |
|
677 | + $user->setEMailAddress($data[AccountManager::PROPERTY_EMAIL]['value']); |
|
678 | + } |
|
679 | + |
|
680 | + $this->accountManager->updateUser($user, $data); |
|
681 | + } |
|
682 | + |
|
683 | + /** |
|
684 | + * Count all unique users visible for the current admin/subadmin. |
|
685 | + * |
|
686 | + * @NoAdminRequired |
|
687 | + * |
|
688 | + * @return DataResponse |
|
689 | + */ |
|
690 | + public function stats() { |
|
691 | + $userCount = 0; |
|
692 | + if ($this->isAdmin) { |
|
693 | + $countByBackend = $this->userManager->countUsers(); |
|
694 | + |
|
695 | + if (!empty($countByBackend)) { |
|
696 | + foreach ($countByBackend as $count) { |
|
697 | + $userCount += $count; |
|
698 | + } |
|
699 | + } |
|
700 | + } else { |
|
701 | + $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser()); |
|
702 | + |
|
703 | + $uniqueUsers = []; |
|
704 | + foreach ($groups as $group) { |
|
705 | + foreach($group->getUsers() as $uid => $displayName) { |
|
706 | + $uniqueUsers[$uid] = true; |
|
707 | + } |
|
708 | + } |
|
709 | + |
|
710 | + $userCount = count($uniqueUsers); |
|
711 | + } |
|
712 | + |
|
713 | + return new DataResponse( |
|
714 | + [ |
|
715 | + 'totalUsers' => $userCount |
|
716 | + ] |
|
717 | + ); |
|
718 | + } |
|
719 | + |
|
720 | + |
|
721 | + /** |
|
722 | + * Set the displayName of a user |
|
723 | + * |
|
724 | + * @NoAdminRequired |
|
725 | + * @NoSubadminRequired |
|
726 | + * @PasswordConfirmationRequired |
|
727 | + * @todo merge into saveUserSettings |
|
728 | + * |
|
729 | + * @param string $username |
|
730 | + * @param string $displayName |
|
731 | + * @return DataResponse |
|
732 | + */ |
|
733 | + public function setDisplayName($username, $displayName) { |
|
734 | + $currentUser = $this->userSession->getUser(); |
|
735 | + $user = $this->userManager->get($username); |
|
736 | + |
|
737 | + if ($user === null || |
|
738 | + !$user->canChangeDisplayName() || |
|
739 | + ( |
|
740 | + !$this->groupManager->isAdmin($currentUser->getUID()) && |
|
741 | + !$this->groupManager->getSubAdmin()->isUserAccessible($currentUser, $user) && |
|
742 | + $currentUser->getUID() !== $username |
|
743 | + |
|
744 | + ) |
|
745 | + ) { |
|
746 | + return new DataResponse([ |
|
747 | + 'status' => 'error', |
|
748 | + 'data' => [ |
|
749 | + 'message' => $this->l10n->t('Authentication error'), |
|
750 | + ], |
|
751 | + ]); |
|
752 | + } |
|
753 | + |
|
754 | + $userData = $this->accountManager->getUser($user); |
|
755 | + $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'] = $displayName; |
|
756 | + |
|
757 | + |
|
758 | + try { |
|
759 | + $this->saveUserSettings($user, $userData); |
|
760 | + return new DataResponse([ |
|
761 | + 'status' => 'success', |
|
762 | + 'data' => [ |
|
763 | + 'message' => $this->l10n->t('Your full name has been changed.'), |
|
764 | + 'username' => $username, |
|
765 | + 'displayName' => $displayName, |
|
766 | + ], |
|
767 | + ]); |
|
768 | + } catch (ForbiddenException $e) { |
|
769 | + return new DataResponse([ |
|
770 | + 'status' => 'error', |
|
771 | + 'data' => [ |
|
772 | + 'message' => $e->getMessage(), |
|
773 | + 'displayName' => $user->getDisplayName(), |
|
774 | + ], |
|
775 | + ]); |
|
776 | + } |
|
777 | + } |
|
778 | + |
|
779 | + /** |
|
780 | + * Set the mail address of a user |
|
781 | + * |
|
782 | + * @NoAdminRequired |
|
783 | + * @NoSubadminRequired |
|
784 | + * @PasswordConfirmationRequired |
|
785 | + * |
|
786 | + * @param string $id |
|
787 | + * @param string $mailAddress |
|
788 | + * @return DataResponse |
|
789 | + */ |
|
790 | + public function setEMailAddress($id, $mailAddress) { |
|
791 | + $user = $this->userManager->get($id); |
|
792 | + if (!$this->isAdmin |
|
793 | + && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user) |
|
794 | + ) { |
|
795 | + return new DataResponse( |
|
796 | + array( |
|
797 | + 'status' => 'error', |
|
798 | + 'data' => array( |
|
799 | + 'message' => (string)$this->l10n->t('Forbidden') |
|
800 | + ) |
|
801 | + ), |
|
802 | + Http::STATUS_FORBIDDEN |
|
803 | + ); |
|
804 | + } |
|
805 | + |
|
806 | + if($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) { |
|
807 | + return new DataResponse( |
|
808 | + array( |
|
809 | + 'status' => 'error', |
|
810 | + 'data' => array( |
|
811 | + 'message' => (string)$this->l10n->t('Invalid mail address') |
|
812 | + ) |
|
813 | + ), |
|
814 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
815 | + ); |
|
816 | + } |
|
817 | + |
|
818 | + if (!$user) { |
|
819 | + return new DataResponse( |
|
820 | + array( |
|
821 | + 'status' => 'error', |
|
822 | + 'data' => array( |
|
823 | + 'message' => (string)$this->l10n->t('Invalid user') |
|
824 | + ) |
|
825 | + ), |
|
826 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
827 | + ); |
|
828 | + } |
|
829 | + // this is the only permission a backend provides and is also used |
|
830 | + // for the permission of setting a email address |
|
831 | + if (!$user->canChangeDisplayName()) { |
|
832 | + return new DataResponse( |
|
833 | + array( |
|
834 | + 'status' => 'error', |
|
835 | + 'data' => array( |
|
836 | + 'message' => (string)$this->l10n->t('Unable to change mail address') |
|
837 | + ) |
|
838 | + ), |
|
839 | + Http::STATUS_FORBIDDEN |
|
840 | + ); |
|
841 | + } |
|
842 | + |
|
843 | + $userData = $this->accountManager->getUser($user); |
|
844 | + $userData[AccountManager::PROPERTY_EMAIL]['value'] = $mailAddress; |
|
845 | + |
|
846 | + try { |
|
847 | + $this->saveUserSettings($user, $userData); |
|
848 | + return new DataResponse( |
|
849 | + array( |
|
850 | + 'status' => 'success', |
|
851 | + 'data' => array( |
|
852 | + 'username' => $id, |
|
853 | + 'mailAddress' => $mailAddress, |
|
854 | + 'message' => (string)$this->l10n->t('Email saved') |
|
855 | + ) |
|
856 | + ), |
|
857 | + Http::STATUS_OK |
|
858 | + ); |
|
859 | + } catch (ForbiddenException $e) { |
|
860 | + return new DataResponse([ |
|
861 | + 'status' => 'error', |
|
862 | + 'data' => [ |
|
863 | + 'message' => $e->getMessage() |
|
864 | + ], |
|
865 | + ]); |
|
866 | + } |
|
867 | + } |
|
868 | 868 | |
869 | 869 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | // check for encryption state - TODO see formatUserForIndex |
152 | 152 | $this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption'); |
153 | - if($this->isEncryptionAppEnabled) { |
|
153 | + if ($this->isEncryptionAppEnabled) { |
|
154 | 154 | // putting this directly in empty is possible in PHP 5.5+ |
155 | 155 | $result = $config->getAppValue('encryption', 'recoveryAdminEnabled', 0); |
156 | 156 | $this->isRestoreEnabled = !empty($result); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user); |
193 | - foreach($subAdminGroups as $key => $subAdminGroup) { |
|
193 | + foreach ($subAdminGroups as $key => $subAdminGroup) { |
|
194 | 194 | $subAdminGroups[$key] = $subAdminGroup->getGID(); |
195 | 195 | } |
196 | 196 | |
@@ -247,16 +247,16 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function index($offset = 0, $limit = 10, $gid = '', $pattern = '', $backend = '') { |
249 | 249 | // FIXME: The JS sends the group '_everyone' instead of no GID for the "all users" group. |
250 | - if($gid === '_everyone') { |
|
250 | + if ($gid === '_everyone') { |
|
251 | 251 | $gid = ''; |
252 | 252 | } |
253 | 253 | |
254 | 254 | // Remove backends |
255 | - if(!empty($backend)) { |
|
255 | + if (!empty($backend)) { |
|
256 | 256 | $activeBackends = $this->userManager->getBackends(); |
257 | 257 | $this->userManager->clearBackends(); |
258 | - foreach($activeBackends as $singleActiveBackend) { |
|
259 | - if($backend === get_class($singleActiveBackend)) { |
|
258 | + foreach ($activeBackends as $singleActiveBackend) { |
|
259 | + if ($backend === get_class($singleActiveBackend)) { |
|
260 | 260 | $this->userManager->registerBackend($singleActiveBackend); |
261 | 261 | break; |
262 | 262 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $users = []; |
267 | 267 | if ($this->isAdmin) { |
268 | 268 | |
269 | - if($gid !== '') { |
|
269 | + if ($gid !== '') { |
|
270 | 270 | $batch = $this->getUsersForUID($this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset)); |
271 | 271 | } else { |
272 | 272 | $batch = $this->userManager->search($pattern, $limit, $offset); |
@@ -286,17 +286,17 @@ discard block |
||
286 | 286 | $subAdminOfGroups = $gids; |
287 | 287 | |
288 | 288 | // Set the $gid parameter to an empty value if the subadmin has no rights to access a specific group |
289 | - if($gid !== '' && !in_array($gid, $subAdminOfGroups)) { |
|
289 | + if ($gid !== '' && !in_array($gid, $subAdminOfGroups)) { |
|
290 | 290 | $gid = ''; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Batch all groups the user is subadmin of when a group is specified |
294 | 294 | $batch = []; |
295 | - if($gid === '') { |
|
296 | - foreach($subAdminOfGroups as $group) { |
|
295 | + if ($gid === '') { |
|
296 | + foreach ($subAdminOfGroups as $group) { |
|
297 | 297 | $groupUsers = $this->groupManager->displayNamesInGroup($group, $pattern, $limit, $offset); |
298 | 298 | |
299 | - foreach($groupUsers as $uid => $displayName) { |
|
299 | + foreach ($groupUsers as $uid => $displayName) { |
|
300 | 300 | $batch[$uid] = $displayName; |
301 | 301 | } |
302 | 302 | } |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | * @param string $email |
329 | 329 | * @return DataResponse |
330 | 330 | */ |
331 | - public function create($username, $password, array $groups=array(), $email='') { |
|
332 | - if($email !== '' && !$this->mailer->validateMailAddress($email)) { |
|
331 | + public function create($username, $password, array $groups = array(), $email = '') { |
|
332 | + if ($email !== '' && !$this->mailer->validateMailAddress($email)) { |
|
333 | 333 | return new DataResponse( |
334 | 334 | array( |
335 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
335 | + 'message' => (string) $this->l10n->t('Invalid mail address') |
|
336 | 336 | ), |
337 | 337 | Http::STATUS_UNPROCESSABLE_ENTITY |
338 | 338 | ); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | if (!empty($groups)) { |
345 | 345 | foreach ($groups as $key => $group) { |
346 | 346 | $groupObject = $this->groupManager->get($group); |
347 | - if($groupObject === null) { |
|
347 | + if ($groupObject === null) { |
|
348 | 348 | unset($groups[$key]); |
349 | 349 | continue; |
350 | 350 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | if ($this->userManager->userExists($username)) { |
369 | 369 | return new DataResponse( |
370 | 370 | array( |
371 | - 'message' => (string)$this->l10n->t('A user with that name already exists.') |
|
371 | + 'message' => (string) $this->l10n->t('A user with that name already exists.') |
|
372 | 372 | ), |
373 | 373 | Http::STATUS_CONFLICT |
374 | 374 | ); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | if ($email === '') { |
380 | 380 | return new DataResponse( |
381 | 381 | array( |
382 | - 'message' => (string)$this->l10n->t('To send a password link to the user an email address is required.') |
|
382 | + 'message' => (string) $this->l10n->t('To send a password link to the user an email address is required.') |
|
383 | 383 | ), |
384 | 384 | Http::STATUS_UNPROCESSABLE_ENTITY |
385 | 385 | ); |
@@ -404,12 +404,12 @@ discard block |
||
404 | 404 | ); |
405 | 405 | } |
406 | 406 | |
407 | - if($user instanceof IUser) { |
|
408 | - if($groups !== null) { |
|
409 | - foreach($groups as $groupName) { |
|
407 | + if ($user instanceof IUser) { |
|
408 | + if ($groups !== null) { |
|
409 | + foreach ($groups as $groupName) { |
|
410 | 410 | $group = $this->groupManager->get($groupName); |
411 | 411 | |
412 | - if(empty($group)) { |
|
412 | + if (empty($group)) { |
|
413 | 413 | $group = $this->groupManager->createGroup($groupName); |
414 | 414 | } |
415 | 415 | $group->addUser($user); |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | /** |
419 | 419 | * Send new user mail only if a mail is set |
420 | 420 | */ |
421 | - if($email !== '') { |
|
421 | + if ($email !== '') { |
|
422 | 422 | $user->setEMailAddress($email); |
423 | 423 | try { |
424 | 424 | $emailTemplate = $this->newUserMailHelper->generateTemplate($user, $generatePasswordResetToken); |
425 | 425 | $this->newUserMailHelper->sendMail($user, $emailTemplate); |
426 | - } catch(\Exception $e) { |
|
427 | - $this->log->error("Can't send new user mail to $email: " . $e->getMessage(), array('app' => 'settings')); |
|
426 | + } catch (\Exception $e) { |
|
427 | + $this->log->error("Can't send new user mail to $email: ".$e->getMessage(), array('app' => 'settings')); |
|
428 | 428 | } |
429 | 429 | } |
430 | 430 | // fetch users groups |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | |
439 | 439 | return new DataResponse( |
440 | 440 | array( |
441 | - 'message' => (string)$this->l10n->t('Unable to create user.') |
|
441 | + 'message' => (string) $this->l10n->t('Unable to create user.') |
|
442 | 442 | ), |
443 | 443 | Http::STATUS_FORBIDDEN |
444 | 444 | ); |
@@ -456,32 +456,32 @@ discard block |
||
456 | 456 | $userId = $this->userSession->getUser()->getUID(); |
457 | 457 | $user = $this->userManager->get($id); |
458 | 458 | |
459 | - if($userId === $id) { |
|
459 | + if ($userId === $id) { |
|
460 | 460 | return new DataResponse( |
461 | 461 | array( |
462 | 462 | 'status' => 'error', |
463 | 463 | 'data' => array( |
464 | - 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
464 | + 'message' => (string) $this->l10n->t('Unable to delete user.') |
|
465 | 465 | ) |
466 | 466 | ), |
467 | 467 | Http::STATUS_FORBIDDEN |
468 | 468 | ); |
469 | 469 | } |
470 | 470 | |
471 | - if(!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) { |
|
471 | + if (!$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) { |
|
472 | 472 | return new DataResponse( |
473 | 473 | array( |
474 | 474 | 'status' => 'error', |
475 | 475 | 'data' => array( |
476 | - 'message' => (string)$this->l10n->t('Authentication error') |
|
476 | + 'message' => (string) $this->l10n->t('Authentication error') |
|
477 | 477 | ) |
478 | 478 | ), |
479 | 479 | Http::STATUS_FORBIDDEN |
480 | 480 | ); |
481 | 481 | } |
482 | 482 | |
483 | - if($user) { |
|
484 | - if($user->delete()) { |
|
483 | + if ($user) { |
|
484 | + if ($user->delete()) { |
|
485 | 485 | return new DataResponse( |
486 | 486 | array( |
487 | 487 | 'status' => 'success', |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | array( |
499 | 499 | 'status' => 'error', |
500 | 500 | 'data' => array( |
501 | - 'message' => (string)$this->l10n->t('Unable to delete user.') |
|
501 | + 'message' => (string) $this->l10n->t('Unable to delete user.') |
|
502 | 502 | ) |
503 | 503 | ), |
504 | 504 | Http::STATUS_FORBIDDEN |
@@ -523,13 +523,13 @@ discard block |
||
523 | 523 | |
524 | 524 | $accountData = $this->accountManager->getUser($user); |
525 | 525 | $cloudId = $user->getCloudId(); |
526 | - $message = "Use my Federated Cloud ID to share with me: " . $cloudId; |
|
526 | + $message = "Use my Federated Cloud ID to share with me: ".$cloudId; |
|
527 | 527 | $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
528 | 528 | openssl_sign(json_encode($message), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
529 | 529 | $signatureBase64 = base64_encode($signature); |
530 | 530 | |
531 | - $code = $message . ' ' . $signatureBase64; |
|
532 | - $codeMd5 = $message . ' ' . md5($signatureBase64); |
|
531 | + $code = $message.' '.$signatureBase64; |
|
532 | + $codeMd5 = $message.' '.md5($signatureBase64); |
|
533 | 533 | |
534 | 534 | switch ($account) { |
535 | 535 | case 'verify-twitter': |
@@ -585,12 +585,12 @@ discard block |
||
585 | 585 | $twitterScope |
586 | 586 | ) { |
587 | 587 | |
588 | - if(!empty($email) && !$this->mailer->validateMailAddress($email)) { |
|
588 | + if (!empty($email) && !$this->mailer->validateMailAddress($email)) { |
|
589 | 589 | return new DataResponse( |
590 | 590 | array( |
591 | 591 | 'status' => 'error', |
592 | 592 | 'data' => array( |
593 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
593 | + 'message' => (string) $this->l10n->t('Invalid mail address') |
|
594 | 594 | ) |
595 | 595 | ), |
596 | 596 | Http::STATUS_UNPROCESSABLE_ENTITY |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | 'websiteScope' => $websiteScope, |
626 | 626 | 'address' => $address, |
627 | 627 | 'addressScope' => $addressScope, |
628 | - 'message' => (string)$this->l10n->t('Settings saved') |
|
628 | + 'message' => (string) $this->l10n->t('Settings saved') |
|
629 | 629 | ) |
630 | 630 | ), |
631 | 631 | Http::STATUS_OK |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | |
703 | 703 | $uniqueUsers = []; |
704 | 704 | foreach ($groups as $group) { |
705 | - foreach($group->getUsers() as $uid => $displayName) { |
|
705 | + foreach ($group->getUsers() as $uid => $displayName) { |
|
706 | 706 | $uniqueUsers[$uid] = true; |
707 | 707 | } |
708 | 708 | } |
@@ -796,19 +796,19 @@ discard block |
||
796 | 796 | array( |
797 | 797 | 'status' => 'error', |
798 | 798 | 'data' => array( |
799 | - 'message' => (string)$this->l10n->t('Forbidden') |
|
799 | + 'message' => (string) $this->l10n->t('Forbidden') |
|
800 | 800 | ) |
801 | 801 | ), |
802 | 802 | Http::STATUS_FORBIDDEN |
803 | 803 | ); |
804 | 804 | } |
805 | 805 | |
806 | - if($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) { |
|
806 | + if ($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) { |
|
807 | 807 | return new DataResponse( |
808 | 808 | array( |
809 | 809 | 'status' => 'error', |
810 | 810 | 'data' => array( |
811 | - 'message' => (string)$this->l10n->t('Invalid mail address') |
|
811 | + 'message' => (string) $this->l10n->t('Invalid mail address') |
|
812 | 812 | ) |
813 | 813 | ), |
814 | 814 | Http::STATUS_UNPROCESSABLE_ENTITY |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | array( |
821 | 821 | 'status' => 'error', |
822 | 822 | 'data' => array( |
823 | - 'message' => (string)$this->l10n->t('Invalid user') |
|
823 | + 'message' => (string) $this->l10n->t('Invalid user') |
|
824 | 824 | ) |
825 | 825 | ), |
826 | 826 | Http::STATUS_UNPROCESSABLE_ENTITY |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | array( |
834 | 834 | 'status' => 'error', |
835 | 835 | 'data' => array( |
836 | - 'message' => (string)$this->l10n->t('Unable to change mail address') |
|
836 | + 'message' => (string) $this->l10n->t('Unable to change mail address') |
|
837 | 837 | ) |
838 | 838 | ), |
839 | 839 | Http::STATUS_FORBIDDEN |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | 'data' => array( |
852 | 852 | 'username' => $id, |
853 | 853 | 'mailAddress' => $mailAddress, |
854 | - 'message' => (string)$this->l10n->t('Email saved') |
|
854 | + 'message' => (string) $this->l10n->t('Email saved') |
|
855 | 855 | ) |
856 | 856 | ), |
857 | 857 | Http::STATUS_OK |
@@ -36,77 +36,77 @@ |
||
36 | 36 | |
37 | 37 | $application = new Application(); |
38 | 38 | $application->registerRoutes($this, [ |
39 | - 'resources' => [ |
|
40 | - 'users' => ['url' => '/settings/users/users'], |
|
41 | - 'AuthSettings' => ['url' => '/settings/personal/authtokens'], |
|
42 | - ], |
|
43 | - 'routes' => [ |
|
44 | - ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'], |
|
45 | - ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'], |
|
46 | - ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'], |
|
47 | - ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'], |
|
48 | - ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], |
|
49 | - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], |
|
50 | - ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], |
|
51 | - ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], |
|
52 | - ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], |
|
53 | - ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], |
|
54 | - ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], |
|
55 | - ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], |
|
56 | - ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], |
|
57 | - ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], |
|
58 | - ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], |
|
59 | - ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], |
|
60 | - ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'], |
|
61 | - ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'], |
|
62 | - ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'], |
|
63 | - ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'], |
|
64 | - ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
65 | - ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'], |
|
66 | - ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
67 | - ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']], |
|
68 | - ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'], |
|
69 | - ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'], |
|
70 | - ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'], |
|
71 | - ['name' => 'Personal#setLanguage', 'url' => '/settings/ajax/setlanguage.php', 'verb' => 'POST'], |
|
72 | - ['name' => 'Groups#index', 'url' => '/settings/users/groups', 'verb' => 'GET'], |
|
73 | - ['name' => 'Groups#show', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'GET'], |
|
74 | - ['name' => 'Groups#create', 'url' => '/settings/users/groups', 'verb' => 'POST'], |
|
75 | - ['name' => 'Groups#update', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'PUT'], |
|
76 | - ['name' => 'Groups#destroy', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'DELETE'], |
|
77 | - ] |
|
39 | + 'resources' => [ |
|
40 | + 'users' => ['url' => '/settings/users/users'], |
|
41 | + 'AuthSettings' => ['url' => '/settings/personal/authtokens'], |
|
42 | + ], |
|
43 | + 'routes' => [ |
|
44 | + ['name' => 'MailSettings#setMailSettings', 'url' => '/settings/admin/mailsettings', 'verb' => 'POST'], |
|
45 | + ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST'], |
|
46 | + ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST'], |
|
47 | + ['name' => 'Encryption#startMigration', 'url' => '/settings/admin/startmigration', 'verb' => 'POST'], |
|
48 | + ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET'], |
|
49 | + ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET'], |
|
50 | + ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET'], |
|
51 | + ['name' => 'SecuritySettings#trustedDomains', 'url' => '/settings/admin/security/trustedDomains', 'verb' => 'POST'], |
|
52 | + ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST'], |
|
53 | + ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT'], |
|
54 | + ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT'], |
|
55 | + ['name' => 'Users#getVerificationCode', 'url' => '/settings/users/{account}/verify', 'verb' => 'GET'], |
|
56 | + ['name' => 'Users#stats', 'url' => '/settings/users/stats', 'verb' => 'GET'], |
|
57 | + ['name' => 'LogSettings#setLogLevel', 'url' => '/settings/admin/log/level', 'verb' => 'POST'], |
|
58 | + ['name' => 'LogSettings#getEntries', 'url' => '/settings/admin/log/entries', 'verb' => 'GET'], |
|
59 | + ['name' => 'LogSettings#download', 'url' => '/settings/admin/log/download', 'verb' => 'GET'], |
|
60 | + ['name' => 'CheckSetup#check', 'url' => '/settings/ajax/checksetup', 'verb' => 'GET'], |
|
61 | + ['name' => 'CheckSetup#getFailedIntegrityCheckFiles', 'url' => '/settings/integrity/failed', 'verb' => 'GET'], |
|
62 | + ['name' => 'CheckSetup#rescanFailedIntegrityCheck', 'url' => '/settings/integrity/rescan', 'verb' => 'GET'], |
|
63 | + ['name' => 'Certificate#addPersonalRootCertificate', 'url' => '/settings/personal/certificate', 'verb' => 'POST'], |
|
64 | + ['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
65 | + ['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'], |
|
66 | + ['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'], |
|
67 | + ['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']], |
|
68 | + ['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'], |
|
69 | + ['name' => 'ChangePassword#changePersonalPassword', 'url' => '/settings/personal/changepassword', 'verb' => 'POST'], |
|
70 | + ['name' => 'ChangePassword#changeUserPassword', 'url' => '/settings/users/changepassword', 'verb' => 'POST'], |
|
71 | + ['name' => 'Personal#setLanguage', 'url' => '/settings/ajax/setlanguage.php', 'verb' => 'POST'], |
|
72 | + ['name' => 'Groups#index', 'url' => '/settings/users/groups', 'verb' => 'GET'], |
|
73 | + ['name' => 'Groups#show', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'GET'], |
|
74 | + ['name' => 'Groups#create', 'url' => '/settings/users/groups', 'verb' => 'POST'], |
|
75 | + ['name' => 'Groups#update', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'PUT'], |
|
76 | + ['name' => 'Groups#destroy', 'url' => '/settings/users/groups/{id}', 'requirements' => ['id' => '[^?]*'], 'verb' => 'DELETE'], |
|
77 | + ] |
|
78 | 78 | ]); |
79 | 79 | |
80 | 80 | /** @var $this \OCP\Route\IRouter */ |
81 | 81 | |
82 | 82 | // Settings pages |
83 | 83 | $this->create('settings_help', '/settings/help') |
84 | - ->actionInclude('settings/help.php'); |
|
84 | + ->actionInclude('settings/help.php'); |
|
85 | 85 | $this->create('settings_personal', '/settings/personal') |
86 | - ->actionInclude('settings/personal.php'); |
|
86 | + ->actionInclude('settings/personal.php'); |
|
87 | 87 | $this->create('settings_users', '/settings/users') |
88 | - ->actionInclude('settings/users.php'); |
|
88 | + ->actionInclude('settings/users.php'); |
|
89 | 89 | // Settings ajax actions |
90 | 90 | // users |
91 | 91 | $this->create('settings_ajax_setquota', '/settings/ajax/setquota.php') |
92 | - ->actionInclude('settings/ajax/setquota.php'); |
|
92 | + ->actionInclude('settings/ajax/setquota.php'); |
|
93 | 93 | $this->create('settings_ajax_togglegroups', '/settings/ajax/togglegroups.php') |
94 | - ->actionInclude('settings/ajax/togglegroups.php'); |
|
94 | + ->actionInclude('settings/ajax/togglegroups.php'); |
|
95 | 95 | $this->create('settings_ajax_togglesubadmins', '/settings/ajax/togglesubadmins.php') |
96 | - ->actionInclude('settings/ajax/togglesubadmins.php'); |
|
96 | + ->actionInclude('settings/ajax/togglesubadmins.php'); |
|
97 | 97 | $this->create('settings_ajax_changegorupname', '/settings/ajax/changegroupname.php') |
98 | - ->actionInclude('settings/ajax/changegroupname.php'); |
|
98 | + ->actionInclude('settings/ajax/changegroupname.php'); |
|
99 | 99 | // apps |
100 | 100 | $this->create('settings_ajax_enableapp', '/settings/ajax/enableapp.php') |
101 | - ->actionInclude('settings/ajax/enableapp.php'); |
|
101 | + ->actionInclude('settings/ajax/enableapp.php'); |
|
102 | 102 | $this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php') |
103 | - ->actionInclude('settings/ajax/disableapp.php'); |
|
103 | + ->actionInclude('settings/ajax/disableapp.php'); |
|
104 | 104 | $this->create('settings_ajax_updateapp', '/settings/ajax/updateapp.php') |
105 | - ->actionInclude('settings/ajax/updateapp.php'); |
|
105 | + ->actionInclude('settings/ajax/updateapp.php'); |
|
106 | 106 | $this->create('settings_ajax_uninstallapp', '/settings/ajax/uninstallapp.php') |
107 | - ->actionInclude('settings/ajax/uninstallapp.php'); |
|
107 | + ->actionInclude('settings/ajax/uninstallapp.php'); |
|
108 | 108 | $this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php') |
109 | - ->actionInclude('settings/ajax/navigationdetect.php'); |
|
109 | + ->actionInclude('settings/ajax/navigationdetect.php'); |
|
110 | 110 | // admin |
111 | 111 | $this->create('settings_ajax_excludegroups', '/settings/ajax/excludegroups.php') |
112 | - ->actionInclude('settings/ajax/excludegroups.php'); |
|
112 | + ->actionInclude('settings/ajax/excludegroups.php'); |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | |
23 | 23 | <div id="app-navigation"> |
24 | 24 | <ul class="with-icon"> |
25 | - <?php foreach($_['forms'] as $form) { |
|
25 | + <?php foreach ($_['forms'] as $form) { |
|
26 | 26 | if (isset($form['anchor'])) { |
27 | - $anchor = '#' . $form['anchor']; |
|
28 | - $class = 'nav-icon-' . $form['anchor']; |
|
27 | + $anchor = '#'.$form['anchor']; |
|
28 | + $class = 'nav-icon-'.$form['anchor']; |
|
29 | 29 | $sectionName = $form['section-name']; |
30 | 30 | print_unescaped(sprintf("<li><a href='%s' class='%s'>%s</a></li>", \OCP\Util::sanitizeHTML($anchor), |
31 | 31 | \OCP\Util::sanitizeHTML($class), \OCP\Util::sanitizeHTML($sectionName))); |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | <div id="app-content"> |
38 | 38 | |
39 | 39 | <div id="quota" class="section"> |
40 | - <div style="width:<?php p($_['usage_relative']);?>%" |
|
41 | - <?php if($_['usage_relative'] > 80): ?> class="quota-warning" <?php endif; ?>> |
|
40 | + <div style="width:<?php p($_['usage_relative']); ?>%" |
|
41 | + <?php if ($_['usage_relative'] > 80): ?> class="quota-warning" <?php endif; ?>> |
|
42 | 42 | <p id="quotatext"> |
43 | 43 | <?php if ($_['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED): ?> |
44 | 44 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong>', |
45 | - [$_['usage'], $_['total_space']]));?> |
|
45 | + [$_['usage'], $_['total_space']])); ?> |
|
46 | 46 | <?php else: ?> |
47 | 47 | <?php print_unescaped($l->t('You are using <strong>%s</strong> of <strong>%s</strong> (<strong>%s %%</strong>)', |
48 | - [$_['usage'], $_['total_space'], $_['usage_relative']]));?> |
|
48 | + [$_['usage'], $_['total_space'], $_['usage_relative']])); ?> |
|
49 | 49 | <?php endif ?> |
50 | 50 | </p> |
51 | 51 | </div> |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | </div> |
80 | 80 | </div> |
81 | 81 | <span class="icon-checkmark hidden"/> |
82 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
82 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
83 | 83 | <input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>"> |
84 | 84 | <?php } ?> |
85 | 85 | </form> |
@@ -93,14 +93,14 @@ discard block |
||
93 | 93 | <span class="icon-password"/> |
94 | 94 | </h2> |
95 | 95 | <input type="text" id="displayname" name="displayname" |
96 | - <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
96 | + <?php if (!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
97 | 97 | value="<?php p($_['displayName']) ?>" |
98 | 98 | autocomplete="on" autocapitalize="none" autocorrect="off" /> |
99 | - <?php if(!$_['displayNameChangeSupported']) { ?> |
|
100 | - <span><?php if(isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span> |
|
99 | + <?php if (!$_['displayNameChangeSupported']) { ?> |
|
100 | + <span><?php if (isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span> |
|
101 | 101 | <?php } ?> |
102 | 102 | <span class="icon-checkmark hidden"/> |
103 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
103 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
104 | 104 | <input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>"> |
105 | 105 | <?php } ?> |
106 | 106 | </form> |
@@ -113,23 +113,23 @@ discard block |
||
113 | 113 | </h2> |
114 | 114 | <span class="verify" id="verify-email">Verify</span> |
115 | 115 | <input type="email" name="email" id="email" value="<?php p($_['email']); ?>" |
116 | - <?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
116 | + <?php if (!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?> |
|
117 | 117 | placeholder="<?php p($l->t('Your email address')); ?>" |
118 | 118 | autocomplete="on" autocapitalize="none" autocorrect="off" /> |
119 | - <?php if(!$_['displayNameChangeSupported']) { ?> |
|
120 | - <span><?php if(isset($_['email']) && !empty($_['email'])) { p($_['email']); } else { p($l->t('No email address set')); }?></span> |
|
119 | + <?php if (!$_['displayNameChangeSupported']) { ?> |
|
120 | + <span><?php if (isset($_['email']) && !empty($_['email'])) { p($_['email']); } else { p($l->t('No email address set')); }?></span> |
|
121 | 121 | <?php } ?> |
122 | - <?php if($_['displayNameChangeSupported']) { ?> |
|
122 | + <?php if ($_['displayNameChangeSupported']) { ?> |
|
123 | 123 | <br /> |
124 | 124 | <em><?php p($l->t('For password reset and notifications')); ?></em> |
125 | 125 | <?php } ?> |
126 | 126 | <span class="icon-checkmark hidden"/> |
127 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
127 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
128 | 128 | <input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>"> |
129 | 129 | <?php } ?> |
130 | 130 | </form> |
131 | 131 | </div> |
132 | - <?php if($_['lookupServerUploadEnabled']) { ?> |
|
132 | + <?php if ($_['lookupServerUploadEnabled']) { ?> |
|
133 | 133 | <div class="personal-settings-setting-box"> |
134 | 134 | <form id="phoneform" class="section"> |
135 | 135 | <h2> |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | </div> |
201 | 201 | |
202 | 202 | <?php |
203 | -if($_['passwordChangeSupported']) { |
|
203 | +if ($_['passwordChangeSupported']) { |
|
204 | 204 | script('jquery-showpassword'); |
205 | 205 | ?> |
206 | 206 | <form id="passwordform" class="section"> |
207 | - <h2 class="inlineblock"><?php p($l->t('Password'));?></h2> |
|
207 | + <h2 class="inlineblock"><?php p($l->t('Password')); ?></h2> |
|
208 | 208 | <div id="password-error-msg" class="msg success inlineblock" style="display: none;">Saved</div> |
209 | 209 | <br> |
210 | 210 | <label for="pass1" class="hidden-visually"><?php p($l->t('Current password')); ?>: </label> |
211 | 211 | <input type="password" id="pass1" name="oldpassword" |
212 | - placeholder="<?php p($l->t('Current password'));?>" |
|
212 | + placeholder="<?php p($l->t('Current password')); ?>" |
|
213 | 213 | autocomplete="off" autocapitalize="none" autocorrect="off" /> |
214 | 214 | <div class="personal-show-container"> |
215 | - <label for="pass2" class="hidden-visually"><?php p($l->t('New password'));?>: </label> |
|
215 | + <label for="pass2" class="hidden-visually"><?php p($l->t('New password')); ?>: </label> |
|
216 | 216 | <input type="password" id="pass2" name="newpassword" |
217 | 217 | placeholder="<?php p($l->t('New password')); ?>" |
218 | 218 | data-typetoggle="#personal-show" |
@@ -228,44 +228,44 @@ discard block |
||
228 | 228 | |
229 | 229 | <form id="language" class="section"> |
230 | 230 | <h2> |
231 | - <label for="languageinput"><?php p($l->t('Language'));?></label> |
|
231 | + <label for="languageinput"><?php p($l->t('Language')); ?></label> |
|
232 | 232 | </h2> |
233 | - <select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language'));?>"> |
|
234 | - <option value="<?php p($_['activelanguage']['code']);?>"> |
|
235 | - <?php p($_['activelanguage']['name']);?> |
|
233 | + <select id="languageinput" name="lang" data-placeholder="<?php p($l->t('Language')); ?>"> |
|
234 | + <option value="<?php p($_['activelanguage']['code']); ?>"> |
|
235 | + <?php p($_['activelanguage']['name']); ?> |
|
236 | 236 | </option> |
237 | - <?php foreach($_['commonlanguages'] as $language):?> |
|
238 | - <option value="<?php p($language['code']);?>"> |
|
239 | - <?php p($language['name']);?> |
|
237 | + <?php foreach ($_['commonlanguages'] as $language):?> |
|
238 | + <option value="<?php p($language['code']); ?>"> |
|
239 | + <?php p($language['name']); ?> |
|
240 | 240 | </option> |
241 | - <?php endforeach;?> |
|
241 | + <?php endforeach; ?> |
|
242 | 242 | <optgroup label="––––––––––"></optgroup> |
243 | - <?php foreach($_['languages'] as $language):?> |
|
244 | - <option value="<?php p($language['code']);?>"> |
|
245 | - <?php p($language['name']);?> |
|
243 | + <?php foreach ($_['languages'] as $language):?> |
|
244 | + <option value="<?php p($language['code']); ?>"> |
|
245 | + <?php p($language['name']); ?> |
|
246 | 246 | </option> |
247 | - <?php endforeach;?> |
|
247 | + <?php endforeach; ?> |
|
248 | 248 | </select> |
249 | 249 | <a href="https://www.transifex.com/nextcloud/nextcloud/" |
250 | 250 | target="_blank" rel="noreferrer"> |
251 | - <em><?php p($l->t('Help translate'));?></em> |
|
251 | + <em><?php p($l->t('Help translate')); ?></em> |
|
252 | 252 | </a> |
253 | 253 | </form> |
254 | 254 | |
255 | 255 | |
256 | 256 | <div id="clientsbox" class="section clientsbox"> |
257 | - <h2><?php p($l->t('Get the apps to sync your files'));?></h2> |
|
257 | + <h2><?php p($l->t('Get the apps to sync your files')); ?></h2> |
|
258 | 258 | <a href="<?php p($_['clients']['desktop']); ?>" rel="noreferrer" target="_blank"> |
259 | 259 | <img src="<?php print_unescaped(image_path('core', 'desktopapp.svg')); ?>" |
260 | - alt="<?php p($l->t('Desktop client'));?>" /> |
|
260 | + alt="<?php p($l->t('Desktop client')); ?>" /> |
|
261 | 261 | </a> |
262 | 262 | <a href="<?php p($_['clients']['android']); ?>" rel="noreferrer" target="_blank"> |
263 | 263 | <img src="<?php print_unescaped(image_path('core', 'googleplay.png')); ?>" |
264 | - alt="<?php p($l->t('Android app'));?>" /> |
|
264 | + alt="<?php p($l->t('Android app')); ?>" /> |
|
265 | 265 | </a> |
266 | 266 | <a href="<?php p($_['clients']['ios']); ?>" rel="noreferrer" target="_blank"> |
267 | 267 | <img src="<?php print_unescaped(image_path('core', 'appstore.svg')); ?>" |
268 | - alt="<?php p($l->t('iOS app'));?>" /> |
|
268 | + alt="<?php p($l->t('iOS app')); ?>" /> |
|
269 | 269 | </a> |
270 | 270 | |
271 | 271 | <p> |
@@ -281,19 +281,19 @@ discard block |
||
281 | 281 | $l->t('If you want to support the project {contributeopen}join development{linkclose} or {contributeopen}spread the word{linkclose}!'))); ?> |
282 | 282 | </p> |
283 | 283 | |
284 | - <?php if(OC_APP::isEnabled('firstrunwizard')) {?> |
|
285 | - <p><a class="button" href="#" id="showWizard"><?php p($l->t('Show First Run Wizard again'));?></a></p> |
|
284 | + <?php if (OC_APP::isEnabled('firstrunwizard')) {?> |
|
285 | + <p><a class="button" href="#" id="showWizard"><?php p($l->t('Show First Run Wizard again')); ?></a></p> |
|
286 | 286 | <?php }?> |
287 | 287 | </div> |
288 | 288 | |
289 | 289 | <div id="sessions" class="section"> |
290 | - <h2><?php p($l->t('Sessions'));?></h2> |
|
291 | - <span class="hidden-when-empty"><?php p($l->t('Web, desktop and mobile clients currently logged in to your account.'));?></span> |
|
290 | + <h2><?php p($l->t('Sessions')); ?></h2> |
|
291 | + <span class="hidden-when-empty"><?php p($l->t('Web, desktop and mobile clients currently logged in to your account.')); ?></span> |
|
292 | 292 | <table class="icon-loading"> |
293 | 293 | <thead class="token-list-header"> |
294 | 294 | <tr> |
295 | - <th><?php p($l->t('Device'));?></th> |
|
296 | - <th><?php p($l->t('Last activity'));?></th> |
|
295 | + <th><?php p($l->t('Device')); ?></th> |
|
296 | + <th><?php p($l->t('Last activity')); ?></th> |
|
297 | 297 | <th></th> |
298 | 298 | </tr> |
299 | 299 | </thead> |
@@ -303,13 +303,13 @@ discard block |
||
303 | 303 | </div> |
304 | 304 | |
305 | 305 | <div id="apppasswords" class="section"> |
306 | - <h2><?php p($l->t('App passwords'));?></h2> |
|
307 | - <p><?php p($l->t('Passcodes that give an app or device permissions to access your account.'));?></p> |
|
306 | + <h2><?php p($l->t('App passwords')); ?></h2> |
|
307 | + <p><?php p($l->t('Passcodes that give an app or device permissions to access your account.')); ?></p> |
|
308 | 308 | <table class="icon-loading"> |
309 | 309 | <thead class="hidden-when-empty"> |
310 | 310 | <tr> |
311 | - <th><?php p($l->t('Name'));?></th> |
|
312 | - <th><?php p($l->t('Last activity'));?></th> |
|
311 | + <th><?php p($l->t('Name')); ?></th> |
|
312 | + <th><?php p($l->t('Last activity')); ?></th> |
|
313 | 313 | <th></th> |
314 | 314 | </tr> |
315 | 315 | </thead> |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | </div> |
339 | 339 | </div> |
340 | 340 | |
341 | -<?php foreach($_['forms'] as $form) { |
|
341 | +<?php foreach ($_['forms'] as $form) { |
|
342 | 342 | if (isset($form['form'])) {?> |
343 | - <div id="<?php isset($form['anchor']) ? p($form['anchor']) : p('');?>"><?php print_unescaped($form['form']);?></div> |
|
343 | + <div id="<?php isset($form['anchor']) ? p($form['anchor']) : p(''); ?>"><?php print_unescaped($form['form']); ?></div> |
|
344 | 344 | <?php } |
345 | 345 | };?> |
346 | 346 | |
347 | 347 | <div class="section"> |
348 | - <h2><?php p($l->t('Version'));?></h2> |
|
348 | + <h2><?php p($l->t('Version')); ?></h2> |
|
349 | 349 | <p><a href="<?php print_unescaped($theme->getBaseUrl()); ?>" target="_blank"><?php p($theme->getTitle()); ?></a> <?php p(OC_Util::getHumanVersion()) ?></p> |
350 | 350 | <p><?php include('settings.development.notice.php'); ?></p> |
351 | 351 | </div> |