private void Document_Update_After(object sender, DocumentEventArgs e) { if (e.Node.ClassName.Equals("PbcLinear.Product")) { TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); var relatedProductCategories = tree.SelectNodes(SiteContext.CurrentSiteName, "/Products/%", e.Node.DocumentCulture, false, "PbcLinear.ProductSubCategory", string.Empty, "NodeOrder", -1, true, e.Node.NodeGUID, ProductCategoryRelationshipName, true).ToList(); DocumentAliasInfoProvider.DeleteNodeAliases(e.Node.NodeID); foreach (var category in relatedProductCategories) { DocumentAliasInfoProvider.SetDocumentAliasInfo(new DocumentAliasInfo { AliasNodeID = e.Node.NodeID, AliasURLPath = TreePathUtils.GetSafeNodeAliasPath(string.Format("{0}/{1}", category.NodeAliasPath, e.Node.DocumentName), "PbcLinear"), AliasSiteID = SiteContext.CurrentSiteID, AliasCulture = "", AliasExtensions = "" }, SiteContext.CurrentSiteName); } } }
/// <summary> /// Creates document. /// </summary> public int Save() { // Validate input data string message = new Validator().NotEmpty(txtDocumentName.Text.Trim(), GetString("om.enterdocumentname")).Result; if (message != String.Empty) { ShowError(message); return(0); } if (mNode == null) { ShowError(GetString("general.invalidparameters")); return(0); } // Select parent node TreeNode parent = mTree.SelectSingleNode(SiteContext.CurrentSiteName, ucPath.Value.ToString(), TreeProvider.ALL_CULTURES, false, null, false); if (parent == null) { ShowError(GetString("om.pathdoesnotexists")); return(0); } // Check security if (!MembershipContext.AuthenticatedUser.IsAuthorizedToCreateNewDocument(parent.NodeID, mNode.NodeClassName)) { RedirectToAccessDenied(GetString("cmsdesk.notauthorizedtocreatedocument")); return(0); } var newDocument = ProcessAction(mNode, parent, "copynode", false, true, true); if (newDocument == null) { ShowError(string.Format(GetString("om.invalidchildtype"), parent.ClassName)); return(0); } // Get all language translations var documents = DocumentHelper.GetDocuments() .All() .OnCurrentSite() .AllCultures() .WhereEquals("NodeID", newDocument.NodeID); // Limit length to 100 characters string documentName = TextHelper.LimitLength(txtDocumentName.Text.Trim(), 100, String.Empty); // Update all documents and delete all aliases foreach (var document in documents) { UpdateDocument(document, documentName); DocumentAliasInfoProvider.DeleteNodeAliases(document.NodeID); // Set new node to any updated document to have updated info newDocument = document; } // Create new AB variant if AB test defined if (!CreateABVariant(newDocument)) { return(0); } // Get the page mode if (PortalContext.ViewMode != ViewModeEnum.EditLive) { PortalContext.ViewMode = ViewModeEnum.EditForm; } txtDocumentName.Text = String.Empty; return(newDocument.NodeID); }