Example #1
0
 public function organizer_id($organizer_id = null)
 {
     if ($organizer_id) {
         $this->andWhere([Poll::tableName() . '.organizer_id' => $organizer_id]);
     }
     return $this;
 }
Example #2
0
 protected function getPollByID($id)
 {
     if (($model = Poll::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('app/error', 'The requested page does not exist.'));
     }
 }
 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.');
     }
 }
Example #4
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;
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPolls()
 {
     return $this->hasMany(Poll::className(), ['organizer_id' => 'id']);
 }
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPoll()
 {
     return $this->hasOne(Poll::className(), ['id' => 'poll_id']);
 }
Example #7
0
<?php

use yii\helpers\Html;
use app\models\Poll;
/**
 * @var yii\web\View $this
 * @var app\models\Poll $model
 */
$this->title = Yii::t('app', 'Update {modelClass}: ', ['modelClass' => Poll::label(1)]) . ' ' . $model->__toString();
$this->params['breadcrumbs'][] = ['label' => Poll::label(2), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->__toString(), 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
?>
<div class="poll-update">
    <div class="page-header">
        <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    </div>
    <?php 
echo $this->render('_form', ['model' => $model, 'modelOptions' => $modelOptions]);
?>
    <?php 
echo $this->render('//system/leaving_prompt');
?>
</div>
Example #8
0
 * @var app\models\Poll $model
 */
?>


<?php 
// Populate the attribute array for display.
$attributes = ['question:ntext', 'info:ntext'];
foreach ($model->getOptions()->all() as $index => $option) {
    $no = $index + 1;
    $attributes[] = ['attribute' => "Option {$no}", 'value' => $option->text];
}
?>

<?php 
echo Html::tag('h2', Poll::label(1));
?>

<p>
<?php 
if ($model->isLocked()) {
    echo AlertBlock::widget(['useSessionFlash' => false, 'type' => AlertBlock::TYPE_ALERT, 'delay' => false, 'alertSettings' => ['warning' => ['type' => Alert::TYPE_WARNING, 'body' => Yii::t('app', 'This poll cannot be edited because it has already been accessed by a voter'), 'closeButton' => false]]]);
}
?>
    <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary' . ($model->isLocked() ? ' disabled' : null)]);
?>
    <?php 
echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    <?php 
Example #9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $list = Poll::findOrFail($id);
         $list->delete();
     } catch (Exception $e) {
         return redirect()->back()->withMessage('Error deleting Poll, Possibly it is already Deleted')->withStatus('error');
     }
     return redirect()->route('polls.index', compact('list'))->withMessage('Poll has been Deleted')->withStatus('success');
 }
Example #10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPolls()
 {
     return $this->hasMany(Poll::className(), ['created_by' => 'id']);
 }
Example #11
0
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['@']]], 'ruleConfig' => ['class' => OrganizationAccessRule::className(), 'modelClass' => Poll::className(), 'queryParam' => 'poll_id']]];
 }
Example #12
0
 public function behaviors()
 {
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post'], 'import' => ['post']]], 'returnUrl' => ['class' => ReturnUrlFilter::className(), 'only' => ['update', 'create', 'delete']], 'access' => ['class' => AccessControl::className(), 'only' => ['update', 'view', 'delete'], 'rules' => [['allow' => true, 'roles' => ['@']]], 'ruleConfig' => ['class' => OrganizationAccessRule::className(), 'modelClass' => Member::className()]], 'access' => ['class' => AccessControl::className(), 'only' => ['import', 'index', 'clear', 'create', 'update', 'view', 'delete'], 'rules' => [['allow' => true, 'roles' => ['@']]], 'ruleConfig' => ['class' => OrganizationAccessRule::className(), 'modelClass' => Poll::className(), 'queryParam' => 'poll_id']]];
 }
Example #13
0
 public function behaviors()
 {
     return ['verbs' => ['class' => VerbFilter::className(), 'actions' => ['delete' => ['post'], 'invalidate' => ['post']]], 'access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['@']]], 'ruleConfig' => ['class' => OrganizationAccessRule::className(), 'modelClass' => Poll::className(), 'queryParam' => 'poll_id']]];
 }
Example #14
0
use yii\helpers\Html;
use yii\grid\GridView;
use app\models\Poll;
/**
* @var yii\web\View $this
* @var yii\data\ActiveDataProvider $dataProvider
* @var app\models\search\PollSearch $searchModel
*/
$this->title = Yii::t('app', Poll::label(2));
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="poll-index">
    <div class="page-header">
        <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    </div>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
    <p>
<?php 
echo Html::a(Yii::t('app', 'Create {modelClass}', ['modelClass' => Poll::label(1)]), ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
echo $this->render('_grid', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
?>
</div>