Ejemplo n.º 1
0
        protected void AddModuleToPane_Click(object sender, EventArgs e)
        {
            // All new modules go to the end of the content pane
            var m = new ModuleItem();

            m.Title       = this.moduleTitle.Text;
            m.ModuleDefID = Int32.Parse(this.moduleType.SelectedItem.Value);
            m.Order       = 999;

            // save to database
            var mod = new ModulesDB();

            // Change by [email protected]
            // Date: 6/2/2003
            // Original:             m.ID = _mod.AddModule(tabID, m.Order, "ContentPane", m.Title, m.ModuleDefID, 0, "Admins", "All Users", "Admins", "Admins", "Admins", false);
            // Changed by Mario Endara <*****@*****.**> (2004/11/09)
            // The new module inherits security from Pages module (current ModuleID)
            // so who can edit the tab properties/content can edit the module properties/content (except view that remains =)
            m.ID = mod.AddModule(
                this.PageID,
                m.Order,
                this.paneLocation.SelectedItem.Value,
                m.Title,
                m.ModuleDefID,
                0,
                PortalSecurity.GetEditPermissions(this.ModuleID),
                this.viewPermissions.SelectedItem.Value,
                PortalSecurity.GetAddPermissions(this.ModuleID),
                PortalSecurity.GetDeletePermissions(this.ModuleID),
                PortalSecurity.GetPropertiesPermissions(this.ModuleID),
                PortalSecurity.GetMoveModulePermissions(this.ModuleID),
                PortalSecurity.GetDeleteModulePermissions(this.ModuleID),
                false,
                PortalSecurity.GetPublishPermissions(this.ModuleID),
                false,
                false,
                false);

            // End Change [email protected]

            // reload the portalSettings from the database
            this.Context.Items["PortalSettings"] = PortalSettings.GetPortalSettings(this.PageID, this.PortalSettings.PortalAlias);
            this.PortalSettings = (PortalSettings)this.Context.Items["PortalSettings"];

            // reorder the modules in the content pane
            var modules = this.GetModules("ContentPane");

            this.OrderModules(modules);

            // resave the order
            foreach (ModuleItem item in modules)
            {
                mod.UpdateModuleOrder(item.ID, item.Order, "ContentPane");
            }

            // Redirect to the same page to pick up changes
            this.Response.Redirect(this.AppendModuleID(this.Request.RawUrl, m.ID));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The AddModule_Click server event handler
        /// on this page is used to add a new portal module
        /// into the tab
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddModule_Click(Object sender, EventArgs e)
        {
            if (this.TabID != 0)
            {
                // All new modules go to the end of the contentpane
                string selectedModule = moduleType.SelectedItem.Value.ToString();
                int    start          = selectedModule.IndexOf("|");
                int    moduleID       = Convert.ToInt32(selectedModule.Substring(0, start).Trim());

                // Hide error message in case there was a previous error.
                moduleError.Visible = false;

                // This allows the user to pick what type of people can view the module being added.
                // If Authorised Roles is selected from the dropdown then every role that has view permission for the
                // Add Role module will be added to the view permissions of the module being added.
                string viewPermissionRoles = viewPermissions.SelectedValue.ToString();
                if (viewPermissionRoles == "Authorised Roles")
                {
                    viewPermissionRoles = Rainbow.Security.PortalSecurity.GetViewPermissions(this.ModuleID);
                }

                try
                {
                    ModuleItem m = new ModuleItem();
                    m.Title       = moduleTitle.Text;
                    m.ModuleDefID = moduleID;
                    m.Order       = 999;

                    // save to database
                    ModulesDB _mod = new ModulesDB();
                    m.ID = _mod.AddModule(TabID, m.Order, paneLocation.SelectedValue.ToString(), m.Title, m.ModuleDefID, 0, Rainbow.Security.PortalSecurity.GetEditPermissions(this.ModuleID), viewPermissionRoles, Rainbow.Security.PortalSecurity.GetAddPermissions(this.ModuleID), Rainbow.Security.PortalSecurity.GetDeletePermissions(this.ModuleID), Rainbow.Security.PortalSecurity.GetPropertiesPermissions(this.ModuleID), Rainbow.Security.PortalSecurity.GetMoveModulePermissions(this.ModuleID), Rainbow.Security.PortalSecurity.GetDeleteModulePermissions(this.ModuleID), false, Rainbow.Security.PortalSecurity.GetPublishPermissions(this.ModuleID), false, false, false);
                }
                catch (Exception ex)
                {
                    moduleError.Visible = true;
                    Rainbow.Configuration.ErrorHandler.HandleException("There was an error with the Add Module Module while trying to add a new module.", ex);
                }
                finally
                {
                    if (moduleError.Visible == false)
                    {
                        // Reload page to pick up changes
                        Response.Redirect(Request.RawUrl, false);
                    }
                }
            }
            else
            {
                moduleError.TextKey = "ADDMODULE_HOMEPAGEERROR";
                moduleError.Text    = "You are currently on the homepage using the default virtual ID (The default ID is set when no specific page is selected. e.g. www.yourdomain.com. Please select your homepage from the Navigation menu e.g. 'Home' so that you can add a module against the page's actual ID.";
                moduleError.Visible = true;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleDefId"></param>
        /// <param name="pageId"></param>
        /// <param name="title"></param>
        /// <param name="alsoIfExists"></param>
        /// <returns></returns>
        public static int AddModuleToPage(int moduleDefId, int pageId, string title, bool alsoIfExists)
        {
            var module = default(rb_Modules);

            using (var context = new AppleseedDBContext()) {
                module = context.rb_Modules.Where(d => d.TabID == pageId && d.ModuleDefID == moduleDefId).FirstOrDefault();
            }

            if (module == default(rb_Modules) || alsoIfExists)
            {
                var sdb = new ModulesDB();
                return(sdb.AddModule(pageId, 0, "ContentPane", title, moduleDefId, 0, "Admins", "All Users", "Admins", "Admins", "Admins", "Admins", "Admins", false, string.Empty, true, false, false));
            }
            else
            {
                return(module.ModuleID);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        /*[Ajax.AjaxMethod]*/

        /*
         * public System.Collections.Specialized.StringCollection ModuleChangeStrings(string moduleType, string moduleName)
         * {
         *  SetDatata(moduleType);
         *  moduleTitle.Text = moduleName;
         *
         *  System.Collections.Specialized.StringCollection s = new System.Collections.Specialized.StringCollection();
         *
         *  s.Add(moduleTitle.Text);
         *
         *  if (AddModuleHelp.Visible)
         *  {
         *      s.Add(AddModuleHelp.Attributes["onclick"].ToString());
         *      s.Add(AddModuleHelp.NavigateUrl);
         *      s.Add(AddModuleHelp.ImageUrl);
         *      s.Add(AddModuleHelp.ToolTip);
         *  }
         *
         *  return s;
         * }
         * */

        /// <summary>
        /// The AddModule_Click server event handler
        ///   on this page is used to add a new portal module
        ///   into the tab
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        /// <remarks>
        /// </remarks>
        private void AddModule_Click(object sender, EventArgs e)
        {
            // TODO: IF PAGE ID = 0 Then we know it's home page, cant we get from db the id?
            // PagesDB _d = new PagesDB();
            var pid = this.PageID;

            if (pid == 0)
            {
                pid = PagesDB.PortalHomePageId(this.PortalID);
            }

            if (pid != 0)
            {
                // All new modules go to the end of the content pane
                var selectedModule = this.moduleType.SelectedItem.Value;
                var start          = selectedModule.IndexOf("|");
                var moduleID       = Convert.ToInt32(selectedModule.Substring(0, start).Trim());

                // Hide error message in case there was a previous error.
                this.moduleError.Visible = false;

                // This allows the user to pick what type of people can view the module being added.
                // If Authorized Roles is selected from the dropdown then every role that has view permission for the
                // Add Role module will be added to the view permissions of the module being added.
                var viewPermissionRoles = this.viewPermissions.SelectedValue;
                if (viewPermissionRoles == "Authorised Roles")
                {
                    viewPermissionRoles = PortalSecurity.GetViewPermissions(this.ModuleID);
                }

                try
                {
                    var m = new ModuleItem {
                        Title = this.TitleTextBox.Value, ModuleDefID = moduleID, Order = 999
                    };

                    // save to database
                    var mod = new ModulesDB();
                    m.ID = mod.AddModule(
                        pid,
                        m.Order,
                        this.paneLocation.SelectedValue,
                        m.Title,
                        m.ModuleDefID,
                        0,
                        PortalSecurity.GetEditPermissions(this.ModuleID),
                        viewPermissionRoles,
                        PortalSecurity.GetAddPermissions(this.ModuleID),
                        PortalSecurity.GetDeletePermissions(this.ModuleID),
                        PortalSecurity.GetPropertiesPermissions(this.ModuleID),
                        PortalSecurity.GetMoveModulePermissions(this.ModuleID),
                        PortalSecurity.GetDeleteModulePermissions(this.ModuleID),
                        false,
                        PortalSecurity.GetPublishPermissions(this.ModuleID),
                        false,
                        false,
                        false);
                }
                catch (Exception ex)
                {
                    this.moduleError.Visible = true;
                    ErrorHandler.Publish(
                        LogLevel.Error,
                        "There was an error with the Add Module Module while trying to add a new module.",
                        ex);
                }
                finally
                {
                    if (this.moduleError.Visible == false)
                    {
                        // Reload page to pick up changes
                        this.Response.Redirect(this.Request.RawUrl, false);
                    }
                }
            }
            else
            {
                // moduleError.TextKey = "ADDMODULE_HOMEPAGEERROR";
                this.moduleError.Text = General.GetString(
                    "ADDMODULE_HOMEPAGEERROR",
                    "You are currently on the homepage using the default virtual ID (The default ID is set when no specific page is selected. e.g. www.yourdomain.com. Please select your homepage from the Navigation menu e.g. 'Home' so that you can add a module against the page's actual ID.");
                this.moduleError.Visible = true;
            }
        }
        public JsonResult Clone(int id, int parentId)
        {
            try
            {
                var      generalModuleDef = Guid.Parse("F9F9C3A4-6E16-43B4-B540-984DDB5F1CD2");
                object[] queryargs        = { generalModuleDef, PortalSettings.PortalID };

                int moduleDefinition;

                try
                {
                    moduleDefinition =
                        new rb_ModuleDefinitions().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID;
                }
                catch (Exception e)
                {
                    // Shortcut module doesn't exist in current Portal

                    var modules = new ModulesDB();

                    modules.UpdateModuleDefinitions(
                        generalModuleDef,
                        PortalSettings.PortalID,
                        true);

                    moduleDefinition =
                        new rb_ModuleSettings().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID;
                }

                var db = new PagesDB();

                PortalPages = db.GetPagesFlat(PortalSettings.PortalID);
                var t = new PageItem
                {
                    Name  = General.GetString("TAB_NAME", "New Page Name"),
                    ID    = -1,
                    Order = 990000
                };

                PortalPages.Add(t);

                var tabs = new PagesDB();
                t.ID = tabs.AddPage(PortalSettings.PortalID, t.Name, t.Order);

                db.UpdatePageParent(t.ID, parentId, PortalSettings.PortalID);

                OrderPages();
                //JsonResult treeData = GetTreeData();

                // Coping Modules



                var pagesModules = new rb_Modules().All(where : "TabID = @0", args: id);

                foreach (var module in pagesModules)
                {
                    var m = new ModuleItem();
                    m.Title       = module.ModuleTitle;
                    m.ModuleDefID = moduleDefinition;
                    m.Order       = module.ModuleOrder;

                    // save to database
                    var mod = new ModulesDB();

                    m.ID = mod.AddModule(
                        t.ID,
                        m.Order,
                        module.PaneName,
                        module.ModuleTitle,
                        m.ModuleDefID,
                        0,
                        module.AuthorizedEditRoles,
                        module.AuthorizedViewRoles,
                        module.AuthorizedAddRoles,
                        module.AuthorizedDeleteRoles,
                        module.AuthorizedPropertiesRoles,
                        module.AuthorizedMoveModuleRoles,
                        module.AuthorizedDeleteModuleRoles,
                        false,
                        PortalSecurity.GetDeleteModulePermissions(module.ModuleID),
                        false,
                        false,
                        false);

                    var settings = new rb_ModuleSettings();
                    settings.Insert(new { ModuleID = m.ID, SettingName = "LinkedModule", SettingValue = module.ModuleID });
                }



                return(Json(new { pageId = t.ID }));
            }
            catch (Exception e)
            {
                ErrorHandler.Publish(LogLevel.Error, e);
                Response.StatusCode = 500;
                return(Json(""));
            }
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        //
        // GET: /Module/

        public JsonResult AddModule(string title, string moduleType, string paneLocation, string viewPermission, string pageId, string ModuleId)
        {
            // All new modules go to the end of the content pane
            var m = new ModuleItem();

            m.Title       = title;
            m.ModuleDefID = Int32.Parse(moduleType);
            m.Order       = 999;

            // save to database
            var mod   = new ModulesDB();
            var modId = Int32.Parse(ModuleId);

            m.ID = mod.AddModule(
                Int32.Parse(pageId),
                m.Order,
                paneLocation,
                m.Title,
                m.ModuleDefID,
                0,
                PortalSecurity.GetEditPermissions(modId),
                viewPermission,
                PortalSecurity.GetAddPermissions(modId),
                PortalSecurity.GetDeletePermissions(modId),
                PortalSecurity.GetPropertiesPermissions(modId),
                PortalSecurity.GetMoveModulePermissions(modId),
                PortalSecurity.GetDeleteModulePermissions(modId),
                false,
                PortalSecurity.GetPublishPermissions(modId),
                false,
                false,
                false);

            // End Change [email protected]

            //// reload the portalSettings from the database

            //this.Context.Items["PortalSettings"] = new PortalSettings(this.PageID, this.PortalSettings.PortalAlias);
            //this.PortalSettings = (PortalSettings)this.Context.Items["PortalSettings"];

            // reorder the modules in the content pane
            //var modules = GetModules("ContentPane", Int32.Parse(pageId), Int32.Parse(portalId));
            //this.OrderModules(modules);

            //// resave the order
            //foreach (ModuleItem item in modules) {
            //    mod.UpdateModuleOrder(item.ID, item.Order, "ContentPane");
            //}

            //// Redirect to the same page to pick up changes
            ////this.Response.Redirect(this.AppendModuleID(this.Request.RawUrl, m.ID));
            var list = GetModules(paneLocation, Int32.Parse(pageId));

            StringBuilder ls = new StringBuilder();

            foreach (ModuleItem md in list)
            {
                ls.AppendFormat("<option value=\"{0}\">{1}</option>", md.ID, md.Title);
            }

            return(Json(new { value = ls.ToString() }));
        }
Ejemplo n.º 9
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);
        }