Пример #1
0
    public void LoadMessage(string parentMessageId)
    {
        IdParentMessage = parentMessageId;

        BusiBlocks.CommsBlock.Forums.Message parentMessage = GetParentMessage();

        if (!IsPostBack)
        {
            string title = parentMessage.Title;

            if (title.StartsWith(MESSAGE_RESPONSE_TAG))
            {
                newMessage.MessageSubject = title;
            }
            else
            {
                newMessage.MessageSubject = MESSAGE_RESPONSE_TAG + title;
            }

            BusiBlocks.CommsBlock.Forums.Category forum = parentMessage.Topic.Category;

            if (forum.AttachEnabled)
            {
                newMessage.SetAcceptedExtensions(BusiBlocks.Attachment.FileHelper.ReplaceExtensionsSets(forum.AttachExtensions));
                newMessage.SetMaxAttachSize(forum.AttachMaxSize);
                newMessage.EnabledAttach = true;
            }
            else
            {
                newMessage.EnabledAttach = false;
            }
        }

        viewParentMessage.SetMessage(parentMessage);
    }
Пример #2
0
    private string[] GetSelectedForums()
    {
        var returnList = new List <string>();

        string queryForum = Request["name"];

        if (string.IsNullOrEmpty(queryForum))
        {
            IList <BusiBlocks.CommsBlock.Forums.Category> allCategories = BusiBlocks.CommsBlock.Forums.ForumsManager.GetAllCategories();

            foreach (BusiBlocks.CommsBlock.Forums.Category category in allCategories)
            {
                //if (BusiBlocks.SecurityHelper.CanRead(User, category, null))
                returnList.Add(category.Name);
            }
        }
        else
        {
            string[] forumsNameArray = queryForum.Split(','); //I can use the comma as a separator because the forum name cannot contains comma

            foreach (string forumName in forumsNameArray)
            {
                BusiBlocks.CommsBlock.Forums.Category category = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategoryByName(forumName, true);
                //if (BusiBlocks.SecurityHelper.CanRead(User, category, null))
                returnList.Add(category.Name);
            }
        }

        return(returnList.ToArray());
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string forumId = Request["id"];

            //Edit
            if (forumId != null)
            {
                BusiBlocks.CommsBlock.Forums.Category forum = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategory(forumId);

                txtName.Enabled = false;

                txtName.Text          = forum.Name;
                txtDisplayName.Text   = forum.DisplayName;
                ctrlAccess.CategoryId = forum.Id;

                txtDescription.Text = forum.Description;

                chkEnabledAttach.Checked = forum.AttachEnabled;
                txtAttachExtensions.Text = forum.AttachExtensions;
                txtAttachMaxSize.Text    = forum.AttachMaxSize.ToString(CultureInfo.InvariantCulture);
            }
            else //New
            {
                chkEnabledAttach.Checked = true;
                txtAttachExtensions.Text = BusiBlocks.Attachment.FileHelper.EXTENSIONS_ALL;
                txtAttachMaxSize.Text    = "500"; //Kb
            }
        }
    }
Пример #4
0
    protected void MessageDelete_Click(object sender, EventArgs e)
    {
        BusiBlocks.CommsBlock.Forums.Message  msg   = BusiBlocks.CommsBlock.Forums.ForumsManager.GetMessage(IdMessage);
        BusiBlocks.CommsBlock.Forums.Topic    topic = msg.Topic;
        BusiBlocks.CommsBlock.Forums.Category forum = topic.Category;

        if (!BusiBlocks.SecurityHelper.CanUserEdit(Page.User.Identity.Name, forum.Id))
        {
            throw new BusiBlocks.InvalidPermissionException("delete message");
        }

        //If there isn't a parent it is because it is the root message, in this case I delete directly the topic
        if (string.IsNullOrEmpty(msg.IdParentMessage))
        {
            BusiBlocks.CommsBlock.Forums.ForumsManager.DeleteTopic(topic);

            Navigation.Forum_ViewForum(forum.Name).Redirect(this);
        }
        else
        {
            BusiBlocks.CommsBlock.Forums.ForumsManager.DeleteMessage(msg);

            Navigation.Communication_ForumViewTopic(topic.Id).Redirect(this);
        }
    }
    private void LoadMessages()
    {
        List <Access> accessibleList = AccessManager.GetUsersAccessibleItems(Page.User.Identity.Name, BusiBlocks.ItemType.ForumTopic, BusiBlocks.AccessType.View);
        //IList<PersonType> personTypes = PersonManager.GetPersonTypesByUser(Page.User.Identity.Name);
        var itemsToList = new List <BusiBlocks.CommsBlock.Forums.Topic>();

        // todo MASSIVE problem here. When we create a forum topic, we store the permissions for it as the forum Category.
        // Then we retrieve all 'topics' by looking at the categories in the access table.
        // Then we are expected to display those 'topics', even though we have now lost that information (since we
        // stored them as categories.
        // We should have stored them as topicIds not categoryIds in the access table, then retrieved those topics

        // For the moment, filter the duplicate category items in the accessible list.
        var cleanAccessList = new List <Access>();

        foreach (Access access in accessibleList)
        {
            if (!cleanAccessList.Exists(delegate(Access a) { return(a.ItemId == access.ItemId); }))
            {
                cleanAccessList.Add(access);
            }
        }

        foreach (Access access in cleanAccessList)
        {
            BusiBlocks.CommsBlock.Forums.Category      category = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategory(access.ItemId);
            IList <BusiBlocks.CommsBlock.Forums.Topic> items    = BusiBlocks.CommsBlock.Forums.ForumsManager.GetTopics(category, new BusiBlocks.PagingInfo(0, 1));

            foreach (BusiBlocks.CommsBlock.Forums.Topic item in items)
            {
                if (!itemsToList.Exists(delegate(BusiBlocks.CommsBlock.Forums.Topic i) { return(i.Id == item.Id); }))
                {
                    //if (item.RequiresAck)
                    //{
                    //    if (item.Acknowledged)
                    //        continue;
                    //}
                    //else
                    //{
                    //    if (item.Viewed)
                    //        continue;
                    //}
                    itemsToList.Add(item);
                }
            }
        }

        lblNoResults.Visible = itemsToList.Count == 0;

        listRepeater.DataSource = itemsToList;
        listRepeater.DataBind();
    }
Пример #6
0
    private void LoadMessage(BusiBlocks.CommsBlock.Forums.Message msg)
    {
        linkNew.HRef    = "javascript:__doPostBack('reply','" + msg.Id + "')";
        linkDelete.HRef = "javascript:if(confirm('Are you sure to delete the message?')) __doPostBack('delete','" + msg.Id + "')";

        BusiBlocks.CommsBlock.Forums.Topic    topic = msg.Topic;
        BusiBlocks.CommsBlock.Forums.Category forum = topic.Category;


        if (!BusiBlocks.SecurityHelper.CanUserView(Page.User.Identity.Name, forum.Id))
        {
            throw new BusiBlocks.InvalidPermissionException("read message");
        }

        //if (!BusiBlocks.SecurityHelper.CanUserView(Page.User.Identity.Name, Profile.Locations, msg.Id))
        //    throw new BusiBlocks.InvalidGroupMembershipException();

        //Create a link (a element) that can be used for anchor (vertical navigation), note that I cannot use ASP.NET element because ASP.NET automatically change the ID adding the container id (containerid:controlid)
        string anchorId = "msg" + msg.Id; //Note: this is the format that you must use when you want to navigate to a message: es. ViewTopic.aspx?id=xxx#msgYYY

        messageTitle.InnerHtml = string.Format("<a id=\"{0}\">{1}</a>", anchorId, HttpUtility.HtmlEncode(msg.Title));


        lblAuthor.InnerText = Utilities.GetDisplayUser(msg.Owner);
        lblDate.InnerText   = Utilities.GetDateTimeForDisplay(msg.InsertDate);

        sectionBody.InnerHtml = msg.Body;

        bool visible = BusiBlocks.SecurityHelper.CanUserEdit(Page.User.Identity.Name, forum.Id);

        linkNew.Visible    = linkNew.Visible && ReplyLinkVisible;
        linkDelete.Visible = linkDelete.Visible && DeleteLinkVisible;


        //sectionDelete.Visible = (&& BusiBlocks.SecurityHelper.CanUserEdit(Page.User.Identity.Name, forum.Id));
        //sectionNew.Visible = (ReplyLinkVisible && BusiBlocks.SecurityHelper.CanUserEdit(Page.User.Identity.Name, forum.Id));

        if (msg.Attachment != null)
        {
            sectionAttachment.Visible = true;

            linkAttach.InnerHtml = HttpUtility.HtmlEncode(msg.Attachment.Name);
            linkAttach.HRef      = Navigation.Communication_ForumAttach(msg.Id, true).GetServerUrl(true);
        }
        else
        {
            sectionAttachment.Visible = false;
        }

        //Flag the control as loaded
        mMessageLoaded = true;
    }
Пример #7
0
    private void LoadList()
    {
        if (!string.IsNullOrEmpty(CategoryName))
        {
            BusiBlocks.CommsBlock.Forums.Category category = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategoryByName(CategoryName, true);

            var paging = new BusiBlocks.PagingInfo(ListPagingSize, CurrentPage);
            IList <BusiBlocks.CommsBlock.Forums.Topic> topics = BusiBlocks.CommsBlock.Forums.ForumsManager.GetTopics(category,
                                                                                                                     paging);

            var allowedTopics = new List <BusiBlocks.CommsBlock.Forums.Topic>();

            IList <PersonType> groups = PersonManager.GetPersonTypesByUser(Page.User.Identity.Name);

            foreach (BusiBlocks.CommsBlock.Forums.Topic topic in topics)
            {
                if (BusiBlocks.SecurityHelper.CanUserView(Page.User.Identity.Name, topic.Category.Id))
                {
                    // If the user is in at least one group, then let them continue.
                    if (groups.Count > 0)
                    {
                        allowedTopics.Add(topic);
                    }
                }
            }

            lblCurrentPage.InnerText = (CurrentPage + 1).ToString();
            lblTotalPage.InnerText   = paging.PagesCount.ToString();

            listRepeater.DataSource = allowedTopics;
            listRepeater.DataBind();

            if (CurrentPage == 0)
            {
                linkPrev.Enabled = false;
            }
            else
            {
                linkPrev.Enabled = true;
            }
            if (CurrentPage + 1 >= paging.PagesCount)
            {
                linkNext.Enabled = false;
            }
            else
            {
                linkNext.Enabled = true;
            }
        }
    }
Пример #8
0
    public void LoadForum(string forumName)
    {
        BusiBlocks.CommsBlock.Forums.Category forum = GetForum();

        if (forum.AttachEnabled)
        {
            newMessage.SetAcceptedExtensions(BusiBlocks.Attachment.FileHelper.ReplaceExtensionsSets(forum.AttachExtensions));
            newMessage.SetMaxAttachSize(forum.AttachMaxSize);
            newMessage.EnabledAttach = true;
        }
        else
        {
            newMessage.EnabledAttach = false;
        }
    }
Пример #9
0
    private void ExploreMessages(BusiBlocks.CommsBlock.Forums.Category forum, BusiBlocks.CommsBlock.Forums.Topic topic,
                                 IList <BusiBlocks.CommsBlock.Forums.Message> messages, string filterParent, int level)
    {
        foreach (BusiBlocks.CommsBlock.Forums.Message msg in messages)
        {
            if (string.Equals(msg.IdParentMessage, filterParent, StringComparison.InvariantCultureIgnoreCase))
            {
                Communication_ViewMessage ctlMessage = (Communication_ViewMessage)LoadControl("~/Communication/Forum/ViewMessage.ascx");
                ctlMessage.SetMessage(msg);
                ctlMessage.SetIndentLevel(level);

                Controls.Add(ctlMessage);

                ExploreMessages(forum, topic, messages, msg.Id, level + 1);
            }
        }
    }
Пример #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string forumId = Request["id"];

            //Edit
            if (forumId != null)
            {
                BusiBlocks.CommsBlock.Forums.Category forum = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategory(forumId);

                txtName.Enabled     = false;
                txtName.Text        = forum.Name;
                txtDisplayName.Text = forum.DisplayName;
                txtDescription.Text = forum.Description;
            }
        }
    }
Пример #11
0
    private string[] GetSelectedForums()
    {
        var forums = new List <string>();

        foreach (ListItem item in listForum.Items)
        {
            if (item.Selected)
            {
                BusiBlocks.CommsBlock.Forums.Category category = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategory(item.Value);
                //if (BusiBlocks.SecurityHelper.CanRead(User, category, null))
                {
                    forums.Add(category.Name);
                }
            }
        }

        return(forums.ToArray());
    }
Пример #12
0
    private void LoadTopic(string IdTopic)
    {
        BusiBlocks.CommsBlock.Forums.Topic    topic = BusiBlocks.CommsBlock.Forums.ForumsManager.GetTopic(IdTopic);
        BusiBlocks.CommsBlock.Forums.Category forum = topic.Category;


        if (!BusiBlocks.SecurityHelper.CanUserView(Page.User.Identity.Name, topic.Category.Id))
        {
            throw new BusiBlocks.InvalidGroupMembershipException();
        }

        //if (!BusiBlocks.SecurityHelper.HasGroupAccess(Page.User.Identity.Name, topic))
        //    throw new BusiBlocks.InvalidGroupMembershipException();

        //if (BusiBlocks.SecurityHelper.CanRead(Page.User, forum, null) == false)
        //    throw new BusiBlocks.InvalidPermissionException("read forum");

        IList <BusiBlocks.CommsBlock.Forums.Message> messages = BusiBlocks.CommsBlock.Forums.ForumsManager.GetMessagesByTopic(topic);

        ExploreMessages(forum, topic, messages, null, 0);
    }
Пример #13
0
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            BusiBlocks.CommsBlock.Forums.Category forum = GetForum();

            var sb = new StringBuilder();

            var xhtml = new BusiBlocks.XHTMLText();
            xhtml.Load(newMessage.MessageBodyHtml);

            Exception validateError;
            if (xhtml.IsValid(forum.XHtmlMode, out validateError) == false)
            {
                throw new BusiBlocks.TextNotValidException(validateError);
            }

            BusiBlocks.Attachment.FileInfo attachment = null;
            //Create attachmentAccess.Access
            if (newMessage.AttachmentFile.HasFile)
            {
                attachment = new BusiBlocks.Attachment.FileInfo(newMessage.AttachmentFile.FileName,
                                                                newMessage.AttachmentFile.PostedFile.ContentType,
                                                                newMessage.AttachmentFile.FileBytes);
            }

            //Insert the topic
            BusiBlocks.CommsBlock.Forums.ForumsManager.CreateTopic(forum, Page.User.Identity.Name,
                                                                   newMessage.MessageSubject,
                                                                   xhtml.Xhtml,
                                                                   attachment, sb.ToString());

            Navigation.Communication_ForumView(forum.Name).Redirect(this);
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Page.Master).SetException(GetType(), ex);
        }
    }
Пример #14
0
    private void NewMessage(string ParentId)
    {
        try
        {
            BusiBlocks.CommsBlock.Forums.Message  msg   = BusiBlocks.CommsBlock.Forums.ForumsManager.GetMessage(ParentId);
            BusiBlocks.CommsBlock.Forums.Topic    topic = msg.Topic;
            BusiBlocks.CommsBlock.Forums.Category forum = topic.Category;

            if (BusiBlocks.SecurityHelper.CanUserEdit(Page.User.Identity.Name, forum.Id))
            {
                Navigation.Communication_ForumNewMessage(ParentId).Redirect(this);
            }
            else
            {
                throw new BusiBlocks.InvalidPermissionException("insert new message");
            }
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Page.Master).SetException(GetType(), ex);
        }
    }
Пример #15
0
 private BusiBlocks.CommsBlock.Forums.Category GetForum()
 {
     BusiBlocks.CommsBlock.Forums.Category forum = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategoryByName(Request.QueryString["forum"], true);
     return(forum);
 }