Beispiel #1
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);
            }
        }
        /// <summary>
        /// Gets the current profile control.
        /// </summary>
        /// <returns></returns>
        public static Control GetCurrentProfileControl()
        {
            //default
            string RegisterPage = "Register.ascx";

            // 19/08/2004 Jonathan Fong
            // www.gt.com.au
            RainbowPrincipal user = HttpContext.Current.User as RainbowPrincipal;

            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            //Select the actual register page
            if (portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"] != null &&
                portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"].ToString() != "Register.ascx")
            {
                RegisterPage = portalSettings.CustomSettings["SITESETTINGS_REGISTER_TYPE"].ToString();
            }
            System.Web.UI.Page x = new System.Web.UI.Page();

            // Modified by gman3001 10/06/2004, to support proper loading of a register module specified by 'Register Module ID' setting in the Portal Settings admin page
            int    moduleID         = int.Parse(portalSettings.CustomSettings["SITESETTINGS_REGISTER_MODULEID"].ToString());
            string moduleDesktopSrc = string.Empty;

            if (moduleID > 0)
            {
                moduleDesktopSrc = ModuleSettings.GetModuleDesktopSrc(moduleID);
            }
            if (moduleDesktopSrc.Length == 0)
            {
                moduleDesktopSrc = RegisterPage;
            }
            Control myControl = x.LoadControl(moduleDesktopSrc);
            // End Modification by gman3001

            PortalModuleControl p = ((PortalModuleControl)myControl);

            //p.ModuleID = int.Parse(portalSettings.CustomSettings["SITESETTINGS_REGISTER_MODULEID"].ToString());
            p.ModuleID = moduleID;
            if (p.ModuleID == 0)
            {
                ((SettingItem)p.Settings["MODULESETTINGS_SHOW_TITLE"]).Value = "false";
            }
            return((Control)p);

            return(null);
        }
Beispiel #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="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            foreach (ModuleSettings module in this.PortalSettings.ActivePage.Modules)
            {
                if (this.Request.Params["ModID"] != null && module.ModuleID == int.Parse(this.Request.Params["ModID"]))
                {
                    // create an instance of the module
                    PortalModuleControl myPortalModule = (PortalModuleControl)LoadControl(Path.ApplicationRoot + "/" + module.DesktopSrc);
                    myPortalModule.PortalID            = this.PortalSettings.PortalID;
                    myPortalModule.ModuleConfiguration = module;

                    // add the module to the placeholder
                    PrintPlaceHolder.Controls.Add(myPortalModule);

                    break;
                }
            }
        }
        /// <summary>
        /// The CreateChildControls method is called when the ASP.NET Page Framework
        /// determines that it is time to instantiate a server control.<br/>
        /// The CachedPortalModuleControl control overrides this method and attempts
        /// to resolve any previously cached output of the portal module from the ASP.NET cache.
        /// If it doesn't find cached output from a previous request, then the
        /// CachedPortalModuleControl will instantiate and add the portal module's
        /// User Control instance into the page tree.
        /// </summary>
        protected override void CreateChildControls()
        {
            // Attempt to resolve previously cached content from the ASP.NET Cache
            if (_moduleConfiguration.CacheTime > 0)
            {
                _cachedOutput = (string)Context.Cache[CacheKey];
            }

            // If no cached content is found, then instantiate and add the portal
            // module user control into the portal's page server control tree
            if (_cachedOutput == null)
            {
                base.CreateChildControls();

                PortalModuleControl module = (PortalModuleControl)Page.LoadControl(_moduleConfiguration.DesktopSrc);

                module.ModuleConfiguration = ModuleConfiguration;
                module.PortalID            = PortalID;

                Controls.Add(module);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Uninstalls the specified desktop source.
        /// </summary>
        /// <param name="desktopSource">The desktop source.</param>
        /// <param name="mobileSource">The mobile source.</param>
        public static void Uninstall(string desktopSource, string mobileSource)
        {
            Page page = new Page();

            // Istantiate the module
            PortalModuleControl portalModule =
                (PortalModuleControl)page.LoadControl(Path.ApplicationRoot + "/" + desktopSource);

            //Call Uninstall
            try
            {
                portalModule.Uninstall(null);
            }
            catch (Exception ex)
            {
                //Rethrow exception
                throw new Exception("Exception during uninstall!", ex);
            }

            // Delete definition
            new ModulesDB().DeleteModuleDefinition(portalModule.GuidID);
        }
Beispiel #6
0
        public rb_Modules TranslateModulesDTOIntoRb_Modules(ModulesDTO module)
        {
            if (this.DesktopSources.ContainsKey(module.ModuleDefinitions.GeneralModDefID))
            {
                rb_Modules _module = new rb_Modules();
                _module.AuthorizedAddRoles          = module.AuthorizedAddRoles;
                _module.AuthorizedApproveRoles      = module.AuthorizedApproveRoles;
                _module.AuthorizedDeleteModuleRoles = module.AuthorizedDeleteModuleRoles;
                _module.AuthorizedDeleteRoles       = module.AuthorizedDeleteRoles;
                _module.AuthorizedEditRoles         = module.AuthorizedEditRoles;
                _module.AuthorizedMoveModuleRoles   = module.AuthorizedMoveModuleRoles;
                _module.AuthorizedPropertiesRoles   = module.AuthorizedPropertiesRoles;
                _module.AuthorizedPublishingRoles   = module.AuthorizedPublishingRoles;
                _module.AuthorizedViewRoles         = module.AuthorizedViewRoles;
                _module.CacheTime           = module.CacheTime;
                _module.LastEditor          = module.LastEditor;
                _module.LastModified        = module.LastModified;
                _module.ModuleDefID         = module.ModuleDefID;
                _module.ModuleID            = module.ModuleID;
                _module.ModuleOrder         = module.ModuleOrder;
                _module.ModuleTitle         = module.ModuleTitle;
                _module.NewVersion          = module.NewVersion;
                _module.PaneName            = module.PaneName;
                _module.ShowEveryWhere      = module.ShowEveryWhere;
                _module.ShowMobile          = module.ShowMobile;
                _module.StagingLastEditor   = module.StagingLastEditor;
                _module.StagingLastModified = module.StagingLastModified;
                _module.SupportCollapsable  = module.SupportCollapsable;
                _module.SupportWorkflow     = module.SupportWorkflow;
                _module.TabID         = module.TabID;
                _module.WorkflowState = module.WorkflowState;

                _module.rb_ModuleSettings = new EntitySet <rb_ModuleSettings>();
                foreach (ModuleSettingsDTO m in module.ModuleSettings)
                {
                    _module.rb_ModuleSettings.Add(TranslateModuleSettingsDTOIntoRb_ModuleSettings(m));
                }

                if (this.ModuleDefinitionsDeserialized.ContainsKey(module.ModuleDefinitions.GeneralModDefID))
                {
                    rb_ModuleDefinition def = this.ModuleDefinitionsDeserialized[module.ModuleDefinitions.GeneralModDefID];
                    _module.rb_ModuleDefinition = def;
                }
                else
                {
                    _module.rb_ModuleDefinition = TranslateModuleDefinitionsDTOIntoRb_ModuleDefinitions(module.ModuleDefinitions);
                    this.ModuleDefinitionsDeserialized.Add(module.ModuleDefinitions.GeneralModDefID, _module.rb_ModuleDefinition);
                }

                Page   p = new Page();
                string portalModuleName = string.Concat(Appleseed.Framework.Settings.Path.ApplicationRoot, "/", this.DesktopSources[_module.rb_ModuleDefinition.GeneralModDefID]);
                if (!portalModuleName.Contains("/Areas/") && !portalModuleName.StartsWith("Areas/"))
                {
                    PortalModuleControl portalModule = (PortalModuleControl)p.LoadControl(portalModuleName);

                    if (portalModule is IModuleExportable)
                    {
                        this.ContentModules.Add(moduleIndex, module.Content);
                        //((IModuleExportable)portalModule).SetContentData(modules.ModuleID, modules.Content, this.PTDataContext);
                    }
                }
                moduleIndex++;

                return(_module);
            }
            else
            {
                moduleIndex++;
                this.ModulesNotInserted.Add(module.ModuleID, module.ModuleTitle);
                return(null);
            }
        }
        /// <summary>
        /// The BindData helper method is used to populate a asp:datalist
        ///   server control with the current "edit access" permissions
        ///   set within the portal configuration system
        /// </summary>
        private void BindData()
        {
            var useNTLM = HttpContext.Current.User is WindowsPrincipal;

            // add by Jonathan Fong 22/07/2004 to support LDAP
            // jes1111 - useNTLM |= ConfigurationSettings.AppSettings["LDAPLogin"] != null ? true : false;
            useNTLM |= Config.LDAPLogin.Length != 0 ? true : false;

            this.authAddRoles.Visible                                      =
                this.authApproveRoles.Visible                              =
                    this.authDeleteRoles.Visible                           =
                        this.authEditRoles.Visible                         =
                            this.authPropertiesRoles.Visible               =
                                this.authPublishingRoles.Visible           =
                                    this.authMoveModuleRoles.Visible       =
                                        this.authDeleteModuleRoles.Visible = this.authViewRoles.Visible = !useNTLM;
            var m = this.GetModule();

            if (m != null)
            {
                this.moduleType.Text = GiveMeFriendlyName(m.GuidID);

                // Update Textbox Settings
                this.moduleTitle.Text = m.ModuleTitle;
                this.cacheTime.Text   = m.CacheTime.ToString();

                this.portalTabs = new PagesDB().GetPagesFlat(this.PortalSettings.PortalID);
                this.tabDropDownList.DataBind();
                this.tabDropDownList.ClearSelection();
                if (this.tabDropDownList.Items.FindByValue(m.PageID.ToString()) != null)
                {
                    this.tabDropDownList.Items.FindByValue(m.PageID.ToString()).Selected = true;
                }

                // Change by [email protected]
                // Date: 19/5/2003
                this.showEveryWhere.Checked = m.ShowEveryWhere;

                // is the window mgmt support enabled
                // jes1111 - allowCollapsable.Enabled = GlobalResources.SupportWindowMgmt;
                this.allowCollapsable.Enabled = Config.WindowMgmtControls;
                this.allowCollapsable.Checked = m.SupportCollapsable;

                this.ShowMobile.Checked = m.ShowMobile;

                // Change by [email protected]
                // Date: 6/2/2003
                PortalModuleControl pm = null;
                var controlPath        = Path.WebPathCombine(Path.ApplicationRoot, m.DesktopSrc);

                try
                {
                    if (!controlPath.Contains("Area"))
                    {
                        pm = (PortalModuleControl)this.LoadControl(controlPath);
                        if (pm.InnerSupportsWorkflow)
                        {
                            this.enableWorkflowSupport.Checked = m.SupportWorkflow;
                            this.authApproveRoles.Enabled      = m.SupportWorkflow;
                            this.authPublishingRoles.Enabled   = m.SupportWorkflow;
                            this.PopulateRoles(ref this.authPublishingRoles, m.AuthorizedPublishingRoles);
                            this.PopulateRoles(ref this.authApproveRoles, m.AuthorizedApproveRoles);
                        }
                        else
                        {
                            this.enableWorkflowSupport.Enabled = false;
                            this.authApproveRoles.Enabled      = false;
                            this.authPublishingRoles.Enabled   = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    // ErrorHandler.HandleException("There was a problem loading: '" + controlPath + "'", ex);
                    // throw;
                    throw new AppleseedException(
                              LogLevel.Error, "There was a problem loading: '" + controlPath + "'", ex);
                }

                // End Change [email protected]

                // Populate checkbox list with all security roles for this portal
                // and "check" the ones already configured for this module
                this.PopulateRoles(ref this.authEditRoles, m.AuthorizedEditRoles);
                this.PopulateRoles(ref this.authViewRoles, m.AuthorizedViewRoles);
                this.PopulateRoles(ref this.authAddRoles, m.AuthorizedAddRoles);
                this.PopulateRoles(ref this.authDeleteRoles, m.AuthorizedDeleteRoles);
                this.PopulateRoles(ref this.authMoveModuleRoles, m.AuthorizedMoveModuleRoles);
                this.PopulateRoles(ref this.authDeleteModuleRoles, m.AuthorizedDeleteModuleRoles);
                this.PopulateRoles(ref this.authPropertiesRoles, m.AuthorizedPropertiesRoles);

                // Jes1111
                if (pm != null)
                {
                    if (!pm.Cacheable)
                    {
                        this.cacheTime.Text    = "-1";
                        this.cacheTime.Enabled = false;
                    }
                }
            }
            else
            {
                // Denied access if Module not in Tab. [email protected] (2004/07/23)
                PortalSecurity.AccessDenied();
            }
        }
Beispiel #8
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>
 static public bool IsMDFApplied(PortalModuleControl pmc)
 {
     return(bool.Parse(pmc.Settings[NameApplyMDF].ToString()));
 }
Beispiel #9
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);
 }
Beispiel #10
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);
        }
Beispiel #11
0
        /// <summary>
        /// Installs module
        /// </summary>
        /// <param name="friendlyName">Name of the friendly.</param>
        /// <param name="desktopSource">The desktop source.</param>
        /// <param name="mobileSource">The mobile source.</param>
        /// <param name="install">if set to <c>true</c> [install].</param>
        public static void Install(string friendlyName, string desktopSource, string mobileSource, bool install)
        {
            ErrorHandler.Publish(LogLevel.Info,
                                 "Installing DesktopModule '" + friendlyName + "' from '" + desktopSource + "'");
            if (mobileSource != null && mobileSource.Length > 0)
            {
                ErrorHandler.Publish(LogLevel.Info,
                                     "Installing MobileModule '" + friendlyName + "' from '" + mobileSource + "'");
            }

            string controlFullPath = Path.ApplicationRoot + "/" + desktopSource;

            // Instantiate the module
            Page page = new Page();
            //http://sourceforge.net/tracker/index.php?func=detail&aid=738670&group_id=66837&atid=515929
            //Rainbow.Framework.Web.UI.Page page = new Rainbow.Framework.Web.UI.Page();

            Control myControl = page.LoadControl(controlFullPath);

            if (!(myControl is PortalModuleControl))
            {
                throw new Exception("Module '" + myControl.GetType().FullName + "' is not a PortalModule Control");
            }

            PortalModuleControl portalModule = (PortalModuleControl)myControl;

            // Check mobile module
            if (mobileSource != null && mobileSource.Length != 0 && mobileSource.ToLower().EndsWith(".ascx"))
            {
                //TODO: Check mobile module
                //TODO: MobilePortalModuleControl mobileModule = (MobilePortalModuleControl) page.LoadControl(Rainbow.Framework.Settings.Path.ApplicationRoot + "/" + mobileSource);
                if (!File.Exists(HttpContext.Current.Server.MapPath(Path.ApplicationRoot + "/" + mobileSource)))
                {
                    throw new FileNotFoundException("Mobile Control not found");
                }
            }

            // Get Module ID
            Guid defID = portalModule.GuidID;

            //Get Assembly name
            string assemblyName = portalModule.GetType().BaseType.Assembly.CodeBase;

            assemblyName = assemblyName.Substring(assemblyName.LastIndexOf('/') + 1); //Get name only

            // Get Module Class name
            string className = portalModule.GetType().BaseType.FullName;

            // Now we add the definition to module list
            ModulesDB modules = new ModulesDB();

            if (install)
            {
                //Install as new module

                //Call Install
                try
                {
                    ErrorHandler.Publish(LogLevel.Debug, "Installing '" + friendlyName + "' as new module.");
                    portalModule.Install(null);
                }
                catch (Exception ex)
                {
                    //Error occurred
                    portalModule.Rollback(null);
                    //Rethrow exception
                    throw new Exception("Exception occurred installing '" + portalModule.GuidID.ToString() + "'!", ex);
                }

                try
                {
                    // Add a new module definition to the database
                    modules.AddGeneralModuleDefinitions(defID, friendlyName, desktopSource, mobileSource, assemblyName,
                                                        className, portalModule.AdminModule, portalModule.Searchable);
                }
                catch (Exception ex)
                {
                    //Rethrow exception
                    throw new Exception(
                              "AddGeneralModuleDefinitions Exception '" + portalModule.GuidID.ToString() + "'!", ex);
                }

                // All is fine: we can call Commit
                portalModule.Commit(null);
            }
            else
            {
                // Update the general module definition
                try
                {
                    ErrorHandler.Publish(LogLevel.Debug, "Updating '" + friendlyName + "' as new module.");
                    modules.UpdateGeneralModuleDefinitions(defID, friendlyName, desktopSource, mobileSource,
                                                           assemblyName, className, portalModule.AdminModule,
                                                           portalModule.Searchable);
                }
                catch (Exception ex)
                {
                    //Rethrow exception
                    throw new Exception(
                              "UpdateGeneralModuleDefinitions Exception '" + portalModule.GuidID.ToString() + "'!", ex);
                }
            }

            // Update the module definition - install for portal 0
            modules.UpdateModuleDefinitions(defID, 0, true);
        }
        /// <summary>
        /// This method determines the tab index of the currently
        /// requested portal view, and then dynamically populate the left,
        /// center and right hand sections of the portal tab.
        /// </summary>
        protected override void InitializeDataSource()
        {
            base.InitializeDataSource();

            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            // Dynamically Populate the Left, Center and Right pane sections of the portal page
            if (portalSettings.ActivePage.Modules.Count > 0)
            {
                // Loop through each entry in the configuration system for this tab
                foreach (ModuleSettings _moduleSettings in portalSettings.ActivePage.Modules)
                {
                    if (!_moduleSettings.Cacheable)
                    {
                        _moduleSettings.CacheTime = -1;                             // Disable cache
                    }
                    // NEW MODULE_VIEW PERMISSIONS ADDED
                    // Ensure that the visiting user has access to view the current module
                    if (PortalSecurity.IsInRoles(_moduleSettings.AuthorizedViewRoles) == true)
                    {
                        ArrayList arrayData;

                        switch (_moduleSettings.PaneName.ToLower())
                        {
                        case "leftpane":
                            arrayData = DataSource[IDX_LEFT_PANE_DATA];
                            break;

                        case "contentpane":
                            arrayData = DataSource[IDX_CONTENT_PANE_DATA];
                            break;

                        case "rightpane":
                            arrayData = DataSource[IDX_RIGHT_PANE_DATA];
                            break;

                        default:
                            arrayData = DataSource[IDX_CONTENT_PANE_DATA];
                            break;
                        }

                        // If no caching is specified, create the user control instance and dynamically
                        // inject it into the page.  Otherwise, create a cached module instance that
                        // may or may not optionally inject the module into the tree

                        //Cache. If == 0 then override with default cache in web.config
// jes1111
//						if(ConfigurationSettings.AppSettings["ModuleOverrideCache"] != null
//							&& !_moduleSettings.Admin
//							&& _moduleSettings.CacheTime == 0)
                        if (!_moduleSettings.Admin && _moduleSettings.CacheTime == 0)
                        {
                            //jes1111 - int mCache = Int32.Parse(ConfigurationSettings.AppSettings["ModuleOverrideCache"]);
                            int mCache = Config.ModuleOverrideCache;
                            if (mCache > 0)
                            {
                                _moduleSettings.CacheTime = mCache;
                            }
                        }

                        // Change 28/Feb/2003 Jeremy Esland - added security settings to condition test so that a user who has
                        // edit or properties permission will not cause the module output to be cached.
                        if (
                            ((_moduleSettings.CacheTime) <= 0) ||
                            (PortalSecurity.HasEditPermissions(_moduleSettings.ModuleID)) ||
                            (PortalSecurity.HasPropertiesPermissions(_moduleSettings.ModuleID)) ||
                            (PortalSecurity.HasAddPermissions(_moduleSettings.ModuleID)) ||
                            (PortalSecurity.HasDeletePermissions(_moduleSettings.ModuleID))
                            )
                        {
                            try
                            {
                                string portalModuleName =
                                    string.Concat(Path.ApplicationRoot, "/", _moduleSettings.DesktopSrc);
                                PortalModuleControl portalModule =
                                    (PortalModuleControl)Page.LoadControl(portalModuleName);

                                portalModule.PortalID            = portalSettings.PortalID;
                                portalModule.ModuleConfiguration = _moduleSettings;

                                //TODO: This is not the best place: should be done early
                                if (portalModule.Cultures == string.Empty ||
                                    (portalModule.Cultures + ";").IndexOf(portalSettings.PortalContentLanguage.Name +
                                                                          ";") >= 0)
                                {
                                    arrayData.Add(portalModule);
                                }
                            }
                            catch (Exception ex)
                            {
                                //ErrorHandler.HandleException("DesktopPanes: Unable to load control '" + _moduleSettings.DesktopSrc + "'!", ex);
                                ErrorHandler.Publish(LogLevel.Error,
                                                     "DesktopPanes: Unable to load control '" +
                                                     _moduleSettings.DesktopSrc + "'!", ex); // jes1111
                                if (PortalSecurity.IsInRoles("Admins"))
                                {
                                    arrayData.Add(
                                        new LiteralControl("<br><span class=NormalRed>" + "Unable to load control '" +
                                                           _moduleSettings.DesktopSrc +
                                                           "'! (Full Error Logged)<br />Error Message: " +
                                                           ex.Message.ToString()));
                                }
                                else
                                {
                                    arrayData.Add(
                                        new LiteralControl("<br><span class=NormalRed>" + "Unable to load control '" +
                                                           _moduleSettings.DesktopSrc + "'!"));
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                using (CachedPortalModuleControl portalModule = new CachedPortalModuleControl())
                                {
                                    portalModule.PortalID            = portalSettings.PortalID;
                                    portalModule.ModuleConfiguration = _moduleSettings;

                                    arrayData.Add(portalModule);
                                }
                            }
                            catch (Exception ex)
                            {
                                //ErrorHandler.HandleException("DesktopPanes: Unable to load cached control '" + _moduleSettings.DesktopSrc + "'!", ex);
                                ErrorHandler.Publish(LogLevel.Error,
                                                     "DesktopPanes: Unable to load cached control '" +
                                                     _moduleSettings.DesktopSrc + "'!", ex);
                                if (PortalSecurity.IsInRoles("Admins"))
                                {
                                    arrayData.Add(
                                        new LiteralControl("<br><span class=NormalRed>" +
                                                           "Unable to load cached control '" +
                                                           _moduleSettings.DesktopSrc +
                                                           "'! (Full Error Logged)<br />Error Message: " +
                                                           ex.Message.ToString()));
                                }
                                else
                                {
                                    arrayData.Add(
                                        new LiteralControl("<br><span class=NormalRed>" +
                                                           "Unable to load cached control '" +
                                                           _moduleSettings.DesktopSrc + "'!"));
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #13
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);
        }
Beispiel #14
0
        /// <summary>
        /// Initialize internal data source
        /// </summary>
        public void InitializeDataSource()
        {
            innerDataSource = new ArrayList();

            // Obtain PortalSettings from Current Context
            PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

            // Loop through each entry in the configuration system for this tab
            // Ensure that the visiting user has access to view the module
            foreach (ModuleSettings _moduleSettings in portalSettings.ActivePage.Modules)
            {
                if (_moduleSettings.PaneName.ToLower() == Content.ToLower() &&
                    PortalSecurity.IsInRoles(_moduleSettings.AuthorizedViewRoles))
                {
                    //Cache. If == 0 then override with default cache in web.config
                    if (ConfigurationManager.AppSettings["ModuleOverrideCache"] != null &&
                        !_moduleSettings.Admin &&
                        _moduleSettings.CacheTime == 0)
                    {
                        int mCache = Int32.Parse(ConfigurationManager.AppSettings["ModuleOverrideCache"]);
                        if (mCache > 0)
                        {
                            _moduleSettings.CacheTime = mCache;
                        }
                    }

                    // added security settings to condition test so that a user who has
                    // edit or properties permission will not cause the module output to be cached.
                    if (
                        ((_moduleSettings.CacheTime) <= 0) ||
                        (PortalSecurity.HasEditPermissions(_moduleSettings.ModuleID)) ||
                        (PortalSecurity.HasPropertiesPermissions(_moduleSettings.ModuleID)) ||
                        (PortalSecurity.HasAddPermissions(_moduleSettings.ModuleID)) ||
                        (PortalSecurity.HasDeletePermissions(_moduleSettings.ModuleID))
                        )
                    {
                        try
                        {
                            string portalModuleName =
                                string.Concat(Path.ApplicationRoot, "/", _moduleSettings.DesktopSrc);
                            PortalModuleControl portalModule = (PortalModuleControl)Page.LoadControl(portalModuleName);

                            portalModule.PortalID            = portalSettings.PortalID;
                            portalModule.ModuleConfiguration = _moduleSettings;

                            //TODO: This is not the best place: should be done early
                            if ((portalModule.Cultures != null && portalModule.Cultures.Length == 0) ||
                                (portalModule.Cultures + ";").IndexOf(portalSettings.PortalContentLanguage.Name + ";") >=
                                0)
                            {
                                innerDataSource.Add(portalModule);
                            }
                        }
                        catch (Exception ex)
                        {
                            ErrorHandler.Publish(LogLevel.Error,
                                                 "ZenLayout: Unable to load control '" + _moduleSettings.DesktopSrc +
                                                 "'!", ex);
                            innerDataSource.Add(
                                new LiteralControl("<br><span class=\"NormalRed\">" +
                                                   "ZenLayout: Unable to load control '" + _moduleSettings.DesktopSrc +
                                                   "'!"));
                        }
                    }
                    else
                    {
                        try
                        {
                            CachedPortalModuleControl portalModule = new CachedPortalModuleControl();

                            portalModule.PortalID            = portalSettings.PortalID;
                            portalModule.ModuleConfiguration = _moduleSettings;

                            innerDataSource.Add(portalModule);
                        }
                        catch (Exception ex)
                        {
                            ErrorHandler.Publish(LogLevel.Error,
                                                 "ZenLayout: Unable to load cached control '" +
                                                 _moduleSettings.DesktopSrc + "'!", ex);
                            innerDataSource.Add(
                                new LiteralControl("<br><span class=\"NormalRed\">" +
                                                   "ZenLayout: Unable to load cached control '" +
                                                   _moduleSettings.DesktopSrc + "'!"));
                        }
                    }
                }
            }
        }