示例#1
0
        public bool CheckAccessLevel(string charName, BoardAccessLevel level)
        {
            var checkname = charName.ToLower();

            if (ModeratorList.Contains(checkname))
            {
                return(true);
            }

            if (BlockList.Contains(checkname))
            {
                return(false);
            }

            switch (level)
            {
            case BoardAccessLevel.Read:
                return(ReaderList.Count == 0 || ReaderList.Contains(checkname) || WriterList.Contains(checkname));

            case BoardAccessLevel.Write:
                return(WriterList.Count == 0 || WriterList.Contains(checkname));

            case BoardAccessLevel.Moderate:
                return(ModeratorList.Contains(checkname));
            }
            return(false);
        }
示例#2
0
 public void SetAccessLevel(string charName, BoardAccessLevel level)
 {
     if (level == BoardAccessLevel.Read)
     {
         ReaderList.Add(charName.ToLower());
     }
     if (level == BoardAccessLevel.Moderate)
     {
         ModeratorList.Add(charName.ToLower());
     }
     if (level == BoardAccessLevel.Write)
     {
         WriterList.Add(charName.ToLower());
     }
 }
示例#3
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int avIndex = Convert.ToInt32(DropDownList1.SelectedValue);

        MultiView1.ActiveViewIndex = avIndex;

        SnitzRoleProvider srp = new SnitzRoleProvider();

        if (avIndex == 0)                       //Moderator View
        {
            if (ModeratorList.Items.Count == 0) // if the list has never been filled
            {
                ModeratorList.DataSource     = srp.GetUsersInRole("Moderator");
                ModeratorList.DataTextField  = "u.UserName";
                ModeratorList.DataValueField = "u.UserId";
                ModeratorList.DataBind();

                if (ModeratorList.SelectedItem == null)
                {
                    ModeratorList.SelectedIndex = 0;
                }
            }


            int memberId = Convert.ToInt32(ModeratorList.SelectedItem.Value);

            Dictionary <int, string> unForumList = Moderators.GetUnModeratedForumsIdNameList(memberId);
            AvForumsList.DataSource     = unForumList;
            AvForumsList.DataTextField  = "Value";
            AvForumsList.DataValueField = "Key";

            Dictionary <int, string> forumList = Moderators.GetModeratedForumsIdNameList(memberId);
            MdForumsList.DataSource     = forumList;
            MdForumsList.DataTextField  = "Value";
            MdForumsList.DataValueField = "Key";
        }
        else  // Forums View
        {
            if (ForumsList.Items.Count == 0)
            {
                ForumsList.DataSource     = Forums.GetAllForums();
                ForumsList.DataTextField  = "Subject";
                ForumsList.DataValueField = "Id";

                ForumsList.DataBind();

                if (ForumsList.SelectedItem == null)
                {
                    ForumsList.SelectedIndex = 0;
                }
            }


            int forumId = Convert.ToInt32(ForumsList.SelectedItem.Value);

            Dictionary <int, string> avList = Moderators.GetAvailableModeratorsIdName(forumId);
            AvModsList.DataSource     = avList;
            AvModsList.DataTextField  = "Value";
            AvModsList.DataValueField = "Key";

            Dictionary <int, string> mList = Moderators.GetCurrentModeratorsIdName(forumId);
            CurModsList.DataSource     = mList;
            CurModsList.DataTextField  = "Value";
            CurModsList.DataValueField = "Key";
        }

        Page.DataBind();
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SnitzRoleProvider srp = new SnitzRoleProvider();
            int avIndex           = Convert.ToInt32(DropDownList1.SelectedValue);
            MultiView1.ActiveViewIndex = Convert.ToInt32(DropDownList1.SelectedValue);

            if (avIndex == 0) //Moderator View
            {
                int memberId;

                ModeratorList.DataSource     = Moderators.GetAll();
                ModeratorList.DataTextField  = "Name";
                ModeratorList.DataValueField = "MemberId";

                ModeratorList.DataBind();


                if (ModeratorList.SelectedItem == null)
                {
                    ModeratorList.SelectedIndex = 0;
                }
                if (ModeratorList.Items.Count > 0)
                {
                    memberId = Convert.ToInt32(ModeratorList.SelectedValue);
                }
                else
                {
                    SaveBtn.Enabled = false;
                    memberId        = 0;
                }

                Dictionary <int, string> unForumList = Moderators.GetUnModeratedForumsIdNameList(memberId);
                AvForumsList.DataSource     = unForumList;
                AvForumsList.DataTextField  = "Value";
                AvForumsList.DataValueField = "Key";

                Dictionary <int, string> forumList = Moderators.GetModeratedForumsIdNameList(memberId);
                MdForumsList.DataSource     = forumList;
                MdForumsList.DataTextField  = "Value";
                MdForumsList.DataValueField = "Key";
            }
            else  // Forums View
            {
                //DataTable fList = ForumDatasource.GetForumsIDSubject();

                ForumsList.DataSource     = Forums.GetAllForums();
                ForumsList.DataTextField  = "Title";
                ForumsList.DataValueField = "ForumId";

                ForumsList.DataBind();

                if (ForumsList.SelectedItem == null)
                {
                    ForumsList.SelectedIndex = 0;
                }

                int forumId = Convert.ToInt32(ForumsList.SelectedItem.Value);

                List <MemberInfo> avList = Moderators.GetAvailableModerators(forumId);
                AvModsList.DataSource     = avList;
                AvModsList.DataTextField  = "Username";
                AvModsList.DataValueField = "Id";

                CurModsList.DataSource     = Forums.GetForumModerators(forumId);
                CurModsList.DataTextField  = "Value";
                CurModsList.DataValueField = "Key";
            }

            Page.DataBind();
        }
    }