forked from dnnsoftware/Dnn.Platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial New User Email Not Sending At Time of Creation (dnnsoftware#2492
) This is alternative way to fix above issue proposed in dnnsoftware/Dnn.AdminExperience#174 As per @sleupold , we need to move email notifications from UI to core part. Once this will be approved and merged, we can remove email notifications from UI and replace it with updated controller method to let notifications to be send to their recipients. fixes dnnsoftware#2424
- Loading branch information
Showing
4 changed files
with
83 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
DNN Platform/Library/Entities/Users/UserRegistrationEmailNotifier.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using DotNetNuke.Common; | ||
using DotNetNuke.Common.Utilities; | ||
using DotNetNuke.Entities.Portals; | ||
using DotNetNuke.Services.Mail; | ||
using static DotNetNuke.Common.Globals; | ||
|
||
namespace DotNetNuke.Entities.Users | ||
{ | ||
public class UserRegistrationEmailNotifier | ||
{ | ||
public UserRegistrationEmailNotifier() | ||
{ | ||
} | ||
|
||
public static void NotifyAdministrator(UserInfo user) | ||
{ | ||
// avoid self-notification (i.e. on site installation/super user creation) | ||
var currentUser = UserController.Instance.GetCurrentUserInfo(); | ||
if (currentUser != null && (currentUser.UserID == Null.NullInteger || currentUser.UserID == user.UserID)) | ||
{ | ||
return; | ||
} | ||
|
||
//send notification to portal administrator of new user registration | ||
//check the receive notification setting first, but if register type is Private, we will always send the notification email. | ||
//because the user need administrators to do the approve action so that he can continue use the website. | ||
if (PortalSettings.Current.EnableRegisterNotification || PortalSettings.Current.UserRegistration == (int)Globals.PortalRegistrationType.PrivateRegistration) | ||
{ | ||
NotifyUser(user, MessageType.UserRegistrationAdmin); | ||
} | ||
} | ||
|
||
public static void NotifyUser(UserInfo user) | ||
{ | ||
switch (PortalSettings.Current.UserRegistration) | ||
{ | ||
case (int)PortalRegistrationType.PrivateRegistration: | ||
NotifyUser(user, MessageType.UserRegistrationPrivate); | ||
break; | ||
case (int)PortalRegistrationType.PublicRegistration: | ||
NotifyUser(user, MessageType.UserRegistrationPublic); | ||
break; | ||
case (int)PortalRegistrationType.VerifiedRegistration: | ||
NotifyUser(user, MessageType.UserRegistrationVerified); | ||
break; | ||
case (int)PortalRegistrationType.NoRegistration: | ||
NotifyUser(user, MessageType.UserRegistrationPublic); | ||
break; | ||
} | ||
} | ||
|
||
public static void NotifyUser(UserInfo user, MessageType type) | ||
{ | ||
Mail.SendMail(user, type, PortalSettings.Current); | ||
} | ||
} | ||
} |