/// <summary> /// Fires on the grid action. /// </summary> /// <param name="actionName">Action name</param> /// <param name="actionArgument">Action argument</param> private void UniGridRelationship_OnAction(string actionName, object actionArgument) { // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(TreeNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { return; } if (actionName == "delete") { string[] parameters = ((string)actionArgument).Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (parameters.Length == 3) { // Parse parameters int leftNodeId = ValidationHelper.GetInteger(parameters[0], 0); int rightNodeId = ValidationHelper.GetInteger(parameters[1], 0); int relationshipNameId = ValidationHelper.GetInteger(parameters[2], 0); // If parameters are valid if ((leftNodeId > 0) && (rightNodeId > 0) && (relationshipNameId > 0)) { // Remove relationship RelationshipProvider.RemoveRelationship(leftNodeId, rightNodeId, relationshipNameId); // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(CMSContext.CurrentSiteName, TreeNode.NodeAliasPath, TaskTypeEnum.UpdateDocument, TreeProvider); ShowConfirmation(GetString("relationship.wasdeleted")); } } } }
/// <summary> /// Deletes relationship between documents. Called when the "Delete relationship" button is pressed. /// Expects the CreateRelationshipName and the CreateRelationship methods to be run first. /// </summary> private bool DeleteRelationship() { // Get the relationship name RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName"); if (relationshipName != null) { // Get the tree structure TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Get documents which are in relationship (the Root document is used for both in this example) TreeNode root = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", null, true); // Delete the relationship between documents RelationshipProvider.RemoveRelationship(root.NodeID, root.NodeID, relationshipName.RelationshipNameId); return(true); } return(false); }