public function actionAjaxentermsg($id = null) { if (isset($_GET['text'])) { if (!Yii::$app->user->isGuest) { $model = new Msgs(); $model->admin_id = Yii::$app->user->id; $model->text = $_GET['text']; $model->time = time(); $model->unit_type = 1; $model->unit_id = $id; if ($model->save()) { echo '<tr> <th>' . User::name(Yii::$app->user->id) . '<br/> <span style="font-size: xx-small; color: #c0c0c0;">(' . date('d.m.y', time()) . ')</span> </th> <td>' . nl2br(HTML::encode($_GET['text'])) . '</td> </tr>'; } else { echo '== данные не сохранились... =='; } } else { echo '<tr class="grey"> <th> Гость<br/> <span style="font-size: xx-small;">(' . date('d.m.y', time()) . ')</span> </th> <td>' . nl2br(HTML::encode($_GET['text'])) . '</td> </tr>'; } } else { echo '== данные не получены... =='; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Msgs::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'category' => $this->category, 'datetime' => $this->datetime]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'source', $this->source]); return $dataProvider; }
/** * Finds the Msgs model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Msgs the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Msgs::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionCreateseason($id = null) { if ($id != null) { $t = T::findOne(['id' => $id]); if ($t != null and $t['admin_id'] == Yii::$app->user->id) { $season = new Season(); if ($season->load(Yii::$app->request->post())) { $season->time_update = time(); $season->time = time(); $season->t_id = $id; if (trim($season->name) == null) { $season->name = 'Season 1'; } $season->admin_id = Yii::$app->user->id; if ($season->save()) { return $this->render('view', ['t' => $t, 'seasons' => Season::find()->where(['t_id' => $id])->all(), 'msgs' => Msgs::find()->where(['unit_type' => 1, 'unit_id' => $t['id']])->orderBy('id DESC')->limit(50)->all()]); } else { echo 'Ошибка сохранения!!!'; } } return $this->render('createseason', ['season' => $season, 't' => $t]); } else { echo 'Ошибка! Не найден турнир или Вы не админ тунира...'; } } else { echo 'Ошибка! Не получены данные...'; } }