/** * 任务审核 * * @param $id * @param $operation */ public function actionTaskOperation($id, $operation) { $task = Task::findOne($id); if (!$task) { static::renderJson([], -1, '任务号不存在'); } // 是否为该项目的审核管理员(超级管理员可以不用审核,如果想审核就得设置为审核管理员,要不只能维护配置) if (!Group::isAuditAdmin($this->uid, $task->project_id)) { throw new \Exception('不可以操作其它人的任务:)'); } $task->status = $operation ? Task::STATUS_PASS : Task::STATUS_REFUSE; $task->save(); static::renderJson(['status' => \Yii::t('status', 'task_status_' . $task->status)]); }
/** * 任务审核 * * @param $id * @param $operation */ public function actionTaskOperation($id, $operation) { $task = Task::findOne($id); if (!$task) { static::renderJson([], -1, yii::t('task', 'unknown deployment bill')); } // 是否为该项目的审核管理员(超级管理员可以不用审核,如果想审核就得设置为审核管理员,要不只能维护配置) if (!Group::isAuditAdmin($this->uid, $task->project_id)) { throw new \Exception(yii::t('w', 'you are not master of project')); } $task->status = $operation ? Task::STATUS_PASS : Task::STATUS_REFUSE; $task->save(); static::renderJson(['status' => \Yii::t('w', 'task_status_' . $task->status)]); }
/** * 简化 * * @param integer $id * @return the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Project::getConf($id)) !== null) { //判断是否为管理员 if (!Group::isAuditAdmin($this->uid, $model->id)) { throw new \Exception(yii::t('w', 'you are not admin of project')); } return $model; } else { throw new NotFoundHttpException(yii::t('conf', 'project not exists')); } }