public static function cacheLocalPower($uid) { global $memc_obj; $usermanager = new localUserManageModel(); $userinfo = $usermanager->getUserInfoById($uid); $powerlist = $usermanager->translatePowerList(unserialize($userinfo['powerlist'])); $powerlist = serialize($powerlist); if (empty($userinfo)) { //没找到本地用户信息 则存空数组 $memc_obj->set($uid . '_localpower', serialize(array()), C('CACHELIFETIME')); } else { $r = $memc_obj->set($uid . '_localpower', $powerlist, C('CACHELIFETIME')); } }
public function view_editpower() { $uid = isset($_GET['uid']) ? abs(intval($_GET['uid'])) : 0; if (empty($uid)) { //没有传用户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; } $usermanager = new localUserManageModel(); $userinfo = $usermanager->getUserInfoById($uid); if (empty($userinfo)) { //没找到用户信息 $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; } global $dbConn; $sql = "select pag.groupname,pag.groupnamezh, pag.id as gid , pa.actcode, pa.actnamezh, pa.id as aid from trans_power_actiongroup as pag left join trans_power_actions as pa on pag.id=pa.gid where pag.isdelete='0' and pa.isdelete = '0' order by pag.id "; //echo $sql;exit; $rowlist = $dbConn->fetch_array_all($dbConn->query($sql)); $resultlist = array(); foreach ($rowlist as $rval) { if (!array_key_exists($rval['gid'], $resultlist)) { $resultlist[$rval['gid']] = array('ginfo' => array('gid' => $rval['gid'], 'gname' => $rval['groupname'], 'gnamezh' => $rval['groupnamezh']), 'actionlist' => array(array('aname' => $rval['actcode'], 'anamezh' => $rval['actnamezh'], 'aid' => $rval['aid']))); } else { $resultlist[$rval['gid']]['actionlist'][] = array('aname' => $rval['actcode'], 'anamezh' => $rval['actnamezh'], 'aid' => $rval['aid']); } } $userpower = unserialize($userinfo['powerlist']); //var_dump($userpower);exit; $location_ar = array('<a href="index.php?mod=poweruser&act=list" class="navhref">授权系统</a>', '>', '<span class="navlast">用户权限编辑</span>', '>', $userinfo['username']); $this->tp_obj->set_var('module', '用户权限编辑--权限管理'); $this->tp_obj->set_var('username', $userinfo['username']); $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_file('powerpage', 'poweruserpoweredit.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); } $this->tp_obj->set_block('powerpage', 'actionlist', 'action_l'); foreach ($resultlist as $value) { $this->tp_obj->set_var('groupname', $value['ginfo']['gname']); $this->tp_obj->set_var('groupnamezh', $value['ginfo']['gnamezh']); $actstring = ''; $gid = $value['ginfo']['gid']; //print_r($value['actionlist']);exit; foreach ($value['actionlist'] as $actval) { $checked = ''; if (isset($userpower[$gid]) && in_array($actval['aid'], $userpower[$gid])) { $checked = 'checked="checked"'; } $actstring .= <<<EOD <label title="{$actval['anamezh']}"><input {$checked} type="checkbox" id="action" style="vertical-align:middle" name="action[{$gid}][]" value="{$actval['aid']}" value="tquery">{$actval['aname']}【{$actval['anamezh']}】</label> EOD; } $this->tp_obj->set_var('actions', $actstring); $this->tp_obj->parse('action_l', 'actionlist', TRUE); } $this->tp_obj->set_var('userid', $uid); $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', 'powerpage'); $this->tp_obj->p('powerpage'); }