1
0

extentAction.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. class extentClassAction extends Action
  3. {
  4. public function beforeextentuser($table)
  5. {
  6. $key = $this->post('key');
  7. $where = '';
  8. if(!isempt($key))$where = m('admin')->getkeywhere($key);
  9. if($this->adminid>1)$where.=m('admin')->getcompanywhere();
  10. return array(
  11. 'where' => 'and `status`=1 and `type`=0 '.$where.'',
  12. 'fields'=> '`id`,`name`,`user`,`deptname`'
  13. );
  14. }
  15. public function beforeextentgroup($table)
  16. {
  17. $where = '';
  18. if($this->adminid>1 && ISMORECOM){
  19. $where.= 'and `companyid` in('.m('admin')->getcompanyid().')';
  20. }
  21. return $where;
  22. }
  23. /**
  24. 保存
  25. */
  26. public function saveAjax()
  27. {
  28. $type = $this->rock->post('type');
  29. $mid = $this->rock->post('mid');
  30. $checkaid = $this->rock->post('checkaid');
  31. if($type == 'clear'){
  32. $this->extentclear($mid);
  33. }else{
  34. $this->db->delete($this->T('sjoin'), "`type`='$type' and `mid`='$mid'");
  35. }
  36. $ntable = '';
  37. $msg = '';
  38. switch($type){
  39. case 'um';
  40. $ntable = ''.PREFIX.'menu';
  41. break;
  42. case 'gm';
  43. $ntable = ''.PREFIX.'menu';
  44. break;
  45. case 'mu';
  46. $ntable = ''.PREFIX.'admin';
  47. break;
  48. case 'mg';
  49. $ntable = ''.PREFIX.'group';
  50. break;
  51. }
  52. if($ntable != '' && $checkaid != '' ){
  53. $this->db->insert($this->T('sjoin'),'`type`,`mid`,`sid`,`indate`',"select '$type','$mid',`id`,'$this->now' from `$ntable` where `id` in($checkaid)",true);
  54. }
  55. if($msg=='')$msg='success';
  56. echo $msg;
  57. }
  58. //清空用户权限
  59. private function extentclear($uid)
  60. {
  61. $this->db->delete($this->T('sjoin'), "( (`type` in ('um','uu','ut') and `mid`='$uid') or (`type`='mu' and `sid`='$uid') )");
  62. }
  63. public function qingkongAjax()
  64. {
  65. $this->db->delete($this->T('sjoin'), "`type` not in ('ug','gu')");
  66. }
  67. /**
  68. 获取权限信息
  69. */
  70. function getextentAjax()
  71. {
  72. $type = $this->rock->post('type');
  73. $mid = $this->rock->post('mid');
  74. $ntable = '';
  75. $s = '[0]';
  76. //权限查看的
  77. if($type == 'view'){
  78. $s = m('sjoin')->getuserext($mid);
  79. }else{
  80. $rsa = $this->db->getall("select `sid` from `".PREFIX."sjoin` where `type`='$type' and `mid`='$mid'");
  81. foreach($rsa as $rs)$s.=',['.$rs['sid'].']';
  82. }
  83. echo $s;
  84. }
  85. }
粤ICP备19079148号