mode_userAction.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. // 初始化密码
  55. $passStr = 'Zhks'.$rows['user'].'@jw';
  56. if(isempt($pass))$pass = $passStr;
  57. $rows['pass'] = md5($pass);
  58. }else{
  59. if(isempt($pass)){
  60. $notsave = 'pass';
  61. }else{
  62. $rows['pass'] = md5($pass);
  63. $rows['editpass'] = '0';
  64. }
  65. }
  66. $info = [ $table, $cans, $id, $addbo ];
  67. // // 第三方会议-第三方同步创建用户
  68. // m('meet_sys_login')->createUser($user, $pass, False);
  69. $arr = array('msg'=>$msg, 'rows'=>$rows, 'notsave'=>$notsave);
  70. return $arr;
  71. }
  72. public function companydata()
  73. {
  74. return m('company')->getselectdata(1);
  75. }
  76. //保存后处理
  77. protected function saveafter($table, $cans, $id, $addbo){
  78. m($table)->record(array('superman'=>$cans['name']), "`superid`='$id'");
  79. if(isset($cans['groupname']))m('sjoin')->addgroupuid($id, $cans['groupname']);
  80. // 第三方会议-第三方同步创建用户第三方平台密码调整
  81. // $uname = $cans['user'];
  82. // $pass = $cans['pass'];
  83. // m('meet_sys_login')->changeUserInfo($uname, $pass);
  84. return m('admin')->updateinfo('and a.id='.$id.'');
  85. }
  86. //组数据源
  87. public function groupdata()
  88. {
  89. return m('sjoin')->getgrouparrs();
  90. }
  91. //生成列表页,数据读取后处理
  92. protected function storeafter($table, $rows)
  93. {
  94. $barr['rows'] = $rows;
  95. if($this->loadci==1 && $this->post('atype')=='txlmy'){
  96. $this->depta = array();
  97. $drows = m('dept')->getdata($rows);
  98. $fids = '0';
  99. if($drows)$fids = $drows[0]['pid'];
  100. $barr['deptdata'] = $this->depttreeshu($drows, $fids, $fids);
  101. $barr['drows'] = $drows;
  102. }
  103. return $barr;
  104. }
  105. //更新在线的状态,token10分钟内都是在线
  106. protected function storebefore($table)
  107. {
  108. m('login')->updateallonline();
  109. }
  110. //组织结构活动得到树形数据
  111. private function depttreeshu($rows, $pid, $fids)
  112. {
  113. $barr = array();
  114. foreach($rows as $k=>$rs){
  115. if($rs['pid']==$pid){
  116. $rs['children'] = $this->depttreeshu($rows, $rs['id'], $fids);
  117. $rs['expanded'] = $pid==$fids;
  118. $barr[] = $rs;
  119. }
  120. }
  121. return $barr;
  122. }
  123. //修改上级
  124. public function editsuperAjax()
  125. {
  126. $sna = $this->post('sna');
  127. $sid = $this->post('sid');
  128. $xid = $this->post('xid');
  129. m('admin')->update(array(
  130. 'superid' => $sid,
  131. 'superman' => $sna,
  132. ),"`id` in($xid) and id not in($sid)");
  133. m('admin')->updateinfo(); //更新
  134. return 'ok';
  135. }
  136. public function rankingdata()
  137. {
  138. $arr = array();
  139. $rows = $this->db->getall('select `ranking` from `[Q]admin` where ranking is not null group by `ranking`');
  140. foreach($rows as $k=>$rs)$arr[] = array('name'=>$rs['ranking'],'value'=>'');
  141. return $arr;
  142. }
  143. }