Esempio n. 1
0
        public List<IModuleSettings> getModulesSettingsInPage(int PageId, string PaneName)
        {
            var modules = new List<IModuleSettings>();

            // Create Instance of Connection and Command Object
            using (var connection = Config.SqlConnectionString)
            using (var command = new SqlCommand("rb_GetModulesSettingsInPage", connection) {
                // Mark the Command as a SPROC
                CommandType = CommandType.StoredProcedure
            }) {

                // Add Parameters to SPROC
                var parameterPageId = new SqlParameter(StringsPageId, SqlDbType.Int, 4) { Value = PageId };
                command.Parameters.Add(parameterPageId);

                var parameterFriendlyName = new SqlParameter(StringsPaneName, SqlDbType.NVarChar, 50) { Value = PaneName };
                command.Parameters.Add(parameterFriendlyName);

                // Open the database connection and execute the command
                connection.Open();
                using (var reader = command.ExecuteReader()) {
                    try {
                        // Always call Read before accessing data.
                        while (reader.Read()) {
                            IModuleSettings module = new ModuleSettings();
                            module.ModuleID = reader.GetInt32(0);
                            module.ModuleDefID = reader.GetInt32(1);
                            module.ModuleOrder = reader.GetInt32(2);
                            module.ModuleTitle = reader.GetString(3);
                            module.PageID = PageId;
                            module.PaneName = PaneName;

                            modules.Add(module);
                        }
                    } finally {
                        reader.Close();
                        connection.Close();
                    }
                }
            }

            return modules;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PortalSettings"/> class.
        ///   The PortalSettings Constructor encapsulates all of the logic
        ///   necessary to obtain configuration settings necessary to render
        ///   a Portal Page view for a given request.<br/>
        ///   These Portal Settings are stored within a SQL database, and are
        ///   fetched below by calling the "GetPortalSettings" stored procedure.<br/>
        ///   This stored procedure returns values as SPROC output parameters,
        ///   and using three result sets.
        /// </summary>
        /// <param name="pageId">
        /// The page id.
        /// </param>
        /// <param name="portalAlias">
        /// The portal alias.
        /// </param>
        /// <remarks>
        /// </remarks>
        private PortalSettings(int pageId, string portalAlias)
        {
            this.ActivePage = new PageSettings();
            this.DesktopPages = new List<PageStripDetails>();
            this.ShowPages = true;
            this.MobilePages = new ArrayList();

            // Create Instance of Connection and Command Object
            using (var connection = Config.SqlConnectionString)
            using (var command = new SqlCommand("rb_GetPortalSettings", connection))
            {
                // Mark the Command as a SPROC
                command.CommandType = CommandType.StoredProcedure;

                // Add Parameters to SPROC
                var parameterPortalAlias = new SqlParameter("@PortalAlias", SqlDbType.NVarChar, 128)
                    {
                        Value = portalAlias // Specify the Portal Alias Dynamically
                    };
                command.Parameters.Add(parameterPortalAlias);
                var parameterPageId = new SqlParameter(StringsAtPageId, SqlDbType.Int, 4) { Value = pageId };
                command.Parameters.Add(parameterPageId);
                var parameterPortalLanguage = new SqlParameter("@PortalLanguage", SqlDbType.NVarChar, 12)
                    {
                       Value = this.PortalContentLanguage.Name
                    };
                command.Parameters.Add(parameterPortalLanguage);

                // Add out parameters to Sproc
                var parameterPortalId = new SqlParameter(StringsAtPortalId, SqlDbType.Int, 4)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterPortalId);
                var parameterPortalName = new SqlParameter("@PortalName", SqlDbType.NVarChar, 128)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterPortalName);
                var parameterPortalPath = new SqlParameter("@PortalPath", SqlDbType.NVarChar, 128)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterPortalPath);
                var parameterEditButton = new SqlParameter("@AlwaysShowEditButton", SqlDbType.Bit, 1)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterEditButton);
                var parameterPageName = new SqlParameter("@PageName", SqlDbType.NVarChar, 50)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterPageName);
                var parameterPageOrder = new SqlParameter("@PageOrder", SqlDbType.Int, 4)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterPageOrder);
                var parameterParentPageId = new SqlParameter("@ParentPageID", SqlDbType.Int, 4)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterParentPageId);
                var parameterMobilePageName = new SqlParameter("@MobilePageName", SqlDbType.NVarChar, 50)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterMobilePageName);
                var parameterAuthRoles = new SqlParameter("@AuthRoles", SqlDbType.NVarChar, 512)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterAuthRoles);
                var parameterShowMobile = new SqlParameter("@ShowMobile", SqlDbType.Bit, 1)
                    {
                       Direction = ParameterDirection.Output
                    };
                command.Parameters.Add(parameterShowMobile);
                SqlDataReader result;

                try
                {
                    // Open the database connection and execute the command
                    // try // jes1111
                    // {
                    connection.Open();
                    result = command.ExecuteReader(CommandBehavior.CloseConnection);
                    this.CurrentLayout = "Default";

                    // Read the first resultset -- Desktop Page Information
                    while (result.Read())
                    {
                        var tabDetails = new PageStripDetails
                            {
                                PageID = (int)result["PageID"],
                                ParentPageID = Int32.Parse("0" + result["ParentPageID"]),
                                PageName = (string)result["PageName"],
                                PageOrder = (int)result["PageOrder"],
                                PageLayout = this.CurrentLayout,
                                AuthorizedRoles = (string)result["AuthorizedRoles"]
                            };
                        this.PortalAlias = portalAlias;

                        // Update the AuthorizedRoles Variable
                        this.DesktopPages.Add(tabDetails);
                    }

                    if (this.DesktopPages.Count == 0)
                    {
                        return; // Abort load

                        // throw new Exception("The portal you requested has no Pages. PortalAlias: '" + portalAlias + "'", new HttpException(404, "Portal not found"));
                    }

                    // Read the second result --  Mobile Page Information
                    result.NextResult();

                    while (result.Read())
                    {
                        var tabDetails = new PageStripDetails
                            {
                                PageID = (int)result["PageID"],
                                PageName = (string)result["MobilePageName"],
                                PageLayout = this.CurrentLayout,
                                AuthorizedRoles = (string)result["AuthorizedRoles"]
                            };
                        this.MobilePages.Add(tabDetails);
                    }

                    // Read the third result --  Module Page Information
                    result.NextResult();

                    while (result.Read())
                    {
                        var m = new ModuleSettings
                            {
                                ModuleID = (int)result["ModuleID"],
                                ModuleDefID = (int)result["ModuleDefID"],
                                GuidID = (Guid)result["GeneralModDefID"],
                                PageID = (int)result["TabID"],
                                PaneName = (string)result["PaneName"],
                                ModuleTitle = (string)result["ModuleTitle"]
                            };
                        var value = result["AuthorizedEditRoles"];
                        m.AuthorizedEditRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;
                        value = result["AuthorizedViewRoles"];
                        m.AuthorizedViewRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;
                        value = result["AuthorizedAddRoles"];
                        m.AuthorizedAddRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;
                        value = result["AuthorizedDeleteRoles"];
                        m.AuthorizedDeleteRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;
                        value = result["AuthorizedPropertiesRoles"];
                        m.AuthorizedPropertiesRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;

                        // [email protected] (19/08/2004) Add support for move & delete module roles
                        value = result["AuthorizedMoveModuleRoles"];
                        m.AuthorizedMoveModuleRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;
                        value = result["AuthorizedDeleteModuleRoles"];
                        m.AuthorizedDeleteModuleRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;

                        // Change by [email protected]
                        // Date: 6/2/2003
                        value = result["AuthorizedPublishingRoles"];
                        m.AuthorizedPublishingRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;
                        value = result["SupportWorkflow"];
                        m.SupportWorkflow = !Convert.IsDBNull(value) ? (bool)value : false;

                        // Date: 27/2/2003
                        value = result["AuthorizedApproveRoles"];
                        m.AuthorizedApproveRoles = !Convert.IsDBNull(value) ? (string)value : string.Empty;
                        value = result["WorkflowState"];
                        m.WorkflowStatus = !Convert.IsDBNull(value)
                                               ? (WorkflowState)(0 + (byte)value)
                                               : WorkflowState.Original;

                        // End Change [email protected]
                        // Start Change [email protected]
                        try
                        {
                            value = result["SupportCollapsable"];
                        }
                        catch
                        {
                            value = DBNull.Value;
                        }

                        m.SupportCollapsable = DBNull.Value != value ? (bool)value : false;

                        // End Change  [email protected]
                        // Start Change [email protected]
                        try
                        {
                            value = result["ShowEveryWhere"];
                        }
                        catch
                        {
                            value = DBNull.Value;
                        }

                        m.ShowEveryWhere = DBNull.Value != value ? (bool)value : false;

                        // End Change  [email protected]
                        m.CacheTime = int.Parse(result["CacheTime"].ToString());
                        m.ModuleOrder = int.Parse(result["ModuleOrder"].ToString());
                        value = result["ShowMobile"];
                        m.ShowMobile = !Convert.IsDBNull(value) ? (bool)value : false;
                        m.DesktopSrc = result["DesktopSrc"].ToString();
                        m.MobileSrc = result["MobileSrc"].ToString();
                        m.Admin = bool.Parse(result["Admin"].ToString());
                        this.ActivePage.Modules.Add(m);
                    }

                    // Now read Portal out params
                    result.NextResult();
                    this.PortalID = (int)parameterPortalId.Value;
                    this.PortalName = (string)parameterPortalName.Value;

                    // jes1111 - this.PortalTitle = ConfigurationSettings.AppSettings["PortalTitlePrefix"] + this.PortalName;
                    this.PortalTitle = String.Concat(Config.PortalTitlePrefix, this.PortalName);

                    // jes1111 - this.PortalPath = Settings.Path.WebPathCombine(ConfigurationSettings.AppSettings["PortalsDirectory"], (string) parameterPortalPath.Value);
                    this.PortalPath = Path.WebPathCombine(Config.PortalsDirectory, (string)parameterPortalPath.Value);

                    // jes1111 - this.PortalSecurePath = ConfigurationSettings.AppSettings["PortalSecureDirectory"]; // added Thierry (tiptopweb) 12 Apr 2003
                    this.PortalSecurePath = Config.PortalSecureDirectory;
                    this.ActivePage.PageID = pageId;
                    this.ActivePage.PageLayout = this.CurrentLayout;
                    this.ActivePage.ParentPageID = Int32.Parse("0" + parameterParentPageId.Value);
                    this.ActivePage.PageOrder = (int)parameterPageOrder.Value;
                    this.ActivePage.MobilePageName = (string)parameterMobilePageName.Value;
                    this.ActivePage.AuthorizedRoles = (string)parameterAuthRoles.Value;
                    this.ActivePage.PageName = (string)parameterPageName.Value;
                    this.ActivePage.ShowMobile = (bool)parameterShowMobile.Value;
                    this.ActivePage.PortalPath = this.PortalPath; // [email protected] for page custom layout
                    result.Close(); // by Manu, fixed bug 807858

                    // }
                    // catch (Exception ex)
                    // {
                    // HttpContext.Current.Response.Write("Failed rb_GetPortalSettings for " + pageID.ToString() + ", " + portalAlias + ":<br/>"+ex.Message);
                    // HttpContext.Current.Response.End();
                    // //Response.Redirect("~/app_support/ErrorNoPortal.aspx",true);
                    // }
                }
                catch (SqlException sqex)
                {
                    var requestUri = HttpContext.Current.Request.Url;

                        throw new DatabaseUnreachableException("This may be a new db", sqex);

                    return;
                }
                finally
                {
                    // by Manu fix close bug #2
                    if (connection.State == ConnectionState.Open)
                    {
                        connection.Close();
                    }
                }
            }

            // Provide a valid tab id if it is missing

            // 11-10-2011
            // Changed to go to the first page that the user logged has permission to see

            //if (this.ActivePage.PageID == 0)
            //{
            //    this.ActivePage.PageID = ((PageStripDetails)this.DesktopPages[0]).PageID;
            //}

            // Go to get custom settings
            if (!Directory.Exists(Path.ApplicationPhysicalPath + this.PortalFullPath))
            {
                var portals = new PortalsDB();
                portals.CreatePortalPath(this.PortalAlias);
            }

            this.CustomSettings = GetPortalCustomSettings(this.PortalID, GetPortalBaseSettings(this.PortalPath));

            // Initialize Theme
            var themeManager = new ThemeManager(this.PortalPath);

            // Default
            themeManager.Load(this.CustomSettings["SITESETTINGS_THEME"].ToString());
            this.CurrentThemeDefault = themeManager.CurrentTheme;

            // Alternate
            if (this.CustomSettings["SITESETTINGS_ALT_THEME"].ToString() == this.CurrentThemeDefault.Name)
            {
                this.CurrentThemeAlt = this.CurrentThemeDefault;
            }
            else
            {
                themeManager.Load(this.CustomSettings["SITESETTINGS_ALT_THEME"].ToString());
                this.CurrentThemeAlt = themeManager.CurrentTheme;
            }

            // themeManager.Save(this.CustomSettings["SITESETTINGS_THEME"].ToString());
            // Set layout
            this.CurrentLayout = this.CustomSettings["SITESETTINGS_PAGE_LAYOUT"].ToString();

            // Jes1111
            // Generate DesktopPagesXml
            // jes1111 - if (bool.Parse(ConfigurationSettings.AppSettings["PortalSettingDesktopPagesXml"]))
            // if (Config.PortalSettingDesktopPagesXml)
            // this.DesktopPagesXml = GetDesktopPagesXml();
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </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>
        private void Page_Load(object sender, EventArgs e)
        {
            this.DeleteButton.Visible = true;
            this.UpdateButton.Visible = false;

            try
            {
                _moduleID = int.Parse(Request.Params["mID"]);

                module = RecyclerDB.GetModuleSettingsForIndividualModule(_moduleID);
                if (RecyclerDB.ModuleIsInRecycler(_moduleID))
                {
                    if (!Page.IsPostBack)
                    {
                        //load tab names for the dropdown list, then bind them
                        // TODO check if this works
                        //portalTabs = new PagesDB().GetPagesFlat(portalSettings.PortalID);
                        portalTabs = new PagesDB().GetPagesFlatTable(this.PortalSettings.PortalID);

                        ddTabs.DataBind();

                        //on initial load, disable the restore button until they make a selection
                        restoreButton.Enabled = false;
                        ddTabs.Items.Insert(0, "--Choose a Page to Restore this Module--");
                    }

                    // create an instance of the module
                    PortalModuleControl myPortalModule =
                        (PortalModuleControl) LoadControl(Path.ApplicationRoot + "/" + this.module.DesktopSrc);
                    myPortalModule.PortalID = this.PortalSettings.PortalID;
                    myPortalModule.ModuleConfiguration = module;

                    // add the module to the placeholder
                    PrintPlaceHolder.Controls.Add(myPortalModule);
                }
                else
                    //they're trying to view a module that isn't in the recycler - maybe a manual manipulation of the url...?
                {
                    pnlMain.Visible = false;
                    pnlError.Visible = true;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        /// <remarks></remarks>
        protected override void OnInit(EventArgs e)
        {
            var controlPath = string.Empty;

            // Try to get info on linked control
            var linkedModuleId = Int32.Parse(this.Settings["LinkedModule"].ToString());
            var dr = ModuleSettings.GetModuleDefinitionByID(linkedModuleId);
            try
            {
                if (dr.Read())
                {
                    controlPath = string.Format("{0}/{1}", Path.ApplicationRoot, dr["DesktopSrc"]);
                }
            }
            finally
            {
                dr.Close();
            }

            // Load control
            PortalModuleControl portalModule = null;
            try
            {
                if (controlPath.Length == 0) {
                    this.PlaceHolderModule.Controls.Add(
                        new LiteralControl(
                            string.Format("Module '{0}' not found!  Use Admin panel to add a linked control.", linkedModuleId)));
                    portalModule = new PortalModuleControl();

                } else {
                    if (controlPath.ToLowerInvariant().Trim().EndsWith(".ascx"))
                    {
                        portalModule = (PortalModuleControl)this.Page.LoadControl(controlPath);
                    }
                    else // MVC
                    {
                        var strArray = controlPath.Split(
                            new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
                        int index = 1;
                        if (!Path.ApplicationRoot.Equals(string.Empty))
                        {
                            index++;
                        }
                        var areaName = (strArray[index].ToLower() == "views") ? string.Empty : strArray[index];
                        var controllerName = strArray[strArray.Length - 2];
                        var actionName = strArray[strArray.Length - 1];

                        // var ns = strArray[2];
                        portalModule =

                            (PortalModuleControl)this.Page.LoadControl("~/DesktopModules/CoreModules/MVC/MVCModule.ascx");

                        ((MVCModuleControl)portalModule).ControllerName = controllerName;
                        ((MVCModuleControl)portalModule).ActionName = actionName;
                        ((MVCModuleControl)portalModule).AreaName = areaName;
                        ((MVCModuleControl)portalModule).ModID = linkedModuleId;

                        ((MVCModuleControl)portalModule).Initialize();
                    }

                    // Sets portal ID
                    portalModule.PortalID = this.PortalID;

                    // Update settings
                    var m = new ModuleSettings {
                        ModuleID = linkedModuleId,
                        PageID = this.ModuleConfiguration.PageID,
                        PaneName = this.ModuleConfiguration.PaneName,
                        ModuleTitle = this.ModuleConfiguration.ModuleTitle,
                        AuthorizedEditRoles = string.Empty,   // read only
                        AuthorizedViewRoles = string.Empty,   // read only
                        AuthorizedAddRoles = string.Empty,    // read only
                        AuthorizedDeleteRoles = string.Empty, // read only
                        AuthorizedPropertiesRoles = this.ModuleConfiguration.AuthorizedPropertiesRoles,
                        CacheTime = this.ModuleConfiguration.CacheTime,
                        ModuleOrder = this.ModuleConfiguration.ModuleOrder,
                        ShowMobile = this.ModuleConfiguration.ShowMobile,
                        DesktopSrc = controlPath,
                        MobileSrc = string.Empty, // not supported yet
                        SupportCollapsable = this.ModuleConfiguration.SupportCollapsable
                    };

                    // added [email protected]
                    portalModule.ModuleConfiguration = m;

                    portalModule.Settings["MODULESETTINGS_APPLY_THEME"] = this.Settings["MODULESETTINGS_APPLY_THEME"];
                    portalModule.Settings["MODULESETTINGS_THEME"] = this.Settings["MODULESETTINGS_THEME"];

                    // added so ShowTitle is independent of the Linked Module
                    portalModule.Settings["MODULESETTINGS_SHOW_TITLE"] = this.Settings["MODULESETTINGS_SHOW_TITLE"];

                    // added so that shortcut works for module "print this..." feature
                    this.PlaceHolderModule.ID = "Shortcut";

                    // added so AllowCollapsable -- [email protected]
                    if (portalModule.Settings.ContainsKey("AllowCollapsable"))
                        portalModule.Settings["AllowCollapsable"] = this.Settings["AllowCollapsable"];

                    // Add control to the page
                    this.PlaceHolderModule.Controls.Add(portalModule);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Publish(LogLevel.Error, string.Format("Shortcut: Unable to load control '{0}'!", controlPath), ex);
                this.PlaceHolderModule.Controls.Add(
                    new LiteralControl(
                        string.Format("<br /><span class=\"NormalRed\">Unable to load control '{0}'!</span><br />", controlPath)));
                this.PlaceHolderModule.Controls.Add(new LiteralControl(ex.Message));
                return; // The controls has failed!
            }

            // Set title
            portalModule.PropertiesUrl = HttpUrlBuilder.BuildUrl(
                "~/DesktopModules/CoreModules/Admin/PropertyPage.aspx", this.PageID, "mID=" + this.ModuleID);
            portalModule.PropertiesText = "PROPERTIES";
            portalModule.AddUrl = string.Empty; // Readonly
            portalModule.AddText = string.Empty; // Readonly
            portalModule.EditUrl = string.Empty; // Readonly
            portalModule.EditText = string.Empty; // Readonly

            // jes1111
            portalModule.OriginalModuleID = this.ModuleID;
            CurrentCache.Remove(Key.ModuleSettings(linkedModuleId));

            base.OnInit(e);
        }
        /// <summary>
        /// Toes the show.
        /// </summary>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <returns>
        /// </returns>
        /// <remarks>
        /// </remarks>
        private Control ToShow(string text)
        {
            var module = 0;
            if (text.StartsWith(TokenModule))
            {
                module = int.Parse(text.Substring(TokenModule.Length));
            }
            else if (text.StartsWith(TokenPortalModule))
            {
                module = int.Parse(text.Substring(TokenPortalModule.Length));
            }
            else
            {
                return new LiteralControl(text);
            }

            PortalModuleControl portalModule;
            var controlPath = string.Empty;
            using (var dr = ModuleSettings.GetModuleDefinitionByID(module))
            {
                if (dr.Read())
                {
                    controlPath = string.Format("{0}/{1}", Framework.Settings.Path.ApplicationRoot, dr["DesktopSrc"]);
                }
            }

            try
            {
                if (string.IsNullOrEmpty(controlPath))
                {
                    return new LiteralControl(string.Format("Module '{0}' not found! ", module));
                }

                portalModule = (PortalModuleControl)this.Page.LoadControl(controlPath);

                // Sets portal ID
                portalModule.PortalID = this.PortalID;

                var m = new ModuleSettings
                    {
                        ModuleID = module,
                        PageID = this.ModuleConfiguration.PageID,
                        PaneName = this.ModuleConfiguration.PaneName,
                        ModuleTitle = this.ModuleConfiguration.ModuleTitle,
                        AuthorizedEditRoles = string.Empty,
                        AuthorizedViewRoles = string.Empty,
                        AuthorizedAddRoles = string.Empty,
                        AuthorizedDeleteRoles = string.Empty,
                        AuthorizedPropertiesRoles = string.Empty,
                        CacheTime = this.ModuleConfiguration.CacheTime,
                        ModuleOrder = this.ModuleConfiguration.ModuleOrder,
                        ShowMobile = this.ModuleConfiguration.ShowMobile,
                        DesktopSrc = controlPath
                    };

                portalModule.ModuleConfiguration = m;

                portalModule.Settings["MODULESETTINGS_APPLY_THEME"].Value = false;
                portalModule.Settings["MODULESETTINGS_SHOW_TITLE"].Value = false;
            }
            catch (Exception ex)
            {
                ErrorHandler.Publish(
                    LogLevel.Warn, string.Format("Shortcut: Unable to load control '{0}'!", controlPath), ex);
                return
                    new LiteralControl(
                        string.Format("<br><span class=NormalRed>Unable to load control '{0}'!<br>", controlPath));
            }

            portalModule.PropertiesUrl = string.Empty;
            portalModule.AddUrl = string.Empty; // Readonly
            portalModule.AddText = string.Empty; // Readonly
            portalModule.EditUrl = string.Empty; // Readonly
            portalModule.EditText = string.Empty; // Readonly
            portalModule.OriginalModuleID = this.ModuleID;

            CurrentCache.Remove(Key.ModuleSettings(module));
            return portalModule;
        }
        /// <summary>
        ///   Initializes a new instance of the <see cref = "PortalModuleControl" /> class.
        /// </summary>
        public PortalModuleControl()
        {
            this.BaseSettings = new Dictionary<string, ISettingItem>();
            this.ButtonListAdmin = new List<Control>(3);
            this.ButtonListCustom = new List<Control>(3);
            this.ButtonListUser = new List<Control>(3);
            this.ApproveText = "SWI_APPROVE";
            this.ProductionVersionText = "SWI_SWAPTOPRODUCTION";
            this.PublishText = "SWI_PUBLISH";
            this.ReadyToApproveText = "SWI_READYTOAPPROVE";
            this.RejectText = "SWI_REJECT";
            this.RevertText = "SWI_REVERT";
            this.StagingVersionText = "SWI_SWAPTOSTAGING";
            this.SupportsPrint = true;
            this.Cacheable = true;

            // MVC
            var wrapper = new HttpContextWrapper(this.Context);

            var viewContext = new ViewContext { HttpContext = wrapper, ViewData = new ViewDataDictionary() };

            this.ViewContext = viewContext;

            // THEME MANAGEMENT
            var group = SettingItemGroup.THEME_LAYOUT_SETTINGS;
            var groupOrderBase = (int)SettingItemGroup.THEME_LAYOUT_SETTINGS;

            var applyTheme = new SettingItem<bool, CheckBox>
                {
                    Order = groupOrderBase + 10,
                    Group = group,
                    Value = true,
                    EnglishName = "Apply Theme",
                    Description = "Check this box to apply theme to this module"
                };
            this.BaseSettings.Add("MODULESETTINGS_APPLY_THEME", applyTheme);

            var themeOptions = new List<SettingOption>
                {
                    new SettingOption((int)ThemeList.Default, General.GetString("MODULESETTINGS_THEME_DEFAULT")),
                    new SettingOption((int)ThemeList.Alt, General.GetString("MODULESETTINGS_THEME_ALT"))
                };
            var theme = new SettingItem<string, ListControl>(new CustomListDataType(themeOptions, "Name", "Val"))
                {
                    Order = groupOrderBase + 20,
                    Group = group,
                    Value = ((int)ThemeList.Default).ToString(),
                    EnglishName = "Theme",
                    Description = "Choose theme for this module"
                };
            this.BaseSettings.Add("MODULESETTINGS_THEME", theme);

            if (HttpContext.Current != null)
            {
                // null in DesignMode
                // Added: Jes1111 - 2004-08-03
                var PortalSettings1 = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

                // end addition: Jes1111
                if (PortalSettings1 != null)
                {
                    // fix by The Bitland Prince
                    this.PortalID = PortalSettings1.PortalID;

                    // added: Jes1111 2004-08-02 - custom module theme
                    if (PortalSettings1.CustomSettings.ContainsKey("SITESETTINGS_ALLOW_MODULE_CUSTOM_THEMES") &&
                        PortalSettings1.CustomSettings["SITESETTINGS_ALLOW_MODULE_CUSTOM_THEMES"].ToString().Length != 0 &&
                        bool.Parse(PortalSettings1.CustomSettings["SITESETTINGS_ALLOW_MODULE_CUSTOM_THEMES"].ToString()))
                    {
                        var tempList = new List<object>(new ThemeManager(PortalSettings1.PortalPath).GetThemes());
                        var themeList =
                            tempList.Cast<ThemeItem>().Where(item => item.Name.ToLower().StartsWith("module")).ToList();

                        var customThemeNo = new ThemeItem { Name = string.Empty };
                        themeList.Insert(0, customThemeNo);
                        var moduleTheme =
                            new SettingItem<string, ListControl>(new CustomListDataType(themeList, "Name", "Name"))
                                {
                                    Order = groupOrderBase + 25,
                                    Group = group,
                                    EnglishName = "Custom Theme",
                                    Description = "Set a custom theme for this module only"
                                };
                        this.BaseSettings.Add("MODULESETTINGS_MODULE_THEME", moduleTheme);
                    }
                }
            }

            // switches title display on/off
            var showTitle = new SettingItem<bool, CheckBox>
                {
                    Order = groupOrderBase + 30,
                    Group = group,
                    Value = true,
                    EnglishName = "Show Title",
                    Description = "Switches title display on/off"
                };
            this.BaseSettings.Add("MODULESETTINGS_SHOW_TITLE", showTitle);

            // switches last modified summary on/off
            var showModifiedBy = new SettingItem<bool, CheckBox>
                {
                    Order = groupOrderBase + 40,
                    Group = group,
                    Value = false,
                    EnglishName = "Show Modified by",
                    Description = "Switches 'Show Modified by' display on/off"
                };
            this.BaseSettings.Add("MODULESETTINGS_SHOW_MODIFIED_BY", showModifiedBy);

            // gman3001: added 10/26/2004
            // - implement width, height, and content scrolling options for all modules
            // - implement auto-stretch option
            // Windows height
            var controlHeight = new SettingItem<int, TextBox>
                {
                    Value = 0,
                    MinValue = 0,
                    MaxValue = 3000,
                    Required = true,
                    Order = groupOrderBase + 50,
                    Group = group,
                    EnglishName = "Content Height",
                    Description = "Minimum height(in pixels) of the content area of this module. (0 for none)"
                };
            this.BaseSettings.Add("MODULESETTINGS_CONTENT_HEIGHT", controlHeight);

            // Windows width
            var controlWidth = new SettingItem<int, TextBox>
                {
                    Value = 0,
                    MinValue = 0,
                    MaxValue = 3000,
                    Required = true,
                    Order = groupOrderBase + 60,
                    Group = group,
                    EnglishName = "Content Width",
                    Description = "Minimum width(in pixels) of the content area of this module. (0 for none)"
                };
            this.BaseSettings.Add("MODULESETTINGS_CONTENT_WIDTH", controlWidth);

            // Content scrolling option
            var scrollingSetting = new SettingItem<bool, CheckBox>
                {
                    Value = false,
                    Order = groupOrderBase + 70,
                    Group = group,
                    EnglishName = "Content Scrolling",
                    Description = "Set to enable/disable scrolling of Content based on height and width settings."
                };
            this.BaseSettings.Add("MODULESETTINGS_CONTENT_SCROLLING", scrollingSetting);

            // Module Stretching option
            var stretchSetting = new SettingItem<bool, CheckBox>
                {
                    Value = true,
                    Order = groupOrderBase + 80,
                    Group = group,
                    EnglishName = "Module Auto Stretch",
                    Description =
                        "Set to enable/disable automatic stretching of the module's width to fill the empty area to the right of the module."
                };
            this.BaseSettings.Add("MODULESETTINGS_WIDTH_STRETCHING", stretchSetting);

            // gman3001: END

            // BUTTONS
            group = SettingItemGroup.BUTTON_DISPLAY_SETTINGS;
            groupOrderBase = (int)SettingItemGroup.BUTTON_DISPLAY_SETTINGS;

            // Show print button in view mode?
            var printButton1 = new SettingItem<bool, CheckBox>
                {
                    Value = false,
                    Order = groupOrderBase + 20,
                    Group = group,
                    EnglishName = "Show Print Button",
                    Description = "Show print button in view mode?"
                };
            this.BaseSettings.Add("MODULESETTINGS_SHOW_PRINT_BUTTION", printButton1);

            // added: Jes1111 2004-08-29 - choice! Default is 'true' for backward compatibility
            // Show Title for print?
            var showTitlePrint = new SettingItem<bool, CheckBox>
                {
                    Value = true,
                    Order = groupOrderBase + 25,
                    Group = group,
                    EnglishName = "Show Title for Print",
                    Description = "Show Title for this module in print popup?"
                };
            this.BaseSettings.Add("MODULESETTINGS_SHOW_TITLE_PRINT", showTitlePrint);

            // added: Jes1111 2004-08-02 - choices for Button display on module
            var buttonDisplayOptions = new List<SettingOption>
                {
                    new SettingOption(
                        (int)ModuleButton.RenderOptions.ImageOnly,
                        General.GetString("MODULESETTINGS_BUTTON_DISPLAY_IMAGE")),
                    new SettingOption(
                        (int)ModuleButton.RenderOptions.TextOnly,
                        General.GetString("MODULESETTINGS_BUTTON_DISPLAY_TEXT")),
                    new SettingOption(
                        (int)ModuleButton.RenderOptions.ImageAndTextCSS,
                        General.GetString("MODULESETTINGS_BUTTON_DISPLAY_BOTH")),
                    new SettingOption(
                        (int)ModuleButton.RenderOptions.ImageOnlyCSS,
                        General.GetString("MODULESETTINGS_BUTTON_DISPLAY_IMAGECSS"))
                };
            var buttonDisplay =
                new SettingItem<string, ListControl>(new CustomListDataType(buttonDisplayOptions, "Name", "Val"))
                    {
                        Order = groupOrderBase + 30,
                        Group = group,
                        Value = ((int)ModuleButton.RenderOptions.ImageOnly).ToString(),
                        EnglishName = "Display Buttons as:",
                        Description =
                            "Choose how you want module buttons to be displayed. Note that settings other than 'Image only' may require Zen or special treatment in the Theme."
                    };
            this.BaseSettings.Add("MODULESETTINGS_BUTTON_DISPLAY", buttonDisplay);

            // Jes1111 - not implemented yet
            // // Show email button in view mode?
            // SettingItem EmailButton = new SettingItem<bool, CheckBox>();
            // EmailButton.Value = "False";
            // EmailButton.Order = _groupOrderBase + 30;
            // EmailButton.Group = _Group;
            // this.BaseSettings.Add("ShowEmailButton",EmailButton);

            // Show arrows buttons to move modules (admin only, property authorize)
            var arrowButtons = new SettingItem<bool, CheckBox>
                {
                    Value = true,
                    Order = groupOrderBase + 40,
                    Group = group,
                    EnglishName = "Show Arrow Admin Buttons",
                    Description = "Show Arrow Admin buttons?"
                };
            this.BaseSettings.Add("MODULESETTINGS_SHOW_ARROW_BUTTONS", arrowButtons);

            // Show help button if exists
            var helpButton1 = new SettingItem<bool, CheckBox>
                {
                    Value = true,
                    Order = groupOrderBase + 50,
                    Group = group,
                    EnglishName = "Show Help Button",
                    Description = "Show help button in title if exists documentation for this module"
                };
            this.BaseSettings.Add("MODULESETTINGS_SHOW_HELP_BUTTON", helpButton1);

            // LANGUAGE/CULTURE MANAGEMENT
            groupOrderBase = (int)SettingItemGroup.CULTURE_SETTINGS;
            group = SettingItemGroup.CULTURE_SETTINGS;

            var cultureList = Localization.LanguageSwitcher.GetLanguageList(true);

            var culture =
                new SettingItem<string, ListControl>(new MultiSelectListDataType(cultureList, "DisplayName", "Name"))
                    {
                        Value = string.Empty,
                        Order = groupOrderBase + 10,
                        Group = group,
                        EnglishName = "Culture",
                        Description =
                            "Please choose the culture. Invariant cultures shows always the module, if you choose one or more cultures only when culture is selected this module will shown."
                    };
            this.BaseSettings.Add("MODULESETTINGS_CULTURE", culture);

            // Localized module title
            var counter = groupOrderBase + 11;

            // Ignore invariant
            foreach (var c in
                cultureList.Where(c => c != CultureInfo.InvariantCulture && !this.BaseSettings.ContainsKey(c.Name)))
            {
                var localizedTitle = new SettingItem<string, TextBox>
                    {
                        Order = counter,
                        Group = group,
                        EnglishName = string.Format("Title ({0})", c.Name),
                        Description = string.Format("Set title for {0} culture.", c.EnglishName)
                    };
                this.BaseSettings.Add(string.Format("MODULESETTINGS_TITLE_{0}", c.Name), localizedTitle);
                counter++;
            }

            // SEARCH
            if (this.Searchable)
            {
                groupOrderBase = (int)SettingItemGroup.MODULE_SPECIAL_SETTINGS;
                group = SettingItemGroup.MODULE_SPECIAL_SETTINGS;

                var topicName = new SettingItem<string, TextBox>
                    {
                        Required = false,
                        Value = string.Empty,
                        // modified by Hongwei Shen([email protected]) 11/9/2005
                        // group base and order is not specified
                        Group = group,
                        Order = groupOrderBase,
                        EnglishName = "Topic",
                        Description = "Select a topic for this module. You may filter items by topic in Portal Search."
                    };

                // end of modification
                this.BaseSettings.Add("TopicName", topicName);
            }

            // Default configuration
            this.pageId = 0;

            this.moduleConfiguration = new ModuleSettings();

            var share = new SettingItem<bool, CheckBox>
                {
                    Value = false,
                    Order = groupOrderBase + 51,
                    Group = SettingItemGroup.MODULE_SPECIAL_SETTINGS,
                    EnglishName = "ShareModule",
                    Description = "Share Module"
                };
            this.BaseSettings.Add("SHARE_MODULE", share);
        }
        /// <summary>
        /// Creates the portal.
        /// </summary>
        /// <param name="templateID">The template ID.</param>
        /// <param name="templateAlias">The template alias.</param>
        /// <param name="portalAlias">The portal alias.</param>
        /// <param name="portalName">Name of the portal.</param>
        /// <param name="portalPath">The portal path.</param>
        /// <returns></returns>
        private int CreatePortal(int templateID, string templateAlias, string portalAlias, string portalName,
            string portalPath)
        {
            int newPortalID;

            PortalsDB portals = new PortalsDB();
            PagesDB tabs = new PagesDB();
            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();

            // TODO: Is this still valid? Admin user will be created the first time the portal is accessed
            //if (!Config.UseSingleUserBase)
            //{
            //    // TODO: multiple portals still not supported
            //    Guid userID;

            //    // 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("admin", 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["PageID"];
                tab.newID =
                    tabs.AddPage(newPortalID, myReader["PageName"].ToString(),
                                 Int32.Parse(myReader["PageOrder"].ToString()));
                templateTabs.Add(tab);
            }
            myReader.Close();

            //Clear SiteMaps Cache
            AppleseedSiteMapProvider.ClearAllAppleseedSiteMapCaches();

            // 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
                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["PageID"])
                        newTabID = tab.newID;
                    if (tab.oldID == Int32.Parse("0" + myReader["ParentPageID"]))
                        newParentTabID = tab.newID;
                }

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

                // Update the Tab in the new portal
                tabs.UpdatePage(newPortalID, newTabID, newParentTabID, myReader["PageName"].ToString(),
                                Int32.Parse(myReader["PageOrder"].ToString()), myReader["AuthorizedRoles"].ToString(),
                                myReader["MobilePageName"].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 = GetPageModules(Int32.Parse(myReader["PageID"].ToString()), my2ndConnection);

                    object myValue;

                    while (result.Read()) {
                        ModuleSettings m = new ModuleSettings();
                        m.ModuleID = (int)result["ModuleID"];
                        m.ModuleDefID = (int)result["ModuleDefID"];
                        m.PageID = 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()) {
                                Framework.Site.Configuration.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;
        }
Esempio n. 8
0
        /// <summary>
        /// MOST OF THIS METHOD'S CODE IS COPIED DIRECTLY FROM THE PortalSettings() CLASS
        ///   THE RECYCLER NEEDS TO BE ABLE TO RETRIEVE A MODULE'S ModuleSettings INDEPENDENT
        ///   OF THE TAB THE MODULE IS LOCATED ON (AND INDEPENDENT OF THE CURRENT 'ActiveTab'
        /// </summary>
        /// <param name="moduleId">
        /// The module ID.
        /// </param>
        /// <returns>
        /// The module settings.
        /// </returns>
        public static ModuleSettings GetModuleSettingsForIndividualModule(int moduleId)
        {
            // Create Instance of Connection and Command Object
            using (var connection = Config.SqlConnectionString)
            using (var command = new SqlCommand("rb_GetModuleSettingsForIndividualModule", connection))
            {
                // Mark the Command as a SPROC
                command.CommandType = CommandType.StoredProcedure;

                // Add Parameters to SPROC
                var parameterModuleId = new SqlParameter("@ModuleID", SqlDbType.Int, 4) { Value = moduleId };
                command.Parameters.Add(parameterModuleId);

                // Open the database connection and execute the command
                connection.Open();
                var result = command.ExecuteReader(CommandBehavior.CloseConnection);

                var m = new ModuleSettings();

                // Read the result set -- There is only one row!
                while (result.Read())
                {
                    m.ModuleID = (int)result["ModuleID"];
                    m.ModuleDefID = (int)result["ModuleDefID"];
                    m.PageID = (int)result["TabID"];
                    m.PaneName = (string)result["PaneName"];
                    m.ModuleTitle = (string)result["ModuleTitle"];

                    var 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;

                    // [email protected] (19/08/2004) Add support for move & delete module roles
                    myvalue = result["AuthorizedMoveModuleRoles"];
                    m.AuthorizedMoveModuleRoles = !Convert.IsDBNull(myvalue) ? (string)myvalue : string.Empty;

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

                    // Change by [email protected]
                    // Date: 6/2/2003
                    myvalue = result["AuthorizedPublishingRoles"];
                    m.AuthorizedPublishingRoles = !Convert.IsDBNull(myvalue) ? (string)myvalue : string.Empty;

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

                    // Date: 27/2/2003
                    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;

                    // End Change [email protected]
                    // Start Change [email protected]
                    try
                    {
                        myvalue = result["SupportCollapsable"];
                    }
                    catch
                    {
                        myvalue = DBNull.Value;
                    }

                    m.SupportCollapsable = DBNull.Value != myvalue ? (bool)myvalue : false;

                    // End Change  [email protected]
                    // Start Change [email protected]
                    try
                    {
                        myvalue = result["ShowEveryWhere"];
                    }
                    catch
                    {
                        myvalue = DBNull.Value;
                    }

                    m.ShowEveryWhere = DBNull.Value != myvalue ? (bool)myvalue : false;

                    // End Change  [email protected]
                    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;

                    m.DesktopSrc = result["DesktopSrc"].ToString();
                    m.MobileSrc = result["MobileSrc"].ToString();
                    m.Admin = bool.Parse(result["Admin"].ToString());
                }

                return m;
            }
        }
Esempio n. 9
0
 private static IModuleSettings ConvertRb_ModuleToModuleSettings(rb_Modules rbModules, AppleseedDBContext context)
 {
     var guidid = new ModulesDB().GetModuleGuid(rbModules.ModuleID);
     var newmodule = new ModuleSettings
     {
         PageID = rbModules.TabID,
         ModuleID = rbModules.ModuleID,
         PaneName = rbModules.PaneName,
         ModuleTitle = rbModules.ModuleTitle,
         AuthorizedEditRoles = rbModules.AuthorizedEditRoles,
         AuthorizedViewRoles = rbModules.AuthorizedViewRoles,
         AuthorizedAddRoles = rbModules.AuthorizedAddRoles,
         AuthorizedDeleteRoles = rbModules.AuthorizedDeleteModuleRoles,
         AuthorizedPropertiesRoles = rbModules.AuthorizedPropertiesRoles,
         CacheTime = rbModules.CacheTime,
         ModuleOrder = rbModules.ModuleOrder,
         ShowMobile = rbModules.ShowMobile != null && ((rbModules.ShowMobile == null) && (bool)rbModules.ShowMobile),
         DesktopSrc = context.rb_GeneralModuleDefinitions.First(d => d.GeneralModDefID == guidid).DesktopSrc,
         //MobileSrc =  // not supported yet
         SupportCollapsable = rbModules.SupportCollapsable != null && (bool)rbModules.SupportCollapsable,
         ShowEveryWhere = rbModules.ShowEveryWhere != null && (bool)rbModules.ShowEveryWhere,
         GuidID = guidid,
     };
     return newmodule;
 }