frontend/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 Users();
        $user->user_name       = $this->user_name
            ? $this->user_name
            : Functions::getNameFromEmail($this->user_email);
        $user->user_email      = $this->user_email;
        $user->license_type    = Licenses::TYPE_FREE_TRIAL;
        $user->license_expire  = date(SQL_DATE_FORMAT, time() + Licenses::getCountDaysTrialLicense() * 86400);
        $user->user_last_ip    = Yii::$app->request->getUserIP();
        $user->user_ref_id     = Yii::$app->request->cookies->getValue('ref', null);
        $user->user_promo_code = $this->promo_code;
        if (Yii::$app->params['self_hosted']) {
            $user->user_status = Users::STATUS_CONFIRMED;
        }
        $user->setPassword($this->password);
        $user->generateAuthKey();
        $user->generatePasswordResetToken();
        if ($user->save()) {
            $UserNode = NodeApi::registerNodeFM($user);
            if ($UserNode) {
                $UserNode->node_online = UserNode::ONLINE_ON;
                $UserNode->node_useragent = Yii::$app->request->getUserAgent();
                $UserNode->node_osname = Functions::getOsExtendedByUserAgent($UserNode->node_useragent);
                $UserNode->node_ostype = Functions::getOsTypeByUserAgent($UserNode->node_useragent);
                $UserNode->save();
            }
            $session = new Sessions();
            $session->user_id = $user->user_id;
            $session->node_id = $UserNode->node_id;
            $session->sess_action = Sessions::ACTION_REGISTER;
            $session->save();
            MailTemplatesStatic::sendByKey(MailTemplatesStatic::template_key_newRegister, $user->user_email, ['UserObject' => $user]);
            return $user;
        }
        return null;
    }
public function signup ( ) { $ user = new Users ( ) ; $ user -> user_name = $ this -> user_name ? $ this -> user_name : Functions :: getNameFromEmail ( $ this -> user_email ) ; $ user -> user_email = $ this -> user_email ; $ user -> license_type = Licenses :: TYPE_FREE_TRIAL ; $ user -> license_expire = date ( SQL_DATE_FORMAT , time ( ) + Licenses :: getCountDaysTrialLicense ( ) * 86400 ) ; $ user -> user_last_ip = Yii :: $ app -> request -> getUserIP ( ) ; $ user -> user_ref_id = Yii :: $ app -> request -> cookies -> getValue ( 'ref' , null ) ; $ user -> user_promo_code = $ this -> promo_code ; if ( Yii :: $ app -> params [ 'self_hosted' ] ) { $ user -> user_status = Users :: STATUS_CONFIRMED ; } $ user -> setPassword ( $ this -> password ) ; $ user -> generateAuthKey ( ) ; $ user -> generatePasswordResetToken ( ) ; if ( $ user -> save ( ) ) { $ UserNode = NodeApi :: registerNodeFM ( $ user ) ; if ( $ UserNode ) { $ UserNode -> node_online = UserNode :: ONLINE_ON ; $ UserNode -> node_useragent = Yii :: $ app -> request -> getUserAgent ( ) ; $ UserNode -> node_osname = Functions :: getOsExtendedByUserAgent ( $ UserNode -> node_useragent ) ; $ UserNode -> node_ostype = Functions :: getOsTypeByUserAgent ( $ UserNode -> node_useragent ) ; $ UserNode -> save ( ) ; } $ session = new Sessions ( ) ; $ session -> user_id = $ user -> user_id ; $ session -> node_id = $ UserNode -> node_id ; $ session -> sess_action = Sessions :: ACTION_REGISTER ; $ session -> save ( ) ; MailTemplatesStatic :: sendByKey ( MailTemplatesStatic :: template_key_newRegister , $ user -> user_email , [ 'UserObject' => $ user ] ) ; return $ user ; } return null ; }
Signs user up.
Signs user up .
//var_dump($this->validate()); var_dump($this->getErrors()); exit; //$user->user_status = Users::STATUS_BLOCKED;