mode_userAction.php 4.2 KB

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