#region Copyright // // DotNetNukeŽ - http://www.dotnetnuke.com // Copyright (c) 2002-2011 // by DotNetNuke Corporation // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated // documentation files (the "Software"), to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and // to permit persons to whom the Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all copies or substantial portions // of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #endregion #region Usings using System; using DotNetNuke.Entities.Modules; using DotNetNuke.Entities.Profile; using DotNetNuke.Entities.Users; using DotNetNuke.Framework; using DotNetNuke.Services.Localization; using DotNetNuke.UI.WebControls; #endregion namespace DotNetNuke.Modules.Admin.Users { /// ----------------------------------------------------------------------------- /// /// The Profile UserModuleBase is used to register Users /// /// /// /// /// [cnurse] 03/02/2006 /// /// ----------------------------------------------------------------------------- public partial class DNNProfile : ProfileUserControlBase { #region "Protected Properties" /// ----------------------------------------------------------------------------- /// /// Gets whether to display the Visibility controls /// /// /// [cnurse] 08/11/2006 Created /// /// ----------------------------------------------------------------------------- protected bool ShowVisibility { get { object setting = GetSetting(PortalId, "Profile_DisplayVisibility"); return Convert.ToBoolean(setting) && IsUser; } } #endregion #region "Public Properties" /// ----------------------------------------------------------------------------- /// /// Gets and sets the EditorMode /// /// /// [cnurse] 05/02/2006 Created /// /// ----------------------------------------------------------------------------- public PropertyEditorMode EditorMode { get { return ProfileProperties.EditMode; } set { ProfileProperties.EditMode = value; } } /// ----------------------------------------------------------------------------- /// /// Gets whether the User is valid /// /// /// [cnurse] 05/18/2006 Created /// /// ----------------------------------------------------------------------------- public bool IsValid { get { bool _IsValid = false; if (ProfileProperties.IsValid || IsAdmin) { _IsValid = true; } return _IsValid; } } /// ----------------------------------------------------------------------------- /// /// Gets and sets whether the Update button /// /// /// [cnurse] 05/18/2006 Created /// /// ----------------------------------------------------------------------------- public bool ShowUpdate { get { return actionsRow.Visible; } set { actionsRow.Visible = value; } } /// ----------------------------------------------------------------------------- /// /// Gets the UserProfile associated with this control /// /// /// [cnurse] 03/02/2006 Created /// /// ----------------------------------------------------------------------------- public UserProfile UserProfile { get { UserProfile _Profile = null; if (User != null) { _Profile = User.Profile; } return _Profile; } } #endregion #region "Public Methods" /// ----------------------------------------------------------------------------- /// /// DataBind binds the data to the controls /// /// /// [cnurse] 03/01/2006 Created /// /// ----------------------------------------------------------------------------- public override void DataBind() { if (IsAdmin) { lblTitle.Text = string.Format(Localization.GetString("ProfileTitle.Text", LocalResourceFile), User.Username, User.UserID); } else if (IsRegister) { lblTitle.Text = Localization.GetString("RequireProfile.Text", LocalResourceFile); } else { divTitle.Visible = false; } //Before we bind the Profile to the editor we need to "update" the visible data ProfilePropertyDefinitionCollection properties = new ProfilePropertyDefinitionCollection(); foreach (ProfilePropertyDefinition profProperty in UserProfile.ProfileProperties) { if (IsAdmin && !IsProfile) { profProperty.Visible = true; } if (!profProperty.Deleted) properties.Add(profProperty); } ProfileProperties.ShowVisibility = ShowVisibility; ProfileProperties.DataSource = properties; ProfileProperties.DataBind(); } #endregion #region "Event Handlers" /// ----------------------------------------------------------------------------- /// /// Page_Init runs when the control is initialised /// /// /// /// /// [cnurse] 03/01/2006 Created /// /// ----------------------------------------------------------------------------- protected override void OnInit(EventArgs e) { base.OnInit(e); //Get the base Page var basePage = Page as PageBase; if (basePage != null) { //Check if culture is RTL if (basePage.PageCulture.TextInfo.IsRightToLeft) { ProfileProperties.LabelMode = LabelMode.Right; } else { ProfileProperties.LabelMode = LabelMode.Left; } } } /// ----------------------------------------------------------------------------- /// /// Page_Load runs when the control is loaded /// /// /// /// /// [cnurse] 03/01/2006 Created /// /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); ProfileProperties.LocalResourceFile = LocalResourceFile; cmdUpdate.Click += cmdUpdate_Click; } /// ----------------------------------------------------------------------------- /// /// cmdUpdate_Click runs when the Update Button is clicked /// /// /// /// /// [cnurse] 03/01/2006 Created /// /// ----------------------------------------------------------------------------- private void cmdUpdate_Click(object sender, EventArgs e) { if (IsValid) { var properties = (ProfilePropertyDefinitionCollection) ProfileProperties.DataSource; //Update User's profile User = ProfileController.UpdateUserProfile(User, properties); OnProfileUpdated(EventArgs.Empty); OnProfileUpdateCompleted(EventArgs.Empty); } } #endregion } }