コード例 #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Check if the user is authorized
            if (!(PortalSecurity.HasAddPermissions(ModuleID) ||
                  PortalSecurity.HasEditPermissions(ModuleID) ||
                  PortalSecurity.HasDeletePermissions(ModuleID)))
            {
                PortalSecurity.AccessDeniedEdit();
            }

            // Fill email form with default
            if (!IsPostBack)
            {
                // Destinators
                ModuleSettings ms = null;
                for (int i = 0; i < portalSettings.ActiveTab.Modules.Count; i++)
                {
                    ms = (ModuleSettings)portalSettings.ActiveTab.Modules[i];
                    if (ms.ModuleID == ModuleID)
                    {
                        break;
                    }
                }
                string[] emails = MailHelper.GetEmailAddressesInRoles(ms.AuthorizedApproveRoles.Split(";".ToCharArray()), portalSettings.PortalID);
                for (int i = 0; i < emails.Length; i++)
                {
                    emailForm.To.Add(emails[i]);
                }
                // Subject
                emailForm.Subject = Esperantus.Localize.GetString("SWI_REQUEST_APPROVAL_SUBJECT", "Request approval of the new content of '") + ms.ModuleTitle + "'";
                // Message
                emailForm.HtmlBodyText = Esperantus.Localize.GetString("SWI_REQUEST_BODY", "You can find the new content at:") + "<br><br><a href='" + UrlReferrer + "'>" + UrlReferrer + "</a>";
            }
        }
コード例 #2
0
 /// <summary>
 /// Determines whether [has delete permissions] [the specified module ID].
 /// </summary>
 /// <param name="moduleId">
 /// The module ID.
 /// </param>
 /// <param name="itemId">
 /// The item ID.
 /// </param>
 /// <param name="itemUserEmail">
 /// The item user email.
 /// </param>
 /// <returns>
 /// <c>true</c> if [has delete permissions] [the specified module ID]; otherwise, <c>false</c>.
 /// </returns>
 public static bool HasDeletePermissions(int moduleId, int itemId, string itemUserEmail)
 {
     // string currentUserEmail = PortalSettings.CurrentUser.Identity.Email;
     // if true then
     // || currentUserEmail == itemUserEmail))
     // also need to check for NUMBER of children
     // so someone doesn't delte a post with children
     // or just reattach the children
     return(PortalSecurity.HasDeletePermissions(moduleId));
 }
コード例 #3
0
        public static bool HasDeletePermissions(int ModuleID, int itemID, string itemUserEmail)
        {
            string currentUserEmail = PortalSettings.CurrentUser.Identity.Email;

            if (PortalSecurity.HasDeletePermissions(ModuleID) == true)
            {
                // || currentUserEmail == itemUserEmail))
                // also need to check for NUMBER of children
                // so someone doesn't delte a post with children
                // or just reattach the children
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles OnDelete event at Page level<br/>
        /// Performs OnDelete actions that are common to all Pages<br/>
        /// Can be overridden
        /// </summary>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected virtual void OnDelete(EventArgs e)
        {
            if (Delete != null)
            {
                Delete(this, e);   //Invokes the delegates
            }
            //Flush cache
            OnFlushCache();

            // Verify that the current user has access to delete in this module
            if (PortalSecurity.HasDeletePermissions(ModuleID) == false)
            {
                PortalSecurity.AccessDeniedEdit();
            }

            // any other code goes here
        }
コード例 #5
0
        private void Page_Load(object sender, EventArgs e)
        {
            //Check permissions and enable/disable buttons accordingly
            if (!PortalSecurity.IsInRoles("Admins"))
            {
                AddEditControl.AllowAdd    = PortalSecurity.HasAddPermissions(ModuleID);
                AddEditControl.AllowDelete = PortalSecurity.HasDeletePermissions(ModuleID);
                AddEditControl.AllowUpdate = PortalSecurity.HasEditPermissions(ModuleID);
            }

            if (!IsPostBack)
            {
                if (AddEditControl.AllowUpdate && ItemID > 0) //If editing
                {
                    AddEditControl.StartEdit(ItemID.ToString());
                }
            }
        }
コード例 #6
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);
        }
コード例 #7
0
        /// <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 + "'!"));
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Handles the OnInit event at Page level<br/>
        /// Performs OnInit events that are common to all Pages<br/>
        /// Can be overridden
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            LoadSettings();

            //if (cancelButton != null)
            Control myControl = null;

            if (cancelButton != null || (myControl = Page.FindControl("cancelButton")) != null)

            //if ((myControl=Page.FindControl("cancelButton")) != null)
            {
                if (cancelButton == null)
                {
                    cancelButton = (System.Web.UI.WebControls.LinkButton)myControl;
                }

                cancelButton.Click           += new EventHandler(CancelBtn_Click);
                cancelButton.Text             = General.GetString("CANCEL", "Cancel");
                cancelButton.CausesValidation = false;
                cancelButton.EnableViewState  = false;
            }
            //if (updateButton != null)
            if (updateButton != null || (myControl = Page.FindControl("updateButton")) != null)
            {
                if (updateButton == null)
                {
                    updateButton = (System.Web.UI.WebControls.LinkButton)myControl;
                }

                updateButton.Click          += new EventHandler(UpdateBtn_Click);
                updateButton.Text            = General.GetString("APPLY", "Apply", updateButton);
                updateButton.EnableViewState = false;
            }
            //if (deleteButton != null)
            if (deleteButton != null || (myControl = Page.FindControl("deleteButton")) != null)
            {
                if (deleteButton == null)
                {
                    deleteButton = (System.Web.UI.WebControls.LinkButton)myControl;
                }

                deleteButton.Click          += new EventHandler(DeleteBtn_Click);
                deleteButton.Text            = General.GetString("DELETE", "Delete", deleteButton);
                deleteButton.EnableViewState = false;

                // Assign current permissions to Delete button
                if (PortalSecurity.HasDeletePermissions(ModuleID) == false)
                {
                    deleteButton.Visible = false;
                }
                else
                {
                    if (!(ClientScript.IsClientScriptBlockRegistered("confirmDelete")))
                    {
                        string[] s = { "CONFIRM_DELETE" };
                        ClientScript.RegisterClientScriptBlock(GetType(), "confirmDelete",
                                                               PortalSettings.GetStringResource(
                                                                   "CONFIRM_DELETE_SCRIPT",
                                                                   s));
                    }
                    deleteButton.Attributes.Add("OnClick", "return confirmDelete()");
                }
            }
            ModuleGuidInCookie();

            base.OnInit(e);
        }
コード例 #9
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 + "'!"));
                        }
                    }
                }
            }
        }