Completed
Push — master ( 0fa796...acbcc6 )
by Morris
54:31 queued 39:54
created
apps/provisioning_api/lib/Controller/AUserData.php 2 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -35,152 +35,152 @@
 block discarded – undo
35 35
 
36 36
 abstract class AUserData extends OCSController {
37 37
 
38
-	/** @var IUserManager */
39
-	protected $userManager;
40
-	/** @var IConfig */
41
-	protected $config;
42
-	/** @var IGroupManager|\OC\Group\Manager */ // FIXME Requires a method that is not on the interface
43
-	protected $groupManager;
44
-	/** @var IUserSession */
45
-	protected $userSession;
46
-	/** @var AccountManager */
47
-	protected $accountManager;
48
-
49
-	/**
50
-	 * @param string $appName
51
-	 * @param IRequest $request
52
-	 * @param IUserManager $userManager
53
-	 * @param IConfig $config
54
-	 * @param IGroupManager $groupManager
55
-	 * @param IUserSession $userSession
56
-	 * @param AccountManager $accountManager
57
-	 */
58
-	public function __construct(string $appName,
59
-								IRequest $request,
60
-								IUserManager $userManager,
61
-								IConfig $config,
62
-								IGroupManager $groupManager,
63
-								IUserSession $userSession,
64
-								AccountManager $accountManager) {
65
-		parent::__construct($appName, $request);
66
-
67
-		$this->userManager = $userManager;
68
-		$this->config = $config;
69
-		$this->groupManager = $groupManager;
70
-		$this->userSession = $userSession;
71
-		$this->accountManager = $accountManager;
72
-	}
73
-
74
-	/**
75
-	 * creates a array with all user data
76
-	 *
77
-	 * @param $userId
78
-	 * @return array
79
-	 * @throws OCSException
80
-	 */
81
-	protected function getUserData(string $userId): array {
82
-		$currentLoggedInUser = $this->userSession->getUser();
83
-
84
-		$data = [];
85
-
86
-		// Check if the target user exists
87
-		$targetUserObject = $this->userManager->get($userId);
88
-		if($targetUserObject === null) {
89
-			throw new OCSNotFoundException('User does not exist');
90
-		}
91
-
92
-		// Should be at least Admin Or SubAdmin!
93
-		if( $this->groupManager->isAdmin($currentLoggedInUser->getUID())
94
-			|| $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) {
95
-				$data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true';
96
-		} else {
97
-			// Check they are looking up themselves
98
-			if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) {
99
-				return $data;
100
-			}
101
-		}
102
-
103
-		// Get groups data
104
-		$userAccount = $this->accountManager->getUser($targetUserObject);
105
-		$groups = $this->groupManager->getUserGroups($targetUserObject);
106
-		$gids = [];
107
-		foreach ($groups as $group) {
108
-			$gids[] = $group->getDisplayName();
109
-		}
110
-
111
-		// Find the data
112
-		$data['id'] = $targetUserObject->getUID();
113
-		$data['storageLocation'] = $targetUserObject->getHome();
114
-		$data['lastLogin'] = $targetUserObject->getLastLogin() * 1000;
115
-		$data['backend'] = $targetUserObject->getBackendClassName();
116
-		$data['subadmin'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID());
117
-		$data['quota'] = $this->fillStorageInfo($targetUserObject->getUID());
118
-		$data[AccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress();
119
-		$data[AccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName();
120
-		$data[AccountManager::PROPERTY_PHONE] = $userAccount[AccountManager::PROPERTY_PHONE]['value'];
121
-		$data[AccountManager::PROPERTY_ADDRESS] = $userAccount[AccountManager::PROPERTY_ADDRESS]['value'];
122
-		$data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value'];
123
-		$data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value'];
124
-		$data['groups'] = $gids;
125
-		$data['language'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang');
126
-
127
-		return $data;
38
+    /** @var IUserManager */
39
+    protected $userManager;
40
+    /** @var IConfig */
41
+    protected $config;
42
+    /** @var IGroupManager|\OC\Group\Manager */ // FIXME Requires a method that is not on the interface
43
+    protected $groupManager;
44
+    /** @var IUserSession */
45
+    protected $userSession;
46
+    /** @var AccountManager */
47
+    protected $accountManager;
48
+
49
+    /**
50
+     * @param string $appName
51
+     * @param IRequest $request
52
+     * @param IUserManager $userManager
53
+     * @param IConfig $config
54
+     * @param IGroupManager $groupManager
55
+     * @param IUserSession $userSession
56
+     * @param AccountManager $accountManager
57
+     */
58
+    public function __construct(string $appName,
59
+                                IRequest $request,
60
+                                IUserManager $userManager,
61
+                                IConfig $config,
62
+                                IGroupManager $groupManager,
63
+                                IUserSession $userSession,
64
+                                AccountManager $accountManager) {
65
+        parent::__construct($appName, $request);
66
+
67
+        $this->userManager = $userManager;
68
+        $this->config = $config;
69
+        $this->groupManager = $groupManager;
70
+        $this->userSession = $userSession;
71
+        $this->accountManager = $accountManager;
128 72
     }
129 73
 
130
-	/**
131
-	 * Get the groups a user is a subadmin of
132
-	 *
133
-	 * @param string $userId
134
-	 * @return array
135
-	 * @throws OCSException
136
-	 */
137
-	protected function getUserSubAdminGroupsData(string $userId): array {
138
-		$user = $this->userManager->get($userId);
139
-		// Check if the user exists
140
-		if($user === null) {
141
-			throw new OCSNotFoundException('User does not exist');
142
-		}
143
-
144
-		// Get the subadmin groups
145
-		$subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
146
-		$groups = [];
147
-		foreach ($subAdminGroups as $key => $group) {
148
-			$groups[] = $group->getGID();
149
-		}
150
-
151
-		return $groups;
152
-	}
153
-
154
-	/**
155
-	 * @param string $userId
156
-	 * @return array
157
-	 * @throws \OCP\Files\NotFoundException
158
-	 */
159
-	protected function fillStorageInfo(string $userId): array {
160
-		try {
161
-			\OC_Util::tearDownFS();
162
-			\OC_Util::setupFS($userId);
163
-			$storage = OC_Helper::getStorageInfo('/');
164
-			$data = [
165
-				'free' => $storage['free'],
166
-				'used' => $storage['used'],
167
-				'total' => $storage['total'],
168
-				'relative' => $storage['relative'],
169
-				'quota' => $storage['quota'],
170
-			];
171
-		} catch (NotFoundException $ex) {
172
-			// User fs is not setup yet
173
-			$user = $this->userManager->get($userId);
174
-			if ($user === null) {
175
-				throw new OCSException('User does not exist', 101);
176
-			}
177
-			$quota = OC_Helper::computerFileSize($user->getQuota());
178
-			$data = [
179
-				'quota' => $quota ? $quota : 'none',
180
-				'used' => 0
181
-			];
182
-		}
183
-		return $data;
184
-	}
74
+    /**
75
+     * creates a array with all user data
76
+     *
77
+     * @param $userId
78
+     * @return array
79
+     * @throws OCSException
80
+     */
81
+    protected function getUserData(string $userId): array {
82
+        $currentLoggedInUser = $this->userSession->getUser();
83
+
84
+        $data = [];
85
+
86
+        // Check if the target user exists
87
+        $targetUserObject = $this->userManager->get($userId);
88
+        if($targetUserObject === null) {
89
+            throw new OCSNotFoundException('User does not exist');
90
+        }
91
+
92
+        // Should be at least Admin Or SubAdmin!
93
+        if( $this->groupManager->isAdmin($currentLoggedInUser->getUID())
94
+            || $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) {
95
+                $data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true';
96
+        } else {
97
+            // Check they are looking up themselves
98
+            if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) {
99
+                return $data;
100
+            }
101
+        }
102
+
103
+        // Get groups data
104
+        $userAccount = $this->accountManager->getUser($targetUserObject);
105
+        $groups = $this->groupManager->getUserGroups($targetUserObject);
106
+        $gids = [];
107
+        foreach ($groups as $group) {
108
+            $gids[] = $group->getDisplayName();
109
+        }
110
+
111
+        // Find the data
112
+        $data['id'] = $targetUserObject->getUID();
113
+        $data['storageLocation'] = $targetUserObject->getHome();
114
+        $data['lastLogin'] = $targetUserObject->getLastLogin() * 1000;
115
+        $data['backend'] = $targetUserObject->getBackendClassName();
116
+        $data['subadmin'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID());
117
+        $data['quota'] = $this->fillStorageInfo($targetUserObject->getUID());
118
+        $data[AccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress();
119
+        $data[AccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName();
120
+        $data[AccountManager::PROPERTY_PHONE] = $userAccount[AccountManager::PROPERTY_PHONE]['value'];
121
+        $data[AccountManager::PROPERTY_ADDRESS] = $userAccount[AccountManager::PROPERTY_ADDRESS]['value'];
122
+        $data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value'];
123
+        $data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value'];
124
+        $data['groups'] = $gids;
125
+        $data['language'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang');
126
+
127
+        return $data;
128
+    }
129
+
130
+    /**
131
+     * Get the groups a user is a subadmin of
132
+     *
133
+     * @param string $userId
134
+     * @return array
135
+     * @throws OCSException
136
+     */
137
+    protected function getUserSubAdminGroupsData(string $userId): array {
138
+        $user = $this->userManager->get($userId);
139
+        // Check if the user exists
140
+        if($user === null) {
141
+            throw new OCSNotFoundException('User does not exist');
142
+        }
143
+
144
+        // Get the subadmin groups
145
+        $subAdminGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
146
+        $groups = [];
147
+        foreach ($subAdminGroups as $key => $group) {
148
+            $groups[] = $group->getGID();
149
+        }
150
+
151
+        return $groups;
152
+    }
153
+
154
+    /**
155
+     * @param string $userId
156
+     * @return array
157
+     * @throws \OCP\Files\NotFoundException
158
+     */
159
+    protected function fillStorageInfo(string $userId): array {
160
+        try {
161
+            \OC_Util::tearDownFS();
162
+            \OC_Util::setupFS($userId);
163
+            $storage = OC_Helper::getStorageInfo('/');
164
+            $data = [
165
+                'free' => $storage['free'],
166
+                'used' => $storage['used'],
167
+                'total' => $storage['total'],
168
+                'relative' => $storage['relative'],
169
+                'quota' => $storage['quota'],
170
+            ];
171
+        } catch (NotFoundException $ex) {
172
+            // User fs is not setup yet
173
+            $user = $this->userManager->get($userId);
174
+            if ($user === null) {
175
+                throw new OCSException('User does not exist', 101);
176
+            }
177
+            $quota = OC_Helper::computerFileSize($user->getQuota());
178
+            $data = [
179
+                'quota' => $quota ? $quota : 'none',
180
+                'used' => 0
181
+            ];
182
+        }
183
+        return $data;
184
+    }
185 185
 
186 186
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * @copyright Copyright (c) 2018 John Molakvoæ (skjnldsv) <[email protected]>
5 5
  *
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 
86 86
 		// Check if the target user exists
87 87
 		$targetUserObject = $this->userManager->get($userId);
88
-		if($targetUserObject === null) {
88
+		if ($targetUserObject === null) {
89 89
 			throw new OCSNotFoundException('User does not exist');
90 90
 		}
91 91
 
92 92
 		// Should be at least Admin Or SubAdmin!
93
-		if( $this->groupManager->isAdmin($currentLoggedInUser->getUID())
93
+		if ($this->groupManager->isAdmin($currentLoggedInUser->getUID())
94 94
 			|| $this->groupManager->getSubAdmin()->isUserAccessible($currentLoggedInUser, $targetUserObject)) {
95 95
 				$data['enabled'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'enabled', 'true') === 'true';
96 96
 		} else {
97 97
 			// Check they are looking up themselves
98
-			if($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) {
98
+			if ($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) {
99 99
 				return $data;
100 100
 			}
101 101
 		}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	protected function getUserSubAdminGroupsData(string $userId): array {
138 138
 		$user = $this->userManager->get($userId);
139 139
 		// Check if the user exists
140
-		if($user === null) {
140
+		if ($user === null) {
141 141
 			throw new OCSNotFoundException('User does not exist');
142 142
 		}
143 143
 
Please login to merge, or discard this patch.
lib/private/User/User.php 1 patch
Indentation   +411 added lines, -411 removed lines patch added patch discarded remove patch
@@ -44,415 +44,415 @@
 block discarded – undo
44 44
 use \OCP\IUserBackend;
45 45
 
46 46
 class User implements IUser {
47
-	/** @var string $uid */
48
-	private $uid;
49
-
50
-	/** @var string $displayName */
51
-	private $displayName;
52
-
53
-	/** @var UserInterface $backend */
54
-	private $backend;
55
-
56
-	/** @var bool $enabled */
57
-	private $enabled;
58
-
59
-	/** @var Emitter|Manager $emitter */
60
-	private $emitter;
61
-
62
-	/** @var string $home */
63
-	private $home;
64
-
65
-	/** @var int $lastLogin */
66
-	private $lastLogin;
67
-
68
-	/** @var \OCP\IConfig $config */
69
-	private $config;
70
-
71
-	/** @var IAvatarManager */
72
-	private $avatarManager;
73
-
74
-	/** @var IURLGenerator */
75
-	private $urlGenerator;
76
-
77
-	/**
78
-	 * @param string $uid
79
-	 * @param UserInterface $backend
80
-	 * @param \OC\Hooks\Emitter $emitter
81
-	 * @param IConfig|null $config
82
-	 * @param IURLGenerator $urlGenerator
83
-	 */
84
-	public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $urlGenerator = null) {
85
-		$this->uid = $uid;
86
-		$this->backend = $backend;
87
-		$this->emitter = $emitter;
88
-		if(is_null($config)) {
89
-			$config = \OC::$server->getConfig();
90
-		}
91
-		$this->config = $config;
92
-		$this->urlGenerator = $urlGenerator;
93
-		$enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true');
94
-		$this->enabled = ($enabled === 'true');
95
-		$this->lastLogin = $this->config->getUserValue($uid, 'login', 'lastLogin', 0);
96
-		if (is_null($this->urlGenerator)) {
97
-			$this->urlGenerator = \OC::$server->getURLGenerator();
98
-		}
99
-	}
100
-
101
-	/**
102
-	 * get the user id
103
-	 *
104
-	 * @return string
105
-	 */
106
-	public function getUID() {
107
-		return $this->uid;
108
-	}
109
-
110
-	/**
111
-	 * get the display name for the user, if no specific display name is set it will fallback to the user id
112
-	 *
113
-	 * @return string
114
-	 */
115
-	public function getDisplayName() {
116
-		if (!isset($this->displayName)) {
117
-			$displayName = '';
118
-			if ($this->backend and $this->backend->implementsActions(Backend::GET_DISPLAYNAME)) {
119
-				// get display name and strip whitespace from the beginning and end of it
120
-				$backendDisplayName = $this->backend->getDisplayName($this->uid);
121
-				if (is_string($backendDisplayName)) {
122
-					$displayName = trim($backendDisplayName);
123
-				}
124
-			}
125
-
126
-			if (!empty($displayName)) {
127
-				$this->displayName = $displayName;
128
-			} else {
129
-				$this->displayName = $this->uid;
130
-			}
131
-		}
132
-		return $this->displayName;
133
-	}
134
-
135
-	/**
136
-	 * set the displayname for the user
137
-	 *
138
-	 * @param string $displayName
139
-	 * @return bool
140
-	 */
141
-	public function setDisplayName($displayName) {
142
-		$displayName = trim($displayName);
143
-		if ($this->backend->implementsActions(Backend::SET_DISPLAYNAME) && !empty($displayName)) {
144
-			$result = $this->backend->setDisplayName($this->uid, $displayName);
145
-			if ($result) {
146
-				$this->displayName = $displayName;
147
-				$this->triggerChange('displayName', $displayName);
148
-			}
149
-			return $result !== false;
150
-		} else {
151
-			return false;
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * set the email address of the user
157
-	 *
158
-	 * @param string|null $mailAddress
159
-	 * @return void
160
-	 * @since 9.0.0
161
-	 */
162
-	public function setEMailAddress($mailAddress) {
163
-		$oldMailAddress = $this->getEMailAddress();
164
-		if($mailAddress === '') {
165
-			$this->config->deleteUserValue($this->uid, 'settings', 'email');
166
-		} else {
167
-			$this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
168
-		}
169
-		if($oldMailAddress !== $mailAddress) {
170
-			$this->triggerChange('eMailAddress', $mailAddress, $oldMailAddress);
171
-		}
172
-	}
173
-
174
-	/**
175
-	 * returns the timestamp of the user's last login or 0 if the user did never
176
-	 * login
177
-	 *
178
-	 * @return int
179
-	 */
180
-	public function getLastLogin() {
181
-		return $this->lastLogin;
182
-	}
183
-
184
-	/**
185
-	 * updates the timestamp of the most recent login of this user
186
-	 */
187
-	public function updateLastLoginTimestamp() {
188
-		$firstTimeLogin = ($this->lastLogin === 0);
189
-		$this->lastLogin = time();
190
-		$this->config->setUserValue(
191
-			$this->uid, 'login', 'lastLogin', $this->lastLogin);
192
-
193
-		return $firstTimeLogin;
194
-	}
195
-
196
-	/**
197
-	 * Delete the user
198
-	 *
199
-	 * @return bool
200
-	 */
201
-	public function delete() {
202
-		if ($this->emitter) {
203
-			$this->emitter->emit('\OC\User', 'preDelete', array($this));
204
-		}
205
-		// get the home now because it won't return it after user deletion
206
-		$homePath = $this->getHome();
207
-		$result = $this->backend->deleteUser($this->uid);
208
-		if ($result) {
209
-
210
-			// FIXME: Feels like an hack - suggestions?
211
-
212
-			$groupManager = \OC::$server->getGroupManager();
213
-			// We have to delete the user from all groups
214
-			foreach ($groupManager->getUserGroupIds($this) as $groupId) {
215
-				$group = $groupManager->get($groupId);
216
-				if ($group) {
217
-					\OC_Hook::emit("OC_Group", "pre_removeFromGroup", ["run" => true, "uid" => $this->uid, "gid" => $groupId]);
218
-					$group->removeUser($this);
219
-					\OC_Hook::emit("OC_User", "post_removeFromGroup", ["uid" => $this->uid, "gid" => $groupId]);
220
-				}
221
-			}
222
-			// Delete the user's keys in preferences
223
-			\OC::$server->getConfig()->deleteAllUserValues($this->uid);
224
-
225
-			// Delete user files in /data/
226
-			if ($homePath !== false) {
227
-				// FIXME: this operates directly on FS, should use View instead...
228
-				// also this is not testable/mockable...
229
-				\OC_Helper::rmdirr($homePath);
230
-			}
231
-
232
-			// Delete the users entry in the storage table
233
-			Storage::remove('home::' . $this->uid);
234
-
235
-			\OC::$server->getCommentsManager()->deleteReferencesOfActor('users', $this->uid);
236
-			\OC::$server->getCommentsManager()->deleteReadMarksFromUser($this);
237
-
238
-			$notification = \OC::$server->getNotificationManager()->createNotification();
239
-			$notification->setUser($this->uid);
240
-			\OC::$server->getNotificationManager()->markProcessed($notification);
241
-
242
-			/** @var AccountManager $accountManager */
243
-			$accountManager = \OC::$server->query(AccountManager::class);
244
-			$accountManager->deleteUser($this);
245
-
246
-			if ($this->emitter) {
247
-				$this->emitter->emit('\OC\User', 'postDelete', array($this));
248
-			}
249
-		}
250
-		return !($result === false);
251
-	}
252
-
253
-	/**
254
-	 * Set the password of the user
255
-	 *
256
-	 * @param string $password
257
-	 * @param string $recoveryPassword for the encryption app to reset encryption keys
258
-	 * @return bool
259
-	 */
260
-	public function setPassword($password, $recoveryPassword = null) {
261
-		if ($this->emitter) {
262
-			$this->emitter->emit('\OC\User', 'preSetPassword', array($this, $password, $recoveryPassword));
263
-		}
264
-		if ($this->backend->implementsActions(Backend::SET_PASSWORD)) {
265
-			$result = $this->backend->setPassword($this->uid, $password);
266
-			if ($this->emitter) {
267
-				$this->emitter->emit('\OC\User', 'postSetPassword', array($this, $password, $recoveryPassword));
268
-			}
269
-			return !($result === false);
270
-		} else {
271
-			return false;
272
-		}
273
-	}
274
-
275
-	/**
276
-	 * get the users home folder to mount
277
-	 *
278
-	 * @return string
279
-	 */
280
-	public function getHome() {
281
-		if (!$this->home) {
282
-			if ($this->backend->implementsActions(Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) {
283
-				$this->home = $home;
284
-			} elseif ($this->config) {
285
-				$this->home = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $this->uid;
286
-			} else {
287
-				$this->home = \OC::$SERVERROOT . '/data/' . $this->uid;
288
-			}
289
-		}
290
-		return $this->home;
291
-	}
292
-
293
-	/**
294
-	 * Get the name of the backend class the user is connected with
295
-	 *
296
-	 * @return string
297
-	 */
298
-	public function getBackendClassName() {
299
-		if($this->backend instanceof IUserBackend) {
300
-			return $this->backend->getBackendName();
301
-		}
302
-		return get_class($this->backend);
303
-	}
304
-
305
-	/**
306
-	 * check if the backend allows the user to change his avatar on Personal page
307
-	 *
308
-	 * @return bool
309
-	 */
310
-	public function canChangeAvatar() {
311
-		if ($this->backend->implementsActions(Backend::PROVIDE_AVATAR)) {
312
-			return $this->backend->canChangeAvatar($this->uid);
313
-		}
314
-		return true;
315
-	}
316
-
317
-	/**
318
-	 * check if the backend supports changing passwords
319
-	 *
320
-	 * @return bool
321
-	 */
322
-	public function canChangePassword() {
323
-		return $this->backend->implementsActions(Backend::SET_PASSWORD);
324
-	}
325
-
326
-	/**
327
-	 * check if the backend supports changing display names
328
-	 *
329
-	 * @return bool
330
-	 */
331
-	public function canChangeDisplayName() {
332
-		if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) {
333
-			return false;
334
-		}
335
-		return $this->backend->implementsActions(Backend::SET_DISPLAYNAME);
336
-	}
337
-
338
-	/**
339
-	 * check if the user is enabled
340
-	 *
341
-	 * @return bool
342
-	 */
343
-	public function isEnabled() {
344
-		return $this->enabled;
345
-	}
346
-
347
-	/**
348
-	 * set the enabled status for the user
349
-	 *
350
-	 * @param bool $enabled
351
-	 */
352
-	public function setEnabled(bool $enabled = true) {
353
-		$oldStatus = $this->isEnabled();
354
-		$this->enabled = $enabled;
355
-		if ($oldStatus !== $this->enabled) {
356
-			$this->triggerChange('enabled', $enabled);
357
-			$this->config->setUserValue($this->uid, 'core', 'enabled', $enabled ? 'true' : 'false');
358
-		}
359
-	}
360
-
361
-	/**
362
-	 * get the users email address
363
-	 *
364
-	 * @return string|null
365
-	 * @since 9.0.0
366
-	 */
367
-	public function getEMailAddress() {
368
-		return $this->config->getUserValue($this->uid, 'settings', 'email', null);
369
-	}
370
-
371
-	/**
372
-	 * get the users' quota
373
-	 *
374
-	 * @return string
375
-	 * @since 9.0.0
376
-	 */
377
-	public function getQuota() {
378
-		$quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default');
379
-		if($quota === 'default') {
380
-			$quota = $this->config->getAppValue('files', 'default_quota', 'none');
381
-		}
382
-		return $quota;
383
-	}
384
-
385
-	/**
386
-	 * set the users' quota
387
-	 *
388
-	 * @param string $quota
389
-	 * @return void
390
-	 * @since 9.0.0
391
-	 */
392
-	public function setQuota($quota) {
393
-		$oldQuota = $this->config->getUserValue($this->uid, 'files', 'quota', '');
394
-		if($quota !== 'none' and $quota !== 'default') {
395
-			$quota = OC_Helper::computerFileSize($quota);
396
-			$quota = OC_Helper::humanFileSize($quota);
397
-		}
398
-		$this->config->setUserValue($this->uid, 'files', 'quota', $quota);
399
-		if($quota !== $oldQuota) {
400
-			$this->triggerChange('quota', $quota);
401
-		}
402
-	}
403
-
404
-	/**
405
-	 * get the avatar image if it exists
406
-	 *
407
-	 * @param int $size
408
-	 * @return IImage|null
409
-	 * @since 9.0.0
410
-	 */
411
-	public function getAvatarImage($size) {
412
-		// delay the initialization
413
-		if (is_null($this->avatarManager)) {
414
-			$this->avatarManager = \OC::$server->getAvatarManager();
415
-		}
416
-
417
-		$avatar = $this->avatarManager->getAvatar($this->uid);
418
-		$image = $avatar->get(-1);
419
-		if ($image) {
420
-			return $image;
421
-		}
422
-
423
-		return null;
424
-	}
425
-
426
-	/**
427
-	 * get the federation cloud id
428
-	 *
429
-	 * @return string
430
-	 * @since 9.0.0
431
-	 */
432
-	public function getCloudId() {
433
-		$uid = $this->getUID();
434
-		$server = $this->urlGenerator->getAbsoluteURL('/');
435
-		$server =  rtrim( $this->removeProtocolFromUrl($server), '/');
436
-		return \OC::$server->getCloudIdManager()->getCloudId($uid, $server)->getId();
437
-	}
438
-
439
-	/**
440
-	 * @param string $url
441
-	 * @return string
442
-	 */
443
-	private function removeProtocolFromUrl($url) {
444
-		if (strpos($url, 'https://') === 0) {
445
-			return substr($url, strlen('https://'));
446
-		} else if (strpos($url, 'http://') === 0) {
447
-			return substr($url, strlen('http://'));
448
-		}
449
-
450
-		return $url;
451
-	}
452
-
453
-	public function triggerChange($feature, $value = null, $oldValue = null) {
454
-		if ($this->emitter) {
455
-			$this->emitter->emit('\OC\User', 'changeUser', array($this, $feature, $value, $oldValue));
456
-		}
457
-	}
47
+    /** @var string $uid */
48
+    private $uid;
49
+
50
+    /** @var string $displayName */
51
+    private $displayName;
52
+
53
+    /** @var UserInterface $backend */
54
+    private $backend;
55
+
56
+    /** @var bool $enabled */
57
+    private $enabled;
58
+
59
+    /** @var Emitter|Manager $emitter */
60
+    private $emitter;
61
+
62
+    /** @var string $home */
63
+    private $home;
64
+
65
+    /** @var int $lastLogin */
66
+    private $lastLogin;
67
+
68
+    /** @var \OCP\IConfig $config */
69
+    private $config;
70
+
71
+    /** @var IAvatarManager */
72
+    private $avatarManager;
73
+
74
+    /** @var IURLGenerator */
75
+    private $urlGenerator;
76
+
77
+    /**
78
+     * @param string $uid
79
+     * @param UserInterface $backend
80
+     * @param \OC\Hooks\Emitter $emitter
81
+     * @param IConfig|null $config
82
+     * @param IURLGenerator $urlGenerator
83
+     */
84
+    public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $urlGenerator = null) {
85
+        $this->uid = $uid;
86
+        $this->backend = $backend;
87
+        $this->emitter = $emitter;
88
+        if(is_null($config)) {
89
+            $config = \OC::$server->getConfig();
90
+        }
91
+        $this->config = $config;
92
+        $this->urlGenerator = $urlGenerator;
93
+        $enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true');
94
+        $this->enabled = ($enabled === 'true');
95
+        $this->lastLogin = $this->config->getUserValue($uid, 'login', 'lastLogin', 0);
96
+        if (is_null($this->urlGenerator)) {
97
+            $this->urlGenerator = \OC::$server->getURLGenerator();
98
+        }
99
+    }
100
+
101
+    /**
102
+     * get the user id
103
+     *
104
+     * @return string
105
+     */
106
+    public function getUID() {
107
+        return $this->uid;
108
+    }
109
+
110
+    /**
111
+     * get the display name for the user, if no specific display name is set it will fallback to the user id
112
+     *
113
+     * @return string
114
+     */
115
+    public function getDisplayName() {
116
+        if (!isset($this->displayName)) {
117
+            $displayName = '';
118
+            if ($this->backend and $this->backend->implementsActions(Backend::GET_DISPLAYNAME)) {
119
+                // get display name and strip whitespace from the beginning and end of it
120
+                $backendDisplayName = $this->backend->getDisplayName($this->uid);
121
+                if (is_string($backendDisplayName)) {
122
+                    $displayName = trim($backendDisplayName);
123
+                }
124
+            }
125
+
126
+            if (!empty($displayName)) {
127
+                $this->displayName = $displayName;
128
+            } else {
129
+                $this->displayName = $this->uid;
130
+            }
131
+        }
132
+        return $this->displayName;
133
+    }
134
+
135
+    /**
136
+     * set the displayname for the user
137
+     *
138
+     * @param string $displayName
139
+     * @return bool
140
+     */
141
+    public function setDisplayName($displayName) {
142
+        $displayName = trim($displayName);
143
+        if ($this->backend->implementsActions(Backend::SET_DISPLAYNAME) && !empty($displayName)) {
144
+            $result = $this->backend->setDisplayName($this->uid, $displayName);
145
+            if ($result) {
146
+                $this->displayName = $displayName;
147
+                $this->triggerChange('displayName', $displayName);
148
+            }
149
+            return $result !== false;
150
+        } else {
151
+            return false;
152
+        }
153
+    }
154
+
155
+    /**
156
+     * set the email address of the user
157
+     *
158
+     * @param string|null $mailAddress
159
+     * @return void
160
+     * @since 9.0.0
161
+     */
162
+    public function setEMailAddress($mailAddress) {
163
+        $oldMailAddress = $this->getEMailAddress();
164
+        if($mailAddress === '') {
165
+            $this->config->deleteUserValue($this->uid, 'settings', 'email');
166
+        } else {
167
+            $this->config->setUserValue($this->uid, 'settings', 'email', $mailAddress);
168
+        }
169
+        if($oldMailAddress !== $mailAddress) {
170
+            $this->triggerChange('eMailAddress', $mailAddress, $oldMailAddress);
171
+        }
172
+    }
173
+
174
+    /**
175
+     * returns the timestamp of the user's last login or 0 if the user did never
176
+     * login
177
+     *
178
+     * @return int
179
+     */
180
+    public function getLastLogin() {
181
+        return $this->lastLogin;
182
+    }
183
+
184
+    /**
185
+     * updates the timestamp of the most recent login of this user
186
+     */
187
+    public function updateLastLoginTimestamp() {
188
+        $firstTimeLogin = ($this->lastLogin === 0);
189
+        $this->lastLogin = time();
190
+        $this->config->setUserValue(
191
+            $this->uid, 'login', 'lastLogin', $this->lastLogin);
192
+
193
+        return $firstTimeLogin;
194
+    }
195
+
196
+    /**
197
+     * Delete the user
198
+     *
199
+     * @return bool
200
+     */
201
+    public function delete() {
202
+        if ($this->emitter) {
203
+            $this->emitter->emit('\OC\User', 'preDelete', array($this));
204
+        }
205
+        // get the home now because it won't return it after user deletion
206
+        $homePath = $this->getHome();
207
+        $result = $this->backend->deleteUser($this->uid);
208
+        if ($result) {
209
+
210
+            // FIXME: Feels like an hack - suggestions?
211
+
212
+            $groupManager = \OC::$server->getGroupManager();
213
+            // We have to delete the user from all groups
214
+            foreach ($groupManager->getUserGroupIds($this) as $groupId) {
215
+                $group = $groupManager->get($groupId);
216
+                if ($group) {
217
+                    \OC_Hook::emit("OC_Group", "pre_removeFromGroup", ["run" => true, "uid" => $this->uid, "gid" => $groupId]);
218
+                    $group->removeUser($this);
219
+                    \OC_Hook::emit("OC_User", "post_removeFromGroup", ["uid" => $this->uid, "gid" => $groupId]);
220
+                }
221
+            }
222
+            // Delete the user's keys in preferences
223
+            \OC::$server->getConfig()->deleteAllUserValues($this->uid);
224
+
225
+            // Delete user files in /data/
226
+            if ($homePath !== false) {
227
+                // FIXME: this operates directly on FS, should use View instead...
228
+                // also this is not testable/mockable...
229
+                \OC_Helper::rmdirr($homePath);
230
+            }
231
+
232
+            // Delete the users entry in the storage table
233
+            Storage::remove('home::' . $this->uid);
234
+
235
+            \OC::$server->getCommentsManager()->deleteReferencesOfActor('users', $this->uid);
236
+            \OC::$server->getCommentsManager()->deleteReadMarksFromUser($this);
237
+
238
+            $notification = \OC::$server->getNotificationManager()->createNotification();
239
+            $notification->setUser($this->uid);
240
+            \OC::$server->getNotificationManager()->markProcessed($notification);
241
+
242
+            /** @var AccountManager $accountManager */
243
+            $accountManager = \OC::$server->query(AccountManager::class);
244
+            $accountManager->deleteUser($this);
245
+
246
+            if ($this->emitter) {
247
+                $this->emitter->emit('\OC\User', 'postDelete', array($this));
248
+            }
249
+        }
250
+        return !($result === false);
251
+    }
252
+
253
+    /**
254
+     * Set the password of the user
255
+     *
256
+     * @param string $password
257
+     * @param string $recoveryPassword for the encryption app to reset encryption keys
258
+     * @return bool
259
+     */
260
+    public function setPassword($password, $recoveryPassword = null) {
261
+        if ($this->emitter) {
262
+            $this->emitter->emit('\OC\User', 'preSetPassword', array($this, $password, $recoveryPassword));
263
+        }
264
+        if ($this->backend->implementsActions(Backend::SET_PASSWORD)) {
265
+            $result = $this->backend->setPassword($this->uid, $password);
266
+            if ($this->emitter) {
267
+                $this->emitter->emit('\OC\User', 'postSetPassword', array($this, $password, $recoveryPassword));
268
+            }
269
+            return !($result === false);
270
+        } else {
271
+            return false;
272
+        }
273
+    }
274
+
275
+    /**
276
+     * get the users home folder to mount
277
+     *
278
+     * @return string
279
+     */
280
+    public function getHome() {
281
+        if (!$this->home) {
282
+            if ($this->backend->implementsActions(Backend::GET_HOME) and $home = $this->backend->getHome($this->uid)) {
283
+                $this->home = $home;
284
+            } elseif ($this->config) {
285
+                $this->home = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $this->uid;
286
+            } else {
287
+                $this->home = \OC::$SERVERROOT . '/data/' . $this->uid;
288
+            }
289
+        }
290
+        return $this->home;
291
+    }
292
+
293
+    /**
294
+     * Get the name of the backend class the user is connected with
295
+     *
296
+     * @return string
297
+     */
298
+    public function getBackendClassName() {
299
+        if($this->backend instanceof IUserBackend) {
300
+            return $this->backend->getBackendName();
301
+        }
302
+        return get_class($this->backend);
303
+    }
304
+
305
+    /**
306
+     * check if the backend allows the user to change his avatar on Personal page
307
+     *
308
+     * @return bool
309
+     */
310
+    public function canChangeAvatar() {
311
+        if ($this->backend->implementsActions(Backend::PROVIDE_AVATAR)) {
312
+            return $this->backend->canChangeAvatar($this->uid);
313
+        }
314
+        return true;
315
+    }
316
+
317
+    /**
318
+     * check if the backend supports changing passwords
319
+     *
320
+     * @return bool
321
+     */
322
+    public function canChangePassword() {
323
+        return $this->backend->implementsActions(Backend::SET_PASSWORD);
324
+    }
325
+
326
+    /**
327
+     * check if the backend supports changing display names
328
+     *
329
+     * @return bool
330
+     */
331
+    public function canChangeDisplayName() {
332
+        if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) {
333
+            return false;
334
+        }
335
+        return $this->backend->implementsActions(Backend::SET_DISPLAYNAME);
336
+    }
337
+
338
+    /**
339
+     * check if the user is enabled
340
+     *
341
+     * @return bool
342
+     */
343
+    public function isEnabled() {
344
+        return $this->enabled;
345
+    }
346
+
347
+    /**
348
+     * set the enabled status for the user
349
+     *
350
+     * @param bool $enabled
351
+     */
352
+    public function setEnabled(bool $enabled = true) {
353
+        $oldStatus = $this->isEnabled();
354
+        $this->enabled = $enabled;
355
+        if ($oldStatus !== $this->enabled) {
356
+            $this->triggerChange('enabled', $enabled);
357
+            $this->config->setUserValue($this->uid, 'core', 'enabled', $enabled ? 'true' : 'false');
358
+        }
359
+    }
360
+
361
+    /**
362
+     * get the users email address
363
+     *
364
+     * @return string|null
365
+     * @since 9.0.0
366
+     */
367
+    public function getEMailAddress() {
368
+        return $this->config->getUserValue($this->uid, 'settings', 'email', null);
369
+    }
370
+
371
+    /**
372
+     * get the users' quota
373
+     *
374
+     * @return string
375
+     * @since 9.0.0
376
+     */
377
+    public function getQuota() {
378
+        $quota = $this->config->getUserValue($this->uid, 'files', 'quota', 'default');
379
+        if($quota === 'default') {
380
+            $quota = $this->config->getAppValue('files', 'default_quota', 'none');
381
+        }
382
+        return $quota;
383
+    }
384
+
385
+    /**
386
+     * set the users' quota
387
+     *
388
+     * @param string $quota
389
+     * @return void
390
+     * @since 9.0.0
391
+     */
392
+    public function setQuota($quota) {
393
+        $oldQuota = $this->config->getUserValue($this->uid, 'files', 'quota', '');
394
+        if($quota !== 'none' and $quota !== 'default') {
395
+            $quota = OC_Helper::computerFileSize($quota);
396
+            $quota = OC_Helper::humanFileSize($quota);
397
+        }
398
+        $this->config->setUserValue($this->uid, 'files', 'quota', $quota);
399
+        if($quota !== $oldQuota) {
400
+            $this->triggerChange('quota', $quota);
401
+        }
402
+    }
403
+
404
+    /**
405
+     * get the avatar image if it exists
406
+     *
407
+     * @param int $size
408
+     * @return IImage|null
409
+     * @since 9.0.0
410
+     */
411
+    public function getAvatarImage($size) {
412
+        // delay the initialization
413
+        if (is_null($this->avatarManager)) {
414
+            $this->avatarManager = \OC::$server->getAvatarManager();
415
+        }
416
+
417
+        $avatar = $this->avatarManager->getAvatar($this->uid);
418
+        $image = $avatar->get(-1);
419
+        if ($image) {
420
+            return $image;
421
+        }
422
+
423
+        return null;
424
+    }
425
+
426
+    /**
427
+     * get the federation cloud id
428
+     *
429
+     * @return string
430
+     * @since 9.0.0
431
+     */
432
+    public function getCloudId() {
433
+        $uid = $this->getUID();
434
+        $server = $this->urlGenerator->getAbsoluteURL('/');
435
+        $server =  rtrim( $this->removeProtocolFromUrl($server), '/');
436
+        return \OC::$server->getCloudIdManager()->getCloudId($uid, $server)->getId();
437
+    }
438
+
439
+    /**
440
+     * @param string $url
441
+     * @return string
442
+     */
443
+    private function removeProtocolFromUrl($url) {
444
+        if (strpos($url, 'https://') === 0) {
445
+            return substr($url, strlen('https://'));
446
+        } else if (strpos($url, 'http://') === 0) {
447
+            return substr($url, strlen('http://'));
448
+        }
449
+
450
+        return $url;
451
+    }
452
+
453
+    public function triggerChange($feature, $value = null, $oldValue = null) {
454
+        if ($this->emitter) {
455
+            $this->emitter->emit('\OC\User', 'changeUser', array($this, $feature, $value, $oldValue));
456
+        }
457
+    }
458 458
 }
Please login to merge, or discard this patch.
lib/public/IUser.php 1 patch
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -34,170 +34,170 @@
 block discarded – undo
34 34
  */
35 35
 interface IUser {
36 36
 
37
-	/**
38
-	 * get the user id
39
-	 *
40
-	 * @return string
41
-	 * @since 8.0.0
42
-	 */
43
-	public function getUID();
44
-
45
-	/**
46
-	 * get the display name for the user, if no specific display name is set it will fallback to the user id
47
-	 *
48
-	 * @return string
49
-	 * @since 8.0.0
50
-	 */
51
-	public function getDisplayName();
52
-
53
-	/**
54
-	 * set the display name for the user
55
-	 *
56
-	 * @param string $displayName
57
-	 * @return bool
58
-	 * @since 8.0.0
59
-	 */
60
-	public function setDisplayName($displayName);
61
-
62
-	/**
63
-	 * returns the timestamp of the user's last login or 0 if the user did never
64
-	 * login
65
-	 *
66
-	 * @return int
67
-	 * @since 8.0.0
68
-	 */
69
-	public function getLastLogin();
70
-
71
-	/**
72
-	 * updates the timestamp of the most recent login of this user
73
-	 * @since 8.0.0
74
-	 */
75
-	public function updateLastLoginTimestamp();
76
-
77
-	/**
78
-	 * Delete the user
79
-	 *
80
-	 * @return bool
81
-	 * @since 8.0.0
82
-	 */
83
-	public function delete();
84
-
85
-	/**
86
-	 * Set the password of the user
87
-	 *
88
-	 * @param string $password
89
-	 * @param string $recoveryPassword for the encryption app to reset encryption keys
90
-	 * @return bool
91
-	 * @since 8.0.0
92
-	 */
93
-	public function setPassword($password, $recoveryPassword = null);
94
-
95
-	/**
96
-	 * get the users home folder to mount
97
-	 *
98
-	 * @return string
99
-	 * @since 8.0.0
100
-	 */
101
-	public function getHome();
102
-
103
-	/**
104
-	 * Get the name of the backend class the user is connected with
105
-	 *
106
-	 * @return string
107
-	 * @since 8.0.0
108
-	 */
109
-	public function getBackendClassName();
110
-
111
-	/**
112
-	 * check if the backend allows the user to change his avatar on Personal page
113
-	 *
114
-	 * @return bool
115
-	 * @since 8.0.0
116
-	 */
117
-	public function canChangeAvatar();
118
-
119
-	/**
120
-	 * check if the backend supports changing passwords
121
-	 *
122
-	 * @return bool
123
-	 * @since 8.0.0
124
-	 */
125
-	public function canChangePassword();
126
-
127
-	/**
128
-	 * check if the backend supports changing display names
129
-	 *
130
-	 * @return bool
131
-	 * @since 8.0.0
132
-	 */
133
-	public function canChangeDisplayName();
134
-
135
-	/**
136
-	 * check if the user is enabled
137
-	 *
138
-	 * @return bool
139
-	 * @since 8.0.0
140
-	 */
141
-	public function isEnabled();
142
-
143
-	/**
144
-	 * set the enabled status for the user
145
-	 *
146
-	 * @param bool $enabled
147
-	 * @since 8.0.0
148
-	 */
149
-	public function setEnabled(bool $enabled = true);
150
-
151
-	/**
152
-	 * get the users email address
153
-	 *
154
-	 * @return string|null
155
-	 * @since 9.0.0
156
-	 */
157
-	public function getEMailAddress();
158
-
159
-	/**
160
-	 * get the avatar image if it exists
161
-	 *
162
-	 * @param int $size
163
-	 * @return IImage|null
164
-	 * @since 9.0.0
165
-	 */
166
-	public function getAvatarImage($size);
167
-
168
-	/**
169
-	 * get the federation cloud id
170
-	 *
171
-	 * @return string
172
-	 * @since 9.0.0
173
-	 */
174
-	public function getCloudId();
175
-
176
-	/**
177
-	 * set the email address of the user
178
-	 *
179
-	 * @param string|null $mailAddress
180
-	 * @return void
181
-	 * @since 9.0.0
182
-	 */
183
-	public function setEMailAddress($mailAddress);
184
-
185
-	/**
186
-	 * get the users' quota in human readable form. If a specific quota is not
187
-	 * set for the user, the default value is returned. If a default setting
188
-	 * was not set otherwise, it is return as 'none', i.e. quota is not limited.
189
-	 *
190
-	 * @return string
191
-	 * @since 9.0.0
192
-	 */
193
-	public function getQuota();
194
-
195
-	/**
196
-	 * set the users' quota
197
-	 *
198
-	 * @param string $quota
199
-	 * @return void
200
-	 * @since 9.0.0
201
-	 */
202
-	public function setQuota($quota);
37
+    /**
38
+     * get the user id
39
+     *
40
+     * @return string
41
+     * @since 8.0.0
42
+     */
43
+    public function getUID();
44
+
45
+    /**
46
+     * get the display name for the user, if no specific display name is set it will fallback to the user id
47
+     *
48
+     * @return string
49
+     * @since 8.0.0
50
+     */
51
+    public function getDisplayName();
52
+
53
+    /**
54
+     * set the display name for the user
55
+     *
56
+     * @param string $displayName
57
+     * @return bool
58
+     * @since 8.0.0
59
+     */
60
+    public function setDisplayName($displayName);
61
+
62
+    /**
63
+     * returns the timestamp of the user's last login or 0 if the user did never
64
+     * login
65
+     *
66
+     * @return int
67
+     * @since 8.0.0
68
+     */
69
+    public function getLastLogin();
70
+
71
+    /**
72
+     * updates the timestamp of the most recent login of this user
73
+     * @since 8.0.0
74
+     */
75
+    public function updateLastLoginTimestamp();
76
+
77
+    /**
78
+     * Delete the user
79
+     *
80
+     * @return bool
81
+     * @since 8.0.0
82
+     */
83
+    public function delete();
84
+
85
+    /**
86
+     * Set the password of the user
87
+     *
88
+     * @param string $password
89
+     * @param string $recoveryPassword for the encryption app to reset encryption keys
90
+     * @return bool
91
+     * @since 8.0.0
92
+     */
93
+    public function setPassword($password, $recoveryPassword = null);
94
+
95
+    /**
96
+     * get the users home folder to mount
97
+     *
98
+     * @return string
99
+     * @since 8.0.0
100
+     */
101
+    public function getHome();
102
+
103
+    /**
104
+     * Get the name of the backend class the user is connected with
105
+     *
106
+     * @return string
107
+     * @since 8.0.0
108
+     */
109
+    public function getBackendClassName();
110
+
111
+    /**
112
+     * check if the backend allows the user to change his avatar on Personal page
113
+     *
114
+     * @return bool
115
+     * @since 8.0.0
116
+     */
117
+    public function canChangeAvatar();
118
+
119
+    /**
120
+     * check if the backend supports changing passwords
121
+     *
122
+     * @return bool
123
+     * @since 8.0.0
124
+     */
125
+    public function canChangePassword();
126
+
127
+    /**
128
+     * check if the backend supports changing display names
129
+     *
130
+     * @return bool
131
+     * @since 8.0.0
132
+     */
133
+    public function canChangeDisplayName();
134
+
135
+    /**
136
+     * check if the user is enabled
137
+     *
138
+     * @return bool
139
+     * @since 8.0.0
140
+     */
141
+    public function isEnabled();
142
+
143
+    /**
144
+     * set the enabled status for the user
145
+     *
146
+     * @param bool $enabled
147
+     * @since 8.0.0
148
+     */
149
+    public function setEnabled(bool $enabled = true);
150
+
151
+    /**
152
+     * get the users email address
153
+     *
154
+     * @return string|null
155
+     * @since 9.0.0
156
+     */
157
+    public function getEMailAddress();
158
+
159
+    /**
160
+     * get the avatar image if it exists
161
+     *
162
+     * @param int $size
163
+     * @return IImage|null
164
+     * @since 9.0.0
165
+     */
166
+    public function getAvatarImage($size);
167
+
168
+    /**
169
+     * get the federation cloud id
170
+     *
171
+     * @return string
172
+     * @since 9.0.0
173
+     */
174
+    public function getCloudId();
175
+
176
+    /**
177
+     * set the email address of the user
178
+     *
179
+     * @param string|null $mailAddress
180
+     * @return void
181
+     * @since 9.0.0
182
+     */
183
+    public function setEMailAddress($mailAddress);
184
+
185
+    /**
186
+     * get the users' quota in human readable form. If a specific quota is not
187
+     * set for the user, the default value is returned. If a default setting
188
+     * was not set otherwise, it is return as 'none', i.e. quota is not limited.
189
+     *
190
+     * @return string
191
+     * @since 9.0.0
192
+     */
193
+    public function getQuota();
194
+
195
+    /**
196
+     * set the users' quota
197
+     *
198
+     * @param string $quota
199
+     * @return void
200
+     * @since 9.0.0
201
+     */
202
+    public function setQuota($quota);
203 203
 }
Please login to merge, or discard this patch.