public static PublishItemAndRequiredAncestors ( ID itemID ) : void | ||
itemID | ID | |
return | void |
public void pingback(string sourceUri, string targetUri) { try { string entryId = HttpContext.Current.Request.QueryString["entryId"].ToString(); var currentID = ID.Parse(entryId); var comment = new Model.Comment() { AuthorName = "Automatic pingback", Text = string.Format("Pingkback from {0}", sourceUri) }; comment.Fields.Add(Constants.Fields.Website, sourceUri); var commentId = ManagerFactory.CommentManagerInstance.AddCommentToEntry(currentID, comment); ContentHelper.PublishItemAndRequiredAncestors(commentId); } catch (Exception) { throw new XmlRpcFaultException(1, "Invalid sourceUri parameter."); } // return "Your ping request has been received successfully."; }
public string newPost(string blogid, string username, string password, XmlRpcStruct rpcstruct, bool publish) { Authenticate(username, password); CheckUserRights(blogid, username); var entryTitle = rpcstruct["title"].ToString(); var currentBlog = ContentHelper.GetContentDatabase().GetItem(blogid); if (currentBlog != null) { // test var access = Sitecore.Security.AccessControl.AuthorizationManager.GetAccess(currentBlog, Sitecore.Context.User, Sitecore.Security.AccessControl.AccessRight.ItemCreate); // end test BlogHomeItem blogItem = currentBlog; var template = new TemplateID(blogItem.BlogSettings.EntryTemplateID); var newItem = ItemManager.AddFromTemplate(entryTitle, template, currentBlog); SetItemData(newItem, rpcstruct); if (publish) { ContentHelper.PublishItemAndRequiredAncestors(newItem.ID); } return(newItem.ID.ToString()); } else { return(string.Empty); } }
public string newPost(string blogid, string username, string password, XmlRpcStruct rpcstruct, bool publish) { Authenticate(username, password); CheckUserRights(blogid, username); var entryTitleRaw = rpcstruct["title"]; if (entryTitleRaw == null) { throw new ArgumentException("'title' must be provided"); } var entryTitle = entryTitleRaw.ToString(); var currentBlog = GetContentDatabase().GetItem(blogid); if (currentBlog != null) { BlogHomeItem blogItem = currentBlog; var template = new TemplateID(blogItem.BlogSettings.EntryTemplateID); var newItem = ItemManager.AddFromTemplate(entryTitle, template, currentBlog); SetItemData(newItem, rpcstruct); if (publish) { ContentHelper.PublishItemAndRequiredAncestors(newItem.ID); } return(newItem.ID.ToString()); } else { return(string.Empty); } }
public XmlRpcStruct newMediaObject(string blogid, string username, string password, XmlRpcStruct rpcstruct) { // Check user validation Authenticate(username, password); var name = rpcstruct["name"].ToString(); var media = (byte[])rpcstruct["bits"]; var blogName = string.Empty; var currentBlog = GetContentDatabase().GetItem(blogid); blogName = currentBlog.Name; // Get filename var fileName = Path.GetFileName(name); var imageName = ItemUtil.ProposeValidItemName(Path.GetFileNameWithoutExtension(fileName)); // Create strem from byte array var memStream = new MemoryStream(media); var md = new MediaCreatorOptions(); md.Destination = string.Join("/", new string[] { Constants.Paths.WeBlogMedia, blogName, imageName }); md.Database = GetContentDatabase(); md.AlternateText = imageName; // Check access rights CheckUserCreateRights(md.Destination); // Create mediaitem var mediaItem = MediaManager.Creator.CreateFromStream(memStream, fileName, md); // Close stream memStream.Close(); memStream.Dispose(); // Publish mediaitem to web database ContentHelper.PublishItemAndRequiredAncestors(mediaItem.ID); // Get the mediaitem url and return it var rstruct = new XmlRpcStruct(); #if FEATURE_URL_BUILDERS var options = new MediaUrlBuilderOptions() #else var options = new MediaUrlOptions() #endif { AbsolutePath = false, UseItemPath = false }; rstruct.Add("url", MediaManager.GetMediaUrl(mediaItem, options)); return(rstruct); }
public bool editPost(string postid, string username, string password, XmlRpcStruct rpcstruct, bool publish) { Authenticate(username, password); CheckUserRights(postid); var item = GetContentDatabase().GetItem(new ID(postid)); if (item != null) { SetItemData(item, rpcstruct); if (publish) { ContentHelper.PublishItemAndRequiredAncestors(item.ID); } return(true); } return(false); }