Beispiel #1
0
 public function search($params)
 {
     $query = AuthItem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['type' => $this->type, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'rule_name', $this->rule_name])->andFilterWhere(['like', 'data', $this->data]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AuthItem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['type' => $this->type, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'rule_name', $this->rule_name])->andFilterWhere(['like', 'data', $this->data]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = AuthItem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => array('pageSize' => 100)]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['type' => $this->type]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'rule_name', $this->rule_name])->andFilterWhere(['like', 'data', $this->data]);
     return $dataProvider;
 }
 public function actionInit()
 {
     $auth = \Yii::$app->authManager;
     $auth->removeAll();
     //$arrPerm = [];
     $query = AuthItem::find()->where(['type' => 0]);
     $modelAuthItem = $query->all();
     foreach ($modelAuthItem as $obj) {
         $arrPerm[$obj->name] = $obj->description;
     }
     //$arrRole = [];
     $query = AuthItem::find()->where(['type' => 2]);
     $modelAuthItem = $query->all();
     foreach ($modelAuthItem as $obj) {
         $arrRole[$obj->name] = $obj->description;
     }
     $query = AuthItem::find()->where(['type' => 2]);
     $modelAuthItem = $query->all();
     //$arrRolePerm = [];
     foreach ($modelAuthItem as $obj) {
         $name = $obj->name;
         $query = AuthItemChild::find()->where(['parent' => $name]);
         $modelAuthItemChild = $query->all();
         foreach ($modelAuthItemChild as $objchild) {
             $arrRolePerm[$name][] = $objchild->child;
         }
     }
     $auth->removeAll();
     foreach ($arrPerm as $permName => $title) {
         $perm = $auth->createPermission($permName);
         $perm->description = $title;
         $auth->add($perm);
     }
     foreach ($arrRole as $roleName => $title) {
         $role = $auth->createRole($roleName);
         $role->description = $title;
         $auth->add($role);
         // assign role permission
         foreach ($arrRolePerm[$roleName] as $permName) {
             $perm = $auth->getPermission($permName);
             $auth->addChild($role, $perm);
         }
     }
 }
Beispiel #5
0
    
    <?php 
echo $form->field($model, 'first_name')->textInput();
?>
    
    <?php 
echo $form->field($model, 'middle_name')->textInput();
?>
    
    <?php 
echo $form->field($model, 'last_name')->textInput();
?>
    
    
    <?php 
echo $form->field($model, 'authAssignments')->widget(MultipleInput::className(), ['min' => 1, 'limit' => 10, 'columns' => [['name' => 'item_name', 'type' => 'dropDownList', 'defaultValue' => 'user', 'items' => ArrayHelper::map(\common\models\AuthItem::find()->all(), 'name', 'description')]]]);
?>
       
    <?php 
$tzlist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
$list = array();
foreach (Yii::$app->params['timezones'] as $key => $tz) {
    $list[$tz] = $key;
}
?>
    
    <?php 
echo $form->field($model, 'timezone')->dropDownList($list);
?>

    <div class="form-group">
Beispiel #6
0
 public function getdropAssignment()
 {
     $data = AuthItem::find()->where(['type' => 1])->asArray()->all();
     return ArrayHelper::map($data, 'name', 'name');
 }
Beispiel #7
0
 public function authItem()
 {
     $data = ArrayHelper::map(AuthItem::find()->where(['type' => 1])->all(), 'name', 'name');
     return $data;
 }
 /**
  * Signs user up.
  *
  * @return mixed
  */
 public function actionSignup()
 {
     $model = new SignupForm();
     $authItems = AuthItem::find()->all();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     return $this->render('signup', ['model' => $model, 'authItems' => $authItems]);
 }
Beispiel #9
0
 /**
  * @param int $type
  * @param bool $empty
  * @return array
  * Получение массива ролей (type=1) и точек доступа (type=2)
  */
 public static function getAll($type = null, $key = 'name')
 {
     $roles = [];
     if ($type) {
         $role = AuthItem::find()->where(['type' => $type])->all();
         if ($role) {
             foreach ($role as $r) {
                 if ($key == 'name') {
                     $roles[$r->name] = $r->name;
                 } elseif ($key == 'id') {
                     $roles[$r->id] = $r->name;
                 }
             }
         }
     } else {
         $role = AuthItem::find()->all();
         if ($role) {
             foreach ($role as $r) {
                 if ($r->type == 1) {
                     if ($key == 'name') {
                         $roles['Роли'][$r->name] = $r->name;
                     } elseif ($key == 'id') {
                         $roles['Роли'][$r->id] = $r->name;
                     }
                 } else {
                     if ($key == 'name') {
                         $roles['Точки доступа'][$r->name] = $r->name;
                     } elseif ($key == 'id') {
                         $roles['Точки доступа'][$r->id] = $r->name;
                     }
                 }
             }
         }
     }
     return $roles;
 }
 public function actionList()
 {
     $query = User::find();
     if (\Yii::$app->request->isPost) {
         if ($_REQUEST['op'] == "delete") {
             $arrId = $_REQUEST['selectUser'];
             foreach ($arrId as $lst) {
                 $queryUser = User::find();
                 $User = $queryUser->where(['id' => $lst])->one()->delete();
             }
             echo $this->redirect(Url::toRoute('user/list'));
         }
         if ($_REQUEST['op'] == "search") {
             $searchText = $_REQUEST['searchText'];
             $query->andWhere(['LIKE', 'firstName', '%' . $searchText . '%', false]);
         }
     }
     $pagination = new Pagination(['defaultPageSize' => 20, 'totalCount' => $query->count()]);
     $queryauth = AuthItem::find();
     $queryauth->where(['type' => '2']);
     $modelauth = $queryauth->all();
     $arrauth = '';
     foreach ($modelauth as $lst) {
         $arrauth[0] = 'เลือกสิทธิ์ ให้กับ user';
         $arrauth[] = $lst->name;
     }
     $model = $query->orderBy('createTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     echo $this->render('list', ['model' => $model, 'arrauth' => $arrauth, 'pagination' => $pagination]);
 }