/// <summary> /// Handle publishing restrictions for the specified item. /// </summary> /// <param name="item">The item to check.</param> /// <param name="requireLatest">Whether to require that the item specified is the /// latest version of the item.</param> /// <param name="target">The publishing target to check.</param> /// <returns>True if the item has publishing restrictions.</returns> /// <exception cref="PublishingException"><c>PublishingException</c> - Any type of /// error.</exception> protected bool HandlePublishingRestrictions( Sitecore.Data.Items.Item item, bool requireLatest, PublishingTarget target) { Sitecore.Diagnostics.Assert.IsNotNull(item, "item"); if (this.HandlePublishingRestrictions(item, requireLatest)) { return(true); } if (item.HasPublishingRestrictions(true, requireLatest, target)) { string message = this.Logger.Info( "{0} has item publishing restrictions.", item.Paths.FullPath); if (this.ThrowExceptions) { throw new PublishingException(message); } return(true); } return(false); }
/// <summary> /// Extension method to Sitecore.Data.Items.Item to indicate whether an item or a /// version of an item or any of its ancestors has publishing restrictions. /// </summary> /// <param name="me">The item to check.</param> /// <param name="checkAncestors">Whether to check ancestors of the item for /// publishing restrictions (does not check version publishing restrictions). /// </param> /// <param name="checkRevision">Whether to check if this version of the item has /// publishing restrictions.</param> /// <param name="target">Publishing target to check.</param> /// <returns> /// True if the item or any of its ancestors has publishing restrictions. /// </returns> public static bool HasPublishingRestrictions( this Sitecore.Data.Items.Item me, bool checkAncestors, bool checkRevision, Sitecore.Sharedsource.Publishing.PublishingTarget target) { if (me.HasPublishingRestrictions(checkAncestors, checkRevision)) { return(true); } if (!target.IsRelevant(me)) { return(true); } return(false); }