private void ItemCopyingEvenHandler(object sender, CancellableDestinationEventArgs e) { if (security.Enabled && security.ScopeEnabled) { OnItemCopying(e.AffectedItem, e.Destination); } }
/// <summary>Update a page version with another, i.e. save a version of the current item and replace it with the replacement item. Returns a version of the previously published item.</summary> /// <param name="currentItem">The item that will be stored as a previous version.</param> /// <param name="replacementItem">The item that will take the place of the current item using it's ID. Any saved version of this item will not be modified.</param> /// <param name="storeCurrentVersion">Create a copy of the currently published version before overwriting it.</param> /// <returns>A version of the previously published item or the current item when storeCurrentVersion is false.</returns> public virtual ContentItem ReplaceVersion(ContentItem currentItem, ContentItem replacementItem, bool storeCurrentVersion = true) { if (currentItem == null) { throw new ArgumentNullException("currentItem"); } if (replacementItem == null) { throw new ArgumentNullException("replacementItem"); } CancellableDestinationEventArgs args = new CancellableDestinationEventArgs(currentItem, replacementItem); if (ItemReplacingVersion != null) { ItemReplacingVersion.Invoke(this, args); } if (!args.Cancel) { currentItem = args.AffectedItem; replacementItem = args.Destination; using (ITransaction transaction = itemRepository.BeginTransaction()) { if (storeCurrentVersion) { ContentItem versionOfCurrentItem = AddVersion(currentItem); Replace(currentItem, replacementItem); if ((replacementItem.State == ContentState.Draft || replacementItem.State == ContentState.Waiting) && replacementItem.VersionOf.Value == currentItem) { // drafts can be removed once they have been published currentItem.VersionIndex = replacementItem.VersionIndex; itemRepository.SaveOrUpdate(currentItem); Repository.Delete(replacementItem); } transaction.Commit(); return(versionOfCurrentItem); } else { Replace(currentItem, replacementItem); if (replacementItem.State == ContentState.Draft && replacementItem.VersionOf.Value == currentItem) { // drafts can be removed once they have been published //itemRepository.Delete(replacementItem); Repository.Delete(replacementItem); } transaction.Commit(); return(currentItem); } } } return(currentItem); }
void OnItemCopying(object sender, CancellableDestinationEventArgs e) { InvokeBehaviors <IAddingBehavior>( e.AffectedItem, e.Destination, "Adding", (behavior, ctx) => behavior.OnAddingChild(ctx), (behavior, ctx) => behavior.OnAdding(ctx)); }
private void OnItemMoved(object sender, CancellableDestinationEventArgs e) { if (LeavingTrash(e)) { trashHandler.RestoreValues(e.AffectedItem); } else if (trashHandler.IsInTrash(e.Destination)) { trashHandler.ExpireTrashedItem(e.AffectedItem); } }
void persister_ItemMoving(object sender, CancellableDestinationEventArgs e) { var originalAction = e.FinalAction; e.FinalAction = (from, to) => { var result = originalAction(from, to); ItemDeleted(from.ID); return(result); }; }
private void OnItemMoved(object sender, CancellableDestinationEventArgs e) { if (LeavingTrash(e)) { trashHandler.RestoreValues(e.AffectedItem); } else if (trashHandler.IsInTrash(e.Destination)) { trashHandler.ExpireTrashedItem(e.AffectedItem); } }
/// <summary>Update a page version with another, i.e. save a version of the current item and replace it with the replacement item. Returns a version of the previously published item.</summary> /// <param name="currentItem">The item that will be stored as a previous version.</param> /// <param name="replacementItem">The item that will take the place of the current item using it's ID. Any saved version of this item will not be modified.</param> /// <param name="storeCurrentVersion">Create a copy of the currently published version before overwriting it.</param> /// <returns>A version of the previously published item or the current item when storeCurrentVersion is false.</returns> public virtual ContentItem ReplaceVersion(ContentItem currentItem, ContentItem replacementItem, bool storeCurrentVersion) { CancellableDestinationEventArgs args = new CancellableDestinationEventArgs(currentItem, replacementItem); if (ItemReplacingVersion != null) { ItemReplacingVersion.Invoke(this, args); } if (!args.Cancel) { currentItem = args.AffectedItem; replacementItem = args.Destination; using (ITransaction transaction = itemRepository.BeginTransaction()) { if (storeCurrentVersion) { ContentItem versionOfCurrentItem = SaveVersion(currentItem); //TODO: remove? Replace(currentItem, replacementItem); if (replacementItem.State == ContentState.Draft && replacementItem.VersionOf == currentItem) { // drafts can be removed once they have been published itemRepository.Delete(replacementItem); } transaction.Commit(); return(versionOfCurrentItem); } else { Replace(currentItem, replacementItem); if (replacementItem.State == ContentState.Draft && replacementItem.VersionOf == currentItem) { // drafts can be removed once they have been published itemRepository.Delete(replacementItem); } transaction.Commit(); return(currentItem); } } } return(currentItem); }
private void ItemCopyingEvenHandler(object sender, CancellableDestinationEventArgs e) { OnItemCopying(e.AffectedItem, e.Destination); }
/// <summary>Update a page version with another, i.e. save a version of the current item and replace it with the replacement item. Returns a version of the previously published item.</summary> /// <param name="currentItem">The item that will be stored as a previous version.</param> /// <param name="replacementItem">The item that will take the place of the current item using it's ID. Any saved version of this item will not be modified.</param> /// <param name="storeCurrentVersion">Create a copy of the currently published version before overwriting it.</param> /// <returns>A version of the previously published item or the current item when storeCurrentVersion is false.</returns> public virtual ContentItem ReplaceVersion(ContentItem currentItem, ContentItem replacementItem, bool storeCurrentVersion = true) { if (currentItem == null) throw new ArgumentNullException("currentItem"); if (replacementItem == null) throw new ArgumentNullException("replacementItem"); CancellableDestinationEventArgs args = new CancellableDestinationEventArgs(currentItem, replacementItem); if (ItemReplacingVersion != null) ItemReplacingVersion.Invoke(this, args); if (!args.Cancel) { currentItem = args.AffectedItem; replacementItem = args.Destination; using (ITransaction transaction = itemRepository.BeginTransaction()) { if (storeCurrentVersion) { ContentItem versionOfCurrentItem = AddVersion(currentItem); Replace(currentItem, replacementItem); if ((replacementItem.State == ContentState.Draft || replacementItem.State == ContentState.Waiting) && replacementItem.VersionOf.Value == currentItem) { // drafts can be removed once they have been published currentItem.VersionIndex = replacementItem.VersionIndex; itemRepository.SaveOrUpdate(currentItem); Repository.Delete(replacementItem); } transaction.Commit(); return versionOfCurrentItem; } else { Replace(currentItem, replacementItem); if (replacementItem.State == ContentState.Draft && replacementItem.VersionOf.Value == currentItem) // drafts can be removed once they have been published //itemRepository.Delete(replacementItem); Repository.Delete(replacementItem); transaction.Commit(); return currentItem; } } } return currentItem; }
void Persister_ItemCopying(object sender, CancellableDestinationEventArgs e) { events.AppendLine(DateTime.Now + ": " + MethodBase.GetCurrentMethod().Name + ", " + e.AffectedItem); }
void Events_ItemReplacingVersion(object sender, CancellableDestinationEventArgs e) { events.AppendLine(DateTime.Now + ": " + MethodBase.GetCurrentMethod().Name + ", " + e.AffectedItem); }
void Persister_ItemCopying(object sender, CancellableDestinationEventArgs e) { events.AppendLine(DateTime.Now + ": " + MethodBase.GetCurrentMethod().Name + ", " + e.AffectedItem); }
/// <summary>Update a page version with another, i.e. save a version of the current item and replace it with the replacement item. Returns a version of the previously published item.</summary> /// <param name="currentItem">The item that will be stored as a previous version.</param> /// <param name="replacementItem">The item that will take the place of the current item using it's ID. Any saved version of this item will not be modified.</param> /// <param name="storeCurrentVersion">Create a copy of the currently published version before overwriting it.</param> /// <returns>A version of the previously published item or the current item when storeCurrentVersion is false.</returns> public virtual ContentItem ReplaceVersion(ContentItem currentItem, ContentItem replacementItem, bool storeCurrentVersion) { CancellableDestinationEventArgs args = new CancellableDestinationEventArgs(currentItem, replacementItem); if (ItemReplacingVersion != null) ItemReplacingVersion.Invoke(this, args); if (!args.Cancel) { currentItem = args.AffectedItem; replacementItem = args.Destination; using (ITransaction transaction = itemRepository.BeginTransaction()) { if (storeCurrentVersion) { ContentItem versionOfCurrentItem = SaveVersion(currentItem); //TODO: remove? Replace(currentItem, replacementItem); if (replacementItem.State == ContentState.Draft && replacementItem.VersionOf == currentItem) // drafts can be removed once they have been published itemRepository.Delete(replacementItem); transaction.Commit(); return versionOfCurrentItem; } else { Replace(currentItem, replacementItem); if (replacementItem.State == ContentState.Draft && replacementItem.VersionOf == currentItem) // drafts can be removed once they have been published itemRepository.Delete(replacementItem); transaction.Commit(); return currentItem; } } } return currentItem; }
private void ItemCopyingEvenHandler(object sender, CancellableDestinationEventArgs e) { OnItemCopying(e.AffectedItem, e.Destination); }
void Events_ItemReplacingVersion(object sender, CancellableDestinationEventArgs e) { events.AppendLine(DateTime.Now + ": " + MethodBase.GetCurrentMethod().Name + ", " + e.AffectedItem); }
void persister_ItemMoving(object sender, CancellableDestinationEventArgs e) { var originalAction = e.FinalAction; e.FinalAction = (from, to) => { var result = originalAction(from, to); ItemDeleted(from.ID); return result; }; }
private void ItemMovingEvenHandler(object sender, CancellableDestinationEventArgs e) { if (security.Enabled && security.ScopeEnabled) OnItemMoving(e.AffectedItem, e.Destination); }