/// ----------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <remarks> /// - manage affiliates /// - log visit to site /// </remarks> /// <history> /// [sun1] 1/19/2004 Created /// </history> /// ----------------------------------------------------------------------------- private void ManageRequest() { //affiliate processing int affiliateId = -1; if (Request.QueryString["AffiliateId"] != null) { if (Regex.IsMatch(Request.QueryString["AffiliateId"], "^\\d+$")) { affiliateId = Int32.Parse(Request.QueryString["AffiliateId"]); var objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats(affiliateId, 1, 0); //save the affiliateid for acquisitions if (Request.Cookies["AffiliateId"] == null) //do not overwrite { var objCookie = new HttpCookie("AffiliateId"); objCookie.Value = affiliateId.ToString(); objCookie.Expires = DateTime.Now.AddYears(1); //persist cookie for one year Response.Cookies.Add(objCookie); } } } //site logging if (PortalSettings.SiteLogHistory != 0) { //get User ID //URL Referrer string urlReferrer = ""; try { if (Request.UrlReferrer != null) { urlReferrer = Request.UrlReferrer.ToString(); } } catch (Exception exc) { Logger.Error(exc); } string strSiteLogStorage = Host.SiteLogStorage; int intSiteLogBuffer = Host.SiteLogBuffer; //log visit var objSiteLogs = new SiteLogController(); UserInfo objUserInfo = UserController.GetCurrentUserInfo(); objSiteLogs.AddSiteLog(PortalSettings.PortalId, objUserInfo.UserID, urlReferrer, Request.Url.ToString(), Request.UserAgent, Request.UserHostAddress, Request.UserHostName, PortalSettings.ActiveTab.TabID, affiliateId, intSiteLogBuffer, strSiteLogStorage); } }
protected string CompleteUserCreation(UserCreateStatus createStatus, UserInfo newUser, bool notify, bool register) { var strMessage = ""; var message = ModuleMessage.ModuleMessageType.RedError; if (register) { //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.EnableRegisterNotification || PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PrivateRegistration) { strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationAdmin, PortalSettings); SendAdminNotification(newUser, PortalSettings); } var loginStatus = UserLoginStatus.LOGIN_FAILURE; //complete registration switch (PortalSettings.UserRegistration) { case (int) Globals.PortalRegistrationType.PrivateRegistration: strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPrivate, PortalSettings); //show a message that a portal administrator has to verify the user credentials if (string.IsNullOrEmpty(strMessage)) { strMessage += Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile); message = ModuleMessage.ModuleMessageType.GreenSuccess; } break; case (int) Globals.PortalRegistrationType.PublicRegistration: Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalSettings); UserController.UserLogin(PortalSettings.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false); break; case (int) Globals.PortalRegistrationType.VerifiedRegistration: Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalSettings); UserController.UserLogin(PortalSettings.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false); break; } //affiliate if (!Null.IsNull(User.AffiliateID)) { var objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats(newUser.AffiliateID, 0, 1); } //store preferredlocale in cookie Localization.SetLanguage(newUser.Profile.PreferredLocale); if (IsRegister && message == ModuleMessage.ModuleMessageType.RedError) { AddLocalizedModuleMessage(string.Format(Localization.GetString("SendMail.Error", Localization.SharedResourceFile), strMessage), message, (!String.IsNullOrEmpty(strMessage))); } else { AddLocalizedModuleMessage(strMessage, message, (!String.IsNullOrEmpty(strMessage))); } } else { if (notify) { //Send Notification to User if (PortalSettings.UserRegistration == (int) Globals.PortalRegistrationType.VerifiedRegistration) { strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalSettings); } else { strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalSettings); } } } return strMessage; }
/// <summary> /// UserCreateCompleted runs when a new user has been Created /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 3/06/2006 created /// </history> protected void UserCreateCompleted( object sender, User.UserCreatedEventArgs e ) { string strMessage = ""; try { if( e.CreateStatus == UserCreateStatus.Success ) { if( IsRegister ) { // send notification to portal administrator of new user registration Mail.SendMail( User, MessageType.UserRegistrationAdmin, PortalSettings ); // complete registration switch( PortalSettings.UserRegistration ) { case (int)Globals.PortalRegistrationType.PrivateRegistration: Mail.SendMail( User, MessageType.UserRegistrationPrivate, PortalSettings ); //show a message that a portal administrator has to verify the user credentials strMessage = string.Format( Localization.GetString( "PrivateConfirmationMessage", this.LocalResourceFile ), User.Email ); break; case (int)Globals.PortalRegistrationType.PublicRegistration: Mail.SendMail( User, MessageType.UserRegistrationPublic, PortalSettings ); UserLoginStatus loginStatus = 0; UserController.UserLogin( PortalSettings.PortalId, User.Username, User.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false ); break; case (int)Globals.PortalRegistrationType.VerifiedRegistration: Mail.SendMail( User, MessageType.UserRegistrationVerified, PortalSettings ); //show a message that an email has been send with the registration details strMessage = string.Format( Localization.GetString( "VerifiedConfirmationMessage", this.LocalResourceFile ), User.Email ); break; } // affiliate if( ! Null.IsNull( User.AffiliateID ) ) { AffiliateController objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats( User.AffiliateID, 0, 1 ); } //store preferredlocale in cookie Localization.SetLanguage( User.Profile.PreferredLocale ); AddLocalizedModuleMessage( strMessage, ModuleMessageType.GreenSuccess, ( strMessage.Length > 0 ) ); } else { if( e.Notify ) { //Send Notification to User if( PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration ) { Mail.SendMail( User, MessageType.UserRegistrationVerified, PortalSettings ); } else { Mail.SendMail( User, MessageType.UserRegistrationPublic, PortalSettings ); } } } //Log Event to Event Log EventLogController objEventLog = new EventLogController(); objEventLog.AddLog( User, PortalSettings, UserId, User.Username, EventLogController.EventLogType.USER_CREATED ); if( IsRegister ) { //Response.Redirect( RedirectURL, true ); if (string.IsNullOrEmpty(strMessage)) { Response.Redirect(RedirectURL, true); } else { DisableForm(); pnlRegister.Visible = false; } } else { Response.Redirect( ReturnUrl, true ); } } else { AddLocalizedModuleMessage( UserController.GetUserCreateStatus( e.CreateStatus ), ModuleMessageType.RedError, true ); } } catch( Exception exc ) //Module failed to load { Exceptions.ProcessModuleLoadException( this, exc ); } }
protected string CompleteUserCreation(UserCreateStatus createStatus, UserInfo newUser, bool notify, bool register) { string strMessage = ""; ModuleMessage.ModuleMessageType message = ModuleMessage.ModuleMessageType.RedError; if (register) { //send notification to portal administrator of new user registration strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationAdmin, PortalSettings); var loginStatus = UserLoginStatus.LOGIN_FAILURE; //complete registration switch (PortalSettings.UserRegistration) { case (int) Globals.PortalRegistrationType.PrivateRegistration: strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPrivate, PortalSettings); //show a message that a portal administrator has to verify the user credentials if (string.IsNullOrEmpty(strMessage)) { strMessage += string.Format(Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile), newUser.Email); message = ModuleMessage.ModuleMessageType.GreenSuccess; } break; case (int) Globals.PortalRegistrationType.PublicRegistration: Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalSettings); UserController.UserLogin(PortalSettings.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false); break; case (int) Globals.PortalRegistrationType.VerifiedRegistration: Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalSettings); UserController.UserLogin(PortalSettings.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.PortalName, "", ref loginStatus, false); break; } //affiliate if (!Null.IsNull(User.AffiliateID)) { var objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats(newUser.AffiliateID, 0, 1); } //store preferredlocale in cookie Localization.SetLanguage(newUser.Profile.PreferredLocale); if (IsRegister && message == ModuleMessage.ModuleMessageType.RedError) { AddLocalizedModuleMessage(string.Format(Localization.GetString("SendMail.Error", Localization.SharedResourceFile), strMessage), message, (!String.IsNullOrEmpty(strMessage))); } else { AddLocalizedModuleMessage(strMessage, message, (!String.IsNullOrEmpty(strMessage))); } } else { if (notify) { //Send Notification to User if (PortalSettings.UserRegistration == (int) Globals.PortalRegistrationType.VerifiedRegistration) { strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalSettings); } else { strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalSettings); } } } //Log Event to Event Log var objEventLog = new EventLogController(); objEventLog.AddLog(newUser, PortalSettings, UserId, newUser.Username, EventLogController.EventLogType.USER_CREATED); return strMessage; }
/// <summary> /// cmdRegister_Click runs when the Register Button is clicked /// </summary> /// <history> /// [cnurse] 9/13/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// [cnurse] 10/06/2004 System Messages now handled by Localization /// </history> protected void cmdRegister_Click( Object sender, EventArgs E ) { try { // Only attempt a save/update if all form fields on the page are valid if( Page.IsValid ) { // Add New User to Portal User Database UserInfo objUserInfo; objUserInfo = UserController.GetUserByName( PortalId, userControl.UserName, false ); if( Request.IsAuthenticated ) { if( !String.IsNullOrEmpty(userControl.Password) || !String.IsNullOrEmpty(userControl.Confirm) ) { if( userControl.Password != userControl.Confirm ) { UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "PasswordMatchFailure", this.LocalResourceFile ), ModuleMessageType.YellowWarning ); } return; } string Username = null; if( UserInfo.UserID >= 0 ) { Username = UserInfo.Username; } //if a user is found with that username and the username isn't our current user's username if( objUserInfo != null && userControl.UserName != Username ) { //username already exists in DB so show user an error UI.Skins.Skin.AddModuleMessage( this, string.Format( Localization.GetString( "RegistrationFailure", this.LocalResourceFile ), userControl.UserName ), ModuleMessageType.YellowWarning ); } else { //update the user if (objUserInfo != null) { objUserInfo.UserID = UserInfo.UserID; objUserInfo.PortalID = PortalId; objUserInfo.Profile.FirstName = userControl.FirstName; objUserInfo.Profile.LastName = userControl.LastName; objUserInfo.Profile.Unit = addressUser.Unit; objUserInfo.Profile.Street = addressUser.Street; objUserInfo.Profile.City = addressUser.City; objUserInfo.Profile.Region = addressUser.Region; objUserInfo.Profile.PostalCode = addressUser.Postal; objUserInfo.Profile.Country = addressUser.Country; objUserInfo.Profile.Telephone = addressUser.Telephone; objUserInfo.Email = userControl.Email; objUserInfo.Username = userControl.UserName; objUserInfo.Profile.Cell = addressUser.Cell; objUserInfo.Profile.Fax = addressUser.Fax; objUserInfo.Profile.IM = userControl.IM; objUserInfo.Profile.Website = userControl.Website; objUserInfo.Profile.PreferredLocale = cboLocale.SelectedItem.Value; objUserInfo.Profile.TimeZone = Convert.ToInt32( cboTimeZone.SelectedItem.Value ); //Update the User UserController.UpdateUser( PortalId, objUserInfo ); //store preferredlocale in cookie Localization.SetLanguage( objUserInfo.Profile.PreferredLocale ); } //clear the portal cache if current user is portal administrator (catch email adress changes) if( UserInfo.UserID == PortalSettings.AdministratorId ) { DataCache.ClearPortalCache( PortalId, true ); } // Redirect browser back to home page Response.Redirect( Convert.ToString( ViewState["UrlReferrer"] ), true ); } } else { UserCreateStatus userCreateStatus; //if a user is found with that username, error. //this prevents you from adding a username //with the same name as a superuser. if( objUserInfo != null ) { //username already exists in DB so show user an error UI.Skins.Skin.AddModuleMessage( this, string.Format( Localization.GetString( "RegistrationFailure", this.LocalResourceFile ), userControl.UserName ), ModuleMessageType.YellowWarning ); return; } int AffiliateId = Null.NullInteger; if( Request.Cookies[ "AffiliateId" ] != null ) { AffiliateId = int.Parse( Request.Cookies[ "AffiliateId" ].Value ); } UserInfo objNewUser = new UserInfo(); objNewUser.PortalID = PortalId; objNewUser.Profile.FirstName = userControl.FirstName; objNewUser.Profile.LastName = userControl.LastName; objNewUser.Profile.Unit = addressUser.Unit; objNewUser.Profile.Street = addressUser.Street; objNewUser.Profile.City = addressUser.City; objNewUser.Profile.Region = addressUser.Region; objNewUser.Profile.PostalCode = addressUser.Postal; objNewUser.Profile.Country = addressUser.Country; objNewUser.Profile.Telephone = addressUser.Telephone; objNewUser.Email = userControl.Email; objNewUser.Username = userControl.UserName; objNewUser.Membership.Password = userControl.Password; objNewUser.Membership.Approved = Convert.ToBoolean( PortalSettings.UserRegistration != (int)Globals.PortalRegistrationType.PublicRegistration ? false : true ); objNewUser.AffiliateID = AffiliateId; objNewUser.Profile.Cell = addressUser.Cell; objNewUser.Profile.Fax = addressUser.Fax; objNewUser.Profile.IM = userControl.IM; objNewUser.Profile.Website = userControl.Website; objNewUser.Profile.PreferredLocale = cboLocale.SelectedItem.Value; objNewUser.Profile.TimeZone = Convert.ToInt32( cboTimeZone.SelectedItem.Value ); userCreateStatus = UserController.CreateUser( ref objNewUser ); if( userCreateStatus == UserCreateStatus.Success ) { EventLogController objEventLog = new EventLogController(); objEventLog.AddLog( objNewUser, PortalSettings, UserId, userControl.UserName, EventLogController.EventLogType.USER_CREATED ); // send notification to portal administrator of new user registration Mail.SendMail( PortalSettings.Email, PortalSettings.Email, "", Localization.GetSystemMessage( PortalSettings.DefaultLanguage, PortalSettings, "EMAIL_USER_REGISTRATION_ADMINISTRATOR_SUBJECT", objNewUser ), Localization.GetSystemMessage( PortalSettings.DefaultLanguage, PortalSettings, "EMAIL_USER_REGISTRATION_ADMINISTRATOR_BODY", objNewUser ), "", "", "", "", "", "" ); // complete registration string strMessage = ""; if( PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PrivateRegistration ) { Mail.SendMail( PortalSettings.Email, userControl.Email, "", Localization.GetSystemMessage( objNewUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PRIVATE_SUBJECT", objNewUser ), Localization.GetSystemMessage( objNewUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PRIVATE_BODY", objNewUser ), "", "", "", "", "", "" ); //show a message that a portal administrator has to verify the user credentials strMessage = string.Format( Localization.GetString( "PrivateConfirmationMessage", this.LocalResourceFile ), userControl.Email ); } else if( PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration ) { UserLoginStatus loginStatus = 0; UserController.UserLogin( PortalSettings.PortalId, userControl.UserName, userControl.Password, "", PortalSettings.PortalName, "", ref loginStatus, false ); } else if( PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration ) { Mail.SendMail( PortalSettings.Email, userControl.Email, "", Localization.GetSystemMessage( objNewUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PUBLIC_SUBJECT", objNewUser ), Localization.GetSystemMessage( objNewUser.Profile.PreferredLocale, PortalSettings, "EMAIL_USER_REGISTRATION_PUBLIC_BODY", objNewUser ), "", "", "", "", "", "" ); //show a message that an email has been send with the registration details strMessage = string.Format( Localization.GetString( "VerifiedConfirmationMessage", this.LocalResourceFile ), userControl.Email ); } // affiliate if( ! Null.IsNull( AffiliateId ) ) { AffiliateController objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats( AffiliateId, 0, 1 ); } //store preferredlocale in cookie Localization.SetLanguage( objNewUser.Profile.PreferredLocale ); if( strMessage.Length != 0 ) { UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.GreenSuccess ); UserRow.Visible = false; cmdRegister.Visible = false; cmdUnregister.Visible = false; cmdCancel.Visible = false; } else { // Redirect browser back to home page Response.Redirect( Convert.ToString( ViewState["UrlReferrer"] ), true ); } } else // registration error { UI.Skins.Skin.AddModuleMessage( this, UserController.GetUserCreateStatus( userCreateStatus ), ModuleMessageType.RedError ); } } } } catch( Exception exc ) //Module failed to load { Exceptions.ProcessModuleLoadException( this, exc ); } }
/// <remarks> /// - manage affiliates /// - log visit to site /// </remarks> /// <history> /// [sun1] 1/19/2004 Created /// </history> private void ManageRequest() { // affiliate processing int AffiliateId = - 1; if( Request.QueryString["AffiliateId"] != null ) { if( Int32.TryParse(Request.QueryString["AffiliateId"], out AffiliateId ) ) { AffiliateId = int.Parse( Request.QueryString["AffiliateId"] ); AffiliateController objAffiliates = new AffiliateController(); objAffiliates.UpdateAffiliateStats( AffiliateId, 1, 0 ); // save the affiliateid for acquisitions if( Request.Cookies["AffiliateId"] == null ) // do not overwrite { HttpCookie objCookie = new HttpCookie( "AffiliateId" ); objCookie.Value = AffiliateId.ToString(); objCookie.Expires = DateTime.Now.AddYears( 1 ); // persist cookie for one year Response.Cookies.Add( objCookie ); } } } // site logging if( PortalSettings.SiteLogHistory != 0 ) { // get User ID // URL Referrer string URLReferrer = ""; if( Request.UrlReferrer != null ) { URLReferrer = Request.UrlReferrer.ToString(); } string strSiteLogStorage = "D"; if( Convert.ToString( Globals.HostSettings["SiteLogStorage"] ) != "" ) { strSiteLogStorage = Convert.ToString( Globals.HostSettings["SiteLogStorage"] ); } int intSiteLogBuffer = 1; if( Convert.ToString( Globals.HostSettings["SiteLogBuffer"] ) != "" ) { intSiteLogBuffer = int.Parse( Convert.ToString( Globals.HostSettings["SiteLogBuffer"] ) ); } // log visit SiteLogController objSiteLogs = new SiteLogController(); UserInfo objUserInfo = UserController.GetCurrentUserInfo(); objSiteLogs.AddSiteLog( PortalSettings.PortalId, objUserInfo.UserID, URLReferrer, Request.Url.ToString(), Request.UserAgent, Request.UserHostAddress, Request.UserHostName, PortalSettings.ActiveTab.TabID, AffiliateId, intSiteLogBuffer, strSiteLogStorage ); } }