frontend/controllers/UserController.php
/**
     * Send share link to email
     * @return mixed
     */
Send share link to email
@return mixed
Send share link to email @return mixed
public function actionShareSendToEmail()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        $model = new ShareElementForm();
        if ($model->load(['ShareElementForm' => $_POST], 'ShareElementForm') && $model->validate()) {
            $UserFile = UserFiles::findOne(['share_hash' => $model->share_hash]);
            $user = $this->User;
            if ($UserFile && $UserFile->user_id == $user->user_id) {
                $UserTo = Users::findByEmail($model->share_email);
                MailTemplatesStatic::sendByKey(MailTemplatesStatic::template_key_ShareSendToEmail, $model->share_email, ['UserObject' => $UserTo, 'UserFileObject' => $UserFile]);
                return ['status' => true, 'info' => "OK"];
            }
            return ['status' => false, 'info' => 'Share not found.'];
        }
        return ['status' => false, 'info' => 'Validation error.'];
    }
public function actionShareSendToEmail ( ) { Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; $ model = new ShareElementForm ( ) ; if ( $ model -> load ( [ 'ShareElementForm' => $ _POST ] , 'ShareElementForm' ) && $ model -> validate ( ) ) { $ UserFile = UserFiles :: findOne ( [ 'share_hash' => $ model -> share_hash ] ) ; $ user = $ this -> User ; if ( $ UserFile && $ UserFile -> user_id == $ user -> user_id ) { $ UserTo = Users :: findByEmail ( $ model -> share_email ) ; MailTemplatesStatic :: sendByKey ( MailTemplatesStatic :: template_key_ShareSendToEmail , $ model -> share_email , [ 'UserObject' => $ UserTo , 'UserFileObject' => $ UserFile ] ) ; return [ 'status' => true , 'info' => " OK " ] ; } return [ 'status' => false , 'info' => 'Share not found.' ] ; } return [ 'status' => false , 'info' => 'Validation error.' ] ; }
Send share link to email
 @return mixed
Send share link to email @return mixed
/** @var \common\models\Users $user */ /*
                Yii::$app->session->setFlash('success', [
                    'message'   => Yii::t('app/flash-messages', 'ShareSendToEmail_success'),
                    'ttl'       => FLASH_MESSAGES_TTL,
                    'showClose' => true,
                    'alert_action' => 'actionShareSendToEmail',
                ]);
                */