mode_userAction.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /**
  3. * 用户管理
  4. */
  5. class mode_userClassAction extends inputAction{
  6. private $depta;
  7. protected function savebefore($table, $cans, $id, $addbo){
  8. if(getconfig('systype')=='demo' && $id>0)return '演示请勿编辑';
  9. if($id>0){
  10. $uto = m($table)->rows('1=1');
  11. $bstr = $this->option->authercheck();
  12. if(is_string($bstr) && $uto>=100)return $bstr.$this->jm->base64decode('77yM5pyA5aSa5Y!v5re75YqgMTAw5Liq55So5oi3');
  13. }
  14. $user = trimstr($cans['user']);
  15. $name = trimstr($cans['name']);
  16. $num = trimstr(arrvalue($cans,'num'));
  17. $email= trimstr(arrvalue($cans,'email'));
  18. $pass = $cans['pass'];
  19. $check= c('check');
  20. $mobile = arrvalue($cans,'mobile');
  21. $weixinid = arrvalue($cans,'weixinid');
  22. $pingyin = arrvalue($cans,'pingyin');
  23. if(!isempt($pass)){
  24. if(strlen($pass)<4)return '密码至少要4位数';
  25. }
  26. $msg = '';
  27. if($check->isincn($user))return '用户名不能有中文';
  28. if(strlen($user)<2)return '用户名必须2位字符以上';
  29. if(!isempt($email) && !$check->isemail($email))return '邮箱格式有误';
  30. if(!isempt($pingyin) && $check->isincn($pingyin))return '名字拼音不能有中文';
  31. if(!isempt($num) && $check->isincn($num))return '编号不能有中文';
  32. if(!isempt($mobile)){
  33. if(!$check->ismobile($mobile))return '手机格式有误';
  34. }
  35. if(isempt($mobile) && isempt($email))return '邮箱/手机号不能同时为空';
  36. if(!isempt($weixinid)){
  37. if(is_numeric($weixinid))return '微信号不能是数字';
  38. if($check->isincn($weixinid))return '微信号不能有中文';
  39. }
  40. $db = m($table);
  41. if($msg=='')if($db->rows("`user`='$user' and `id`<>'$id'")>0)$msg ='用户名['.$user.']已存在';
  42. $rows = array();
  43. if($msg == ''){
  44. $did = $cans['deptid'];
  45. $sup = $cans['superid'];
  46. $rows = $db->getpath($did, $sup);
  47. }
  48. if(isempt($pingyin))$pingyin = c('pingyin')->get($name,1);
  49. $rows['pingyin'] = $pingyin;
  50. $rows['user'] = $user;
  51. $rows['name'] = $name;
  52. $rows['email'] = $email;
  53. $notsave = '';
  54. $randslat = md5($this->rock->jm->getRandkey().time().rand(100,99999));
  55. if($addbo){
  56. if(isempt($pass))$pass = '123456';
  57. $rows['pass'] = md5($pass.$randslat);
  58. $rows['randslat'] = $randslat;
  59. }else{
  60. if(isempt($pass)){
  61. $notsave = 'pass';
  62. }else{
  63. $rows['pass'] = md5($pass.$randslat);
  64. $rows['randslat'] = $randslat;
  65. $rows['editpass'] = '0';
  66. }
  67. }
  68. $arr = array('msg'=>$msg, 'rows'=>$rows,'notsave'=>$notsave);
  69. return $arr;
  70. }
  71. public function companydata()
  72. {
  73. return m('company')->getselectdata(1);
  74. }
  75. //保存后处理
  76. protected function saveafter($table, $cans, $id, $addbo){
  77. m($table)->record(array('superman'=>$cans['name']), "`superid`='$id'");
  78. if(isset($cans['groupname']))m('sjoin')->addgroupuid($id, $cans['groupname']);
  79. return m('admin')->updateinfo('and a.id='.$id.'');
  80. }
  81. //组数据源
  82. public function groupdata()
  83. {
  84. $data = m('sjoin')->getgrouparrs();
  85. if(!$data)$data[] = array(
  86. 'value'=> '0',
  87. 'name' => '无组选择'
  88. );
  89. return $data;
  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 = c('check')->onlynumber($this->post('sid'));
  128. $xid = c('check')->onlynumber($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` group by `ranking`');
  140. foreach($rows as $k=>$rs)$arr[] = array('name'=>$rs['ranking'],'value'=>'');
  141. return $arr;
  142. }
  143. public function editpassAjax()
  144. {
  145. $id = (int)$this->get('id');
  146. $pass = $this->get('pass');
  147. if(!$pass)return;
  148. m('login')->editpass($id, true, $this->jm->base64decode($pass));
  149. return 'ok';
  150. }
  151. }
粤ICP备19079148号