Ejemplo n.º 1
0
        /// <summary>
        /// cmdDelete_Click runs when the Delete button is clicked
        /// </summary>
        /// <history>
        ///     [cnurse]	01/17/2005	documented
        /// </history>
        protected void cmdDelete_Click(Object sender, EventArgs e)
        {
            try
            {
                int intPortalAliasID;
                intPortalAliasID = Convert.ToInt32(ViewState["PortalAliasID"]);
                PortalAliasInfo       objPortalAliasInfo;
                PortalAliasController p = new PortalAliasController();
                objPortalAliasInfo = p.GetPortalAliasByPortalAliasID(intPortalAliasID);

                if (!UserInfo.IsSuperUser)
                {
                    if (objPortalAliasInfo.PortalID != PortalSettings.PortalId)
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AccessDenied", this.LocalResourceFile), ModuleMessageType.RedError);
                        return;
                    }
                }
                p.DeletePortalAlias(intPortalAliasID);

                Response.Redirect(Convert.ToString(ViewState["UrlReferrer"]), true);
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 2
0
        protected string GetPortalAlias(int portalAliasId)
        {
            StringBuilder sb = new StringBuilder();

            if (portalAliasId >= 0)
            {
                DotNetNuke.Entities.Portals.PortalAliasController pac = new PortalAliasController();
                PortalAliasInfo pa = pac.GetPortalAliasByPortalAliasID(portalAliasId);
                if (pa != null)
                {
                    sb.Append(pa.HTTPAlias);
                }
            }

            return(sb.ToString());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// BindData fetches the data from the database and updates the controls
        /// </summary>
        /// <history>
        ///     [cnurse]	01/17/2005	documented
        /// </history>
        private void BindData()
        {
            if (Request.QueryString["paid"] != null)
            {
                PortalAliasInfo objPortalAliasInfo;
                int             intPortalAliasID = Convert.ToInt32(Request.QueryString["paid"]);

                PortalAliasController p = new PortalAliasController();
                objPortalAliasInfo = p.GetPortalAliasByPortalAliasID(intPortalAliasID);

                ViewState.Add("PortalAliasID", intPortalAliasID);
                ViewState.Add("PortalID", objPortalAliasInfo.PortalID);

                if (!UserInfo.IsSuperUser)
                {
                    if (objPortalAliasInfo.PortalID != PortalSettings.PortalId)
                    {
                        UI.Skins.Skin.AddModuleMessage(this, "You do not have access to view this Portal Alias.", ModuleMessageType.RedError);
                        return;
                    }
                }

                txtAlias.Text = objPortalAliasInfo.HTTPAlias;
                SetDeleteVisibility(objPortalAliasInfo.PortalID);
            }
            else if (Request.QueryString["pid"] != "")
            {
                if (UserInfo.IsSuperUser)
                {
                    ViewState.Add("PortalID", Convert.ToInt32(Request.QueryString["pid"]));
                }
                SetDeleteVisibility(Convert.ToInt32(Request.QueryString["pid"]));
            }
            else
            {
                ViewState.Add("PortalID", PortalSettings.PortalId);
                SetDeleteVisibility(PortalSettings.PortalId);
            }
        }
Ejemplo n.º 4
0
        public PortalSettings CreatePortalSettings(int portalAliasID, int tabID)
        {
            var cacheKey = "EventsPortalSettings" + portalAliasID;
            var ps       = new PortalSettings();
            var pscache  = (PortalSettings)DataCache.GetCache(cacheKey);

            if (ReferenceEquals(pscache, null))
            {
                // Setup PortalSettings
                var objPortalAliases = new PortalAliasController();
                var objPortalAlias   = default(PortalAliasInfo);

                objPortalAlias = objPortalAliases.GetPortalAliasByPortalAliasID(portalAliasID);
                if (ReferenceEquals(objPortalAlias, null))
                {
                    return(null);
                }
                var portalController = new PortalController();
                var portal           = portalController.GetPortal(objPortalAlias.PortalID);


                ps.PortalAlias           = objPortalAlias;
                ps.PortalId              = portal.PortalID;
                ps.PortalName            = portal.PortalName;
                ps.LogoFile              = portal.LogoFile;
                ps.FooterText            = portal.FooterText;
                ps.ExpiryDate            = portal.ExpiryDate;
                ps.UserRegistration      = portal.UserRegistration;
                ps.BannerAdvertising     = portal.BannerAdvertising;
                ps.Currency              = portal.Currency;
                ps.AdministratorId       = portal.AdministratorId;
                ps.Email                 = portal.Email;
                ps.HostFee               = portal.HostFee;
                ps.HostSpace             = portal.HostSpace;
                ps.PageQuota             = portal.PageQuota;
                ps.UserQuota             = portal.UserQuota;
                ps.AdministratorRoleId   = portal.AdministratorRoleId;
                ps.AdministratorRoleName = portal.AdministratorRoleName;
                ps.RegisteredRoleId      = portal.RegisteredRoleId;
                ps.RegisteredRoleName    = portal.RegisteredRoleName;
                ps.Description           = portal.Description;
                ps.KeyWords              = portal.KeyWords;
                ps.BackgroundFile        = portal.BackgroundFile;
                ps.GUID            = portal.GUID;
                ps.SiteLogHistory  = portal.SiteLogHistory;
                ps.AdminTabId      = portal.AdminTabId;
                ps.SuperTabId      = portal.SuperTabId;
                ps.SplashTabId     = portal.SuperTabId;
                ps.HomeTabId       = portal.HomeTabId;
                ps.LoginTabId      = portal.LoginTabId;
                ps.UserTabId       = portal.UserTabId;
                ps.DefaultLanguage = portal.DefaultLanguage;
                ps.Pages           = portal.Pages;
                ps.Users           = portal.Users;
                if (ps.HostSpace == null)
                {
                    ps.HostSpace = 0;
                }
                if (ReferenceEquals(ps.DefaultLanguage, null))
                {
                    ps.DefaultLanguage = Localization.SystemLocale;
                }
                if (ReferenceEquals(ps.TimeZone, null))
                {
                    ps.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(Localization.SystemTimeZone);
                }
                ps.HomeDirectory = Globals.ApplicationPath + "/" + portal.HomeDirectory + "/";
                DataCache.SetCache(cacheKey, ps);
            }
            else
            {
                ps = pscache;
            }
            var tabController = new TabController();
            var tab           = tabController.GetTab(tabID, ps.PortalId, false);

            if (ReferenceEquals(tab, null))
            {
                return(null);
            }
            ps.ActiveTab = tab;

            try
            {
                // Now to put it into the HTTPContext
                if (ReferenceEquals(HttpContext.Current, null))
                {
                    var        page          = ps.PortalAlias.HTTPAlias;
                    var        query         = string.Empty;
                    TextWriter output        = null;
                    var        workerrequest = new SimpleWorkerRequest(page, query, output);
                    HttpContext.Current = new HttpContext(workerrequest);
                    HttpContext.Current.Items.Add("PortalSettings", ps);
                }
                else
                {
                    HttpContext.Current.Items.Remove("PortalSettings");
                    HttpContext.Current.Items.Add("PortalSettings", ps);
                }
            }
            catch (Exception)
            { }

            return(ps);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns a list of tab and redirects from the database, for the specified portal
        /// Assumes that the dictionary should have any existing items replaced if the portalid is specified
        /// and the portal tabs already exist in the dictionary.
        /// </summary>
        /// <param name="existingTabs"></param>
        /// <param name="portalId"></param>
        /// <param name="settings"></param>
        /// <param name="customAliasTabs"></param>
        /// <remarks>
        ///    Each dictionary entry in the return value is a complex data type of another dictionary that is indexed by the url culture.  If there is
        ///    only one culture for the Url, it will be that culture.
        /// </remarks>
        /// <returns></returns>
        private static SharedDictionary <int, SharedDictionary <string, string> > BuildUrlDictionary(SharedDictionary <int, SharedDictionary <string, string> > existingTabs,
                                                                                                     int portalId,
                                                                                                     FriendlyUrlSettings settings,
                                                                                                     ref SharedDictionary <string, string> customAliasTabs)
        {
            //fetch tabs with redirects
            var tabs = FriendlyUrlController.GetTabs(portalId, false, null, settings);

            if (existingTabs == null)
            {
                existingTabs = new SharedDictionary <int, SharedDictionary <string, string> >();
            }
            if (customAliasTabs == null)
            {
                customAliasTabs = new SharedDictionary <string, string>();
            }


            //go through each tab in the found list
            foreach (TabInfo tab in tabs.Values)
            {
                //check the custom alias tabs collection and add to the dictionary where necessary
                foreach (var customAlias in tab.CustomAliases)
                {
                    string key = tab.TabID.ToString() + ":" + customAlias.Key;
                    using (customAliasTabs.GetWriteLock())  //obtain write lock on custom alias Tabs
                    {
                        if (customAliasTabs.ContainsKey(key) == false)
                        {
                            customAliasTabs.Add(key, customAlias.Value);
                        }
                    }
                }

                foreach (TabUrlInfo redirect in tab.TabUrls)
                {
                    if (redirect.HttpStatus == "200")
                    {
                        string url = redirect.Url;
                        //770 : add in custom alias into the tab path for the custom Urls
                        if (redirect.PortalAliasUsage != PortalAliasUsageType.Default && redirect.PortalAliasId > 0)
                        {
                            //there is a custom http alias specified for this portal alias
                            var             pac   = new PortalAliasController();
                            PortalAliasInfo alias = pac.GetPortalAliasByPortalAliasID(redirect.PortalAliasId);
                            if (alias != null)
                            {
                                string customHttpAlias = alias.HTTPAlias;
                                url = customHttpAlias + "::" + url;
                            }
                        }
                        string cultureKey = redirect.CultureCode.ToLower();
                        int    tabid      = tab.TabID;
                        using (existingTabs.GetWriteLock())
                        {
                            if (existingTabs.ContainsKey(tabid) == false)
                            {
                                var entry = new SharedDictionary <string, string>();
                                using (entry.GetWriteLock())
                                {
                                    entry.Add(cultureKey, url);
                                }
                                //871 : use lower case culture code as key
                                existingTabs.Add(tab.TabID, entry);
                            }
                            else
                            {
                                SharedDictionary <string, string> entry = existingTabs[tabid];
                                //replace tab if existing but was retreieved from tabs call
                                if (tab.PortalID == portalId || portalId == -1)
                                {
                                    using (entry.GetWriteLock())
                                    {
                                        if (entry.ContainsKey(cultureKey) == false)
                                        {
                                            //add the culture and set in parent dictionary
                                            //871 : use lower case culture code as key
                                            entry.Add(cultureKey, url);
                                            existingTabs[tabid] = entry;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(existingTabs);
        }