/** * Displays a single DcmdOprCmd model. * @param integer $id * @return mixed */ public function actionView($id) { ///判断用户权限 if (Yii::$app->user->getIdentity()->admin != 1) { $query = DcmdUserGroup::find()->andWhere(['uid' => Yii::$app->user->getId()])->asArray()->all(); $gstr = " opr_cmd_id = " . $id . " and gid in (0"; foreach ($query as $item) { $gstr .= "," . $item['gid']; } $gstr .= ")"; $query = DcmdGroupCmd::find()->where($gstr)->asArray()->all(); if (count($query) == 0) { Yii::$app->getSession()->setFlash('error', '对不起, 你没有权限!'); return $this->redirect(['dcmd-opr-cmd/index']); } } $searchModel = new DcmdOprCmdArgSearch(); $params = array(); $params['DcmdOprCmdArgSearch'] = array('opr_cmd_id' => $id); $dataProvider = $searchModel->search($params); $group_searchModel = new DcmdGroupCmdSearch(); $params = array('DcmdGroupCmdSearch' => array('opr_cmd_id' => $id)); $group_dataProvider = $group_searchModel->search($params); return $this->render('view', ['model' => $this->findModel($id), 'arg_dataProvider' => $dataProvider, 'group_searchModel' => $group_searchModel, 'group_dataProvider' => $group_dataProvider]); }
/** * Lists all DcmdOprCmdArg models. * @return mixed */ public function actionIndex() { $searchModel = new DcmdOprCmdArgSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }