User_adminAction.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <?php
  2. /*超级管理员操作,修改自身密码
  3. * 及添加新用户
  4. *
  5. * */
  6. require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
  7. require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
  8. class User_adminAction extends Action{
  9. public function __construct(){
  10. parent::__construct();
  11. if(empty($_SESSION['mds_user'])){
  12. header("Location:/?a=index&m=admin_login");
  13. exit();
  14. }
  15. }
  16. function index(){
  17. }
  18. function update(){
  19. // $this->check_user();
  20. $admin = new AdvertAdminAction();
  21. $uname = $_SESSION['user_infos']['uname'];
  22. if($_POST['uname']){
  23. $uname = $_POST['uname'];
  24. $pwd = $_POST['pwd'];
  25. $new_pwd = $_POST['new_pwd'];
  26. if(!empty($uname) && !empty($pwd) && !empty($new_pwd)){
  27. $pwd = md5($pwd);
  28. $new_pwd = md5($new_pwd);
  29. $check_user = $admin->selectUser($uname, $pwd);
  30. if(!empty($check_user)){
  31. $update = $admin->updateUserPwd($uname, $new_pwd);
  32. if($update){
  33. $succ = "修改用户成功";
  34. header("Location:/?a=user_admin&m=update&succ=$succ");
  35. exit();
  36. }
  37. }else{
  38. $this->assign('error','原密码有误');
  39. $this->assign('username',$uname);
  40. }
  41. }else{
  42. $this->assign('error','原密码、新密码必填');
  43. $this->assign('username',$uname);
  44. }
  45. }
  46. $succ = $_REQUEST['succ'];
  47. $this->assign('succ',$succ);
  48. $this->assign('username',$uname);
  49. $this->display('update.html');
  50. }
  51. // function delete(){
  52. //
  53. //// $this->check_user();
  54. //
  55. // $admin = new AdvertAdminAction();
  56. //
  57. // $uname = $_REQUEST['uname'];
  58. //
  59. //
  60. // if($uname!='admin'){
  61. //
  62. // $delete = $admin->deleteUser($uname);
  63. // $info = "删除成功";
  64. //
  65. // }else{
  66. //
  67. // $error = "不能删除超级管理员";
  68. // }
  69. //
  70. // header("Location:/?a=user_admin&m=index&info=$info&error=$error");
  71. // exit();
  72. //
  73. //
  74. // }
  75. //给用户分配权限
  76. function setPersission(){
  77. global $PERSISSION_ARRAY;
  78. $this->check_user();
  79. $admin = new AdvertAdminAction();
  80. $persission_array = $PERSISSION_ARRAY;
  81. $uname = $_REQUEST['uname'];
  82. $perssion = $_REQUEST['persision_array'];
  83. if($_POST['persision_array']){
  84. $persission_string = implode(',', $perssion);
  85. $update = $admin->updateUserPersission($uname, $persission_string);
  86. if($update){
  87. $info = "设置用户权限成功";
  88. }else{
  89. $error = "设置用户权限失败";
  90. }
  91. }
  92. $user_info = $admin->selectUserByName($uname);
  93. $my_persission = $user_info['permission'];
  94. $this->assign('my_persission',$my_persission);
  95. $this->assign('info',$info);
  96. $this->assign('error',$error);
  97. $this->assign('persission_array',$persission_array);
  98. $this->assign('username',$uname);
  99. $this->display('persission.html');
  100. }
  101. //分配角色,及设置直属领导人
  102. function setRole(){
  103. $this->check_user();
  104. $admin = new AdvertAdminAction();
  105. $data['uname'] = $_REQUEST['uname'];
  106. $data['role'] = $_REQUEST['role'];
  107. $data['header_uid'] = $_REQUEST['header_uid'];
  108. if(!empty($data['role'])){
  109. $update = $admin->updateUserRole($data);
  110. if($update){
  111. $info = "设置用户角色及直属领导成功";
  112. header("Location:/?a=user_admin&m=index&info=$info&error=$error");
  113. exit();
  114. }else{
  115. $error = "设置用户角色及直属领导失败";
  116. }
  117. }
  118. $user_info = $admin->selectUserByName($data['uname']);
  119. $header_list = $admin->selectHeaderUser();
  120. $headerList = array();
  121. foreach($header_list as $h){
  122. $headerList[$h['id']] = $h['uname'];
  123. }
  124. $this->assign('header_list',$headerList);
  125. $this->assign('user_info',$user_info);
  126. $this->display('role.html');
  127. }
  128. //end
  129. //判断是否是超级管理员
  130. function check_user(){
  131. if($_SESSION['mds_user']!=='admin'){
  132. echo "<script>alert('I am sorry you can not access');window.location.href='/?a=index&m=login_succ'</script>";
  133. exit;
  134. }
  135. }
  136. //class end
  137. }