///<summary> /// Add a new blog post /// </summary> /// <param name="blogid">Blogid</param> /// <param name="username">username</param> /// <param name="password">password</param> /// <param name="post">post</param> /// <param name="publish">publish</param> string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish) { LocatePortal(Context.Request); DotNetNuke.Entities.Users.UserInfo ui = Authenticate(username, password); if (ui != null) { //TODO: we need a default category for users, then we can allow theme detection in WLW var pc = new List <Publish.Category>(); foreach (string s in post.categories) { Publish.Category c = Publish.Category.GetCategory(s, PortalId); pc.Add(c); } //This only works for the first category, how should we handle other categories? if (pc.Count < 1) { Publish.Category c = Publish.Category.GetCategory(ModuleBase.DefaultCategoryForPortal(PortalId), PortalId); pc.Add(c); } if (pc.Count > 0) { //get description //string description = post.description.Substring(0,post.description.IndexOf(" //look for <!--pagebreak--> Article a = Article.Create(post.title, post.description, post.description, ui.UserID, pc[0].ItemId, pc[0].ModuleId, pc[0].PortalId); //TODO: check if dateCreated is a valid date //TODO: date Created is coming in as UTC time //TODO: re-enable Date created //a.StartDate = post.dateCreated.ToString(); a.VersionDescription = Localization.GetString("MetaBlogApi", LocalResourceFile); if (pc.Count > 1) { for (int i = 1; i < pc.Count; i++) { var irel = new ItemRelationship { RelationshipTypeId = Util.RelationshipType.ItemToRelatedCategory.GetId(), ParentItemId = pc[i].ItemId }; a.Relationships.Add(irel); } } //check for tags if (post.mt_keywords != null && post.mt_keywords.Trim() != string.Empty) { //split tags foreach (Tag t in Tag.ParseTags(post.mt_keywords, _portalId)) { ItemTag it = ItemTag.Create(); it.TagId = Convert.ToInt32(t.TagId, CultureInfo.InvariantCulture); a.Tags.Add(it); } } if (post.mt_excerpt != null && post.mt_excerpt.Trim() != string.Empty) { a.Description = post.mt_excerpt; } // handle approval process if (ModuleBase.UseApprovalsForPortal(_portalId)) { if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAdminRole + _portalId)) || ui.IsSuperUser) { a.ApprovalStatusId = ApprovalStatus.Approved.GetId(); } else if (ui.IsInRole(HostController.Instance.GetString(Utility.PublishAuthorRole + _portalId))) { a.ApprovalStatusId = ApprovalStatus.Waiting.GetId(); } } a.Save(ui.UserID); return(a.ItemId.ToString()); } throw new XmlRpcFaultException(0, Localization.GetString("PostCategoryFailed.Text", LocalResourceFile)); } throw new XmlRpcFaultException(0, Localization.GetString("FailedAuthentication.Text", LocalResourceFile)); }