コード例 #1
0
        /// <summary>
        ///   Includes page urls on the sitemap
        /// </summary>
        /// <remarks>
        ///   Pages that are included:
        ///   - are not deleted
        ///   - are not disabled
        ///   - are normal pages (not links,...)
        ///   - are visible (based on date and permissions)
        /// </remarks>
        public override List<SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            var objTabs = new TabController();
            SitemapUrl pageUrl = null;
            var urls = new List<SitemapUrl>();

            useLevelBasedPagePriority = bool.Parse(PortalController.GetPortalSetting("SitemapLevelMode", portalId, "False"));
            minPagePriority = float.Parse(PortalController.GetPortalSetting("SitemapMinPriority", portalId, "0.1"), CultureInfo.InvariantCulture);
            includeHiddenPages = bool.Parse(PortalController.GetPortalSetting("SitemapIncludeHidden", portalId, "True"));

            this.ps = ps;

            foreach (TabInfo objTab in objTabs.GetTabsByPortal(portalId).Values)
            {
                if (!objTab.IsDeleted && !objTab.DisableLink && objTab.TabType == TabType.Normal && (Null.IsNull(objTab.StartDate) || objTab.StartDate < DateTime.Now) &&
                    (Null.IsNull(objTab.EndDate) || objTab.EndDate > DateTime.Now) && IsTabPublic(objTab.TabPermissions))
                {
                    if (includeHiddenPages || objTab.IsVisible)
                    {
                        pageUrl = GetPageUrl(objTab, (ps.ContentLocalizationEnabled) ? objTab.CultureCode : null);
                        urls.Add(pageUrl);
                    }
                }
            }


            return urls;
        }
コード例 #2
0
ファイル: Toast.ascx.cs プロジェクト: heitkea/DNN_DEV_7_2
        //This method is copied from user skin object
        private int FindMessageTab()
        {
            var tabController = new TabController();
            var moduleController = new ModuleController();

            //On brand new install the new Message Center Module is on the child page of User Profile Page 
            //On Upgrade to 6.2.0, the Message Center module is on the User Profile Page
            var profileTab = tabController.GetTab(PortalSettings.UserTabId, PortalSettings.PortalId, false);
            if (profileTab != null)
            {
                var childTabs = tabController.GetTabsByPortal(profileTab.PortalID).DescendentsOf(profileTab.TabID);
                foreach (TabInfo tab in childTabs)
                {
                    foreach (KeyValuePair<int, ModuleInfo> kvp in moduleController.GetTabModules(tab.TabID))
                    {
                        var module = kvp.Value;
                        if (module.DesktopModule.FriendlyName == "Message Center")
                        {
                            return tab.TabID;                            
                        }
                    }
                }
            }

            //default to User Profile Page
            return PortalSettings.UserTabId;            
        }        
コード例 #3
0
ファイル: DnnUtils.cs プロジェクト: robsiera/NBrightDNN
        public static DotNetNuke.Entities.Tabs.TabCollection GetPortalTabs(int portalId)
        {
            var portalTabs = (DotNetNuke.Entities.Tabs.TabCollection)NBrightCore.common.Utils.GetCache("NBright_portalTabs" + portalId.ToString(""));

            if (portalTabs == null)
            {
                var objTabCtrl = new DotNetNuke.Entities.Tabs.TabController();
                portalTabs = objTabCtrl.GetTabsByPortal(portalId);
                NBrightCore.common.Utils.SetCache("NBright_portalTabs" + portalId.ToString(""), portalTabs);
            }
            return(portalTabs);
        }
コード例 #4
0
ファイル: TabIndexer.cs プロジェクト: hungnt-me/Dnn.Platform
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Returns the collection of SearchDocuments populated with Tab MetaData for the given portal.
        /// </summary>
        /// <param name="portalId"></param>
        /// <param name="startDate"></param>
        /// <returns></returns>
        /// <history>
        ///     [vnguyen]   04/16/2013  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override IEnumerable<SearchDocument> GetSearchDocuments(int portalId, DateTime startDate)
        {
            var searchDocuments = new List<SearchDocument>();
            var tabController = new TabController();
            var tabs = tabController.GetTabsByPortal(portalId).AsList().Where(t => ((t.TabSettings["AllowIndex"] == null) ||
                                                                                    (t.TabSettings["AllowIndex"] != null && t.TabSettings["AllowIndex"].ToString().ToLower() != "false")) &&
                                                                                    t.LastModifiedOnDate > startDate);
            try
            {
                foreach (var tab in tabs)
                {
                    var searchDoc = new SearchDocument
                    {
                        SearchTypeId = TabSearchTypeId,
                        UniqueKey = Constants.TabMetaDataPrefixTag + tab.TabID,
                        TabId = tab.TabID,
                        PortalId = tab.PortalID,
                        CultureCode = tab.CultureCode,
                        ModifiedTimeUtc = tab.LastModifiedOnDate,
                        Body = tab.PageHeadText,
                        Description = tab.Description
                    };
                    searchDoc.Keywords.Add("keywords", tab.KeyWords);

                    //Using TabName for searchDoc.Title due to higher prevalence and relavency || TabTitle will be stored as a keyword
                    searchDoc.Title = tab.TabName;
                    searchDoc.Keywords.Add("title", tab.Title);
                    
                    if (tab.Terms != null && tab.Terms.Count > 0)
                    {
                        searchDoc.Tags = tab.Terms.Select(t => t.Name);
                    }

                    Logger.Trace("TabIndexer: Search document for metaData added for page [" + tab.Title + " tid:" + tab.TabID + "]");

                    searchDocuments.Add(searchDoc);
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
            }

            return searchDocuments;
        }
コード例 #5
0
        /// <summary>
        /// Will take a link like http:\\... to a file or page and try to return a DNN-style info like
        /// Page:35 or File:43003
        /// </summary>
        /// <param name="potentialFilePath"></param>
        /// <returns></returns>
        public string TryToResolveOneLinkToInternalDnnCode(string potentialFilePath)
        {
            var portalInfo = PortalSettings.Current; //PortalController.Instance.GetCurrentPortalSettings();

            // Try file reference
            var fileInfo = FileManager.Instance.GetFile(portalInfo.PortalId, potentialFilePath);
            if (fileInfo != null)
                return "File:" + fileInfo.FileId;

            // Try page / tab ID
            var tabController = new TabController();
            var tabCollection = tabController.GetTabsByPortal(portalInfo.PortalId);
            var tabInfo = tabCollection.Select(tab => tab.Value)
                                       .Where(tab => tab.TabPath == potentialFilePath)
                                       .FirstOrDefault();
            if (tabInfo != null)
                return "Page:" + tabInfo.TabID;

            return potentialFilePath;
        }
コード例 #6
0
        public override bool HasViewPermission(SearchResult searchResult)
        {
            var viewable = false;
            if (searchResult.ModuleId > 0)
            {
                //Get All related tabIds from moduleId (while minimizing DB access; using caching)
                var tabController = new TabController();
                var moduleId = searchResult.ModuleId;
                // The next call has over 30% performance enhancement over the above one
                var tabModules = tabController.GetTabsByPortal(searchResult.PortalId).Values
                    .SelectMany(tabinfo => tabinfo.ChildModules.Where(kv => kv.Key == moduleId)).Select(m => m.Value);

                foreach (ModuleInfo module in tabModules)
                {
                    var tab = tabController.GetTab(module.TabID, searchResult.PortalId, false);
                    if (!module.IsDeleted && !tab.IsDeleted && TabPermissionController.CanViewPage(tab))
                    {
                        //Check If authorised to View Module
                        if (ModulePermissionController.CanViewModule(module))
                        {
                            //Verify against search document permissions
                            if (string.IsNullOrEmpty(searchResult.Permissions) || PortalSecurity.IsInRoles(searchResult.Permissions))
                            {
                                viewable = true;
                                if (string.IsNullOrEmpty(searchResult.Url))
                                {
                                    searchResult.Url = TestableGlobals.Instance.NavigateURL(module.TabID, string.Empty, searchResult.QueryString);
                                }
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                viewable = true;
            }

            return viewable;
        }
コード例 #7
0
        public HttpResponseMessage GetNonTranslatedPages(string languageCode)
        {
            var request = HttpContext.Current.Request;
           var locale = new LocaleController().GetLocale(languageCode);

            List<PageDto> pages = new List<PageDto>();
            if (!IsDefaultLanguage(locale.Code))
            {
                TabController ctl = new TabController();
                var nonTranslated = (from t in ctl.GetTabsByPortal(PortalSettings.PortalId).WithCulture(locale.Code, false).Values where !t.IsTranslated && !t.IsDeleted select t);
                foreach (TabInfo page in nonTranslated)
                {
                    pages.Add(new PageDto()
                    {
                        Name = page.TabName,
                        ViewUrl = DotNetNuke.Common.Globals.NavigateURL(page.TabID),
                        EditUrl = DotNetNuke.Common.Globals.NavigateURL(page.TabID, "Tab", "action=edit", "returntabid=" + PortalSettings.ActiveTab.TabID)
                    });
                }
            }
            return Request.CreateResponse(HttpStatusCode.OK, pages);
        }
コード例 #8
0
        private void RewriteUrl(HttpApplication app, out string portalAlias)
        {
            HttpRequest request = app.Request;
            HttpResponse response = app.Response;
            string requestedPath = app.Request.Url.AbsoluteUri;


            portalAlias = "";

            //determine portal alias looking for longest possible match
            String myAlias = Globals.GetDomainName(app.Request, true);
            PortalAliasInfo objPortalAlias;
            do
            {
                objPortalAlias = PortalAliasController.GetPortalAliasInfo(myAlias);

                if (objPortalAlias != null)
                {
                    portalAlias = myAlias;
                    break;
                }

                int slashIndex = myAlias.LastIndexOf('/');
                myAlias = slashIndex > 1 ? myAlias.Substring(0, slashIndex) : "";
            } while (myAlias.Length > 0);


            app.Context.Items.Add("UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri);

            //Friendly URLs are exposed externally using the following format
            //http://www.domain.com/tabid/###/mid/###/ctl/xxx/default.aspx
            //and processed internally using the following format
            //http://www.domain.com/default.aspx?tabid=###&mid=###&ctl=xxx
            //The system for accomplishing this is based on an extensible Regex rules definition stored in /SiteUrls.config
            string sendTo = "";

            //save and remove the querystring as it gets added back on later
            //path parameter specifications will take precedence over querystring parameters
            string strQueryString = "";
            if ((!String.IsNullOrEmpty(app.Request.Url.Query)))
            {
                strQueryString = request.QueryString.ToString();
                requestedPath = requestedPath.Replace(app.Request.Url.Query, "");
            }

            //get url rewriting rules 
            RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;

            //iterate through list of rules
            int matchIndex = -1;
            for (int ruleIndex = 0; ruleIndex <= rules.Count - 1; ruleIndex++)
            {
                //check for the existence of the LookFor value 
                string pattern = "^" +
                                 RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[ruleIndex].LookFor) +
                                 "$";
                Match objMatch = Regex.Match(requestedPath, pattern, RegexOptions.IgnoreCase);

                //if there is a match
                if ((objMatch.Success))
                {
                    //create a new URL using the SendTo regex value
                    sendTo = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath,
                                                      Regex.Replace(requestedPath, pattern, rules[ruleIndex].SendTo,
                                                                    RegexOptions.IgnoreCase));

                    string parameters = objMatch.Groups[2].Value;
                    //process the parameters
                    if ((parameters.Trim().Length > 0))
                    {
                        //split the value into an array based on "/" ( ie. /tabid/##/ )
                        parameters = parameters.Replace("\\", "/");
                        string[] splitParameters = parameters.Split('/');
                        //icreate a well formed querystring based on the array of parameters
                        for (int parameterIndex = 0; parameterIndex < splitParameters.Length; parameterIndex++)
                        {
                            //ignore the page name 
                            if (
                                splitParameters[parameterIndex].IndexOf(".aspx",
                                                                        StringComparison.InvariantCultureIgnoreCase) ==
                                -1)
                            {
                                //get parameter name
                                string parameterName = splitParameters[parameterIndex].Trim();
                                if (parameterName.Length > 0)
                                {
                                    //add parameter to SendTo if it does not exist already  
                                    if (
                                        sendTo.IndexOf("?" + parameterName + "=",
                                                       StringComparison.InvariantCultureIgnoreCase) == -1 &&
                                        sendTo.IndexOf("&" + parameterName + "=",
                                                       StringComparison.InvariantCultureIgnoreCase) == -1)
                                    {
                                        //get parameter delimiter
                                        string parameterDelimiter = sendTo.IndexOf("?", StringComparison.Ordinal) != -1 ? "&" : "?";
                                        sendTo = sendTo + parameterDelimiter + parameterName;
                                        //get parameter value
                                        string parameterValue = "";
                                        if (parameterIndex < splitParameters.Length - 1)
                                        {
                                            parameterIndex += 1;
                                            if (!String.IsNullOrEmpty(splitParameters[parameterIndex].Trim()))
                                            {
                                                parameterValue = splitParameters[parameterIndex].Trim();
                                            }
                                        }
                                        //add the parameter value
                                        if (parameterValue.Length > 0)
                                        {
                                            sendTo = sendTo + "=" + parameterValue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    matchIndex = ruleIndex;
                    break; //exit as soon as it processes the first match
                }
            }
            if (!String.IsNullOrEmpty(strQueryString))
            {
                //add querystring parameters back to SendTo
                string[] parameters = strQueryString.Split('&');
                //iterate through the array of parameters
                for (int parameterIndex = 0; parameterIndex <= parameters.Length - 1; parameterIndex++)
                {
                    //get parameter name
                    string parameterName = parameters[parameterIndex];
                    if (parameterName.IndexOf("=", StringComparison.Ordinal) != -1)
                    {
                        parameterName = parameterName.Substring(0, parameterName.IndexOf("=", StringComparison.Ordinal));
                    }
                    //check if parameter already exists
                    if (sendTo.IndexOf("?" + parameterName + "=", StringComparison.InvariantCultureIgnoreCase) == -1 &&
                        sendTo.IndexOf("&" + parameterName + "=", StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        //add parameter to SendTo value
                        sendTo = sendTo.IndexOf("?", StringComparison.Ordinal) != -1
                                     ? sendTo + "&" + parameters[parameterIndex]
                                     : sendTo + "?" + parameters[parameterIndex];
                    }
                }
            }

            //if a match was found to the urlrewrite rules
            if (matchIndex != -1)
            {
                if (rules[matchIndex].SendTo.StartsWith("~"))
                {
                    //rewrite the URL for internal processing
                    RewriterUtils.RewriteUrl(app.Context, sendTo);
                }
                else
                {
                    //it is not possible to rewrite the domain portion of the URL so redirect to the new URL
                    response.Redirect(sendTo, true);
                }
            }
            else
            {
                //Try to rewrite by TabPath
                string url;
                if (Globals.UsePortNumber() &&
                    ((app.Request.Url.Port != 80 && !app.Request.IsSecureConnection) ||
                     (app.Request.Url.Port != 443 && app.Request.IsSecureConnection)))
                {
                    url = app.Request.Url.Host + ":" + app.Request.Url.Port + app.Request.Url.LocalPath;
                }
                else
                {
                    url = app.Request.Url.Host + app.Request.Url.LocalPath;
                }

                if (!String.IsNullOrEmpty(myAlias))
                {
                    if (objPortalAlias != null)
                    {
                        int portalID = objPortalAlias.PortalID;
                        //Identify Tab Name 
                        string tabPath = url;
                        if (tabPath.StartsWith(myAlias))
                        {
                            tabPath = url.Remove(0, myAlias.Length);
                        }
                        //Default Page has been Requested
                        if ((tabPath == "/" + Globals.glbDefaultPage.ToLower()))
                        {
                            return;
                        }

                        //Start of patch
                        string cultureCode = string.Empty;

                        Dictionary<string, Locale> dicLocales = LocaleController.Instance.GetLocales(portalID);
                        if (dicLocales.Count > 1)
                        {
                            String[] splitUrl = app.Request.Url.ToString().Split('/');

                            foreach (string culturePart in splitUrl)
                            {
                                if (culturePart.IndexOf("-", StringComparison.Ordinal) > -1)
                                {
                                    foreach (KeyValuePair<string, Locale> key in dicLocales)
                                    {
                                        if (key.Key.ToLower().Equals(culturePart.ToLower()))
                                        {
                                            cultureCode = key.Value.Code;
                                            tabPath = tabPath.Replace("/" + culturePart, "");
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        // Check to see if the tab exists (if localization is enable, check for the specified culture)
                        int tabID = TabController.GetTabByTabPath(portalID,
                                                                  tabPath.Replace("/", "//").Replace(".aspx", ""),
                                                                  cultureCode);

                        // Check to see if neutral culture tab exists
                        if ((tabID == Null.NullInteger && cultureCode.Length > 0))
                        {
                            tabID = TabController.GetTabByTabPath(portalID,
                                                                  tabPath.Replace("/", "//").Replace(".aspx", ""), "");
                        }
                        //End of patch

                        if ((tabID != Null.NullInteger))
                        {
                            string sendToUrl = "~/" + Globals.glbDefaultPage + "?TabID=" + tabID;
                            if (!cultureCode.Equals(string.Empty))
                            {
                                sendToUrl = sendToUrl + "&language=" + cultureCode;
                            }
                            if ((!String.IsNullOrEmpty(app.Request.Url.Query)))
                            {
                                sendToUrl = sendToUrl + "&" + app.Request.Url.Query.TrimStart('?');
                            }
                            RewriterUtils.RewriteUrl(app.Context, sendToUrl);
                            return;
                        }
                        tabPath = tabPath.ToLower();
                        if ((tabPath.IndexOf('?') != -1))
                        {
                            tabPath = tabPath.Substring(0, tabPath.IndexOf('?'));
                        }

                        //Get the Portal
                        PortalInfo portal = new PortalController().GetPortal(portalID);
                        string requestQuery = app.Request.Url.Query;
                        if (!string.IsNullOrEmpty(requestQuery))
                        {
                            requestQuery = Regex.Replace(requestQuery, "&?tabid=\\d+", string.Empty,
                                                         RegexOptions.IgnoreCase);
                            requestQuery = Regex.Replace(requestQuery, "&?portalid=\\d+", string.Empty,
                                                         RegexOptions.IgnoreCase);
                            requestQuery = requestQuery.TrimStart('?', '&');
                        }
                        if (tabPath == "/login.aspx")
                        {
                            if (portal.LoginTabId > Null.NullInteger && Globals.ValidateLoginTabID(portal.LoginTabId))
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.LoginTabId + "&" + requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.LoginTabId);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.HomeTabId + "&portalid=" + portalID + "&ctl=login&" +
                                                             requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.HomeTabId + "&portalid=" + portalID + "&ctl=login");
                                }
                            }
                            return;
                        }
                        if (tabPath == "/register.aspx")
                        {
                            if (portal.RegisterTabId > Null.NullInteger)
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.RegisterTabId + "&portalid=" + portalID + "&" +
                                                             requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.RegisterTabId + "&portalid=" + portalID);
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(requestQuery))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.HomeTabId + "&portalid=" + portalID +
                                                             "&ctl=Register&" + requestQuery);
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" +
                                                             portal.HomeTabId + "&portalid=" + portalID +
                                                             "&ctl=Register");
                                }
                            }
                            return;
                        }
                        if (tabPath == "/terms.aspx")
                        {
                            if (!string.IsNullOrEmpty(requestQuery))
                            {
                                RewriterUtils.RewriteUrl(app.Context,
                                                         "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                                         "&portalid=" + portalID + "&ctl=Terms&" + requestQuery);
                            }
                            else
                            {
                                RewriterUtils.RewriteUrl(app.Context,
                                                         "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                                         "&portalid=" + portalID + "&ctl=Terms");
                            }
                            return;
                        }
                        if (tabPath == "/privacy.aspx")
                        {
                            if (!string.IsNullOrEmpty(requestQuery))
                            {
                                RewriterUtils.RewriteUrl(app.Context,
                                                         "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                                         "&portalid=" + portalID + "&ctl=Privacy&" + requestQuery);
                            }
                            else
                            {
                                RewriterUtils.RewriteUrl(app.Context,
                                                         "~/" + Globals.glbDefaultPage + "?TabID=" + portal.HomeTabId +
                                                         "&portalid=" + portalID + "&ctl=Privacy");
                            }
                            return;
                        }
                        tabPath = tabPath.Replace("/", "//");
                        tabPath = tabPath.Replace(".aspx", "");
                        var objTabController = new TabController();
                        TabCollection objTabs = objTabController.GetTabsByPortal(tabPath.StartsWith("//host") ? Null.NullInteger : portalID);
                        foreach (KeyValuePair<int, TabInfo> kvp in objTabs)
                        {
                            if ((kvp.Value.IsDeleted == false && kvp.Value.TabPath.ToLower() == tabPath))
                            {
                                if ((!String.IsNullOrEmpty(app.Request.Url.Query)))
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID +
                                                             "&" + app.Request.Url.Query.TrimStart('?'));
                                }
                                else
                                {
                                    RewriterUtils.RewriteUrl(app.Context,
                                                             "~/" + Globals.glbDefaultPage + "?TabID=" + kvp.Value.TabID);
                                }
                                return;
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
        protected void MakeNeutral_Click(object sender, EventArgs e)
        {
            var t = new TabController();
            if (t.GetTabsByPortal(PortalId).WithParentId(_tab.TabID).Count == 0)
            {
                var defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId);

                t.ConvertTabToNeutralLanguage(PortalId, _tab.TabID, defaultLocale.Code, true);

                Response.Redirect(Request.RawUrl, false);
            }
        }
コード例 #10
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   UpdateWorkFlow updates the currently active Workflow
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="WorkFlowType">The type of workflow (Module | Page | Site)</param>
        /// <param name = "WorkflowID">The ID of the Workflow</param>
        /// <param name="ObjectID">The ID of the object to apply the update to (depends on WorkFlowType)</param>
        /// <param name="ReplaceExistingSettings">Should existing settings be overwritten?</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        public void UpdateWorkflow(int ObjectID, string WorkFlowType, int WorkflowID, bool ReplaceExistingSettings)
        {
            var tabController = new TabController();
            var moduleController = new ModuleController();

            switch (WorkFlowType)
            {
                case "Module":
                    moduleController.UpdateModuleSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                    break;
                case "Page":
                    tabController.UpdateTabSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                    if (ReplaceExistingSettings)
                    {
                        //Get All Modules on the current Tab
                        foreach (var kvp in moduleController.GetTabModules(ObjectID))
                        {
                            ClearModuleSettings(kvp.Value);
                        }
                    }
                    break;
                case "Site":
                    PortalController.UpdatePortalSetting(ObjectID, "WorkflowID", WorkflowID.ToString());
                    if (ReplaceExistingSettings)
                    {
                        //Get All Tabs aon the Site
                        foreach (var kvp in tabController.GetTabsByPortal(ObjectID))
                        {
                            tabController.DeleteTabSetting(kvp.Value.TabID, "WorkFlowID");
                        }
                        //Get All Modules in the current Site
                        foreach (ModuleInfo objModule in moduleController.GetModules(ObjectID))
                        {
                            ClearModuleSettings(objModule);
                        }
                    }
                    break;
            }
        }
コード例 #11
0
        public static Dictionary<int, TabInfo> GetTabs(int portalId, bool includeStdUrls, PortalSettings portalSettings, FriendlyUrlSettings settings)
        {
            var tc = new TabController();
            //811 : friendly urls for admin/host tabs
            var tabs = new Dictionary<int, TabInfo>();
            var portalTabs = tc.GetTabsByPortal(portalId);
            var hostTabs = tc.GetTabsByPortal(-1);

            foreach (TabInfo tab in portalTabs.Values)
            {
                tabs[tab.TabID] = tab;
            }

            if (settings.FriendlyAdminHostUrls)
            {
                foreach (TabInfo tab in hostTabs.Values)
                {
                    tabs[tab.TabID] = tab;
                }
            }
            return tabs;
        }
コード例 #12
0
        private IEnumerable<ItemDto> GetPageDescendantsInternal(int portalId, int parentId, int sortOrder, string searchText)
        {
            List<TabInfo> tabs;

            if (portalId == -1)
            {
                portalId = GetActivePortalId(parentId);
            }
            else
            {
                if (!IsPortalIdValid(portalId)) return new List<ItemDto>();
            }

            Func<TabInfo, bool> searchFunc;
            if (String.IsNullOrEmpty(searchText))
            {
                searchFunc = page => true;
            }
            else
            {
                searchFunc = page => page.LocalizedTabName.IndexOf(searchText, StringComparison.InvariantCultureIgnoreCase) > -1;
            }

            if (portalId > -1)
            {
                var includeHiddenTabs = PortalSettings.UserInfo.IsSuperUser || PortalSettings.UserInfo.IsInRole("Administrators");
                tabs =
                    TabController.GetPortalTabs(portalId, Null.NullInteger, false, null, includeHiddenTabs, false, false, true, false)
                                 .Where(tab => searchFunc(tab) && tab.ParentId == parentId && !tab.DisableLink)
                                 .OrderBy(tab => tab.TabOrder)
                                 .ToList();
            }
            else
            {
                if (PortalSettings.UserInfo.IsSuperUser)
                {
                    var tabController = new TabController();

                    tabs = tabController.GetTabsByPortal(-1).AsList()
                        .Where(tab => searchFunc(tab) && tab.ParentId == parentId && !tab.IsDeleted && !tab.DisableLink)
                        .OrderBy(tab => tab.TabOrder)
                        .ToList();
                }
                else
                {
                    return new List<ItemDto>();
                }
            }

            var pages = tabs.Select(tab => new ItemDto {
                    Key = tab.TabID.ToString(CultureInfo.InvariantCulture), 
                    Value = tab.LocalizedTabName, 
                    HasChildren = tab.HasChildren,
                    Selectable = true
                });

            return ApplySort(pages, sortOrder);
        }
コード例 #13
0
ファイル: Tabs.ascx.cs プロジェクト: patonomatic/VUWTC
        private bool MoveTab(TabInfo tab, TabInfo targetTab, Position position)
        {
            //Validate Tab Path
            if (!IsValidTabPath(tab, Globals.GenerateTabPath((targetTab == null) ? Null.NullInteger : targetTab.TabID, tab.TabName)))
            {
                return false;
            }

            var tabController = new TabController();

            //get current siblings of moving tab
            var siblingTabs = GetSiblingTabs(tab);
            int siblingCount = siblingTabs.Count;

            //move all current siblings of moving tab one level up in order
            int tabIndex = GetIndexOfTab(tab, siblingTabs);
            UpdateTabOrder(siblingTabs, tabIndex + 1, siblingCount - 1, -2);

            //get siblings of new position
            siblingTabs = GetSiblingTabs(targetTab);
            siblingCount = siblingTabs.Count;

            //First make sure the list of siblings at the new position is sorted and spaced
            UpdateTabOrder(siblingTabs, tab.CultureCode, 2);

            //Find Index position of new positin in the Sibling List
            var targetIndex = GetIndexOfTab(targetTab, siblingTabs);

            switch (position)
            {
                case Position.Above:
                    targetIndex = targetIndex - 1;
                    break;
                case Position.Below:
                    break;
            }

            //We need to update the taborder for items that were after that position
            UpdateTabOrder(siblingTabs, targetIndex + 1, siblingCount - 1, 2);

            //Get the descendents of old tab position now before the new parentid is updated
            var descendantTabs = tabController.GetTabsByPortal(tab.PortalID).DescendentsOf(tab.TabID);

            //Update the current Tab to reflect new parent id and new taborder
            tab.ParentId = targetTab.ParentId;

            tabController.UpdateTab(tab);

            //Update the moving tabs level and tabpath
            tab.Level = targetTab.Level;

            //Update TabOrder as the previous UpdateTab call pushes the tab to the bottom
            switch (position)
            {
                case Position.Above:
                    tab.TabOrder = targetTab.TabOrder - 2;
                    break;
                case Position.Below:
                    tab.TabOrder = targetTab.TabOrder + 1;
                    break;
            }

            UpdateTabOrder(tab, true);

            //Update the Descendents of the moving tab
            UpdateDescendantLevel(descendantTabs, tab.Level + 1);
            ShowSuccessMessage(string.Format(Localization.GetString("TabMoved", LocalResourceFile), tab.TabName));
            return true;
        }
コード例 #14
0
ファイル: DataCache.cs プロジェクト: huayang912/cs-dotnetnuke
 public static void ClearPortalCache(int PortalId, bool Cascade)
 {
     RemovePersistentCacheItem(string.Format(PortalCacheKey, PortalId));
     RemoveCache("Folders:" + PortalId.ToString());
     RemoveCache("GetSkins" + PortalId.ToString());
     if (Cascade)
     {
         TabController objTabs = new TabController();
         foreach (KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal(PortalId))
         {
             TabInfo objTab = tabPair.Value;
             ClearModuleCache(objTab.TabID);
         }
         ClearTabPermissionsCache(PortalId);
     }
     ClearTabsCache(PortalId);
 }
コード例 #15
0
        protected void enabledCheckbox_CheckChanged(object sender, EventArgs e)
        {
            try
            {
                if ((sender) is DnnCheckBox)
                {
                    var enabledCheckbox = (DnnCheckBox) sender;
                    int languageId = int.Parse(enabledCheckbox.CommandArgument);
                    Locale locale = LocaleController.Instance.GetLocale(languageId);
                    Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId);

                    Dictionary<string, Locale> enabledLanguages = LocaleController.Instance.GetLocales(PortalId);

                    var tabController = new TabController();
                    var localizedTabs = PortalSettings.ContentLocalizationEnabled ?
                        tabController.GetTabsByPortal(PortalId).WithCulture(locale.Code, false).AsList() : new List<TabInfo>();

                    var redirectUrl = string.Empty;
                    if (enabledCheckbox.Enabled)
                    {
                        // do not touch default language
                        if (enabledCheckbox.Checked)
                        {
                            if (!enabledLanguages.ContainsKey(locale.Code))
                            {
                                //Add language to portal
                                Localization.AddLanguageToPortal(PortalId, languageId, true);
                            }

                            //restore the tabs and modules
                            var moduleController = new ModuleController();
                            foreach (var tab in localizedTabs)
                            {
                                tabController.RestoreTab(tab, PortalSettings);
                                moduleController.GetTabModules(tab.TabID).Values.ToList().ForEach(moduleController.RestoreModule);
                            }
                        }
                        else
                        {
                            //remove language from portal
                            Localization.RemoveLanguageFromPortal(PortalId, languageId);

                            //if the disable language is current language, should redirect to default language.
                            if(locale.Code.Equals(Thread.CurrentThread.CurrentUICulture.ToString(), StringComparison.InvariantCultureIgnoreCase))
                            {
                                redirectUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID,
                                                                    PortalSettings.ActiveTab.IsSuperTab,
                                                                    PortalSettings, "", defaultLocale.Code);
                            }

                            //delete the tabs in this language
                            foreach (var tab in localizedTabs)
                            {
                                tab.DefaultLanguageGuid = Guid.Empty;
                                tabController.SoftDeleteTab(tab.TabID, PortalSettings);
                            }
                        }
                    }

                    //Redirect to refresh page (and skinobjects)
                    if (string.IsNullOrEmpty(redirectUrl))
                    {
                        redirectUrl = Globals.NavigateURL();
                    }

                    Response.Redirect(redirectUrl, true);
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
コード例 #16
0
        private void LoadData()
        {
            var moduleController = new ModuleController();
            var tabController = new TabController();
            var currentLocale = LocaleController.Instance.GetCurrentLocale(PortalId);

            TabCollection tabsList = modeButtonList.SelectedValue == "ALL"
                             ? tabController.GetTabsByPortal(PortalId)
                             : tabController.GetTabsByPortal(PortalId).WithCulture(currentLocale.Code, true);

            DeletedTabs = tabsList.Values.Where(tab => tab.IsDeleted)
                                            .OrderBy(tab => tab.TabPath)
                                            .ToList();

            DeletedModules = moduleController.GetRecycleModules(PortalId)
                                                .Cast<ModuleInfo>()
                                                .Where(module => module.IsDeleted && (modeButtonList.SelectedValue == "ALL" || module.CultureCode == currentLocale.Code))
                                                .ToList();
        }
コード例 #17
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (UserInfo.IsSuperUser)
                {
                    //Update Language
                    if (Language == null)
                    {
                        _Language = LocaleController.Instance.GetLocale(languageComboBox.SelectedValue);
                        if (_Language == null)
                        {
                            _Language = new Locale();
                            Language.Code = languageComboBox.SelectedValue;
                        }
                    }
                    Language.Fallback = fallBackComboBox.SelectedValue;
                    Language.Text = CultureInfo.CreateSpecificCulture(Language.Code).NativeName;
                    Localization.SaveLanguage(Language);
                }

                if (!IsLanguageEnabled(Language.Code))
                {
                    //Add language to portal
                    Localization.AddLanguageToPortal(PortalId, Language.LanguageId, true);
                }

                string roles = Null.NullString;
                if (IsAddMode)
                {
                    roles = string.Format("Administrators;{0}", string.Format("Translator ({0})", Language.Code));
                }
                else
                {
                    foreach (string role in translatorRoles.SelectedRoleNames)
                    {
                        roles += role + ";";
                    }

                    roles = roles.TrimEnd(';');
                }

                PortalController.UpdatePortalSetting(PortalId, string.Format("DefaultTranslatorRoles-{0}", Language.Code), roles);

                var tabCtrl = new TabController();
                TabCollection tabs = tabCtrl.GetTabsByPortal(PortalId).WithCulture(Language.Code, false);
                if (PortalSettings.ContentLocalizationEnabled && tabs.Count == 0)
                {
                    //Create Localized Pages
                    foreach (TabInfo t in tabCtrl.GetCultureTabList(PortalId))
                    {
                        tabCtrl.CreateLocalizedCopy(t, Language);
                    }

                    var portalCtl = new PortalController();
                    portalCtl.MapLocalizedSpecialPages(PortalId, Language.Code);
                }

                Response.Redirect(Globals.NavigateURL(), true);
                //Module failed to load
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #18
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Update module settings and permissions in database from ModuleInfo
        /// </summary>
        /// <param name="module">ModuleInfo of the module to update</param>
        /// <history>
        ///    [sleupold]   2007-09-24   commented
        ///    [vnguyen]    2010-05-10   Modified: Added update tabmodule version guid
        ///    [sleupold]   2010-12-09   Fixed .AllModule updates
        /// </history>
        /// -----------------------------------------------------------------------------
        public void UpdateModule(ModuleInfo module)
        {
            //Update ContentItem If neccessary
            if (module.ContentItemId == Null.NullInteger && module.ModuleID != Null.NullInteger)
            {
                CreateContentItem(module);
            }

            //update module
            dataProvider.UpdateModule(module.ModuleID,
                                      module.ModuleDefID,
                                      module.ContentItemId,
                                      module.AllTabs,
                                      module.StartDate,
                                      module.EndDate,
                                      module.InheritViewPermissions,
                                      module.IsShareable,
                                      module.IsShareableViewOnly,
                                      module.IsDeleted,
                                      UserController.GetCurrentUserInfo().UserID);

            //Update Tags
            ITermController termController = Util.GetTermController();
            termController.RemoveTermsFromContent(module);
            foreach (Term _Term in module.Terms)
            {
                termController.AddTermToContent(_Term, module);
            }

            var eventLogController = new EventLogController();
            eventLogController.AddLog(module, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.MODULE_UPDATED);

            //save module permissions
            ModulePermissionController.SaveModulePermissions(module);
            UpdateModuleSettings(module);
            module.VersionGuid = Guid.NewGuid();
            module.LocalizedVersionGuid = Guid.NewGuid();

            if (!Null.IsNull(module.TabID))
            {
                //update tabmodule
                dataProvider.UpdateTabModule(module.TabModuleID,
                                             module.TabID,
                                             module.ModuleID,
                                             module.ModuleTitle,
                                             module.Header,
                                             module.Footer,
                                             module.ModuleOrder,
                                             module.PaneName,
                                             module.CacheTime,
                                             module.CacheMethod,
                                             module.Alignment,
                                             module.Color,
                                             module.Border,
                                             module.IconFile,
                                             (int)module.Visibility,
                                             module.ContainerSrc,
                                             module.DisplayTitle,
                                             module.DisplayPrint,
                                             module.DisplaySyndicate,
                                             module.IsWebSlice,
                                             module.WebSliceTitle,
                                             module.WebSliceExpiryDate,
                                             module.WebSliceTTL,
                                             module.VersionGuid,
                                             module.DefaultLanguageGuid,
                                             module.LocalizedVersionGuid,
                                             module.CultureCode,
                                             UserController.GetCurrentUserInfo().UserID);

                eventLogController.AddLog(module, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.TABMODULE_UPDATED);

                //update module order in pane
                UpdateModuleOrder(module.TabID, module.ModuleID, module.ModuleOrder, module.PaneName);

                //set the default module
                if (PortalSettings.Current != null)
                {
                    if (module.IsDefaultModule)
                    {
                        if (module.ModuleID != PortalSettings.Current.DefaultModuleId)
                        {
                            //Update Setting
                            PortalController.UpdatePortalSetting(module.PortalID, "defaultmoduleid", module.ModuleID.ToString());
                        }
                        if (module.TabID != PortalSettings.Current.DefaultTabId)
                        {
                            //Update Setting
                            PortalController.UpdatePortalSetting(module.PortalID, "defaulttabid", module.TabID.ToString());
                        }
                    }
                    else
                    {
                        if (module.ModuleID == PortalSettings.Current.DefaultModuleId && module.TabID == PortalSettings.Current.DefaultTabId)
                        {
                            //Clear setting
                            PortalController.DeletePortalSetting(module.PortalID, "defaultmoduleid");
                            PortalController.DeletePortalSetting(module.PortalID, "defaulttabid");
                        }
                    }
                }
                //apply settings to all desktop modules in portal
                if (module.AllModules)
                {
                    var tabController = new TabController();
                    foreach (KeyValuePair<int, TabInfo> tabPair in tabController.GetTabsByPortal(module.PortalID))
                    {
                        TabInfo tab = tabPair.Value;
                        foreach (KeyValuePair<int, ModuleInfo> modulePair in GetTabModules(tab.TabID))
                        {
                            var targetModule = modulePair.Value;
                            targetModule.VersionGuid = Guid.NewGuid();
                            targetModule.LocalizedVersionGuid = Guid.NewGuid();

                            dataProvider.UpdateTabModule(targetModule.TabModuleID,
                                                         targetModule.TabID,
                                                         targetModule.ModuleID,
                                                         targetModule.ModuleTitle,
                                                         targetModule.Header,
                                                         targetModule.Footer,
                                                         targetModule.ModuleOrder,
                                                         targetModule.PaneName,
                                                         targetModule.CacheTime,
                                                         targetModule.CacheMethod,
                                                         module.Alignment,
                                                         module.Color,
                                                         module.Border,
                                                         module.IconFile,
                                                         (int)module.Visibility,
                                                         module.ContainerSrc,
                                                         module.DisplayTitle,
                                                         module.DisplayPrint,
                                                         module.DisplaySyndicate,
                                                         module.IsWebSlice,
                                                         module.WebSliceTitle,
                                                         module.WebSliceExpiryDate,
                                                         module.WebSliceTTL,
                                                         targetModule.VersionGuid,
                                                         targetModule.DefaultLanguageGuid,
                                                         targetModule.LocalizedVersionGuid,
                                                         targetModule.CultureCode,
                                                         UserController.GetCurrentUserInfo().UserID);

							ClearCache(targetModule.TabID);
                        }
                    }
                }
            }
            //Clear Cache for all TabModules
            foreach (ModuleInfo tabModule in GetModuleTabs(module.ModuleID))
            {
                ClearCache(tabModule.TabID);
            }
        }
コード例 #19
0
        /// <summary>
        /// Processess a template file for the new portal. This method will be called twice: for the portal template and for the admin template
        /// </summary>
        /// <param name="PortalId">PortalId of the new portal</param>
        /// <param name="TemplatePath">Path for the folder where templates are stored</param>
        /// <param name="TemplateFile">Template file to process</param>
        /// <param name="AdministratorId">UserId for the portal administrator. This is used to assign roles to this user</param>
        /// <param name="mergeTabs">Flag to determine whether Module content is merged.</param>
        /// <param name="IsNewPortal">Flag to determine is the template is applied to an existing portal or a new one.</param>
        /// <remarks>
        /// The roles and settings nodes will only be processed on the portal template file.
        /// </remarks>
        /// <history>
        /// 	[VMasanas]	27/08/2004	Created
        /// </history>
        public void ParseTemplate( int PortalId, string TemplatePath, string TemplateFile, int AdministratorId, PortalTemplateModuleAction mergeTabs, bool IsNewPortal )
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlNode node = null;
            int AdministratorRoleId = -1;
            int RegisteredRoleId = -1;
            int SubscriberRoleId = -1;
            RoleController objrole = new RoleController();
            bool isAdminTemplate = false;

            isAdminTemplate = ( TemplateFile == "admin.template" );

            // open the XML file
            try
            {
                xmlDoc.Load( TemplatePath + TemplateFile );
            }
            catch // error
            {
                // 
            }

            // settings, roles, folders and files can only be specified in portal templates, will be ignored on the admin template
            if( !isAdminTemplate )
            {
                // parse roles if available
                node = xmlDoc.SelectSingleNode( "//portal/roles" );
                if( node != null )
                {
                    ParseRoles( node, PortalId, AdministratorId, ref AdministratorRoleId, ref RegisteredRoleId, ref SubscriberRoleId );
                }

                // create required roles if not already created
                if( AdministratorRoleId == -1 )
                {
                    AdministratorRoleId = CreateRole( PortalId, "Administrators", "Portal Administrators", 0F, 0, "M", 0F, 0, "N", false, false );
                }
                if( RegisteredRoleId == -1 )
                {
                    RegisteredRoleId = CreateRole( PortalId, "Registered Users", "Registered Users", 0F, 0, "M", 0F, 0, "N", false, true );
                }
                if( SubscriberRoleId == -1 )
                {
                    SubscriberRoleId = CreateRole( PortalId, "Subscribers", "A public role for portal subscriptions", 0F, 0, "M", 0F, 0, "N", true, true );
                }

                objrole.AddUserRole( PortalId, AdministratorId, AdministratorRoleId, Null.NullDate, Null.NullDate );
                objrole.AddUserRole( PortalId, AdministratorId, RegisteredRoleId, Null.NullDate, Null.NullDate );
                objrole.AddUserRole( PortalId, AdministratorId, SubscriberRoleId, Null.NullDate, Null.NullDate );

                // parse portal folders
                node = xmlDoc.SelectSingleNode( "//portal/folders" );
                if( node != null )
                {
                    ParseFolders( node, PortalId );
                }
                // force creation of root folder if not present on template
                FolderController objController = new FolderController();
                if( objController.GetFolder( PortalId, "" ) == null )
                {
                    int folderid = objController.AddFolder( PortalId, "", (int)FolderController.StorageLocationTypes.InsecureFileSystem, true, false );
                    PermissionController objPermissionController = new PermissionController();
                    ArrayList arr = objPermissionController.GetPermissionByCodeAndKey( "SYSTEM_FOLDER", "" );
                    foreach( PermissionInfo objpermission in arr )
                    {
                        FileSystemUtils.SetFolderPermission( PortalId, folderid, objpermission.PermissionID, AdministratorRoleId, "" );
                        if( objpermission.PermissionKey == "READ" )
                        {
                            // add READ permissions to the All Users Role
                            FileSystemUtils.SetFolderPermission( PortalId, folderid, objpermission.PermissionID, int.Parse( Globals.glbRoleAllUsers ), "" );
                        }
                    }
                }

                // parse portal settings if available only for new portals
                node = xmlDoc.SelectSingleNode( "//portal/settings" );
                if( node != null & IsNewPortal )
                {
                    ParsePortalSettings( node, PortalId );
                }

                // update portal setup
                PortalInfo objportal = null;
                objportal = GetPortal( PortalId );
                UpdatePortalSetup( PortalId, AdministratorId, AdministratorRoleId, RegisteredRoleId, objportal.SplashTabId, objportal.HomeTabId, objportal.LoginTabId, objportal.UserTabId, objportal.AdminTabId );

                //Remove Exising Tabs if doing a "Replace"
                if( mergeTabs == PortalTemplateModuleAction.Replace )
                {
                    TabController objTabs = new TabController();
                    TabInfo objTab = null;
                    foreach( KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal( PortalId ) )
                    {
                        objTab = tabPair.Value;
                        if( !objTab.IsAdminTab )
                        {
                            //soft delete Tab
                            objTab.TabName = objTab.TabName + "_old";
                            objTab.IsDeleted = true;
                            objTabs.UpdateTab( objTab );
                            //Delete all Modules
                            ModuleController objModules = new ModuleController();
                            ModuleInfo objModule = null;
                            foreach( KeyValuePair<int, ModuleInfo> modulePair in objModules.GetTabModules( objTab.TabID ) )
                            {
                                objModule = modulePair.Value;
                                objModules.DeleteTabModule( objModule.TabID, objModule.ModuleID );
                            }
                        }
                    }
                }
            }

            // parse portal tabs
            node = xmlDoc.SelectSingleNode( "//portal/tabs" );
            if( node != null )
            {
                ParseTabs( node, PortalId, isAdminTemplate, mergeTabs, IsNewPortal );
            }
        }
コード例 #20
0
ファイル: Tabs.ascx.cs プロジェクト: patonomatic/VUWTC
 private static List<TabInfo> GetSiblingTabs(TabInfo objTab)
 {
     var objTabController = new TabController();
     return objTabController.GetTabsByPortal(objTab.PortalID).WithCulture(objTab.CultureCode, true).WithParentId(objTab.ParentId);
 }
コード例 #21
0
        /// <summary>
        /// Processes all tabs from the template
        /// </summary>
        /// <param name="nodeTabs">Template file node for the tabs</param>
        /// <param name="PortalId">PortalId of the new portal</param>
        /// <param name="IsAdminTemplate">True when processing admin template, false when processing portal template</param>
        /// <param name="mergeTabs">Flag to determine whether Module content is merged.</param>
        /// <param name="IsNewPortal">Flag to determine is the template is applied to an existing portal or a new one.</param>
        /// <remarks>
        /// When a special tab is found (HomeTab, UserTab, LoginTab, AdminTab) portal information will be updated.
        /// </remarks>
        /// <history>
        /// 	[VMasanas]	26/08/2004	Removed code to allow multiple tabs with same name.
        /// 	[VMasanas]	15/10/2004	Modified for new skin structure
        ///		[cnurse]	15/10/2004	Modified to allow for merging template
        ///								with existing pages
        /// </history>
        private void ParseTabs( XmlNode nodeTabs, int PortalId, bool IsAdminTemplate, PortalTemplateModuleAction mergeTabs, bool IsNewPortal )
        {
            //used to control if modules are true modules or instances
            //will hold module ID from template / new module ID so new instances can reference right moduleid
            //only first one from the template will be create as a true module, 
            //others will be moduleinstances (tabmodules)
            Hashtable hModules = new Hashtable();
            Hashtable hTabs = new Hashtable();

            //if running from wizard we need to pre populate htabs with existing tabs so ParseTab 
            //can find all existing ones
            string tabname = null;
            if( !IsNewPortal )
            {
                Hashtable hTabNames = new Hashtable();
                TabController objTabs = new TabController();
                foreach( KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal( PortalId ) )
                {
                    TabInfo objTab = tabPair.Value;

                    if( !objTab.IsDeleted & !objTab.IsAdminTab )
                    {
                        tabname = objTab.TabName;
                        if( !( Null.IsNull( objTab.ParentId ) ) )
                        {
                            tabname = Convert.ToString( hTabNames[objTab.ParentId] ) + "/" + objTab.TabName;
                        }
                        hTabNames.Add( objTab.TabID, tabname );
                    }
                }

                //when parsing tabs we will need tabid given tabname
                foreach( int i in hTabNames.Keys )
                {
                    if( hTabs[hTabNames[i]] == null )
                    {
                        hTabs.Add( hTabNames[i], i );
                    }
                }
                hTabNames = null;
            }

            foreach( XmlNode nodeTab in nodeTabs.SelectNodes( "//tab" ) )
            {
                ParseTab( nodeTab, PortalId, IsAdminTemplate, mergeTabs, ref hModules, ref hTabs, IsNewPortal );
            }
        }
コード例 #22
0
        private List<TabInfo> GetPortalPages(int portalId)
        {
            List<TabInfo> tabs = null;
            if (portalId == -1)
            {
                portalId = GetActivePortalId();
            }
            else
            {
                if (!IsPortalIdValid(portalId))
                {
                    return null;
                }
            }

            if (portalId > -1)
            {
                var includeHiddenTabs = PortalSettings.UserInfo.IsSuperUser || PortalSettings.UserInfo.IsInRole("Administrators");
                tabs = TabController.GetPortalTabs(portalId, Null.NullInteger, false, null, includeHiddenTabs, false, false, true, false)
                    .Where(t => !t.DisableLink)
                    .ToList();
            }
            else
            {
                if (PortalSettings.UserInfo.IsSuperUser)
                {
                    var tabController = new TabController();
                    tabs = tabController.GetTabsByPortal(-1).AsList().Where(t => !t.IsDeleted && !t.DisableLink).ToList();
                }
            }
            return tabs;
        }
コード例 #23
0
        private void GetBreadCrumbsRecursively(ref ArrayList breadCrumbs, int tabId)
        {
            TabInfo tab;
            var tabController = new TabController();
            var portalTabs = tabController.GetTabsByPortal(PortalId);
            var hostTabs = tabController.GetTabsByPortal(Null.NullInteger);
            bool tabFound = portalTabs.TryGetValue(tabId, out tab);
            if (!tabFound)
            {
                tabFound = hostTabs.TryGetValue(tabId, out tab);
            }
            //if tab was found
            if (tabFound)
            {
                //add tab to breadcrumb collection
                breadCrumbs.Insert(0, tab.Clone());

                //get the tab parent
                if (!Null.IsNull(tab.ParentId) && tabId != tab.ParentId)
                {
                    GetBreadCrumbsRecursively(ref breadCrumbs, tab.ParentId);
                }
            }
        }
コード例 #24
0
        /// <summary>
        /// Get Redirection Url based on Http Context and Portal Id.         
        /// </summary>
        /// <returns>string - Empty if redirection rules are not defined or no match found</returns>
        /// <param name="userAgent">User Agent - used for client capability detection.</param>
        /// <param name="portalId">Portal Id from which Redirection Rules should be applied.</param>
        /// <param name="currentTabId">Current Tab Id that needs to be evaluated.</param>        
        public string GetRedirectUrl(string userAgent, int portalId, int currentTabId)
        {
            Requires.NotNull("userAgent", userAgent);

			string redirectUrl = string.Empty;

			IList<IRedirection> redirections = GetRedirectionsByPortal(portalId);
			//check for redirect only when redirect rules are defined
			if (redirections == null || redirections.Count == 0)
			{
                return redirectUrl;
			}

            //try to get content from cache
        	var cacheKey = string.Format(RedirectionUrlCacheKey, userAgent, portalId, currentTabId);
            redirectUrl = GetUrlFromCache(cacheKey);
            if (!string.IsNullOrEmpty(redirectUrl)) 
            {
                return redirectUrl;
            }
			
			var clientCapability = ClientCapabilityProvider.Instance().GetClientCapability(userAgent);
			var tabController = new TabController();
			foreach (var redirection in redirections)
			{
				if (redirection.Enabled)
				{
					bool checkFurther = false;
					//redirection is based on source tab
					if (redirection.SourceTabId != Null.NullInteger)
					{
						//source tab matches current tab
						if (currentTabId == redirection.SourceTabId)
						{
							checkFurther = true;
						}
							//is child tabs to be included as well
						else if (redirection.IncludeChildTabs)
						{
							//Get all the descendents of the source tab and find out if current tab is in source tab's hierarchy or not.
							foreach (var childTab in tabController.GetTabsByPortal(portalId).DescendentsOf(redirection.SourceTabId))
							{
								if (childTab.TabID == currentTabId)
								{
									checkFurther = true;
									break;
								}
							}
						}
					}
						//redirection is based on portal
					else if (redirection.SourceTabId == Null.NullInteger)
					{
						checkFurther = true;
					}

					if (checkFurther)
					{
						//check if client capability matches with this rule
						if (DoesCapabilityMatchWithRule(clientCapability, redirection))
						{
							//find the redirect url
							redirectUrl = GetRedirectUrlFromRule(redirection, portalId, currentTabId);

                            //update cache content
                            SetUrlInCache(cacheKey, redirectUrl);
							break;
						}
					}
				}
			}

        	return redirectUrl;
        }
コード例 #25
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The VerifyPortalTab method verifies that the TabId/PortalId combination
        /// is allowed and returns default/home tab ids if not
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        ///	<param name="portalId">The Portal's id</param>
        ///	<param name="tabId">The current tab's id</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        private bool VerifyPortalTab(int portalId, int tabId)
        {
            var tabController = new TabController();
            var portalTabs = tabController.GetTabsByPortal(portalId);
            var hostTabs = tabController.GetTabsByPortal(Null.NullInteger);

            //Check portal
            bool isVerified = VerifyTabExists(tabId, portalTabs);

            if (!isVerified)
            {
                //check host
                isVerified = VerifyTabExists(tabId, hostTabs);
            }

            if (!isVerified)
            {
                //check splash tab
                isVerified = VerifySpecialTab(portalId, SplashTabId);
            }

            if (!isVerified)
            {
                //check home tab
                isVerified = VerifySpecialTab(portalId, HomeTabId);
            }

            if (!isVerified)
            {
                TabInfo tab = (from TabInfo t in portalTabs.AsList() where !t.IsDeleted && t.IsVisible select t).FirstOrDefault();

                if (tab != null)
                {
                    isVerified = true;
                    ActiveTab = tab.Clone();
                }
            }

            if (ActiveTab != null)
            {
                if (Null.IsNull(ActiveTab.StartDate))
                {
                    ActiveTab.StartDate = DateTime.MinValue;
                }
                if (Null.IsNull(ActiveTab.EndDate))
                {
                    ActiveTab.EndDate = DateTime.MaxValue;
                }
            }

            return isVerified;
        }
コード例 #26
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {

                if (Page.IsPostBack == false)
                {
                    // load the list of files found in the upload directory
                    ctlIcon.ShowFiles = true;
                    ctlIcon.ShowImages = true;
                    ctlIcon.ShowTabs = false;
                    ctlIcon.ShowUrls = false;
                    ctlIcon.Required = false;

                    ctlIcon.ShowLog = false;
                    ctlIcon.ShowNewWindow = false;
                    ctlIcon.ShowTrack = false;
                    ctlIcon.FileFilter = Globals.glbImageFileTypes;
                    ctlIcon.Width = "275px";

                    ctlIconLarge.ShowFiles = ctlIcon.ShowFiles;
                    ctlIconLarge.ShowImages = ctlIcon.ShowImages;
                    ctlIconLarge.ShowTabs = ctlIcon.ShowTabs;
                    ctlIconLarge.ShowUrls = ctlIcon.ShowUrls;
                    ctlIconLarge.Required = ctlIcon.Required;

                    ctlIconLarge.ShowLog = ctlIcon.ShowLog;
                    ctlIconLarge.ShowNewWindow = ctlIcon.ShowNewWindow;
                    ctlIconLarge.ShowTrack = ctlIcon.ShowTrack;
                    ctlIconLarge.FileFilter = ctlIcon.FileFilter;
                    ctlIconLarge.Width = ctlIcon.Width;

                    // tab administrators can only manage their own tab
                    if (!UserInfo.IsSuperUser && !UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
                    {
                        cboParentTab.Enabled = false;
                    }

                    ctlURL.Width = "275px";

                    rowCopySkin.Visible = false;
                    copyPermissionRow.Visible = false;
                    cmdUpdate.Visible = TabPermissionController.HasTabPermission("ADD,EDIT,COPY,MANAGE");
                    cmdUpdate.Text = Localization.GetString(_strAction == "edit" ? "Update" : "Add", LocalResourceFile);

                    bool usingDefaultLocale = LocaleController.Instance.IsDefaultLanguage(LocaleController.Instance.GetCurrentLocale(PortalId).Code);
                    switch (_strAction)
                    {
                        case "":
                        case "add":
                            // add
                            CheckQuota();
                            templateRow1.Visible = true;
                            templateRow2.Visible = true;
                            copyPanel.Visible = TabPermissionController.CanCopyPage() && usingDefaultLocale;
                            cmdDelete.Visible = false;
                            ctlURL.IncludeActiveTab = true;
                            ctlAudit.Visible = false;
                            AdvancedSettingExtensionControl.Visible = false;
                            break;
                        case "edit":
                            var tabCtrl = new TabController();
                            copyPermissionRow.Visible = (TabPermissionController.CanAdminPage() && tabCtrl.GetTabsByPortal(PortalId).DescendentsOf(TabId).Count > 0);
                            rowCopySkin.Visible = true;
                            copyPanel.Visible = false;
                            cmdDelete.Visible = TabPermissionController.CanDeletePage() && !TabController.IsSpecialTab(TabId, PortalSettings);
                            ctlURL.IncludeActiveTab = false;
                            ctlAudit.Visible = true;
                            AdvancedSettingExtensionControl.Visible = (Config.GetFriendlyUrlProvider() == "advanced");
                            break;
                        case "copy":
                            CheckQuota();
                            copyPanel.Visible = TabPermissionController.CanCopyPage() && usingDefaultLocale;
                            cmdDelete.Visible = false;
                            ctlURL.IncludeActiveTab = true;
                            ctlAudit.Visible = false;
                            AdvancedSettingExtensionControl.Visible = false;
                            break;
                        case "delete":
                            if (DeleteTab(TabId))
                            {
                                Response.Redirect(Globals.AddHTTP(PortalAlias.HTTPAlias), true);
                            }
                            else
                            {
                                _strAction = "edit";
                                copyPanel.Visible = false;
                                cmdDelete.Visible = TabPermissionController.CanDeletePage();
                            }
                            ctlURL.IncludeActiveTab = false;
                            ctlAudit.Visible = true;
                            AdvancedSettingExtensionControl.Visible = false;
                            break;
                    }
                    copyTab.Visible = copyPanel.Visible;

                    BindTab();

                    //Set the tab id of the permissions grid to the TabId (Note If in add mode
                    //this means that the default permissions inherit from the parent)
                    if (_strAction == "edit" || _strAction == "delete" || _strAction == "copy" || !TabPermissionController.CanAdminPage())
                    {
                        dgPermissions.TabID = TabId;
                    }
                    else
                    {
                        var parentTabId = (cboParentTab.SelectedItem != null) ? cboParentTab.SelectedItemValueAsInt : Null.NullInteger;
                        dgPermissions.TabID = parentTabId;
                    }
                }

                CheckLocalizationVisibility();

                BindLocalization(false);

                cancelHyperLink.NavigateUrl = Globals.NavigateURL();

                if (Request.QueryString["returntabid"] != null)
                {
                    // return to admin tab
                    var navigateUrl = Globals.NavigateURL(Convert.ToInt32(Request.QueryString["returntabid"]));
                    // add localtion hash to let it select in admin tab intially
                    var hash = "#" + (Tab.PortalID == Null.NullInteger ? "H" : "P") + "&" + Tab.TabID;
                    cancelHyperLink.NavigateUrl = navigateUrl + hash;
                }
                else if (!string.IsNullOrEmpty(UrlUtils.ValidReturnUrl(Request.QueryString["returnurl"])))
                {
                    cancelHyperLink.NavigateUrl = Request.QueryString["returnurl"];
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #27
0
ファイル: Upgrade.cs プロジェクト: ryanmalone/BGDNNWEB
        private static void UpgradeToVersion600()
        {
            var tabController = new TabController();

            var hostPages = tabController.GetTabsByPortal(Null.NullInteger);

            //This ensures that all host pages have a tab path.
            //so they can be found later. (DNNPRO-17129)
            foreach (var hostPage in hostPages.Values)
            {
                hostPage.TabPath = Globals.GenerateTabPath(hostPage.ParentId, hostPage.TabName);
                tabController.UpdateTab(hostPage);
            }

            var settings = PortalController.GetCurrentPortalSettings();

            var moduleController = new ModuleController();

            if (settings != null)
            {
                var hostTab = tabController.GetTab(settings.SuperTabId, Null.NullInteger, false);
                hostTab.IsVisible = false;
                tabController.UpdateTab(hostTab);
                foreach (var module in moduleController.GetTabModules(settings.SuperTabId).Values)
                {
                    moduleController.UpdateTabModuleSetting(module.TabModuleID, "hideadminborder", "true");
                }
            }

            //remove timezone editor
            int moduleDefId = GetModuleDefinition("Languages", "Languages");
            RemoveModuleControl(moduleDefId, "TimeZone");

            //6.0 requires the old TimeZone property to be marked as Deleted - Delete for Host
            ProfilePropertyDefinition ppdHostTimeZone = ProfileController.GetPropertyDefinitionByName(Null.NullInteger, "TimeZone");
            if (ppdHostTimeZone != null)
            {
                ProfileController.DeletePropertyDefinition(ppdHostTimeZone);
            }

            var portalController = new PortalController();
            foreach (PortalInfo portal in portalController.GetPortals())
            {
                //update timezoneinfo
#pragma warning disable 612,618
                TimeZoneInfo timeZoneInfo = Localization.Localization.ConvertLegacyTimeZoneOffsetToTimeZoneInfo(portal.TimeZoneOffset);                
#pragma warning restore 612,618
                PortalController.UpdatePortalSetting(portal.PortalID, "TimeZone", timeZoneInfo.Id, false);

                //6.0 requires the old TimeZone property to be marked as Deleted - Delete for Portals
                ProfilePropertyDefinition ppdTimeZone = ProfileController.GetPropertyDefinitionByName(portal.PortalID, "TimeZone");
                if (ppdTimeZone != null)
                {
                    ProfileController.DeletePropertyDefinition(ppdTimeZone);
                }

                var adminTab = tabController.GetTab(portal.AdminTabId, portal.PortalID, false);

                adminTab.IsVisible = false;
                tabController.UpdateTab(adminTab);

                foreach (var module in moduleController.GetTabModules(portal.AdminTabId).Values)
                {
                    moduleController.UpdateTabModuleSetting(module.TabModuleID, "hideadminborder", "true");
                }
            }

            //Ensure that Display Beta Notice setting is present
            var displayBetaNotice = Host.DisplayBetaNotice;
            HostController.Instance.Update("DisplayBetaNotice", displayBetaNotice ? "Y": "N");

            moduleDefId = GetModuleDefinition("Languages", "Languages");
            AddModuleControl(moduleDefId, "EnableContent", "Enable Localized Content", "DesktopModules/Admin/Languages/EnableLocalizedContent.ascx", "", SecurityAccessLevel.Host, 0, null, false);
            AddProfessionalPreviewPages();

            AddDefaultModuleIcons();

            AddIconToAllowedFiles();

            FavIconsToPortalSettings();

            var tab = tabController.GetTabByName("Host", Null.NullInteger, Null.NullInteger);

            if (tab != null)
            {
                RemoveModule("Extensions", "Module Definitions", tab.TabID, true);
                RemoveModule("Marketplace", "Marketplace", tab.TabID, true);
            }
        }
コード例 #28
0
        protected void BindCLControl()
        {
            MakeTranslatable.Visible = false;
            MakeNeutral.Visible = false;
            cmdUpdateLocalization.Visible = false;
            AddMissing.Visible = false;
            if (String.IsNullOrEmpty(_tab.CultureCode))
            {
                CLControl1.Visible = false;
                if (!(string.IsNullOrEmpty(_strAction) || _strAction == "add" || _strAction == "copy"))
                {
                    MakeTranslatable.Visible = true;
                }
            }
            else
            {
                CLControl1.Visible = true;
                CLControl1.enablePageEdit = true;
                CLControl1.BindAll(_tab.TabID);
                cmdUpdateLocalization.Visible = true;
                var controller = new TabController();

                // only show "Convert to neutral" if page has no child pages
                MakeNeutral.Visible = (controller.GetTabsByPortal(PortalId).WithParentId(_tab.TabID).Count == 0);

                // only show "add missing languages" if not all languages are available
                AddMissing.Visible = controller.HasMissingLanguages(PortalId, _tab.TabID);
            }
        }
コード例 #29
0
ファイル: CachingProvider.cs プロジェクト: biganth/Curt
 private void ClearModulePermissionsCachesByPortalInternal(int portalId, bool clearRuntime)
 {
     var objTabs = new TabController();
     foreach (KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal(portalId))
     {
         RemoveFormattedCacheKey(DataCache.ModulePermissionCacheKey, clearRuntime, tabPair.Value.TabID);
     }
 }
コード例 #30
0
        private void LoadValues()
        {
            cboValue.Items.Clear();
            txtValue.Text = "";

            var strFile = Globals.ApplicationMapPath + "\\" + cboTokens.SelectedItem.Value.ToLower().Replace("/", "\\").Replace(".ascx", ".xml");
            if (File.Exists(strFile))
            {
                try
                {
                    var xmlDoc = new XmlDocument();
                    xmlDoc.Load(strFile);
                    foreach (XmlNode xmlSetting in xmlDoc.SelectNodes("//Settings/Setting"))
                    {
                        if (xmlSetting.SelectSingleNode("Name").InnerText == cboSettings.SelectedItem.Value)
                        {
                            string strValue = xmlSetting.SelectSingleNode("Value").InnerText;
                            switch (strValue)
                            {
                                case "":
                                    txtValue.Visible = true;
                                    cboValue.Visible = false;
                                    break;
                                case "[TABID]":
                                    var objTabs = new TabController();
                                    foreach (var objTab in objTabs.GetTabsByPortal(PortalId).Values)
                                    {
                                        cboValue.AddItem(objTab.TabName, objTab.TabID.ToString());
                                    }

                                    cboValue.InsertItem(0, "<" + Localization.GetString("Not_Specified") + ">", "");
                                    cboValue.Visible = true;
                                    txtValue.Visible = false;
                                    break;
                                default:
                                    var arrValues = (strValue + ",").Split(',');
                                    foreach (var value in arrValues)
                                    {
                                        if (!String.IsNullOrEmpty(value))
                                        {
                                            cboValue.AddItem(value, value);
                                        }
                                    }

                                    cboValue.InsertItem(0, "<" + Localization.GetString("Not_Specified") + ">", "");
                                    cboValue.Visible = true;
                                    txtValue.Visible = false;
                                    break;
                            }
                            lblHelp.Text = xmlSetting.SelectSingleNode("Help").InnerText;
                        }
                    }
                }
                catch
                {
                    UI.Skins.Skin.AddModuleMessage(this, "Error Loading Settings File For Object", ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                UI.Skins.Skin.AddModuleMessage(this, "Object Selected Does Not Have Settings Defined", ModuleMessage.ModuleMessageType.YellowWarning);
            }
        }
コード例 #31
0
ファイル: CachingProvider.cs プロジェクト: biganth/Curt
        private void ClearPortalCacheInternal(int portalId, bool cascade, bool clearRuntime)
        {
            RemoveFormattedCacheKey(DataCache.PortalSettingsCacheKey, clearRuntime, portalId);

            Dictionary<string, Locale> locales = LocaleController.Instance.GetLocales(portalId);
            if (locales == null || locales.Count == 0)
            {
                //At least attempt to remove default locale
                string defaultLocale = PortalController.GetPortalDefaultLanguage(portalId);
                RemoveCacheKey(String.Format(DataCache.PortalCacheKey, portalId, defaultLocale), clearRuntime);
            }
            else
            {
                foreach (Locale portalLocale in LocaleController.Instance.GetLocales(portalId).Values)
                {
                    RemoveCacheKey(String.Format(DataCache.PortalCacheKey, portalId, portalLocale.Code), clearRuntime);
                }
            }
            if (cascade)
            {
                var objTabs = new TabController();
                foreach (KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal(portalId))
                {
                    ClearModuleCacheInternal(tabPair.Value.TabID, clearRuntime);
                }
                var moduleController = new ModuleController();
                foreach (ModuleInfo moduleInfo in moduleController.GetModules(portalId))
                {
                    RemoveCacheKey("GetModuleSettings" + moduleInfo.ModuleID, clearRuntime);
                }
            }
			
            //Clear "portal keys" for Portal
            ClearFolderCacheInternal(portalId, clearRuntime);
            ClearCacheKeysByPortalInternal(portalId, clearRuntime);
            ClearDesktopModuleCacheInternal(portalId, clearRuntime);
            ClearTabCacheInternal(portalId, clearRuntime);

            RemoveCacheKey(String.Format(DataCache.RolesCacheKey, portalId), clearRuntime);
        }