protected function findPoll($poll_id)
 {
     $model = Poll::find()->where(['id' => $poll_id])->one();
     if ($model !== null) {
         // Todo: test if the current user has access to this model
         $this->_poll_model = $model;
         $this->_poll_id = $model->getPrimaryKey();
         return $model;
     } else {
         $this->_poll_model = null;
         $this->_poll_id = null;
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 2
0
 public function search($params)
 {
     $query = Poll::find()->indexBy('id');
     if (\Yii::$app->user->identity) {
         if (!\Yii::$app->user->identity->isAdmin()) {
             $query->organizer_id(Yii::$app->user->identity->organizer_id);
         }
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_ASC]], 'pagination' => ['pageSize' => 20]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'select_min' => $this->select_min, 'select_max' => $this->select_max, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'organizer_id' => $this->organizer_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'question', $this->question]);
     return $dataProvider;
 }