1
0

newsModel.php 3.7 KB

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