#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 System.Web;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Entities.Users;
using DotNetNuke.Framework;
using DotNetNuke.Modules.Admin.Security;
using DotNetNuke.Security;
using DotNetNuke.Security.Membership;
using DotNetNuke.Security.Profile;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Mail;
using DotNetNuke.UI.Skins.Controls;
#endregion
namespace DotNetNuke.Modules.Admin.Users
{
/// -----------------------------------------------------------------------------
///
/// The ManageUsers UserModuleBase is used to manage Users
///
///
///
///
/// [cnurse] 9/13/2004 Updated to reflect design changes for Help, 508 support
/// and localisation
/// [cnurse] 2/21/2005 Updated to use new User UserControl
///
/// -----------------------------------------------------------------------------
public partial class ManageUsers : UserModuleBase, IActionable
{
#region "Protected Members"
/// -----------------------------------------------------------------------------
///
/// Gets whether to display the Manage Services tab
///
///
/// [cnurse] 08/11/2006 Created
///
/// -----------------------------------------------------------------------------
protected bool DisplayServices
{
get
{
object setting = GetSetting(PortalId, "Profile_ManageServices");
return Convert.ToBoolean(setting) && !(IsEdit || User.IsSuperUser);
}
}
/// -----------------------------------------------------------------------------
///
/// Gets the Redirect URL (after successful registration)
///
///
/// [cnurse] 05/18/2006 Created
///
/// -----------------------------------------------------------------------------
protected string RedirectURL
{
get
{
string _RedirectURL = "";
object setting = GetSetting(PortalId, "Redirect_AfterRegistration");
if (Convert.ToInt32(setting) == Null.NullInteger)
{
if (Request.QueryString["returnurl"] != null)
{
//return to the url passed to register
_RedirectURL = HttpUtility.UrlDecode(Request.QueryString["returnurl"]);
//redirect url should never contain a protocol ( if it does, it is likely a cross-site request forgery attempt )
if (_RedirectURL.Contains("://"))
{
_RedirectURL = "";
}
if (_RedirectURL.Contains("?returnurl"))
{
string baseURL = _RedirectURL.Substring(0, _RedirectURL.IndexOf("?returnurl"));
string returnURL = _RedirectURL.Substring(_RedirectURL.IndexOf("?returnurl") + 11);
_RedirectURL = string.Concat(baseURL, "?returnurl", HttpUtility.UrlEncode(returnURL));
}
}
if (String.IsNullOrEmpty(_RedirectURL))
{
//redirect to current page
_RedirectURL = Globals.NavigateURL();
}
}
else //redirect to after registration page
{
_RedirectURL = Globals.NavigateURL(Convert.ToInt32(setting));
}
return _RedirectURL;
}
}
/// -----------------------------------------------------------------------------
///
/// Gets whether a profile is required in AddUser mode
///
///
/// [cnurse] 05/18/2006 Created
///
/// -----------------------------------------------------------------------------
protected bool RequireProfile
{
get
{
object setting = GetSetting(PortalId, "Security_RequireValidProfile");
return Convert.ToBoolean(setting) && IsRegister;
}
}
/// -----------------------------------------------------------------------------
///
/// Gets the Return Url for the page
///
///
/// [cnurse] 03/09/2006 Created
///
/// -----------------------------------------------------------------------------
protected string ReturnUrl
{
get
{
return Globals.NavigateURL(TabId, "", !String.IsNullOrEmpty(UserFilter) ? UserFilter : "");
}
}
/// -----------------------------------------------------------------------------
///
/// Gets whether the Captcha control is used to validate registration
///
///
/// [cnurse] 03/21/2006 Created
///
/// -----------------------------------------------------------------------------
protected bool UseCaptcha
{
get
{
object setting = GetSetting(PortalId, "Security_CaptchaRegister");
return Convert.ToBoolean(setting) && IsRegister;
}
}
/// -----------------------------------------------------------------------------
///
/// Gets and sets the Filter to use
///
///
/// [cnurse] 03/09/2006 Created
///
/// -----------------------------------------------------------------------------
protected string UserFilter
{
get
{
string filterString = !string.IsNullOrEmpty(Request["filter"]) ? "filter=" + Request["filter"] : "";
string filterProperty = !string.IsNullOrEmpty(Request["filterproperty"]) ? "filterproperty=" + Request["filterproperty"] : "";
string page = !string.IsNullOrEmpty(Request["currentpage"]) ? "currentpage=" + Request["currentpage"] : "";
if (!string.IsNullOrEmpty(filterString))
{
filterString += "&";
}
if (!string.IsNullOrEmpty(filterProperty))
{
filterString += filterProperty + "&";
}
if (!string.IsNullOrEmpty(page))
{
filterString += page;
}
return filterString;
}
}
#endregion
#region "Public Properties"
/// -----------------------------------------------------------------------------
///
/// Gets and sets the current Page No
///
///
/// [cnurse] 03/09/2006 Created
///
/// -----------------------------------------------------------------------------
public int PageNo
{
get
{
int _PageNo = 0;
if (ViewState["PageNo"] != null)
{
_PageNo = Convert.ToInt32(ViewState["PageNo"]);
}
return _PageNo;
}
set
{
ViewState["PageNo"] = value;
}
}
#endregion
#region IActionable Members
public ModuleActionCollection ModuleActions
{
get
{
var Actions = new ModuleActionCollection();
if (!IsProfile)
{
if (!AddUser && !IsEdit)
{
Actions.Add(GetNextActionID(),
Localization.GetString(ModuleActionType.AddContent, LocalResourceFile),
ModuleActionType.AddContent,
"",
"add.gif",
EditUrl(),
false,
SecurityAccessLevel.Admin,
true,
false);
if (ProfileProviderConfig.CanEditProviderProperties)
{
Actions.Add(GetNextActionID(),
Localization.GetString("ManageProfile.Action", LocalResourceFile),
ModuleActionType.AddContent,
"",
"icon_profile_16px.gif",
EditUrl("ManageProfile"),
false,
SecurityAccessLevel.Admin,
true,
false);
}
Actions.Add(GetNextActionID(),
Localization.GetString("Cancel.Action", LocalResourceFile),
ModuleActionType.AddContent,
"",
"lt.gif",
ReturnUrl,
false,
SecurityAccessLevel.Admin,
true,
false);
}
}
return Actions;
}
}
#endregion
#region "Private Methods"
/// -----------------------------------------------------------------------------
///
/// BindData binds the controls to the Data
///
///
///
///
/// [cnurse] 9/13/2004 Updated to reflect design changes for Help, 508 support
/// and localisation
///
/// -----------------------------------------------------------------------------
private void BindData()
{
if (User != null)
{
//If trying to add a SuperUser - check that user is a SuperUser
if (AddUser && !IsRegister && IsHostMenu && !UserInfo.IsSuperUser)
{
AddModuleMessage("NoUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
DisableForm();
return;
}
//Check if User is a member of the Current Portal
if (User.PortalID != Null.NullInteger && User.PortalID != PortalId)
{
AddModuleMessage("InvalidUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
DisableForm();
return;
}
//Check if User is a SuperUser and that the current User is a SuperUser
if (User.IsSuperUser && !UserInfo.IsSuperUser)
{
AddModuleMessage("NoUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
DisableForm();
return;
}
if (IsEdit)
{
//Check if user has admin rights
if (!IsAdmin || (User.IsInRole(PortalSettings.AdministratorRoleName) && !PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)))
{
AddModuleMessage("NotAuthorized", ModuleMessage.ModuleMessageType.YellowWarning, true);
DisableForm();
return;
}
}
else
{
if (!IsUser)
{
if (Request.IsAuthenticated)
{
if (!PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
{
//Display current user's profile
Response.Redirect(Globals.NavigateURL(PortalSettings.UserTabId, "", "UserID=" + UserInfo.UserID), true);
}
}
else
{
if ((User.UserID > Null.NullInteger))
{
AddModuleMessage("NotAuthorized", ModuleMessage.ModuleMessageType.YellowWarning, true);
DisableForm();
return;
}
}
}
}
if (AddUser)
{
if (!Request.IsAuthenticated)
{
BindRegister();
}
else
{
cmdRegister.Text = Localization.GetString("AddUser", LocalResourceFile);
lblTitle.Text = Localization.GetString("AddUser", LocalResourceFile);
}
}
else
{
if (!Request.IsAuthenticated)
{
titleRow.Visible = false;
}
else
{
if (IsUser && IsProfile)
{
titleRow.Visible = false;
}
else
{
lblTitle.Text = string.Format(Localization.GetString("UserTitle", LocalResourceFile), User.Username, User.UserID);
}
}
}
if (!Page.IsPostBack)
{
if ((Request.QueryString["pageno"] != null))
{
PageNo = int.Parse(Request.QueryString["pageno"]);
}
else
{
PageNo = 0;
}
}
ShowPanel();
}
else
{
AddModuleMessage("NoUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
DisableForm();
}
}
/// -----------------------------------------------------------------------------
///
/// BindMembership binds the membership controls
///
///
/// [cnurse] 03/13/2006
///
/// -----------------------------------------------------------------------------
private void BindMembership()
{
ctlMembership.User = User;
ctlMembership.DataBind();
AddModuleMessage("UserLockedOut", ModuleMessage.ModuleMessageType.YellowWarning, ctlMembership.UserMembership.LockedOut && (!Page.IsPostBack));
imgLockedOut.Visible = ctlMembership.UserMembership.LockedOut;
imgOnline.Visible = ctlMembership.UserMembership.IsOnLine;
}
/// -----------------------------------------------------------------------------
///
/// BindRegister binds the register controls
///
///
/// [cnurse] 03/20/2006
///
/// -----------------------------------------------------------------------------
private void BindRegister()
{
if (UseCaptcha)
{
ctlCaptcha.ErrorMessage = Localization.GetString("InvalidCaptcha", LocalResourceFile);
ctlCaptcha.Text = Localization.GetString("CaptchaText", LocalResourceFile);
}
//Verify that the current user has access to this page
if (PortalSettings.UserRegistration == (int) Globals.PortalRegistrationType.NoRegistration && Request.IsAuthenticated == false)
{
Response.Redirect(Globals.NavigateURL("Access Denied"), true);
}
lblTitle.Text = Localization.GetString("Register", LocalResourceFile);
cmdRegister.Text = Localization.GetString("cmdRegister", LocalResourceFile);
lblUserHelp.Text = Localization.GetSystemMessage(PortalSettings, "MESSAGE_REGISTRATION_INSTRUCTIONS");
switch (PortalSettings.UserRegistration)
{
case (int) Globals.PortalRegistrationType.PrivateRegistration:
lblUserHelp.Text += Localization.GetString("PrivateMembership", Localization.SharedResourceFile);
break;
case (int) Globals.PortalRegistrationType.PublicRegistration:
lblUserHelp.Text += Localization.GetString("PublicMembership", Localization.SharedResourceFile);
break;
case (int) Globals.PortalRegistrationType.VerifiedRegistration:
lblUserHelp.Text += Localization.GetString("VerifiedMembership", Localization.SharedResourceFile);
break;
}
lblUserHelp.Text += Localization.GetString("Required", LocalResourceFile);
lblUserHelp.Text += Localization.GetString("RegisterWarning", LocalResourceFile);
helpRow.Visible = true;
captchaRow.Visible = UseCaptcha;
}
/// -----------------------------------------------------------------------------
///
/// BindUser binds the user controls
///
///
/// [cnurse] 03/13/2006
///
/// -----------------------------------------------------------------------------
private void BindUser()
{
if (AddUser)
{
ctlUser.ShowUpdate = false;
CheckQuota();
}
ctlUser.User = User;
ctlUser.DataBind();
//Bind the Membership
if (AddUser || (IsUser && !IsAdmin))
{
membershipRow.Visible = false;
}
else
{
BindMembership();
}
}
/// -----------------------------------------------------------------------------
///
/// CheckQuota checks whether the User Quota will be exceeded
///
///
///
///
/// [cnurse] 11/16/2006 Created
///
/// -----------------------------------------------------------------------------
private void CheckQuota()
{
if (PortalSettings.Users < PortalSettings.UserQuota || UserInfo.IsSuperUser || PortalSettings.UserQuota == 0)
{
cmdRegister.Enabled = true;
}
else
{
cmdRegister.Enabled = false;
if (IsRegister)
{
AddModuleMessage("ExceededRegisterQuota", ModuleMessage.ModuleMessageType.YellowWarning, true);
}
else
{
AddModuleMessage("ExceededUserQuota", ModuleMessage.ModuleMessageType.YellowWarning, true);
}
}
}
/// -----------------------------------------------------------------------------
///
/// DisableForm disbles the form (if the user is not authorised)
///
///
/// [cnurse] 03/13/2006
///
/// -----------------------------------------------------------------------------
private void DisableForm()
{
adminTabNav.Visible = false;
}
/// -----------------------------------------------------------------------------
///
/// ShowPanel displays the correct "panel"
///
///
/// [cnurse] 03/13/2006
///
/// -----------------------------------------------------------------------------
private void ShowPanel()
{
if (AddUser)
{
adminTabNav.Visible = false;
if (Request.IsAuthenticated && MembershipProviderConfig.RequiresQuestionAndAnswer)
{
//Admin adding user
//pnlUser.Visible = false;
actionsRow.Visible = false;
AddModuleMessage("CannotAddUser", ModuleMessage.ModuleMessageType.YellowWarning, true);
}
else
{
//pnlUser.Visible = true;
actionsRow.Visible = true;
}
BindUser();
if (RequireProfile)
{
if (AddUser)
{
ctlProfile.ShowUpdate = false;
}
dnnProfileDetails.CssClass += " dnnRequireProfile";
ctlProfile.User = User;
ctlProfile.DataBind();
}
dnnProfileDetails.Visible = RequireProfile;
}
else
{
//pnlUser.Visible = showUser;
//pnlProfile.Visible = showProfile;
if ((!IsAdmin && !IsUser))
{
passwordTab.Visible = false;
}
else
{
ctlPassword.User = User;
ctlPassword.DataBind();
}
if ((!IsEdit || User.IsSuperUser))
{
rolesTab.Visible = false;
}
else
{
ctlRoles.DataBind();
}
//cmdProfile.Enabled = !showProfile;
if ((!DisplayServices))
{
servicesTab.Visible = false;
}
else
{
ctlServices.User = User;
ctlServices.DataBind();
}
BindUser();
ctlProfile.User = User;
ctlProfile.DataBind();
}
dnnRoleDetails.Visible = IsEdit && !User.IsSuperUser && !AddUser;
dnnServicesDetails.Visible = DisplayServices && !IsRegister && !AddUser;
dnnPasswordDetails.Visible = (IsAdmin || IsUser) && !AddUser;
}
#endregion
#region "Event Handlers"
/// -----------------------------------------------------------------------------
///
/// Page_Init runs when the control is initialised
///
///
///
///
/// [cnurse] 03/01/2006
///
/// -----------------------------------------------------------------------------
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
jQuery.RequestDnnPluginsRegistration();
//Set the Membership Control Properties
ctlMembership.ID = "Membership";
ctlMembership.ModuleConfiguration = ModuleConfiguration;
ctlMembership.UserId = UserId;
//Set the User Control Properties
ctlUser.ID = "User";
ctlUser.ModuleConfiguration = ModuleConfiguration;
ctlUser.UserId = UserId;
//Set the Roles Control Properties
ctlRoles.ID = "SecurityRoles";
ctlRoles.ModuleConfiguration = ModuleConfiguration;
ctlRoles.ParentModule = this;
//Set the Password Control Properties
ctlPassword.ID = "Password";
ctlPassword.ModuleConfiguration = ModuleConfiguration;
ctlPassword.UserId = UserId;
//Set the Profile Control Properties
ctlProfile.ID = "Profile";
ctlProfile.ModuleConfiguration = ModuleConfiguration;
ctlProfile.UserId = UserId;
//Set the Services Control Properties
ctlServices.ID = "MemberServices";
ctlServices.ModuleConfiguration = ModuleConfiguration;
ctlServices.UserId = UserId;
//Customise the Control Title
if (AddUser)
{
if (!Request.IsAuthenticated)
{
//Register
ModuleConfiguration.ModuleTitle = Localization.GetString("Register.Title", LocalResourceFile);
}
else
{
//Add User
ModuleConfiguration.ModuleTitle = Localization.GetString("AddUser.Title", LocalResourceFile);
}
ctlUser.CssClass = "register";
}
}
/// -----------------------------------------------------------------------------
///
/// Page_Load runs when the control is loaded
///
///
///
///
/// [cnurse] 03/01/2006
///
/// -----------------------------------------------------------------------------
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
cmdCancel.Click += cmdCancel_Click;
cmdRegister.Click += cmdRegister_Click;
ctlUser.UserCreateCompleted += UserCreateCompleted;
ctlUser.UserDeleted += UserDeleted;
ctlUser.UserRemoved += UserRemoved;
ctlUser.UserRestored += UserRestored;
ctlUser.UserUpdateCompleted += UserUpdateCompleted;
ctlUser.UserUpdateError += UserUpdateError;
ctlServices.SubscriptionUpdated += SubscriptionUpdated;
ctlProfile.ProfileUpdateCompleted += ProfileUpdateCompleted;
ctlPassword.PasswordUpdated += PasswordUpdated;
ctlPassword.PasswordQuestionAnswerUpdated += PasswordQuestionAnswerUpdated;
ctlMembership.MembershipAuthorized += MembershipAuthorized;
ctlMembership.MembershipPasswordUpdateChanged += MembershipPasswordUpdateChanged;
ctlMembership.MembershipUnAuthorized += MembershipUnAuthorized;
ctlMembership.MembershipUnLocked += MembershipUnLocked;
try
{
//Add an Action Event Handler to the Skin
AddActionHandler(ModuleAction_Click);
//Bind the User information to the controls
BindData();
loginLink.NavigateUrl = Globals.LoginURL(RedirectURL, (Request.QueryString["override"] != null));
if (PortalSettings.EnablePopUps)
{
loginLink.Attributes.Add("onclick", "return " + UrlUtils.PopUpUrl(loginLink.NavigateUrl, this, PortalSettings, true, false, 300, 650));
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
protected void cmdCancel_Click(object sender, EventArgs e)
{
Response.Redirect(Globals.NavigateURL(), true);
}
/// -----------------------------------------------------------------------------
///
/// cmdRegister_Click runs when the Register button is clicked
///
///
///
///
/// [cnurse] 05/18/2006
///
/// -----------------------------------------------------------------------------
protected void cmdRegister_Click(object sender, EventArgs e)
{
if (((UseCaptcha && ctlCaptcha.IsValid) || (!UseCaptcha)) && ctlUser.IsValid && ((RequireProfile && ctlProfile.IsValid) || (!RequireProfile)))
{
ctlUser.CreateUser();
}
}
/// -----------------------------------------------------------------------------
///
/// ModuleAction_Click handles all ModuleAction events raised from the skin
///
///
///
/// The object that triggers the event
/// An ActionEventArgs object
///
/// [cnurse] 03/01/2006 Created
///
/// -----------------------------------------------------------------------------
private void ModuleAction_Click(object sender, ActionEventArgs e)
{
switch (e.Action.CommandArgument)
{
case "ManageRoles":
//pnlRoles.Visible = true;
//pnlUser.Visible = false;
break;
case "Cancel":
break;
case "Delete":
break;
case "Edit":
break;
case "Save":
break;
default:
break;
}
}
/// -----------------------------------------------------------------------------
///
/// MembershipAuthorized runs when the User has been unlocked
///
///
///
///
/// [cnurse] 3/01/2006 created
///
/// -----------------------------------------------------------------------------
private void MembershipAuthorized(object sender, EventArgs e)
{
try
{
AddModuleMessage("UserAuthorized", ModuleMessage.ModuleMessageType.GreenSuccess, true);
//Send Notification to User
if (string.IsNullOrEmpty(User.Membership.Password) && !MembershipProviderConfig.RequiresQuestionAndAnswer && MembershipProviderConfig.PasswordRetrievalEnabled)
{
UserInfo user = User;
User.Membership.Password = UserController.GetPassword(ref user, "");
}
Mail.SendMail(User, MessageType.UserRegistrationPublic, PortalSettings);
BindMembership();
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
/// -----------------------------------------------------------------------------
///
/// MembershipPasswordUpdateChanged runs when the Admin has forced the User to update their password
///
///
///
///
/// [cnurse] 05/14/2008 created
///
/// -----------------------------------------------------------------------------
protected void MembershipPasswordUpdateChanged(object sender, EventArgs e)
{
try
{
AddModuleMessage("UserPasswordUpdateChanged", ModuleMessage.ModuleMessageType.GreenSuccess, true);
BindMembership();
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
/// -----------------------------------------------------------------------------
///
/// MembershipUnAuthorized runs when the User has been unlocked
///
///
///
///
/// [cnurse] 3/01/2006 created
///
/// -----------------------------------------------------------------------------
private void MembershipUnAuthorized(object sender, EventArgs e)
{
try
{
AddModuleMessage("UserUnAuthorized", ModuleMessage.ModuleMessageType.GreenSuccess, true);
BindMembership();
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
/// -----------------------------------------------------------------------------
///
/// MembershipUnLocked runs when the User has been unlocked
///
///
///
///
/// [cnurse] 3/01/2006 created
///
/// -----------------------------------------------------------------------------
private void MembershipUnLocked(object sender, EventArgs e)
{
try
{
AddModuleMessage("UserUnLocked", ModuleMessage.ModuleMessageType.GreenSuccess, true);
BindMembership();
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
/// -----------------------------------------------------------------------------
///
/// PasswordQuestionAnswerUpdated runs when the Password Q and A have been updated.
///
///
///
///
/// [cnurse] 3/09/2006 created
///
/// -----------------------------------------------------------------------------
private void PasswordQuestionAnswerUpdated(object sender, Password.PasswordUpdatedEventArgs e)
{
PasswordUpdateStatus status = e.UpdateStatus;
if (status == PasswordUpdateStatus.Success)
{
AddModuleMessage("PasswordQAChanged", ModuleMessage.ModuleMessageType.GreenSuccess, true);
}
else
{
AddModuleMessage(status.ToString(), ModuleMessage.ModuleMessageType.RedError, true);
}
}
/// -----------------------------------------------------------------------------
///
/// PasswordUpdated runs when the Password has been updated or reset
///
///
///
///
/// [cnurse] 3/08/2006 created
///
/// -----------------------------------------------------------------------------
private void PasswordUpdated(object sender, Password.PasswordUpdatedEventArgs e)
{
PasswordUpdateStatus status = e.UpdateStatus;
if (status == PasswordUpdateStatus.Success)
{
//Send Notification to User
try
{
var accessingUser = (UserInfo) HttpContext.Current.Items["UserInfo"];
if (accessingUser.UserID != User.UserID)
{
//The password was changed by someone else
Mail.SendMail(User, MessageType.PasswordReminder, PortalSettings);
}
else
{
//The User changed his own password
Mail.SendMail(User, MessageType.UserUpdatedOwnPassword, PortalSettings);
}
AddModuleMessage("PasswordChanged", ModuleMessage.ModuleMessageType.GreenSuccess, true);
}
catch (Exception ex)
{
AddModuleMessage("PasswordMailError", ModuleMessage.ModuleMessageType.YellowWarning, true);
Exceptions.LogException(ex);
}
}
else
{
AddModuleMessage(status.ToString(), ModuleMessage.ModuleMessageType.RedError, true);
}
}
/// -----------------------------------------------------------------------------
///
/// ProfileUpdateCompleted runs when the Profile has been updated
///
///
///
///
/// [cnurse] 3/20/2006 created
///
/// -----------------------------------------------------------------------------
private void ProfileUpdateCompleted(object sender, EventArgs e)
{
if (IsUser)
{
//Notify the user that his/her profile was updated
Mail.SendMail(User, MessageType.ProfileUpdated, PortalSettings);
ProfilePropertyDefinition localeProperty = User.Profile.GetProperty("PreferredLocale");
if (localeProperty.IsDirty)
{
//store preferredlocale in cookie, if none specified set to portal default.
if (User.Profile.PreferredLocale == string.Empty)
{
Localization.SetLanguage(PortalController.GetPortalDefaultLanguage(User.PortalID));
}
else
{
Localization.SetLanguage(User.Profile.PreferredLocale);
}
}
}
//Redirect to same page (this will update all controls for any changes to profile
//and leave us at Page 0 (User Credentials)
Response.Redirect(Request.RawUrl, true);
}
private void SubscriptionUpdated(object sender, MemberServices.SubscriptionUpdatedEventArgs e)
{
string message = Null.NullString;
if (e.Cancel)
{
message = string.Format(Localization.GetString("UserUnSubscribed", LocalResourceFile), e.RoleName);
}
else
{
message = string.Format(Localization.GetString("UserSubscribed", LocalResourceFile), e.RoleName);
}
PortalSecurity.ClearRoles();
AddLocalizedModuleMessage(message, ModuleMessage.ModuleMessageType.GreenSuccess, true);
}
/// -----------------------------------------------------------------------------
///
/// UserCreateCompleted runs when a new user has been Created
///
///
///
///
/// [cnurse] 3/06/2006 created
///
/// -----------------------------------------------------------------------------
private void UserCreateCompleted(object sender, UserUserControlBase.UserCreatedEventArgs e)
{
string strMessage = "";
try
{
if (e.CreateStatus == UserCreateStatus.Success)
{
//hide the succesful captcha
captchaRow.Visible = false;
strMessage = CompleteUserCreation(e.CreateStatus, e.NewUser, e.Notify, IsRegister);
if (IsRegister)
{
if ((string.IsNullOrEmpty(strMessage)))
{
Response.Redirect(RedirectURL, true);
}
else
{
object setting = GetSetting(PortalId, "Redirect_AfterRegistration");
if (Convert.ToInt32(setting) == Null.NullInteger)
{
DisableForm();
cmdRegister.Visible = false;
loginLink.Visible = true;
}
else //redirect to after registration page
{
Response.Redirect(RedirectURL, true);
}
DisableForm();
cmdRegister.Visible = false;
loginLink.Visible = true;
}
}
else
{
Response.Redirect(ReturnUrl, true);
}
}
else
{
AddLocalizedModuleMessage(UserController.GetUserCreateStatus(e.CreateStatus), ModuleMessage.ModuleMessageType.RedError, true);
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
/// -----------------------------------------------------------------------------
///
/// UserDeleted runs when the User has been deleted
///
///
///
///
/// [cnurse] 3/01/2006 created
///
/// -----------------------------------------------------------------------------
private void UserDeleted(object sender, UserUserControlBase.UserDeletedEventArgs e)
{
try
{
Response.Redirect(ReturnUrl, true);
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
/// -----------------------------------------------------------------------------
///
/// UserUpdateCompleted runs when a user has been updated
///
///
///
///
/// [cnurse] 3/02/2006 created
///
/// -----------------------------------------------------------------------------
private void UserRestored(object sender, UserUserControlBase.UserRestoredEventArgs e)
{
try
{
Response.Redirect(ReturnUrl, true);
//Module failed to load
}
catch (Exception exc)
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
private void UserRemoved(object sender, UserUserControlBase.UserRemovedEventArgs e)
{
try
{
Response.Redirect(ReturnUrl, true);
//Module failed to load
}
catch (Exception exc)
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
private void UserUpdateCompleted(object sender, EventArgs e)
{
Response.Redirect(Request.RawUrl, true);
}
/// -----------------------------------------------------------------------------
///
/// UserUpdateError runs when there is an error updating the user
///
///
///
///
/// [cnurse] 2/07/2007 created
///
/// -----------------------------------------------------------------------------
private void UserUpdateError(object sender, UserUserControlBase.UserUpdateErrorArgs e)
{
AddModuleMessage(e.Message, ModuleMessage.ModuleMessageType.RedError, true);
}
#endregion
}
}