コード例 #1
0
ファイル: BbiiPoll.php プロジェクト: sourcetoad/bbii2
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * 
  * @param  [type] $params [description]
  * @return ActiveDataProvider The data provider that can return the models based on the search/filter conditions.
  */
 public function search($params = null)
 {
     $query = BbiiPoll::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition('allow_multiple', $this->allow_multiple);
     $this->addCondition('allow_revote', $this->allow_revote);
     $this->addCondition('expire_date', $this->expire_date, true);
     $this->addCondition('id', $this->id, true);
     $this->addCondition('post_id', $this->post_id, true);
     $this->addCondition('question', $this->question, true);
     $this->addCondition('user_id', $this->user_id, true);
     $this->addCondition('votes', $this->votes);
     return $dataProvider;
 }
コード例 #2
0
ファイル: ForumController.php プロジェクト: sourcetoad/bbii2
 /**
  * Handle Ajax call for display of poll edit form
  */
 public function actionEditPoll()
 {
     $json = array();
     if (isset(\Yii::$app->request->post()['poll_id'])) {
         $poll = BbiiPoll::find(\Yii::$app->request->post()['poll_id']);
         $choices = array();
         $models = BbiiChoice::find()->findAll('poll_id = ' . $poll->id);
         foreach ($models as $model) {
             $choices[$model->id] = $model->choice;
         }
         $json['html'] = $this->render('editPoll', array('poll' => $poll, 'choices' => $choices), true);
         $json['success'] = 'yes';
     } else {
         $json['success'] = 'no';
     }
     echo json_encode($json);
     \Yii::$app->end();
 }