예제 #1
0
 /**
  * Lists all DcmdUser models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (Yii::$app->user->getIdentity()->admin != 1) {
         Yii::$app->getSession()->setFlash('success', NULL);
         Yii::$app->getSession()->setFlash('error', "对不起, 你没有权限!");
         return $this->redirect(array('index'));
     }
     $searchModel = new DcmdUserSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Creates a new DcmdUserGroup model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($gid)
 {
     if (Yii::$app->user->getIdentity()->admin != 1 || Yii::$app->user->getIdentity()->sa != 1) {
         Yii::$app->getSession()->setFlash('success', NULL);
         Yii::$app->getSession()->setFlash('error', "对不起,你没有权限!");
         return $this->redirect(array('dcmd-group/index', ['id' => $gid]));
     }
     $query = DcmdUserGroup::find()->andWhere(["gid" => $gid])->asArray()->all();
     $uids = "uid not in (0";
     foreach ($query as $item) {
         $uids .= "," . $item['uid'];
     }
     $uids .= ")";
     $query = DcmdGroup::findOne($gid);
     if ($query['gtype'] == 1) {
         $uids .= " and admin = 1";
     } else {
         $uids .= " and admin = 0";
     }
     $searchModel = new DcmdUserSearch();
     $dataProvider = $searchModel->search(array(), $uids);
     return $this->render('create', ['gid' => Yii::$app->request->queryParams['gid'], 'gname' => Yii::$app->request->queryParams['gname'], 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }