private ActionResult UpdateGeneralSettings(dynamic request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                HostController.Instance.Update("AutoAccountUnlockDuration", request.AutoAccountUnlockDuration.Value.ToString(), false);
                HostController.Instance.Update("AsyncTimeout", request.AsyncTimeout.Value.ToString(), false);
                HostController.Instance.Update("FileExtensions", SecurityManager.ValidateFileExtension(request.FileExtensions.Value.ToString()), false);

                long    maxCurrentRequest = Config.GetMaxUploadSize();
                dynamic maxUploadByMb     = request.MaxUploadSize.Value * 1024 * 1024;
                if (maxCurrentRequest != maxUploadByMb)
                {
                    Config.SetMaxUploadSize(maxUploadByMb);
                }

                DataCache.ClearCache();
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
Exemplo n.º 2
0
        public ActionResult DeleteProfileProperty(int propertyId)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                int pid = PortalSettings.PortalId;
                if (!UserInfo.IsSuperUser && PortalSettings.PortalId != pid)
                {
                    actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage);
                }

                if (actionResult.IsSuccess)
                {
                    ProfilePropertyDefinition propertyDefinition = ProfileController.GetPropertyDefinition(propertyId, pid);

                    if (!CanDeleteProperty(propertyDefinition))
                    {
                        actionResult.AddError(HttpStatusCode.BadRequest.ToString(), "ForbiddenDelete");
                    }
                    if (actionResult.IsSuccess)
                    {
                        ProfileController.DeletePropertyDefinition(propertyDefinition);
                        DataCache.ClearDefinitionsCache(pid);
                        actionResult.Data = new { MemberProfile = Managers.MemberProfileManager.GetProfileProperties(pid).Data.Properties };
                    }
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
Exemplo n.º 3
0
        public ActionResult UpdateProfileSettings(UpdateProfileSettingsRequest request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                int pid = request.PortalId ?? PortalSettings.PortalId;
                if (!UserInfo.IsSuperUser && PortalSettings.PortalId != pid)
                {
                    actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage);
                }

                if (actionResult.IsSuccess)
                {
                    if (Config.GetFriendlyUrlProvider() == "advanced")
                    {
                        PortalController.UpdatePortalSetting(pid, FriendlyUrlSettings.RedirectOldProfileUrlSetting, request.RedirectOldProfileUrl ? "Y" : "N", true);
                    }
                    PortalController.UpdatePortalSetting(pid, FriendlyUrlSettings.VanityUrlPrefixSetting, request.VanityUrlPrefix, false);
                    PortalController.UpdatePortalSetting(pid, "Profile_DefaultVisibility", request.ProfileDefaultVisibility.ToString(), false);
                    PortalController.UpdatePortalSetting(pid, "Profile_DisplayVisibility", request.ProfileDisplayVisibility.ToString(), false);

                    DataCache.ClearPortalCache(pid, false);
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
        protected void OnRemoveAllModulesClick(object sender, EventArgs e)
        {
            //Remove all Modules
            foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values)
            {
                DesktopModuleController.RemoveDesktopModuleFromPortal(_portalId, desktopModule.DesktopModuleID, false);
            }
            DataCache.ClearPortalCache(_portalId, false);

            BindDesktopModules();
        }
        protected void OnAddAllModulesClick(object sender, EventArgs e)
        {
            //Add all Modules
            foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values)
            {
                DesktopModuleController.AddDesktopModuleToPortal(_portalId, desktopModule.DesktopModuleID, true, false);
            }
            DataCache.ClearPortalCache(_portalId, false);

            BindDesktopModules();
        }
Exemplo n.º 6
0
        protected void ctlPortals_RemoveAllButtonClick(object sender, EventArgs e)
        {
            //Add all Portals
            foreach (PortalInfo objPortal in PortalController.Instance.GetPortals())
            {
                DesktopModuleController.RemoveDesktopModuleFromPortal(objPortal.PortalID, DesktopModule.DesktopModuleID, false);
            }
            DataCache.ClearHostCache(true);

            BindDesktopModule(false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// The Render method is called when the ASP.NET Page Framework
        /// determines that it is time to render content into the page output stream.
        /// This method and captures the output generated by the portal module user control
        /// It then adds this content into the ASP.NET Cache for future requests.
        /// </summary>
        /// <remarks>
        /// </remarks>
        protected override void Render(HtmlTextWriter output)
        {
            if (_moduleConfiguration != null)
            {
                // If no caching is specified or in admin mode, render the child tree and return
                if (_moduleConfiguration.CacheTime == 0 | PortalSecurity.HasEditPermissions(_moduleConfiguration.ModulePermissions))
                {
                    base.Render(output);
                }
                else //output caching enabled
                {
                    // If no cached output was found from a previous request, render
                    // child controls into a TextWriter, and then cache the results
                    if (_cachedOutput == "")
                    {
                        StringWriter tempWriter = new StringWriter();
                        base.Render(new HtmlTextWriter(tempWriter));
                        _cachedOutput = tempWriter.ToString();

                        if (CacheMethod != "D")
                        {
                            DataCache.SetCache(CacheKey, _cachedOutput, DateTime.Now.AddSeconds(_moduleConfiguration.CacheTime));
                        }
                        else // cache to disk
                        {
                            try
                            {
                                if (!Directory.Exists(CacheDirectory))
                                {
                                    Directory.CreateDirectory(CacheDirectory);
                                }

                                StreamWriter objStream;
                                objStream = File.CreateText(CacheFileName);
                                objStream.WriteLine(_cachedOutput);
                                objStream.Close();
                            }
                            catch
                            {
                                // error writing to disk
                            }
                        }
                    }

                    // Output the user control's content
                    output.Write(_cachedOutput);
                }
            }
            else
            {
                base.Render(output);
            }
        }
Exemplo n.º 8
0
        protected void ctlPortals_AddAllButtonClick(object sender, EventArgs e)
        {
            //Add all Portals
            var objPortals = new PortalController();

            foreach (PortalInfo objPortal in objPortals.GetPortals())
            {
                DesktopModuleController.AddDesktopModuleToPortal(objPortal.PortalID, DesktopModule.DesktopModuleID, true, false);
            }
            DataCache.ClearHostCache(true);

            BindDesktopModule(false);
        }
Exemplo n.º 9
0
        protected void ctlPortals_RemoveButtonClick(object sender, DualListBoxEventArgs e)
        {
            if (e.Items != null)
            {
                foreach (string portal in e.Items)
                {
                    DesktopModuleController.RemoveDesktopModuleFromPortal(int.Parse(portal), DesktopModule.DesktopModuleID, false);
                }
            }
            DataCache.ClearHostCache(true);

            BindDesktopModule(false);
        }
        protected void OnRemoveModuleClick(object sender, DualListBoxEventArgs e)
        {
            if (e.Items != null)
            {
                foreach (string desktopModule in e.Items)
                {
                    DesktopModuleController.RemoveDesktopModuleFromPortal(_portalId, int.Parse(desktopModule), false);
                }
            }
            DataCache.ClearPortalCache(_portalId, false);

            BindDesktopModules();
        }
Exemplo n.º 11
0
            public static ActionResult CreateUser(RegisterDetails RegisterDetails)
            {
                ActionResult actionResult = new ActionResult();

                User.Membership.Approved = PortalSettings.Current.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration;
                CreateStatus             = UserController.CreateUser(ref User);
                DataCache.ClearPortalUserCountCache(PortalSettings.Current.PortalId);

                try
                {
                    if (CreateStatus == UserCreateStatus.Success)
                    {
                        ////Assocate alternate Login with User and proceed with Login
                        //if (!String.IsNullOrEmpty(AuthenticationType))
                        //{
                        //    AuthenticationController.AddUserAuthentication(User.UserID, AuthenticationType, UserToken);
                        //}

                        ActionResult result = CompleteUserCreation(CreateStatus, User, true, !(HttpContext.Current.Request.IsAuthenticated && PortalSecurity.IsInRole(PortalSettings.Current.AdministratorRoleName)) && !(HttpContext.Current.Request.IsAuthenticated && (User.UserID == (PortalController.Instance.GetCurrentSettings() as PortalSettings).UserInfo.UserID)));
                        if (result.IsSuccess)
                        {
                            if (string.IsNullOrEmpty(result.Message))
                            {
                                IDictionary <string, object> dynObjects = new ExpandoObject() as IDictionary <string, object>;
                                dynObjects.Add("RedirectURL", GetRedirectUrl());
                                actionResult.Data = dynObjects;
                            }
                            actionResult.Message = result.Message;
                        }
                        else
                        {
                            string errorMessage = string.Empty;
                            foreach (KeyValuePair <string, Exception> error in result.Errors)
                            {
                                errorMessage = error.Value.ToString();
                            }
                            actionResult.AddError("RegisterManager.CompleteUserCreation", errorMessage);
                        }
                    }
                    else
                    {
                        actionResult.AddError("RegisterManager.CreateUser", UserController.GetUserCreateStatus(CreateStatus));
                    }
                }
                catch (Exception exc) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(null, exc);
                }
                return(actionResult);
            }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the properties
        /// </summary>
        /// <history>
        ///     [cnurse]	02/23/2006	created
        /// </history>
        private ProfilePropertyDefinitionCollection GetProperties()
        {
            string strKey = ProfileController.PROPERTIES_CACHEKEY + "." + UsersPortalId;

            if (m_objProperties == null)
            {
                m_objProperties = (ProfilePropertyDefinitionCollection)DataCache.GetCache(strKey);
                if (m_objProperties == null)
                {
                    m_objProperties = ProfileController.GetPropertyDefinitionsByPortal(UsersPortalId);
                    DataCache.SetCache(strKey, m_objProperties);
                }
            }
            return(m_objProperties);
        }
Exemplo n.º 13
0
 protected void cmdRestore_Click(object sender, EventArgs e)
 {
     if (chkPortal.Checked)
     {
         SkinController.SetSkin(SkinInfo.RootSkin, PortalId, SkinType.Portal, "");
         SkinController.SetSkin(SkinInfo.RootContainer, PortalId, SkinType.Portal, "");
     }
     if (chkAdmin.Checked)
     {
         SkinController.SetSkin(SkinInfo.RootSkin, PortalId, SkinType.Admin, "");
         SkinController.SetSkin(SkinInfo.RootContainer, PortalId, SkinType.Admin, "");
     }
     DataCache.ClearPortalCache(PortalId, true);
     Response.Redirect(Request.RawUrl);
 }
Exemplo n.º 14
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update Button is clicked
        /// </summary>
        /// <history>
        ///     [cnurse]	03/01/2006  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void cmdUpdate_Click(Object sender, EventArgs e)
        {
            if (IsUserOrAdmin == false)
            {
                return;
            }

            if (AddUser)
            {
                if (IsValid)
                {
                    CreateUser();
                    DataCache.ClearPortalCache(PortalId, true);
                }
            }
            else
            {
                if (userForm.IsValid && (User != null))
                {
                    if (User.UserID == PortalSettings.AdministratorId)
                    {
                        //Clear the Portal Cache
                        DataCache.ClearPortalCache(UserPortalID, true);
                    }
                    try
                    {
                        //Update DisplayName to conform to Format
                        UpdateDisplayName();
                        //either update the username or update the user details
                        if (CanUpdateUsername())
                        {
                            UserController.ChangeUsername(User.UserID, renameUserName.Value.ToString());
                        }

                        UserController.UpdateUser(UserPortalID, User);
                        OnUserUpdated(EventArgs.Empty);
                        OnUserUpdateCompleted(EventArgs.Empty);
                    }
                    catch (Exception exc)
                    {
                        Logger.Error(exc);

                        var args = new UserUpdateErrorArgs(User.UserID, User.Username, "EmailError");
                        OnUserUpdateError(args);
                    }
                }
            }
        }
        private ActionResult UpdateSslSettings(Entities.UpdateSslSettingsRequest request)
        {
            ActionResult ActionResult = new ActionResult();

            try
            {
                PortalSettings PortalSettings           = PortalController.Instance.GetCurrentSettings() as PortalSettings;
                bool           PreviousValue_SSLEnabled = PortalController.GetPortalSettingAsBoolean("SSLEnabled", PortalSettings.PortalId, false);
                PortalController.UpdatePortalSetting(PortalSettings.PortalId, "SSLEnabled", request.SSLEnabled.ToString(), false);
                PortalController.UpdatePortalSetting(PortalSettings.PortalId, "SSLEnforced", request.SSLEnforced.ToString(), false);
                PortalController.UpdatePortalSetting(PortalSettings.PortalId, "SSLURL", AddPortalAlias(request.SSLURL, PortalSettings.PortalId), false);
                PortalController.UpdatePortalSetting(PortalSettings.PortalId, "STDURL", AddPortalAlias(request.STDURL, PortalSettings.PortalId), false);
                if (UserInfo.IsSuperUser)
                {
                    HostController.Instance.Update("SSLOffloadHeader", request.SSLOffloadHeader);
                }

                if (PreviousValue_SSLEnabled != request.SSLEnabled)
                {
                    foreach (KeyValuePair <int, TabInfo> t in TabController.Instance.GetTabsByPortal(PortalSettings.Current.PortalId))
                    {
                        t.Value.IsSecure = request.SSLEnabled;
                        TabController.Instance.UpdateTab(t.Value);
                    }

                    if (PortalSettings.Current != null && PortalSettings.Current.ActiveTab != null && !string.IsNullOrEmpty(PortalSettings.Current.ActiveTab.FullUrl))
                    {
                        ActionResult.RedirectURL = PortalSettings.Current.ActiveTab.FullUrl;
                    }
                    else
                    {
                        ActionResult.RedirectURL = ServiceProvider.NavigationManager.NavigateURL();
                    }
                }
                DataCache.ClearPortalCache(PortalSettings.PortalId, false);
            }
            catch (Exception ex)
            {
                ActionResult.AddError("UpdateSslSettings", ex.Message);
            }
            return(ActionResult);
        }
Exemplo n.º 16
0
 public void SynchronizeModule()
 {
     if (CacheMethod != "D")
     {
         DataCache.RemoveCache(CacheKey);
     }
     else // disk caching
     {
         if (File.Exists(CacheFileName))
         {
             try
             {
                 File.Delete(CacheFileName);
             }
             catch
             {
                 // error deleting file from disk
             }
         }
     }
 }
Exemplo n.º 17
0
        public ActionResult UpdateProfilePropertyOrders(UpdateProfilePropertyOrdersRequest request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                if (request != null)
                {
                    int pid = request.PortalId ?? PortalSettings.PortalId;
                    if (!UserInfo.IsSuperUser && PortalSettings.PortalId != pid)
                    {
                        actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage);
                    }

                    if (actionResult.IsSuccess)
                    {
                        for (int i = 0; i <= request.Properties.Length - 1; i++)
                        {
                            var    profileProperty = ProfileController.GetPropertyDefinition(request.Properties[i].PropertyDefinitionId.Value, pid);
                            string ControlType     = Managers.MemberProfileManager.GetControlType(profileProperty.DataType);
                            if (profileProperty.PropertyValue == "-1" && (ControlType == "Country" || ControlType == "Region" || ControlType == "List"))
                            {
                                profileProperty.PropertyValue = "";
                            }
                            if (profileProperty.ViewOrder != request.Properties[i].ViewOrder)
                            {
                                profileProperty.ViewOrder = request.Properties[i].ViewOrder;
                                ProfileController.UpdatePropertyDefinition(profileProperty);
                            }
                        }
                        DataCache.ClearDefinitionsCache(pid);
                    }
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
Exemplo n.º 18
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   Deletes the localized file for a given locale
        /// </summary>
        /// <param name = "sender"></param>
        /// <param name = "e"></param>
        /// <remarks>
        ///   System Default file cannot be deleted
        /// </remarks>
        /// <history>
        ///   [vmasanas]	04/10/2004	Created
        ///   [vmasanas]	25/03/2006	Modified to support new host resources and incremental saving
        /// </history>
        /// -----------------------------------------------------------------------------
        private void cmdDelete_Click(Object sender, EventArgs e)
        {
            try
            {
                if (Locale == Localization.SystemLocale && rbMode.SelectedValue == "System")
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("Delete.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                }
                else
                {
                    try
                    {
                        if (File.Exists(ResourceFile(Locale, rbMode.SelectedValue)))
                        {
                            File.SetAttributes(ResourceFile(Locale, rbMode.SelectedValue), FileAttributes.Normal);
                            File.Delete(ResourceFile(Locale, rbMode.SelectedValue));
                            UI.Skins.Skin.AddModuleMessage(this,
                                                           string.Format(Localization.GetString("Deleted", LocalResourceFile), ResourceFile(Locale, rbMode.SelectedValue)),
                                                           ModuleMessage.ModuleMessageType.GreenSuccess);

                            BindGrid(true);

                            //Clear the resource file lookup dictionary as we have removed a file
                            DataCache.RemoveCache(DataCache.ResourceFileLookupDictionaryCacheKey);
                        }
                    }
                    catch
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("Save.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                    }
                }
                //Module failed to load
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 19
0
        public ActionResult UpdateListEntryOrders(UpdateListEntryOrdersRequest request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                int pid = request.PortalId ?? PortalSettings.PortalId;
                if (!UserInfo.IsSuperUser && PortalSettings.PortalId != pid)
                {
                    actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage);
                }

                if (actionResult.IsSuccess)
                {
                    ListController listController = new ListController();
                    for (int i = 0; i <= request.Entries.Length - 1; i++)
                    {
                        if (request.Entries[i].EntryId.HasValue)
                        {
                            ListEntryInfo entry = listController.GetListEntryInfo(request.Entries[i].EntryId.Value);
                            if (entry.SortOrder != request.Entries[i].SortOrder)
                            {
                                entry.SortOrder = request.Entries[i].SortOrder.Value;
                                Managers.MemberProfileManager.UpdateSortOrder(entry);
                                string cacheKey = string.Format(DataCache.ListEntriesCacheKey, pid, entry.ListName);
                                DataCache.RemoveCache(cacheKey);
                            }
                        }
                    }
                    DataCache.ClearListsCache(pid);
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
Exemplo n.º 20
0
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            if (ModuleContext.PortalSettings.ActiveTab.IsSuperTab)
            {
                UpdatePackage();
            }
            else
            {
                //Update DesktopModule Permissions
                DesktopModulePermissionCollection objCurrentPermissions = DesktopModulePermissionController.GetDesktopModulePermissions(dgPermissions.PortalDesktopModuleID);
                if (!objCurrentPermissions.CompareTo(dgPermissions.Permissions))
                {
                    DesktopModulePermissionController.DeleteDesktopModulePermissionsByPortalDesktopModuleID(dgPermissions.PortalDesktopModuleID);
                    foreach (DesktopModulePermissionInfo objPermission in dgPermissions.Permissions)
                    {
                        DesktopModulePermissionController.AddDesktopModulePermission(objPermission);
                    }
                }
                DataCache.RemoveCache(string.Format(DataCache.PortalDesktopModuleCacheKey, ModuleContext.PortalId));

                dgPermissions.ResetPermissions();
            }
        }
Exemplo n.º 21
0
        private void ManageFavicon()
        {
            string strFavicon = Convert.ToString(DataCache.GetCache("FAVICON" + PortalSettings.PortalId));

            if (strFavicon == "")
            {
                if (File.Exists(PortalSettings.HomeDirectoryMapPath + "favicon.ico"))
                {
                    strFavicon = PortalSettings.HomeDirectory + "favicon.ico";
                    if (Globals.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
                    {
                        DataCache.SetCache("FAVICON" + PortalSettings.PortalId, strFavicon);
                    }
                }
            }
            if (!String.IsNullOrEmpty(strFavicon))
            {
                HtmlLink objLink = new HtmlLink();
                objLink.Attributes["rel"]  = "SHORTCUT ICON";
                objLink.Attributes["href"] = strFavicon;

                Page.Header.Controls.Add(objLink);
            }
        }
Exemplo n.º 22
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update Button is clicked.
        /// </summary>
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            if (this.IsUserOrAdmin == false)
            {
                return;
            }

            if (this.AddUser)
            {
                if (this.IsValid)
                {
                    this.CreateUser();
                    DataCache.ClearPortalUserCountCache(this.PortalId);
                }
            }
            else
            {
                if (this.userForm.IsValid && (this.User != null))
                {
                    if (this.User.UserID == this.PortalSettings.AdministratorId)
                    {
                        // Clear the Portal Cache
                        DataCache.ClearPortalUserCountCache(this.UserPortalID);
                    }

                    try
                    {
                        // Update DisplayName to conform to Format
                        this.UpdateDisplayName();

                        // either update the username or update the user details
                        if (this.CanUpdateUsername() && !this.PortalSettings.Registration.UseEmailAsUserName)
                        {
                            UserController.ChangeUsername(this.User.UserID, this.renameUserName.Value.ToString());
                        }

                        // DNN-5874 Check if unique display name is required
                        if (this.PortalSettings.Registration.RequireUniqueDisplayName)
                        {
                            var usersWithSameDisplayName = (System.Collections.Generic.List <UserInfo>)MembershipProvider.Instance().GetUsersBasicSearch(this.PortalId, 0, 2, "DisplayName", true, "DisplayName", this.User.DisplayName);
                            if (usersWithSameDisplayName.Any(user => user.UserID != this.User.UserID))
                            {
                                UI.Skins.Skin.AddModuleMessage(this, this.LocalizeString("DisplayNameNotUnique"), UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
                                return;
                            }
                        }

                        UserController.UpdateUser(this.UserPortalID, this.User);

                        if (this.PortalSettings.Registration.UseEmailAsUserName && (this.User.Username.ToLower() != this.User.Email.ToLower()))
                        {
                            UserController.ChangeUsername(this.User.UserID, this.User.Email);
                        }

                        this.OnUserUpdated(EventArgs.Empty);
                        this.OnUserUpdateCompleted(EventArgs.Empty);
                    }
                    catch (Exception exc)
                    {
                        Logger.Error(exc);

                        var args = new UserUpdateErrorArgs(this.User.UserID, this.User.Username, "EmailError");
                        this.OnUserUpdateError(args);
                    }
                }
            }
        }
Exemplo n.º 23
0
        private void ManageStyleSheets(bool PortalCSS)
        {
            // initialize reference paths to load the cascading style sheets
            string id;

            Hashtable objCSSCache = (Hashtable)DataCache.GetCache("CSS");

            if (objCSSCache == null)
            {
                objCSSCache = new Hashtable();
            }

            if (PortalCSS == false)
            {
                // default style sheet ( required )
                id = Globals.CreateValidID(Globals.HostPath);
                AddStyleSheet(id, Globals.HostPath + "default.css");

                // skin package style sheet
                id = Globals.CreateValidID(PortalSettings.ActiveTab.SkinPath);
                if (objCSSCache.ContainsKey(id) == false)
                {
                    if (File.Exists(Server.MapPath(PortalSettings.ActiveTab.SkinPath) + "skin.css"))
                    {
                        objCSSCache[id] = PortalSettings.ActiveTab.SkinPath + "skin.css";
                    }
                    else
                    {
                        objCSSCache[id] = "";
                    }
                    if (Globals.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
                    {
                        DataCache.SetCache("CSS", objCSSCache);
                    }
                }
                if (objCSSCache[id].ToString() != "")
                {
                    AddStyleSheet(id, objCSSCache[id].ToString());
                }

                // skin file style sheet
                id = Globals.CreateValidID(PortalSettings.ActiveTab.SkinSrc.Replace(".ascx", ".css"));
                if (objCSSCache.ContainsKey(id) == false)
                {
                    if (File.Exists(Server.MapPath(PortalSettings.ActiveTab.SkinSrc.Replace(".ascx", ".css"))))
                    {
                        objCSSCache[id] = PortalSettings.ActiveTab.SkinSrc.Replace(".ascx", ".css");
                    }
                    else
                    {
                        objCSSCache[id] = "";
                    }
                    if (Globals.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
                    {
                        DataCache.SetCache("CSS", objCSSCache);
                    }
                }
                if (objCSSCache[id].ToString() != "")
                {
                    AddStyleSheet(id, objCSSCache[id].ToString());
                }
            }
            else
            {
                // portal style sheet
                id = Globals.CreateValidID(PortalSettings.HomeDirectory);
                AddStyleSheet(id, PortalSettings.HomeDirectory + "portal.css");
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update LinkButton is clicked.
        /// It saves the current Site Settings
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/9/2004	Modified
        ///     [aprasad]	1/17/2011	New setting AutoAddPortalAlias
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void UpdatePortal(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    var        objPortalController = new PortalController();
                    PortalInfo objPortal           = objPortalController.GetPortal(_portalId);

                    string strLogo       = String.Format("FileID={0}", ctlLogo.FileID);
                    string strBackground = String.Format("FileID={0}", ctlBackground.FileID);

                    //Refresh if Background or Logo file have changed
                    bool refreshPage = (strBackground == objPortal.BackgroundFile || strLogo == objPortal.LogoFile);

                    double dblHostFee = 0;
                    if (!String.IsNullOrEmpty(txtHostFee.Text))
                    {
                        dblHostFee = double.Parse(txtHostFee.Text);
                    }

                    double dblHostSpace = 0;
                    if (!String.IsNullOrEmpty(txtHostSpace.Text))
                    {
                        dblHostSpace = double.Parse(txtHostSpace.Text);
                    }

                    int intPageQuota = 0;
                    if (!String.IsNullOrEmpty(txtPageQuota.Text))
                    {
                        intPageQuota = int.Parse(txtPageQuota.Text);
                    }

                    double intUserQuota = 0;
                    if (!String.IsNullOrEmpty(txtUserQuota.Text))
                    {
                        intUserQuota = int.Parse(txtUserQuota.Text);
                    }

                    int intSiteLogHistory = 0;
                    if (!String.IsNullOrEmpty(txtSiteLogHistory.Text))
                    {
                        intSiteLogHistory = int.Parse(txtSiteLogHistory.Text);
                    }

                    DateTime datExpiryDate = Null.NullDate;
                    if (datepickerExpiryDate.SelectedDate.HasValue)
                    {
                        datExpiryDate = datepickerExpiryDate.SelectedDate.Value;
                    }

                    int intSplashTabId = Null.NullInteger;
                    if (cboSplashTabId.SelectedItem != null)
                    {
                        intSplashTabId = int.Parse(cboSplashTabId.SelectedItem.Value);
                    }

                    int intHomeTabId = Null.NullInteger;
                    if (cboHomeTabId.SelectedItem != null)
                    {
                        intHomeTabId = int.Parse(cboHomeTabId.SelectedItem.Value);
                    }

                    int intLoginTabId = Null.NullInteger;
                    if (cboLoginTabId.SelectedItem != null)
                    {
                        intLoginTabId = int.Parse(cboLoginTabId.SelectedItem.Value);
                    }
                    int intRegisterTabId = Null.NullInteger;
                    if (cboRegisterTabId.SelectedItem != null)
                    {
                        intRegisterTabId = int.Parse(cboRegisterTabId.SelectedItem.Value);
                    }

                    int intUserTabId = Null.NullInteger;
                    if (cboUserTabId.SelectedItem != null)
                    {
                        intUserTabId = int.Parse(cboUserTabId.SelectedItem.Value);
                    }

                    int intSearchTabId = Null.NullInteger;
                    if (cboSearchTabId.SelectedItem != null)
                    {
                        intSearchTabId = int.Parse(cboSearchTabId.SelectedItem.Value);
                    }

                    if (txtPassword.Attributes["value"] != null)
                    {
                        txtPassword.Attributes["value"] = txtPassword.Text;
                    }

                    //check only relevant fields altered
                    if (!UserInfo.IsSuperUser)
                    {
                        bool hostChanged = false;
                        if (dblHostFee != objPortal.HostFee)
                        {
                            hostChanged = true;
                        }

                        if (dblHostSpace != objPortal.HostSpace)
                        {
                            hostChanged = true;
                        }

                        if (intPageQuota != objPortal.PageQuota)
                        {
                            hostChanged = true;
                        }

                        if (intUserQuota != objPortal.UserQuota)
                        {
                            hostChanged = true;
                        }

                        if (intSiteLogHistory != objPortal.SiteLogHistory)
                        {
                            hostChanged = true;
                        }

                        if (datExpiryDate != objPortal.ExpiryDate)
                        {
                            hostChanged = true;
                        }

                        if (hostChanged)
                        {
                            throw new Exception();
                        }
                    }

                    objPortalController.UpdatePortalInfo(_portalId,
                                                         txtPortalName.Text,
                                                         strLogo,
                                                         txtFooterText.Text,
                                                         datExpiryDate,
                                                         optUserRegistration.SelectedIndex,
                                                         optBanners.SelectedIndex,
                                                         currencyCombo.SelectedItem.Value,
                                                         Convert.ToInt32(cboAdministratorId.SelectedItem.Value),
                                                         dblHostFee,
                                                         dblHostSpace,
                                                         intPageQuota,
                                                         (int)intUserQuota,
                                                         String.IsNullOrEmpty(processorCombo.SelectedValue) ? "" : processorCombo.SelectedItem.Text,
                                                         txtUserId.Text,
                                                         txtPassword.Text,
                                                         txtDescription.Text,
                                                         txtKeyWords.Text,
                                                         strBackground,
                                                         intSiteLogHistory,
                                                         intSplashTabId,
                                                         intHomeTabId,
                                                         intLoginTabId,
                                                         intRegisterTabId,
                                                         intUserTabId,
                                                         intSearchTabId,
                                                         objPortal.DefaultLanguage,
                                                         lblHomeDirectory.Text,
                                                         SelectedCultureCode);
                    if (!refreshPage)
                    {
                        refreshPage = (PortalSettings.DefaultAdminSkin == editSkinCombo.SelectedValue) ||
                                      (PortalSettings.DefaultAdminContainer == editContainerCombo.SelectedValue);
                    }
                    PortalController.UpdatePortalSetting(_portalId, "EnableSkinWidgets", chkSkinWidgestEnabled.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultAdminSkin", editSkinCombo.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultPortalSkin", portalSkinCombo.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultAdminContainer", editContainerCombo.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultPortalContainer", portalContainerCombo.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "EnablePopups", enablePopUpsCheckBox.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "InlineEditorEnabled", chkInlineEditor.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "HideFoldersEnabled", chkHideSystemFolders.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "ControlPanelMode", optControlPanelMode.SelectedItem.Value, false);
                    PortalController.UpdatePortalSetting(_portalId, "ControlPanelVisibility", optControlPanelVisibility.SelectedItem.Value, false);
                    PortalController.UpdatePortalSetting(_portalId, "ControlPanelSecurity", optControlPanelSecurity.SelectedItem.Value, false);

                    PortalController.UpdatePortalSetting(_portalId, "paypalsandbox", chkPayPalSandboxEnabled.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "paypalsubscriptionreturn", txtPayPalReturnURL.Text, false);
                    PortalController.UpdatePortalSetting(_portalId, "paypalsubscriptioncancelreturn", txtPayPalCancelURL.Text, false);
                    PortalController.UpdatePortalSetting(_portalId, "TimeZone", cboTimeZone.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "PortalAliasMapping", portalAliasModeButtonList.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultPortalAlias", defaultAliasDropDown.SelectedValue, false);
                    HostController.Instance.Update("AutoAddPortalAlias", chkAutoAddPortalAlias.Checked ? "Y" : "N", true);

                    new FavIcon(_portalId).Update(ctlFavIcon.FileID);

                    if (IsSuperUser())
                    {
                        PortalController.UpdatePortalSetting(_portalId, "SSLEnabled", chkSSLEnabled.Checked.ToString(), false);
                        PortalController.UpdatePortalSetting(_portalId, "SSLEnforced", chkSSLEnforced.Checked.ToString(), false);
                        PortalController.UpdatePortalSetting(_portalId, "SSLURL", AddPortalAlias(txtSSLURL.Text, _portalId), false);
                        PortalController.UpdatePortalSetting(_portalId, "STDURL", AddPortalAlias(txtSTDURL.Text, _portalId), false);
                    }

                    //Redirect to this site to refresh only if admin skin changed or either of the images have changed
                    if (refreshPage)
                    {
                        Response.Redirect(Request.RawUrl, true);
                    }
                    DataCache.ClearPortalCache(PortalId, false);
                    BindPortal(_portalId, SelectedCultureCode);
                }
                catch (Exception exc)
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
                finally
                {
                    DataCache.ClearPortalCache(_portalId, false);
                }
            }
        }
Exemplo n.º 25
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                if (Page.IsPostBack == false)
                {
                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));

                    LoadSkins();
                    LoadContainers();

                    if (Request.QueryString["action"] != null)
                    {
                        string strType = Request.QueryString["Type"];
                        string strRoot = Request.QueryString["Root"];
                        string strName = Request.QueryString["Name"];
                        string strSrc  = "[" + strType + "]" + strRoot + "/" + strName + "/" + Request.QueryString["Src"];

                        switch (Request.QueryString["action"])
                        {
                        case "apply":

                            if (strRoot == SkinInfo.RootSkin)
                            {
                                if (chkPortal.Checked)
                                {
                                    SkinController.SetSkin(SkinInfo.RootSkin, PortalId, SkinType.Portal, strSrc);
                                }
                                if (chkAdmin.Checked)
                                {
                                    SkinController.SetSkin(SkinInfo.RootSkin, PortalId, SkinType.Admin, strSrc);
                                }
                            }
                            if (strRoot == SkinInfo.RootContainer)
                            {
                                if (chkPortal.Checked)
                                {
                                    SkinController.SetSkin(SkinInfo.RootContainer, PortalId, SkinType.Portal, strSrc);
                                }
                                if (chkAdmin.Checked)
                                {
                                    SkinController.SetSkin(SkinInfo.RootContainer, PortalId, SkinType.Admin, strSrc);
                                }
                            }
                            DataCache.ClearPortalCache(PortalId, true);
                            Response.Redirect(Request.RawUrl.Replace("&action=apply", ""));
                            break;

                        case "delete":

                            File.Delete(Request.MapPath(SkinController.FormatSkinSrc(strSrc, PortalSettings)));
                            LoadSkins();
                            LoadContainers();
                            break;
                        }
                    }
                }

                if (PortalSettings.ActiveTab.IsSuperTab)
                {
                    typeRow.Visible = false;
                }
                else
                {
                    typeRow.Visible = true;
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Helper function that clears property cache
        /// </summary>
        /// <history>
        ///     [Jon Henning]	03/12/2006	created
        /// </history>
        private void ClearCachedProperties()
        {
            string strKey = ProfileController.PROPERTIES_CACHEKEY + "." + UsersPortalId;

            DataCache.RemoveCache(strKey);
        }
Exemplo n.º 27
0
        /// <summary>
        /// The CreateChildControls method is called when the ASP.NET Page Framework
        /// determines that it is time to instantiate a server control.
        /// This method and attempts to resolve any previously cached output of the portal
        /// module from the ASP.NET cache.
        /// If it doesn't find cached output from a previous request, then it will instantiate
        /// and add the portal modules UserControl instance into the page tree.
        /// </summary>
        /// <remarks>
        /// </remarks>
        protected override void CreateChildControls()
        {
            if (_moduleConfiguration != null)
            {
                // if user does not have EDIT rights for the module ( content editors can not see cached versions of modules )
                if (PortalSecurity.HasEditPermissions(_moduleConfiguration.ModulePermissions) == false)
                {
                    // Attempt to resolve previously cached content
                    if (_moduleConfiguration.CacheTime != 0)
                    {
                        if (CacheMethod != "D")
                        {
                            _cachedOutput = Convert.ToString(DataCache.GetCache(CacheKey));
                        }
                        else // cache from disk
                        {
                            if (File.Exists(CacheFileName))
                            {
                                FileInfo cacheFile = new FileInfo(CacheFileName);
                                if (cacheFile.CreationTime.AddSeconds(_moduleConfiguration.CacheTime) >= DateTime.Now)
                                {
                                    try
                                    {
                                        //Load from Cache
                                        StreamReader objStreamReader = cacheFile.OpenText();
                                        _cachedOutput = objStreamReader.ReadToEnd();
                                        objStreamReader.Close();
                                    }
                                    catch (Exception)
                                    {
                                        //locking error
                                        _cachedOutput = String.Empty;
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        //Cache Expired so delete it
                                        cacheFile.Delete();
                                    }
                                    catch (Exception)
                                    {
                                        //locking error
                                        _cachedOutput = String.Empty;
                                    }
                                }
                            }
                        }
                    }

                    // If no cached content is found, then instantiate and add the portal
                    // module user control into the portal's page server control tree
                    if (_cachedOutput == "" && _moduleConfiguration.CacheTime > 0)
                    {
                        base.CreateChildControls();

                        PortalModuleBase objPortalModuleBase = (PortalModuleBase)Page.LoadControl(_moduleConfiguration.ControlSrc);
                        objPortalModuleBase.ModuleConfiguration = this.ModuleConfiguration;

                        // set the control ID to the resource file name ( ie. controlname.ascx = controlname )
                        // this is necessary for the Localization in PageBase
                        objPortalModuleBase.ID = Path.GetFileNameWithoutExtension(_moduleConfiguration.ControlSrc);

                        // In skin.vb, the call to Me.Controls.Add(objPortalModuleBase) calls CreateChildControls() therefore
                        // we need to indicate the control has already been created. We will manipulate the CacheTime property for this purpose.
                        objPortalModuleBase.ModuleConfiguration.CacheTime = -(objPortalModuleBase.ModuleConfiguration.CacheTime);

                        this.Controls.Add(objPortalModuleBase);
                    }
                    else
                    {
                        // restore the CacheTime property in preparation for the Render() event
                        if (_moduleConfiguration.CacheTime < 0)
                        {
                            _moduleConfiguration.CacheTime = -(_moduleConfiguration.CacheTime);
                        }
                    }
                }
            }
        }
Exemplo n.º 28
0
        /// <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);
            }
        }