Пример #1
0
 public function act_deletePower()
 {
     $pid = isset($_GET['pid']) ? abs(intval($_GET['pid'])) : 0;
     //echo $pid;exit;
     if (!$pid) {
         self::$errCode = 0;
         self::$errMsg = '请指定要删除的权限!';
         return;
     }
     $powermodel = new powerActionModel();
     $powermodel->deletePower($pid);
     self::$errCode = 1;
     self::$errMsg = '删除完成!';
     return;
 }
Пример #2
0
 public function translatePowerList($powerlist)
 {
     $power = array();
     $groupmodel = new PowerActionGroupModel();
     $powermodel = new powerActionModel();
     foreach ($powerlist as $key => $value) {
         $group = $groupmodel->getGroupInfoById($key);
         $power[$group['groupname']] = array();
         foreach ($value as $v) {
             $powerinfo = $powermodel->getPowerInfoById($v);
             $power[$group['groupname']][] = $powerinfo['actcode'];
         }
     }
     return $power;
 }
Пример #3
0
 public function view_searchpower()
 {
     $group = isset($_POST['group']) ? abs(intval($_POST['group'])) : 0;
     if (!$group) {
         //为指定组 报错
         $urldata = array('msg' => array('要指定所属组!'), 'link' => 'index.php?mod=power&act=powerlist');
         $urldata = urlencode(json_encode($urldata));
         header('location:index.php?mod=showerror&act=showerror&data=' . $urldata);
         exit;
     }
     $key = isset($_POST['keywords']) ? trim($_POST['keywords']) : '';
     if (strlen($key) == 0) {
         //传入了空值
         $urldata = array('msg' => array('请输入要搜索的关键字'), 'link' => 'index.php?mod=power&act=powerlist');
         $urldata = urlencode(json_encode($urldata));
         header('location:index.php?mod=showerror&act=showerror&data=' . $urldata);
         exit;
     }
     $powermodel = new powerActionModel();
     $result = $powermodel->searchPower($group, $key);
     $this->tp_obj->set_file('powerpagese', 'power_search.html');
     //主模板
     $location_ar = array('<a href="index.php?mod=poweruser&act=list" class="navhref">授权管理</a>', '>', '<a href="index.php?mod=power&act=powerlist" class="navhref">权限管理</a>', '>', '权限搜索', '>', $key);
     $this->tp_obj->set_var('pagehtml', $showpage);
     $this->tp_obj->set_var('keywords', $key);
     $this->tp_obj->set_file('header', 'header.html');
     $this->tp_obj->set_file('footer', 'footer.html');
     $this->tp_obj->set_file('navbar', 'transmanagernav.html');
     $this->tp_obj->set_file('powerleftmenu', 'powerleftmenu.html');
     $this->tp_obj->set_block('navbar', 'navlist', 'locationlist');
     //导航
     foreach ($location_ar as $lval) {
         $this->tp_obj->set_var('location', $lval);
         $this->tp_obj->parse('locationlist', 'navlist', TRUE);
     }
     $groupmodel = new PowerActionGroupModel();
     $garray = $groupmodel->getAllPowerGroupList();
     $this->tp_obj->set_block('powerpagese', 'gplist', 'gxlist');
     foreach ($garray as $val) {
         $this->tp_obj->set_var('gid', $val['id']);
         if ($val['id'] == $group) {
             $this->tp_obj->set_var('isselect', 'selected="selected"');
         } else {
             $this->tp_obj->set_var('isselect', '');
         }
         $this->tp_obj->set_var('text', $val['groupname']);
         $this->tp_obj->parse('gxlist', 'gplist', TRUE);
     }
     $this->tp_obj->set_block('powerpagese', 'grouplist', 'glist');
     //权限列表
     foreach ($result as $gval) {
         $this->tp_obj->set_var('id', $gval['id']);
         $this->tp_obj->set_var('gname', $gval['groupname']);
         $this->tp_obj->set_var('name', $gval['actcode']);
         $this->tp_obj->set_var('desc', $gval['actnamezh']);
         $this->tp_obj->set_var('updatetime', date('Y-m-d H:i:s', $gval['lastupdatetime']));
         $this->tp_obj->parse('glist', 'grouplist', true);
     }
     $this->tp_obj->set_var('username', $_SESSION['userName']);
     $this->tp_obj->parse('header', 'header');
     $this->tp_obj->parse('footer', 'footer');
     $this->tp_obj->parse('powerleftmenu', 'powerleftmenu');
     $this->tp_obj->parse('powerpage', 'powerpagese');
     $this->tp_obj->p('powerpage');
 }
Пример #4
0
 public function view_powerEditSubmit()
 {
     $actlist = $_POST['action'];
     $userid = isset($_POST['userid']) ? abs(intval($_POST['userid'])) : 0;
     if (empty($userid)) {
         //没有指定用户id
         $urldata = array('msg' => array('没有指定要编辑的用户!'), 'link' => 'index.php?mod=poweruser&act=list');
         $urldata = urlencode(json_encode($urldata));
         header('location:index.php?mod=showerror&act=showerror&data=' . $urldata);
         exit;
     }
     //var_dump($actlist);
     $groupmodel = new PowerActionGroupModel();
     $actmodel = new powerActionModel();
     /* 验证数据 */
     $dataok = TRUE;
     //var_dump($actlist);exit;
     foreach ($actlist as $key => $value) {
         $groupinfo = $groupmodel->getGroupInfoById($key);
         if (empty($groupinfo)) {
             //没找到改组的信息 数据验证失败 退出循环
             $dataok = FALSE;
             break;
         }
         foreach ($value as $actval) {
             $actinfo = $actmodel->getPowerInfoById($actval);
             if (empty($actinfo)) {
                 //没找到对应的action信息 数据验证失败
                 $dataok = FALSE;
                 break;
             }
         }
         if ($dataok === FALSE) {
             //数据验证失败 退出循环
             break;
         }
     }
     if ($dataok === FALSE) {
         $urldata = array('msg' => array('提交数据不正确'), 'link' => 'index.php?mod=poweruser&act=list');
         $urldata = urlencode(json_encode($urldata));
         header('location:index.php?mod=showerror&act=showerror&data=' . $urldata);
         exit;
     }
     $usermanager = new localUserManageModel();
     $usermanager->updateUserPower($actlist, $userid);
     $urldata = array('msg' => array('更新成功'), 'link' => 'index.php?mod=poweruser&act=list');
     $urldata = urlencode(json_encode($urldata));
     header('location:index.php?mod=showerror&act=showok&data=' . $urldata);
     exit;
 }