indexreimAction.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <?php
  2. class indexreimClassAction extends apiAction
  3. {
  4. /**
  5. * PC客户端首页读取
  6. */
  7. public function indexinitAction()
  8. {
  9. $viewobj = m('view');
  10. $dbs = m('reim');
  11. $dba = m('admin');
  12. $gtype = $this->rock->get('gtype');
  13. $udarr = m('dept')->getdeptuserdata();
  14. $userarr = $udarr['uarr'];
  15. $deptarr = $udarr['darr'];
  16. $grouparr = $dbs->getgroup($this->adminid);
  17. $agentarr = $dbs->getagent($this->adminid);
  18. $historyarr = $dbs->gethistory($this->adminid);
  19. $modearr = array();
  20. if(isempt($gtype)){
  21. $applyarr = m('mode')->getmoderows($this->adminid,'and islu=1');
  22. foreach($applyarr as $k=>$rs){
  23. if(!$viewobj->isadd($rs, $this->adminid))continue;
  24. $modearr[]=array('type'=>$rs['type'],'num'=>$rs['num'],'name'=>$rs['name']);
  25. }
  26. }
  27. $arr['deptjson'] = json_encode($deptarr);
  28. $arr['userjson'] = json_encode($userarr);
  29. $arr['groupjson'] = json_encode($grouparr);
  30. $arr['agentjson'] = json_encode($agentarr);
  31. $arr['historyjson'] = json_encode($historyarr);
  32. $arr['modearr'] = $modearr;
  33. $arr['config'] = $dbs->getreims();
  34. $arr['loaddt'] = $this->now;
  35. $arr['ip'] = $this->ip;
  36. $arr['editpass'] = $dba->iseditpass($this->adminid);
  37. $arr['companyinfo'] = $dba->getcompanyinfo($this->adminid, 1);
  38. $arr['onlinearr'] = $this->onlinearr();
  39. $arr['outunum'] = $this->option->getval('outunum'.$this->adminid.'');
  40. $arr['outgroupopen']= $this->option->getval('outgroupopen'.$this->adminid.'');
  41. if(getconfig('systype')=='demo'){
  42. $arr['outgroupopen'] = 'close';
  43. $arr['outunum'] = 'y4rwlnabc';
  44. }
  45. $this->rock->savesession(array('homestyle' => 'rock'));
  46. return returnsuccess($arr);
  47. }
  48. //在线情况读取
  49. private function onlinearr()
  50. {
  51. $time = date('Y-m-d H:i:s', time()-6*60);
  52. $rows = m('login')->getall("`online`=1 and ((`ispush`=1) or (`cfrom`='reim' and moddt>='$time'))",'uid,ispush,web,cfrom');
  53. $onlinearr = array();
  54. foreach($rows as $k=>$rs){
  55. $uid = $rs['uid'];
  56. if(!isset($onlinearr[$uid]))$onlinearr[$uid]=array('uid'=>$uid,'reim'=>0,'mobile'=>0,'web'=>'');
  57. if($rs['cfrom']=='reim')$onlinearr[$uid]['reim'] = 1;
  58. if($rs['ispush']=='1'){
  59. $onlinearr[$uid]['mobile'] = 1;
  60. $onlinearr[$uid]['web'] = $rs['web'];
  61. }
  62. }
  63. return $onlinearr;
  64. }
  65. /**
  66. * REIM的初始化
  67. */
  68. public function reiminitAction()
  69. {
  70. $dbs = m('reim');
  71. $dba = m('admin');
  72. $udarr = m('dept')->getdeptuserdata();
  73. $userarr = $udarr['uarr'];
  74. $deptarr = $udarr['darr'];
  75. $grouparr = $dbs->getgroup($this->adminid);
  76. $historyarr = $dbs->gethistory($this->adminid);
  77. $agentarr = $dbs->getagent($this->adminid);
  78. $arr['deptjson'] = json_encode($deptarr);
  79. $arr['userjson'] = json_encode($userarr);
  80. $arr['groupjson'] = json_encode($grouparr);
  81. $arr['historyjson'] = json_encode($historyarr);
  82. $arr['agentjson'] = json_encode($agentarr);
  83. $arr['config'] = $dbs->getreims();
  84. $arr['loaddt'] = $this->now;
  85. $arr['ip'] = $this->ip;
  86. $arr['editpass'] = $dba->iseditpass($this->adminid);
  87. $arr['companyinfo'] = $dba->getcompanyinfo($this->adminid, 1);
  88. $this->showreturn($arr);
  89. }
  90. /**
  91. * 会话列表记录
  92. */
  93. public function gethistoryAction()
  94. {
  95. $arr = m('reim')->gethistory($this->adminid);
  96. $this->showreturn($arr);
  97. }
  98. /**
  99. * 最新app读取通信地址
  100. */
  101. public function reimconfigAction()
  102. {
  103. $arr['config'] = m('reim')->getreims();
  104. $type = $this->option->getval('reimservertype','0');
  105. $appwx = $this->option->getval('reimappwxsystem','0');
  106. if($type=='0' || $appwx=='0'){//非nodejs版本就不要
  107. $arr['config']['wsurl'] = '';
  108. $arr['config']['recid'] = '';
  109. }
  110. $this->showreturn($arr);
  111. }
  112. /**
  113. * 手机网页版读取,最新webapp的
  114. */
  115. public function mwebinitAction()
  116. {
  117. $dbs = m('reim');
  118. $dba = m('admin');
  119. $agentarr = $dbs->getappagent($this->adminid);
  120. $historyarr = $dbs->gethistory($this->adminid);
  121. $arr['agentjson'] = json_encode($agentarr['rows']);
  122. $arr['historyjson'] = json_encode($historyarr);
  123. $arr['loaddt'] = $this->now;
  124. $arr['loadtime'] = time();
  125. if($historyarr)$arr['loadtime'] = strtotime($historyarr[0]['optdt']);
  126. $arr['editpass'] = $dba->iseditpass($this->adminid);
  127. $arr['companyinfo'] = $dba->getcompanyinfo($this->adminid, 1);
  128. //读取app首页显示图片,从公告和新闻上读取
  129. $arr['myhomenum'] = '';
  130. if($this->isshowshouye('appsy_yyshow'))$arr['myhomenum'] = $this->option->getval('yinghomeshow_'.$this->adminid.'');//我常用的
  131. $silderarr = array();
  132. if($this->isshowshouye('appsy_ggshow')){
  133. $sildergong = m('flow')->initflow('gong')->getflowrows($this->adminid, 'my', 5, " and `appxs`=1");
  134. foreach($sildergong as $k=>$rs){
  135. if(isempt($rs['fengmian']))continue;
  136. $silderarr[] = array(
  137. 'src' => $this->rock->gethttppath($rs['fengmian']),
  138. 'title' => $rs['title'],
  139. 'url' => 'task.php?a=x&num=gong&mid='.$rs['id'].''
  140. );
  141. }
  142. }
  143. if($this->isshowshouye('appsy_xwshow','否')){
  144. $sildernews = m('flow')->initflow('news')->getflowrows($this->adminid, 'my', 5, " and `appxs`=1");
  145. foreach($sildernews as $k=>$rs){
  146. if(isempt($rs['fengmian']))continue;
  147. $silderarr[] = array(
  148. 'src' => $this->rock->gethttppath($rs['fengmian']),
  149. 'title' => $rs['title'],
  150. 'url' => 'task.php?a=x&num=news&mid='.$rs['id'].''
  151. );
  152. }
  153. }
  154. $arr['silderarr'] = $silderarr;
  155. $arr['outunum'] = $this->option->getval('outunum'.$this->adminid.'');
  156. $arr['outgroupopen'] = $this->option->getval('outgroupopen'.$this->adminid.'');
  157. $arr['tonghuabo'] = getconfig('video_bool') ? '1' : '2';//是否开启音视频
  158. $arr['lxrshow'] = ($this->option->getval('appsy_lxrshow')!='否') ? 1 : 2;
  159. $arr['config'] = $dbs->getreims();
  160. $this->showreturn($arr);
  161. }
  162. private function isshowshouye($lx, $mr='是')
  163. {
  164. $val = $this->option->getval($lx);
  165. if(isempt($val))$val=$mr;
  166. return $val=='是';
  167. }
  168. public function ldataAction()
  169. {
  170. $loaddt = $this->rock->jm->base64decode($this->post('loaddt'));
  171. if($loaddt && !c('check')->isdatetime($loaddt))$loaddt='';
  172. $type = $this->post('type','history');
  173. $dbs = m('reim');
  174. $json = array();
  175. if($type=='history')$json = $dbs->gethistory($this->adminid, $loaddt);
  176. if($type=='group')$json = $dbs->getgroup($this->adminid);
  177. if($type=='dept')$json = m('dept')->getdata();
  178. if($type=='user')$json = m('admin')->getuser();
  179. if($type=='agent')$json = $dbs->getagent($this->adminid);
  180. if($type=='config')$json = m('reim')->getreims();
  181. $arr['json'] = json_encode($json);
  182. $arr['loaddt'] = $this->now;
  183. $arr['ip'] = $this->ip;
  184. $arr['type'] = $type;
  185. $this->showreturn($arr);
  186. }
  187. public function indexupgetAction()
  188. {
  189. $historyarr = m('reim')->gethistory($this->adminid);
  190. $arr['historyjson'] = json_encode($historyarr);
  191. $this->showreturn($arr);
  192. }
  193. public function changewxtxAction()
  194. {
  195. $tx = (int)$this->post('tx','1');
  196. m('admin')->update('wxtx='.$tx.'', $this->adminid);
  197. $this->showreturn('');
  198. }
  199. public function showmyinfoAction()
  200. {
  201. $dbs = m('admin');
  202. $arr = $dbs->getone($this->adminid,'`id`,`deptallname`,`ranking`,`email`,`tel`,`apptx`,`face`,`name`,`user`,`mobile`');
  203. if(!$arr)$this->showreturn('','not user', 201);
  204. $arr['face'] = $dbs->getface($arr['face']);
  205. $arr['admintoken'] = $this->admintoken;
  206. $arr['companyinfo'] = $dbs->getcompanyinfo($this->adminid, 1);
  207. $arr['companymode'] = ISMORECOM;
  208. if(m('reim')->installwx(3)){
  209. $bdwx = m('wouser')->getone('`uid`='.$this->adminid.'','nickname,headimgurl');
  210. $arr['bdwx'] = $bdwx;
  211. }
  212. $this->showreturn($arr);
  213. }
  214. public function wxbdjcAction()
  215. {
  216. m('wouser')->update('`uid`=0','`uid`='.$this->adminid.'');
  217. $this->showreturn('');
  218. }
  219. //同步微信上头像
  220. public function tongbufaceAction()
  221. {
  222. $reim = m('reim');
  223. if($reim->installwx(1)){
  224. $barr = m('weixinqy:user')->anayface($this->userrs['user'], true);
  225. if($barr['errcode'] != 0)$this->showreturn('',$barr['msg'],202);
  226. $this->showreturn($barr);
  227. }else{
  228. $this->showreturn('','没部署企业微信',201);
  229. }
  230. }
  231. public function loadinfoAction()
  232. {
  233. $type = $this->get('type');
  234. $receid = $this->get('receid');
  235. $arr = array();
  236. if($type=='user'){
  237. $arr = m('admin')->getuser(0, $receid);
  238. }
  239. $this->showreturn($arr);
  240. }
  241. //判断是否有最新历史信息
  242. public function loadhitAction()
  243. {
  244. $time = $this->get('time');
  245. $arr['loadtime'] = $time;
  246. $optdt = date('Y-m-d H:i:s', $time);
  247. $arr['total'] = 0;
  248. $historyarr = m('reim')->gethistory($this->adminid, $optdt);
  249. $arr['rows'] = $historyarr;
  250. if($historyarr)$arr['loadtime'] = strtotime($historyarr[0]['optdt']);
  251. $this->showreturn($arr);
  252. }
  253. //设置常应用
  254. public function shecyyAction()
  255. {
  256. $yynum = $this->get('yynum');
  257. $myyyid= $this->option->getval('yinghomeshow_'.$this->adminid.'');
  258. $yarrs = array();
  259. $iscy = 0;
  260. if(isempt($myyyid)){
  261. $yarrs[]= $yynum;
  262. $iscy = 1;
  263. }else{
  264. $yarrs = explode(',', $myyyid);
  265. if(in_array($yynum, $yarrs)){
  266. $iscy = 0;
  267. foreach($yarrs as $k1=>$v1)if($v1==$yynum)unset($yarrs[$k1]);
  268. }else{
  269. $iscy = 1;
  270. $yarrs[]= $yynum;
  271. }
  272. }
  273. $myyyid = join(',', $yarrs);
  274. $this->option->setval('yinghomeshow_'.$this->adminid.'', $myyyid);
  275. $msg = '已设置首页显示';
  276. if($iscy==0)$msg = '已取消首页显示';
  277. $this->showreturn(array(
  278. 'iscy' => $iscy,
  279. 'msg' => $msg,
  280. ));
  281. }
  282. public function openoutqunAction()
  283. {
  284. $isop = $this->get('isop');
  285. $this->option->setval('outgroupopen'.$this->adminid.'', $isop);
  286. return returnsuccess();
  287. }
  288. }
粤ICP备19079148号