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>";
            }
        }
 /// <summary>
 /// See whether the current user has permissions to add a post to the discussion thread
 /// </summary>
 /// <param name="ModuleID">ID of the current Discussion Module</param>
 /// <returns>Returns true or flase</returns>
 public static bool HasAddPermissions(int ModuleID)
 {
     if (PortalSecurity.HasAddPermissions(ModuleID) == true)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Load settings
 /// </summary>
 protected override void LoadSettings()
 {
     // Verify that the current user has access to edit this module
     // Removed by Mario Endara <*****@*****.**> (2004/11/04)
     //			if (PortalSecurity.HasAddPermissions(ModuleID) == false && PortalSecurity.IsInRoles("Admins") == false)
     if (PortalSecurity.HasAddPermissions(ModuleID) == false)
     {
         PortalSecurity.AccessDeniedEdit();
     }
     base.LoadSettings();
 }
 /// <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
     // Removed by Mario Endara <*****@*****.**> (2004/11/04)
     //			if ((PortalSecurity.HasAddPermissions(ModuleID) == false && PortalSecurity.HasEditPermissions(ModuleID) == false) && PortalSecurity.IsInRoles("Admins") == false)
     if (PortalSecurity.HasAddPermissions(ModuleID) == false &&
         PortalSecurity.HasEditPermissions(ModuleID) == false)
     {
         PortalSecurity.AccessDeniedEdit();
     }
     base.OnUpdate(e);
 }
        /// <summary>
        /// Handles OnAdd event at Page level<br/>
        /// Performs OnAdd 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 OnAdd(EventArgs e)
        {
            if (Add != null)
            {
                Add(this, e);   //Invokes the delegates
            }
            //Flush cache
            OnFlushCache();

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

            // any other code goes here
        }
        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());
                }
            }
        }
        /// <summary>
        /// Handles OnUpdate event at Page level<br/>
        /// Performs OnUpdate 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 OnUpdate(EventArgs e)
        {
            if (Update != null)
            {
                Update(this, e);   //Invokes the delegates
            }
            //Flush cache
            OnFlushCache();

            // Verify that the current user has access to edit this module
            // June 23, 2003: Mark McFarlane made change to check for both Add AND Edit permissions
            // Since UI.Page.EditPage and UI.Page.AddPage both inherit from this UI.Page class
            if (PortalSecurity.HasEditPermissions(ModuleID) == false &&
                PortalSecurity.HasAddPermissions(ModuleID) == false)
            {
                PortalSecurity.AccessDeniedEdit();
            }

            // any other code goes here
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                BindCountry();
                BindState();

                // Edit check
                if (EditMode)   // Someone requested edit this record
                {
                    //True is use is editing himself, false if is edited by an admin
                    selfEdit = (userName == PortalSettings.CurrentUser.Identity.Email);

                    // Removed by Mario Endara <*****@*****.**> (2004/11/04)
                    //					if (PortalSecurity.IsInRoles("Admins") || selfEdit)
                    if (PortalSecurity.HasEditPermissions(ModuleID) || PortalSecurity.HasAddPermissions(ModuleID) ||
                        selfEdit)
                    {
                        //We can edit

                        // Hide
                        RequiredPassword.Visible = false;
                        RequiredConfirm.Visible  = false;
                        EditPasswordRow.Visible  = true;
                        SaveChangesBtn.Visible   = true;
                        RegisterBtn.Visible      = false;

                        // Obtain a single row of event information
                        UsersDB accountSystem = new UsersDB();

                        RainbowUser memberUser = accountSystem.GetSingleUser(userName);

                        try {
                            originalUserID    = memberUser.ProviderUserKey;
                            NameField.Text    = memberUser.Name;
                            EmailField.Text   = memberUser.Email;
                            CompanyField.Text = memberUser.Company;
                            AddressField.Text = memberUser.Address;
                            ZipField.Text     = memberUser.Zip;
                            CityField.Text    = memberUser.City;

                            CountryField.ClearSelection();
                            if (CountryField.Items.FindByValue(memberUser.CountryID) != null)
                            {
                                CountryField.Items.FindByValue(memberUser.CountryID).Selected = true;
                            }
                            BindState();
                            StateField.ClearSelection();
                            if (StateField.Items.Count > 0 &&
                                StateField.Items.FindByValue(memberUser.StateID.ToString()) != null)
                            {
                                StateField.Items.FindByValue(memberUser.StateID.ToString()).Selected = true;
                            }

                            FaxField.Text          = memberUser.Fax;
                            PhoneField.Text        = memberUser.Phone;
                            SendNewsletter.Checked = memberUser.SendNewsletter;

                            //stores original password for later check
                            // originalPassword = memberUser.GetPassword();  NOT STILL SUPPORTED
                        }
                        catch (System.ArgumentNullException error) {
                            // no  existe el usuario;
                        }
                    }
                    else
                    {
                        //We do not have rights to do it!
                        PortalSecurity.AccessDeniedEdit();
                    }
                }
                else
                {
                    BindState();

                    //No edit
                    RequiredPassword.Visible = true;
                    RequiredConfirm.Visible  = true;
                    EditPasswordRow.Visible  = false;
                    SaveChangesBtn.Visible   = false;
                    RegisterBtn.Visible      = true;
                }

                string termsOfService = portalSettings.GetTermsOfService;

                //Verify if we have to show conditions
                if (termsOfService.Length != 0)
                {
                    //Shows conditions
                    FieldConditions.Text  = termsOfService;
                    ConditionsRow.Visible = true;
                }
                else
                {
                    //Hides conditions
                    ConditionsRow.Visible = false;
                }
            }
        }
Esempio n. 9
0
 /// <summary>
 /// See whether the current user has permissions to add a post to the discussion thread
 /// </summary>
 /// <param name="moduleId">
 /// ID of the current Discussion Module
 /// </param>
 /// <returns>
 /// Returns true or flase
 /// </returns>
 public static bool HasAddPermissions(int moduleId)
 {
     return(PortalSecurity.HasAddPermissions(moduleId));
 }
Esempio n. 10
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 + "'!"));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                //Remove validation for Windows users
                if (HttpContext.Current != null && Context.User is WindowsPrincipal)
                {
                    ValidEmail.Visible = false;
                    EmailLabel.TextKey = "WINDOWS_USER_NAME";
                    EmailLabel.Text    = "Windows User Name";
                }

                // TODO: Jonathan - need to bring in country functionality from esperantus or new somehow?
                BindCountry();

                // TODO: Fix this
                // More esperanuts country stuff...
                // CountryInfo country = CountryInfo.CurrentCountry;
                //if (country != null && CountryField.Items.FindByValue(country.Name) != null)
                //	CountryField.Items.FindByValue(country.Name).Selected = true;
                BindState();


                // Edit check
                if (EditMode)   // Someone requested edit this record
                {
                    //True is use is editing himself, false if is edited by an admin
                    selfEdit = (userName == PortalSettings.CurrentUser.Identity.UserName);

                    // Removed by Mario Endara <*****@*****.**> (2004/11/04)
                    //					if (PortalSecurity.IsInRoles("Admins") || selfEdit)
                    if (PortalSecurity.HasEditPermissions(ModuleID) || PortalSecurity.HasAddPermissions(ModuleID) || selfEdit)
                    {
                        //We can edit

                        // Hide
                        RequiredPassword.Visible = false;
                        RequiredConfirm.Visible  = false;
                        EditPasswordRow.Visible  = true;
                        SaveChangesBtn.Visible   = true;
                        RegisterBtn.Visible      = false;

                        // Obtain a single row of event information
                        UsersDB accountSystem = new UsersDB();

                        RainbowUser memberUser = accountSystem.GetSingleUser(userName);

                        try {
                            NameField.Text    = memberUser.Name;
                            EmailField.Text   = memberUser.Email;
                            CompanyField.Text = memberUser.Company;
                            AddressField.Text = memberUser.Address;
                            ZipField.Text     = memberUser.Zip;
                            CityField.Text    = memberUser.City;

                            CountryField.ClearSelection();
                            if (CountryField.Items.FindByValue(memberUser.CountryID) != null)
                            {
                                CountryField.Items.FindByValue(memberUser.CountryID).Selected = true;
                            }
                            BindState();
                            StateField.ClearSelection();
                            if (StateField.Items.Count > 0 &&
                                StateField.Items.FindByValue(memberUser.StateID.ToString()) != null)
                            {
                                StateField.Items.FindByValue(memberUser.StateID.ToString()).Selected = true;
                            }

                            FaxField.Text          = memberUser.Fax;
                            PhoneField.Text        = memberUser.Phone;
                            SendNewsletter.Checked = memberUser.SendNewsletter;

                            //stores original password for later check
                            originalPassword = memberUser.GetPassword();
                            originalUserID   = memberUser.ProviderUserKey;
                        }
                        catch (System.ArgumentNullException error) {
                            // user doesn't exist
                        }
                    }
                    else
                    {
                        //We do not have rights to do it!
                        PortalSecurity.AccessDeniedEdit();
                    }
                }
                else
                {
                    BindState();

                    //No edit
                    RequiredPassword.Visible = true;
                    RequiredConfirm.Visible  = true;
                    EditPasswordRow.Visible  = false;
                    SaveChangesBtn.Visible   = false;
                    RegisterBtn.Visible      = true;
                }

                string termsOfService = portalSettings.GetTermsOfService;

                //Verify if we have to show conditions
                if (termsOfService.Length != 0)
                {
                    //Shows conditions
                    FieldConditions.Text  = termsOfService;
                    ConditionsRow.Visible = true;
                }
                else
                {
                    //Hides conditions
                    ConditionsRow.Visible = false;
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// The Page_Load server event handler on this page is used
        /// to obtain the ModuleID and ItemID of the discussion list,
        /// and to then display the message contents.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Page_Load(object sender, System.EventArgs e)
        {
            //Translations on the buttons, it doesn't appear there is a
            //		tra:LinkButton style supported
            submitButton.Text = Esperantus.Localize.GetString("SUBMIT");
            cancelButton.Text = Esperantus.Localize.GetString("CANCEL");

            // Populate message contents if this is the first visit to the page
            if (Page.IsPostBack == false)
            {
                DiscussionDB  discuss;
                SqlDataReader dr;

                switch (GetMode())
                {
                case "REPLY":
                    if (PortalSecurity.HasAddPermissions(ModuleID) == false)
                    {
                        PortalSecurity.AccessDeniedEdit();
                    }

                    DiscussionEditInstructions.Text = Esperantus.Localize.GetString("DS_REPLYTHISMSG");

                    // Load fields for the item that we are replying to
                    discuss = new DiscussionDB();
                    dr      = discuss.GetSingleMessage(ItemID);
                    try
                    {
                        if (dr.Read())
                        {
                            // Update labels with message contents
                            Title.Text         = (string)dr["Title"];
                            Body.Text          = (string)dr["Body"];
                            CreatedByUser.Text = (string)dr["CreatedByUser"];
                            CreatedDate.Text   = string.Format("{0:d}", dr["CreatedDate"]);
                            TitleField.Text    = string.Empty;                                          // don't give users a default subject for their reply
                            // encourage them to title their response
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (CreatedByUser.Text == "unknown")
                            {
                                CreatedByUser.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                        }
                    }
                    finally
                    {
                        dr.Close();
                    }
                    break;

                case "ADD":
                    if (PortalSecurity.HasAddPermissions(ModuleID) == false)
                    {
                        PortalSecurity.AccessDeniedEdit();
                    }

                    // hide the 'previous message' controls
                    OriginalMessagePanel.Visible = false;
                    break;


                case "EDIT":
                {
                    string itemUserEmail = string.Empty;
                    // hide the 'parent message' controls
                    OriginalMessagePanel.Visible    = false;
                    DiscussionEditInstructions.Text = Esperantus.Localize.GetString("EDIT");

                    // Bind the data to the control
                    // Obtain the selected item from the Discussion table
                    discuss = new DiscussionDB();
                    dr      = discuss.GetSingleMessage(ItemID);

                    try
                    {
                        // Load first row from database
                        if (dr.Read())
                        {
                            // Update edit fields with message contents
                            TitleField.Text = (string)dr["Title"];
                            BodyField.Text  = (string)dr["Body"];
                            itemUserEmail   = (string)dr["CreatedByUser"];
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (itemUserEmail == "unknown")
                            {
                                itemUserEmail = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                        }
                    }
                    finally
                    {
                        dr.Close();
                    }

                    if (DiscussionPermissions.HasEditPermissions(ModuleID, itemUserEmail) == false)
                    {
                        PortalSecurity.AccessDeniedEdit();
                    }
                }
                break;

                /* case "DELETE":
                 *      if (PortalSecurity.HasDeletePermissions(ModuleID) == false)
                 *              PortalSecurity.AccessDeniedEdit();
                 *      break;
                 */

                default:
                    // invalid mode specified
                    PortalSecurity.AccessDeniedEdit();
                    break;
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// The on load.
        /// </summary>
        /// <param name="e">
        /// Event arguments.
        /// </param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!this.Page.IsPostBack)
            {
                // Edit check
                if (this.EditMode)
                {
                    // Someone requested edit this record
                    // True is use is editing himself, false if is edited by an admin
                    this.SelfEdit = this.UserName == PortalSettings.CurrentUser.Identity.UserName;

                    // Removed by Mario Endara <*****@*****.**> (2004/11/04)
                    // if (PortalSecurity.IsInRoles("Admins") || selfEdit)
                    if (PortalSecurity.HasEditPermissions(this.ModuleID) ||
                        PortalSecurity.HasAddPermissions(this.ModuleID) || this.SelfEdit)
                    {
                        // We can edit

                        // Hide
                        this.RequiredPassword.Visible = false;
                        this.RequiredConfirm.Visible  = false;
                        this.EditPasswordRow.Visible  = true;
                        this.SaveChangesBtn.Visible   = true;
                        this.RegisterBtn.Visible      = false;

                        // Obtain a single row of event information
                        var accountSystem = new UsersDB();

                        var memberUser = accountSystem.GetSingleUser(this.UserName, this.PortalSettings.PortalAlias);

                        try
                        {
                            this.NameField.Text    = memberUser.Name;
                            this.EmailField.Text   = memberUser.Email;
                            this.CompanyField.Text = memberUser.Company;
                            this.AddressField.Text = memberUser.Address;
                            this.ZipField.Text     = memberUser.Zip;
                            this.CityField.Text    = memberUser.City;

                            this.CountryField.ClearSelection();
                            if (this.CountryField.Items.FindByValue(memberUser.CountryID) != null)
                            {
                                this.CountryField.Items.FindByValue(memberUser.CountryID).Selected = true;
                            }

                            this.BindState();
                            this.StateField.ClearSelection();
                            if (this.StateField.Items.Count > 0 &&
                                this.StateField.Items.FindByValue(memberUser.StateID.ToString()) != null)
                            {
                                this.StateField.Items.FindByValue(memberUser.StateID.ToString()).Selected = true;
                            }

                            this.FaxField.Text          = memberUser.Fax;
                            this.PhoneField.Text        = memberUser.Phone;
                            this.SendNewsletter.Checked = memberUser.SendNewsletter;

                            // stores original password for later check
                            this.OriginalPassword = memberUser.GetPassword();
                            this.OriginalUserId   = memberUser.ProviderUserKey;
                        }
                        catch (ArgumentNullException)
                        {
                            // user doesn't exist
                        }
                    }
                    else
                    {
                        // We do not have rights to do it!
                        PortalSecurity.AccessDeniedEdit();
                    }
                }
                else
                {
                    this.BindState();

                    // No edit
                    this.RequiredPassword.Visible = true;
                    this.RequiredConfirm.Visible  = true;
                    this.EditPasswordRow.Visible  = false;
                    this.SaveChangesBtn.Visible   = false;
                    this.RegisterBtn.Visible      = true;
                }
            }
        }
Esempio n. 15
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                //Remove validation for Windows users
                if (HttpContext.Current != null && Context.User is System.Security.Principal.WindowsPrincipal)
                {
                    this.ValidEmail.Visible = false;
                    this.EmailLabel.TextKey = "WINDOWS_USER_NAME";
                    this.EmailLabel.Text    = "Windows User Name";
                }

                //If allow id and user is not new show id row
                //When we create an user, id is ignored
                if (allowEditUserID && userName.Length != 0)
                {
                    UserIDRow.Visible = true;
                }

                BindCountry();

                //Bind to current language country
                CountryField.ClearSelection();

                Esperantus.CountryInfo country = Esperantus.CountryInfo.CurrentCountry;
                if (country != null && CountryField.Items.FindByValue(country.Name) != null)
                {
                    CountryField.Items.FindByValue(country.Name).Selected = true;
                }
                BindState();


                // Edit check
                if (EditMode)                 // Someone requested edit this record
                {
                    //True is use is editing himself, false if is edited by an admin
                    selfEdit = (userName == PortalSettings.CurrentUser.Identity.Email);

                    // Removed by Mario Endara <*****@*****.**> (2004/11/04)
//					if (PortalSecurity.IsInRoles("Admins") || selfEdit)
                    if (PortalSecurity.HasEditPermissions(ModuleID) || PortalSecurity.HasAddPermissions(ModuleID) || selfEdit)
                    {
                        //We can edit

                        // Hide
                        RequiredPassword.Visible = false;
                        RequiredConfirm.Visible  = false;
                        EditPasswordRow.Visible  = true;
                        SaveChangesBtn.Visible   = true;
                        RegisterBtn.Visible      = false;

                        // Obtain a single row of event information
                        UsersDB       accountSystem = new UsersDB();
                        SqlDataReader dr            = accountSystem.GetSingleUser(userName, portalSettings.PortalID);

                        try
                        {
                            // Read first row from database
                            if (dr.Read())
                            {
                                UseridField.Text = dr["UserID"].ToString();
                                //stores original user id for later check
                                originalUserID    = int.Parse(dr["UserID"].ToString());
                                NameField.Text    = dr["Name"].ToString();
                                EmailField.Text   = dr["Email"].ToString();
                                CompanyField.Text = dr["Company"].ToString();
                                AddressField.Text = dr["Address"].ToString();
                                ZipField.Text     = dr["Zip"].ToString();
                                CityField.Text    = dr["City"].ToString();

                                CountryField.ClearSelection();
                                if (CountryField.Items.FindByValue(dr["CountryID"].ToString()) != null)
                                {
                                    CountryField.Items.FindByValue(dr["CountryID"].ToString()).Selected = true;
                                }
                                BindState();
                                StateField.ClearSelection();
                                if (StateField.Items.Count > 0 && StateField.Items.FindByValue(dr["StateID"].ToString()) != null)
                                {
                                    StateField.Items.FindByValue(dr["StateID"].ToString()).Selected = true;
                                }

                                FaxField.Text          = dr["Fax"].ToString();
                                PhoneField.Text        = dr["Phone"].ToString();
                                CFiscaleField.Text     = dr["CFiscale"].ToString();
                                PIvaField.Text         = dr["PIva"].ToString();
                                SendNewsletter.Checked = bool.Parse(dr["SendNewsletter"].ToString());

                                //stores original password for later check
                                originalPassword = dr["Password"].ToString();
                            }
                        }
                        finally
                        {
                            dr.Close();
                        }
                    }
                    else
                    {
                        //We do not have rights to do it!
                        Security.PortalSecurity.AccessDeniedEdit();
                    }
                }
                else
                {
                    BindState();

                    //No edit
                    RequiredPassword.Visible = true;
                    RequiredConfirm.Visible  = true;
                    EditPasswordRow.Visible  = false;
                    SaveChangesBtn.Visible   = false;
                    RegisterBtn.Visible      = true;
                }

                string termsOfService = portalSettings.GetTermsOfService;

                //Verify if we have to show conditions
                if (termsOfService != string.Empty)
                {
                    //Shows conditions
                    FieldConditions.Text  = termsOfService;
                    ConditionsRow.Visible = true;
                }
                else
                {
                    //Hides conditions
                    ConditionsRow.Visible = false;
                }
            }
        }
Esempio n. 16
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 + "'!"));
                        }
                    }
                }
            }
        }