flowtodoModel.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * 流程通知
  4. */
  5. class flowtodoClassModel extends Model
  6. {
  7. public function initModel()
  8. {
  9. $this->settable('flow_todos');
  10. }
  11. /**
  12. * 添加人员提醒表里,让他必读查看
  13. */
  14. public function addtotouids($uids, $uarr=array())
  15. {
  16. if(isempt($uids) || !$uarr)return;
  17. $mid = arrvalue($uarr,'mid');
  18. $modenum = arrvalue($uarr,'modenum');
  19. $uidsa = explode(',',$uids);
  20. $isuar = array();
  21. $uarrs = $this->getrows("`modenum`='$modenum' and `mid`=$mid and `uid` in($uids)", '`uid`,`id`');
  22. foreach($uarrs as $k=>$rs)$isuar[$rs['uid']]=$rs['id'];
  23. $iarr = $garr = array();
  24. $gids = '';
  25. foreach($uidsa as $uid){
  26. $where = '';
  27. if(isset($isuar[$uid]))$where = $isuar[$uid];
  28. $adda['adddt'] = $this->rock->now;
  29. $adda['readdt'] = null;
  30. $adda['isread'] = 0;
  31. foreach($uarr as $k=>$v)$adda[$k] = $v;
  32. if($where==''){
  33. $adda['uid'] = $uid;
  34. $iarr[] = $adda;
  35. }else{
  36. if(!$garr)$garr = $adda;
  37. $gids.=','.$where.'';
  38. }
  39. }
  40. if($iarr)$this->insertAll($iarr);
  41. if($gids!='')$this->update($garr,'`id` in('.substr($gids,1).')');
  42. }
  43. /**
  44. * 标识已读
  45. */
  46. public function biaoyidu($uid, $mode, $mid)
  47. {
  48. $where = "`uid`='$uid' and `modenum`='$mode' and `mid`='$mid'";
  49. $this->update(array(
  50. 'isread' => 1,
  51. 'readdt' => $this->rock->now
  52. ),"$where and `isread`=0");
  53. m('todo')->update(array(
  54. 'status' => 1,
  55. 'readdt' => $this->rock->now
  56. ), "$where and `status`=0");
  57. //历史会话
  58. m('im_history')->update('`stotal`=0',"`uid`='$uid' and `stotal`>0 and `xgurl`='".$mode."|".$mid."'");
  59. }
  60. public function getwdtotals($uid)
  61. {
  62. $to = $this->rows("`uid`='$uid' and `isread`=0");
  63. return $to;
  64. }
  65. }
粤ICP备19079148号