diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-23 23:57:20 +0100 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-25 10:26:48 +0100 |
commit | 0de685c5629deb66984e536e5fd20f140228aa3f (patch) | |
tree | 7386419957b1faecca0be50a56427fa531166857 /lib/private/Accounts | |
parent | 3fc75073b80a3ffedbcd127e9e75edf567f245a5 (diff) | |
download | nextcloud-server-0de685c5629deb66984e536e5fd20f140228aa3f.tar.gz nextcloud-server-0de685c5629deb66984e536e5fd20f140228aa3f.zip |
bring back setEmailAddress for the user management
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'lib/private/Accounts')
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 4 | ||||
-rw-r--r-- | lib/private/Accounts/Hooks.php | 36 |
2 files changed, 28 insertions, 12 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 8c7cd010de1..3701421a20f 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -23,7 +23,6 @@ namespace OC\Accounts; -use OCP\IConfig; use OCP\IDBConnection; use OCP\IUser; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -63,9 +62,6 @@ class AccountManager { /** @var EventDispatcherInterface */ private $eventDispatcher; - /** @var IConfig */ - private $config; - /** * AccountManager constructor. * diff --git a/lib/private/Accounts/Hooks.php b/lib/private/Accounts/Hooks.php index 187024e5472..38e7e20485b 100644 --- a/lib/private/Accounts/Hooks.php +++ b/lib/private/Accounts/Hooks.php @@ -22,6 +22,7 @@ namespace OC\Accounts; +use OCP\ILogger; use OCP\IUser; class Hooks { @@ -29,6 +30,18 @@ class Hooks { /** @var AccountManager */ private $accountManager = null; + /** @var ILogger */ + private $logger; + + /** + * Hooks constructor. + * + * @param ILogger $logger + */ + public function __construct(ILogger $logger) { + $this->logger = $logger; + } + /** * update accounts table if email address or display name was changed from outside * @@ -36,25 +49,31 @@ class Hooks { */ public function changeUserHook($params) { - $this->instantiateAccountManager(); + $accountManager = $this->getAccountManager(); /** @var IUser $user */ - $user = $params['user']; - $feature = $params['feature']; - $newValue = $params['value']; - $accountData = $this->accountManager->getUser($user); + $user = isset($params['user']) ? $params['user'] : null; + $feature = isset($params['feature']) ? $params['feature'] : null; + $newValue = isset($params['value']) ? $params['value'] : null; + + if (is_null($user) || is_null($feature) || is_null($newValue)) { + $this->logger->warning('Missing expected parameters in change user hook'); + return; + } + + $accountData = $accountManager->getUser($user); switch ($feature) { case 'eMailAddress': if ($accountData[AccountManager::PROPERTY_EMAIL]['value'] !== $newValue) { $accountData[AccountManager::PROPERTY_EMAIL]['value'] = $newValue; - $this->accountManager->updateUser($user, $accountData); + $accountManager->updateUser($user, $accountData); } break; case 'displayName': if ($accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] !== $newValue) { $accountData[AccountManager::PROPERTY_DISPLAYNAME]['value'] = $newValue; - $this->accountManager->updateUser($user, $accountData); + $accountManager->updateUser($user, $accountData); } break; } @@ -66,13 +85,14 @@ class Hooks { * * @return AccountManager */ - protected function instantiateAccountManager() { + protected function getAccountManager() { if (is_null($this->accountManager)) { $this->accountManager = new AccountManager( \OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher() ); } + return $this->accountManager; } } |