using System; using System.Web; using System.Web.UI; using CMS.CMSHelper; using CMS.Community; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.UIControls; public partial class CMSWebParts_Community_Profile_GroupProperties : CMSAbstractWebPart { #region "Public properties" /// /// Gets or sets group name to specify group members. /// public string GroupName { get { string groupName = ValidationHelper.GetString(GetValue("GroupName"), ""); if ((string.IsNullOrEmpty(groupName) || groupName == GroupInfoProvider.CURRENT_GROUP) && (CommunityContext.CurrentGroup != null)) { return CommunityContext.CurrentGroup.GroupName; } return groupName; } set { SetValue("GroupName", value); } } /// /// Gets or sets message which should be displayed if user hasn't permissions. /// public string NoPermissionMessage { get { return ValidationHelper.GetString(GetValue("NoPermissionMessage"), ""); } set { SetValue("NoPermissionMessage", value); messageElem.ErrorMessage = value; } } /// /// If true group display name change allowed on live site. /// public bool AllowChangeGroupDisplayName { get { return ValidationHelper.GetBoolean(GetValue("AllowChangeGroupDisplayName"), false); } set { groupEditElem.AllowChangeGroupDisplayName = value; SetValue("AllowChangeGroupDisplayName", value); } } /// /// If true changing theme for group page is enabled. /// public bool AllowSelectTheme { get { return ValidationHelper.GetBoolean(GetValue("AllowSelectTheme"), false); } set { SetValue("AllowSelectTheme", value); groupEditElem.AllowSelectTheme = value; } } #endregion /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Reloads data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { // Do nothing } else { groupEditElem.HideWhenGroupIsNotSupplied = true; groupEditElem.OnCheckPermissions += groupEditElem_OnCheckPermissions; GroupInfo gi = GroupInfoProvider.GetGroupInfo(GroupName, CMSContext.CurrentSiteName); if (gi != null) { groupEditElem.AllowChangeGroupDisplayName = AllowChangeGroupDisplayName; groupEditElem.GroupID = gi.GroupID; groupEditElem.SiteID = gi.GroupSiteID; groupEditElem.AllowSelectTheme = AllowSelectTheme; } else { Visible = false; } } } /// /// Group properties - check permissions. /// private void groupEditElem_OnCheckPermissions(string permissionType, CMSAdminControl sender) { if (!(CMSContext.CurrentUser.IsGroupAdministrator(groupEditElem.GroupID) | CMSContext.CurrentUser.IsAuthorizedPerResource("cms.groups", "Manage"))) { if (sender != null) { sender.StopProcessing = true; } groupEditElem.StopProcessing = true; groupEditElem.Visible = false; messageElem.ErrorMessage = NoPermissionMessage; messageElem.Visible = true; } } }