using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.ProjectManagement; using CMS.SettingsProvider; public partial class CMSWebParts_ProjectManagement_MyProjects : CMSAbstractWebPart { #region "Properties" /// /// Show finished projects too. /// public bool ShowFinishedProjects { get { return ValidationHelper.GetBoolean(GetValue("ShowFinishedProjects"), false); } set { SetValue("ShowFinishedProjects", value); } } /// /// Gets or sets the value that indicates whether paging should be used. /// public bool EnablePaging { get { return ValidationHelper.GetBoolean(GetValue("EnablePaging"), false); } set { SetValue("EnablePaging", value); } } /// /// Gets or sets the number of items per page. /// public int PageSize { get { return ValidationHelper.GetInteger(GetValue("PageSize"), 10); } set { SetValue("PageSize", value); } } #endregion #region "Methods" /// /// On content loaded. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Setup control. /// protected void SetupControl() { if (!StopProcessing) { // Ignore community groups ucProjectList.IgnoreCommunityGroup = true; // Build condition event handler ucProjectList.BuildCondition += new CMSModules_ProjectManagement_Controls_UI_Project_List.BuildConditionEvent(ucProjectList_BuildCondition); ucProjectList.RegisterEditScript = false; ucProjectList.Grid.GridName = "~/CMSModules/ProjectManagement/Controls/UI/Project/MyProjects.xml"; ucProjectList.IsLiveSite = true; ucProjectList.EnablePaging = EnablePaging; ucProjectList.PageSize = PageSize; } else { ucProjectList.StopProcessing = true; ucProjectList.Visible = false; } } /// /// Builds where condition. /// private string ucProjectList_BuildCondition(object sender, string whereCondition) { // Do not display projects without relation to document whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "ProjectNodeID IS NOT NULL"); // Finished projects if (!ShowFinishedProjects) { whereCondition = SqlHelperClass.AddWhereCondition(whereCondition, "StatusIsFinished=0"); } // Security condition whereCondition = ProjectInfoProvider.CombineSecurityWhereCondition(whereCondition, CMSContext.CurrentUser, CMSContext.CurrentSiteName); return whereCondition; } /// /// Reloads the control data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); } #endregion }