예제 #1
0
 /// <summary>
 /// Handles OnUpdate event
 /// </summary>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected override void OnUpdate(EventArgs e)
 {
     // Verify that the current user has access to add in this module
     if (PortalSecurity.HasPropertiesPermissions(ModuleID) == false)
     {
         // Removed by Mario Endara <*****@*****.**> (2004/11/04)
         //				&& PortalSecurity.IsInRoles("Admins") == false)
         PortalSecurity.AccessDeniedEdit();
     }
     base.OnUpdate(e);
 }
예제 #2
0
        /// <summary>
        /// Load settings
        /// </summary>
        protected override void LoadSettings()
        {
            // Verify that the current user has access to edit this module
            if (PortalSecurity.HasPropertiesPermissions(this.ModuleID) == false)
            {
                // Removed by Mario Endara <*****@*****.**> (2004/11/04)
                // && PortalSecurity.IsInRoles("Admins") == false)
                PortalSecurity.AccessDeniedEdit();
            }

            base.LoadSettings();
        }
예제 #3
0
        /// <summary>
        /// Convert the module list to dictionary.
        /// </summary>
        /// <param name="modules"></param>
        /// <returns>A dictionary</returns>
        /// <exception cref="Exception"></exception>
        private static Dictionary <string, List <Control> > ConvertModuleListToDictionary(List <IModuleSettings> modules)
        {
            var     settings     = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
            var     dictionary   = new Dictionary <string, List <Control> >();
            dynamic faultyModule = null;
            var     modErrKey    = HttpContext.Current.Request.Params["modErr"];

            //we receive this param if in the Application_Error it was discovered that a module is broken
            if (!string.IsNullOrEmpty(modErrKey))
            {
                faultyModule = HttpContext.Current.Cache.Get(modErrKey);
                HttpContext.Current.Cache.Remove(modErrKey);
            }

            if (modules.Count > 0)
            {
                var page = new Page();
                foreach (ModuleSettings settings2 in modules)
                {
                    if (!settings2.Cacheable)
                    {
                        settings2.CacheTime = -1;
                    }

                    if (PortalSecurity.IsInRoles(settings2.AuthorizedViewRoles))
                    {
                        List <Control> list;
                        Exception      exception;
                        var            str = settings2.PaneName.ToLower();
                        if (!string.IsNullOrEmpty(str))
                        {
                            if (!dictionary.ContainsKey(str))
                            {
                                dictionary.Add(str, new List <Control>());
                            }

                            list = dictionary[str];
                        }
                        else
                        {
                            if (!dictionary.ContainsKey("contentpane"))
                            {
                                dictionary.Add("contentpane", new List <Control>());
                            }

                            list = dictionary["contentpane"];
                        }

                        if (!settings2.Admin && (settings2.CacheTime == 0))
                        {
                            var moduleOverrideCache = Config.ModuleOverrideCache;
                            if (moduleOverrideCache > 0)
                            {
                                settings2.CacheTime = moduleOverrideCache;
                            }
                        }

                        if ((((settings2.CacheTime <= 0) || PortalSecurity.HasEditPermissions(settings2.ModuleID)) ||
                             (PortalSecurity.HasPropertiesPermissions(settings2.ModuleID) ||
                              PortalSecurity.HasAddPermissions(settings2.ModuleID))) ||
                            PortalSecurity.HasDeletePermissions(settings2.ModuleID))
                        {
                            try
                            {
                                PortalModuleControl control;
                                var virtualPath = Path.ApplicationRoot + "/" + settings2.DesktopSrc;
                                if (virtualPath.ToLowerInvariant().Trim().EndsWith(".ascx"))
                                {
                                    if (faultyModule != null && faultyModule.ModuleDefID == settings2.ModuleDefID)
                                    {
                                        throw new Exception(faultyModule.Message); //if this was the module that was generating the error, we then show the error.
                                    }
                                    control = (PortalModuleControl)page.LoadControl(virtualPath);
                                }
                                else
                                {
                                    var strArray = virtualPath.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];
                                    control =
                                        (PortalModuleControl)
                                        page.LoadControl("~/DesktopModules/CoreModules/MVC/MVCModule.ascx");

                                    ((MVCModuleControl)control).ControllerName = controllerName;
                                    ((MVCModuleControl)control).ActionName     = actionName;
                                    ((MVCModuleControl)control).AreaName       = areaName;
                                    ((MVCModuleControl)control).ModID          = settings2.ModuleID;

                                    ((MVCModuleControl)control).Initialize();
                                }

                                control.PortalID            = settings.PortalID;
                                control.ModuleConfiguration = settings2;
                                if ((control.Cultures == string.Empty) ||
                                    ((control.Cultures + ";").IndexOf(settings.PortalContentLanguage.Name + ";") >= 0))
                                {
                                    list.Add(control);
                                }
                            }
                            catch (Exception exception1)
                            {
                                exception = exception1;
                                ErrorHandler.Publish(
                                    LogLevel.Error,
                                    string.Format("DesktopPanes: Unable to load control '{0}'!", settings2.DesktopSrc),
                                    exception);
                                if (PortalSecurity.IsInRoles("Admins"))
                                {
                                    list.Add(
                                        new LiteralControl(
                                            string.Format("<br><span class=NormalRed>Unable to load control '{0}'! (Full Error Logged)<br />Error Message: {1}", settings2.DesktopSrc, exception.Message)));
                                }
                                else
                                {
                                    list.Add(
                                        new LiteralControl(
                                            string.Format("<br><span class=NormalRed>Unable to load control '{0}'!", settings2.DesktopSrc)));
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                using (var control2 = new CachedPortalModuleControl())
                                {
                                    control2.PortalID            = settings.PortalID;
                                    control2.ModuleConfiguration = settings2;
                                    list.Add(control2);
                                }
                            }
                            catch (Exception exception2)
                            {
                                exception = exception2;
                                ErrorHandler.Publish(
                                    LogLevel.Error,
                                    string.Format("DesktopPanes: Unable to load cached control '{0}'!", settings2.DesktopSrc),
                                    exception);
                                if (PortalSecurity.IsInRoles("Admins"))
                                {
                                    list.Add(
                                        new LiteralControl(
                                            string.Format("<br><span class=NormalRed>Unable to load cached control '{0}'! (Full Error Logged)<br />Error Message: {1}", settings2.DesktopSrc, exception.Message)));
                                }
                                else
                                {
                                    list.Add(
                                        new LiteralControl(
                                            string.Format("<br><span class=NormalRed>Unable to load cached control '{0}'!", settings2.DesktopSrc)));
                                }
                            }
                        }
                    }
                }
            }
            return(dictionary);
        }
        /// <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 + "'!"));
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #5
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 + "'!"));
                        }
                    }
                }
            }
        }