protected void menuNew_OnReloadData(object sender, EventArgs e) { int nodeId = ValidationHelper.GetInteger(menuNew.Parameter, 0); // Get the node TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode node = tree.SelectSingleNode(nodeId); plcNewVariant.Visible = false; if (node != null) { if (CurrentUser.IsAuthorizedToCreateNewDocument(node, null)) { DocumentTypeScopeInfo scope = DocumentTypeScopeInfoProvider.GetScopeInfo(node); if (scope != null) { plcNewLink.Visible = scope.ScopeAllowLinks; } // It's not allowed to link pages for content only sites plcNewLink.Visible &= !SiteContext.CurrentSite.SiteIsContentOnly; // AB test variant settings if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSABTestingEnabled") && EnableABTestVariant && CurrentUser.IsAuthorizedPerResource("cms.ABTest", "Read") && ModuleEntryManager.IsModuleLoaded(ModuleName.ONLINEMARKETING) && ResourceSiteInfoProvider.IsResourceOnSite("CMS.ABTest", SiteContext.CurrentSiteName) && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.ABTesting) && (node.NodeAliasPath != "/") && !node.IsFolder() && ((scope == null) || scope.ScopeAllowABVariant) && CurrentUser.IsAuthorizedToCreateNewDocument(node, node.ClassName)) { plcNewVariant.Visible = true; } pnlSepNewLinkVariant.Visible = (plcNewVariant.Visible || plcNewLink.Visible); string where = "ClassID IN (SELECT ChildClassID FROM CMS_AllowedChildClasses WHERE ParentClassID=" + ValidationHelper.GetInteger(node.GetValue("NodeClassID"), 0) + ") " + "AND ClassID IN (SELECT ClassID FROM CMS_ClassSite WHERE SiteID = " + SiteContext.CurrentSiteID + ")"; if (!string.IsNullOrEmpty(DocumentTypeWhere)) { where = SqlHelper.AddWhereCondition(where, DocumentTypeWhere); } if (scope != null) { // Apply document type scope where = SqlHelper.AddWhereCondition(where, DocumentTypeScopeInfoProvider.GetScopeClassWhereCondition(scope).ToString(true)); } // Get the allowed child classes DataSet ds = DocumentTypeHelper.GetDocumentTypeClasses() .Where(where) .OrderBy(DocumentTypeOrderBy) .TopN(50) .Columns("ClassID", "ClassName", "ClassDisplayName", string.Format("(CASE WHEN (ClassName = '{0}') THEN 0 ELSE 1 END) AS MenuItemOrder", SystemDocumentTypes.MenuItem)); var rows = new List <DataRow>(); if (!DataHelper.DataSourceIsEmpty(ds)) { // Check user permissions for "Create" permission bool hasNodeAllowCreate = (CurrentUser.IsAuthorizedPerTreeNode(node, NodePermissionsEnum.Create) == AuthorizationResultEnum.Allowed); bool isAuthorizedToCreateInContent = CurrentUser.IsAuthorizedPerResource("CMS.Content", "Create"); DataTable resultTable = ds.Tables[0].DefaultView.ToTable(); for (int i = 0; i < resultTable.Rows.Count; ++i) { DataRow dr = resultTable.Rows[i]; string doc = DataHelper.GetStringValue(dr, "ClassName"); // Document type is not allowed, remove it from the data set if (!isAuthorizedToCreateInContent && !CurrentUser.IsAuthorizedPerClassName(doc, "Create") && (!CurrentUser.IsAuthorizedPerClassName(doc, "CreateSpecific") || !hasNodeAllowCreate)) { rows.Add(dr); } } // Remove the document types foreach (DataRow dr in rows) { resultTable.Rows.Remove(dr); } bool classesRemoved = false; // Leave only first 15 rows while (resultTable.Rows.Count > 15) { resultTable.Rows.RemoveAt(resultTable.Rows.Count - 1); classesRemoved = true; } if (!DataHelper.DataSourceIsEmpty(resultTable)) { // Add show more item if (classesRemoved) { DataRow dr = resultTable.NewRow(); dr["ClassID"] = 0; dr["ClassName"] = "more"; dr["ClassDisplayName"] = ResHelper.GetString("class.showmore"); resultTable.Rows.InsertAt(dr, resultTable.Rows.Count); } // Create temp column int rowCount = resultTable.Rows.Count; DataColumn tmpColumn = new DataColumn("Count"); tmpColumn.DefaultValue = rowCount; resultTable.Columns.Add(tmpColumn); repNew.DataSource = resultTable; repNew.DataBind(); } else { DisplayErrorMessage(scope != null ? "Content.ScopeApplied" : "Content.NoPermissions"); } } else { DisplayErrorMessage(scope != null ? "Content.ScopeApplied" : "NewMenu.NoChildAllowed"); } } else { DisplayErrorMessage("Content.NoPermissions"); } } }