/// <summary>
        /// The AddUser_Click server event handler is used to add
        /// a new user to this security role.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void AddUser_Click(Object sender, EventArgs e)
        {
            //get user id from dropdownlist of existing users
            Guid userID = new Guid(allUsers.SelectedItem.Value);

            if (!userID.Equals(Guid.Empty))
            {
                // Add a new userRole to the database
                UsersDB users = new UsersDB();
                users.AddUserRole(roleId, userID, this.PortalSettings.PortalAlias);
            }

            // Rebind list
            BindData();
        }
Пример #2
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;
        }
Пример #3
0
        /// <summary>
        /// The AddRole_Click server event handler is used to add
        /// the user to this security role.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void AddRole_Click(Object sender, EventArgs e)
        {
            Guid roleID;

            //get user id from dropdownlist of existing users
            roleID = new Guid(allRoles.SelectedItem.Value);

            // Add a new userRole to the database
            UsersDB users = new UsersDB();

            users.AddUserRole(roleID, userID, this.PortalSettings.PortalAlias);

            // Rebind list
            BindData();
        }
Пример #4
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 (Exception exc) {

                }

                // 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;
        }