示例#1
0
        private int CreatePortal(out bool createdOk)
        {
            string fileName    = ddlXMLTemplates.Text;
            string portalAlias = AliasField.Text;
            string portalName  = TitleField.Text;
            string portalPath  = "/" + PathField.Text;
            IPortalTemplateRepository repository = new PortalTemplateRepository();
            IPortalTemplateServices   services   = PortalTemplateFactory.GetPortalTemplateServices(repository);
            int newPortalID = 1;

            createdOk = services.DeserializePortal(fileName, portalName, portalAlias, portalPath, PortalSettings.PortalFullPath, out newPortalID);
            if (createdOk && !Config.UseSingleUserBase)
            {
                string AdminEmail = "*****@*****.**";

                // Create the stradmin User for the new portal
                UsersDB User = new UsersDB();
                // Create the "Admins" role for the new portal
                Guid roleID = User.AddRole(portalAlias, "Admins");
                Guid userID = User.AddUser("admin", AdminEmail, "admin", portalAlias);
                // Create a new row in a many to many table (userroles)
                // giving the "admins" role to the stradmin user
                User.AddUserRole(roleID, userID, portalAlias);
                PortalsDB portals = new PortalsDB();

                portals.CreatePortalPath(portalPath);
            }
            return(newPortalID);
        }
        /// <summary>
        /// The AddUser_Click server event handler is used to add
        /// a new user to this security role.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddUser_Click(Object sender, EventArgs e)
        {
            int userID;

            if (((LinkButton)sender).ID == "addNew")
            {
                // add new user to users table
                UsersDB users = new UsersDB();
                if ((userID = users.AddUser(windowsUserName.Text, windowsUserName.Text, "acme", portalSettings.PortalID)) == -1)
                {
                    // Added EsperantusKeys for Localization
                    // Mario Endara [email protected] june-1-2004
                    Message.Text = Esperantus.Localize.GetString("ROLE_ERROR_ADD").Replace("%1%", windowsUserName.Text);
                }
            }
            else
            {
                //get user id from dropdownlist of existing users
                userID = Int32.Parse(allUsers.SelectedItem.Value);
            }

            if (userID != -1)
            {
                // Add a new userRole to the database
                UsersDB users = new UsersDB();
                users.AddUserRole(roleID, userID);
            }

            // Rebind list
            BindData();
        }
        //Регистрация пользователя и занесение данных в БД
        public void RegistrationOfUsers(object sender, EventArgs e)
        {
            DataValidation dv = new DataValidation();

            if (dv.CheckEmptyFields(textBox1.Text, textBox2.Text, textBox3.Text))
            {
                if (dv.CheckLenghtLogin(textBox1.Text))
                {
                    if (dv.CheckLenghtPassword(textBox2.Text))
                    {
                        if (dv.CheckPasswordMatch(textBox2.Text, textBox3.Text))
                        {
                            if (!UsersDB.CheckUserInDB(textBox1.Text))
                            {
                                UsersDB.AddUser(textBox1.Text, textBox2.Text);
                                MessageBox.Show("Регистрация прошла успешно");
                                form.Visible = true;
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Пользователь с таким логином уже существует. Введите другой логин", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Пароли не совпадают", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            textBox2.Clear();
                            textBox3.Clear();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Пароль содержит недоступное количество символов", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        textBox2.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("Логин содержит недоступное количество символов", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    textBox1.Clear();
                }
            }
            else
            {
                MessageBox.Show("Одно из полей пустое", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#4
0
        public IActionResult SignUp(AddUser newUser)
        {
            string result = "";

            switch (_usersDB.AddUser(newUser))
            {
            case UsersDB.RegisterError.NONE:
                return(LocalRedirect("~/Users/SignIn"));

            case UsersDB.RegisterError.LOGIN_EXISTS:
                result = "Такой логин уже существует";
                break;

            case UsersDB.RegisterError.OTHER:
                result = "Произошла ошибка";
                break;
            }

            ViewData["WasError"]  = true;
            ViewData["ErrorText"] = result;
            return(View());
        }
示例#5
0
        private int CreatePortal(int templateID, string templateAlias, string portalAlias, string portalName, string portalPath)
        {
            int newPortalID;

            PortalsDB portals = new PortalsDB();
            TabsDB    tabs    = new TabsDB();
            ModulesDB modules = new ModulesDB();
            UsersDB   users   = new UsersDB();

            // create an Array to stores modules ID and GUID for finding them later
            ArrayList      templateModules = new ArrayList();
            moduleTemplate module;
            // create an Array to stores tabs ID for finding them later
            ArrayList   templateTabs = new ArrayList();
            tabTemplate tab;

            // Create a new portal
            newPortalID = portals.AddPortal(portalAlias, portalName, portalPath);

            // Open the connection to the PortalTemplates Database
            SqlConnection myConnection    = GetConnection();
            SqlConnection my2ndConnection = GetConnection();
            SqlConnection my3rdConnection = GetConnection();

            myConnection.Open();
            my2ndConnection.Open();
            my3rdConnection.Open();

            // get module definitions and save them in the new portal
            SqlDataReader myReader = GetTemplateModuleDefinitions(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                module.id     = (int)myReader["ModuleDefID"];
                module.GuidID = GetGeneralModuleDefinitionByName(myReader["FriendlyName"].ToString(), my2ndConnection);
                try
                {
                    // save module definitions in the new portal
                    modules.UpdateModuleDefinitions(module.GuidID, newPortalID, true);
                    // Save the modules into a list for finding them later
                    templateModules.Add(module);
                }
                catch
                {
                    // tried to add a Module thas doesn´t exists in this implementation of the portal
                }
            }

            myReader.Close();

            if (!PortalSettings.UseSingleUserBase)
            {
                int roleID;
                int userID;
                int adminRoleID = 0;

                // get roles and save them in the new portal
                myReader = GetPortalRoles(templateID, myConnection);

                // Always call Read before accessing data.
                while (myReader.Read())
                {
                    roleID = users.AddRole(newPortalID, myReader["RoleName"].ToString());
                    if (myReader["RoleName"].ToString() == "Admins")
                    {
                        adminRoleID = roleID;
                    }
                }

                myReader.Close();

                // Create the "admin" User for the new portal
                string AdminEmail = "*****@*****.**";
                userID = users.AddUser("admin", AdminEmail, "admin", newPortalID);

                // Create a new row in a many to many table (userroles)
                // giving the "admins" role to the "admin" user
                users.AddUserRole(adminRoleID, userID);
            }

            // Get all the Tabs in the Template Portal, store IDs in a list for finding them later
            // and create the Tabs in the new Portal
            myReader = GetTabsByPortal(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                // Save the tabs into a list for finding them later
                tab.oldID = (int)myReader["TabID"];
                tab.newID = tabs.AddTab(newPortalID, myReader["TabName"].ToString(), Int32.Parse(myReader["TabOrder"].ToString()));
                templateTabs.Add(tab);
            }
            myReader.Close();

            // now I have to get them again to set up the ParentID for each Tab
            myReader = GetTabsByPortal(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                // Find the news TabID and ParentTabID
                System.Collections.IEnumerator myEnumerator = templateTabs.GetEnumerator();
                int newTabID       = -1;
                int newParentTabID = -1;

                while (myEnumerator.MoveNext() && (newTabID == -1 || newParentTabID == -1))
                {
                    tab = (tabTemplate)myEnumerator.Current;
                    if (tab.oldID == (int)myReader["TabID"])
                    {
                        newTabID = tab.newID;
                    }
                    if (tab.oldID == Int32.Parse("0" + myReader["ParentTabID"]))
                    {
                        newParentTabID = tab.newID;
                    }
                }

                if (newParentTabID == -1)
                {
                    newParentTabID = 0;
                }

                // Update the Tab in the new portal
                tabs.UpdateTab(newPortalID, newTabID, newParentTabID, myReader["TabName"].ToString(),
                               Int32.Parse(myReader["TabOrder"].ToString()), myReader["AuthorizedRoles"].ToString(),
                               myReader["MobileTabName"].ToString(), (bool)myReader["ShowMobile"]);

                // Finally use GetPortalSettings to access each Tab and its Modules in the Template Portal
                // and create them in the new Portal
                SqlDataReader result;

                try
                {
                    result = GetTabModules(Int32.Parse(myReader["TabID"].ToString()), my2ndConnection);

                    object myValue;

                    while (result.Read())
                    {
                        ModuleSettings m = new ModuleSettings();
                        m.ModuleID    = (int)result["ModuleID"];
                        m.ModuleDefID = (int)result["ModuleDefID"];
                        m.TabID       = newTabID;
                        m.PaneName    = (string)result["PaneName"];
                        m.ModuleTitle = (string)result["ModuleTitle"];

                        myValue = result["AuthorizedEditRoles"];
                        m.AuthorizedEditRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedViewRoles"];
                        m.AuthorizedViewRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedAddRoles"];
                        m.AuthorizedAddRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedDeleteRoles"];
                        m.AuthorizedDeleteRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedPropertiesRoles"];
                        m.AuthorizedPropertiesRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedMoveModuleRoles"];
                        m.AuthorizedMoveModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedDeleteModuleRoles"];
                        m.AuthorizedDeleteModuleRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue = result["AuthorizedPublishingRoles"];
                        m.AuthorizedPublishingRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue           = result["SupportWorkflow"];
                        m.SupportWorkflow = !Convert.IsDBNull(myValue) ? (bool)myValue : false;

                        myValue = result["AuthorizedApproveRoles"];
                        m.AuthorizedApproveRoles = !Convert.IsDBNull(myValue) ? (string)myValue : string.Empty;

                        myValue          = result["WorkflowState"];
                        m.WorkflowStatus = !Convert.IsDBNull(myValue) ? (WorkflowState)(0 + (byte)myValue) : WorkflowState.Original;

                        try { myValue = result["SupportCollapsable"]; }
                        catch { myValue = DBNull.Value; }
                        m.SupportCollapsable = DBNull.Value != myValue ? (bool)myValue : false;

                        try { myValue = result["ShowEveryWhere"]; }
                        catch { myValue = DBNull.Value; }
                        m.ShowEveryWhere = DBNull.Value != myValue ? (bool)myValue : false;

                        m.CacheTime   = int.Parse(result["CacheTime"].ToString());
                        m.ModuleOrder = int.Parse(result["ModuleOrder"].ToString());

                        myValue      = result["ShowMobile"];
                        m.ShowMobile = !Convert.IsDBNull(myValue) ? (bool)myValue : false;

                        // Find the new ModuleDefID assigned to the module in the new portal
                        myEnumerator = templateModules.GetEnumerator();
                        int newModuleDefID = 0;

                        while (myEnumerator.MoveNext() && newModuleDefID == 0)
                        {
                            module = (moduleTemplate)myEnumerator.Current;
                            if (module.id == m.ModuleDefID)
                            {
                                newModuleDefID = modules.GetModuleDefinitionByGuid(newPortalID, module.GuidID);
                            }
                        }

                        if (newModuleDefID > 0)
                        {
                            // add the module to the new tab
                            int newModuleID = modules.AddModule(newTabID, m.ModuleOrder, m.PaneName, m.ModuleTitle,
                                                                newModuleDefID, m.CacheTime, m.AuthorizedEditRoles, m.AuthorizedViewRoles,
                                                                m.AuthorizedAddRoles, m.AuthorizedDeleteRoles, m.AuthorizedPropertiesRoles,
                                                                m.AuthorizedMoveModuleRoles, m.AuthorizedDeleteModuleRoles,
                                                                m.ShowMobile, m.AuthorizedPublishingRoles, m.SupportWorkflow,
                                                                m.ShowEveryWhere, m.SupportCollapsable);
                            // At the end, get all ModuleSettings and save them in the new module
                            SqlDataReader dr = GetModuleSettings(m.ModuleID, my3rdConnection);

                            while (dr.Read())
                            {
                                ModuleSettings.UpdateModuleSetting(newModuleID, dr["SettingName"].ToString(), dr["SettingValue"].ToString());
                            }
                            dr.Close();
                        }
                    }

                    result.Close();
                }
                catch
                {
                    // Error? ignore Tab ...
                }
            }
            myReader.Close();

            // Set the CustomSettings of the New Portal based in the Template Portal
            myReader = GetPortalCustomSettings(templateID, myConnection);

            // Always call Read before accessing data.
            while (myReader.Read())
            {
                PortalSettings.UpdatePortalSetting(newPortalID, myReader["SettingName"].ToString(), myReader["SettingValue"].ToString());
            }

            myReader.Close();

            // close the conections
            myConnection.Close();
            myConnection.Dispose();
            my2ndConnection.Close();
            my2ndConnection.Dispose();
            my3rdConnection.Close();
            my3rdConnection.Dispose();

            // Create paths
            portals.CreatePortalPath(portalPath);

            return(newPortalID);
        }
示例#6
0
        /// <summary>
        /// The Page_Load server event handler on this page is used
        /// to populate the role information for the page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Verify that the current user has access to access this page
            // Removed by Mario Endara <*****@*****.**> (2004/11/04)
//			if (PortalSecurity.IsInRoles("Admins") == false)
//				PortalSecurity.AccessDeniedEdit();

            //Code no longer needed here, gman3001 10/06/2004

            /*string RegisterPage;
             *
             * //Select the actual register page
             * if (portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"] != null &&
             *              portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"].ToString() != "register.aspx" )
             *      RegisterPage = portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"].ToString();
             * else
             *      RegisterPage = "register.aspx";
             */

            // Calculate userid
            if (Request.Params["userid"] != null)
            {
                userID = Int32.Parse(Request.Params["userid"]);
            }
            if (Request.Params["username"] != null)
            {
                userName = (string)Request.Params["username"];
            }


            //Control myControl = this.LoadControl("../DesktopModules/Register/" + RegisterPage);
            //Control myControl = this.LoadControl(Rainbow.Settings.Path.WebPathCombine(Rainbow.Settings.Path.ApplicationRoot, "DesktopModules/Register", RegisterPage));
            // Line Added by gman3001 10/06/2004, to support proper loading of a register module specified by 'Register Module ID' setting in the Portal Settings admin page
            Control myControl = GetCurrentProfileControl();

            EditControl = ((IEditUserProfile)myControl);
            //EditControl.RedirectPage = HttpUrlBuilder.BuildUrl("~/Admin/UsersManage.aspx", TabID, "username="******"New User created " + DateTime.Now.ToString();
                            userName = "******" + i.ToString() + "@yoursite.com";
                            try
                            {
                                uid = users.AddUser(friendlyName, userName, string.Empty, portalSettings.PortalID);
                            }
                            catch (Exception ex)
                            {
                                uid           = -1;
                                lastException = ex;
                            }
                            i++;
                        }
                        if (uid == -1)
                        {
                            throw new Exception("New user creation failed after " + i.ToString() + " retries.", lastException);
                        }

                        // redirect to this page with the corrected querystring args
                        Response.Redirect(HttpUrlBuilder.BuildUrl("~/DesktopModules/Users/UsersManage.aspx", TabID, "mID=" + ModuleID + "&userID=" + uid + "&username="******"Error creating new user", ex);
                        ErrorLabel.Text    = ex.Message;
                        ErrorLabel.Visible = true;
                    }
                }

                BindData();
            }
        }
示例#7
0
        /// <summary>
        /// Save user data
        /// </summary>
        /// <returns></returns>
        public Guid SaveUserData()
        {
            Guid returnID = Guid.Empty;

            //if (PasswordField.Text.Length > 0 || ConfirmPasswordField.Text.Length > 0)
            //{
            //    if (PasswordField.Text != ConfirmPasswordField.Text)
            //        ComparePasswords.IsValid = false;
            //}

            // Only attempt a login if all form fields on the page are valid
            if (Page.IsValid)
            {
                UsersDB accountSystem = new UsersDB();

                string CountryID = string.Empty;
                if (CountryField.SelectedItem != null)
                {
                    CountryID = CountryField.SelectedItem.Value;
                }

                int StateID = 0;
                if (StateField.SelectedItem != null)
                {
                    StateID = Convert.ToInt32(StateField.SelectedItem.Value);
                }

                try {
                    if (userName == string.Empty)
                    {
                        // Add New User to Portal User Database
                        returnID =
                            accountSystem.AddUser(NameField.Text, CompanyField.Text,
                                                  AddressField.Text, CityField.Text, ZipField.Text, CountryID, StateID,
                                                  PhoneField.Text, FaxField.Text,
                                                  PasswordField.Text, EmailField.Text, SendNewsletter.Checked);
                    }
                    else
                    {
                        // Update user
                        if (PasswordField.Text.Equals(string.Empty))
                        {
                            accountSystem.UpdateUser(originalUserID, NameField.Text, CompanyField.Text, AddressField.Text,
                                                     CityField.Text, ZipField.Text, CountryID, StateID, PhoneField.Text, FaxField.Text, EmailField.Text, SendNewsletter.Checked);
                        }
                        else
                        {
                            accountSystem.UpdateUser(originalUserID, NameField.Text, CompanyField.Text, AddressField.Text,
                                                     CityField.Text, ZipField.Text, CountryID, StateID, PhoneField.Text, PasswordField.Text,
                                                     FaxField.Text, EmailField.Text, SendNewsletter.Checked);
                        }
                    }
                    //If we are here no error occurred
                }
                catch (Exception ex) {
                    Message.Text = General.GetString("REGISTRATION_FAILED", "Registration failed", Message) + " - ";

                    ErrorHandler.Publish(LogLevel.Error, "Error registering user", ex);
                }
            }
            return(returnID);
        }
示例#8
0
        public int CreatePortal(int solutionId, string portalAlias, string portalName, string portalPath)
        {
            var tabs    = new PagesDB();
            var modules = new ModulesDB();

            // Create a new portal
            var portalId = this.AddPortal(portalAlias, portalName, portalPath);

            // get module definitions
            foreach (var solutionModuleDefinition in modules.GetSolutionModuleDefinitions(solutionId))
            {
                modules.UpdateModuleDefinitions(solutionModuleDefinition.GeneralModuleDefinitionId, portalId, true);
            }

            if (!Config.UseSingleUserBase)
            {
                const string AdminEmail = "*****@*****.**";

                // Create the stradmin User for the new portal
                var user = new UsersDB();

                // Create the "Admins" role for the new portal
                var roleId = user.AddRole(portalAlias, "Admins");
                var userId = user.AddUser(StringsAdmin, AdminEmail, StringsAdmin, portalAlias);

                // Create the "Admins" profile for the new portal
                var profile = ProfileBase.Create(AdminEmail);
                profile.SetPropertyValue("Email", AdminEmail);
                profile.SetPropertyValue("Name", "admin");
                try {
                    profile.Save();
                } catch  {
                }

                // Create a new row in a many to many table (userroles)
                // giving the "admins" role to the stradmin user
                user.AddUserRole(roleId, userId, portalAlias);
            }

            // Create a new Page "home"
            var homePageId = tabs.AddPage(portalId, "Home", 1);

            // Create a new Page "admin"
            var localizedString = General.GetString("ADMIN_TAB_NAME");
            var adminPageId     = tabs.AddPage(portalId, localizedString, StrAdmins, 9999);

            // Add Modules for portal use
            // Html Document
            modules.UpdateModuleDefinitions(new Guid(StrGuidhtmlDocument), portalId, true);

            // Add Modules for portal administration
            // Site Settings (Admin)
            localizedString = General.GetString("MODULE_SITE_SETTINGS");
            modules.UpdateModuleDefinitions(new Guid(StrGuidSiteSettings), portalId, true);
            modules.AddModule(
                adminPageId,
                1,
                StrContentPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidSiteSettings)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Pages (Admin)
            localizedString = General.GetString("MODULE_TABS");
            modules.UpdateModuleDefinitions(new Guid(StrGuidPages), portalId, true);
            modules.AddModule(
                adminPageId,
                2,
                StrContentPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidPages)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Roles (Admin)
            localizedString = General.GetString("MODULE_SECURITY_ROLES");
            modules.UpdateModuleDefinitions(new Guid(StrGuidSecurityRoles), portalId, true);
            modules.AddModule(
                adminPageId,
                3,
                StrContentPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidSecurityRoles)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Manage Users (Admin)
            localizedString = General.GetString("MODULE_MANAGE_USERS");
            modules.UpdateModuleDefinitions(new Guid(StrGuidManageUsers), portalId, true);
            modules.AddModule(
                adminPageId,
                4,
                StrContentPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidManageUsers)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Module Definitions (Admin)
            localizedString = General.GetString("MODULE_MODULES");
            modules.UpdateModuleDefinitions(new Guid(StrGuidModules), portalId, true);
            modules.AddModule(
                adminPageId,
                1,
                StringsRightPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidModules)),
                0,
                StrAdmins,
                StrAllUsers,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // End Change [email protected]
            // Change by [email protected]
            // Add Signin Module and put it on the hometab
            // Signin
            localizedString = General.GetString("MODULE_LOGIN", "Login");
            modules.UpdateModuleDefinitions(new Guid(StrGuidLogin), portalId, true);
            modules.AddModule(
                homePageId,
                -1,
                StrLeftPane,
                localizedString,
                modules.GetModuleDefinitionByGuid(portalId, new Guid(StrGuidLogin)),
                0,
                StrAdmins,
                "Unauthenticated Users;Admins;",
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                StrAdmins,
                false,
                string.Empty,
                false,
                false,
                false);

            // Add language switcher to available modules
            // Language Switcher
            modules.UpdateModuleDefinitions(new Guid(StrGuidLanguageSwitcher), portalId, true);

            // End of change by [email protected]
            // Create paths
            this.CreatePortalPath(portalPath);
            return(portalId);
        }
示例#9
0
        /// <summary>
        /// Save user data
        /// </summary>
        /// <returns></returns>
        public Guid SaveUserData()
        {
            Guid returnID = Guid.Empty;

            if (PasswordField.Text.Length > 0 || ConfirmPasswordField.Text.Length > 0)
            {
                if (PasswordField.Text != ConfirmPasswordField.Text)
                {
                    ComparePasswords.IsValid = false;
                }
            }

            // Only attempt a login if all form fields on the page are valid
            if (Page.IsValid)
            {
                UsersDB accountSystem = new UsersDB();

                string CountryID = string.Empty;
                if (CountryField.SelectedItem != null)
                {
                    CountryID = CountryField.SelectedItem.Value;
                }

                int StateID = 0;
                if (StateField.SelectedItem != null)
                {
                    StateID = Convert.ToInt32(StateField.SelectedItem.Value);
                }

                try {
                    if (userName == string.Empty)
                    {
                        // Add New User to Portal User Database
                        returnID =
                            accountSystem.AddUser(NameField.Text, CompanyField.Text,
                                                  AddressField.Text, CityField.Text, ZipField.Text, CountryID, StateID,
                                                  PhoneField.Text, FaxField.Text,
                                                  PasswordField.Text, EmailField.Text, SendNewsletter.Checked);
                    }
                    else
                    {
                        // Update user
                        if (PasswordField.Text.Equals(ConfirmPasswordField.Text) && PasswordField.Text.Equals(string.Empty))
                        {
                            accountSystem.UpdateUser(originalUserID, NameField.Text, CompanyField.Text, AddressField.Text,
                                                     CityField.Text, ZipField.Text, CountryID, StateID, PhoneField.Text,
                                                     FaxField.Text, EmailField.Text, SendNewsletter.Checked);
                        }
                        else
                        {
                            accountSystem.UpdateUser(originalUserID, NameField.Text, CompanyField.Text, AddressField.Text,
                                                     CityField.Text, ZipField.Text, CountryID, StateID, PhoneField.Text, FaxField.Text,
                                                     PasswordField.Text, EmailField.Text, SendNewsletter.Checked);
                        }
                        //If we are here no error occurred
                    }
                }
                catch (Exception ex) {
                    Message.Text = General.GetString("REGISTRATION_FAILED", "Registration failed", Message) + " - ";

                    if (ex is SqlException)
                    {
                        if (((( SqlException )ex).Number == 2627))
                        {
                            Message.Text =
                                General.GetString("REGISTRATION_FAILED_EXISTING_EMAIL_ADDRESS",
                                                  "Registration has failed. This email address has already been registered. Please use a different email address or use the 'Send Password' button on the login page.",
                                                  Message);
                        }
                    }

                    ErrorHandler.Publish(LogLevel.Error, "Error registering user", ex);
                }
            }
            return(returnID);
        }
示例#10
0
        public int CreatePortal(int solutionID, string portalAlias, string portalName, string portalPath)
        {
            int       portalID;
            PagesDB   tabs    = new PagesDB();
            ModulesDB modules = new ModulesDB();

            // Create a new portal
            portalID = AddPortal(portalAlias, portalName, portalPath);
            // get module definitions
            SqlDataReader myReader;

            myReader = modules.GetSolutionModuleDefinitions(solutionID);

            // Always call Read before accessing data.
            try
            {
                while (myReader.Read())
                {
                    modules.UpdateModuleDefinitions(new Guid(myReader["GeneralModDefID"].ToString()), portalID, true);
                }
            }

            finally
            {
                myReader.Close(); //by Manu, fixed bug 807858
            }

            if (!Config.UseSingleUserBase)
            {
                string AdminEmail = "*****@*****.**";

                // Create the stradmin User for the new portal
                UsersDB User = new UsersDB();
                // Create the "Admins" role for the new portal
                Guid roleID = User.AddRole("Admins");
                Guid userID = User.AddUser(stradmin, AdminEmail, stradmin);
                // Create a new row in a many to many table (userroles)
                // giving the "admins" role to the stradmin user
                User.AddUserRole(roleID, userID);
            }
            // Create a new Page "home"
            int homePageID = tabs.AddPage(portalID, "Home", 1);
            // Create a new Page "admin"
            string localizedString = General.GetString("ADMIN_TAB_NAME");
            int    adminPageID     = tabs.AddPage(portalID, localizedString, strAdmins, 9999);

            // Add Modules for portal use
            // Html Document
            modules.UpdateModuleDefinitions(new Guid(strGUIDHTMLDocument), portalID, true);
            // Add Modules for portal administration
            // Site Settings (Admin)
            localizedString = General.GetString("MODULE_SITE_SETTINGS");
            modules.UpdateModuleDefinitions(new Guid(strGUIDSiteSettings), portalID, true);
            modules.AddModule(adminPageID, 1, strContentPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDSiteSettings)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // Pages (Admin)
            localizedString = General.GetString("MODULE_TABS");
            modules.UpdateModuleDefinitions(new Guid(strGUIDPages), portalID, true);
            modules.AddModule(adminPageID, 2, strContentPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDPages)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // Roles (Admin)
            localizedString = General.GetString("MODULE_SECURITY_ROLES");
            modules.UpdateModuleDefinitions(new Guid(strGUIDSecurityRoles), portalID, true);
            modules.AddModule(adminPageID, 3, strContentPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDSecurityRoles)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // Manage Users (Admin)
            localizedString = General.GetString("MODULE_MANAGE_USERS");
            modules.UpdateModuleDefinitions(new Guid(strGUIDManageUsers), portalID, true);
            modules.AddModule(adminPageID, 4, strContentPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDManageUsers)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // Module Definitions (Admin)
            localizedString = General.GetString("MODULE_MODULES");
            modules.UpdateModuleDefinitions(new Guid(strGUIDModules), portalID, true);
            modules.AddModule(adminPageID, 1, strRightPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDModules)), 0, strAdmins,
                              strAllUsers, strAdmins, strAdmins, strAdmins, strAdmins, strAdmins, false, string.Empty,
                              false, false, false);
            // End Change [email protected]
            // Change by [email protected]
            // Add Signin Module and put it on the hometab
            // Signin
            localizedString = General.GetString("MODULE_LOGIN", "Login");
            modules.UpdateModuleDefinitions(new Guid(strGUIDLogin), portalID, true);
            modules.AddModule(homePageID, -1, strLeftPane, localizedString,
                              modules.GetModuleDefinitionByGuid(portalID, new Guid(strGUIDLogin)), 0, strAdmins,
                              "Unauthenticated Users;Admins;", strAdmins, strAdmins, strAdmins, strAdmins, strAdmins,
                              false, string.Empty, false, false, false);
            // Add language switcher to available modules
            // Language Switcher
            modules.UpdateModuleDefinitions(new Guid(strGUIDLanguageSwitcher), portalID, true);
            // End of change by [email protected]
            // Create paths
            CreatePortalPath(portalPath);
            return(portalID);
        }
示例#11
0
        /// <summary>
        /// Save user data
        /// </summary>
        /// <returns>
        /// The user id
        /// </returns>
        public Guid SaveUserData()
        {
            var returnId = Guid.Empty;

            if (this.PasswordField.Text.Length > 0 || this.ConfirmPasswordField.Text.Length > 0)
            {
                if (this.PasswordField.Text != this.ConfirmPasswordField.Text)
                {
                    this.ComparePasswords.IsValid = false;
                }
            }

            // Only attempt a login if all form fields on the page are valid
            if (this.Page.IsValid)
            {
                var accountSystem = new UsersDB();

                var countryId = string.Empty;
                if (this.CountryField.SelectedItem != null)
                {
                    countryId = this.CountryField.SelectedItem.Value;
                }

                var stateId = 0;
                if (this.StateField.SelectedItem != null)
                {
                    stateId = Convert.ToInt32(this.StateField.SelectedItem.Value);
                }

                try
                {
                    if (this.UserName == string.Empty)
                    {
                        // Add New User to Portal User Database
                        returnId = accountSystem.AddUser(
                            this.NameField.Text,
                            this.CompanyField.Text,
                            this.AddressField.Text,
                            this.CityField.Text,
                            this.ZipField.Text,
                            countryId,
                            stateId,
                            this.PhoneField.Text,
                            this.FaxField.Text,
                            this.PasswordField.Text,
                            this.EmailField.Text,
                            this.SendNewsletter.Checked,
                            CurrentPortalSettings.PortalAlias);
                    }
                    else
                    {
                        // Update user
                        if (this.PasswordField.Text.Equals(this.ConfirmPasswordField.Text) &&
                            this.PasswordField.Text.Equals(string.Empty))
                        {
                            accountSystem.UpdateUser(
                                this.OriginalUserId,
                                this.NameField.Text,
                                this.CompanyField.Text,
                                this.AddressField.Text,
                                this.CityField.Text,
                                this.ZipField.Text,
                                countryId,
                                stateId,
                                this.PhoneField.Text,
                                this.FaxField.Text,
                                this.EmailField.Text,
                                this.SendNewsletter.Checked);
                        }
                        else
                        {
                            accountSystem.UpdateUser(
                                this.OriginalUserId,
                                this.NameField.Text,
                                this.CompanyField.Text,
                                this.AddressField.Text,
                                this.CityField.Text,
                                this.ZipField.Text,
                                countryId,
                                stateId,
                                this.PhoneField.Text,
                                this.FaxField.Text,
                                this.PasswordField.Text,
                                this.EmailField.Text,
                                this.SendNewsletter.Checked,
                                this.PortalSettings.PortalAlias);
                        }

                        // If we are here no error occurred
                    }
                }
                catch (Exception ex)
                {
                    this.Message.Text = General.GetString("REGISTRATION_FAILED", "Registration failed", this.Message) +
                                        " - ";

                    if (ex is SqlException)
                    {
                        if (((SqlException)ex).Number == 2627)
                        {
                            this.Message.Text = General.GetString(
                                "REGISTRATION_FAILED_EXISTING_EMAIL_ADDRESS",
                                "Registration has failed. This email address has already been registered. Please use a different email address or use the 'Send Password' button on the login page.",
                                this.Message);
                        }
                    }

                    ErrorHandler.Publish(LogLevel.Error, "Error registering user", ex);
                }
            }

            return(returnId);
        }
示例#12
0
        public int SaveUserData()
        {
            int returnID = 0;

            if (PasswordField.Text.Length > 0 || ConfirmPasswordField.Text.Length > 0)
            {
                if (PasswordField.Text != ConfirmPasswordField.Text)
                {
                    ComparePasswords.IsValid = false;
                }
            }

            // Only attempt a login if all form fields on the page are valid
            if (Page.IsValid == true)
            {
                UsersDB accountSystem = new UsersDB();

                string CountryID = string.Empty;
                if (CountryField.SelectedItem != null)
                {
                    CountryID = CountryField.SelectedItem.Value;
                }

                int StateID = 0;
                if (StateField.SelectedItem != null)
                {
                    StateID = Convert.ToInt32(StateField.SelectedItem.Value);
                }

                try
                {
                    if (userName == string.Empty)
                    {
                        // Add New User to Portal User Database
                        returnID = accountSystem.AddUser(portalSettings.PortalID, NameField.Text, CompanyField.Text, AddressField.Text, CityField.Text, ZipField.Text, CountryID, StateID, PIvaField.Text, CFiscaleField.Text, PhoneField.Text, FaxField.Text, PasswordField.Text, EmailField.Text, SendNewsletter.Checked);
                    }
                    else
                    {
                        // Update user
                        if (allowEditUserID && Int32.Parse(UseridField.Text) > 0)
                        {
                            //If allow id
                            int currentUserID = Int32.Parse(UseridField.Text);
                            accountSystem.UpdateUser(originalUserID, currentUserID, portalSettings.PortalID, NameField.Text, CompanyField.Text, AddressField.Text, CityField.Text, ZipField.Text, CountryID, StateID, PIvaField.Text, CFiscaleField.Text, PhoneField.Text, FaxField.Text, PasswordField.Text, EmailField.Text, SendNewsletter.Checked);
                        }
                        else
                        {
                            //Update user throws any error occurs
                            accountSystem.UpdateUser(originalUserID, portalSettings.PortalID, NameField.Text, CompanyField.Text, AddressField.Text, CityField.Text, ZipField.Text, CountryID, StateID, PIvaField.Text, CFiscaleField.Text, PhoneField.Text, FaxField.Text, PasswordField.Text, EmailField.Text, SendNewsletter.Checked);
                        }
                        //If we are here no error occurred
                        returnID = 1;
                    }
                }
                catch (Exception ex)
                {
                    Message.Text = Esperantus.Localize.GetString("REGISTRATION_FAILED", "Registration failed", Message);

                    if (ex is SqlException)
                    {
                        if ((((SqlException)ex).Number == 2627))
                        {
                            Message.Text = Esperantus.Localize.GetString("REGISTRATION_FAILED_EXISTING_EMAIL_ADDRESS", "Registration has failed. This email address has already been registered. Please use a different email address or use the 'Send Password' button on the login page.", Message);
                        }
                    }

                    Rainbow.Configuration.ErrorHandler.HandleException("Error registering user", ex);
                }
            }
            return(returnID);
        }