Пример #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            if (!Page.IsPostBack)
            {
                // Read all the current existing forums and their section names.
                ForumsWithSectionNameTypedList forumsWithSectionNames = ForumGuiHelper.GetAllForumsWithSectionNames();
                rpForums.DataSource = forumsWithSectionNames;
                rpForums.DataBind();

                SectionCollection sections = SectionGuiHelper.GetAllSections();
                cbxSections.DataSource = sections;
                cbxSections.DataBind();

                SupportQueueCollection supportQueues = CacheManager.GetAllSupportQueues();
                cbxSupportQueues.DataSource = supportQueues;
                cbxSupportQueues.DataBind();
            }
        }
Пример #2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            if (!Page.IsPostBack)
            {
                // bind the sections repeater to a collection with all sections.
                SectionCollection sections = SectionGuiHelper.GetAllSections();
                rpSections.DataSource = sections;
                rpSections.DataBind();
            }
        }
Пример #3
0
        public async Task <ActionResult <IEnumerable <SectionDto> > > GetSections()
        {
            if (!this.HttpContext.Session.HasSystemActionRights() || !this.HttpContext.Session.HasSystemActionRight(ActionRights.SystemManagement))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var supportQueueDtos = await SectionGuiHelper.GetAllSectionDtosAsync();

            return(Ok(supportQueueDtos));
        }
Пример #4
0
        /// <summary>
        /// Gets all sections in a collection from the Cache. If it's not available, the collection with all the section entities is loaded from the DB and
        /// added to the cache.
        /// </summary>
        /// <param name="cache">The cache object this methods works on</param>
        /// <returns>A SectionCollection with all SectionEntity instances of the sections of the forum system. This collection has to be threated as
        /// a readonly collection with readonly objects</returns>
        public static async Task <EntityCollection <SectionEntity> > GetAllSectionsAsync(this IMemoryCache cache)
        {
            var toReturn = cache.Get <EntityCollection <SectionEntity> >(CacheKeys.AllSections);

            if (toReturn == null)
            {
                // not there, store it.
                toReturn = await SectionGuiHelper.GetAllSectionsAsync();

                // just store it in the cache without any dependency, as it's not changing often.
                cache.Set(CacheKeys.AllSections, toReturn);
            }

            return(toReturn);
        }
Пример #5
0
    /// <summary>
    /// Gets all sections in a collection from the Cache. If it's not available, the collection with all the section entities is loaded from the DB and
    /// added to the cache.
    /// </summary>
    /// <returns>A SectionCollection with all SectionEntity instances of the sections of the forum system. This collection has to be threated as
    /// a readonly collection with readonly objects</returns>
    public static SectionCollection GetAllSections()
    {
        Cache             activeCache = HttpRuntime.Cache;
        SectionCollection toReturn    = (SectionCollection)activeCache[CacheKeys.AllSections];

        if (toReturn == null)
        {
            // not there, store it.
            toReturn = SectionGuiHelper.GetAllSections();
            // just store it in the cache without any dependency, as it's hardly changing.
            activeCache.Insert(CacheKeys.AllSections, toReturn);
        }

        return(toReturn);
    }
Пример #6
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _sectionID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["SectionID"]);

            if (!Page.IsPostBack)
            {
                // Get the section directly from the DB, instead from the in-memory cache
                SectionEntity section = SectionGuiHelper.GetSection(_sectionID);

                // Show results in the labels
                if (section != null)
                {
                    // Section found
                    // Get the forums in the section
                    ForumCollection forums = ForumGuiHelper.GetAllForumsInSection(_sectionID);
                    if (forums.Count > 0)
                    {
                        // section has forums. User is not able to delete the section. Show error message plus
                        // disable delete button
                        lblRuleError.Visible = true;
                        btnDelete.Disabled   = true;
                    }
                    lblSectionName.Text        = section.SectionName;
                    lblSectionDescription.Text = section.SectionDescription;
                }
                else
                {
                    // the section doesn't exist anymore
                    Response.Redirect("ModifyDeleteSection.aspx", true);
                }
            }
        }
Пример #7
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _sectionID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["SectionID"]);

            if (!Page.IsPostBack)
            {
                // Load the section directly from the database and show it in the textboxes
                SectionEntity section = SectionGuiHelper.GetSection(_sectionID);

                if (section != null)
                {
                    // show it
                    tbxSectionName.Value       = section.SectionName;
                    tbxSectionDescription.Text = section.SectionDescription;
                    tbxOrderNo.Text            = section.OrderNo.ToString();
                }
                else
                {
                    // not found
                    Response.Redirect("Default.aspx", true);
                }
            }
        }
Пример #8
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            bool hasAccess = SessionAdapter.HasSystemActionRight(ActionRights.SecurityManagement);

            if (!hasAccess)
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _roleID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["RoleID"]);

            if (!Page.IsPostBack)
            {
                // get the role and show the description
                RoleEntity role = SecurityGuiHelper.GetRole(_roleID);
                if (!role.IsNew)
                {
                    _roleDescription = role.RoleDescription;
                }

                // store in viewstate.
                ViewState.Add("sRoleDescription", _roleDescription);

                // Get all sections, which do have a forum.
                DataView sections = SectionGuiHelper.GetAllSectionsWStatisticsAsDataView(true);

                cbxSections.DataSource     = sections;
                cbxSections.DataTextField  = "SectionName";
                cbxSections.DataValueField = "SectionID";
                cbxSections.DataBind();

                if (cbxSections.Items.Count > 0)
                {
                    cbxSections.Items[0].Selected = true;
                }

                FillForumList();

                // get the forum action rights
                ActionRightCollection actionRights = SecurityGuiHelper.GetAllActionRightsApplybleToAForum();

                cblForumRights.DataSource     = actionRights;
                cblForumRights.DataTextField  = "ActionRightDescription";
                cblForumRights.DataValueField = "ActionRightID";
                cblForumRights.DataBind();

                // Reflect action rights for current selected forum for this role
                ReflectCurrentActionRights();
            }
            else
            {
                // read role description from viewstate
                _roleDescription = ViewState["sRoleDescription"].ToString();
                _forumID         = HnDGeneralUtils.TryConvertToInt(cbxForums.SelectedItem.Value);
            }
        }
Пример #9
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the user doesn't have any access rights to management stuff, the user should
            // be redirected to the default of the global system.
            if (!SessionAdapter.HasSystemActionRights())
            {
                // doesn't have system rights. redirect.
                Response.Redirect("../Default.aspx", true);
            }

            // Check if the user has the right systemright
            if (!SessionAdapter.HasSystemActionRight(ActionRights.SystemManagement))
            {
                // no, redirect to admin default page, since the user HAS access to the admin menu.
                Response.Redirect("Default.aspx", true);
            }

            _forumID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["ForumID"]);

            if (!Page.IsPostBack)
            {
                // read sections for the drop down list.
                SectionCollection sections = SectionGuiHelper.GetAllSections();
                cbxSections.DataSource = sections;
                cbxSections.DataBind();

                SupportQueueCollection supportQueues = CacheManager.GetAllSupportQueues();
                cbxSupportQueues.DataSource = supportQueues;
                cbxSupportQueues.DataBind();

                // Load the forum.
                ForumEntity forum = ForumGuiHelper.GetForum(_forumID);
                if (forum != null)
                {
                    // forum found
                    tbxForumDescription.Text = forum.ForumDescription;
                    tbxForumName.Value       = forum.ForumName;
                    tbxOrderNo.Text          = forum.OrderNo.ToString();

                    cbxSections.SelectedValue = forum.SectionID.ToString();

                    if (forum.DefaultSupportQueueID.HasValue)
                    {
                        cbxSupportQueues.SelectedValue = forum.DefaultSupportQueueID.Value.ToString();
                    }
                    chkHasRSSFeed.Checked = forum.HasRSSFeed;
                    cbxThreadListInterval.SelectedValue  = forum.DefaultThreadListInterval.ToString();
                    tbxMaxAttachmentSize.Text            = forum.MaxAttachmentSize.ToString();
                    tbxMaxNoOfAttachmentsPerMessage.Text = forum.MaxNoOfAttachmentsPerMessage.ToString();

                    if (forum.NewThreadWelcomeText != null)
                    {
                        tbxNewThreadWelcomeText.Text = forum.NewThreadWelcomeText;
                    }
                }
                else
                {
                    // not found
                    Response.Redirect("Default.aspx", true);
                }
            }
        }
Пример #10
0
        private static async Task FillDataSetsInModelObjectAsync(AddEditForumData data)
        {
            data.AllExistingSupportQueues = await SupportQueueGuiHelper.GetAllSupportQueueDTOsAsync();

            data.AllExistingSections = await SectionGuiHelper.GetAllSectionDtosAsync();
        }