
namespace Stat.Security
{
    class Menu
    {
        /// <summary>
        /// 权限项目
        /// </summary>
        /// <returns></returns>
        public string[, ,] PowerItem()
        {
            string[, ,] menu = new string[6, 8, 8];
            /*----------------------------------*/
            menu[0, 0, 0] = "系统配置";

            menu[0, 1, 0] = "系统信息";
            menu[0, 0, 1] = "MWebConfig.Aspx";
            menu[0, 2, 0] = "公司信息";
            menu[0, 0, 2] = "MCompany.Aspx";
            menu[0, 3, 0] = "系统重启";
            menu[0, 0, 3] = "Reset.Aspx";
            menu[0, 4, 0] = "统计图标";
            menu[0, 0, 4] = "MStatLogo.Aspx";
            menu[0, 5, 0] = "邮件服务";
            menu[0, 0, 5] = "MStmp.Aspx";
            menu[0, 6, 0] = "网站导航";
            menu[0, 0, 6] = "Navigate.Aspx";
            menu[0, 7, 0] = "采集服务器";
            menu[0, 0, 7] = "GatherServer.aspx";

            /*----------------------------------*/
            menu[1, 0, 0] = "网站管理";

            menu[1, 1, 0] = "站点列表";
            menu[1, 0, 1] = "MWebList.Aspx";

            menu[1, 2, 0] = "风云榜";
            menu[1, 0, 2] = "SitesRank.aspx";
            /*----------------------------------*/
            menu[2, 0, 0] = "账户管理";

            menu[2, 1, 0] = "管理员管理";
            menu[2, 0, 1] = "Master.aspx";
            menu[2, 2, 0] = "用户管理";
            menu[2, 0, 2] = "MUserList.Aspx";
            /*----------------------------------*/
            menu[3, 0, 0] = "信息管理";

            menu[3, 1, 0] = "网站公告";
            menu[3, 0, 1] = "MNotify.aspx";
            menu[3, 2, 0] = "新闻聚焦";
            menu[3, 0, 2] = "MNews.aspx";
            menu[3, 3, 0] = "用户反馈";
            menu[3, 0, 3] = "MMessage.aspx";
            /*----------------------------------*/
            menu[4, 0, 0] = "网站广告";

            menu[4, 1, 0] = "广告管理";
            menu[4, 0, 1] = "MFrendLick.aspx|MSponsorLink.aspx|MAdImg.aspx|MAdCode.aspx";
            /*----------------------------------*/
            menu[5, 0, 0] = "技术员专区";

            menu[5, 1, 0] = "系统运行";
            menu[5, 0, 1] = "ShowAppRuned.aspx";
            menu[5, 2, 0] = "源数据";
            menu[5, 0, 2] = "ShowDatabase.aspx";
            menu[5, 3, 0] = "缓存数据";
            menu[5, 0, 3] = "ShowCache.aspx";
            menu[5, 4, 0] = "作业情况";
            menu[5, 0, 4] = "ShowTask.aspx";
            menu[5, 5, 0] = "程序报错";
            menu[5, 0, 5] = "ShowError.aspx";
            menu[5, 6, 0] = "升级参考";
            menu[5, 0, 6] = "ShowConsult.aspx";
            menu[5, 7, 0] = "活跃指数";
            menu[5, 0, 7] = " ShowActive.aspx";
            /*----------------------------------*/
            return menu;
        }

        /// <summary>
        /// 管理员 系统 权限 列表
        /// </summary>
        /// <param name="admin_power">用户系统权限</param>
        /// <returns></returns>
        public string GetMasterHtml(string admin_power)
        {
            string[, ,] menu = PowerItem();
            admin_power = "," + admin_power + ",";

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            /*------------------------------------------------------------------------------------------------------*/
            sb.Append("<table width='98%' cellpadding=\"5\" cellspacing=\"0\" border=\"0\">");
            //后台列表
            for (int i = 0; i < menu.GetLength(0); i++)
            {
                sb.Append("<tr><td height=25 class=forumRowHighlight colspan=2 align=left><strong>" + menu[i, 0, 0] + "</strong></td></tr>");
                sb.Append("<tr><td height=20 class=forumrow colspan=2 align=left>");
                for (int j = 1; j < menu.GetLength(1); j++)
                {
                    if (menu[i, j, 0] == null)
                        break;
                    sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;<input type=checkbox class='checkbox' name=\"admin_power\" value=\"" + i.ToString() + j.ToString() + "\"");
                    if (admin_power.IndexOf("," + i.ToString() + j.ToString() + ",") > -1)
                        sb.Append(" checked");
                    sb.Append(">" + i.ToString() + j.ToString() + "." + menu[i, j, 0]);
                    if (j % 5 == 0) sb.Append("<br><br>");
                }
                sb.Append("</td></tr>");
            }
            sb.Append("</table>");

            return sb.ToString();
        }
    }
}
