0

I have a requirement where in if a user is both content author and publisher and if this user creates content he should not be given a chance to publish. So on approval when i am sending email to publishers group i am going to check if the user is submitter, if he is i will not send the email. Another thing what i feel required is to grey out the publish option. Can this be done through code? I think setting access rights doesn't work in this scenario. Any input/ideas appreciated.

Thanks, TG.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
Newbie
  • 361
  • 2
  • 15
  • 33

1 Answers1

0

Are you trying to eliminate approval process if content is created or modified by publisher? if so I would have two commands in draft state, Submit which appear for non publishers and Publish which will be shown only to publisher and have it move to final stage on execution.

public class ValidateUser
{
    public void Process(WorkflowPipelineArgs args)
    {
        Assert.ArgumentNotNull(args, "args");
        ProcessorItem processorItem = args.ProcessorItem;
        if (processorItem != null)
        {
            Item contextitem = args.DataItem;
            Item innerItem = processorItem.InnerItem;
            var contentWorkflow = contextitem.Database.WorkflowProvider.GetWorkflow(contextitem);
            var contentHistory = contentWorkflow.GetHistory(contextitem);
            if (contentHistory.Length > 0)
            {
                if (contentHistory[contentHistory.Length - 1].User == Sitecore.Context.User.DisplayName)
                {
                    args.AbortPipeline();
                }
            }
        }
    }
}
navincumar
  • 114
  • 12
  • There is still approval phase where in some other user will approve the content. The content author who is also a publisher should not be able to publish. – Newbie Oct 10 '14 at 14:24
  • you can create a action for approval state which will display a message if context user is submitter and prevent it from moving to next state like validation action – navincumar Oct 10 '14 at 18:28
  • thanku..i understand what you are saying but I am not sure how would i check if the user is the submitter in the action? should i create an action or a validation action? is there a sample that you can refer to? please – Newbie Oct 10 '14 at 19:41
  • public class ValidateUser { public void Process(WorkflowPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); ProcessorItem processorItem = args.ProcessorItem; if (processorItem != null) { Item contextitem = args.DataItem; Item innerItem = processorItem.InnerItem; var contentWorkflow = contextitem.Database.WorkflowProvider.GetWorkflow(contextitem); var contentHistory = contentWorkflow.GetHistory(contextitem); if (contentHistory.Length > 0) { if (contentHistory[contentHistory.Length - 1].User == Sitecore.Context.User.DisplayName) { args.AbortPipeline(); } } } } } – navincumar Oct 10 '14 at 20:11
  • approved is the final step in the workflow...when this user clicks on the publish button either on the ribbon or sitecore->Publish Site a pop window should say you cant publish..what is the function that i can override? – Newbie Oct 21 '14 at 16:46