You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
1.8 KiB

  1. <?php
  2. namespace common\models;
  3. use Yii;
  4. use yii\base\Model;
  5. use yii\data\ActiveDataProvider;
  6. use common\models\User;
  7. /**
  8. * searchUser represents the model behind the search form about `common\models\User`.
  9. */
  10. class searchUser extends User
  11. {
  12. /**
  13. * @inheritdoc
  14. */
  15. public function rules()
  16. {
  17. return [];
  18. }
  19. /**
  20. * Creates data provider instance with search query applied
  21. *
  22. * @param array $params
  23. *
  24. * @return ActiveDataProvider
  25. */
  26. public function search($params)
  27. {
  28. $query = self::find()->joinWith('mainCorp2');
  29. // add conditions that should always apply here
  30. $dataProvider = new ActiveDataProvider([
  31. 'query' => $query,
  32. 'sort' => false
  33. ]);
  34. $this->load($params);
  35. // grid filtering conditions
  36. $query->andFilterWhere([
  37. 'STATUS' => $this->STATUS,
  38. 'MAIN_CORP_ID2' => (Yii::$app->user->identity->USER_ROLE2 == self::SUPER_ADMIN_FO) ? null : Yii::$app->user->identity->MAIN_CORP_ID2,
  39. 'corp_type' => BaseMainCorporation::CORP_FO
  40. ]);
  41. if ($this->USER_ROLE2 != null && $this->USER_ROLE2 != '')
  42. $query->andWhere("user_role2 REGEXP '[[:<:]]" . $this->USER_ROLE2 . "[[:>:]]'");
  43. $query->andFilterWhere(['like', 'USER_NAME', $this->USER_NAME])
  44. ->andFilterWhere(['like', 'TRUE_NAME', $this->TRUE_NAME])
  45. ->andFilterWhere(['<>', 'MAIN_CORP_ID2', 0]);
  46. return $dataProvider;
  47. }
  48. /*
  49. * 是否是车系统超级管理员
  50. * @return bool
  51. */
  52. public static function isSuperAdmin($user_role2)
  53. {
  54. $roles = explode(',', $user_role2);
  55. if (empty(in_array(self::SUPER_ADMIN_FO, $roles))) {
  56. return false;
  57. } else
  58. return true;
  59. }
  60. }