mode_userAction.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * 用户管理
  4. */
  5. class mode_userClassAction extends inputAction{
  6. protected function savebefore($table, $cans, $id, $addbo){
  7. if(getconfig('systype')=='demo' && $id>0)return '演示请勿编辑';
  8. if($id>0){
  9. $uto = m($table)->rows('1=1');
  10. $bstr = $this->option->authercheck();
  11. if(is_string($bstr) && $uto>=100)return $bstr.$this->jm->base64decode('77yM5pyA5aSa5Y!v5re75YqgMTAw5Liq55So5oi3');
  12. }
  13. $user = trimstr($cans['user']);
  14. $name = trimstr($cans['name']);
  15. $num = trimstr(arrvalue($cans,'num'));
  16. $email= trimstr(arrvalue($cans,'email'));
  17. $pass = $cans['pass'];
  18. $check= c('check');
  19. $mobile = arrvalue($cans,'mobile');
  20. $weixinid = arrvalue($cans,'weixinid');
  21. $pingyin = arrvalue($cans,'pingyin');
  22. if(!isempt($pass)){
  23. if(strlen($pass)<4)return '密码至少要4位数';
  24. }
  25. $msg = '';
  26. if($check->isincn($user))return '用户名不能有中文';
  27. if(strlen($user)<2)return '用户名必须2位字符以上';
  28. if(!isempt($email) && !$check->isemail($email))return '邮箱格式有误';
  29. if(!isempt($pingyin) && $check->isincn($pingyin))return '名字拼音不能有中文';
  30. if(!isempt($num) && $check->isincn($num))return '编号不能有中文';
  31. if(!isempt($mobile)){
  32. if(!$check->ismobile($mobile))return '手机格式有误';
  33. }
  34. if(isempt($mobile) && isempt($email))return '邮箱/手机号不能同时为空';
  35. if(!isempt($weixinid)){
  36. if(is_numeric($weixinid))return '微信号不能是数字';
  37. if($check->isincn($weixinid))return '微信号不能有中文';
  38. }
  39. $db = m($table);
  40. if($msg=='')if($db->rows("`user`='$user' and `id`<>'$id'")>0)$msg ='用户名['.$user.']已存在';
  41. $rows = array();
  42. if($msg == ''){
  43. $did = $cans['deptid'];
  44. $sup = $cans['superid'];
  45. $rows = $db->getpath($did, $sup);
  46. }
  47. if(isempt($pingyin))$pingyin = c('pingyin')->get($name,1);
  48. $rows['pingyin'] = $pingyin;
  49. $rows['user'] = $user;
  50. $rows['name'] = $name;
  51. $rows['email'] = $email;
  52. $notsave = '';
  53. if($addbo){
  54. if(isempt($pass))$pass = 'Zhks2023_jw';
  55. $rows['pass'] = md5($pass);
  56. }else{
  57. if(isempt($pass)){
  58. $notsave = 'pass';
  59. }else{
  60. $rows['pass'] = md5($pass);
  61. $rows['editpass'] = '0';
  62. }
  63. }
  64. $info = [ $table, $cans, $id, $addbo ];
  65. // // 第三方会议-第三方同步创建用户
  66. // m('meet_sys_login')->createUser($user, $pass, False);
  67. $arr = array('msg'=>$msg, 'rows'=>$rows, 'notsave'=>$notsave);
  68. return $arr;
  69. }
  70. public function companydata()
  71. {
  72. return m('company')->getselectdata(1);
  73. }
  74. //保存后处理
  75. protected function saveafter($table, $cans, $id, $addbo){
  76. m($table)->record(array('superman'=>$cans['name']), "`superid`='$id'");
  77. if(isset($cans['groupname']))m('sjoin')->addgroupuid($id, $cans['groupname']);
  78. // 第三方会议-第三方同步创建用户第三方平台密码调整
  79. $uname = $cans['user'];
  80. $pass = $cans['pass'];
  81. m('meet_sys_login')->changeUserInfo($uname, $pass);
  82. return m('admin')->updateinfo('and a.id='.$id.'');
  83. }
  84. //组数据源
  85. public function groupdata()
  86. {
  87. return m('sjoin')->getgrouparrs();
  88. }
  89. //生成列表页,数据读取后处理
  90. protected function storeafter($table, $rows)
  91. {
  92. $barr['rows'] = $rows;
  93. if($this->loadci==1 && $this->post('atype')=='txlmy'){
  94. $this->depta = array();
  95. $drows = m('dept')->getdata($rows);
  96. $fids = '0';
  97. if($drows)$fids = $drows[0]['pid'];
  98. $barr['deptdata'] = $this->depttreeshu($drows, $fids, $fids);
  99. $barr['drows'] = $drows;
  100. }
  101. return $barr;
  102. }
  103. //更新在线的状态,token10分钟内都是在线
  104. protected function storebefore($table)
  105. {
  106. m('login')->updateallonline();
  107. }
  108. //组织结构活动得到树形数据
  109. private function depttreeshu($rows, $pid, $fids)
  110. {
  111. $barr = array();
  112. foreach($rows as $k=>$rs){
  113. if($rs['pid']==$pid){
  114. $rs['children'] = $this->depttreeshu($rows, $rs['id'], $fids);
  115. $rs['expanded'] = $pid==$fids;
  116. $barr[] = $rs;
  117. }
  118. }
  119. return $barr;
  120. }
  121. //修改上级
  122. public function editsuperAjax()
  123. {
  124. $sna = $this->post('sna');
  125. $sid = $this->post('sid');
  126. $xid = $this->post('xid');
  127. m('admin')->update(array(
  128. 'superid' => $sid,
  129. 'superman' => $sna,
  130. ),"`id` in($xid) and id not in($sid)");
  131. m('admin')->updateinfo(); //更新
  132. return 'ok';
  133. }
  134. public function rankingdata()
  135. {
  136. $arr = array();
  137. $rows = $this->db->getall('select `ranking` from `[Q]admin` where ranking is not null group by `ranking`');
  138. foreach($rows as $k=>$rs)$arr[] = array('name'=>$rs['ranking'],'value'=>'');
  139. return $arr;
  140. }
  141. }