using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CMS.FormControls;
using CMS.GlobalHelper;
using CMS.UIControls;
using CMS.FormEngine;
using CMS.Forums;
using CMS.Community;
using CMS.SettingsProvider;
public partial class CMSModules_Groups_FormControls_MembershipGroupSelector : FormEngineUserControl
{
#region "Private variables"
private int mSiteId = 0;
#endregion
#region "Public properties"
///
/// Enables or Disables showing all groups or current site groups.
///
public bool ShowCurrentSiteGroups
{
get
{
return ValidationHelper.GetBoolean(GetValue("ShowCurrentSiteGroups"), false);
}
set
{
SetValue("ShowCurrentSiteGroups", value);
}
}
///
/// Enables or Disables multi selection. Default is multi select.
///
public bool MultiSelection
{
get
{
return ValidationHelper.GetBoolean(GetValue("MultiSelection"), true);
}
set
{
SetValue("MultiSelection", value);
}
}
///
/// Gets Value display name.
///
public override string ValueDisplayName
{
get
{
return usGroups.ValueDisplayName;
}
}
///
/// Helper parameter - site id.
///
public override object FormControlParameter
{
get
{
return mSiteId;
}
set
{
mSiteId = ValidationHelper.GetInteger(value, 0);
}
}
///
/// Gets or sets site id.
///
public int SiteID
{
get
{
return mSiteId;
}
set
{
mSiteId = value;
}
}
///
/// Gets or sets the valu that indicates whether friendly mode should be used. Display name is displayed instead code name.
///
public bool UseFriendlyMode
{
get
{
return ValidationHelper.GetBoolean(GetValue("UseFriendlyMode"), false);
}
set
{
SetValue("UseFriendlyMode", value);
}
}
///
/// Gets or sets the enabled state of the control.
///
public override bool Enabled
{
get
{
return base.Enabled;
}
set
{
EnsureChildControls();
base.Enabled = value;
usGroups.Enabled = value;
}
}
///
/// Gets the currene UniSelector instance.
///
public UniSelector CurrentSelector
{
get
{
EnsureChildControls();
return usGroups;
}
}
///
/// Group code name.
///
public string GroupCodeName
{
get
{
EnsureChildControls();
return Convert.ToString(usGroups.Value);
}
set
{
EnsureChildControls();
usGroups.Value = value;
}
}
///
/// Gets the current drop down control.
///
public DropDownList CurrentDropDown
{
get
{
EnsureChildControls();
return usGroups.DropDownSingleSelect;
}
}
///
/// Gets or sets value - group name.
///
public override object Value
{
get
{
EnsureChildControls();
return Convert.ToString(usGroups.Value);
}
set
{
EnsureChildControls();
usGroups.Value = value;
}
}
///
/// Gets Value element id.
///
public override string ValueElementID
{
get
{
EnsureChildControls();
return usGroups.ClientID;
}
}
///
/// Gets or sets if live iste property.
///
public override bool IsLiveSite
{
get
{
EnsureChildControls();
return base.IsLiveSite;
}
set
{
EnsureChildControls();
base.IsLiveSite = value;
usGroups.IsLiveSite = value;
}
}
///
/// Gets or sets stop processing.
///
public override bool StopProcessing
{
get
{
return usGroups.StopProcessing;
}
set
{
usGroups.StopProcessing = value;
}
}
#endregion
#region "Methods"
///
/// Page_load event.
///
/// Sender
/// Arguments
protected void Page_Load(object sender, EventArgs e)
{
if (StopProcessing)
{
usGroups.StopProcessing = true;
}
else
{
// Build WHERE condition
string where = "";
if (SiteID > 0)
{
where = "GroupSiteID =" + SiteID;
}
if (ShowCurrentSiteGroups)
{
where = SqlHelperClass.AddWhereCondition(where, "(GroupSiteID = " + CurrentSite.SiteID + ")");
}
usGroups.WhereCondition = where;
usGroups.AllowEmpty = true;
}
usGroups.SelectionMode = (MultiSelection) ? SelectionModeEnum.MultipleTextBox : SelectionModeEnum.SingleTextBox;
}
///
/// Page_PreRender event.
///
/// Sender
/// Arguments
protected void Page_PreRender(object sender, EventArgs e)
{
if (!StopProcessing)
{
// Settings for (un)friendly mode
if (UseFriendlyMode)
{
usGroups.ButtonClear.Visible = true;
usGroups.TextBoxSelect.ReadOnly = true;
usGroups.DisplayNameFormat = "{%GroupDisplayName%}";
}
else
{
usGroups.ButtonClear.Visible = false;
usGroups.TextBoxSelect.ReadOnly = false;
usGroups.DisplayNameFormat = "{%GroupName%}";
}
}
}
///
/// Reloads the selector's data.
///
/// Indicates whether data should be forcibly reloaded
public void Reload(bool forceReload)
{
usGroups.Reload(forceReload);
}
///
/// Creates child controls and loads update panle container if it is required.
///
protected override void CreateChildControls()
{
// If selector is not defined load update panel container
if (usGroups == null)
{
pnlUpdate.LoadContainer();
}
// Call base method
base.CreateChildControls();
}
#endregion
}