示例#1
0
        /// <summary>
        /// Fills all MDF settings. Returns true if no problems reading and
        /// parsing all MDF settings.
        /// </summary>
        /// <param name="pmc">The PMC.</param>
        /// <param name="itemTableName">Name of the item table.</param>
        /// <param name="titleFieldName">Name of the title field.</param>
        /// <param name="selectFieldList">The select field list.</param>
        /// <param name="searchFieldList">The search field list.</param>
        /// <returns></returns>
        public bool Populate(PortalModuleControl pmc, string itemTableName, string titleFieldName, string selectFieldList, string searchFieldList)
        {
            bool PopulateDone;
            try
            {
                _applyMDF = bool.Parse(pmc.Settings[NameApplyMDF].ToString());

                string ds = pmc.Settings[NameDataSource].ToString();
                if (ds == DataSourceType.This.ToString())
                    _dataSource = DataSourceType.This;
                else if (ds == DataSourceType.All.ToString())
                    _dataSource = DataSourceType.All;
                else if (ds == DataSourceType.List.ToString())
                    _dataSource = DataSourceType.List;

                _maxHits = int.Parse(pmc.Settings[NameMaxHits].ToString());
                _moduleList = pmc.Settings[NameModuleList].ToString();
                _allNotInList = bool.Parse(pmc.Settings[NameAllNotInList].ToString());
                _sortField = pmc.Settings[NameSortField].ToString();
                _sortDirection = pmc.Settings[NameSortDirection].ToString();
                _searchString = pmc.Settings[NameSearchString].ToString();
                _searchField = pmc.Settings[NameSearchField].ToString();
                _mobileOnly = bool.Parse(pmc.Settings[NameMobileOnly].ToString());

                if (_dataSource == DataSourceType.This)
                    _moduleList = pmc.ModuleID.ToString();

                if (_moduleList == "" && _dataSource == DataSourceType.List)
                {
                    // Create data to lazy user that forgot to enter data in field Module List
                    _moduleList = pmc.ModuleID.ToString();
                }

                if (pmc.SupportsWorkflow)
                {
                    _supportsWorkflow = pmc.SupportsWorkflow;
                    _workflowVersion = pmc.Version;
                }

                _itemTableName = itemTableName;
                _titleFieldName = titleFieldName;
                _selectFieldList = selectFieldList;
                _searchFieldList = searchFieldList;

                _portalID = pmc.PortalID;
                UsersDB u = new UsersDB();
                SqlDataReader dr = u.GetSingleUser(PortalSettings.CurrentUser.Identity.Email);
                if (dr.Read())
                    _userID = Int32.Parse(dr["UserID"].ToString());

                PopulateDone = true;
            }
            catch (Exception)
            {
                PopulateDone = false;
            }
            return PopulateDone;
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the MDFSetting object with real settings
 /// </summary>
 /// <param name="pmc">The PMC.</param>
 /// <param name="itemTableName">Name of the item table.</param>
 /// <param name="titleFieldName">Name of the title field.</param>
 /// <param name="selectFieldList">The select field list.</param>
 /// <param name="searchFieldList">The search field list.</param>
 public MDFSettings(PortalModuleControl pmc, string itemTableName, string titleFieldName, string selectFieldList, string searchFieldList)
 {
     Populate(pmc, itemTableName, titleFieldName, selectFieldList, searchFieldList);
 }
示例#3
0
 /// <summary>
 /// Retuns true if the module is using MDF.
 /// </summary>
 /// <param name="pmc">The PMC.</param>
 /// <returns>
 /// 	<c>true</c> if [is MDF applied] [the specified PMC]; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsMDFApplied(PortalModuleControl pmc)
 {
     return bool.Parse(pmc.Settings[NameApplyMDF].ToString());
 }
示例#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);
        }