newsModel.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. class flow_newsClassModel extends flowModel
  3. {
  4. private $readunarr = array();//未读人员
  5. public $logobj,$htmlobj;
  6. public function initModel()
  7. {
  8. $this->logobj = m('log');
  9. $this->htmlobj = c('html');
  10. }
  11. protected function flowchangedata(){
  12. $cont = c('html')->replace($this->rs['content']);
  13. $fm = $this->rs['fengmian'];
  14. if(!isempt($fm)){
  15. $cont='<div align="center"><img src="'.$this->rock->gethttppath($fm).'"></div>'.$cont.'';
  16. }
  17. $url = $this->rs['url'];
  18. if(!isempt($url))$cont.='<div><a href="'.$url.'">查看原文&gt;&gt;</a></div>';
  19. $this->rs['content'] = $cont;
  20. }
  21. public function flowrsreplace($rs, $lx=0)
  22. {
  23. $content = $rs['content'];
  24. if($lx==2){
  25. unset($rs['content']);
  26. $rs['smallcont'] = $this->neircong($content);
  27. }
  28. return $rs;
  29. }
  30. //移动端列表
  31. public function flowrsreplace_we($row, $rs)
  32. {
  33. if(!isempt($rs['fengmian']))$row['picurl'] = $rs['fengmian'];
  34. return $row;
  35. }
  36. public function flowwesearchdata($lx)
  37. {
  38. if($lx==1)return $this->option->getselectdata('newstype', true);
  39. return array(
  40. 'typename' => '所有分类',
  41. 'searchmsg' => '新闻标题/分类',
  42. );
  43. }
  44. protected function flowsubmit($na, $sm)
  45. {
  46. if($this->rs['status']==1)$this->tisongtodo();
  47. }
  48. //审核完成后发通知
  49. protected function flowcheckfinsh($zt)
  50. {
  51. if($zt==1)$this->tisongtodo();
  52. }
  53. public function getreceids($receid, $whe='')
  54. {
  55. $receid = $this->adminmodel->gjoin($receid,'ud','where');
  56. if($receid=='' || $receid=='all'){
  57. $where = '';
  58. }else{
  59. $where = 'and id>0 and ('.$receid.')';
  60. }
  61. $ids = '';
  62. $rows = $this->adminmodel->getall('`status`=1 '.$where.' '.$whe.'','id');
  63. foreach($rows as $k=>$rs)$ids.=',u'.$rs['id'].'';
  64. if($ids!='')$ids = substr($ids, 1);
  65. return $ids;
  66. }
  67. private function neircong($nr)
  68. {
  69. $cont = $this->htmlobj->htmlremove($nr);
  70. $cont = $this->htmlobj->substrstr($cont,0, 50);
  71. if(strlen($cont)>40)$cont.='...';
  72. return $cont;
  73. }
  74. //发送推送通知
  75. private function tisongtodo()
  76. {
  77. //还没到展示时间就不发送提醒
  78. $zstart= arrvalue($this->rs, 'startdt');
  79. if(!isempt($zstart) && $zstart>$this->rock->date)return;
  80. $cont = $this->neircong($this->rs['content']);
  81. if(isempt($cont))$cont = $this->rs['title']; //为空时
  82. $this->push($this->rs['receid'], '', $cont, $this->rs['title'],1);
  83. //添加短信提醒,短信提醒
  84. if(arrvalue($this->rs,'issms')=='1'){
  85. $receid = $this->rs['receid'];
  86. if(isempt($receid))$receid = 'all';
  87. $qiannum= '';
  88. $tplnum = 'gongsms';
  89. $params = array(
  90. 'title' => $this->rs['title'],
  91. 'typename' => $this->rs['typename'],
  92. );
  93. $url = $this->getxiangurlx();
  94. c('xinhuapi')->sendsms($receid, $qiannum, $tplnum, $params, $url);
  95. }
  96. }
  97. protected function flowbillwhere($uid, $lx)
  98. {
  99. $key = $this->rock->post('key');
  100. $typeid = (int)$this->rock->post('typeid','0');
  101. $keywere= '';
  102. if(!isempt($key))$keywere.=" and (`title` like '%$key%' or `typename`='$key')";
  103. $whyere = '';
  104. //我和我未读
  105. if($lx=='my'){
  106. $whyere= "and (`startdt` is null or `startdt`<='{$this->rock->date}')";
  107. $whyere.= " and (`enddt` is null or `enddt`>='{$this->rock->date}')";
  108. }
  109. if($typeid>0){
  110. $typename=$this->option->getmou('name', $typeid);
  111. $whyere.=" and `typename`='$typename'";
  112. }
  113. return array(
  114. 'order' => '`istop` desc,`optdt` desc',
  115. 'keywere' => $keywere,
  116. 'where' => $whyere,
  117. 'fields' => 'id,typename,optdt,title,optname,content,zuozhe,indate,recename,fengmian,mintou,`status`,`istop`,`appxs`'
  118. );
  119. }
  120. //去掉标题
  121. protected function flowdatalog($arr)
  122. {
  123. $arr['title'] = '';
  124. return $arr;
  125. }
  126. }
粤ICP备19079148号