using System; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.SiteProvider; public partial class CMSWebParts_Community_Friends_MyFriends : CMSAbstractWebPart { #region "Variables" private UserInfo mCurrentUser = null; #endregion #region "Public properties" /// /// Gets or sets the WebPart CSS class value. /// public override string CssClass { get { return base.CssClass; } set { base.CssClass = value; myFriendsElem.CssClass = value; } } /// /// Gets or sets the query string parameter name. /// public string ParameterName { get { return ValidationHelper.GetString(GetValue("ParameterName"), myFriendsElem.ParameterName); } set { SetValue("ParameterName", value); myFriendsElem.ParameterName = value; } } /// /// Gets or sets the value that indicates whether 'friends list' is displayed. /// public bool DisplayFriendsList { get { return ValidationHelper.GetBoolean(GetValue("DisplayFriendsList"), myFriendsElem.DisplayFriendsList); } set { SetValue("DisplayFriendsList", value); myFriendsElem.DisplayFriendsList = value; } } /// /// Gets or sets the value that indicates whether 'friends waiting for approval' is displayed. /// public bool DisplayFriendsToApproval { get { return ValidationHelper.GetBoolean(GetValue("DisplayFriendsToApproval"), myFriendsElem.DisplayFriendsToApproval); } set { SetValue("DisplayFriendsToApproval", value); myFriendsElem.DisplayFriendsToApproval = value; } } /// /// Gets or sets the value that indicates whether 'requested friends list' is displayed. /// public bool DisplayFriendsRequested { get { return ValidationHelper.GetBoolean(GetValue("DisplayFriendsRequested"), myFriendsElem.DisplayFriendsRequested); } set { SetValue("DisplayFriendsRequested", value); myFriendsElem.DisplayFriendsRequested = value; } } /// /// Gets or sets the value that indicates whether 'rejected friends list' is displayed. /// public bool DisplayFriendsRejected { get { return ValidationHelper.GetBoolean(GetValue("DisplayFriendsRejected"), myFriendsElem.DisplayFriendsRejected); } set { SetValue("DisplayFriendsRejected", value); myFriendsElem.DisplayFriendsRejected = value; } } /// /// Gets or sets the User ID. /// [Obsolete("Use UserName instead")] public int UserID { get { return CurrentUser.UserID; } set { SetValue("UserID", value); myFriendsElem.UserID = value; } } /// /// User name. /// public string UserName { get { return CurrentUser.UserName; } set { SetValue("UserName", value); } } /// /// Gets or sets current user object. /// public new UserInfo CurrentUser { get { if (mCurrentUser == null) { mCurrentUser = UserInfoProvider.GetUserInfo(ValidationHelper.GetString(GetValue("UserName"), string.Empty)); } if (mCurrentUser == null) { // Backward compatibility int userId = ValidationHelper.GetInteger(GetValue("UserID"), myFriendsElem.UserID); if (userId > 0) { mCurrentUser = UserInfoProvider.GetUserInfo(userId); } } if (mCurrentUser == null) { mCurrentUser = CMSContext.CurrentUser; } return mCurrentUser; } } #endregion #region "Stop processing" /// /// Returns true if the control processing should be stopped. /// public override bool StopProcessing { get { return base.StopProcessing; } set { base.StopProcessing = value; myFriendsElem.StopProcessing = value; } } #endregion #region "Overidden" /// /// Content loaded event handler. /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Reload data. /// public override void ReloadData() { base.ReloadData(); SetupControl(); } #endregion #region "Methods" /// /// Setup control. /// protected void SetupControl() { if (StopProcessing || (CurrentUser == null) || CurrentUser.IsPublic()) { // Do nothing myFriendsElem.StopProcessing = true; Visible = false; } else { // Setup my friends control myFriendsElem.ParameterName = ParameterName; myFriendsElem.CssClass = CssClass; myFriendsElem.DisplayFriendsList = DisplayFriendsList; myFriendsElem.DisplayFriendsToApproval = DisplayFriendsToApproval; myFriendsElem.DisplayFriendsRequested = DisplayFriendsRequested; myFriendsElem.DisplayFriendsRejected = DisplayFriendsRejected; myFriendsElem.UserID = CurrentUser.UserID; } } #endregion }