public WikiPage(int id) { umbraco.cms.businesslogic.web.Document doc = new umbraco.cms.businesslogic.web.Document(id); if (doc != null) { if (doc.ContentType.Alias == "WikiPage") { Exists = true; Body = doc.getProperty("bodyText").Value.ToString(); Locked = (doc.getProperty("umbracoNoEdit").Value.ToString() == "1"); if (doc.getProperty("keywords") != null) { Keywords = doc.getProperty("keywords").Value.ToString(); } Title = doc.Text; Author = (int)doc.getProperty("author").Value; Version = doc.Version; Node = doc; NodeId = doc.Id; ParentId = Node.Parent.Id; } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!(Page.Request.CurrentExecutionFilePath ?? string.Empty).Contains("editContent.aspx")) return; _lblOrderInfo = new Label(); var documentId = int.Parse(HttpContext.Current.Request.QueryString["id"]); var orderDoc = new Document(documentId); var orderGuidValue = orderDoc.getProperty("orderGuid").Value; if (orderGuidValue != null && !string.IsNullOrEmpty(orderGuidValue.ToString())) { var orderGuid = Guid.Parse(orderDoc.getProperty("orderGuid").Value.ToString()); var orderInfoXml = OrderHelper.GetOrderXML(orderGuid); var parameters = new Dictionary<string, object>(1) {{"uniqueOrderId", orderGuid.ToString()}}; var transformation = macro.GetXsltTransformResult(orderInfoXml, macro.getXslt("uwbsOrderInfo.xslt"), parameters); _lblOrderInfo.Text = transformation ?? "uwbsOrderInfo.xslt render issue"; } else { _lblOrderInfo.Text = "Unique Order ID not found. Republish might solve this issue"; } if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lblOrderInfo); }
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; }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!(Page.Request.CurrentExecutionFilePath ?? string.Empty).Contains("editContent.aspx")) return; try { var documentId = HttpContext.Current.Request["id"]; int docId; int.TryParse(documentId, out docId); if (docId != 0) { var emailDoc = new Document(docId); var property = emailDoc.getProperty("emailtemplate"); if(property.Value == null) { // fallback for old installations property = emailDoc.getProperty("xslttemplate"); } if (property.Value != null) { var value = property.Value.ToString(); if (!string.IsNullOrEmpty(value)) { var fileLocation = string.Format("{0}/{1}", SystemDirectories.MacroScripts.TrimEnd('/'), value.TrimStart('/')); _lblRenderRazorContent = new Literal {Text = RazorLibraryExtensions.RenderMacro(fileLocation, docId)}; if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lblRenderRazorContent); } } else { _lblRenderRazorContent = new Literal {Text = "No template set or found, reload node?"}; if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lblRenderRazorContent); } } } catch { _lblRenderRazorContent = new Literal { Text = "Error rendering data" }; if (ContentTemplateContainer != null) ContentTemplateContainer.Controls.Add(_lblRenderRazorContent); } }
public void SetDocumentDate(Document document) { if (!ItemDocumentTypes.Contains(document.ContentType.Alias)) return; if (document.getProperty(ItemDateProperty) == null) return; document.getProperty(ItemDateProperty).Value = document.CreateDateTime.Date; }
/// <summary> /// Document_s the new. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="umbraco.cms.businesslogic.NewEventArgs"/> instance containing the event data.</param> void Document_New(Document sender, umbraco.cms.businesslogic.NewEventArgs e) { if (sender.ContentType.Alias == "BlogPost") { if (sender.getProperty("PostDate") != null) { sender.getProperty("PostDate").Value = sender.CreateDateTime.Date; } } }
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 ActionResult Index(RenderModel model) { if (model.Content.TemplateId.Equals(Template.GetTemplateIdFromAlias("ProjectCreate"))) { var member = Member.GetCurrentMember(); if (member != null) { if (Request.HttpMethod.Equals("GET")) return CurrentTemplate(model); var project = CreateProject(member); if (project != null) return this.Redirect(umbraco.library.NiceUrl(project.Id)); } return this.Redirect(Request.UrlReferrer.AbsoluteUri); } else { var id = Convert.ToInt32(Request.Params["id"]); var project = new Document(id); var member = Member.GetCurrentMember(); var authorId = project.getProperty("author").Value; if (member != null && member.Id.Equals(authorId)) { if (Request.HttpMethod.Equals("GET")) return base.View(model); SaveProject(project, member); } return this.Redirect(umbraco.library.NiceUrl(id)); } }
public void Save() { string[] keys = Page.Request.Form.AllKeys; foreach (string key in keys) { if (key.StartsWith("DictionaryHelper")) { string strDocId = key.Substring(key.IndexOf("docId_") + 6); string property = key.Remove(key.IndexOf("docId_") - 1).Substring(17); string value = Page.Request.Form[key]; Document doc = new Document(int.Parse(strDocId)); if (property == "Text" || property == "Default" || property == "Help") { Property prop = doc.getProperty(property); if (prop != null) { prop.Value = value; } } else if (property == "Key") { doc.Text = value; } } } }
/// <summary> Document_BeforeSave(Document sender, umbraco.cms.businesslogic.SaveEventArgs e) umbraco Document BeforeSave event :Document prüfen /// </summary> void Document_BeforeSave(Document sender, umbraco.cms.businesslogic.SaveEventArgs e) { try { Config config = Config.GetConfig(); foreach (ConfigDatatype author in config.Datatypes) { foreach (Property pr in sender.GenericProperties) { if (author.Guid == pr.PropertyType.DataTypeDefinition.DataType.Id) { Property fileprop = sender.getProperty("" + pr.PropertyType.Alias + ""); e.Cancel = File_Scanner(fileprop); } } } } catch (Exception ex) { } if (html_msg.Length > 0) { HtmlContent(html_msg); html_msg.Clear(); } }
private void CopyProperties(Document fromDoc, Document toDoc) { foreach (umbraco.cms.businesslogic.propertytype.PropertyType propertyType in ParentDocument.ContentType.PropertyTypes) { toDoc.getProperty(propertyType.Alias).Value = fromDoc.getProperty(propertyType.Alias).Value; } }
/// <summary> /// Saveses this instance. /// </summary> public void Save() { // get the data Document document = new Document(NodeId.Value); Property editProperty = document.getProperty(Field); IDataType editDataType = null; if (editProperty != null) { // save the property PropertyType editPropertyType = editProperty.PropertyType; editDataType = editPropertyType.DataTypeDefinition.DataType; editDataType.Data.PropertyId = editProperty.Id; editDataType.Data.Value = Data; } else { if (Field == "pageName") { document.Text = Data.ToString(); } } document.Save(); }
// Implement the Run method of IRunnableWorkflowTask public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime) { // In Umbraco the workflowInstance should always be castable to an UmbracoWorkflowInstance var wf = (UmbracoWorkflowInstance) workflowInstance; // UmbracoWorkflowInstance has a list of node Ids that are associated with the workflow in the CmsNodes property foreach(var nodeId in wf.CmsNodes) { // We'll assume that only documents are attached to this workflow var doc = new Document(nodeId); var property = doc.getProperty(DocumentTypeProperty); if (!String.IsNullOrEmpty((string) property.Value)) continue; var host = HttpContext.Current.Request.Url.Host; var pageUrl = "http://" + host + umbraco.library.NiceUrl(nodeId); var shortUrl = API.Bit(BitLyLogin, BitLyApiKey, pageUrl, "Shorten"); property.Value = shortUrl; } // The run method of a workflow task is responsible for informing the runtime of the outcome. // The outcome should be one of the items in the AvailableTransitions list. runtime.Transition(workflowInstance, this, "done"); }
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"))); } }
private string GetValueRecursively(string alias, int nodeId) { Document n = new Document(nodeId); Property p = n.getProperty(alias); if (p != null && !string.IsNullOrEmpty(p.Value.ToString())) return p.Value.ToString(); else if (n.Level > 1) return GetValueRecursively(alias, n.Parent.Id); return string.Empty; }
/// <summary> /// Get the order document based on a given document/node Id /// Needs property with the alias "orderGuid" filled with the orderGuid of the order /// </summary> /// <param name="documentId"></param> /// <returns></returns> public static OrderInfo GetOrderByDocumentId(int documentId) { var orderDoc = new Document(documentId); if (orderDoc.getProperty("orderGuid") != null) { var orderGuidValue = orderDoc.getProperty("orderGuid").Value; if (orderGuidValue != null && !string.IsNullOrEmpty(orderGuidValue.ToString())) { var orderGuid = Guid.Parse(orderDoc.getProperty("orderGuid").Value.ToString()); return OrderHelper.GetOrderInfo(orderGuid); } } return null; }
public void BeforeDocumentPublish(Document document) { if (!ItemDocumentTypes.Contains(document.ContentType.Alias) || document.Parent == null) return; if (document.getProperty(ItemDateProperty) == null || document.getProperty(ItemDateProperty).Value == null) return; Log.Add(LogTypes.Debug, document.User, document.Id, string.Format("Start Auto Documents Before Publish Event for Document {0}", document.Id)); try { if (!HasDateChanged(document)) return; DateTime itemDate = Convert.ToDateTime(document.getProperty(ItemDateProperty).Value); Node parent = GetParentDocument(new Node(document.Parent.Id)); if (parent == null) return; var yearNode = GetOrCreateNode(document.User, parent, itemDate.Year.ToString(CultureInfo.InvariantCulture)); var monthNode = GetOrCreateNode(document.User, yearNode, itemDate.ToString("MM")); var parentNode = monthNode; if (CreateDayDocuments) { var dayNode = GetOrCreateNode(document.User, monthNode, itemDate.ToString("dd")); parentNode = dayNode; } if (parentNode != null && document.Parent.Id != parentNode.Id) { document.Move(parentNode.Id); Log.Add(LogTypes.Debug, document.User, document.Id, string.Format("Item {0} moved uder node {1}", document.Id, parentNode.Id)); } } catch (Exception ex) { Log.Add(LogTypes.Error, document.User, document.Id, string.Format("Error in Auto Documents Before Publish: {0}", ex.Message)); } library.RefreshContent(); }
protected void Page_Load(object sender, EventArgs e) { if (umbraco.library.IsLoggedOn() && int.TryParse(Request.QueryString["id"], out pageId)) { Member mem = Member.GetCurrentMember(); Document d = new Document(pageId); if ((d.getProperty("owner") != null && d.getProperty("owner").Value.ToString() == mem.Id.ToString())) { holder.Visible = true; } else { Response.Redirect("/"); } } }
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"); } } }
private void SaveProject(Document project, Member user) { if (!string.IsNullOrWhiteSpace(Request["title"])) { project.getProperty("title").Value = Request["title"]; } if (!string.IsNullOrWhiteSpace(Request["description"])) project.getProperty("description").Value = Request["description"]; if (!string.IsNullOrWhiteSpace(Request["projectType"])) project.getProperty("projectType").Value = Convert.ToInt32(Request["projectType"]); if (!string.IsNullOrWhiteSpace(Request["area"])) project.getProperty("area").Value = Convert.ToInt32(Request["area"]); project.getProperty("allowComments").Value = !string.IsNullOrWhiteSpace(Request["allowComments"]) && Request["allowComments"].ToLower().Equals("on"); project.getProperty("author").Value = user.Id; if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { var uploadedFile = Request.Files[0]; var fileName = Path.GetFileName(uploadedFile.FileName); var fileSavePath = Server.MapPath("~/media/projects/" + fileName); uploadedFile.SaveAs(fileSavePath); project.getProperty("image").Value = "/media/projects/" + fileName; } project.SaveAndPublish(user.User); umbraco.library.UpdateDocumentCache(project.Id); }
public void Save() { if (_data != null) _data.Value = _dlOrderStatus.SelectedValue; var documentId = int.Parse(HttpContext.Current.Request.QueryString["id"]); var orderDoc = new Document(documentId); var orderGuidValue = orderDoc.getProperty("orderGuid").Value; if (orderGuidValue == null) { return; } if (string.IsNullOrEmpty(orderGuidValue.ToString())) { return; } var orderInfo = OrderHelper.GetOrder(Guid.Parse(orderDoc.getProperty("orderGuid").Value.ToString())); orderInfo.SetStatus((OrderStatus) Enum.Parse(typeof (OrderStatus), _dlOrderStatus.SelectedValue), _cbSentEmail.Checked); orderInfo.Save(); }
void ProjectVote(object sender, ActionEventArgs e) { uPowers.BusinessLogic.Action a = (uPowers.BusinessLogic.Action)sender; if (a.Alias == "ProjectUp" || a.Alias == "ProjectDown") { Document d = new Document(e.ItemId); e.ReceiverId = (int)d.getProperty("owner").Value; e.ExtraReceivers = Utills.GetProjectContributors(d.Id); } }
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 WikiPage(int id) { umbraco.cms.businesslogic.web.Document doc = new umbraco.cms.businesslogic.web.Document(id); if (doc != null) { if (doc.ContentType.Alias == "WikiPage") { Exists = true; Body = doc.getProperty("bodyText").Value.ToString() ; Locked = (doc.getProperty("umbracoNoEdit").Value.ToString() == "1"); if(doc.getProperty("keywords") != null) Keywords = doc.getProperty("keywords").Value.ToString(); Title = doc.Text; Author = (int)doc.getProperty("author").Value; Version = doc.Version; Node = doc; NodeId = doc.Id; ParentId = Node.Parent.Id; } } }
void content_AfterUpdateDocumentCache(Document sender, umbraco.cms.businesslogic.DocumentCacheEventArgs e) { if (sender.ContentType.Alias == "runwayGalleryAlbum") { if (sender.getProperty("zipBulkUpload") != null && !String.IsNullOrEmpty(sender.getProperty("zipBulkUpload").Value.ToString())) { string zipFile = umbraco.GlobalSettings.FullpathToRoot + sender.getProperty("zipBulkUpload").Value.ToString(); // Loop through and extract all images string zipDir = unpackZip(zipFile); foreach (string file in Directory.GetFiles(zipDir)) { createMedia(file, sender); } // Delete zipped files Directory.Delete(zipDir); // Remove property sender.getProperty("zipBulkUpload").Value = ""; } } }
void Document_AfterSave(umbraco.cms.businesslogic.web.Document sender, umbraco.cms.businesslogic.SaveEventArgs e) { if (sender.ContentType.Alias == "WikiPage") { Hashtable fields = new Hashtable(); fields.Add("id", sender.Id); fields.Add("name", sender.Text); fields.Add("content", umbraco.library.StripHtml(sender.getProperty("bodyText").Value.ToString())); fields.Add("path", (sender.Path.Replace("-1,", "").Replace(",", new Businesslogic.Settings().PathSplit))); Businesslogic.Indexer i = new uSearch.Businesslogic.Indexer(); i.AddToIndex("wiki_" + sender.Id.ToString(), "wiki", fields); } }
public static void SetDateOnNew(Document sender, umbraco.cms.businesslogic.NewEventArgs e) { log.Info("SetDateOnNew start"); if (log.IsDebugEnabled) { log.Debug(string.Format("Name: {0} | ID: {1}", sender.Text, sender.Id)); } Property property = sender.getProperty(ConfigurationManager.PropertyAliases.Date.Value); log.Info("SetDateOnNew property found: " + property != null); if (property != null) { property.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); } log.Info("SetDateOnNew end"); }
public string Create(int parentId, string body, string title, string keywords) { var currentMemberId = Members.GetCurrentMember().Id; if (parentId > 0 && currentMemberId > 0) { var isAdmin = (Xslt.IsInGroup("admin") || Xslt.IsInGroup("wiki editor")); var doc = new Document(parentId); var isLocked = (doc.getProperty("umbracoNoEdit").Value.ToString() == "1"); if ((isAdmin || isLocked == false) && doc.ContentType.Alias == "WikiPage") { var wikiPage = WikiPage.Create(parentId, currentMemberId, body, title, keywords); return umbraco.library.NiceUrl(wikiPage.NodeId); } } return ""; }
/// <summary>Get documents by property relation static id. Documents must be published. Using CMS cache.</summary> public static IList<Document> GetDocumentsByPropertyRelationStaticId(Document cmsDocument) { IList<Document> items = new List<Document>(); var cmsRootNode = CmsHelper.GetRootItem(); var relationStaticIdProperty = cmsDocument.getProperty(PROPERTYALIAS__RelationStaticId); if(cmsRootNode != null && relationStaticIdProperty != null) { var cmsNodes = cmsRootNode.DescendantsOrSelf(cmsDocument.ContentType.Alias).Items; var cmsNodesCount = cmsNodes.Count; for(int i = 0;i < cmsNodesCount;i += 1) { if(cmsDocument.Id != cmsNodes[i].Id && String.Equals(cmsNodes[i].GetPropertyValue(PROPERTYALIAS__RelationStaticId), relationStaticIdProperty.Value)) { items.Add(new Document(cmsNodes[i].Id)); } } } return items; }
public static string Rollback(int ID, string guid) { int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0; umbraco.cms.businesslogic.web.Document olddoc = new umbraco.cms.businesslogic.web.Document(ID, new Guid(guid)); Businesslogic.WikiPage wp = new uWiki.Businesslogic.WikiPage(ID); if (olddoc != null && wp.Exists && !wp.Locked && _currentMember > 0 && wp.Version.ToString() != guid) { wp.Body = olddoc.getProperty("bodyText").Value.ToString(); wp.Title = olddoc.Text; wp.Author = _currentMember; wp.Save(); return(umbraco.library.NiceUrl(wp.NodeId)); } return(""); }
// Implement the Run method of IRunnableWorkflowTask public void Run(IWorkflowInstance workflowInstance, IWorkflowRuntime runtime) { // In Umbraco the workflowInstance should always be castable to an UmbracoWorkflowInstance var wf = (UmbracoWorkflowInstance)workflowInstance; var accessToken = new OAuthTokens { AccessToken = AccessToken, AccessTokenSecret = AccessTokenSecret, ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret }; foreach (var nodeId in wf.CmsNodes) { // We'll assume that only documents are attached to this workflow var doc = new Document(nodeId); string pageUrl; if(string.IsNullOrEmpty(ShortUrlProperty)) { // The user hasn't specified a property for a Short URL. var host = HttpContext.Current.Request.Url.Host; pageUrl = "http://" + host + umbraco.library.NiceUrl(nodeId); } else { pageUrl = (string)doc.getProperty(ShortUrlProperty).Value; } var tweet = string.Format(TweetText, doc.Text, pageUrl); // We could do some error checking with the result here.... var result = TwitterStatus.Update(accessToken, tweet); } // The run method of a workflow task is responsible for informing the runtime of the outcome. // The outcome should be one of the items in the AvailableTransitions list. runtime.Transition(workflowInstance, this, "done"); }
public static string Create(int parentID) { string _body = HttpContext.Current.Request["body"]; string _title = HttpContext.Current.Request["title"]; string _keywords = HttpContext.Current.Request["keywords"]; int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0; if (parentID > 0 && _currentMember > 0) { bool isAdmin = (Library.Xslt.IsInGroup("admin") || Library.Xslt.IsInGroup("wiki editor")); umbraco.cms.businesslogic.web.Document doc = new umbraco.cms.businesslogic.web.Document(parentID); bool isLocked = (doc.getProperty("umbracoNoEdit").Value.ToString() == "1"); if ((isAdmin || !isLocked) && doc.ContentType.Alias == "WikiPage") { Businesslogic.WikiPage wp = Businesslogic.WikiPage.Create(parentID, _currentMember, _body, _title, _keywords); return umbraco.library.NiceUrl(wp.NodeId); } } return ""; }
public static string Create(int parentID) { string _body = HttpContext.Current.Request["body"]; string _title = HttpContext.Current.Request["title"]; string _keywords = HttpContext.Current.Request["keywords"]; int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0; if (parentID > 0 && _currentMember > 0) { bool isAdmin = (Library.Xslt.IsInGroup("admin") || Library.Xslt.IsInGroup("wiki editor")); umbraco.cms.businesslogic.web.Document doc = new umbraco.cms.businesslogic.web.Document(parentID); bool isLocked = (doc.getProperty("umbracoNoEdit").Value.ToString() == "1"); if ((isAdmin || !isLocked) && doc.ContentType.Alias == "WikiPage") { Businesslogic.WikiPage wp = Businesslogic.WikiPage.Create(parentID, _currentMember, _body, _title, _keywords); return(umbraco.library.NiceUrl(wp.NodeId)); } } return(""); }