Esempio n. 1
0
 function goModify()
 {
     $power = new Power(&$this->dbObj, $this->getUid());
     $p = $_POST['updid'] + 0;
     $sql = "SELECT otherruleid,configdefault FROM " . WEB_ADMIN_TABPOX . "otherrule WHERE (isrule = 0) AND (issystemvar = 0) AND (ruleid = {$p})";
     $rs = $this->dbObj->GetArray($sql);
     foreach ($rs as $v) {
         $power->parseSqlData(&$v);
         $def = explode('#', $v['configdefault']);
         sort($def);
         $def = implode('#', $def);
         $posData =& $_POST['attachs'][$p];
         if (array_key_exists($v['otherruleid'], $posData)) {
             $tposd = $posData[$v['otherruleid']];
             if (is_array($tposd)) {
                 sort($tposd);
                 $val = implode('#', $tposd);
             } else {
                 $val = $tposd;
             }
             $this->dbObj->Execute('DELETE FROM ' . WEB_ADMIN_TABPOX . 'config WHERE (userid = ' . $this->getUid() . ') AND (otherruleid = ' . $v['otherruleid'] . ')');
             if ($def != $val) {
                 $this->dbObj->Execute('INSERT INTO ' . WEB_ADMIN_TABPOX . 'config(userid,otherruleid,configvalue,importer)VALUES(' . $this->getUid() . ',' . $v['otherruleid'] . ",'" . $val . "'," . $this->getUid() . ')');
             }
         }
     }
     exit('<script>alert("设置成功!");history.go(-1);</script>');
 }
Esempio n. 2
0
    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');
    }
Esempio n. 3
0
 function goAppend()
 {
     $p = new Power(&$this->dbObj, $this->getUid());
     $id = 0;
     $info = '';
     if ($this->isModify) {
         $info = '修改';
         $id = $_POST[MODIFY . 'id'] + 0;
         $this->dbObj->Execute('update ' . WEB_ADMIN_TABPOX . "role set rolename='" . $_POST['rolename'] . "' where roleid = " . $id);
         $this->dbObj->Execute('delete from ' . WEB_ADMIN_TABPOX . 'rolerule where roleid = ' . $id);
         $this->dbObj->Execute('delete from ' . WEB_ADMIN_TABPOX . 'grouprole where roleid = ' . $id);
         $this->dbObj->Execute('delete from ' . WEB_ADMIN_TABPOX . 'attachrule where userorgrouporrole = 3 and userorgrouporroleid = ' . $id);
     } else {
         $info = '增加';
         $this->dbObj->Execute('insert into ' . WEB_ADMIN_TABPOX . "role(rolename,importer)values('" . $_POST['rolename'] . "'," . $this->getUid() . ")");
         $id = $this->dbObj->Insert_ID();
     }
     //角色权
     if (isset($_POST['rules'])) {
         foreach ($_POST['rules'] as $k => $v) {
             $this->dbObj->Execute('INSERT INTO ' . WEB_ADMIN_TABPOX . 'rolerule(roleid,ruleid,issuperuser,canbrowse,canappend,canmodify,candelete,canimport, canexport, canrecoil, canaudit ,importer)' . "VALUES({$id},{$k}.," . (array_key_exists('S', $v) ? 1 : 0) . ',' . (array_key_exists('B', $v) ? 1 : 0) . ',' . (array_key_exists('A', $v) ? 1 : 0) . ',' . (array_key_exists('M', $v) ? 1 : 0) . ',' . (array_key_exists('D', $v) ? 1 : 0) . ',' . (array_key_exists('I', $v) ? 1 : 0) . ',' . (array_key_exists('E', $v) ? 1 : 0) . ',' . (array_key_exists('R', $v) ? 1 : 0) . ',' . (array_key_exists('H', $v) ? 1 : 0) . ',' . $this->getUid() . ')');
         }
     }
     //附加权
     if (isset($_POST['attachs'])) {
         foreach ($_POST['attachs'] as $k => $v) {
             foreach ($v as $ink => $inv) {
                 $currentStr = $inv;
                 if (is_array($inv)) {
                     sort($inv);
                     reset($inv);
                     $currentStr = implode('#', $inv);
                 }
                 $df = $this->dbObj->GetRow('select configdefault from ' . WEB_ADMIN_TABPOX . 'otherrule where otherruleid = ' . $ink);
                 $p->parseSqlData(&$df);
                 //默认值
                 $sourceStr = explode('#', $df['configdefault']);
                 sort($sourceStr);
                 $sourceStr = implode('#', $sourceStr);
                 if ($sourceStr != $currentStr) {
                     $this->dbObj->Execute('INSERT INTO ' . WEB_ADMIN_TABPOX . 'attachrule(userorgrouporrole,userorgrouporroleid,addordel,ruleid,otherruleid,configvalue,importer)' . "values(3,{$id},1,{$k},{$ink},'{$currentStr}'," . $this->getUid() . ')');
                 }
             }
         }
     }
     //所在组
     if (isset($_POST['groups'])) {
         foreach ($_POST['groups'] as $v) {
             $this->dbObj->Execute('INSERT INTO ' . WEB_ADMIN_TABPOX . "grouprole(groupid,roleid,importer)VALUES({$v},{$id}," . $this->getUid() . ')');
         }
     }
     if ($this->isModify) {
         $this->dbObj->Execute("update " . WEB_ADMIN_TABPOX . "login set updatestate = 1 where userid in(\r\n\t\t\t\tselect ug.userid from " . WEB_ADMIN_TABPOX . "usergroup ug \r\n\t\t\t\tinner join " . WEB_ADMIN_TABPOX . "grouprole gr on ug.groupid = gr.groupid where gr.roleid = {$id})");
     }
     $this->quit($info . '完成!');
 }
Esempio n. 4
0
 /**
  * 获得当前页的相关权限,值,或数组值
  */
 function getAttachRule($varname, $id = null)
 {
     require_once WEB_ADMIN_CLASS_PATH . '/power/Power.cls.php';
     $p = new Power($this->_db, $this->getUid());
     if (is_null($id)) {
         $id = $this->_pageid;
     } else {
         if (!is_numeric($id)) {
             $id = $this->getMenuId($id);
         }
     }
     $sql = "\r\n\t\t\tSELECT configtype,configdefault,c.configvalue AS userdefault FROM " . WEB_ADMIN_TABPOX . "otherrule o \r\n\t\t\t\tLEFT OUTER JOIN\t" . WEB_ADMIN_TABPOX . "config c ON ( (o.otherruleid = c.otherruleid) AND (c.userid = " . $this->getUid() . ") )\r\n\t\t\tWHERE (o.isrule = 1) AND (configvarname = '{$varname}') AND (ruleid = {$id})\r\n\t\t";
     $sourceStr = $this->_db->GetRow($sql);
     $p->parseSqlData(&$sourceStr);
     //		print_r($this->_attachRuleArray[$id]);
     //		print_r($sourceStr);
     //		echo '<br>',$varname,'<br>';
     //		echo $id,$varname;
     //		print_r($this->_attachRuleArray[$id][$varname]);
     if (isset($this->_attachRuleArray[$id][$varname])) {
         if (!is_array($this->_attachRuleArray[$id][$varname])) {
             return $this->_attachRuleArray[$id][$varname];
         } else {
             if (isset($sourceStr['configtype'])) {
                 switch (strtolower($sourceStr['configtype'])) {
                     case 'text':
                     case 'select':
                     case 'radio':
                         //有多个可选项的单选项
                         if (strlen($sourceStr['userdefault']) > 0) {
                             return $sourceStr['userdefault'];
                         } else {
                             if (in_array($sourceStr['configdefault'], $this->_attachRuleArray[$id][$varname])) {
                                 return $sourceStr['configdefault'];
                             } else {
                                 sort($this->_attachRuleArray[$id][$varname]);
                                 return $this->_attachRuleArray[$id][$varname][0];
                             }
                         }
                         break;
                     default:
                         return $this->_attachRuleArray[$id][$varname];
                         break;
                 }
             } else {
                 return false;
             }
         }
     } else {
         if (isset($sourceStr['configdefault'])) {
             if (strpos($sourceStr['configdefault'], '#')) {
                 return explode('#', $sourceStr['configdefault']);
             } else {
                 return $sourceStr['configdefault'];
             }
         } else {
             return false;
         }
     }
 }