imgroupModel.php 962 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. class imgroupClassModel extends Model
  3. {
  4. public function initModel()
  5. {
  6. $this->settable('im_group');
  7. }
  8. public function updateguser($id, $deptid='')
  9. {
  10. if(isempt($deptid)){
  11. $onr = $this->getone($id);
  12. $deptid = $onr['deptid'];
  13. }
  14. if(isempt($deptid) || $deptid=='0')return;
  15. $dbs = m('im_groupuser');
  16. $uids = m('admin')->gjoin($deptid,'d');
  17. if(isempt($uids))$uids='0';
  18. $dbs->delete("`gid`='$id' and `uid` not in($uids)");
  19. $rows = $this->db->getall("SELECT a.id,a.`name`,b.gid FROM `[Q]admin` a left join `[Q]im_groupuser` b on a.`id`=b.`uid` and b.`gid`='$id' where a.`status`=1 and a.`id` in($uids)");
  20. foreach($rows as $k=>$rs){
  21. if(isempt($rs['gid']))$dbs->insert(array(
  22. 'gid' => $id,
  23. 'uid' => $rs['id']
  24. ));
  25. }
  26. }
  27. public function updategall()
  28. {
  29. $rows = $this->getall('`type`<>2','`id`,`deptid`');
  30. foreach($rows as $k=>$rs)$this->updateguser($rs['id'], $rs['deptid']);
  31. }
  32. }
粤ICP备19079148号