private void RemoveSocket(SocketsPart part) { // Trigger item _signals.Trigger(new ContentItemSignal(part.Id)); // Signal anything connected Trigger(part); // And remove all connectors // This time we need to remove the current version // TODO: Still need to double check this is doing the right thing. Need more control over acquiring draft/published/latest on connectors. var list = // Rights AllConnectors(part) // Lefts .Union(_mechanics.Value.LeftConnectors(part).List()); foreach (var connector in list) { // TODO: If someone has permission to delete an item, they should have permission to remove connectors; // but we need to handle versioning in this scenario, and actually also prevent items being deleted // if the user doesn't have permission to // TODO: Additionally there sometimes will need to be some further recursion to e.g. remove comments. This needs to be an // additional connector setting (cascade delete). _mechanics.Value.DeleteConnector(part, connector, true, true, true); } }
private void PublishConnectors(SocketsPart part) { if (part.ContentItem.VersionRecord != null) { // Make sure we get drafts; otherwise we might just get the last published ones now the left item is published foreach (var item in _mechanics.Value.Connectors(part, ConnectorCriteria.DraftsAndDeleted).List()) { // Handle connections flagged for deletion if (item.DeleteWhenLeftPublished) { // Ignore permissions because we already had to get thru the permissions check to set DeleteWhenLeftPublished // (left item is now published so we'll get it definitely deleted this time) _mechanics.Value.DeleteConnector(part, item, true); } else { // Delete orphans if (item.RightContent == null) { _mechanics.Value.DeleteConnector(part, item, true); } else if (!item.IsPublished() // Only publish if RHS already published && item.RightContent.ContentItem.IsPublished()) { // Inverse will get published automatically by the handler Services.ContentManager.Publish(item.ContentItem); // TODO: Some hook in case the right-item needs updating at this point? } } } } }
/// <summary> /// Instance lazy loaded handlers /// </summary> /// <param name="loading"></param> /// <param name="part"></param> protected void LazyLoadSocketHandlers(SocketsPart part, IEnumerable <ConnectorPart> draftedConnectors = null) { part.Endpoint = new SocketEndpoint(part); part.Sockets = new SocketFactory(_mechanics.Value); part.Sockets.AllowedLoader(() => _mechanics.Value.AllowableConnectorTypes(part)); // TODO: We could DI the factory but would this really help anything? part.Sockets.SocketsLoader(new SocketQueryFactory(Services, _mechanics.Value, part.Endpoint, draftedConnectors)); }
private void UnpublishSocket(SocketsPart part) { // Trigger item _signals.Trigger(new ContentItemSignal(part.Id)); // Signal anything connected Trigger(part); // And remove all connectors var list = // Rights _mechanics.Value.Connectors(part, ConnectorCriteria.Published).List() // Lefts .Union(_mechanics.Value.LeftConnectors(part, ConnectorCriteria.Published).List()); foreach (var connector in list) { Services.ContentManager.Unpublish(connector.ContentItem); if (connector.InverseConnector != null) { Services.ContentManager.Unpublish(connector.ContentItem); } } }
private IEnumerable <ConnectorPart> AllConnectors(SocketsPart part) { var allowed = part.Sockets.Allowed.ToList(); return(allowed.SelectMany(d => part.Sockets.Socket(d.Name).Connectors.List()).Select(c => c.As <ConnectorPart>())); }
private IEnumerable<ConnectorPart> AllConnectors(SocketsPart part) { var allowed = part.Sockets.Allowed.ToList(); return allowed.SelectMany(d => part.Sockets.Socket(d.Name).Connectors.List()).Select(c=>c.As<ConnectorPart>()); }
public SocketEndpoint(SocketsPart socketsPart, string displayType):this(socketsPart) { this.DisplayType = displayType; }
/// <summary> /// Instance lazy loaded handlers /// </summary> /// <param name="loading"></param> /// <param name="part"></param> protected void LazyLoadSocketHandlers(SocketsPart part, IEnumerable<ConnectorPart> draftedConnectors = null) { part.Endpoint = new SocketEndpoint(part); part.Sockets = new SocketFactory(_mechanics.Value); part.Sockets.AllowedLoader(() => _mechanics.Value.AllowableConnectorTypes(part)); // TODO: We could DI the factory but would this really help anything? part.Sockets.SocketsLoader(new SocketQueryFactory(Services, _mechanics.Value, part.Endpoint, draftedConnectors)); }
public SocketEndpoint(SocketsPart content) { ContentPart = content; _Metadata = new Lazy<ContentItemMetadata>(() => ContentItem.ContentManager.GetItemMetadata(ContentItem)); }
protected virtual void GetContentItemMetadata(SocketsPart part, ContentItemMetadata metadata) { return; }
public SocketEndpoint(SocketsPart socketsPart, string displayType) : this(socketsPart) { this.DisplayType = displayType; }
public SocketEndpoint(SocketsPart content) { ContentPart = content; _Metadata = new Lazy <ContentItemMetadata>(() => ContentItem.ContentManager.GetItemMetadata(ContentItem)); }