selfhosted/controllers/SiteController.php
/**
     * Displays contact page.
     * @return string|Response
     * @throws BadRequestHttpException
     */
Displays contact page.
@return string|Response
@throws BadRequestHttpException
Displays contact page . @return string|Response @throws BadRequestHttpException
public function actionSupport()
    {
        if ($this->model_contact->load(Yii::$app->request->post())) {
            if ($this->model_contact->validate()) {
                $cnt = Yii::$app->cache->get(Yii::$app->params['ContactCacheKey']);
                if (!$cnt) {
                    $cnt = 1;
                } else {
                    $cnt++;
                }
                Yii::$app->cache->set(Yii::$app->params['ContactCacheKey'], $cnt);
                if ($this->model_contact->sendEmail()) {
                    Yii::$app->session->setFlash('success', [
                        'message' => Yii::t('app/flash-messages', 'Support_success'),
                        'ttl' => FLASH_MESSAGES_TTL,
                        'showClose' => true,
                        'alert_action' => 'actionSupport',
                    ]);
                } else {
                    Yii::$app->session->setFlash('error', [
                        'message' => Yii::t('app/flash-messages', 'Support_error'),
                        'ttl' => FLASH_MESSAGES_TTL,
                        'showClose' => true,
                        'alert_action' => 'actionSupport',
                    ]);
                }
                return $this->refresh();
            } else {
                throw new BadRequestHttpException('Wrong form data');
            }
        } else {
            return $this->render('support', [
                'model' => $this->model_contact,
            ]);
        }
    }
public function actionSupport ( ) { if ( $ this -> model_contact -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ this -> model_contact -> validate ( ) ) { $ cnt = Yii :: $ app -> cache -> get ( Yii :: $ app -> params [ 'ContactCacheKey' ] ) ; if ( ! $ cnt ) { $ cnt = 1 ; } else { $ cnt ++ ; } Yii :: $ app -> cache -> set ( Yii :: $ app -> params [ 'ContactCacheKey' ] , $ cnt ) ; if ( $ this -> model_contact -> sendEmail ( ) ) { Yii :: $ app -> session -> setFlash ( 'success' , [ 'message' => Yii :: t ( 'app/flash-messages' , 'Support_success' ) , 'ttl' => FLASH_MESSAGES_TTL , 'showClose' => true , 'alert_action' => 'actionSupport' , ] ) ; } else { Yii :: $ app -> session -> setFlash ( 'error' , [ 'message' => Yii :: t ( 'app/flash-messages' , 'Support_error' ) , 'ttl' => FLASH_MESSAGES_TTL , 'showClose' => true , 'alert_action' => 'actionSupport' , ] ) ; } return $ this -> refresh ( ) ; } else { throw new BadRequestHttpException ( 'Wrong form data' ) ; } } else { return $ this -> render ( 'support' , [ 'model' => $ this -> model_contact , ] ) ; } }
Displays contact page.
Displays contact page .