Пример #1
0
        public ActionResult SaveTitle(string id, string value)
        {
            try {
                var parse    = id.Split('_');
                int moduleId = Int32.Parse(parse[1]);
                // Si el usuario tiene permiso para modificar
                if (PortalSecurity.HasEditPermissions(moduleId))
                {
                    var modules = new Appleseed.Framework.Site.Data.ModulesDB();

                    modules.UpdateModuleTitle(moduleId, value);



                    return(Json(new { result = true }));
                }
                return(Json(new { result = false }));
            } catch (Exception) {
                return(Json(new { result = false }));
            }
        }
        public JsonResult edit(int id)
        {
            ModulesDB modules     = new ModulesDB();
            Guid      TabGuid     = new Guid("{1C575D94-70FC-4A83-80C3-2087F726CBB3}");
            int       TabModuleID = 0;

            foreach (ModuleItem m in modules.FindModuleItemsByGuid(PortalSettings.PortalID, TabGuid))
            {
                bool HasEditPermissionsOnTabs = PortalSecurity.HasEditPermissions(m.ID);
                if (HasEditPermissionsOnTabs)
                {
                    TabModuleID = m.ID;
                    break;
                }
            }

            string dir = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx?PageID=" + id.ToString() +
                                                 "&mID=" + TabModuleID + "&Alias=" + this.PortalSettings.PortalAlias + "&returntabid=" +
                                                 this.PortalSettings.ActiveModule);

            return(Json(new { url = dir }));
        }
Пример #3
0
        protected override void OnInit(EventArgs e)
        {
            if (HasEditPermission())
            {
                this.HtmlHolder.EnableViewState = false;
            }
            else
            {
                this.HtmlHolder2.EnableViewState = false;
            }


            // Add title
            // ModuleTitle = new DesktopModuleTitle();
            this.EditUrl = "~/DesktopModules/CommunityModules/HTMLDocument/HtmlEdit.aspx";

            // Controls.AddAt(0, ModuleTitle);
            var text = new HtmlTextDB();

            this.Content = this.Server.HtmlDecode(text.GetHtmlTextString(this.ModuleID, this.Version));
            if (PortalSecurity.HasEditPermissions(this.ModuleID) && string.IsNullOrEmpty(this.Content.ToString()))
            {
                this.Content = "Add content here ...<br/><br/><br/><br/>";
            }

            this.HtmlLiteral              = new LiteralControl(this.Content.ToString());
            this.HtmlLiteral.DataBinding += HtmlLiteralDataBinding;
            this.HtmlLiteral.DataBind();
            if (HasEditPermission())
            {
                this.HtmlHolder.Controls.Add(this.HtmlLiteral);
            }
            else
            {
                this.HtmlHolder2.Controls.Add(this.HtmlLiteral);
            }

            base.OnInit(e);
        }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, 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.ActivePage.Modules.Count; i++)
                {
                    ms = (ModuleSettings)portalSettings.ActivePage.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 =
                    General.GetString("SWI_REQUEST_APPROVAL_SUBJECT", "Request approval of the new content of '") +
                    ms.ModuleTitle + "'";
                // Message
                emailForm.HtmlBodyText = General.GetString("SWI_REQUEST_BODY", "You can find the new content at:") +
                                         "<br><br><a href='" + UrlReferrer + "'>" + UrlReferrer + "</a>";
            }
        }
Пример #5
0
        /// <summary>
        /// Binds the control and all its child controls to the specified data source.
        /// </summary>
        public override void DataBind()
        {
            if (HttpContext.Current != null)
            {
                //Init data
                ArrayList list = new ArrayList();

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

                string homeLink = "<a";
                string menuLink;

                // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                if (CssClass.Length != 0)
                {
                    homeLink = homeLink + " class=\"" + CssClass + "\"";
                }

                homeLink = homeLink + " href='" + HttpUrlBuilder.BuildUrl() + "'>" +
                           General.GetString("Rainbow", "HOME") + "</a>";

                // If user logged in, customize welcome message
                if (HttpContext.Current.Request.IsAuthenticated == true)
                {
                    if (ShowWelcome)
                    {
                        list.Add(General.GetString("HEADER_WELCOME", "Welcome", this) + "&#160;" +
                                 PortalSettings.CurrentUser.Identity.Name + "!");
                    }

                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // Added by Mario Endara <*****@*****.**> (2004/11/06)
                    // Find Tab module to see if the user has add/edit rights
                    ModulesDB modules = new ModulesDB();
                    Guid      TabGuid = new Guid("{1C575D94-70FC-4A83-80C3-2087F726CBB3}");
                    // Added by Xu Yiming <*****@*****.**> (2004/12/6)
                    // Modify for support Multi or zero Pages Modules in a single portal.
                    bool HasEditPermissionsOnTabs = false;
                    int  TabModuleID = 0;

//					SqlDataReader result = modules.FindModulesByGuid(portalSettings.PortalID, TabGuid);
//					while(result.Read())
//					{
//						TabModuleID=(int)result["ModuleId"];

                    foreach (ModuleItem m in modules.FindModuleItemsByGuid(portalSettings.PortalID, TabGuid))
                    {
                        HasEditPermissionsOnTabs = PortalSecurity.HasEditPermissions(m.ID);
                        if (HasEditPermissionsOnTabs)
                        {
                            TabModuleID = m.ID;
                            break;
                        }
                    }

                    // If user logged in and has Edit permission in the Tab module, reach tab management just one click
                    if ((ShowTabMan) && (HasEditPermissionsOnTabs))
                    {
                        // added by Mario Endara 2004/08/06 so PageLayout can return to this page
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09)
                        menuLink = menuLink + " href='" +
                                   HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx?PageID=") +
                                   portalSettings.ActivePage.PageID + "&amp;mID=" + TabModuleID.ToString() +
                                   "&amp;Alias=" + portalSettings.PortalAlias + "&amp;lang=" + portalSettings.PortalUILanguage +
                                   "&amp;returntabid=" + portalSettings.ActivePage.PageID + "'>" +
                                   General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "</a>";
                        list.Add(menuLink);
                    }

                    if (ShowEditProfile)
                    {
                        // 19/08/2004 Jonathan Fong
                        // www.gt.com.au
                        if (Context.User.Identity.AuthenticationType == "LDAP")
                        {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx", "userName="******"'>" + "Profile" + "</a>";
                            list.Add(menuLink);
                        }
                        // If user is form add edit user link
                        else if (!(HttpContext.Current.User is WindowsPrincipal))
                        {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx", "userName="******"'>" +
                                       General.GetString("HEADER_EDIT_PROFILE", "Edit profile", this) + "</a>";
                            list.Add(menuLink);
                        }
                    }

                    // if authentication mode is Cookie, provide a logoff link
                    if (Context.User.Identity.AuthenticationType == "Forms" ||
                        Context.User.Identity.AuthenticationType == "LDAP")
                    {
                        if (ShowLogOff)
                        {
                            // Corrections when ShowSecureLogon is true. [email protected] (05/07/2004)
                            string href = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logoff.aspx");
                            if (ShowSecureLogon && Context.Request.IsSecureConnection)
                            {
                                string auxref = Context.Request.Url.AbsoluteUri;
                                auxref = auxref.Substring(0, auxref.IndexOf(Context.Request.Url.PathAndQuery));
                                href   = auxref + href;
                                href   = href.Replace("https", "http");
                            }
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" + href + "'>" +
                                       General.GetString("HEADER_LOGOFF", "Logoff", null) + "</a>";
                            list.Add(menuLink);
                        }
                    }
                }
                else
                {
                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // if not authenticated and ShowLogon is true, provide a logon link
                    if (ShowLogon)
                    {
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logon.aspx") +
                                   "'>" + General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }
                    // Thierry (Tiptopweb) 5 May 2003 : Secure Logon to Secure Directory
                    if (ShowSecureLogon)
                    {
                        // Added localized support. [email protected] (05/07/2004)
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='" + portalSettings.PortalSecurePath + "/Logon.aspx'>" +
                                   General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }
                }
                innerDataSource = list;
            }
            base.DataBind();
        }
Пример #6
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;
                }
            }
        }
Пример #7
0
        /// <summary>
        /// The CreateChildControls method is called when the ASP.NET Page Framework
        /// determines that it is time to instantiate a server control.
        /// This method and attempts to resolve any previously cached output of the portal
        /// module from the ASP.NET cache.
        /// If it doesn't find cached output from a previous request, then it will instantiate
        /// and add the portal modules UserControl instance into the page tree.
        /// </summary>
        /// <remarks>
        /// </remarks>
        protected override void CreateChildControls()
        {
            if (_moduleConfiguration != null)
            {
                // if user does not have EDIT rights for the module ( content editors can not see cached versions of modules )
                if (PortalSecurity.HasEditPermissions(_moduleConfiguration.ModulePermissions) == false)
                {
                    // Attempt to resolve previously cached content
                    if (_moduleConfiguration.CacheTime != 0)
                    {
                        if (CacheMethod != "D")
                        {
                            _cachedOutput = Convert.ToString(DataCache.GetCache(CacheKey));
                        }
                        else // cache from disk
                        {
                            if (File.Exists(CacheFileName))
                            {
                                FileInfo cacheFile = new FileInfo(CacheFileName);
                                if (cacheFile.CreationTime.AddSeconds(_moduleConfiguration.CacheTime) >= DateTime.Now)
                                {
                                    try
                                    {
                                        //Load from Cache
                                        StreamReader objStreamReader = cacheFile.OpenText();
                                        _cachedOutput = objStreamReader.ReadToEnd();
                                        objStreamReader.Close();
                                    }
                                    catch (Exception)
                                    {
                                        //locking error
                                        _cachedOutput = String.Empty;
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        //Cache Expired so delete it
                                        cacheFile.Delete();
                                    }
                                    catch (Exception)
                                    {
                                        //locking error
                                        _cachedOutput = String.Empty;
                                    }
                                }
                            }
                        }
                    }

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

                        PortalModuleBase objPortalModuleBase = (PortalModuleBase)Page.LoadControl(_moduleConfiguration.ControlSrc);
                        objPortalModuleBase.ModuleConfiguration = this.ModuleConfiguration;

                        // set the control ID to the resource file name ( ie. controlname.ascx = controlname )
                        // this is necessary for the Localization in PageBase
                        objPortalModuleBase.ID = Path.GetFileNameWithoutExtension(_moduleConfiguration.ControlSrc);

                        // In skin.vb, the call to Me.Controls.Add(objPortalModuleBase) calls CreateChildControls() therefore
                        // we need to indicate the control has already been created. We will manipulate the CacheTime property for this purpose.
                        objPortalModuleBase.ModuleConfiguration.CacheTime = -(objPortalModuleBase.ModuleConfiguration.CacheTime);

                        this.Controls.Add(objPortalModuleBase);
                    }
                    else
                    {
                        // restore the CacheTime property in preparation for the Render() event
                        if (_moduleConfiguration.CacheTime < 0)
                        {
                            _moduleConfiguration.CacheTime = -(_moduleConfiguration.CacheTime);
                        }
                    }
                }
            }
        }
Пример #8
0
        protected override void OnInit(EventArgs e)
        {
            if (HasEditPermission())
            {
                this.HtmlHolder.EnableViewState = false;
            }
            else
            {
                this.HtmlHolder2.EnableViewState = false;
            }


            // Add title
            // ModuleTitle = new DesktopModuleTitle();
            this.EditUrl = "~/DesktopModules/CommunityModules/HTMLDocument/HtmlEdit.aspx";

            // Controls.AddAt(0, ModuleTitle);
            var text = new HtmlTextDB();

            this.Content = this.Server.HtmlDecode(text.GetHtmlTextString(this.ModuleID, this.Version));
            if (PortalSecurity.HasEditPermissions(this.ModuleID) && string.IsNullOrEmpty(this.Content.ToString()))
            {
                this.Content = "Add content here ...<br/><br/><br/><br/>";
            }



            this.HtmlLiteral              = new LiteralControl(this.Content.ToString());
            this.HtmlLiteral.DataBinding += HtmlLiteralDataBinding;
            this.HtmlLiteral.DataBind();
            if (HasEditPermission())
            {
                this.HtmlHolder.Controls.Add(this.HtmlLiteral);
            }
            else
            {
                this.HtmlHolder2.Controls.Add(this.HtmlLiteral);
            }

            //if (PortalSecurity.HasEditPermissions(this.ModuleID)) {
            //    var editor = Settings["Editor"].ToString();
            //    var width = int.Parse(Settings["Width"].ToString()) + 100;
            //    var height = int.Parse(Settings["Height"].ToString());
            //    if (editor.Equals("FreeTextBox")) {
            //        height += 220;
            //    } else if (editor.Equals("FCKeditor")) {
            //        height += 120;
            //    } else if (editor.Equals("TinyMCE Editor")) {
            //        height += 140;
            //    } else if (editor.Equals("Code Mirror Plain Text")) {
            //        height += 140;
            //    } else if (editor.Equals("Syrinx CkEditor")) {
            //        height += 300;
            //    } else {
            //        height += 140;
            //    }
            //    string title = Resources.Appleseed.HTML_TITLE;
            //    var url = HttpUrlBuilder.BuildUrl("~/DesktopModules/CommunityModules/HTMLDocument/HtmlEditModal.aspx?mID="+this.ModuleID);
            //    this.HtmlModuleText.Attributes.Add("OnDblClick", "setDialog(" + ModuleID.ToString() + "," + width.ToString() + "," + (height + 10).ToString() + ");editHtml(" + ModuleID.ToString() + "," + this.PageID + ",\"" + url + "\");");
            //    this.HtmlModuleText.Attributes.Add("class", "Html_Edit");
            //    this.HtmlModuleDialog.Attributes.Add("class", "HtmlModuleDialog" + ModuleID.ToString());
            //    this.HtmlMoudleIframe.Attributes.Add("class", "HtmlMoudleIframe" + ModuleID.ToString());
            //    this.HtmlMoudleIframe.Attributes.Add("width", "98%");
            //    this.HtmlMoudleIframe.Attributes.Add("height", "99%");
            //    this.HtmlModuleText.Attributes.Add("title", title);
            //    this.HtmlModuleDialog.Attributes.Add("title", General.GetString("HTML_EDITOR", "Html Editor"));
            //    if ((Request.Browser.Browser.Contains("IE") || Request.Browser.Browser.Contains("ie")) && Request.Browser.MajorVersion == 7) {

            //        this.HTMLEditContainer.Attributes.Add("style", "position: relative;overflow: auto;");
            //    }
            //}

            base.OnInit(e);
        }
Пример #9
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);
        }
Пример #10
0
        /// <summary>
        /// Binds the control and all its child controls to the specified data source.
        /// </summary>
        public override void DataBind()
        {
            if (HttpContext.Current != null)
            {
                //Init data
                ArrayList list = new ArrayList();

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

                string homeLink = "<a";
                string menuLink;

                // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                if (CssClass.Length != 0)
                {
                    homeLink = homeLink + " class=\"" + CssClass + "\"";
                }

                homeLink = homeLink + " href='" + HttpUrlBuilder.BuildUrl() + "'>" +
                           General.GetString("Appleseed", "HOME") + "</a>";

                // If user logged in, customize welcome message
                if (HttpContext.Current.Request.IsAuthenticated == true)
                {
                    if (ShowWelcome)
                    {
                        list.Add(General.GetString("HEADER_WELCOME", "Welcome", this) + "&#160;" +
                                 PortalSettings.CurrentUser.Identity.Name + "!");
                    }

                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // Added by Mario Endara <*****@*****.**> (2004/11/06)
                    // Find Tab module to see if the user has add/edit rights
                    ModulesDB modules = new ModulesDB();
                    Guid      TabGuid = new Guid("{1C575D94-70FC-4A83-80C3-2087F726CBB3}");
                    // Added by Xu Yiming <*****@*****.**> (2004/12/6)
                    // Modify for support Multi or zero Pages Modules in a single portal.
                    bool HasEditPermissionsOnTabs = false;
                    int  TabModuleID = 0;

                    //					SqlDataReader result = modules.FindModulesByGuid(PortalSettings.PortalID, TabGuid);
                    //					while(result.Read())
                    //					{
                    //						TabModuleID=(int)result["ModuleId"];

                    foreach (ModuleItem m in modules.FindModuleItemsByGuid(PortalSettings.PortalID, TabGuid))
                    {
                        HasEditPermissionsOnTabs = PortalSecurity.HasEditPermissions(m.ID);
                        if (HasEditPermissionsOnTabs)
                        {
                            TabModuleID = m.ID;
                            break;
                        }
                    }

                    if (!HasEditPermissionsOnTabs || !ShowTabMan)
                    {
                        if (UserProfile.HasEditThisPageAccess())
                        {
                            HasEditPermissionsOnTabs = true;
                            this.ShowTabMan          = true;
                        }
                    }

                    // If user logged in and has Edit permission in the Tab module, reach tab management just one click
                    if ((ShowTabMan) && (HasEditPermissionsOnTabs))
                    {
                        // added by Mario Endara 2004/08/06 so PageLayout can return to this page
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09)
                        var url = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx?PageID=") +
                                  PortalSettings.ActivePage.PageID + "&amp;mID=" + TabModuleID.ToString() +
                                  "&amp;Alias=" + PortalSettings.PortalAlias + "&amp;lang=" + PortalSettings.PortalUILanguage +
                                  "&amp;returntabid=" + PortalSettings.ActivePage.PageID;
                        menuLink = menuLink + " href='" + url + "' onclick=\"openInModal('" + url + "','" + General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "');return false;\");>" +
                                   General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "</a>";
                        list.Add(menuLink);
                    }

                    if (ShowDragNDrop && HasEditPermissionsOnTabs)
                    {
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='javascript:DnD();'>" + General.GetString("DRAGNDROP", "DragNDrop", null) + "</a>";
                        list.Add(menuLink);
                    }

                    if (ShowEditProfile)
                    {
                        // 19/08/2004 Jonathan Fong
                        // www.gt.com.au
                        if (Context.User.Identity.AuthenticationType == "LDAP")
                        {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                       "'>" + "Profile" + "</a>";
                            list.Add(menuLink);
                        }
                        // If user is form add edit user link
                        else if (!(HttpContext.Current.User is WindowsPrincipal))
                        {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                       "'>" +
                                       General.GetString("HEADER_EDIT_PROFILE", "Edit profile", this) + "</a>";
                            list.Add(menuLink);
                        }
                    }

                    // if authentication mode is Cookie, provide a logoff link
                    if (Context.User.Identity.AuthenticationType == "Forms" ||
                        Context.User.Identity.AuthenticationType == "LDAP")
                    {
                        if (ShowLogOff)
                        {
                            // Corrections when ShowSecureLogon is true. [email protected] (05/07/2004)
                            string href = Context.Request.Url.AbsolutePath;
                            if (ShowSecureLogon && Context.Request.IsSecureConnection)
                            {
                                string auxref = Context.Request.Url.AbsoluteUri;
                                auxref = auxref.Substring(0, auxref.IndexOf(Context.Request.Url.PathAndQuery));
                                href   = auxref + href;
                                href   = href.Replace("https", "http");
                            }
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            // added code for redirection on same page after logged out
                            menuLink = menuLink + " href='javascript:void();' onclick=\"if(confirm('" + General.GetString("LOGOFF_CNF_MSG", "Log Off Confirmation: \\nAre you sure you want to log off?", null) + "')){window.location = '/DesktopModules/CoreModules/Admin/Logoff.aspx?redirecturl=" + href + "';  }else{return false;} \">" + General.GetString("HEADER_LOGOFF", "Logoff", null) + "</a>";



                            list.Add(menuLink);
                        }
                    }
                }
                else
                {
                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // if not authenticated and ShowLogon is true, provide a logon link

                    if (ShowLogon)
                    {
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink += string.Concat(" id=\"", this.ClientID, "_logon_link", "\"");
                        menuLink  = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logon.aspx") +
                                    "'>" + General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }

                    var allowNewRegistration = false;
                    if (PortalSettings.CustomSettings["SITESETTINGS_ALLOW_NEW_REGISTRATION"] != null)
                    {
                        if (bool.Parse(PortalSettings.CustomSettings["SITESETTINGS_ALLOW_NEW_REGISTRATION"].ToString()))
                        {
                            allowNewRegistration = true;
                        }
                    }

                    if (ShowRegister && allowNewRegistration)
                    {
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                   "'>" + General.GetString("REGISTER", "Register", null) + "</a>";
                        list.Add(menuLink);
                    }



                    // Thierry (Tiptopweb) 5 May 2003 : Secure Logon to Secure Directory
                    if (ShowSecureLogon)
                    {
                        // Added localized support. [email protected] (05/07/2004)
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='" + PortalSettings.PortalSecurePath + "/Logon.aspx'>" +
                                   General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }
                }

                LanguageSwitcher ls = new LanguageSwitcher();
                Appleseed.Framework.Web.UI.WebControls.LanguageCultureCollection lcc = Appleseed.Framework.Localization.LanguageSwitcher.GetLanguageCultureList();
                if ((ShowLanguages) && (lcc.Count > 1))
                {
                    var mb = new StringBuilder();

                    mb.Append("<a");
                    if (CssClass.Length != 0)
                    {
                        mb.AppendFormat(" class=\"{0}\"", CssClass);
                    }

                    mb.AppendFormat("id = \"popUpLang\" >");

                    if ((ShowLangString) || (ShowLanguages))
                    {
                        string aux = General.GetString("LANGUAGE", "Language", null);
                        mb.AppendFormat("{0}", aux);
                    }
                    if (ShowFlags)
                    {
                        CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                        string      dir         = HttpUrlBuilder.BuildUrl("~/aspnet_client/flags/flags_" + cultureInfo.ToString() + ".gif");
                        mb.AppendFormat("<img src=\"{0}\" alt=\"\" style=\"left:13px;position:relative\"/>", dir);
                    }
                    mb.Append("</a>");
                    list.Add(mb);
                }

                innerDataSource = list;
            }
            base.DataBind();
            if (ShowLogon && DialogLogon)
            {
                //this new list control won't appear in the list, since it has no DataItem. However we need it for "holding" the Signin Control.
                var newItem = new DataListItem(this.Controls.Count, ListItemType.Item);
                this.Controls.Add(newItem);

                var logonDialogPlaceHolder = new PlaceHolder();
                newItem.Controls.Add(logonDialogPlaceHolder);

                if (_logonControl == null) //we ask this in case someone call the Databind more than once.
                {
                    _logonControl = Page.LoadControl(DialogLogonControlPath);
                    _logonControl.ViewStateMode = System.Web.UI.ViewStateMode.Enabled;
                }
                logonDialogPlaceHolder.Controls.Add(_logonControl);
            }
        }
        /// <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 + "'!"));
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #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;
                }
            }
        }
Пример #13
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;
                }
            }
        }
Пример #14
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;
                }
            }
        }
Пример #15
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 + "'!"));
                        }
                    }
                }
            }
        }