<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../inc/Cls_Manager.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    Dim oRs, Id, RoleName, RoleType
    Id = Easp.Get("id:n:0")
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    Set oRs = Easp.db.GR(TablePrefix & "Admin_Role:RoleName,RoleType:1", " Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "不存在的数据！", "back", "Error", "null"
    Else
        RoleName = oRs("RoleName")
        RoleType = oRs("RoleType")
    End If
    Easp.C oRs
%>
<script src="<%=CmsAdminMapPath%>js/check/manager.role.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain" onsubmit="return CheckForm();">
  <input type="hidden" name="id" value="<%=Id%>" />
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <div class="navigation"><a href="Admin.Role.List.Asp" class="back">角色管理</a> 控制面板 &gt; 管理员管理 &gt; 角色管理 &gt; 添加角色 </div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">添加角色</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th> 角色名称： </th>
            <td class="td2"><input type="text" name="RoleName" id="RoleName" maxlength="50" class="txtInput w350" autocomplete="off" value="<%=RoleName%>" />
              <label>*</label></td>
          </tr>
          <tr>
            <th> 角色类型： </th>
            <td class="td2"><%=GetRoleType(Easp.Cookie("ZjjCmsCms>RoleType"), RoleType)%></td>
          </tr>
          <tr>
            <th> 角色权限： </th>
            <td class="td2"><label style="margin: 0;">
                <input type="checkbox" class="cball" onclick="SelectedItems(this, 'config');" />
                <b>系统设置</b></label></td>
          </tr>
          <tr>
            <th> </th>
            <td class="item_list"><ul>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_config|show"<%=GetRoleSysChk(Id, "sys_config", "show")%> />
                    查看系统配置</label>
                </li>
                <li>
                  <input type="hidden" name="hidName" value="sys_config" />
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_config|edit"<%=GetRoleSysChk(Id, "sys_config", "edit")%> />
                    修改系统配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_model|show"<%=GetRoleSysChk(Id, "sys_model", "show")%> />
                    查看模型配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_model|edit"<%=GetRoleSysChk(Id, "sys_model", "edit")%> />
                    修改模型配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_channel|show"<%=GetRoleSysChk(Id, "sys_channel", "show")%> />
                    查看频道配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_channel|add"<%=GetRoleSysChk(Id, "sys_channel", "add")%> />
                    添加频道配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_channel|edit"<%=GetRoleSysChk(Id, "sys_channel", "edit")%> />
                    修改频道配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_channel|del"<%=GetRoleSysChk(Id, "sys_channel", "del")%> />
                    删除频道配置</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_free|show"<%=GetRoleSysChk(Id, "sys_free", "show")%> />
                    查看自定义</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_free|add"<%=GetRoleSysChk(Id, "sys_free", "add")%> />
                    添加自定义</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_free|edit"<%=GetRoleSysChk(Id, "sys_free", "edit")%> />
                    修改自定义</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_free|del"<%=GetRoleSysChk(Id, "sys_free", "del")%> />
                    删除自定义</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_templabel|show"<%=GetRoleSysChk(Id, "sys_templabel", "show")%> />
                    查看模板</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_templabel|add"<%=GetRoleSysChk(Id, "sys_templabel", "add")%> />
                    添加模板</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_templabel|edit"<%=GetRoleSysChk(Id, "sys_templabel", "edit")%> />
                    修改模板</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_templabel|del"<%=GetRoleSysChk(Id, "sys_templabel", "del")%> />
                    删除模板</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_ad|show"<%=GetRoleSysChk(Id, "sys_ad", "show")%> />
                    查看广告</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_ad|add"<%=GetRoleSysChk(Id, "sys_ad", "add")%> />
                    添加广告</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_ad|edit"<%=GetRoleSysChk(Id, "sys_ad", "edit")%> />
                    修改广告</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_ad|del"<%=GetRoleSysChk(Id, "sys_ad", "del")%> />
                    删除广告</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_link|show"<%=GetRoleSysChk(Id, "sys_link", "show")%> />
                    查看友情链接</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_link|add"<%=GetRoleSysChk(Id, "sys_link", "add")%> />
                    添加友情链接</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_link|edit"<%=GetRoleSysChk(Id, "sys_link", "edit")%> />
                    修改友情链接</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_link|del"<%=GetRoleSysChk(Id, "sys_link", "del")%> />
                    删除友情链接</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_hdp|show"<%=GetRoleSysChk(Id, "sys_hdp", "show")%> />
                    查看幻灯片</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_hdp|add"<%=GetRoleSysChk(Id, "sys_hdp", "add")%> />
                    添加幻灯片</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_hdp|edit"<%=GetRoleSysChk(Id, "sys_hdp", "edit")%> />
                    修改幻灯片</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_hdp|del"<%=GetRoleSysChk(Id, "sys_hdp", "del")%> />
                    删除幻灯片</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_book|show"<%=GetRoleSysChk(Id, "sys_book", "show")%> />
                    查看留言信息</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_book|audit"<%=GetRoleSysChk(Id, "sys_book", "audit")%> />
                    审核留言信息</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_book|reply"<%=GetRoleSysChk(Id, "sys_book", "reply")%> />
                    回复留言信息</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_book|del"<%=GetRoleSysChk(Id, "sys_book", "del")%> />
                    删除留言信息</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|show"<%=GetRoleSysChk(Id, "sys_manager", "show")%> />
                    查看管理员</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|add"<%=GetRoleSysChk(Id, "sys_manager", "add")%> />
                    添加管理员</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|edit"<%=GetRoleSysChk(Id, "sys_manager", "edit")%> />
                    修改管理员</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|del"<%=GetRoleSysChk(Id, "sys_manager", "del")%> />
                    删除管理员</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_role|show"<%=GetRoleSysChk(Id, "sys_role", "show")%> />
                    查看管理角色</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_role|add"<%=GetRoleSysChk(Id, "sys_role", "add")%> />
                    添加管理角色</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_role|edit"<%=GetRoleSysChk(Id, "sys_role", "edit")%> />
                    修改管理角色</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_role|del"<%=GetRoleSysChk(Id, "sys_role", "del")%> />
                    删除管理角色</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_manager|pass"<%=GetRoleSysChk(Id, "sys_manager", "pass")%> />
                    修改管理密码</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_upload|show"<%=GetRoleSysChk(Id, "sys_upload", "show")%> />
                    上传文件管理</label>
                </li>
                <li>
                  <label>
                    <input type="checkbox" name="ChkSysName" class="config" value="sys_upload|del"<%=GetRoleSysChk(Id, "sys_upload", "del")%> />
                    删除上传文件</label>
                </li>
              </ul></td>
          </tr>
          <tr>
            <th> </th>
            <td><table border="0" cellspacing="0" cellpadding="0" class="border_table">
                <thead>
                  <tr>
                    <th width="150"> 频道设置 </th>
                    <th width="70"> <label style="margin: 0;">
                        <input type="checkbox" class="cball" onclick="SelectedItems(this, 'item_show');" />
                        <b>查看</b></label>
                    </th>
                    <th width="70"> <label style="margin: 0;">
                        <input type="checkbox" class="cball" onclick="SelectedItems(this, 'item_add');" />
                        <b>添加</b></label>
                    </th>
                    <th width="70"> <label style="margin: 0;">
                        <input type="checkbox" class="cball" onclick="SelectedItems(this, 'item_edit');" />
                        <b>修改</b></label>
                    </th>
                    <th width="70"> <label style="margin: 0;">
                        <input type="checkbox" class="cball" onclick="SelectedItems(this, 'item_delete');" />
                        <b>删除</b></label>
                    </th>
                  </tr>
                </thead>
                <tbody>
                  <%
                  Dim ChannelRs, ArrayList, i
                  Set ChannelRs = Easp.db.GR(TablePrefix & "Channel:Id,BriefName", "", " Px Asc,Id Desc ")
                  If Not Easp.IsN(ChannelRs) Then
                      ArrayList = ChannelRs.GetRows()
                  End If
                  If IsArray(ArrayList) Then
                      For i = 0 To UBound(ArrayList, 2)
                  %>
                  <tr class="td_c">
                    <td><%=ArrayList(1,i)%>频道 </td>
                    <td><input name="ChkChannel" type="checkbox" class="item_show" value="<%=ArrayList(0,i)%>|show"<%=GetRoleChannelChk(Id, ArrayList(0,i), "show")%> /></td>
                    <td><input name="ChkChannel" type="checkbox" class="item_add" value="<%=ArrayList(0,i)%>|add"<%=GetRoleChannelChk(Id, ArrayList(0,i), "add")%> /></td>
                    <td><input name="ChkChannel" type="checkbox" class="item_edit" value="<%=ArrayList(0,i)%>|edit"<%=GetRoleChannelChk(Id, ArrayList(0,i), "edit")%> /></td>
                    <td><input name="ChkChannel" type="checkbox" class="item_delete" value="<%=ArrayList(0,i)%>|delete"<%=GetRoleChannelChk(Id, ArrayList(0,i), "delete")%> /></td>
                  </tr>
                  <%
                      Next
                  End If
                  %>
                </tbody>
              </table></td>
          </tr>
          <tr>
            <th> </th>
            <td><input type="submit" class="btnSubmit" value="提交保存" />
              &nbsp;
              <input name="重置" type="reset" class="btnSubmit" value="重 置" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_role", "edit"
    '=====================================================================
    Dim Id, RoleName, RoleType, ToUrl
    Id = Easp.Post("id:n:0")
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    '=====================================================================
    RoleName = Trim(Easp.Post("RoleName:s"))
    RoleType = Easp.Post("RoleType:n:0")
    ToUrl = Trim(Easp.Post("ToUrl:s"))
    If Easp.IsN(RoleName) Then
        CmsAdmin.JscriptMsg "角色名称不能为空！", "back", "Error", "null"
    End If
    If RoleType = 0 Then
        CmsAdmin.JscriptMsg "角色类型必须选择！", "back", "Error", "null"
    End If
    '===================================================================== 保存角色
    Easp.Use "list"
    Set List = Easp.List.New
    List("RoleName") = RoleName
    List("RoleType") = RoleType
    ResultVal = Easp.db.UR(TablePrefix & "Admin_Role", " Id = "& Id &" ", List.Hash)
    Easp.C List
    If ResultVal <> 0 Then
        '=====================================================================  先删除角色权限
        Easp.db.DR TablePrefix & "Admin_Role_Val", " RoleId = "& RoleType &" "
        '=====================================================================
        Dim ChkSysName, SpSysName, ChkChannel, SpChannel
        Dim i, ii, ChannelId, ChannelName, ValType, List, ResultVal
        ChkSysName = Trim(Easp.Post("ChkSysName:s"))
        ChkChannel = Trim(Easp.Post("ChkChannel:s"))
        If Not Easp.IsN(ChkSysName) Then
            ChkSysName = Split(ChkSysName, ",")
            For i = 0 To UBound(ChkSysName)
                SpSysName = Split(ChkSysName(i), "|")
                ChannelName = Trim(SpSysName(0))
                ValType = Trim(SpSysName(1))
                '============================================================= 开始入库基本设置权限
                Easp.Use "list"
                Set List = Easp.List.New
                List("RoleId") = Id
                List("ChannelName") = ChannelName
                List("ChannelId") = 0
                List("ValType") = ValType
                List("AddTime") = Now()
                Easp.db.AR TablePrefix & "Admin_Role_Val", List.Hash
                Easp.C List
            Next
        End If
        '=====================================================================
        If Not Easp.IsN(ChkChannel) Then
            ChkChannel = Split(ChkChannel, ",")
            For ii = 0 To UBound(ChkChannel)
                SpChannel = Split(ChkChannel(ii), "|")
                ChannelId = Trim(SpChannel(0))
                ValType = Trim(SpChannel(1))
                '============================================================= 开始入库基本设置权限
                Easp.Use "list"
                Set List = Easp.List.New
                List("RoleId") = Id
                List("ChannelId") = ChannelId
                List("ChannelName") = "Channel"
                List("ValType") = ValType
                List("AddTime") = Now()
                Easp.db.AR TablePrefix & "Admin_Role_Val", List.Hash
                Easp.C List
            Next
        End If
        CmsAdmin.JscriptMsg "编辑角色成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Role.List.Asp", ToUrl), "Success", "null"
    End If
    '=====================================================================
End Sub
%>
