+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Comment Approval

Comment Approval

5 posts, 1 answered
  1. scorpionjade
    scorpionjade avatar
    10 posts
    Registered:
    03 May 2007
    18 Jan 2010
    Link to this post
    Hi,

    How can I handle comment moderation programmatically? Is it handled with "Visible" property of IComment?

    Thank you.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Jan 2010
    Link to this post
    Hello scorpionjade,

    The comments moderation is the whole process for managing comments from the backend of Sitefinity( review comment, change it or not and then set it as Visible). The IComment object Visible property indicates whether the comment is visible on the fornt end or not.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. scorpionjade
    scorpionjade avatar
    10 posts
    Registered:
    03 May 2007
    18 Jan 2010
    Link to this post

    Hi Ivan,

    Thank you for your reply.
    I created a generic-content based intra site module.
    Also, I've added the code so comments can be added to content items.
    But I want a comment to be published if it is approved.

    Here is the code I use to add comments to the content:

    this.Manager = new BooksManager("Books");

    IContent bookContent = this.Manager.Content.GetContent(BookId);

    Telerik.Cms.Engine.IComment commentToAdd = this.Manager.Content.CreateComment(bookContent);

    commentToAdd.Text = comment.Text.Trim();
    commentToAdd.Owner = HttpContext.Current.User.Identity.Name.ToString();
    commentToAdd.IpAddress = Request.ServerVariables["REMOTE_ADDR"].ToString();       

    this.Manager.Content.SaveComment(commentToAdd);

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Jan 2010
    Link to this post
    Hi scorpionjade,

    1. Create a backend views.

    • Crate a class that inherits from CommentsView - YourModuleCommentsView : CommentsView<YourModuleControlPanel>
    • Create views by overriding CreateViews method.

    protected override void CreateViews()
    {
        AddView<YourModuleCommentsList>();
        AddView<YourModuleCommentsEdit>();
        AddView<YourModuleCommentsPreview>();
    }

    • Create tree classes that inherits from
     Telerik.Cms.Engine.WebControls.Admi.CommentsList
     Telerik.Cms.Engine.WebControls.Admi.CommentsEdit
     Telerik.Cms.Engine.WebControls.Admi.CommentsPreview

    For your public control( which should be ContentView based) set  AllowCommentsModeration to true. You can set the same property for your provider that is declared in the web.config file.

    Programmatically

    public bool Moderation
    {
        get
        {
          if (this.moderation == null)
          {
                if (this.Manager != null)
            return this.Manager.Provider.CommentsModeration;
            return false;
          }
          return this.moderation.Value;
        }
        set
        {
        this.moderation = value;
        }
    }


    If you use some custom logic to handle the comments that differs from this one for GenericContent based module and ContentView based controls you have to implement some variable that indicates whether the comment has to be approved or not.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  5. scorpionjade
    scorpionjade avatar
    10 posts
    Registered:
    03 May 2007
    18 Jan 2010
    Link to this post
    Thank you Ivan.

    You are great always!
Register for webinar
5 posts, 1 answered