KifUsergroupRelation.class.php 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Cas\Dao;
  3. /**
  4. * kif权限管理系统 - 用户所属组类
  5. * @author lishumingoo@gmail.com
  6. */
  7. use KIF\Verify;
  8. use KIF\Dao\DBAgileDev;
  9. class KifUsergroupRelation extends DBAgileDev {
  10. /**
  11. * 数据表名
  12. * @var string
  13. */
  14. protected $tableName = 'kif_usergroup_relation';
  15. /**
  16. * 表的主键名。默认为id
  17. * @var string
  18. */
  19. protected $primaryKey = 'id';
  20. /**
  21. * 数据库里的真实字段
  22. * @var array
  23. */
  24. protected $other_field = array(
  25. 'uid',
  26. 'groupid',
  27. );
  28. public function __construct($master_flag = 'backend') {
  29. parent::__construct($master_flag);
  30. }
  31. /**
  32. * 获取用户所属的组id集合
  33. * @param int $uid
  34. * @return array
  35. */
  36. public function getsGroupids($uid) {
  37. if (!Verify::unsignedInt($uid)) {
  38. return array();
  39. }
  40. $groupids = array();
  41. $relations = $this->findBy(array('uid' => $uid));
  42. if ($relations) foreach ($relations as $tmprow) {
  43. $groupids[] = $tmprow['groupid'];
  44. }
  45. return array_unique($groupids);
  46. }
  47. }