using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.SettingsProvider; public partial class CMSWebParts_Forums_ForumPostsDataSource : CMSAbstractWebPart { #region "Properties" /// /// Gets or sets the web service URL. /// public string SiteName { get { return DataHelper.GetNotEmpty(GetValue("SiteName"), CMSContext.CurrentSiteName); } set { SetValue("SiteName", value); srcPosts.SiteName = value; } } /// /// Gets or sets forum name for which blog posts should be obtained. /// public string ForumName { get { return ValidationHelper.GetString(GetValue("ForumName"), ""); } set { SetValue("ForumName", value); srcPosts.ForumName = value; } } /// /// Gets or sets Select only approved property. /// public bool SelectOnlyApproved { get { return ValidationHelper.GetBoolean(GetValue("SelectOnlyApproved"), true); } set { SetValue("SelectOnlyApproved", value); srcPosts.SelectOnlyApproved = value; } } /// /// Gets or sets Check permissions property. /// public bool CheckPermissions { get { return ValidationHelper.GetBoolean(GetValue("CheckPermissions"), true); } set { SetValue("CheckPermissions", value); srcPosts.CheckPermissions = value; } } /// /// Gets or sets WHERE condition. /// public string WhereCondition { get { return ValidationHelper.GetString(GetValue("WhereCondition"), ""); } set { SetValue("WhereCondition", value); srcPosts.WhereCondition = value; } } /// /// Gets or sets ORDER BY condition. /// public string OrderBy { get { return ValidationHelper.GetString(GetValue("OrderBy"), ""); } set { SetValue("OrderBy", value); srcPosts.OrderBy = value; } } /// /// Gets or sets top N selected documents. /// public int SelectTopN { get { return ValidationHelper.GetInteger(GetValue("SelectTopN"), 0); } set { SetValue("SelectTopN", value); srcPosts.TopN = value; } } /// /// Gets or sets the source filter name. /// public string FilterName { get { return ValidationHelper.GetString(GetValue("FilterName"), ""); } set { SetValue("FilterName", value); srcPosts.SourceFilterName = value; } } /// /// Gets or sets the cache item name. /// public override string CacheItemName { get { return base.CacheItemName; } set { base.CacheItemName = value; srcPosts.CacheItemName = value; } } /// /// Cache dependencies, each cache dependency on a new line. /// public override string CacheDependencies { get { return ValidationHelper.GetString(base.CacheDependencies, srcPosts.CacheDependencies); } set { base.CacheDependencies = value; srcPosts.CacheDependencies = value; } } /// /// Gets or sets the cache minutes. /// public override int CacheMinutes { get { return base.CacheMinutes; } set { base.CacheMinutes = value; srcPosts.CacheMinutes = value; } } /// /// Gest or sets selected columns. /// public string Columns { get { return ValidationHelper.GetString(GetValue("Columns"), ""); } set { SetValue("Columns", value); srcPosts.SelectedColumns = value; } } /// /// Indicates if group posts should be included. /// public bool ShowGroupPosts { get { return ValidationHelper.GetBoolean(GetValue("ShowGroupPosts"), false); } set { SetValue("ShowGroupPosts", value); srcPosts.ShowGroupPosts = value; } } /// /// Gets or sets community group name. /// public string GroupName { get { return ValidationHelper.GetString(GetValue("GroupName"), ""); } set { SetValue("GroupName", value); } } #endregion #region "Methods" /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes control properties. /// protected void SetupControl() { if (StopProcessing) { // Do nothing } else { srcPosts.SiteName = SiteName; srcPosts.ForumName = ForumName; srcPosts.WhereCondition = WhereCondition; srcPosts.OrderBy = OrderBy; srcPosts.TopN = SelectTopN; srcPosts.FilterName = ValidationHelper.GetString(GetValue("WebPartControlID"), ClientID); srcPosts.SourceFilterName = FilterName; srcPosts.CacheItemName = CacheItemName; srcPosts.CacheDependencies = CacheDependencies; srcPosts.CacheMinutes = CacheMinutes; srcPosts.SelectOnlyApproved = SelectOnlyApproved; srcPosts.CheckPermissions = CheckPermissions; srcPosts.SelectedColumns = Columns; srcPosts.ShowGroupPosts = ShowGroupPosts && String.IsNullOrEmpty(ForumName); // Set data source groupid according to group name if (!String.IsNullOrEmpty(GroupName)) { if (GroupName == CMSConstants.COMMUNITY_CURRENT_GROUP) { srcPosts.GroupID = ModuleCommands.CommunityGetCurrentGroupID(); } else { GeneralizedInfo gi = ModuleCommands.CommunityGetGroupInfoByName(GroupName, SiteName); if (gi != null) { srcPosts.GroupID = ValidationHelper.GetInteger(gi.GetValue("GroupID"), 0); } else { srcPosts.StopProcessing = true; } } } } } /// /// Clears cache. /// public override void ClearCache() { srcPosts.ClearCache(); } #endregion }