private void MetaWeblogSetCustomCreatedDate(int contentItemId, string appKey, string userName, string password, XRpcStruct content, bool publish, ICollection<IXmlRpcDriver> drivers) { if (!publish) return; var createdUtc = content.Optional<DateTime?>("dateCreated"); if (createdUtc == null || createdUtc > DateTime.UtcNow) return; var driver = new XmlRpcDriver(item => { if (!(item is int)) return; var id = (int)item; var contentItem = _contentManager.Get(id, VersionOptions.Latest); if (contentItem == null || !contentItem.Is<CommonPart>()) // only pre-dating of content with the CommonPart (obviously) return; contentItem.As<CommonPart>().CreatedUtc = createdUtc; }); if (contentItemId > 0) driver.Process(contentItemId); else drivers.Add(driver); }
private void MetaWeblogSetCustomPublishedDate(int contentItemId, string appKey, string userName, string password, XRpcStruct content, bool publish, ICollection <IXmlRpcDriver> drivers) { var user = ValidateUser(userName, password); if (user == null) { return; } var publishedUtc = content.Optional <DateTime?>("dateCreated"); if (publishedUtc == null || publishedUtc <= DateTime.UtcNow) // only post-dating/scheduling of content with the PublishLaterPart { return; } var driver = new XmlRpcDriver(item => { if (!(item is int)) { return; } var id = (int)item; var contentItem = _contentManager.Get(id, VersionOptions.Latest); if (contentItem == null || !contentItem.Is <PublishLaterPart>()) { return; } _authorizationService.CheckAccess(Permissions.PublishContent, user, null); contentItem.As <PublishLaterPart>().ScheduledPublishUtc.Value = publishedUtc; _publishingTaskManager.Publish(contentItem, (DateTime)publishedUtc); }); if (contentItemId > 0) { driver.Process(contentItemId); } else { drivers.Add(driver); } }
private void MetaWeblogGetCustomPublishedDate(XRpcStruct postStruct, int itemId, string userName, string password, ICollection <IXmlRpcDriver> drivers) { if (itemId < 1) { return; } var driver = new XmlRpcDriver(item => { var post = item as XRpcStruct; if (post == null) { return; } var postId = post.Optional <int>("postid"); var contentItem = _contentManager.Get(postId, VersionOptions.Latest); if (contentItem == null) { return; } var publishedUtc = contentItem.As <PublishLaterPart>().ScheduledPublishUtc.Value; if (publishedUtc == null || publishedUtc <= DateTime.UtcNow) { return; } post.Set("dateCreated", publishedUtc); post.Set("date_created_gmt", publishedUtc); }); if (postStruct != null) { driver.Process(postStruct); } else { drivers.Add(driver); } }
private void MetaWeblogSetCustomCreatedDate(int contentItemId, string userName, string password, XRpcStruct content, bool publish, ICollection <IXmlRpcDriver> drivers) { if (!publish) { return; } var createdUtc = content.Optional <DateTime?>("dateCreated"); if (createdUtc == null || createdUtc > DateTime.UtcNow) { return; } var driver = new XmlRpcDriver(item => { if (!(item is int)) { return; } var id = (int)item; var contentItem = _contentManager.Get(id, VersionOptions.Latest); if (contentItem == null || !contentItem.Is <CommonPart>()) // only pre-dating of content with the CommonPart (obviously) { return; } contentItem.As <CommonPart>().CreatedUtc = createdUtc; }); if (contentItemId > 0) { driver.Process(contentItemId); } else { drivers.Add(driver); } }
private void MetaWeblogUpdateTags(int contentItemId, string userName, string password, XRpcStruct content, bool publish, ICollection <IXmlRpcDriver> drivers) { List <LocalizedString> validationErrors; var user = _membershipService.ValidateUser(userName, password, out validationErrors); var rawTags = content.Optional <string>("mt_keywords"); if (string.IsNullOrWhiteSpace(rawTags)) { return; } var tags = TagHelpers.ParseCommaSeparatedTagNames(rawTags); var driver = new XmlRpcDriver(item => { if (!(item is int)) { return; } var id = (int)item; var contentItem = _contentManager.Get(id, VersionOptions.Latest); if (contentItem == null) { return; } _orchardServices.WorkContext.CurrentUser = user; _tagService.UpdateTagsForContentItem(contentItem, tags); }); if (contentItemId > 0) { driver.Process(contentItemId); } else { drivers.Add(driver); } }
private void MetaWeblogAttachTagsToPost(XRpcStruct postStruct, int postId, string userName, string password, ICollection <IXmlRpcDriver> drivers) { if (postId < 1) { return; } List <LocalizedString> validationErrors; var user = _membershipService.ValidateUser(userName, password, out validationErrors); _authorizationService.CheckAccess(StandardPermissions.AccessAdminPanel, user, null); var driver = new XmlRpcDriver(item => { var post = item as XRpcStruct; if (post == null) { return; } var contentItem = _contentManager.Get(postId, VersionOptions.Latest); if (contentItem == null) { return; } var tags = contentItem.As <TagsPart>().CurrentTags; post.Set("mt_keywords", string.Join(", ", tags)); }); if (postStruct != null) { driver.Process(postStruct); } else { drivers.Add(driver); } }
private void MetaWeblogUpdateTags(int contentItemId, string appKey, string userName, string password, XRpcStruct content, bool publish, ICollection<IXmlRpcDriver> drivers) { var user = _membershipService.ValidateUser(userName, password); var rawTags = content.Optional<string>("mt_keywords"); if (string.IsNullOrWhiteSpace(rawTags)) return; var tags = TagHelpers.ParseCommaSeparatedTagNames(rawTags); var driver = new XmlRpcDriver(item => { if (!(item is int)) return; var id = (int)item; var contentItem = _contentManager.Get(id, VersionOptions.Latest); if (contentItem == null) return; _orchardServices.WorkContext.CurrentUser = user; _tagService.UpdateTagsForContentItem(contentItem, tags); }); if (contentItemId > 0) driver.Process(contentItemId); else drivers.Add(driver); }
private void MetaWeblogAttachTagsToPost(XRpcStruct postStruct, int postId, string userName, string password, ICollection<IXmlRpcDriver> drivers) { if (postId < 1) return; var user = _membershipService.ValidateUser(userName, password); _authorizationService.CheckAccess(StandardPermissions.AccessAdminPanel, user, null); var driver = new XmlRpcDriver(item => { var post = item as XRpcStruct; if (post == null) return; var contentItem = _contentManager.Get(postId, VersionOptions.Latest); if (contentItem == null) return; var tags = contentItem.As<TagsPart>().CurrentTags.Select(tag => tag.TagName); post.Set("mt_keywords", string.Join(", ", tags)); }); if (postStruct != null) driver.Process(postStruct); else drivers.Add(driver); }
private void MetaWeblogGetCustomPublishedDate(XRpcStruct postStruct, int itemId, string userName, string password, ICollection<IXmlRpcDriver> drivers) { if (itemId < 1) return; var driver = new XmlRpcDriver(item => { var post = item as XRpcStruct; if (post == null) return; var postId = post.Optional<int>("postid"); var contentItem = _contentManager.Get(postId, VersionOptions.Latest); if (contentItem == null) return; var publishedUtc = contentItem.As<PublishLaterPart>().ScheduledPublishUtc.Value; if (publishedUtc == null || publishedUtc <= DateTime.UtcNow) return; post.Set("dateCreated", publishedUtc); post.Set("date_created_gmt", publishedUtc); }); if (postStruct != null) driver.Process(postStruct); else drivers.Add(driver); }
private void MetaWeblogSetCustomPublishedDate(int contentItemId, string appKey, string userName, string password, XRpcStruct content, bool publish, ICollection<IXmlRpcDriver> drivers) { var user = ValidateUser(userName, password); if (user == null) return; var publishedUtc = content.Optional<DateTime?>("dateCreated"); if (publishedUtc == null || publishedUtc <= DateTime.UtcNow) // only post-dating/scheduling of content with the PublishLaterPart return; var driver = new XmlRpcDriver(item => { if (!(item is int)) return; var id = (int)item; var contentItem = _contentManager.Get(id, VersionOptions.Latest); if (contentItem == null || !contentItem.Is<PublishLaterPart>()) return; _authorizationService.CheckAccess(Permissions.PublishContent, user, null); contentItem.As<PublishLaterPart>().ScheduledPublishUtc.Value = publishedUtc; _publishingTaskManager.Publish(contentItem, (DateTime)publishedUtc); }); if (contentItemId > 0) driver.Process(contentItemId); else drivers.Add(driver); }