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_GroupMessageBoards : CMSAbstractWebPart
{
#region "Public properties"
///
/// Returns true if the control processing should be stopped.
///
public override bool StopProcessing
{
get
{
return base.StopProcessing;
}
set
{
base.StopProcessing = value;
boardsElem.StopProcessing = value;
}
}
///
/// 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;
}
}
#endregion
///
/// Content loaded event handler.
///
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
boardsElem.ReloadData(true);
}
///
/// Initializes the control properties.
///
protected void SetupControl()
{
if (StopProcessing)
{
// Do nothing
}
else
{
SetContext();
boardsElem.HideWhenGroupIsNotSupplied = true;
boardsElem.OnCheckPermissions += boardsElem_OnCheckPermissions;
GroupInfo gi = GroupInfoProvider.GetGroupInfo(GroupName, CMSContext.CurrentSiteName);
if (gi != null)
{
boardsElem.GroupID = gi.GroupID;
}
else
{
Visible = false;
}
ReleaseContext();
}
}
///
/// Group message boards - check permissions.
///
protected void boardsElem_OnCheckPermissions(string permissionType, CMSAdminControl sender)
{
if (!(CMSContext.CurrentUser.IsGroupAdministrator(boardsElem.GroupID) | CMSContext.CurrentUser.IsAuthorizedPerResource("cms.groups", "Manage")))
{
if (sender != null)
{
sender.StopProcessing = true;
}
boardsElem.StopProcessing = true;
boardsElem.Visible = false;
messageElem.Visible = true;
messageElem.ErrorMessage = NoPermissionMessage;
}
}
///
/// Reload data.
///
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
}