using CMS.CMSHelper;
using CMS.GlobalHelper;
using CMS.TreeEngine;
using CMS.SiteProvider;
using CMS.Blogs;
...
// Use a valid alias path of a testing post
string postAlias = "/TestingBlog/October-2007/TestingPost";
// Prepare the TreeProvider (it must be initialized with user information when editing
// document structure)
UserInfo ui = UserInfoProvider.GetUserInfo("administrator");
TreeProvider tree = new TreeProvider(ui);
DataSet ds = null;
// Get the parent post document
CMS.TreeEngine.TreeNode postNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, postAlias, TreeProvider.ALL_CULTURES, true, null, false);
if (postNode != null)
{
// Get all post comments
ds = BlogCommentInfoProvider.GetPostComments(postNode.DocumentID, false);
if (!DataHelper.DataSourceIsEmpty(ds))
{
// Set all post comments as approved
foreach (DataRow dr in ds.Tables[0].Rows)
{
// Edit comment and save it
BlogCommentInfo commentObj = new BlogCommentInfo(dr);
commentObj.CommentApprovedByUserID = ui.UserID;
BlogCommentInfoProvider.SetBlogCommentInfo(commentObj);
}
}
}
|