mode_userAction.php 4.4 KB

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