Пример #1
0
 public function processCode($fullCode)
 {
     $code = $fullCode['code'];
     $original = $fullCode['original'];
     if ($this->isCodeActive($code)) {
         $group = Group::findOne($code->z_p_id)->toArray();
         $bank = Bank::findOne($code->z_b_id)->toArray();
         $form = Form::findOne(['f_klasse' => $bank['klasse'], 'f_p_id' => $group['p_id']]);
         $style = Style::findOne(['s_b_id' => $bank['b_id'], 's_p_id' => $group['p_id']]);
         if (!$style) {
             $style = Settings::getSetting('style');
         } else {
             $style = $style->style;
         }
         $label = Yii::$app->params['default_next_label'];
         $message = Yii::$app->params['default_next_message'];
         if ($this->language != "default") {
             $language = Language::findOne($this->language);
             if ($language != null) {
                 if ($language->label != '') {
                     $label = $language->label;
                 }
                 if ($language->message != '') {
                     $message = $language->message;
                 }
             }
         }
         Yii::$app->session['anketData'] = ['original' => $original, 'code' => $code->toArray(), 'group' => $group, 'bank' => $bank, 'form' => $form->f_id, 'status' => 0, 'lang' => $this->language, 'style' => $style, 'label' => $label, 'message' => $message];
         $meta = Meta::findOne(['m_z_id' => $code->z_id]);
         if (!$meta) {
             $meta = new Meta();
             $meta->m_z_id = $code->z_id;
             $meta->ip = $_SERVER['REMOTE_ADDR'];
             $meta->time_start = time();
         } else {
             $meta->ip = $_SERVER['REMOTE_ADDR'];
         }
         $meta->save();
         return true;
     }
     return false;
 }
 /**
  * Finds the Style model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Style the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Style::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }