コード例 #1
0
ファイル: pageconfig.php プロジェクト: TonyWoo/cmlerp
 function disp()
 {
     $t = new Template(WEB_ADMIN_TMPPATH);
     $dispObj = new DispAttachRule(&$this->dbObj, $this->getUid());
     $t->set_file('f', 'pageconfig.html');
     $t->set_block('f', 'row', 'r');
     $p = $_GET['pageid'] + 0;
     $sql = "\r\n\t\t\tSELECT c.configvalue AS userdefalut,o.* FROM " . WEB_ADMIN_TABPOX . "otherrule o \r\n\t\t\t\tLEFT OUTER JOIN " . WEB_ADMIN_TABPOX . "config c ON ( (o.otherruleid = c.otherruleid) AND (c.userid = " . $this->getUid() . ") ) \r\n\t\t\tWHERE (o.isrule = 0) AND (o.issystemvar = 0) AND (o.ruleid = {$p})\r\n\t\t";
     $rs = $this->dbObj->GetArray($sql);
     foreach ($rs as $v) {
         $t->set_var($dispObj->disp($v, $v['userdefalut']));
         $t->parse('r', 'row', true);
     }
     $r = '';
     $m = new Menu(&$this->dbObj);
     $s = $m->getRelating($p);
     for ($i = 0; $i < count($s); $i++) {
         if ($i == 0) {
             $r = $s[$i]['rulename'];
         } else {
             $r .= ' > ' . $s[$i]['rulename'];
         }
     }
     $t->set_var('updid', $p);
     $t->set_var('address', $r);
     $t->set_var('path', WEB_ADMIN_HTTPPATH . '/common/');
     $t->parse('out', 'f');
     $t->p('out');
 }
コード例 #2
0
ファイル: attach.php プロジェクト: TonyWoo/cmlerp
 function disp()
 {
     $dsp = new DispAttachRule(&$this->dbObj, $this->getUid());
     $t = new Template(WEB_ADMIN_TMPPATH . '/system/');
     $t->set_file('f', 'attach.html');
     $t->set_block('f', 'row', 'r');
     $t->set_var('add', $this->getAddStr('img'));
     $where = '';
     if (isset($_GET['fieldname']) && $_GET['fieldname'] != '') {
         $where = ' where o.isrule = ' . $_GET['fieldname'];
     }
     $rs = $this->dbObj->Execute('select o.*,r.rulename from ' . WEB_ADMIN_TABPOX . 'otherrule o left outer join ' . WEB_ADMIN_TABPOX . 'rule r on o.ruleid=r.ruleid' . $where);
     while ($v = $rs->FetchRow()) {
         $t->set_var($v);
         $t->set_var($dsp->disp($v, null, "</td><td width='50%'>", 2, "</td></tr><tr><td width='50%'>"));
         $t->set_var('type', $v['issystemvar'] ? '系统' : '用户');
         $t->set_var('field', $v['ruleid'] ? '当前页' : '全局');
         $t->set_var('edit', $this->getUpdStr($v['importer'], $v['otherruleid'], 'img'));
         $t->set_var('del', $this->getDelStr($v['importer'], $v['otherruleid'], 'img'));
         $t->parse('r', 'row', true);
     }
     $t->set_var($_GET);
     $t->set_var('path', WEB_ADMIN_HTTPCOMMON);
     $t->parse('o', 'f');
     $t->p('o');
 }
コード例 #3
0
ファイル: role.php プロジェクト: TonyWoo/cmlerp
 function goDispModify()
 {
     $m = new Menu(&$this->dbObj);
     $p = new Power(&$this->dbObj, $this->getUid());
     $d = new DispAttachRule(&$this->dbObj, $this->getUid());
     $t = new Template('../template/system');
     $t->set_file('f', 'roledetail.html');
     //设置全局权限块
     $t->set_block('f', 'ttr', 'tr');
     $t->set_block('ttr', 'ttd', 'td');
     //设置菜单权限块
     $t->set_block('f', 'ruleList', 'u');
     $t->set_block('ruleList', 'attachList', 'a');
     //设置组块
     $t->set_block('f', 'gtr', 'gr');
     $t->set_block('gtr', 'gtd', 'gd');
     //默认值
     $rudf = $gdf = array();
     if ($this->isAppend) {
         $t->set_var('actionName', '增加');
         $rudf = array('base' => array(), 'attach' => array());
     } else {
         $updid = $_GET[MODIFY . 'id'] + 0;
         $rudf = $p->getRoleRule($updid);
         $t->set_var('actionName', '修改');
         $t->set_var($this->dbObj->GetRow('select * from ' . WEB_ADMIN_TABPOX . 'role where roleid = ' . $updid));
         $gdfr = $this->dbObj->GetArray('select groupid from ' . WEB_ADMIN_TABPOX . 'grouprole where roleid = ' . $updid);
         foreach ($gdfr as $v) {
             $gdf[] = $v['groupid'];
         }
     }
     $t->set_var($_GET);
     //设置全局菜单
     $grus = $this->dbObj->Execute('select * from ' . WEB_ADMIN_TABPOX . 'otherrule where isrule=1 and (ruleid=0 or ruleid is null)');
     $n = 1;
     $l = $grus->NumRows() + 1;
     while ($rs =& $grus->FetchRow()) {
         $gr_df = isset($rudf['attach'][0][$rs['configvarname']]) ? $rudf['attach'][0][$rs['configvarname']] : null;
         $t->set_var($d->disp($rs, $gr_df, "</td><td width='25%'>", 4, "</td></tr><tr><td width='25%'>"));
         $t->parse('td', 'ttd', true);
         if ($n++ % 2 > 0) {
             if ($n == $l) {
                 if (($l - 1) % 2 == 1) {
                     $t->set_var(array('name' => '', 'value' => ''));
                     $t->parse('td', 'ttd', true);
                 }
                 $t->parse('tr', 'ttr', true);
             }
         } else {
             $t->parse('tr', 'ttr', true);
             $t->set_var('td');
         }
     }
     //设置菜单权限
     $rus = $m->getMenuTreeArr(0);
     foreach ($rus as $v) {
         if ($v['ruleurl']) {
             $t->set_var('display', '');
         } else {
             $t->set_var('display', 'none');
         }
         if (array_key_exists($v['ruleid'], $rudf['base'])) {
             $t->set_var('rschecked', $rudf['base'][$v['ruleid']][0] ? ' checked' : '');
             $t->set_var('rbchecked', $rudf['base'][$v['ruleid']][1] ? ' checked' : '');
             $t->set_var('rachecked', $rudf['base'][$v['ruleid']][2] ? ' checked' : '');
             $t->set_var('rmchecked', $rudf['base'][$v['ruleid']][3] ? ' checked' : '');
             $t->set_var('rdchecked', $rudf['base'][$v['ruleid']][4] ? ' checked' : '');
             $t->set_var('richecked', $rudf['base'][$v['ruleid']][5] ? ' checked' : '');
             $t->set_var('rechecked', $rudf['base'][$v['ruleid']][6] ? ' checked' : '');
             $t->set_var('rrchecked', $rudf['base'][$v['ruleid']][7] ? ' checked' : '');
             $t->set_var('rhchecked', $rudf['base'][$v['ruleid']][8] ? ' checked' : '');
         } else {
             $t->set_var('rschecked', '');
             $t->set_var('rbchecked', '');
             $t->set_var('rachecked', '');
             $t->set_var('rmchecked', '');
             $t->set_var('rdchecked', '');
             $t->set_var('richecked', '');
             $t->set_var('rechecked', '');
             $t->set_var('rrchecked', '');
             $t->set_var('rhchecked', '');
         }
         $t->set_var($v);
         $t->set_var('a');
         //设置菜单的附加值
         $ar = $this->dbObj->Execute('select * from ' . WEB_ADMIN_TABPOX . 'otherrule where isrule=1 and ruleid=' . $v['ruleid']);
         while ($arr =& $ar->FetchRow()) {
             $ar_df = isset($rudf['attach'][$v['ruleid']][$arr['configvarname']]) ? $rudf['attach'][$v['ruleid']][$arr['configvarname']] : null;
             $t->set_var($d->disp($arr, $ar_df, "</td><td width='50%'>", 2, "</td></tr><tr><td width='50%'>"));
             $t->parse('a', 'attachList', true);
         }
         $t->parse('u', 'ruleList', true);
     }
     //设置组列表
     $gs = $this->dbObj->GetArray('select * from ' . WEB_ADMIN_TABPOX . 'group');
     $j = count($gs) + 1;
     $i = 1;
     foreach ($gs as $v) {
         $t->set_var($v);
         if (in_array($v['groupid'], $gdf)) {
             $t->set_var('gchecked', ' checked');
         } else {
             $t->set_var('gchecked', '');
         }
         $t->parse('gd', 'gtd', true);
         if ($i++ % 6 > 0) {
             if ($i == $j) {
                 $t->parse('gr', 'gtr', true);
             }
         } else {
             $t->parse('gr', 'gtr', true);
             $t->set_var('gd');
         }
     }
     $t->set_var('path', WEB_ADMIN_HTTPPATH . '/common/');
     $t->parse('out', 'f');
     $t->p('out');
 }
コード例 #4
0
ファイル: userconfig.php プロジェクト: TonyWoo/cmlerp
    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');
    }