recordAction.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. class recordClassAction extends Action
  3. {
  4. public function storebeforeshow($table)
  5. {
  6. $dt1 = $this->post('dt1');
  7. $dt2 = $this->post('dt2');
  8. $key = $this->post('key');
  9. $atype = $this->post('atype');
  10. $receid = $this->post('receid');
  11. $whe = $this->rock->dbinstr('`receuid`', $this->adminid);
  12. $where = 'and '.$whe.'';
  13. if($atype=='all'){
  14. $where = '';
  15. }
  16. if(!isempt($dt1))$where.=" and `optdt`>='$dt1 00:00:00'";
  17. if(!isempt($dt2))$where.=" and `optdt`<='$dt2 23:59:59'";
  18. if(!isempt($receid)){
  19. $where.=" and ((`sendid` in($receid)) or (`type`='user' and `receid` in($receid)))";
  20. }
  21. if(!isempt($key)){
  22. $key = $this->rock->jm->base64encode($key);
  23. $where.=" and `cont` like '%$key%'";
  24. }
  25. return $where;
  26. }
  27. //数据显示后处理
  28. public function storeaftershow($table,$rows)
  29. {
  30. $suids = '0';
  31. $guids = '0';
  32. $fuids = '0';
  33. $typearr = array('user'=>'单人','group'=>'群会话');
  34. foreach($rows as $k=>$rs){
  35. $suids.=','.$rs['sendid'].'';
  36. $rows[$k]['typetxt']= arrvalue($typearr, $rs['type']);
  37. if($rs['type']=='user'){
  38. $suids.=','.$rs['receid'].'';
  39. }else{
  40. $guids.=','.$rs['receid'].'';
  41. }
  42. if($rs['fileid']!='0')$fuids.=','.$rs['fileid'].'';
  43. }
  44. $warr = $farr = $garr = array();
  45. if($suids!='0')$farr = $this->db->getarr('[Q]admin', "`id` in($suids)",'`face`,`name`');
  46. if($guids!='0')$garr = $this->db->getarr('[Q]im_group', "`id` in($guids)",'`face`,`name`');
  47. if($fuids!='0')$warr = $this->db->getarr('[Q]file', "`id` in($fuids)",'filename,filesizecn,fileext,filepath,thumbpath,filenum'); //相关文件
  48. $fobj = m('file');
  49. $ztfo = m('im_messzt');
  50. foreach($rows as $k=>$rs){
  51. $sendid = $rs['sendid'];
  52. $receid = $rs['receid'];
  53. $type = $rs['type'];
  54. if(isset($farr[$sendid])){
  55. $rows[$k]['sendname'] = $farr[$sendid]['name'];
  56. }
  57. if($type=='user'){
  58. if(isset($farr[$receid])){
  59. $rows[$k]['recename'] = $farr[$receid]['name'];
  60. }
  61. }else{
  62. if(isset($garr[$receid])){
  63. $rows[$k]['recename'] = $garr[$receid]['name']; //群名称
  64. }
  65. }
  66. //发送人是我判断是否已读未读
  67. $zttext = '';
  68. if($type=='user'){
  69. if($rs['zt']=='1'){
  70. $zttext = '已读';
  71. $rows[$k]['ishui']=1;
  72. }else{
  73. $zttext = '<font color=red>未读</font>';
  74. }
  75. }else{
  76. if($sendid == $this->adminid){
  77. $tos = $ztfo->rows('mid='.$rs['id'].'');
  78. if($tos==0){
  79. $zttext = '全部已读';
  80. $rows[$k]['ishui']=1;
  81. }else{
  82. $zttext = '<font color=red>'.$tos.'人未读</font>';
  83. }
  84. }
  85. }
  86. $rows[$k]['zttext'] = $zttext;
  87. $fileid = $rs['fileid'];
  88. if(isset($warr[$fileid])){
  89. $fileid = $fobj->getfilestr($warr[$fileid],1);
  90. }
  91. if($fileid=='0')$fileid = '';
  92. $rows[$k]['fileid'] = $fileid;
  93. }
  94. return array(
  95. 'rows' => $rows
  96. );
  97. }
  98. //删除聊天记录
  99. public function delrecordAjax()
  100. {
  101. $id = c('check')->onlynumber($this->post('id'));
  102. $atype = $this->post('atype');
  103. if($atype!='all'){
  104. if(!isempt($id)){
  105. m('reim')->clearrecord('',0,$this->adminid, $id);
  106. }
  107. }else{
  108. //管理员删除
  109. if($this->getsession('isadmin')!='1')backmsg('非管理员不能操作');
  110. if(!isempt($id)){
  111. m('im_mess')->delete('id in('.$id.')');
  112. m('im_messzt')->delete('mid in('.$id.')');
  113. }
  114. }
  115. backmsg();
  116. }
  117. public function delqingchuAjax()
  118. {
  119. $tas = (int)m('option')->getval('chatrecorddt','0');
  120. if($tas<=0)$tas = 180;
  121. $dt = date('Y-m-d H:i:s', time()-$tas*24*3600);
  122. m('im_mess')->delete("`optdt`<='$dt'");
  123. m('im_history')->delete("`optdt`<='$dt'");
  124. m('im_messzt')->delete("`mid` not in(select `id` from `[Q]im_mess`)");
  125. echo $tas;
  126. }
  127. public function storebefore_tonghuashow($table)
  128. {
  129. $dt1 = $this->post('dt1');
  130. $dt2 = $this->post('dt2');
  131. $key = $this->post('key');
  132. $atype = $this->post('atype');
  133. $receid = $this->post('receid');
  134. $where = 'and (`faid`='.$this->adminid.' or `joinids`='.$this->adminid.')';
  135. if($atype=='all'){
  136. $where = '';
  137. }
  138. if(!isempt($dt1))$where.=" and `adddt`>='$dt1 00:00:00'";
  139. if(!isempt($dt2))$where.=" and `adddt`<='$dt2 23:59:59'";
  140. if(!isempt($receid)){
  141. $where.=" and (`faid` in($receid) or `joinids` in($receid))";
  142. }
  143. if(!isempt($key)){
  144. //$key = $this->rock->jm->base64encode($key);
  145. //$where.=" and `cont` like '%$key%'";
  146. }
  147. return $where;
  148. }
  149. //数据显示后处理
  150. public function storeafter_tonghuashow($table,$rows)
  151. {
  152. $suids = '0';
  153. $typearr = array('语音','视频');
  154. foreach($rows as $k=>$rs){
  155. $suids.=','.$rs['faid'].'';
  156. if(!isempt($rs['joinids']))$suids.=','.$rs['joinids'].'';
  157. }
  158. $farr= array();
  159. if($suids!='0')$farr = $this->db->getarr('[Q]admin', "`id` in($suids)",'`face`,`name`');
  160. $statea = array('呼叫中','<font color=green>接通</font>','<font color=red>拒绝</font>','取消','等待接听','超时取消');
  161. foreach($rows as $k=>$rs){
  162. $faid = $rs['faid'];
  163. $joinids = $rs['joinids'];
  164. if(isset($farr[$faid])){
  165. $rows[$k]['faid'] = $farr[$faid]['name'];
  166. }
  167. if(isset($farr[$joinids])){
  168. $rows[$k]['joinids'] = $farr[$joinids]['name'];
  169. }
  170. if($rs['state']==1 && !isempt($rs['jiedt']) && !isempt($rs['enddt'])){
  171. $sj = strtotime($rs['enddt']) - strtotime($rs['jiedt']);
  172. $rows[$k]['remark'] = '接听'.$sj.'秒';
  173. }
  174. $rows[$k]['type'] = $typearr[$rs['type']];
  175. $rows[$k]['state'] = $statea[$rs['state']];
  176. }
  177. return array(
  178. 'rows' => $rows
  179. );
  180. }
  181. //删除聊天记录
  182. public function delrecord_tonghuaAjax()
  183. {
  184. $id = $this->post('id');
  185. $atype = $this->post('atype');
  186. //管理员删除
  187. if($this->getsession('isadmin')!='1')backmsg('非管理员不能操作');
  188. m('im_tonghua')->delete('id in('.$id.')');
  189. backmsg();
  190. }
  191. public function downloadAction()
  192. {
  193. }
  194. public function historyAction()
  195. {
  196. }
  197. }
粤ICP备19079148号