Example #1
0
 public function actionIndex($id)
 {
     $project = $this->loadModel('app\\models\\Project', $id);
     if (!\Yii::$app->user->can('viewProject', ['project' => $project])) {
         throw new ForbiddenHttpException('Access denied');
     }
     $this->view->params['appSettings'] = ['app_name' => $project->title];
     $searchModel = new IssueSearch();
     $searchModel->project_id = $project->id;
     $dataProvider = $searchModel->search(\Yii::$app->request->queryParams);
     if (\Yii::$app->request->post('hasEditable') && !\Yii::$app->user->isGuest) {
         $model = Issue::findOne(['id' => (int) \Yii::$app->request->post('editableKey')]);
         $out = Json::encode(['output' => '', 'message' => '']);
         $post = current(\Yii::$app->request->post('Issue'));
         if (isset($post['status_id'])) {
             $model->status_id = (int) $post['status_id'];
             $output = StatusEnum::i()->getMap()[$post['status_id']];
             $this->sendMessage($model, ['subject' => \Yii::t('app', 'Issue Status Changed'), 'view' => 'changeStatus']);
         }
         if (isset($post['priority_id'])) {
             $model->priority_id = (int) $post['priority_id'];
             $output = PriorityEnum::i()->getMap()[$post['priority_id']];
         }
         if (isset($post['assignee_id'])) {
             if ($post['assignee_id']) {
                 $model->assignee_id = (int) $post['assignee_id'];
                 $output = \app\models\Project::getAssigneeOptions($project->id)[$post['assignee_id']];
                 $this->sendMessage($model);
             } else {
                 $model->assignee_id = null;
                 $output = '<i>(' . \Yii::t('app', 'not set') . ')</i>';
             }
         }
         if ($model->save()) {
             $out = Json::encode(['output' => $output, 'message' => '']);
         }
         echo $out;
         return;
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'project' => $project]);
 }
Example #2
0
 /**
  * Finds the Issue model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Issue the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Issue::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }