Example #1
0
        /// <summary>Construtor</summary>
        public User(IIdentity _user, string[] _roles)
        {
            reset();
            if (_user.Name == null)
            {
                mail = "";
            }
            else
            {
                mail = _user.Name;
            }

            roles    = _roles;
            identity = _user;
            UserUtility.bd.fillUser(this);

            //carregar a skin
            MasterSkinInfo masterSkin = MasterSkinUtility.getMasterSkinInfoFromId(Skin);

            if (masterSkin == null)
            {
                throw new AlnitakException(string.Format("No foi possivel carregar a skin com o id {0}", skin));
            }
            SkinName   = masterSkin.masterSkinName;
            SkinStyle  = masterSkin.masterSkinStyle;
            SkinScript = masterSkin.masterSkinScript;
        }
Example #2
0
        /// <summary>Povoa a DropDownLost das linguas</summary>
        private void povoateSkin()
        {
            User user = (User)HttpContext.Current.User;
            UtilityCollection skins = MasterSkinUtility.getAllMasterSkins();

            foreach (MasterSkinInfo info in skins.Values)
            {
                ListItem item = new ListItem();
                item.Text  = info.masterSkinDescription;
                item.Value = info.masterSkinId.ToString();
                if (info.masterSkinId == user.Skin)
                {
                    item.Selected = true;
                }
                skin.Items.Add(item);
            }
        }
Example #3
0
        private Control loadSkin()
        {
            Control skin = (Control)Context.Cache[masterSkinInfo.masterSkinName + "/" + _skinName];

            if (skin == null)
            {
                string skinPath = OrionGlobals.AppPath + masterSkinInfo.masterSkinName + "/controls/" + _skinFileName;
                if (!File.Exists(HttpContext.Current.Server.MapPath(skinPath)))
                {
                    MasterSkinInfo m = MasterSkinUtility.getDefaultMasterSkinInfo();
                    skinPath = OrionGlobals.AppPath + m.masterSkinName + "/controls/" + _skinFileName;
                }
                skin = Page.LoadControl(skinPath);
                Context.Cache[masterSkinInfo.masterSkinName + "/" + _skinName] = skin;
            }
            return(skin);
        }
Example #4
0
        protected override void OnInit(EventArgs e)
        {
            Context.Trace.Write("BasePageModule", "OnInit");

            Control skin;

            // Determinar a skin pedida
            SectionInfo sectionInfo = (SectionInfo)HttpContext.Current.Items["SectionInfo"];
            PageInfo    pageInfo    = (PageInfo)HttpContext.Current.Items["PageInfo"];

            masterSkinInfo = (MasterSkinInfo)HttpContext.Current.Items["MasterSkinInfo"];

            string skinFileName;

            if (_sectionContent != string.Empty && sectionInfo.sectionContent != _sectionContent)
            {
                _fileName = "InvalidAccess.ascx";
            }
            else
            {
                _fileName = _fileName == null?pageInfo.pageName:_fileName;
            }

            skinFileName = String.Format("{0}{1}/content/{2}.ascx", OrionGlobals.AppPath, masterSkinInfo.masterSkinName, _fileName);

            if (!File.Exists(HttpContext.Current.Server.MapPath(skinFileName)))
            {
                masterSkinInfo = MasterSkinUtility.getDefaultMasterSkinInfo();
                skinFileName   = String.Format("{0}{1}/content/{2}.ascx", OrionGlobals.AppPath, masterSkinInfo.masterSkinName, _fileName);
            }

            Context.Trace.Write("BasePageModule", "Loading Module: " + skinFileName);
            try {
                skin = Page.LoadControl(skinFileName);
            } catch (Exception ex) {
                throw new Exception("Error Loading " + skinFileName + " - " + ex.Message, ex);
            }
            Controls.Add(skin);
        }
Example #5
0
        private void Application_BeginRequest(Object source, EventArgs e)
        {
            //obter o HttpContext
            HttpContext Context = HttpContext.Current;

            // verificar o wiki
            string path = CheckWiki(Context.Request.Path);

            // obter os paths do ficheiro e da base
            string requestPath     = OrionGlobals.removePathInfo(path);
            string requestBasePath = OrionGlobals.getSectionPath(requestPath);

            Log.log("Request to: {0}", requestPath);

            try {
                //Descobrir qual a seco pedida e adiciona-la ao Items
                Log.log("Checking for {0} section... ", requestPath);
                SectionInfo sectionInfo = SectionUtility.getSectionInfoFromFullPath(requestPath);
                if (sectionInfo == null)
                {
                    Log.log("\tsectionInfo is null");
                    //normalmente acontece quando e named page
                    sectionInfo = SectionUtility.getSectionInfoFromBasePath(requestBasePath);
                }
                else
                {
                    Log.log("\tsectionInfo ok");
                }

                //quando  imagem cai aqui ou outra coisa qq que n seja seco
                if (sectionInfo == null)
                {
                    Log.log("\tsectionInfo is null");
                    return;
                }

                //adiciona aos items a Items
                Context.Items["SectionInfo"] = sectionInfo;
                Log.log("\tSectionInfo: {0}", sectionInfo.sectionName);

                //Descobrir qual a skin corrente
                MasterSkinInfo masterSkinInfo = MasterSkinUtility.getMasterSkinInfoFromId(sectionInfo.sectionSkinId);
                if (masterSkinInfo == null)
                {
                    masterSkinInfo = MasterSkinUtility.getMasterSkinInfoFromId(1);
                }

                //adiciona o nmero da skin (Caso a skin tenha vrios esquemas de cor)
                storeSkinNumber(masterSkinInfo.masterSkinCount);

                //adiciona aos items a Items
                Context.Items["MasterSkinInfo"] = masterSkinInfo;

                PageInfo pageInfo = getPageInfo(sectionInfo, masterSkinInfo, requestPath);
                if (pageInfo != null)
                {
                    Context.Items["PageInfo"] = pageInfo;
                    Chronos.Utils.Log.log("Request: " + requestPath);

                    Log.log("Rewriting Path to '{0}'...", OrionGlobals.UrlBasePage);
                    if (requestPath.IndexOf(".aspx") >= 0)
                    {
                        Log.log("\tDone!");
                        Context.RewritePath(OrionGlobals.UrlBasePage);
                    }
                    else
                    {
                        Log.log("\tNot rewrited! '{0}' isn't aspx", requestPath);
                    }
                }
                else
                {
                    Log.log("PageInfo is null for '{0}'", requestPath);
                }
            } catch (Exception exception) {
                try {
                    ExceptionLog.log(exception);
                } catch (Exception exp) {
                    HttpContext.Current.Cache[OrionGlobals.SessionId + "AlnitakException"] = new ExceptionInfo(exp);;
                }

                //mostrar a pgina de erro global
                HttpContext.Current.Server.Transfer(OrionGlobals.resolveBase(OrionGlobals.getConfigurationValue("pagePath", "globalError")));
            }
        }
Example #6
0
        /// <summary>Altera a skin currente para a skin do utilizador</summary>
        private void setUserSkin(User user)
        {
            MasterSkinInfo masterSkinInfo = MasterSkinUtility.getMasterSkinInfoFromId(user.Skin);

            Context.Items["MasterSkinInfo"] = masterSkinInfo;
        }