diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-05-29 01:05:49 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-05-29 01:05:49 +0200 |
commit | 8320f41dbe463020423c3fe8d2368bc8d415750a (patch) | |
tree | 803d038d9a902efd77fe8ead242d61cd8fdfe2b0 | |
parent | 3e7e2c8a5c5eb51d04302520f1367125c98644bd (diff) | |
download | nextcloud-server-8320f41dbe463020423c3fe8d2368bc8d415750a.tar.gz nextcloud-server-8320f41dbe463020423c3fe8d2368bc8d415750a.zip |
Emit leacgy OC_User hooks
-rw-r--r-- | lib/user.php | 31 | ||||
-rw-r--r-- | lib/user/manager.php | 12 |
2 files changed, 35 insertions, 8 deletions
diff --git a/lib/user.php b/lib/user.php index efae4f9aa36..cab7bee5c00 100644 --- a/lib/user.php +++ b/lib/user.php @@ -30,8 +30,8 @@ * post_createUser(uid, password) * pre_deleteUser(&run, uid) * post_deleteUser(uid) - * pre_setPassword(&run, uid, password) - * post_setPassword(uid, password) + * pre_setPassword(&run, uid, password, recoveryPassword) + * post_setPassword(uid, password, recoveryPassword) * pre_login(&run, uid, password) * post_login(uid) * logout() @@ -43,6 +43,33 @@ class OC_User { if (!self::$userSession) { $manager = new \OC\User\Manager(); self::$userSession = new \OC\User\Session($manager, \OC::$session); + self::$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { + \OC_Hook::emit('OC_User', 'pre_createUser', array("run" => true, "uid" => $uid, "password" => $password)); + }); + self::$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { + \OC_Hook::emit('OC_User', 'post_createUser', array("uid" => $user->getUID(), "password" => $password)); + }); + self::$userSession->listen('\OC\User', 'preDelete', function ($user) { + \OC_Hook::emit('OC_User', 'pre_deleteUser', array("run" => true, "uid" => $user->getUID())); + }); + self::$userSession->listen('\OC\User', 'postDelete', function ($user) { + \OC_Hook::emit('OC_User', 'post_deleteUser', array("uid" => $user->getUID())); + }); + self::$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { + OC_Hook::emit("OC_User", "pre_setPassword", array("run" => &$run, "uid" => $user->getUID(), "password" => $password, "recoveryPassword" => $recoveryPassword)); + }); + self::$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { + OC_Hook::emit("OC_User", "post_setPassword", array("run" => &$run, "uid" => $user->getUID(), "password" => $password, "recoveryPassword" => $recoveryPassword)); + }); + self::$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { + \OC_Hook::emit('OC_User', 'pre_login', array("run" => true, "uid" => $uid, "password" => $password)); + }); + self::$userSession->listen('\OC\User', 'preDeleteUser', function ($user, $password) { + \OC_Hook::emit('OC_User', 'post_login', array("run" => true, "uid" => $user->getUID(), "password" => $password)); + }); + self::$userSession->listen('\OC\User', 'logout', function () { + \OC_Hook::emit('OC_User', 'logout', array()); + }); } return self::$userSession; } diff --git a/lib/user/manager.php b/lib/user/manager.php index 25e67ca36b5..260d0d32dea 100644 --- a/lib/user/manager.php +++ b/lib/user/manager.php @@ -20,7 +20,7 @@ use OC\Hooks\PublicEmitter; * - preDelete(\OC\User\User $user) * - postDelete(\OC\User\User $user) * - preCreateUser(string $uid, string $password) - * - postCreateUser(\OC\User\User $user) + * - postCreateUser(\OC\User\User $user, string $password) * * @package OC\User */ @@ -57,7 +57,7 @@ class Manager extends PublicEmitter { public function get($uid) { foreach ($this->backends as $backend) { if ($backend->userExists($uid)) { - return new User($uid, $backend); + return new User($uid, $backend, $this); } } return null; @@ -90,7 +90,7 @@ class Manager extends PublicEmitter { $backendUsers = $backend->getUsers($pattern, $limit, $offset); if (is_array($backendUsers)) { foreach ($backendUsers as $uid) { - $users[] = new User($uid, $backend); + $users[] = new User($uid, $backend, $this); if (!is_null($limit)) { $limit--; } @@ -126,7 +126,7 @@ class Manager extends PublicEmitter { $backendUsers = $backend->getDisplayNames($pattern, $limit, $offset); if (is_array($backendUsers)) { foreach ($backendUsers as $uid => $displayName) { - $users[] = new User($uid, $backend); + $users[] = new User($uid, $backend, $this); if (!is_null($limit)) { $limit--; } @@ -179,8 +179,8 @@ class Manager extends PublicEmitter { foreach ($this->backends as $backend) { if ($backend->implementsActions(\OC_USER_BACKEND_CREATE_USER)) { $backend->createUser($uid, $password); - $user = new User($uid, $backend); - $this->emit('\OC\User', 'postCreateUser', array($user)); + $user = new User($uid, $backend, $this); + $this->emit('\OC\User', 'postCreateUser', array($user, $password)); return $user; } } |