logo

(.NET)JTBC2.0模块及分类添加权限访问

2025-02-19 点击 63

1.添加模块配置字段(文章模块)
后台开始>系统相关>系统工具>配置管理
代号中输入: articles.cfg.config

添加naccount节点
name: naccount
chinese: passport/account

添加npopedom节点
name: npopedom
chinese: -1
说明:-1为游客;0为注册用户;1为高级用户;999为管理用户;


2.修改后台栏目分类

分类数据表jtbc_sys_category中添加字段:
字段名:ca_popedom   
类型:int  
默认值: -1

2.1 打开admin\category\common\language\config.jtbc
添加popodom节点

    <item>
      <name><![CDATA[popedom]]></name>
      <chinese><![CDATA[阅读权限]]></chinese>
    </item>
2.2 打开passport\account\common\language\sel_group.jtbc
添加节点

    <item>
      <name><![CDATA[-1]]></name>
      <chinese><![CDATA[来宾用户]]></chinese>
    </item>

2.3 打开admin\category\common\template\manage-interface.jtbc
add节点修改参考:
      <form id="form1" method="post" action="manage-interface.aspx?type=action&atype=add" onsubmit="return manages.tAdd('form1');">
      <table width="100%" cellspacing="0" cellpadding="0" border="0">
        <tr>
          <td width="80" class="txt">{$=itake("config.topic", "lng")}</td>
          <td class="txt"><input type="text" name="topic" size="20" class="text" rtype="Require" rmessage="{$=itake("manage.req_topic", "lng")}" /> </td>
        </tr>
        <tr>
          <td class="txt">{$=itake("config.popedom", "lng")}</td>
          <td class="txt"><select name="popedom" class="select" >{$=xmlSelect("global.passport/account:sel_group.all", "-1", "select")}</select></td>
        </tr>
        <tr>
          <td width="80" class="txt"></td>
          <td class="txt"><input id="ajaxSubmit" type="submit" class="btn" value="{$=itake("global.lng_config.submit", "lng")}" /></td>
        </tr>
      </table>
      </form>
      
edit节点修改参考:

      <form id="form2" method="post" action="manage-interface.aspx?type=action&atype=edit&id={$id}" onsubmit="return manages.tEdit('form2');">
      <table width="100%" cellspacing="0" cellpadding="0" border="0">
        <tr>
          <td width="80" class="txt">{$=itake("config.topic", "lng")}</td>
          <td class="txt"><input type="text" name="topic" size="20" class="text" value="{$topic}" /></td>
        </tr>
        <tr>
          <td class="txt">{$=itake("config.popedom", "lng")}</td>
          <td class="txt"><select name="popedom" class="select" >{$=xmlSelect("global.passport/account:sel_group.all", "{$popedom}", "select")}</select></td>
        </tr>
        <tr>
          <td width="80" class="txt"></td>
          <td class="txt"><input id="popup-ajaxSubmit" type="submit" class="btn" value="{$=itake("global.lng_config.submit", "lng")}" /></td>
        </tr>
      </table>
      </form>
2.4 打开admin\category\common\codefile\manage-interface.cs

找到  private string Module_Action_Add()
    在int tfid = cls.getNum(request.form("fid"), 0);下面添加
    int tpopedom = cls.getNum(request.form("popedom"), -1);
    在tsqlstr += cls.cfnames(tfpre, "topic") + ",";下面添加
      tsqlstr += cls.cfnames(tfpre, "popedom") + ",";
    在tsqlstr += "'" + cls.getLeft(encode.addslashes(request.form("topic")), 50) + "',";下面添加
      tsqlstr += tpopedom + ",";

找到  private string Module_Action_Edit()
    在int tid = cls.getNum(request.querystring("id"));下面添加
    int tpopedom = cls.getNum(request.form("popedom"), -1);
    
参考修改这段:
      tsqlstr = "update " + tdatabase + " set ";
      tsqlstr += cls.cfnames(tfpre, "topic") + "='" + cls.getLeft(encode.addslashes(request.form("topic")), 50) + "',";
      tsqlstr += cls.cfnames(tfpre, "popedom") + "=" + tpopedom;
      tsqlstr += " where " + tidfield + "=" + tid;
      
3.修改模块代码文件(文章模块)
打开文件articles\common\codefile\default.cs
3.1 找到代码
public partial class module: jpage
{
替换为:
public partial class module: jpage
{
  private account account;

  private bool PP_CheckPopedom(string argPopedom)
  {
    bool tBoolean = true;
    string tPopedom = argPopedom;
    if (!cls.isEmpty(tPopedom))
    {
      tBoolean = false;
      string tUserGroup = cls.toString(account.getUserInfo("group"));
      if (cls.getNum(tUserGroup,-1) >= cls.toInt32(tPopedom)) tBoolean = true;
    }
    return tBoolean;
  }
3.2 找到代码
  private string Module_List()
  {
把代码tmpstr = jt.itake("default.list", "tpl");
替换为:
    //**********************************access right set  start***************************************//
    if(cls.toString(tClass) == "-1"){
        string tnpopedom = cls.getString(jt.itake("config.npopedom", "cfg"));
        if (!PP_CheckPopedom(tnpopedom)){
            tmpstr = com.webMessages(jt.itake("global.forum:default.popedom-error-1", "lng"), "-1");
        }else{
        tmpstr = jt.itake("default.list", "tpl");
        }
    }else{
        string csqlstr = "select * from jtbc_sys_category where ca_id=" + tClass;
        object[] cArys = db.getDataAry(csqlstr);
        if (cArys != null)
        {
        object[,] cAry = (object[,])cArys[0];
        string tPopedom = cls.toString(db.getValue(cAry, cls.cfnames("ca_", "popedom")));
            if (!PP_CheckPopedom(tPopedom)){
            tmpstr = com.webMessages(jt.itake("global.forum:default.popedom-error-1", "lng"), "-1");
        }else{
            tmpstr = jt.itake("default.list", "tpl");
            }
        }
    }
    //**********************************access right set  end***************************************//

3.3 找到最下面的代码
  protected void Page_Load()
  {
    PageInit();
    
在下面添加代码:
    account = new account();
    account.Init(jt.itake("config.naccount", "cfg"));
    account.UserInit();



说明:以上为修改文章模块的代码,其它模块可以参考来做。


功能说明:

1.可以实现模块权限设定
2.可以实现按模块的分类设置
0%