indexreimAction.php 9.8 KB

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