/// <summary> /// Workflow action implementation. /// </summary> /// <param name="args">Workflow action pipeline arguments.</param> public void Process(Sitecore.Workflows.Simple.WorkflowPipelineArgs args) { Sitecore.Diagnostics.Assert.IsNotNull(args, "args"); Sitecore.Diagnostics.Assert.IsNotNull(args.DataItem, "args.DataItem"); Sitecore.Diagnostics.Assert.IsNotNull(args.ProcessorItem, "args.ProcessorItem"); Sitecore.Diagnostics.Assert.IsNotNull( args.ProcessorItem.InnerItem, "args.ProcessorItem.InnerItem"); this.DataItem = args.DataItem; this.ActionItem = args.ProcessorItem.InnerItem; // Add a new version. Sitecore.Data.Items.Item newVersion = this.DataItem.Versions.AddVersion(); newVersion.Editing.BeginEdit(); //TODO: determine if necessary // Ensure new version is publishable. newVersion.Fields[Sitecore.FieldIDs.HideVersion].Value = String.Empty; this.DataItem.Editing.BeginEdit(); // Hide the old version. this.DataItem.Fields[Sitecore.FieldIDs.HideVersion].Value = "1"; // Move the old version to the specified state // or the final state of the workflow. if (!String.IsNullOrEmpty(this.TargetState)) { // args.nextStateId is the state Sitecore would move the old version to. args.NextStateId = Sitecore.Data.ID.Parse(this.TargetState); } // Move the new version to the next state associated with the current workflow command. if (String.IsNullOrEmpty(this.NextState)) { newVersion.Fields[Sitecore.FieldIDs.WorkflowState].Value = args.NextStateId.ToString(); } else { newVersion.Fields[Sitecore.FieldIDs.WorkflowState].Value = this.NextState; } newVersion.Editing.EndEdit(); this.DataItem.Editing.EndEdit(); if (Sitecore.Context.IsBackgroundThread || !Sitecore.Context.ClientPage.IsEvent) { return; } string message = String.Format( "item:load(id={0},version={1},language={2})", this.DataItem.ID, this.DataItem.Versions.Count, this.DataItem.Language); Sitecore.Context.ClientPage.ClientResponse.Timer(message, 2); }
/// <summary> /// Workflow action implementation. /// </summary> /// <param name="args">Workflow action arguments.</param> public void Process(Sitecore.Workflows.Simple.WorkflowPipelineArgs args) { if (String.Compare( args.DataItem.Statistics.UpdatedBy, Sitecore.Context.User.Name, true) != 0) { return; } Sitecore.Web.UI.Sheer.SheerResponse.Alert( "You cannot approve your own changes."); args.AbortPipeline(); }