Example #1
0
        public override CommandState QueryState(CommandContext context)
        {
            if (context.Items.Length == 1 &&
                context.Items[0] != null &&
                !PublishingHelper.CanPublishItem(context.Items[0], Sitecore.Context.User))
            {
                return(CommandState.Disabled);
            }

            return(base.QueryState(context));
        }
Example #2
0
        public override void Execute(CommandContext context)
        {
            if (context.Items.Length != 1 ||
                context.Items[0] == null ||
                !PublishingHelper.CanPublishItem(context.Items[0], Sitecore.Context.User))
            {
                string msg = Translate.Text("You cannot publish this item.");
                Sitecore.Context.ClientPage.ClientResponse.Alert(msg);
                return;
            }

            base.Execute(context);
        }
        public override CommandState QueryState(CommandContext context)
        {
            Assert.IsNotNull(context, "context");

            if (PublishingHelper.CanPublishDatabase(Sitecore.Context.ContentDatabase) &&
                context.Items.Length == 1 &&
                context.Items[0] != null &&
                (PublishingHelper.CanPublishItem(context.Items[0], Sitecore.Context.User) || context.Items[0].HasChildren))
            {
                return(base.QueryState(context));
            }

            return(CommandState.Disabled);
        }
        public override void Process(PublishItemContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            Item item = context.PublishHelper.GetSourceItem(context.ItemId);

            if (item != null &&
                !PublishingHelper.CanPublishItem(item, Sitecore.Context.User))
            {
                string msg = String.Format(
                    "{0} does not have permission to publish {1}",
                    Sitecore.Context.User.Name,
                    item.Paths.FullPath);
                context.AbortPipeline(
                    PublishOperation.Skipped,
                    PublishChildAction.Allow,
                    Translate.Text(msg));
            }
        }
        protected new void Run(ClientPipelineArgs args)
        {
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["id"], "id");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["language"], "language");
            Sitecore.Diagnostics.Assert.ArgumentNotNull(args.Parameters["version"], "version");

            if (!SheerResponse.CheckModified())
            {
                return;
            }

            Item item = Context.ContentDatabase.GetItem(
                args.Parameters["id"],
                Language.Parse(args.Parameters["language"]),
                Version.Parse(args.Parameters["version"]));

            if (item == null ||
                PublishingHelper.CanPublishItem(item, Sitecore.Context.User))
            {
                base.Run(args);
                return;
            }

            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    base.Run(args);
                }

                return;
            }
            else
            {
                string msg = "You cannot publish this item.\n\nDo you want to publish any descendants that you can publish?";
                SheerResponse.Confirm(Translate.Text(msg));
                args.WaitForPostBack();
                return;
            }
        }