예제 #1
0
        public static void SendTestmail(string email,
                                        umbraco.cms.businesslogic.property.Property Property,
                                        string fromName, string fromEmail, bool IsHtml)
        {
            // version
            string version = Property.VersionId.ToString();

            // Get document
            umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(umbraco.cms.businesslogic.Content.GetContentFromVersion(Property.VersionId).Id);
            System.Web.HttpContext.Current.Items["pageID"] = d.Id;

            // Format mail
            string subject = d.Text;
            string sender  = "\"" + fromName + "\" <" + fromEmail + ">";

            // Get template
            System.Text.StringBuilder    sb     = new System.Text.StringBuilder();
            System.IO.StringWriter       sw     = new StringWriter(sb);
            System.Web.UI.HtmlTextWriter writer = new System.Web.UI.HtmlTextWriter(sw);
            umbraco.template             t      = new template(d.Template);
            t.ParseWithControls(new umbraco.page(d.Id, d.Version)).RenderControl(writer);

            // Embedded emails ;) added by DB, 2005-10-04

            EmailMessage message = mailerHelper.CreateEmbeddedEmail(sb.ToString(), Cms.BusinessLogic.web.Document.GetContentFromVersion(Property.VersionId).Id);

            message.FromAddress = new EmailAddress(fromEmail, fromName);
            message.ToAddresses.Add(new EmailAddress(email));
            message.Subject = subject;
            message.Send(new SmtpServer(GlobalSettings.SmtpServer));
        }
예제 #2
0
		public static void SendTestmail(string email, 
			umbraco.cms.businesslogic.property.Property Property, 
			string fromName, string fromEmail, bool IsHtml) 
		{
			// version
			string version = Property.VersionId.ToString();

			// Get document
			umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(umbraco.cms.businesslogic.Content.GetContentFromVersion(Property.VersionId).Id);
			System.Web.HttpContext.Current.Items["pageID"] = d.Id;

			// Format mail
			string subject = d.Text;
			string sender = "\"" + fromName + "\" <" + fromEmail + ">";

			// Get template			
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			System.IO.StringWriter sw = new StringWriter(sb);
			System.Web.UI.HtmlTextWriter writer = new System.Web.UI.HtmlTextWriter(sw);
			umbraco.template t = new template(d.Template);
			t.ParseWithControls(new umbraco.page(d.Id, d.Version)).RenderControl(writer);
			
			// Embedded emails ;) added by DB, 2005-10-04

			EmailMessage message = mailerHelper.CreateEmbeddedEmail(sb.ToString(), Cms.BusinessLogic.web.Document.GetContentFromVersion(Property.VersionId).Id);
            			
			message.FromAddress = new EmailAddress(fromEmail, fromName);
			message.ToAddresses.Add(new EmailAddress(email));
			message.Subject = subject;
			message.Send(new SmtpServer(GlobalSettings.SmtpServer));
            
		}
예제 #3
0
 private static void ContentAfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs e)
 {
     //ensure that only the providers that have DONT unpublishing support enabled
     //that are also flagged to listen
     ExamineManager.Instance.ReIndexNode(ToXDocument(sender, true).Root, IndexTypes.Content,
                                         ExamineManager.Instance.IndexProviderCollection.OfType <BaseUmbracoIndexer>()
                                         .Where(x => !x.SupportUnpublishedContent &&
                                                x.EnableDefaultEventHandler));
 }
예제 #4
0
        private static void ContentAfterClearDocumentCache(Document sender, DocumentCacheEventArgs e)
        {
            var nodeId = sender.Id.ToString();

            //ensure that only the providers that DONT have unpublishing support enabled
            //that are also flagged to listen
            ExamineManager.Instance.DeleteFromIndex(nodeId,
                                                    ExamineManager.Instance.IndexProviderCollection.OfType <BaseUmbracoIndexer>()
                                                    .Where(x => !x.SupportUnpublishedContent &&
                                                           x.EnableDefaultEventHandler));
        }
예제 #5
0
        void Document_AfterDelete(umbraco.cms.businesslogic.web.Document sender, umbraco.cms.businesslogic.DeleteEventArgs e)
        {
            if (sender.ContentType.Alias == "Forum")
            {
                umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "forum has been deleted");

                Businesslogic.Forum f = new uForum.Businesslogic.Forum(sender.Id);

                umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, f.Id, f.Title);

                f.Delete();
            }
        }
예제 #6
0
        void Document_AfterPublish(umbraco.cms.businesslogic.web.Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
        {
            if (sender.ContentType.Alias == "Forum")
            {
                Businesslogic.Forum f = new uForum.Businesslogic.Forum(sender.Id);

                if (!f.Exists)
                {
                    f.Id        = sender.Id;
                    f.ParentId  = sender.Parent.Id;
                    f.SortOrder = sender.sortOrder;
                }

                f.Save();
            }
        }
예제 #7
0
        public override void Execute(Core.ItemIdentifier itemId, Core.SerializableDictionary<string, string> Parameters)
        {
            Guid g;
            if(Guid.TryParse( itemId.Id, out g )){

                try
                {
                    umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(g);
                    if (d != null && d.Published && d.ReleaseDate < DateTime.Now)
                    {
                     //   d.Publish(new User(0));
                        d.XmlGenerate(new XmlDocument());
                        umbraco.library.UpdateDocumentCache(d.Id);
                    }
                }
                catch (Exception ex) {
                    Core.Helpers.Logging._Debug(ex.ToString());
                }
            }
        }
예제 #8
0
        public override void Execute(Core.ItemIdentifier itemId, Core.SerializableDictionary<string, string> Parameters)
        {
            Guid g;
            if (Guid.TryParse(itemId.Id, out g))
            {
                try {
                    umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(g);

                    if (d != null)
                    {
                        d.UnPublish();
                        umbraco.library.UnPublishSingleNode(d.Id);
                    }

                }
                catch (Exception ex) {
                    Umbraco.Courier.Core.Diagnostics.Logging.RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UnpushlishDocument", ex.ToString(), Core.Diagnostics.Logging.LogItemEntryType.Error);
                }
            }
        }
예제 #9
0
        public override void Execute(Core.ItemIdentifier itemId, Core.SerializableDictionary <string, string> Parameters)
        {
            Guid g;

            if (Guid.TryParse(itemId.Id, out g))
            {
                try {
                    umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(g);

                    if (d != null)
                    {
                        d.UnPublish();
                        umbraco.library.UnPublishSingleNode(d.Id);
                    }
                }
                catch (Exception ex) {
                    Umbraco.Courier.Core.Diagnostics.Logging.RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UnpushlishDocument", ex.ToString(), Core.Diagnostics.Logging.LogItemEntryType.Error);
                }
            }
        }
예제 #10
0
        public override void Execute(Core.ItemIdentifier itemId, Core.SerializableDictionary <string, string> Parameters)
        {
            Guid g;

            if (Guid.TryParse(itemId.Id, out g))
            {
                try
                {
                    umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(g);
                    if (d != null && d.Published && d.ReleaseDate < DateTime.Now)
                    {
                        d.XmlGenerate(new XmlDocument());
                        umbraco.library.UpdateDocumentCache(d.Id);
                    }
                }
                catch (Exception ex)
                {
                    Core.Helpers.Logging._Debug(ex.ToString());
                }
            }
        }
예제 #11
0
        private void ReindexContent(Guid contentGuid, ItemIdentifier itemId)
        {
            umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(contentGuid);
            if (d != null)
            {
                XmlNode n = d.ToXml(new XmlDocument(), true);
                if (n != null)
                {
                    XElement docXnode = XDocument.Parse(n.OuterXml).Root;
                    if (d.Published)
                    {
                        //only if published should it be added to indexes which doesnt support published content
                        try
                        {
                            ExamineManager.Instance.ReIndexNode(docXnode, IndexTypes.Content,
                               ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                                   .Where(x => x.EnableDefaultEventHandler));
                        }
                        catch (Exception ex)
                        {
                            RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                        }
                    }

                    //add to all indexes supporting unpublished content
                    try
                    {
                        ExamineManager.Instance.ReIndexNode(docXnode, IndexTypes.Content,
                           ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
                               .Where(x => x.SupportUnpublishedContent
                                   && x.EnableDefaultEventHandler));
                    }
                    catch (Exception ex)
                    {
                        RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                    }
                }
            }
        }
예제 #12
0
        private void ReindexContent(Guid contentGuid, ItemIdentifier itemId)
        {
            umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(contentGuid);
            if (d != null)
            {
                XmlNode n = d.ToXml(new XmlDocument(), true);
                if (n != null)
                {
                    XElement docXnode = XDocument.Parse(n.OuterXml).Root;
                    if (d.Published)
                    {
                        //only if published should it be added to indexes which doesnt support published content
                        try
                        {
                            ExamineManager.Instance.ReIndexNode(docXnode, IndexTypes.Content,
                                                                ExamineManager.Instance.IndexProviderCollection.OfType <BaseUmbracoIndexer>()
                                                                .Where(x => x.EnableDefaultEventHandler));
                        }
                        catch (Exception ex)
                        {
                            RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                        }
                    }

                    //add to all indexes supporting unpublished content
                    try
                    {
                        ExamineManager.Instance.ReIndexNode(docXnode, IndexTypes.Content,
                                                            ExamineManager.Instance.IndexProviderCollection.OfType <BaseUmbracoIndexer>()
                                                            .Where(x => x.SupportUnpublishedContent &&
                                                                   x.EnableDefaultEventHandler));
                    }
                    catch (Exception ex)
                    {
                        RevisionLog.Instance.AddItemEntry(itemId, this.GetType(), "UpdateLuceneIndexes", ex.ToString(), LogItemEntryType.Error);
                    }
                }
            }
        }
        private void HandleDocumentMoveOrCopy()
        {
            if (helper.Request("copyTo") != "" && helper.Request("id") != "")
            {
                // Check if the current node is allowed at new position
                bool nodeAllowed = false;

                cms.businesslogic.Content currentNode = new cms.businesslogic.Content(int.Parse(helper.Request("id")));
                int oldParent = -1;
                if (currentNode.Level > 1)
                {
                    oldParent = currentNode.Parent.Id;
                }
                cms.businesslogic.Content newNode = new cms.businesslogic.Content(int.Parse(helper.Request("copyTo")));

                // Check on contenttypes
                if (int.Parse(helper.Request("copyTo")) == -1)
                {
                    nodeAllowed = true;
                }
                else
                {
                    foreach (int i in newNode.ContentType.AllowedChildContentTypeIDs.ToList())
                    {
                        if (i == currentNode.ContentType.Id)
                        {
                            nodeAllowed = true;
                            break;
                        }
                    }
                    if (!nodeAllowed)
                    {
                        feedback.Text = ui.Text("moveOrCopy", "notAllowedByContentType", base.getUser());
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
                    }
                    else
                    {
                        // Check on paths
                        if (((string)("," + newNode.Path + ",")).IndexOf("," + currentNode.Id + ",") > -1)
                        {
                            nodeAllowed   = false;
                            feedback.Text = ui.Text("moveOrCopy", "notAllowedByPath", base.getUser());
                            feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
                        }
                    }
                }


                if (nodeAllowed)
                {
                    pane_form.Visible        = false;
                    pane_form_notice.Visible = false;
                    panel_buttons.Visible    = false;

                    string newNodeCaption = newNode.Id == -1 ? ui.Text(helper.Request("app")) : newNode.Text;

                    string[] nodes = { currentNode.Text, newNodeCaption };

                    if (UmbracoContext.Current.Request["mode"] == "cut")
                    {
                        if (UmbracoContext.Current.Request["app"] == "content")
                        {
                            //PPH changed this to document instead of cmsNode to handle republishing.
                            cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
                            d.Move(int.Parse(helper.Request("copyTo")));
                            if (d.Published)
                            {
                                d.Publish(new umbraco.BusinessLogic.User(0));
                                //using library.publish to support load balancing.
                                //umbraco.library.PublishSingleNode(d.Id);
                                umbraco.library.UpdateDocumentCache(d.Id);

                                //PPH added handling of load balanced moving of multiple nodes...
                                if (d.HasChildren)
                                {
                                    handleChildNodes(d);
                                }

                                //Using the general Refresh content method instead as it supports load balancing.
                                //we only need to do this if the node is actually published.
                                library.RefreshContent();
                            }
                            d.Save(); //stub to save stuff to the db.
                        }
                        else
                        {
                            Media m = new Media(int.Parse(UmbracoContext.Current.Request["id"]));
                            m.Move(int.Parse(UmbracoContext.Current.Request["copyTo"]));
                            m.XmlGenerate(new XmlDocument());
                            library.ClearLibraryCacheForMedia(m.Id);
                        }

                        feedback.Text = ui.Text("moveOrCopy", "moveDone", nodes, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;

                        // refresh tree
                        ClientTools.MoveNode(currentNode.Id.ToString(), newNode.Path);
                    }
                    else
                    {
                        cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
                        d.Copy(int.Parse(helper.Request("copyTo")), this.getUser(), RelateDocuments.Checked);
                        feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
                        ClientTools.CopyNode(currentNode.Id.ToString(), newNode.Path);
                    }
                }
            }
        }
예제 #14
0
        public static void SendMail(umbraco.cms.businesslogic.member.MemberGroup Group, umbraco.cms.businesslogic.property.Property Property, string fromName, string fromEmail, bool IsHtml)
        {
            // Create ArrayList with emails who've received the e-mail
            ArrayList sent = new ArrayList();

            // set timeout
            System.Web.HttpContext.Current.Server.ScriptTimeout = 43200;             // 12 hours
            // version
            string version = Property.VersionId.ToString();

            // Get document
            umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(umbraco.cms.businesslogic.Content.GetContentFromVersion(Property.VersionId).Id);
            int id = d.Id;

            System.Web.HttpContext.Current.Items["pageID"] = id;

            // Format mail
            string subject = d.Text;
            string sender  = "\"" + fromName + "\" <" + fromEmail + ">";

            // Get template
            System.Text.StringBuilder    sb     = new System.Text.StringBuilder();
            System.IO.StringWriter       sw     = new StringWriter(sb);
            System.Web.UI.HtmlTextWriter writer = new System.Web.UI.HtmlTextWriter(sw);
            umbraco.template             t      = new template(d.Template);
            t.ParseWithControls(new umbraco.page(d.Id, d.Version)).RenderControl(writer);


            EmailMessage message = mailerHelper.CreateEmbeddedEmail(sb.ToString(), Cms.BusinessLogic.web.Document.GetContentFromVersion(Property.VersionId).Id);

            message.FromAddress = new EmailAddress(fromEmail, fromName);
            message.Subject     = subject;
            SmtpServer smtpServer = new SmtpServer(GlobalSettings.SmtpServer);

            // Bulk send mails
            int counter = 0;

            System.Text.StringBuilder sbStatus = new System.Text.StringBuilder();
            sbStatus.Append("The Newsletter '" + d.Text + "' was starting at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\n");
            using (SqlDataReader dr = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(umbraco.GlobalSettings.DbDSN, CommandType.Text, "select text, email from cmsMember inner join umbracoNode node on node.id = cmsMember.nodeId inner join cmsMember2memberGroup on cmsmember.nodeId = cmsMember2MemberGroup.member where memberGroup = @memberGroupId", new SqlParameter("@memberGroupId", Group.Id)))
            {
                while (dr.Read())
                {
                    try
                    {
                        if (!sent.Contains(dr["email"].ToString()))
                        {
                            message.ToAddresses.Clear();
                            message.ToAddresses.Add(new EmailAddress(dr["email"].ToString(), dr["text"].ToString()));
                            message.Send(smtpServer);

                            // add to arraylist of receiptients
                            sent.Add(dr["email"].ToString());

                            // Append to status
                            sbStatus.Append("Sent to " + dr["text"].ToString() + " <" + dr["email"].ToString() + "> \n\r");
                        }
                        else
                        {
                            // Append to status
                            sbStatus.Append("E-mail has already been sent to email '" + dr["email"].ToString() + ". You have a duplicate member: " + dr["text"].ToString() + " <" + dr["email"].ToString() + "> \n\r");
                        }
                    }
                    catch (Exception ee)
                    {
                        sbStatus.Append("Error sending to " + dr["text"].ToString() + " <" + dr["email"].ToString() + ">: " +
                                        ee.ToString() + " \n");
                    }

                    // For progress bar
                    counter++;

                    if (counter % 5 == 0)
                    {
                        System.Web.HttpContext.Current.Application.Lock();
                        System.Web.HttpContext.Current.Application["ultraSimpleMailerProgress" + id.ToString() + "Done"] = counter;
                        System.Web.HttpContext.Current.Application.UnLock();
                    }
                }
            }

            sbStatus.Append("Finished at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\n");

            // Send status mail
            library.SendMail(fromEmail, fromEmail, "Newsletter status", sbStatus.ToString(), false);
        }
 //even if we override it will still be optimized because of the LoadMinimalDocument flag
 protected override void OnRenderNode(ref XmlTreeNode xNode, umbraco.cms.businesslogic.web.Document doc)
 {
     base.OnRenderNode(ref xNode, doc);
 }
예제 #16
0
        /// <summary>
        /// Guesses the NiceUrl based on the node id.
        /// </summary>
        /// <param name="nodeId">The node id.</param>
        /// <returns>Returns a guestimate of the NiceUrl for a node id.</returns>
        /// <remarks>
        /// GuessNiceUrl is not very performant when attempting to guess the URL for unpublished nodes.
        /// Do not over-use this method. It makes many database calls and will be slow!
        /// </remarks>
        public static string GuessNiceUrl(int nodeId)
        {
            var node = new Node(nodeId);
            var niceUrl = node.NiceUrl;
            var published = node.Path != null;

            if (!niceUrl.StartsWith(Constants.Common.HTTP) || !published)
            {
                const string URLNAME = Constants.Umbraco.Content.UrlName; // "umbracoUrlName";
                var hasDomain = false;
                var domain = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower();
                string nodeName;
                string nodePath;
                int nodeParentId;

                // if the node is published, get from the nodeFactory
                if (published)
                {
                    nodeName = node.GetProperty(URLNAME) != null && !string.IsNullOrEmpty(node.GetProperty(URLNAME).Value) ? node.GetProperty(URLNAME).Value : node.Name;
                    nodePath = node.Path;
                    nodeParentId = node.Parent != null ? node.Parent.Id : uQuery.RootNodeId;
                }
                else
                {
                    // otherwise, get from the Document object.
                    var doc = new umbraco.cms.businesslogic.web.Document(nodeId);
                    nodeName = doc.getProperty(URLNAME) != null && doc.getProperty(URLNAME).Value != null && !string.IsNullOrEmpty(doc.getProperty(URLNAME).Value.ToString()) ? doc.getProperty(URLNAME).Value.ToString() : doc.Text;
                    nodePath = doc.Path;
                    nodeParentId = doc.ParentId;
                }

                // check if the node has a domain associated.
                if (UmbracoSettings.UseDomainPrefixes)
                {
                    // get the path
                    var path = nodePath.Split(Constants.Common.SLASH);

                    // loop through each part of the path in reverse order
                    for (int i = path.Length - 1; i >= 0; i--)
                    {
                        int partId;
                        if (int.TryParse(path[i], out partId))
                        {
                            var domains = umbraco.cms.businesslogic.web.Domain.GetDomainsById(partId);
                            if (domains != null && domains.Length > 0)
                            {
                                hasDomain = true;
                                domain = domains[0].Name;
                                break;
                            }
                        }
                    }
                }

                // if the node is unpublished...
                if (!published)
                {
                    // get the published node for the parent node.
                    var parentNode = new Node(nodeParentId);
                    if (parentNode.Path != null || (nodeParentId == uQuery.RootNodeId && !hasDomain))
                    {
                        int level = parentNode.Path.Split(Constants.Common.COMMA).Length;
                        string parentUrl = nodeParentId > 0 && !(level == 2 && GlobalSettings.HideTopLevelNodeFromPath) ? parentNode.NiceUrl : string.Empty;
                        string urlName = string.Concat(Constants.Common.SLASH, url.FormatUrl(nodeName.ToLower()));
                        string fileExtension = GlobalSettings.UseDirectoryUrls ? string.Empty : Constants.Common.DOTASPX;

                        // construct the NiceUrl for the unpublished node.
                        niceUrl = string.Concat(parentUrl.Replace(Constants.Common.DOTASPX, string.Empty), urlName, fileExtension);
                    }
                }

                // if the node has a domain, and is unpublished, use the domain.
                if (niceUrl == Constants.Common.HASH && hasDomain)
                {
                    niceUrl = string.Concat(Constants.Common.HTTP, domain);
                }

                // if the NiceUrl doesn't start with 'http://' (and isn't '#') then prepend it.
                if (!niceUrl.StartsWith(Constants.Common.HTTP) && niceUrl != Constants.Common.HASH)
                {
                    niceUrl = string.Concat(Constants.Common.HTTP, domain, niceUrl);
                }
            }

            return niceUrl;
        }
예제 #17
0
        private void HandleDocumentMoveOrCopy() 
		{
			if (helper.Request("copyTo") != "" && helper.Request("id") != "") 
			{
				// Check if the current node is allowed at new position
				bool nodeAllowed = false;

				cms.businesslogic.Content currentNode = new cms.businesslogic.Content(int.Parse(helper.Request("id")));
                int oldParent = -1;
                if (currentNode.Level > 1)
                   oldParent = currentNode.Parent.Id;
				cms.businesslogic.Content newNode = new cms.businesslogic.Content(int.Parse(helper.Request("copyTo")));

				// Check on contenttypes
				if (int.Parse(helper.Request("copyTo")) == -1)
					nodeAllowed = true;
				else 
				{
					foreach (int i in newNode.ContentType.AllowedChildContentTypeIDs.ToList())
						if (i == currentNode.ContentType.Id) 
						{
							nodeAllowed = true;
							break;
						}
                    if (!nodeAllowed) {
                        feedback.Text = ui.Text("moveOrCopy", "notAllowedByContentType", base.getUser());
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
                    } else {
                        // Check on paths
                        if (((string)("," + newNode.Path + ",")).IndexOf("," + currentNode.Id + ",") > -1) {
                            nodeAllowed = false;
                            feedback.Text = ui.Text("moveOrCopy", "notAllowedByPath", base.getUser());
                            feedback.type = umbraco.uicontrols.Feedback.feedbacktype.error;
                        }
                    }
				}


				if (nodeAllowed) 
				{
                    pane_form.Visible = false;
                    pane_form_notice.Visible = false;
                    panel_buttons.Visible = false;

                    string newNodeCaption = newNode.Id == -1 ? ui.Text(helper.Request("app")) : newNode.Text;

                    string[] nodes = {currentNode.Text, newNodeCaption };

                    if (UmbracoContext.Current.Request["mode"] == "cut")
                    {
                        if (UmbracoContext.Current.Request["app"] == "content")
                        {
                            //PPH changed this to document instead of cmsNode to handle republishing.
                            cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
                            d.Move(int.Parse(helper.Request("copyTo")));
                            if (d.Published)
                            {
                                d.Publish(new umbraco.BusinessLogic.User(0));
                                //using library.publish to support load balancing.
                                //umbraco.library.PublishSingleNode(d.Id);
                                umbraco.library.UpdateDocumentCache(d.Id);

                                //PPH added handling of load balanced moving of multiple nodes...
                                if (d.HasChildren)
                                {
                                    handleChildNodes(d);
                                }

                                //Using the general Refresh content method instead as it supports load balancing. 
                                //we only need to do this if the node is actually published.
                                library.RefreshContent();
                            }
                            d.Save(); //stub to save stuff to the db.
                        }
                        else
                        {
                            Media m = new Media(int.Parse(UmbracoContext.Current.Request["id"]));
                            m.Move(int.Parse(UmbracoContext.Current.Request["copyTo"]));
                            m.XmlGenerate(new XmlDocument());
                            library.ClearLibraryCacheForMedia(m.Id);
                        }                                 

                        feedback.Text = ui.Text("moveOrCopy", "moveDone", nodes, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;

                        // refresh tree
						ClientTools.MoveNode(currentNode.Id.ToString(), newNode.Path);

                    } 
					else 
					{
						cms.businesslogic.web.Document d = new cms.businesslogic.web.Document(int.Parse(helper.Request("id")));
						d.Copy(int.Parse(helper.Request("copyTo")), this.getUser(), RelateDocuments.Checked);
						feedback.Text = ui.Text("moveOrCopy", "copyDone", nodes, base.getUser()) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
                        feedback.type = umbraco.uicontrols.Feedback.feedbacktype.success;
						ClientTools.CopyNode(currentNode.Id.ToString(), newNode.Path);
                    }
				} 
			}
		}
예제 #18
0
		private static void ContentAfterClearDocumentCache(Document sender, DocumentCacheEventArgs e)
		{
			var nodeId = sender.Id.ToString();
			//ensure that only the providers that DONT have unpublishing support enabled           
			//that are also flagged to listen
			ExamineManager.Instance.DeleteFromIndex(nodeId,
				ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
					.Where(x => !x.SupportUnpublishedContent
						&& x.EnableDefaultEventHandler));
		}
예제 #19
0
		private static void ContentAfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs e)
		{
			//ensure that only the providers that have DONT unpublishing support enabled       
			//that are also flagged to listen
			ExamineManager.Instance.ReIndexNode(ToXDocument(sender, true).Root, IndexTypes.Content,
				ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>()
					.Where(x => !x.SupportUnpublishedContent
						&& x.EnableDefaultEventHandler));
		}
예제 #20
0
		public static void SendMail(umbraco.cms.businesslogic.member.MemberGroup Group, umbraco.cms.businesslogic.property.Property Property, string fromName, string fromEmail, bool IsHtml) 
		{
            // Create ArrayList with emails who've received the e-mail
            ArrayList sent = new ArrayList();

			// set timeout
			System.Web.HttpContext.Current.Server.ScriptTimeout = 43200; // 12 hours
			// version
			string version = Property.VersionId.ToString();

			// Get document
			umbraco.cms.businesslogic.web.Document d = new umbraco.cms.businesslogic.web.Document(umbraco.cms.businesslogic.Content.GetContentFromVersion(Property.VersionId).Id);
			int id = d.Id;
			System.Web.HttpContext.Current.Items["pageID"] = id;

			// Format mail
			string subject = d.Text;
			string sender = "\"" + fromName + "\" <" + fromEmail + ">";

			// Get template			
			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			System.IO.StringWriter sw = new StringWriter(sb);
			System.Web.UI.HtmlTextWriter writer = new System.Web.UI.HtmlTextWriter(sw);
			umbraco.template t = new template(d.Template);
			t.ParseWithControls(new umbraco.page(d.Id, d.Version)).RenderControl(writer);


			EmailMessage message = mailerHelper.CreateEmbeddedEmail(sb.ToString(), Cms.BusinessLogic.web.Document.GetContentFromVersion(Property.VersionId).Id);
            			
			message.FromAddress = new EmailAddress(fromEmail, fromName);
			message.Subject = subject;
			SmtpServer smtpServer = new SmtpServer(GlobalSettings.SmtpServer);

			// Bulk send mails
			int counter = 0;
			System.Text.StringBuilder sbStatus = new System.Text.StringBuilder();
			sbStatus.Append("The Newsletter '" + d.Text + "' was starting at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\n");
			using(SqlDataReader dr = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(umbraco.GlobalSettings.DbDSN, CommandType.Text, "select text, email from cmsMember inner join umbracoNode node on node.id = cmsMember.nodeId inner join cmsMember2memberGroup on cmsmember.nodeId = cmsMember2MemberGroup.member where memberGroup = @memberGroupId", new SqlParameter("@memberGroupId", Group.Id)))
			{
				while(dr.Read())
				{
					try
					{
                        if (!sent.Contains(dr["email"].ToString()))
                        {
                            message.ToAddresses.Clear();
                            message.ToAddresses.Add(new EmailAddress(dr["email"].ToString(), dr["text"].ToString()));
                            message.Send(smtpServer);

                            // add to arraylist of receiptients
                            sent.Add(dr["email"].ToString());

                            // Append to status
                            sbStatus.Append("Sent to " + dr["text"].ToString() + " <" + dr["email"].ToString() + "> \n\r");
                        }
                        else
                        {
                            // Append to status
                            sbStatus.Append("E-mail has already been sent to email '" + dr["email"].ToString() + ". You have a duplicate member: " + dr["text"].ToString() + " <" + dr["email"].ToString() + "> \n\r");
                        }
					}
					catch(Exception ee)
					{
						sbStatus.Append("Error sending to " + dr["text"].ToString() + " <" + dr["email"].ToString() + ">: " +
						                ee.ToString() + " \n");
					}

					// For progress bar
					counter++;

					if(counter % 5 == 0)
					{
						System.Web.HttpContext.Current.Application.Lock();
						System.Web.HttpContext.Current.Application["ultraSimpleMailerProgress" + id.ToString() + "Done"] = counter;
						System.Web.HttpContext.Current.Application.UnLock();
					}
				}
			}

			sbStatus.Append("Finished at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\n");

			// Send status mail
			library.SendMail(fromEmail, fromEmail, "Newsletter status", sbStatus.ToString(), false);
		}
예제 #21
0
        /// <summary>
        /// Guesses the NiceUrl based on the node id.
        /// </summary>
        /// <param name="nodeId">The node id.</param>
        /// <returns>Returns a guestimate of the NiceUrl for a node id.</returns>
        /// <remarks>
        /// GuessNiceUrl is not very performant when attempting to guess the URL for unpublished nodes.
        /// Do not over-use this method. It makes many database calls and will be slow!
        /// </remarks>
        public static string GuessNiceUrl(int nodeId)
        {
            var node      = new Node(nodeId);
            var niceUrl   = node.NiceUrl;
            var published = node.Path != null;

            if (!niceUrl.StartsWith(Constants.Common.HTTP) || !published)
            {
                const string URLNAME   = Constants.Umbraco.Content.UrlName;               // "umbracoUrlName";
                var          hasDomain = false;
                var          domain    = HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToLower();
                string       nodeName;
                string       nodePath;
                int          nodeParentId;

                // if the node is published, get from the nodeFactory
                if (published)
                {
                    nodeName     = node.GetProperty(URLNAME) != null && !string.IsNullOrEmpty(node.GetProperty(URLNAME).Value) ? node.GetProperty(URLNAME).Value : node.Name;
                    nodePath     = node.Path;
                    nodeParentId = node.Parent != null ? node.Parent.Id : uQuery.RootNodeId;
                }
                else
                {
                    // otherwise, get from the Document object.
                    var doc = new umbraco.cms.businesslogic.web.Document(nodeId);
                    nodeName     = doc.getProperty(URLNAME) != null && doc.getProperty(URLNAME).Value != null && !string.IsNullOrEmpty(doc.getProperty(URLNAME).Value.ToString()) ? doc.getProperty(URLNAME).Value.ToString() : doc.Text;
                    nodePath     = doc.Path;
                    nodeParentId = doc.ParentId;
                }

                // check if the node has a domain associated.
                if (UmbracoSettings.UseDomainPrefixes)
                {
                    // get the path
                    var path = nodePath.Split(Constants.Common.SLASH);

                    // loop through each part of the path in reverse order
                    for (int i = path.Length - 1; i >= 0; i--)
                    {
                        int partId;
                        if (int.TryParse(path[i], out partId))
                        {
                            var domains = umbraco.cms.businesslogic.web.Domain.GetDomainsById(partId);
                            if (domains != null && domains.Length > 0)
                            {
                                hasDomain = true;
                                domain    = domains[0].Name;
                                break;
                            }
                        }
                    }
                }

                // if the node is unpublished...
                if (!published)
                {
                    // get the published node for the parent node.
                    var parentNode = new Node(nodeParentId);
                    if (parentNode.Path != null || (nodeParentId == uQuery.RootNodeId && !hasDomain))
                    {
                        int    level         = parentNode.Path.Split(Constants.Common.COMMA).Length;
                        string parentUrl     = nodeParentId > 0 && !(level == 2 && GlobalSettings.HideTopLevelNodeFromPath) ? parentNode.NiceUrl : string.Empty;
                        string urlName       = string.Concat(Constants.Common.SLASH, url.FormatUrl(nodeName.ToLower()));
                        string fileExtension = GlobalSettings.UseDirectoryUrls ? string.Empty : Constants.Common.DOTASPX;

                        // construct the NiceUrl for the unpublished node.
                        niceUrl = string.Concat(parentUrl.Replace(Constants.Common.DOTASPX, string.Empty), urlName, fileExtension);
                    }
                }

                // if the node has a domain, and is unpublished, use the domain.
                if (niceUrl == Constants.Common.HASH && hasDomain)
                {
                    niceUrl = string.Concat(Constants.Common.HTTP, domain);
                }

                // if the NiceUrl doesn't start with 'http://' (and isn't '#') then prepend it.
                if (!niceUrl.StartsWith(Constants.Common.HTTP) && niceUrl != Constants.Common.HASH)
                {
                    niceUrl = string.Concat(Constants.Common.HTTP, domain, niceUrl);
                }
            }

            return(niceUrl);
        }