Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
94: Hook for user deletion and minor fixes
- Loading branch information
Janis Koehr
committed
Jul 23, 2017
1 parent
790a9f4
commit 0a6d1ed
Showing
17 changed files
with
211 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* Nextcloud - OCR | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. | ||
* See the COPYING file. | ||
* | ||
* @author Janis Koehr <janiskoehr@icloud.com> | ||
* @copyright Janis Koehr 2017 | ||
*/ | ||
namespace OCA\Ocr\Hooks; | ||
|
||
use OCP\IUserManager; | ||
use OCA\Ocr\Db\OcrJobMapper; | ||
use OCP\ILogger; | ||
|
||
|
||
/** | ||
* Class UserHooks | ||
* | ||
* @package OCA\Ocr\Hooks | ||
*/ | ||
class UserHooks { | ||
|
||
/** | ||
* | ||
* @var IUserManager | ||
*/ | ||
private $userManager; | ||
|
||
/** | ||
* | ||
* @var OcrJobMapper | ||
*/ | ||
private $ocrJobMapper; | ||
|
||
/** | ||
* | ||
* @var ILogger | ||
*/ | ||
private $logger; | ||
|
||
public function __construct(IUserManager $userManager, OcrJobMapper $ocrJobMapper, ILogger $logger) { | ||
$this->userManager = $userManager; | ||
$this->ocrJobMapper = $ocrJobMapper; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* Registers the user hooks. | ||
*/ | ||
public function register() { | ||
$postDelete = function ($user) { | ||
$this->logger->debug('Deleting all jobs for user "{user}" after user deletion (Hook).', [ | ||
'user' => $user->getUID() | ||
]); | ||
$this->ocrJobMapper->deleteAllForUser($user->getUID()); | ||
}; | ||
$this->userManager->listen('\OC\User', 'postDelete', $postDelete); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.