Example #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);
    }
    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);
        }
    }
 public void LoadMessage(string MessageId)
 {
     if (mMessageLoaded == false)
     {
         BusiBlocks.CommsBlock.Forums.Message msg = BusiBlocks.CommsBlock.Forums.ForumsManager.GetMessage(IdMessage);
         LoadMessage(msg);
     }
 }
    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;
    }
Example #5
0
    private SyndicationLibrary.RSS.RssItem CreateRssItem(BusiBlocks.CommsBlock.Forums.Message msg)
    {
        //Calculate the link of the forum
        //The link is encoded automatically by the Rss library
        string link = "";// Navigation.Forum_ViewTopic(msg.Topic.Id, msg.Id).GetAbsoluteClientUrl(false);

        string rssTitle = string.Format("[{0}] {1}", msg.Topic.Category.DisplayName, msg.Title);

        var item = new SyndicationLibrary.RSS.RssItem(rssTitle, msg.Body, link);

        item.PublicationDate = msg.UpdateDate;
        item.Guid            = new SyndicationLibrary.RSS.RssGuid(link, true);

        return(item);
    }
    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);
        }
    }
 public void SetMessage(BusiBlocks.CommsBlock.Forums.Message msg)
 {
     LoadMessage(msg);
 }