/** @desc 根据用户ID查出所有的权限字段 @param $uid Int 用户ID @return Array */ function registerUser($userid = null) { require_once 'Power.cls.php'; if ($userid) { $this->_user = $userid; } $powObj = new Power(&$this->_db, $this->_user); $ruleArr = $powObj->getUserRule($this->_user); $this->_baseRuleArray = $ruleArr['base']; $this->_attachRuleArray = $ruleArr['attach']; $this->logout(); //插入一行记录到登录表 $this->_db->Execute('update ' . WEB_ADMIN_TABPOX . 'login set updatestate=2 where userid=' . $this->_user); $sql = 'insert into ' . WEB_ADMIN_TABPOX . 'login(userid,clientid,superid,rulestr,attachrulestr,updatestate,logintime)' . "values(" . $this->_user . ",'" . $this->getClientId() . "'," . ($this->_superid ? $this->_superid : 'NULL') . ",'" . serialize($this->_baseRuleArray) . "','" . serialize($this->_attachRuleArray) . "',0,'" . time() . "')"; $this->_db->Execute($sql); }
function disp() { $powerObj = new Power(&$this->dbObj, $this->getUid()); $t = new Template('../template/user'); $t->set_file('f', 'userconfig.html'); $t->set_block('f', 'row', 'r'); $t->set_block('f', 'rule', 'ru'); if ($this->getModify()) { $t->set_var('form', '<form name="form1" method="post" action="userconfig.php">'); $t->set_var('endform', '</form>'); } else { $t->set_var('disabled', ' disabled'); } //得到所有附加权 $attachArr = array(); $sql = ' select c.configvalue as userdefalue,r.rulename,o.* from ' . WEB_ADMIN_TABPOX . 'otherrule o LEFT OUTER JOIN ' . WEB_ADMIN_TABPOX . 'rule r ON o.ruleid = r.ruleid LEFT OUTER JOIN ' . WEB_ADMIN_TABPOX . 'config c ON o.otherruleid = c.otherruleid AND c.userid = ' . $this->getUid() . ' where o.isrule = 1 '; $attachRs = $this->dbObj->Execute($sql); while ($tmpRrs = $attachRs->FetchRow()) { $powerObj->parseSqlData(&$tmpRrs); $attachArr[$tmpRrs['ruleid']][$tmpRrs['configvarname']] = $tmpRrs; } $attachRs->Close(); //得到用户的权限 $userRule = $powerObj->getUserRule($this->getUid()); $have = 'none'; foreach ($userRule['attach'] as $k => $v) { //附加权,菜单 foreach ($v as $ink => $inv) { //附加权,菜单下的权 if (is_array($inv) && count($inv) > 1 && $attachArr[$k][$ink]['configtype'] != 'checkbox') { $t->set_var('rulename', $attachArr[$k][$ink]['rulename']); $t->set_var('configname', $attachArr[$k][$ink]['configname']); $values = ''; $default = explode('#', $attachArr[$k][$ink]['configvalue']); foreach ($inv as $in_v) { //权限下的每一项 foreach ($default as $inn_v) { //权限的默认值 $vs = split('=', $inn_v); if (!isset($vs[1])) { $vs[1] = $vs[0]; } $checked = ''; if ($vs[1] == $in_v) { if ($attachArr[$k][$ink]['userdefalue'] == $in_v) { $checked = ' checked'; } $values .= '<input type="radio" name="attachrule[' . $attachArr[$k][$ink]['otherruleid'] . ']" value="' . $vs[1] . '"' . $checked . '>' . $vs[0] . ' '; } } } $t->set_var('values', $values); $t->parse('ru', 'rule', true); $have = ''; } } } $t->set_var('dispMore', $have); //显示可选择项 $dap = new DispAttachRule(&$this->dbObj, $this->getUid()); $rs = $this->dbObj->GetArray('select * from ' . WEB_ADMIN_TABPOX . 'otherrule where (ruleid is null OR ruleid = 0) and (issystemvar = 0) and (isrule is null OR isrule = 0)'); foreach ($rs as $v) { $sval = $this->dbObj->GetOne('select configvalue from ' . WEB_ADMIN_TABPOX . 'config where (userid=' . $this->getUid() . ') and (otherruleid=' . $v['otherruleid'] . ')'); $t->set_var($dap->disp($v, $sval, "</td><td width='50%'><nobr>", 2, "</nobr></td></tr><tr><td width='25%'>")); $t->parse('r', 'row', true); } $t->set_var('configName', '用户'); $t->set_var('path', WEB_ADMIN_HTTPPATH . '/common/'); $t->parse('out', 'f'); $t->p('out'); }