todoModel.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. class todoClassModel extends Model
  3. {
  4. /**
  5. 添加通知
  6. */
  7. public function add($uid, $title, $mess, $arrs=array())
  8. {
  9. if(isempt($uid))return false;
  10. $arr['title'] = $title;
  11. $mess = htmlspecialchars(str_replace(array('<br>',"\n"),'[br]',$mess));
  12. $arr['mess'] = str_replace('[br]','<br>',$mess);
  13. $arr['status'] = '0';
  14. $arr['optdt'] = $this->rock->now;
  15. $arr['tododt'] = $this->rock->now;
  16. foreach($arrs as $k=>$v)$arr[$k] = $v;
  17. $uid = ''.$uid.'';
  18. $suid = explode(',', $uid);
  19. $iarr = array();
  20. foreach($suid as $suids){
  21. $arr['uid'] = $suids;
  22. $iarr[] = $arr;
  23. }
  24. if($iarr)$this->insertAll($iarr);
  25. }
  26. public function addtodo($receid, $title, $mess, $mode='', $mid=0)
  27. {
  28. if($receid=='')return;
  29. $where = '';
  30. if($receid!='all')$where = ' and `id` in('.$receid.')';
  31. $rows = $this->db->getrows('[Q]admin','`status`=1 '.$where.'','id');
  32. $uids = '';
  33. foreach($rows as $k=>$rs)$uids.= ','.$rs['id'].'';
  34. if($uids != ''){
  35. $uids = substr($uids, 1);
  36. if($mode!='' && $mid>0)$this->delete("`uid` in($uids) and `modenum`='$mode' and mid='$mid' and `status`=0");
  37. $this->add($uids, $title, $mess, array(
  38. 'modenum' => $mode,
  39. 'mid' => $mid
  40. ));
  41. }
  42. return $uids;
  43. }
  44. /**
  45. 添加唯一的通知
  46. */
  47. public function addtz($uid, $title, $mess, $table='', $mid='', $tododt='')
  48. {
  49. $where = '';
  50. if($table != '')$where = " and `table`='$table'";
  51. if($mid != '')$where .= " and `mid`='$mid'";
  52. if($where != ''){
  53. $this->delete("`uid` in($uid) and `status`=0 $where");
  54. }
  55. $arr = array(
  56. 'table' => $table,
  57. 'mid' => $mid
  58. );
  59. if(!$this->isempt($tododt))$arr['tododt'] = $tododt;
  60. $this->add($uid, $title, $mess, $arr);
  61. }
  62. /**
  63. * 删除提醒
  64. */
  65. public function deltodo($num, $mid, $uid, $table='')
  66. {
  67. $where = "`uid` in($uid) and `modenum`='$num' and `mid`='$mid'";
  68. $this->delete($where);
  69. m('flow_todos')->delete($where);
  70. m('im_history')->delete("`uid` in($uid) and `xgurl`='".$num."|".$mid."'");
  71. }
  72. }
粤ICP备19079148号