UserGroup.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * 用户群组相关
  4. * @author solu
  5. */
  6. class UserGroup extends Model {
  7. protected $tableName = 'user_group';
  8. protected $dbKey = 'dw_chat';
  9. const STATE_APPLY = 0; // 申请中
  10. const STATE_IN_GROUP = 1; // 在群里
  11. const STATE_LEAVE = 2; // 离开群
  12. /**
  13. * 检查是否是管理员
  14. * @author benzhan
  15. * @param $group_id
  16. * @param $user_id
  17. * @return array
  18. */
  19. public function isAdmin($group_id, $user_id) {
  20. $row = $this->objTable->getRow(compact('user_id', 'group_id'));
  21. return $row['is_admin'];
  22. }
  23. /**
  24. * 是否被禁言
  25. * @author solu
  26. * @param $group_id
  27. * @param $user_id
  28. * @return bool
  29. */
  30. public function isBlock($group_id, $user_id) {
  31. $row = $this->objTable->getRow(compact('user_id', 'group_id'));
  32. return !!$row['is_block'];
  33. }
  34. /**
  35. * 设置封禁用户
  36. * @param $group_id
  37. * @param $user_id
  38. * @param int $is_block
  39. */
  40. public function setBlock($group_id, $user_id, $is_block = 1) {
  41. // $this->objTable->updateObject(compact('is_block'), compact('user_id', 'group_id'));
  42. $this->setData($group_id, $user_id, compact('is_block'));
  43. }
  44. /**
  45. * 设置数据
  46. * @param $group_id
  47. * @param $user_id
  48. * @param array $data
  49. */
  50. public function setData($group_id, $user_id, $data = []) {
  51. $data['update_time'] = NOW;
  52. $this->objTable->updateObject($data, compact('user_id', 'group_id'));
  53. }
  54. }