selfhosted/models/forms/SignupForm.php
/**
     * Signs user up.
     *
     * @return Users|null the saved model or null if saving fails
     */
Signs user up.
@return Users|null the saved model or null if saving fails
Signs user up . @return Users|null the saved model or null if saving fails
public function signup()
    {
        $user              = new SelfHostUsers();
        $user->shu_company = $this->shu_company;
        $user->shu_name    = $this->shu_name;
        $user->shu_email   = $this->shu_email;
        $user->shu_status  = SelfHostUsers::STATUS_ACTIVE;
        $user->shu_role    = SelfHostUsers::ROLE_ROOT;
        $user->shu_support_status = ($this->shu_support_status) ? SelfHostUsers::ENABLED : SelfHostUsers::DISABLED;
        $user->shu_brand_status   = ($this->shu_brand_status) ? SelfHostUsers::ENABLED : SelfHostUsers::DISABLED;
        $user->license_count_available = SelfHostUsers::MAX_AVAILABLE_LICENSES - 1;
        $user->license_count_used = 1;
        $user->shu_promo_code = $this->promo_code;
        $user->setPassword($this->password);
        $user->generateAuthKey();
        $user->generatePasswordResetToken();
        if ($user->save()) {
            if ($user->shu_support_status || $user->shu_brand_status) {
                if ($user->shu_support_status) {
                    $user->shu_support_requested = SelfHostUsers::YES;
                }
                if ($user->shu_brand_status) {
                    $user->shu_brand_requested = SelfHostUsers::YES;
                }
                $user->requestSupportOrBrand();
            } else {
                $cache_key = 'shu-email-with-link-sent-' . $user->shu_id;
                Yii::$app->cache->set($cache_key, time(), Yii::$app->params['timeout_resend_confirm']);
                MailTemplatesStatic::sendByKey(MailTemplatesStatic::template_key_newShuDownload, $user->shu_email, [
                    'user_name' => $user->shu_name,
                    'user_email' => $user->shu_email,
                    'user_key'   => $user->shu_user_hash,
                    'download_shu_link' => Yii::$app->urlManager->createAbsoluteUrl(['/download_shu_link']),
                ]);
            }
            return [
                'user' => $user,
                'free' => (int) (!$user->shu_support_status && !$user->shu_brand_status),
            ];
        }
        return null;
    }
public function signup ( ) { $ user = new SelfHostUsers ( ) ; $ user -> shu_company = $ this -> shu_company ; $ user -> shu_name = $ this -> shu_name ; $ user -> shu_email = $ this -> shu_email ; $ user -> shu_status = SelfHostUsers :: STATUS_ACTIVE ; $ user -> shu_role = SelfHostUsers :: ROLE_ROOT ; $ user -> shu_support_status = ( $ this -> shu_support_status ) ? SelfHostUsers :: ENABLED : SelfHostUsers :: DISABLED ; $ user -> shu_brand_status = ( $ this -> shu_brand_status ) ? SelfHostUsers :: ENABLED : SelfHostUsers :: DISABLED ; $ user -> license_count_available = SelfHostUsers :: MAX_AVAILABLE_LICENSES - 1 ; $ user -> license_count_used = 1 ; $ user -> shu_promo_code = $ this -> promo_code ; $ user -> setPassword ( $ this -> password ) ; $ user -> generateAuthKey ( ) ; $ user -> generatePasswordResetToken ( ) ; if ( $ user -> save ( ) ) { if ( $ user -> shu_support_status || $ user -> shu_brand_status ) { if ( $ user -> shu_support_status ) { $ user -> shu_support_requested = SelfHostUsers :: YES ; } if ( $ user -> shu_brand_status ) { $ user -> shu_brand_requested = SelfHostUsers :: YES ; } $ user -> requestSupportOrBrand ( ) ; } else { $ cache_key = 'shu-email-with-link-sent-' . $ user -> shu_id ; Yii :: $ app -> cache -> set ( $ cache_key , time ( ) , Yii :: $ app -> params [ 'timeout_resend_confirm' ] ) ; MailTemplatesStatic :: sendByKey ( MailTemplatesStatic :: template_key_newShuDownload , $ user -> shu_email , [ 'user_name' => $ user -> shu_name , 'user_email' => $ user -> shu_email , 'user_key' => $ user -> shu_user_hash , 'download_shu_link' => Yii :: $ app -> urlManager -> createAbsoluteUrl ( [ '/download_shu_link' ] ) , ] ) ; } return [ 'user' => $ user , 'free' => ( int ) ( ! $ user -> shu_support_status && ! $ user -> shu_brand_status ) , ] ; } return null ; }
Signs user up.
Signs user up .
//            MailTemplatesStatic::sendByKey(MailTemplatesStatic::template_key_newShuRegister, $user->shu_email, [ //                'user_name'  => $user->shu_name, //                'user_email' => $user->shu_email, //                'user_key'   => $user->shu_user_hash, //                'confirm_registration_link' => Yii::$app->urlManager->createAbsoluteUrl(['user/confirm-registration', 'token' => $user->password_reset_token]), //            ]); // емейл со ссылкой не отправляем и ставим флеш-мессадж о том что с ним скоро свяжутся // отправляем емейл со сслкой на скачивание архива и ставим об этом флеш-мессадж