/// <summary>Executes the command in the specified context.</summary> /// <param name="context">The context.</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull((object)context, "context"); string name1 = context.Parameters["database"]; string path = context.Parameters["id"]; string name2 = context.Parameters["language"]; string str = context.Parameters["version"]; Database database = Factory.GetDatabase(name1); if (database == null) { return; } Item obj = database.GetItem(path, Language.Parse(name2), Sitecore.Data.Version.Parse(str)); if (obj == null) { return; } IWorkflow workflow = obj.Database.WorkflowProvider.GetWorkflow(obj); if (workflow == null) { return; } WorkflowCommand[] workflowCommandArray = WorkflowFilterer.FilterVisibleCommands(workflow.GetCommands(obj), obj); var repository = new WorxboxItemsRepository(workflow); if (workflowCommandArray == null || workflowCommandArray.Length == 0) { return; } Menu menu = new Menu(); SheerResponse.DisableOutput(); foreach (WorkflowCommand command in workflowCommandArray) { string @string = new WorkflowCommandBuilder(obj, workflow, command).ToString(); menu.Add("C" + command.CommandID, command.DisplayName, command.Icon, string.Empty, @string, false, string.Empty, MenuItemType.Normal).Disabled = !Context.User.IsAdministrator && !obj.Locking.HasLock(); if (repository.IsWorxboxItem(obj.State.GetWorkflowState(), new DataUri(obj.Uri)) && repository.GetWorkflowCommandIDs().Contains(ID.Parse(command.CommandID))) { @string = new WorxBoxWorkflowCommandBuilder(obj, workflow, command).ToString(); menu.Add("C" + command.CommandID, "WorxBox " + command.DisplayName, command.Icon, string.Empty, @string, false, string.Empty, MenuItemType.Normal).Disabled = !Context.User.IsAdministrator && !obj.Locking.HasLock(); } } SheerResponse.EnableOutput(); SheerResponse.ShowContextMenu(Context.ClientPage.ClientRequest.Control, "right", (Control)menu); }
/// <summary>Executes the command in the specified context.</summary> /// <param name="context">The context.</param> public override void Execute(CommandContext context) { Assert.ArgumentNotNull((object)context, nameof(context)); string parameter1 = context.Parameters["database"]; string parameter2 = context.Parameters["id"]; string parameter3 = context.Parameters["language"]; string parameter4 = context.Parameters["version"]; Database database = Factory.GetDatabase(parameter1); if (database == null) { return; } Item obj = database.GetItem(parameter2, Language.Parse(parameter3), Sitecore.Data.Version.Parse(parameter4)); if (obj == null) { return; } IWorkflow workflow = obj.Database.WorkflowProvider.GetWorkflow(obj); if (workflow == null) { return; } WorkflowCommand[] workflowCommandArray = WorkflowFilterer.FilterVisibleCommands(workflow.GetCommands(obj), obj); if (workflowCommandArray == null || workflowCommandArray.Length == 0) { return; } Menu menu = new Menu(); SheerResponse.DisableOutput(); foreach (WorkflowCommand command in workflowCommandArray) { string click = new WorkflowCommandBuilder(obj, workflow, command).ToString(); //Add new logical condition to call canUserRunCommandsWithoutEdit() in Utilities class to check if user has permissions to execute //workflow commands without locking. The rest of the conditions are same as in default class menu.Add("C" + command.CommandID, command.DisplayName, command.Icon, string.Empty, click, false, string.Empty, MenuItemType.Normal).Disabled = !Utilities.canUserRunCommandsWithoutLocking() && !Context.User.IsAdministrator && !obj.Locking.HasLock() && Settings.RequireLockBeforeEditing; } SheerResponse.EnableOutput(); SheerResponse.ShowContextMenu(Context.ClientPage.ClientRequest.Control, "right", (Control)menu); }