protected void BtnMoveClick(object sender, EventArgs e) { if (Category.Id != ddlCategories.SelectedValue.ToInt32()) { // Get the document you will move by its ID var doc = new Document(Topic.Id); // Create a user we can use for both var user = new User(0); // The new parent ID var newParentId = ddlCategories.SelectedValue.ToInt32(); // Now update the topic parent category ID doc.getProperty("forumTopicParentCategoryID").Value = newParentId; // publish application node doc.Publish(user); // Move the document the new parent doc.Move(newParentId); // update the document cache so its available in the XML umbraco.library.UpdateDocumentCache(doc.Id); // Redirect and show message Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("TopicHasBeenMovedText"))); } else { // Can't move as they have selected the category that the topic is already in Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("TopicAlreadyInThisCategory"))); } }
public static string MarkAsSolution(string pageId) { if (MembershipHelper.IsAuthenticated()) { var m = Member.GetCurrentMember(); var forumPost = _mapper.MapForumPost(new Node(Convert.ToInt32(pageId))); if (forumPost != null) { var forumTopic = _mapper.MapForumTopic(new Node(forumPost.ParentId.ToInt32())); // If this current member id doesn't own the topic then ignore, also // if the topic is already solved then ignore. if (m.Id == forumTopic.Owner.MemberId && !forumTopic.IsSolved) { // Get a user to save both documents with var usr = new User(0); // First mark the post as the solution var p = new Document(forumPost.Id); p.getProperty("forumPostIsSolution").Value = 1; p.Publish(usr); library.UpdateDocumentCache(p.Id); // Now update the topic var t = new Document(forumTopic.Id); t.getProperty("forumTopicSolved").Value = 1; t.Publish(usr); library.UpdateDocumentCache(t.Id); return library.GetDictionaryItem("Updated"); } } } return library.GetDictionaryItem("Error"); }
public override TaskExecutionDetails Execute(string Value) { TaskExecutionDetails d = new TaskExecutionDetails(); if (HttpContext.Current != null && HttpContext.Current.Items["pageID"] != null) { string id = HttpContext.Current.Items["pageID"].ToString(); Document doc = new Document(Convert.ToInt32(id)); if (doc.getProperty(PropertyAlias) != null) { d.OriginalValue = doc.getProperty(PropertyAlias).Value.ToString(); doc.getProperty(PropertyAlias).Value = Value; doc.Publish(new BusinessLogic.User(0)); d.NewValue = Value; d.TaskExecutionStatus = TaskExecutionStatus.Completed; } else d.TaskExecutionStatus = TaskExecutionStatus.Cancelled; } else d.TaskExecutionStatus = TaskExecutionStatus.Cancelled; return d; }
public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime) { // Cast to Umbraco worklow instance. var umbracoWorkflowInstance = (UmbracoWorkflowInstance) workflowInstance; foreach(var nodeId in umbracoWorkflowInstance.CmsNodes) { var n = new CMSNode(nodeId); if(!n.IsDocument()) continue; var d = new Document(nodeId); d.Publish(User.GetUser(0)); umbraco.library.UpdateDocumentCache(d.Id); } runtime.Transition(workflowInstance, this, "done"); }
public void ProcessRequest(HttpContext context) { //TODO: Authorize this request!!! HttpPostedFile file = context.Request.Files["Filedata"]; string userguid = context.Request.Form["USERGUID"]; string nodeguid = context.Request.Form["NODEGUID"]; string fileType = context.Request.Form["FILETYPE"]; string fileName = context.Request.Form["FILENAME"]; string umbraoVersion = context.Request.Form["UMBRACOVERSION"]; string dotNetVersion = context.Request.Form["DOTNETVERSION"]; List<UmbracoVersion> v = new List<UmbracoVersion>() { UmbracoVersion.DefaultVersion() }; if (!string.IsNullOrEmpty(umbraoVersion)) { v.Clear(); v = WikiFile.GetVersionsFromString(umbraoVersion); } if (!string.IsNullOrEmpty(userguid) && !string.IsNullOrEmpty(nodeguid) && !string.IsNullOrEmpty(fileType) && !string.IsNullOrEmpty(fileName)) { Document d = new Document( Document.GetContentFromVersion(new Guid(nodeguid)).Id ); Member mem = new Member(new Guid(userguid)); if (d.ContentType.Alias == "Project" && d.getProperty("owner") != null && (d.getProperty("owner").Value.ToString() == mem.Id.ToString() || Utils.IsProjectContributor(mem.Id,d.Id))) { WikiFile.Create(fileName, new Guid(nodeguid), new Guid(userguid), file, fileType, v, dotNetVersion); //the package publish handler will make sure we got the right versions info on the package node itself. //ProjectsEnsureGuid.cs is the handler if (fileType.ToLower() == "package") { d.Publish(new umbraco.BusinessLogic.User(0)); umbraco.library.UpdateDocumentCache(d.Id); } } else { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "wrong type or not a owner"); } } }
public object editPost( string postid, string username, string password, Post post, bool publish) { if (validateUser(username, password)) { Channel userChannel = new Channel(username); Document doc = new Document(Convert.ToInt32(postid)); doc.Text = HttpContext.Current.Server.HtmlDecode(post.title); // Excerpt if (userChannel.FieldExcerptAlias != null && userChannel.FieldExcerptAlias != "") doc.getProperty(userChannel.FieldExcerptAlias).Value = removeLeftUrl(post.mt_excerpt); if (UmbracoSettings.TidyEditorContent) doc.getProperty(userChannel.FieldDescriptionAlias).Value = library.Tidy(removeLeftUrl(post.description), false); else doc.getProperty(userChannel.FieldDescriptionAlias).Value = removeLeftUrl(post.description); updateCategories(doc, post, userChannel); if (publish) { doc.Publish(new User(username)); library.UpdateDocumentCache(doc.Id); } return true; } else { return false; } }
void Action_AfterPerform(object sender, ActionEventArgs e) { uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender; if (a.Alias == "ProjectUp") { Document d = new Document(e.ItemId); if (d.getProperty("approved").Value != null && d.getProperty("approved").Value.ToString() != "1" && uPowers.Library.Xslt.Score(d.Id, "powersProject") >= 15) { //set approved flag d.getProperty("approved").Value = true; d.Save(); d.Publish(new umbraco.BusinessLogic.User(0)); umbraco.library.UpdateDocumentCache(d.Id); umbraco.library.RefreshContent(); } } }
public static string ChangeCollabStatus(int projectId, bool status) { int _currentMember = umbraco.presentation.umbracobase.library.library.CurrentMemberId(); if (_currentMember > 0) { Document p = new Document(projectId); if ((int)p.getProperty("owner").Value == _currentMember) { p.getProperty("openForCollab").Value = status; p.Publish(new User(0)); umbraco.library.UpdateDocumentCache(p.Id); return "true"; } else { return "false"; } } return "false"; }
public string Move(int wikiId, int target) { var currentMemberId = Members.GetCurrentMember().Id; if (Xslt.IsMemberInGroup("admin", currentMemberId) || Xslt.IsMemberInGroup("wiki editor", currentMemberId)) { Document document = new Document(wikiId); Document documentTarget = new Document(target); if (documentTarget.ContentType.Alias == "WikiPage") { Document o = new Document(document.Parent.Id); document.Move(documentTarget.Id); document.Save(); document.Publish(new umbraco.BusinessLogic.User(0)); documentTarget.Publish(new umbraco.BusinessLogic.User(0)); o.Publish(new umbraco.BusinessLogic.User(0)); umbraco.library.UpdateDocumentCache(document.Id); umbraco.library.UpdateDocumentCache(documentTarget.Id); umbraco.library.UpdateDocumentCache(o.Id); umbraco.library.RefreshContent(); return umbraco.library.NiceUrl(document.Id); } } return ""; }
/// <summary> /// Install a new uWebshop store /// </summary> /// <param name="storeAlias">the store alias to use</param> /// <param name="storeDocument">the document of the store</param> /// <param name="cultureCode"> </param> /// <param name="preFillRequiredItems"></param> internal static void InstallStore(string storeAlias, Document storeDocument, string cultureCode = null, bool preFillRequiredItems = false) { var reg = new Regex(@"\s*"); storeAlias = reg.Replace(storeAlias, ""); if (cultureCode == null) { var languages = Language.GetAllAsList(); var firstOrDefaultlanguage = languages.FirstOrDefault(); if (firstOrDefaultlanguage == null) return; cultureCode = firstOrDefaultlanguage.CultureAlias; } var installStoreSpecificPropertiesOnDocumentTypes = WebConfigurationManager.AppSettings["InstallStoreDocumentTypes"]; if (installStoreSpecificPropertiesOnDocumentTypes == null || installStoreSpecificPropertiesOnDocumentTypes != "false") { if (DocumentType.GetAllAsList().Where(x => x.Alias.StartsWith(Store.NodeAlias)).All(x => x.Text.ToLower() != storeAlias.ToLower())) { IO.Container.Resolve<IUmbracoDocumentTypeInstaller>().InstallStore(storeAlias); } else { // todo: return message that store already existed? return; } } var admin = new User(0); var uwbsStoreDt = DocumentType.GetByAlias(Store.NodeAlias); var uwbsStoreRepositoryDt = DocumentType.GetByAlias(Store.StoreRepositoryNodeAlias); var uwbsStoreRepository = Document.GetDocumentsOfDocumentType(uwbsStoreRepositoryDt.Id).FirstOrDefault(x => !x.IsTrashed); if (storeDocument == null) { if (uwbsStoreRepository != null) if (uwbsStoreDt != null) { storeDocument = Document.MakeNew(storeAlias, uwbsStoreDt, admin, uwbsStoreRepository.Id); if (storeDocument != null && preFillRequiredItems) { storeDocument.SetProperty("orderNumberPrefix", storeAlias); storeDocument.SetProperty("globalVat", "0"); storeDocument.SetProperty("countryCode", "DK"); storeDocument.SetProperty("storeEmailFrom", string.Format("info@{0}.com", storeAlias)); storeDocument.SetProperty("storeEmailTo", string.Format("info@{0}.com", storeAlias)); storeDocument.SetProperty("storeEmailFromName", storeAlias); storeDocument.Save(); storeDocument.Publish(new User(0)); } } } var language = Language.GetByCultureCode(cultureCode); if (storeDocument == null) { return; } if (language != null) storeDocument.SetProperty("currencyCulture", language.id.ToString()); storeDocument.Save(); //InstallProductUrlRewritingRules(storeAlias); }
/// <summary> /// Publishes the update. /// </summary> public void Publish() { // keep track of documents published in this request List<int> publishedDocuments = (List<int>)HttpContext.Current.Items["ItemUpdate_PublishedDocuments"]; if (publishedDocuments == null) { HttpContext.Current.Items["ItemUpdate_PublishedDocuments"] = publishedDocuments = new List<int>(); } // publish each modified document just once (e.g. several fields are updated) if(!publishedDocuments.Contains(NodeId.Value)) { Document document = new Document(NodeId.Value); document.Publish(UmbracoEnsuredPage.CurrentUser); library.UpdateDocumentCache(NodeId.Value); publishedDocuments.Add(NodeId.Value); } }
private void handlePublishing(Document doc, documentCarrier carrier, umbraco.BusinessLogic.User user) { switch (carrier.PublishAction) { case documentCarrier.EPublishAction.Publish: doc.Publish(user); umbraco.library.PublishSingleNode(doc.Id); break; case documentCarrier.EPublishAction.Unpublish: doc.Publish(user); umbraco.library.UnPublishSingleNode(doc.Id); break; case documentCarrier.EPublishAction.Ignore: if (doc.Published) { doc.Publish(user); umbraco.library.PublishSingleNode(doc.Id); } else { doc.Publish(user); umbraco.library.UnPublishSingleNode(doc.Id); } break; } }
/// <summary> /// This updates a topic with the current latest post date /// </summary> /// <param name="topicId"></param> public void UpdateTopicWithLastPostDate(int topicId) { // This is a bit s***e, but its the best way to keep performance on some of the larger select queries. // Especially if you have 10000's of nodes // Get the topic to update and get generic user var u = new User(0); var topic = new Document(topicId); // Now get the latest post in this topic, we do this with the node API to make 100% // sure that its correct as Examine takes a few seconds to update var postList = new Node(topicId).ChildrenAsList; var lastPost = (from p in postList orderby p.CreateDate descending select p).FirstOrDefault(); // Update the topic if(lastPost != null) { topic.getProperty("forumTopicLastPostDate").Value = lastPost.CreateDate; } else { topic.getProperty("forumTopicLastPostDate").Value = null; } // Finally save it all topic.sortOrder = 0; // publish application node topic.Publish(u); // update the document cache so its available in the XML umbraco.library.UpdateDocumentCache(topicId); }
public static string UnSubScribeToTopic(string topicId) { if (!String.IsNullOrEmpty(Helpers.SafePlainText(topicId).Trim()) && MembershipHelper.IsAuthenticated()) { var tID = topicId.ToInt32(); // Get the topic from factory, as we'll use this to remove the member from the topics // to make sure there are no mistakes var forumTopic = _mapper.MapForumTopic(new Node(tID)); // Create the token user var u = new User(0); // Get the current logged in member var m = Member.GetCurrentMember(); // Remove this member ID from the list var remainingMembers = forumTopic.SubscriberIds.Where(x => x != m.Id).ToList(); var remainingMembersFormatted = string.Empty; foreach (var id in remainingMembers) { remainingMembersFormatted += (id + "|"); } // Get the topic var t = new Document(tID); // Add the document properties t.getProperty("forumTopicSubscribedList").Value = remainingMembersFormatted; // publish application node t.Publish(u); // update the document cache so its available in the XML library.UpdateDocumentCache(tID); return library.GetDictionaryItem("Success"); } return library.GetDictionaryItem("Error"); }
private INode SaveDoc(Document doc) { doc.Save(); doc.Publish(User.GetAllByLoginName("visitor", false).FirstOrDefault()); umbraco.library.UpdateDocumentCache(doc.Id); return new Node(doc.Id); }
private void Page_PreRender(object sender, EventArgs e) { if (IsPostBack) { foreach (ListItem lang in cbl.Items) { if (lang.Selected) { NewTranslatedLanguages.Add(lang.Value); } } //test for the translation folder if (TranslationFolder == null) { TranslationFolder = CreateTranslationFolder(); TranslationFolder.Publish(CurrentUser); } int count = 1; DocumentType translationDocType = DocumentType.GetByAlias(TranslationDocTypeAlias); foreach (string langISO in NewTranslatedLanguages) { //we make sure the new translations inherit properly from the parent. if (count == 1) { //DocumentType parentDocTypes; ////here we catch an issue with v4.11.x, the result is some properties are not copied down //try //{ // parentDocTypes= new DocumentType(translationDocType.Parent.Id); //} //catch (Exception e2) //{ DocumentType parentDocTypes = new DocumentType(translationDocType.MasterContentType); //} translationDocType.allowedTemplates = parentDocTypes.allowedTemplates; translationDocType.IconUrl = parentDocTypes.IconUrl; translationDocType.DefaultTemplate = parentDocTypes.DefaultTemplate; translationDocType.Save(); } string translationName = langISO; Document newLangDocument = Document.MakeNew(translationName, translationDocType, CurrentUser, TranslationFolder.Id); CopyProperties(ParentDocument, newLangDocument); newLangDocument.getProperty(LanguagePropertyAlias).Value = langISO; newLangDocument.Save(); } BasePage.Current.ClientTools.ReloadActionNode(true, true).CloseModalWindow(); } else { if (TranslationFolder != null) { SetCurrentTranslatedLanguages(); } bool hasAtLeastOne = false; foreach (Language lang in Language.GetAllAsList()) { string langISO = lang.CultureAlias.ToLower().Substring(0, 2); if (!CurrentTranslatedLanguages.Contains(langISO)) { if (langISO != PrimaryLanguageISO) { hasAtLeastOne = true; cbl.Items.Add(new ListItem("<img src='/css/images/flags/" + langISO + ".png'/>" + lang.FriendlyName + " (" + lang.CultureAlias + ")", langISO)); } } } if (!hasAtLeastOne) { footer.Visible = false; HtmlGenericControl div = new HtmlGenericControl("div"); wrapperDiv.Controls.Add(div); div.InnerHtml = umbraco.library.GetDictionaryItem("BabelFishNoLanguages");// "There are no languages available that have not already been translated."; } else { } } }
public void UpdateSortOrder(int ParentId, string SortOrder) { //TODO: The amount of processing this method takes is HUGE. We should look at // refactoring this to use purely the new APIs and see how much faster we can make it! try { if (AuthorizeRequest() == false) return; if (SortOrder.Trim().Length <= 0) return; var ids = SortOrder.Split(','); var isContent = helper.Request("app") == "content" | helper.Request("app") == ""; var isMedia = helper.Request("app") == "media"; //ensure user is authorized for the app requested if (isContent && AuthorizeRequest(DefaultApps.content.ToString()) == false) return; if (isMedia && AuthorizeRequest(DefaultApps.media.ToString()) == false) return; for (var i = 0; i < ids.Length; i++) { if (ids[i] == "" || ids[i].Trim() == "") continue; if (isContent) { var document = new Document(int.Parse(ids[i])) { sortOrder = i }; if (document.Published) { document.Publish(BusinessLogic.User.GetCurrent()); //TODO: WE don't want to have to republish the entire document !!!! library.UpdateDocumentCache(document); } else { //we need to save it if it is not published to persist the sort order value document.Save(); } } // to update the sortorder of the media node in the XML, re-save the node.... else if (isMedia) { var media = new cms.businesslogic.media.Media(int.Parse(ids[i])) { sortOrder = i }; media.Save(); } // Refresh sort order on cached xml if (isContent) { XmlNode parentNode = ParentId == -1 ? content.Instance.XmlContent.DocumentElement : content.Instance.XmlContent.GetElementById(ParentId.ToString()); //only try to do the content sort if the the parent node is available... if (parentNode != null) content.SortNodes(ref parentNode); // Load balancing - then refresh entire cache if (UmbracoSettings.UseDistributedCalls) library.RefreshContent(); // fire actionhandler, check for content BusinessLogic.Actions.Action.RunActionHandlers(new Document(ParentId), ActionSort.Instance); } } } catch (Exception ex) { LogHelper.Error<nodeSorter>("Could not update sort order", ex); } }
private void SaveDoc(Document doc) { doc.Save(); doc.Publish(User.GetCurrent()); umbraco.library.UpdateDocumentCache(doc.Id); }
protected void createEvent(object sender, EventArgs e) { var hasAnchors = false; var hasLowKarma = false; var documentId = 0; var karma = int.Parse(_member.getProperty("reputationTotal").Value.ToString()); if (karma < 50) { hasLowKarma = true; } //edit? if (string.IsNullOrEmpty(Request.QueryString["id"]) == false) { var document = new Document(int.Parse(Request.QueryString["id"])); documentId = document.Id; //allowed? if (document.ContentType.Alias == "Event" && int.Parse(document.getProperty("owner").Value.ToString()) == _member.Id) { SetDescription(document, hasLowKarma, ref hasAnchors); document.Text = tb_name.Text; document.getProperty("venue").Value = tb_venue.Text; document.getProperty("latitude").Value = tb_lat.Value; document.getProperty("longitude").Value = tb_lng.Value; var sync = tb_capacity.Text != document.getProperty("capacity").Value.ToString(); document.getProperty("capacity").Value = tb_capacity.Text; document.getProperty("start").Value = DateTime.Parse(dp_startdate.Text); document.getProperty("end").Value = DateTime.Parse(dp_enddate.Text); document.Save(); document.Publish(new User(0)); umbraco.library.UpdateDocumentCache(document.Id); if (sync) { var ev = new uEvents.Event(document); ev.syncCapacity(); } } } else { Document document = Document.MakeNew(tb_name.Text, DocumentType.GetByAlias("Event"), new User(0), EventsRoot); documentId = document.Id; SetDescription(document, hasLowKarma, ref hasAnchors); document.getProperty("venue").Value = tb_venue.Text; document.getProperty("latitude").Value = tb_lat.Value; document.getProperty("longitude").Value = tb_lng.Value; document.getProperty("capacity").Value = tb_capacity.Text; document.getProperty("signedup").Value = 0; document.getProperty("start").Value = DateTime.Parse(dp_startdate.Text); document.getProperty("end").Value = DateTime.Parse(dp_enddate.Text); document.getProperty("owner").Value = _member.Id; document.Save(); document.Publish(new User(0)); umbraco.library.UpdateDocumentCache(document.Id); } var redirectUrl = umbraco.library.NiceUrl(documentId); if (hasLowKarma && hasAnchors) SendPotentialSpamNotification(tb_name.Text, redirectUrl, _member.Id); Response.Redirect(redirectUrl); }
public static string ThumbsUpPost(string postId) { if (MembershipHelper.IsAuthenticated()) { var m = Member.GetCurrentMember(); var forumPost = _mapper.MapForumPost(new Node(Convert.ToInt32(postId))); // If this current member id owns the post then ignore if (forumPost != null) { if (m.Id != forumPost.Owner.MemberId) { // Get the member who wrote the post var postMember = new Member(Convert.ToInt32(forumPost.Owner.MemberId)); // Get a user to save both documents with var usr = new User(0); // First update the karma on the post and add this logged in user to // list if people who have voted on post var p = new Document(forumPost.Id); var votedUsers = p.getProperty("forumPostUsersVoted").Value.ToString(); var formattedMemberId = string.Format("{0}|", m.Id); // Check to make sure they are not fiddling the system if (forumPost.VotedMembersIds == null || !forumPost.VotedMembersIds.Contains(m.Id)) { p.getProperty("forumPostKarma").Value = (forumPost.Karma + 1); p.getProperty("forumPostUsersVoted").Value = formattedMemberId + votedUsers; p.Publish(usr); umbraco.library.UpdateDocumentCache(p.Id); var newPostKarma = (forumPost.Karma + 1); // Now update the members karma based on the forum settings forumPost.Karma = Convert.ToInt32(postMember.getProperty("forumUserKarma").Value.ToString()); postMember.getProperty("forumUserKarma").Value = (forumPost.Karma + Helpers.MainForumSettings().KarmaPointsAddedForThumbUps); // Save Member details postMember.Save(); //Generate member Xml Cache postMember.XmlGenerate(new System.Xml.XmlDocument()); return newPostKarma.ToString(); } } } } return "0"; }
protected void BtnSubmitPostClick(object sender, EventArgs e) { var txtPost = (TextBox)lvEditPost.FindControl("txtPost"); var btnSubmitPost = (Button)lvEditPost.FindControl("btnSubmitPost"); if (!string.IsNullOrEmpty(txtPost.Text)) { // If the user was on a deep page, redirect them to the same page var addPage = Request.QueryString["p"] != null ? string.Concat("&p=", Request.QueryString["p"].ToInt32()) : null; // Disable button so they don't try and post it twice! btnSubmitPost.Enabled = false; // Create a user we can use for both var u = new User(0); // Create the topic var p = new Document(Convert.ToInt32(CurrentNode.Id)); // Add the document properties p.getProperty("forumPostContent").Value = Helpers.HtmlEncode(Helpers.GetSafeHtml(txtPost.Text)); p.getProperty("forumPostLastEdited").Value = DateTime.Now; // publish application node p.Publish(u); // update the document cache so its available in the XML library.UpdateDocumentCache(p.Id); //############ Only do this is the post is a topic starter if (p.getProperty("forumPostIsTopicStarter").Value.ToString() == "1") { //Get the controls we need var pnlTopicTitle = (Panel)lvEditPost.FindControl("pnlTopicTitle"); var tbTopicTitle = (TextBox)pnlTopicTitle.FindControl("tbTopicTitle"); // This post is the topic starter, so get the topic var t = new Document(p.ParentId) { Text = tbTopicTitle.Text }; //Now see if we show admin buttons for topics if (CurrentMember.MemberIsAdmin) { var cbSticky = (CheckBox)lvEditPost.FindControl("cbSticky"); t.getProperty("forumTopicIsSticky").Value = cbSticky.Checked ? 1 : 0; var cbLockTopic = (CheckBox)lvEditPost.FindControl("cbLockTopic"); t.getProperty("forumTopicClosed").Value = cbLockTopic.Checked ? 1 : 0; } // publish application node t.Publish(u); // update the document cache so its available in the XML library.UpdateDocumentCache(t.Id); } //######################################################## // redirect to the topic now both are created Response.Redirect(string.Concat(library.NiceUrl(p.ParentId), "?nf=true", addPage, "#comment", p.Id)); } else { // Bah.. Show an error as no data in the fields Response.Redirect(string.Concat(CurrentPageAbsoluteUrl, "?m=", library.GetDictionaryItem("PleaseAddSomething"))); } }
public static string ThumbsDownPost(string postId) { if (MembershipHelper.IsAuthenticated()) { var m = Member.GetCurrentMember(); var forumPost = _mapper.MapForumPost(new Node(Convert.ToInt32(postId))); // If this current member id owns the post then ignore if (forumPost != null) { if (m.Id != forumPost.Owner.MemberId) { // Get the member who wrote the post //var postMember = new Member(Convert.ToInt32(ipage.ForumPostOwnedBy)); // Get a user to save both documents with var usr = new User(0); // First update the karma on the post and add this logged in user to // list if people who have voted on post var p = new Document(forumPost.Id); var formattedMemberId = string.Format("{0}|", m.Id); var votedUsers = p.getProperty("forumPostUsersVoted").Value.ToString(); // Check to make sure they are not fiddling the system if (forumPost.VotedMembersIds == null || !forumPost.VotedMembersIds.Contains(m.Id)) { p.getProperty("forumPostKarma").Value = (forumPost.Karma - 1); p.getProperty("forumPostUsersVoted").Value = formattedMemberId + votedUsers; p.Publish(usr); library.UpdateDocumentCache(p.Id); var newPostKarma = (forumPost.Karma - 1); return newPostKarma.ToString(); } } } } return "0"; }
public static string Move(int ID, int target) { int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0; if (Xslt.IsMemberInGroup("admin", _currentMember) || Xslt.IsMemberInGroup("wiki editor", _currentMember)) { Document d = new Document(ID); Document t = new Document(target); if(t.ContentType.Alias == "WikiPage"){ Document o = new Document(d.Parent.Id); d.Move(t.Id); d.Save(); d.Publish(new umbraco.BusinessLogic.User(0)); t.Publish(new umbraco.BusinessLogic.User(0)); o.Publish(new umbraco.BusinessLogic.User(0)); umbraco.library.UpdateDocumentCache(d.Id); umbraco.library.UpdateDocumentCache(t.Id); umbraco.library.UpdateDocumentCache(o.Id); umbraco.library.RefreshContent(); return umbraco.library.NiceUrl(d.Id); } } return ""; }
public static string SubScribeToTopic(string topicId) { if (!String.IsNullOrEmpty(Helpers.SafePlainText(topicId).Trim()) && MembershipHelper.IsAuthenticated()) { // Create the token user var u = new User(0); // Get the current logged in member var m = Member.GetCurrentMember(); // Get the formated member id we will use to remove from list var formattedMemberid = string.Format("{0}|", m.Id); // Get the topic var t = new Document(topicId.ToInt32()); //Get the full list of subscribers var subscriberlist = t.getProperty("forumTopicSubscribedList").Value.ToString(); // Add the document properties t.getProperty("forumTopicSubscribedList").Value = subscriberlist + formattedMemberid; // publish application node t.Publish(u); // update the document cache so its available in the XML library.UpdateDocumentCache(t.Id); return library.GetDictionaryItem("Success"); } return library.GetDictionaryItem("Error"); }
protected void saveProject(object sender, CommandEventArgs e) { Member m = Member.GetCurrentMember(); Document d; var memberHasEnoughReputation = MemberHasEnoughReputation(m); if (memberHasEnoughReputation == false) { holder.Visible = false; notallowed.Visible = true; } else { if (e.CommandName == "save") { int pId = int.Parse(e.CommandArgument.ToString()); d = new Document(pId); if ((int)d.getProperty("owner").Value == m.Id || Utils.IsProjectContributor(m.Id, d.Id)) { d.Text = tb_name.Text; d.getProperty("version").Value = tb_version.Text; d.getProperty("description").Value = tb_desc.Text; d.getProperty("stable").Value = cb_stable.Checked; d.getProperty("status").Value = tb_status.Text; d.getProperty("demoUrl").Value = tb_demoUrl.Text; d.getProperty("sourceUrl").Value = tb_sourceUrl.Text; d.getProperty("websiteUrl").Value = tb_websiteUrl.Text; d.getProperty("vendorUrl").Value = tb_purchaseUrl.Text; d.getProperty("licenseUrl").Value = tb_licenseUrl.Text; d.getProperty("licenseName").Value = tb_license.Text; d.getProperty("file").Value = dd_package.SelectedValue; d.getProperty("defaultScreenshot").Value = dd_screenshot.SelectedValue; if (dd_screenshot.SelectedIndex > -1) { d.getProperty("defaultScreenshotPath").Value = new uWiki.Businesslogic.WikiFile(int.Parse(dd_screenshot.SelectedValue)).Path; } else { d.getProperty("defaultScreenshotPath").Value = ""; } if (Request["projecttags[]"] != null) { Api.CommunityController.SetTags(d.Id.ToString(), "project", Request["projecttags[]"].ToString()); } Node category = new Node(int.Parse(dd_category.SelectedValue)); //if we have a proper category, move the package if (category != null && category.NodeTypeAlias == "ProductGroup") ; { if (d.Parent.Id != category.Id) { d.Move(category.Id); } } if (d.getProperty("packageGuid") == null || string.IsNullOrEmpty(d.getProperty("packageGuid").Value.ToString())) d.getProperty("packageGuid").Value = Guid.NewGuid().ToString(); d.Save(); d.Publish(new umbraco.BusinessLogic.User(0)); umbraco.library.UpdateDocumentCache(d.Id); umbraco.library.RefreshContent(); } } else { d = Document.MakeNew(tb_name.Text, new DocumentType(TypeId), new umbraco.BusinessLogic.User(0), RootId); d.getProperty("version").Value = tb_version.Text; d.getProperty("description").Value = tb_desc.Text; d.getProperty("stable").Value = cb_stable.Checked; d.getProperty("demoUrl").Value = tb_demoUrl.Text; d.getProperty("sourceUrl").Value = tb_sourceUrl.Text; d.getProperty("websiteUrl").Value = tb_websiteUrl.Text; d.getProperty("licenseUrl").Value = tb_licenseUrl.Text; d.getProperty("licenseName").Value = tb_license.Text; d.getProperty("vendorUrl").Value = tb_purchaseUrl.Text; //d.getProperty("file").Value = dd_package.SelectedValue; d.getProperty("owner").Value = m.Id; d.getProperty("packageGuid").Value = Guid.NewGuid().ToString(); if (Request["projecttags[]"] != null) { Api.CommunityController.SetTags(d.Id.ToString(), "project", Request["projecttags[]"].ToString()); d.getProperty("tags").Value = Request["projecttags[]"].ToString(); } Node category = new Node(int.Parse(dd_category.SelectedValue)); //if we have a proper category, move the package if (category != null && category.NodeTypeAlias == "ProductGroup") ; { if (d.Parent.Id != category.Id) { d.Move(category.Id); } } d.Save(); d.Publish(new umbraco.BusinessLogic.User(0)); umbraco.library.UpdateDocumentCache(d.Id); umbraco.library.RefreshContent(); } Response.Redirect(umbraco.library.NiceUrl(GotoOnSave)); } }
/// <summary> /// Saves and publishes a document /// Time: O(1), Space: O(1); where n - number of nodes on content tree. /// </summary> /// <param name="document">The document to save and publish</param> public static void SaveAndPublish(Document document) { if(document != null) { document.Save(); document.Publish(document.User); umbraco.library.UpdateDocumentCache(document.Id); } }