indexreimAction.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. $this->showreturn($arr);
  159. }
  160. private function isshowshouye($lx, $mr='是')
  161. {
  162. $val = $this->option->getval($lx);
  163. if(isempt($val))$val=$mr;
  164. return $val=='是';
  165. }
  166. public function ldataAction()
  167. {
  168. $loaddt = $this->rock->jm->base64decode($this->post('loaddt'));
  169. if($loaddt && !c('check')->isdatetime($loaddt))$loaddt='';
  170. $type = $this->post('type','history');
  171. $dbs = m('reim');
  172. $json = array();
  173. if($type=='history')$json = $dbs->gethistory($this->adminid, $loaddt);
  174. if($type=='group')$json = $dbs->getgroup($this->adminid);
  175. if($type=='dept')$json = m('dept')->getdata();
  176. if($type=='user')$json = m('admin')->getuser();
  177. if($type=='agent')$json = $dbs->getagent($this->adminid);
  178. if($type=='config')$json = m('reim')->getreims();
  179. $arr['json'] = json_encode($json);
  180. $arr['loaddt'] = $this->now;
  181. $arr['ip'] = $this->ip;
  182. $arr['type'] = $type;
  183. $this->showreturn($arr);
  184. }
  185. public function indexupgetAction()
  186. {
  187. $historyarr = m('reim')->gethistory($this->adminid);
  188. $arr['historyjson'] = json_encode($historyarr);
  189. $this->showreturn($arr);
  190. }
  191. public function changewxtxAction()
  192. {
  193. $tx = (int)$this->post('tx','1');
  194. m('admin')->update('wxtx='.$tx.'', $this->adminid);
  195. $this->showreturn('');
  196. }
  197. public function showmyinfoAction()
  198. {
  199. $dbs = m('admin');
  200. $arr = $dbs->getone($this->adminid,'`id`,`deptallname`,`ranking`,`email`,`tel`,`apptx`,`face`,`name`,`user`,`mobile`');
  201. if(!$arr)$this->showreturn('','not user', 201);
  202. $arr['face'] = $dbs->getface($arr['face']);
  203. $arr['admintoken'] = $this->admintoken;
  204. $arr['companyinfo'] = $dbs->getcompanyinfo($this->adminid, 1);
  205. $arr['companymode'] = ISMORECOM;
  206. if(m('reim')->installwx(3)){
  207. $bdwx = m('wouser')->getone('`uid`='.$this->adminid.'','nickname,headimgurl');
  208. $arr['bdwx'] = $bdwx;
  209. }
  210. $this->showreturn($arr);
  211. }
  212. public function wxbdjcAction()
  213. {
  214. m('wouser')->update('`uid`=0','`uid`='.$this->adminid.'');
  215. $this->showreturn('');
  216. }
  217. //同步微信上头像
  218. public function tongbufaceAction()
  219. {
  220. $reim = m('reim');
  221. if($reim->installwx(1)){
  222. $barr = m('weixinqy:user')->anayface($this->userrs['user'], true);
  223. if($barr['errcode'] != 0)$this->showreturn('',$barr['msg'],202);
  224. $this->showreturn($barr);
  225. }else{
  226. $this->showreturn('','没部署企业微信',201);
  227. }
  228. }
  229. public function loadinfoAction()
  230. {
  231. $type = $this->get('type');
  232. $receid = $this->get('receid');
  233. $arr = array();
  234. if($type=='user'){
  235. $arr = m('admin')->getuser(0, $receid);
  236. }
  237. $this->showreturn($arr);
  238. }
  239. //判断是否有最新历史信息
  240. public function loadhitAction()
  241. {
  242. $time = $this->get('time');
  243. $arr['loadtime'] = $time;
  244. $optdt = date('Y-m-d H:i:s', $time);
  245. $arr['total'] = 0;
  246. $historyarr = m('reim')->gethistory($this->adminid, $optdt);
  247. $arr['rows'] = $historyarr;
  248. if($historyarr)$arr['loadtime'] = strtotime($historyarr[0]['optdt']);
  249. $this->showreturn($arr);
  250. }
  251. //设置常应用
  252. public function shecyyAction()
  253. {
  254. $yynum = $this->get('yynum');
  255. $myyyid= $this->option->getval('yinghomeshow_'.$this->adminid.'');
  256. $yarrs = array();
  257. $iscy = 0;
  258. if(isempt($myyyid)){
  259. $yarrs[]= $yynum;
  260. $iscy = 1;
  261. }else{
  262. $yarrs = explode(',', $myyyid);
  263. if(in_array($yynum, $yarrs)){
  264. $iscy = 0;
  265. foreach($yarrs as $k1=>$v1)if($v1==$yynum)unset($yarrs[$k1]);
  266. }else{
  267. $iscy = 1;
  268. $yarrs[]= $yynum;
  269. }
  270. }
  271. $myyyid = join(',', $yarrs);
  272. $this->option->setval('yinghomeshow_'.$this->adminid.'', $myyyid);
  273. $msg = '已设置首页显示';
  274. if($iscy==0)$msg = '已取消首页显示';
  275. $this->showreturn(array(
  276. 'iscy' => $iscy,
  277. 'msg' => $msg,
  278. ));
  279. }
  280. public function openoutqunAction()
  281. {
  282. $isop = $this->get('isop');
  283. $this->option->setval('outgroupopen'.$this->adminid.'', $isop);
  284. return returnsuccess();
  285. }
  286. }