<commit_before><?php
namespace OCA\User_Account_Actions\Hooks;

class UserHooks {

    protected $userManager;
    protected $mailAction;
    protected $fileAction;

    public function __construct($userManager, $mailAction, $fileAction){
        $this->userManager = $userManager;
        $this->mailAction = $mailAction;
        $this->fileAction = $fileAction;

    }

    public function postCreateUser(\OC\User\User $user) {
        $this->mailAction->mailUserCreation($user);
    }

    public function preDeleteUser(\OC\User\User $user) {
        $this->fileAction->saveUserFiles($user);
    }

    public function postDeleteUser(\OC\User\User $user) {
        $this->mailAction->mailUserDeletion($user);
    }

    public function register() {
        $myself = $this;

        $this->userManager->listen('\OC\User', 'preDelete', function(\OC\User\User $user) use ($myself) {
            return $this->preDeleteUser($user);
        });

        $this->userManager->listen('\OC\User', 'postDelete', function(\OC\User\User $user) use ($myself) {<commit_msg>Feature - #3576 - Mantis 40758 - Ajout comportement a la creation d'un compte local<commit_after><?php
namespace OCA\User_Account_Actions\Hooks;

class UserHooks {

    protected $userManager;
    protected $mailAction;
    protected $fileAction;

    public function __construct($userManager, $mailAction, $fileAction){
        $this->userManager = $userManager;
        $this->mailAction = $mailAction;
        $this->fileAction = $fileAction;

    }

    public function postCreateUser(\OC\User\User $user) {
        $this->mailAction->mailUserCreation($user);

        // if user's uid (username) is a email, additional treatments :
        if(filter_var($user->getUID(), FILTER_VALIDATE_EMAIL)) {

            // add the email on oc_preferences
            \OC_Preferences::setValue($user->getUID(), 'settings', 'email', $user->getUID());

            // add the IsLocal on oc_preferences to know the user's account's type
            \OC_Preferences::setValue($user->getUID(), 'settings', 'IsLocal', TRUE);
        }
    }

    public function preDeleteUser(\OC\User\User $user) {
        $this->fileAction->saveUserFiles($user);
    }

    public function postDeleteUser(\OC\User\User $user) {
        $this->mailAction->mailUserDeletion($user);
    }

    public function register() {
        $myself = $this;

        $this->userManager->listen('\OC\User', 'preDelete', function(\OC\User\User $user) use ($myself) {
            return $this->preDeleteUser($user);
        });

        $this->userManager->listen('\OC\User', 'postDelete', function(\OC\User\User $user) use ($myself) {
{'fraction_non_alphanumeric': 0.14576271186440679, 'fraction_numerical': 0.003389830508474576, 'mean_word_length': 3.0364741641337387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '467390', 'n_tokens_mistral': 801, 'n_tokens_neox': 774, 'n_words': 158}