Esempio n. 1
0
        public static void RemoveMemberFromPotentialSpamGroup(Member member)
        {
            var memberGroup = MemberGroup.GetByName(SpamMemberGroupName);

            if (memberGroup == null)
            {
                MemberGroup.MakeNew(SpamMemberGroupName, new User(0));
            }

            memberGroup = MemberGroup.GetByName(SpamMemberGroupName);
            member.RemoveGroup(memberGroup.Id);
        }
Esempio n. 2
0
        public static void AddMemberToPotentialSpamGroup(Member member)
        {
            var memberGroup = MemberGroup.GetByName(SpamMemberGroupName);

            if (memberGroup == null)
            {
                MemberGroup.MakeNew(SpamMemberGroupName, new User(0));
            }

            memberGroup = MemberGroup.GetByName(SpamMemberGroupName);
            member.AddGroup(memberGroup.Id);
        }
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad (e);

			// init progressbar
			pb = new umbraco.controls.progressBar();
			Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "UltraSimpleMailerJs", "<script language='javascript' src='/Umbraco_client/ultraSimpleMailer/javascript.js'></script>");
			string[] config = _configuration.Split("|".ToCharArray());
			Cms.BusinessLogic.Member.MemberGroup mg = new umbraco.cms.businesslogic.member.MemberGroup(int.Parse(config[2]));
			string totalReceip = mailerLogic.GetTotalReceiptients(mg).ToString();
			Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ultraSimpleMailerAjax", "<script language='javascript' src='webservices/ajax.js'></script><script language='javascript' src='webservices/GetJavaScriptProxy.aspx?service=progressStatus.asmx'></script><script>\nultraSimpleMailerTotalMails = " + totalReceip + ";\nvar ultraSimpleMailerId = 'ultraSimpleMailerProgress" + this._data.NodeId + "';</script>");
			Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "progressBar", "<script language='javascript' src='/Umbraco_client/progressBar/javascript.js'></script>");
			Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "progressBarCss", "<LINK href=\"/Umbraco_client/progressBar/style.css\" type=\"text/css\" rel=\"stylesheet\">");
		}
Esempio n. 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // init progressbar
            pb = new umbraco.controls.progressBar();
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "UltraSimpleMailerJs", "<script language='javascript' src='/Umbraco_client/ultraSimpleMailer/javascript.js'></script>");
            string[] config = _configuration.Split("|".ToCharArray());
            Cms.BusinessLogic.Member.MemberGroup mg = new umbraco.cms.businesslogic.member.MemberGroup(int.Parse(config[2]));
            string totalReceip = mailerLogic.GetTotalReceiptients(mg).ToString();

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ultraSimpleMailerAjax", "<script language='javascript' src='webservices/ajax.js'></script><script language='javascript' src='webservices/GetJavaScriptProxy.aspx?service=progressStatus.asmx'></script><script>\nultraSimpleMailerTotalMails = " + totalReceip + ";\nvar ultraSimpleMailerId = 'ultraSimpleMailerProgress" + this._data.NodeId + "';</script>");
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "progressBar", "<script language='javascript' src='/Umbraco_client/progressBar/javascript.js'></script>");
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "progressBarCss", "<LINK href=\"/Umbraco_client/progressBar/style.css\" type=\"text/css\" rel=\"stylesheet\">");
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // init progressbar
            pb = new umbraco.controls.progressBar();
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "UltraSimpleMailerJs", "<script language='javascript' src='/" + GlobalSettings.ClientPath + "/ultraSimpleMailer/javascript.js'></script>");
            string[] config = _configuration.Split("|".ToCharArray());
            cms.businesslogic.member.MemberGroup mg = new umbraco.cms.businesslogic.member.MemberGroup(int.Parse(config[11]));
            string totalReceip = mailerLogic.GetTotalReceiptients(mg).ToString();
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "ultraSimpleMailerAjax", "<script>\nultraSimpleMailerTotalMails = " + totalReceip + ";\nvar ultraSimpleMailerId = 'ultraSimpleMailerProgress" + this._data.NodeId + "';</script>");
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "progressBar", "<script language='javascript' src='/umbraco_client/progressBar/javascript.js'></script>");
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "progressBarCss", "<link href=\"" + GlobalSettings.ClientPath + "/progressBar/style.css\" type=\"text/css\" rel=\"stylesheet\">");

            // We need to make sure we have a reference to the legacy ajax calls in the scriptmanager
            presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page);
        }
Esempio n. 6
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            // init progressbar
            pb = new umbraco.controls.progressBar();
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "UltraSimpleMailerJs", "<script language='javascript' src='/" + GlobalSettings.ClientPath + "/ultraSimpleMailer/javascript.js'></script>");
            string[] config = _configuration.Split("|".ToCharArray());
            cms.businesslogic.member.MemberGroup mg = new umbraco.cms.businesslogic.member.MemberGroup(int.Parse(config[11]));
            string totalReceip = mailerLogic.GetTotalReceiptients(mg).ToString();

            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "ultraSimpleMailerAjax", "<script>\nultraSimpleMailerTotalMails = " + totalReceip + ";\nvar ultraSimpleMailerId = 'ultraSimpleMailerProgress" + this._data.NodeId + "';</script>");
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "progressBar", "<script language='javascript' src='/umbraco_client/progressBar/javascript.js'></script>");
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "progressBarCss", "<link href=\"" + GlobalSettings.ClientPath + "/progressBar/style.css\" type=\"text/css\" rel=\"stylesheet\">");

            // We need to make sure we have a reference to the legacy ajax calls in the scriptmanager
            presentation.webservices.ajaxHelpers.EnsureLegacyCalls(base.Page);
        }
Esempio n. 7
0
        public static cms.businesslogic.member.MemberGroup[] GetAccessingGroups(int DocumentId)
        {
            cms.businesslogic.web.Document d = new Document(DocumentId);

            if (!IsProtected(DocumentId, d.Path))
            {
                return(null);
            }
            else
            {
                XmlNode currentNode = getPage(getProtectedPage(d.Path));
                cms.businesslogic.member.MemberGroup[] mg = new umbraco.cms.businesslogic.member.MemberGroup[currentNode.SelectNodes("./group").Count];
                int count = 0;
                foreach (XmlNode n in currentNode.SelectNodes("./group"))
                {
                    mg[count] = new cms.businesslogic.member.MemberGroup(int.Parse(n.Attributes.GetNamedItem("id").Value));
                    count++;
                }
                return(mg);
            }
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
 public static int GetTotalReceiptients(umbraco.cms.businesslogic.member.MemberGroup Group)
 {
     return(int.Parse(Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteScalar(umbraco.GlobalSettings.DbDSN, CommandType.Text, "select count(*) from cmsMember inner join cmsMember2memberGroup on cmsmember.nodeId = cmsMember2MemberGroup.member where memberGroup = @memberGroupId", new SqlParameter("@memberGroupId", Group.Id)).ToString()));
 }
Esempio n. 10
0
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            // Debug - needs logic
            string[] config = _configuration.Split("|".ToCharArray());
            cms.businesslogic.member.MemberGroup mg = new umbraco.cms.businesslogic.member.MemberGroup(int.Parse(config[11]));

            writer.WriteLine("<input type=\"hidden\" name=\"" + this.ClientID + "_doSend\" id=\"" + this.ClientID + "_doSend\" value=\"" + umbraco.helper.Request(this.ClientID + "_doSend") + "\" />");
            writer.WriteLine("<input type=\"hidden\" name=\"" + this.ClientID + "_doTest\" id=\"" + this.ClientID + "_doTest\" value=\"" + umbraco.helper.Request(this.ClientID + "_doTest") + "\" />");

            if (umbraco.helper.Request(this.ClientID + "_doTest") == "" && umbraco.helper.Request(this.ClientID + "_doSend") == "")
            {
                base.Render(writer);
            }
            else
            {
                writer.WriteLine("<div class=\"propertypane\" style=\"margin: 10px; padding: 10px; width: 100%;height: 100%;background-color: light-blue\">");

                if (umbraco.helper.Request(this.ClientID + "_sendButton") != "")
                {
                    // Test mail
                    if (umbraco.helper.Request(this.ClientID + "_doTest") != "")
                    {
                        writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to test...</h3><br/>");
                        mailerLogic.SendTestmail(umbraco.helper.Request(this.ClientID + "_test_rcp"), new cms.businesslogic.property.Property(_data.PropertyId), config[9], config[10], true);
                        writer.WriteLine("Test mail sent to: <b>" + umbraco.helper.Request(this.ClientID + "_test_rcp") + "</b><br/>");
                    }
                    else
                    {
                        writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to all...</h3><br/>");
                        mailerLogic.SendMail(mg, new cms.businesslogic.property.Property(_data.PropertyId), config[9], config[10], true);
                        writer.WriteLine("Sent...<br/>");
                    }
                }
                else
                {
                    if (umbraco.helper.Request(this.ClientID + "_doTest") != "")
                    {
                        writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to test...</h3><br/>");
                        writer.WriteLine("Send test to: <input type=\"text\" name=\"" + this.ClientID + "_test_rcp\" id=\"" + this.ClientID + "_test_rcp\"/>");
                        writer.WriteLine("<input type=\"submit\" name=\"" + this.ClientID + "_sendButton\" class=\"guiInputButton\" value=\"Send\"/>");
                    }
                    else
                    {
                        string strScript = " alert('The MassMailer / UltraSimplerMailer is incompatible with Umbraco 4');		umbPgStep = 1;\n		umbPgIgnoreSteps = true;\n";
                        if (ScriptManager.GetCurrent(Page).IsInAsyncPostBack)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), this.ClientID, strScript, true);
                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), this.ClientID, strScript, true);
                        }

                        writer.WriteLine("			<div id=\"ultraSimpleMailerAnimDiv\" style=\"DISPLAY: none; TEXT-ALIGN: left\"><br /><br /><span style=\"border: #999 1px solid; PADDING: 15px; BACKGROUND: white; WIDTH: 300px; TEXT-ALIGN: center\"><img id=\"ultraSimpleMailerAnim\" height=\"42\" alt=\"Sending mails...\" src=\"images/anims/publishPages.gif\""+
                                         "			width=\"150\" /><br />\n"+
                                         "		<span class=\"guiDialogTiny\" style=\"TEXT-ALIGN: center\">Sending mails...</span>\n"+
                                         "		<br />\n"+
                                         "		<br />\n");



                        // Progressbar
                        pb.ID    = "ultraSimpleMailerUpgradeStatus";
                        pb.Width = 200;
                        pb.RenderControl(writer);
                        writer.WriteLine("		</span><br /><br /></div>\n"+
                                         "<div id=\"ultraSimpleMailerFormDiv\">");
                        writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to all...</h3><br/>");
                        writer.WriteLine("Please confirm that you want to send this message to <b>" + mailerLogic.GetTotalReceiptients(mg).ToString() + "</b> recipients<br/>");
                        writer.WriteLine("<input type=\"checkbox\" name=\"" + this.ClientID + "_sendButton\" id=\"" + this.ClientID + "_sendButton\" value=\"1\"/> Yes<br/>");
                        writer.WriteLine("<input style=\"margin-left: -10px;\" type=\"button\" onClick=\"if (document.getElementById('" + this.ClientID + "_sendButton').checked) {ultraSimpleMailerDoSend('" + this.ClientID + "');} else {alert('Please confirm');}\" value=\"Send\"/>");
                        writer.WriteLine("</div>");
                    }
                }
                writer.WriteLine("</div>");
            }
        }
Esempio n. 11
0
		public static cms.businesslogic.member.MemberGroup[] GetAccessingGroups(int DocumentId) 
		{
			cms.businesslogic.web.Document d = new Document(DocumentId);

			if (!IsProtected(DocumentId, d.Path))
				return null;
			else 
			{
				XmlNode currentNode = getPage(getProtectedPage(d.Path));
				cms.businesslogic.member.MemberGroup[] mg = new umbraco.cms.businesslogic.member.MemberGroup[currentNode.SelectNodes("./group").Count];
				int count = 0;
				foreach (XmlNode n in currentNode.SelectNodes("./group"))
				{
					mg[count] = new cms.businesslogic.member.MemberGroup(int.Parse(n.Attributes.GetNamedItem("id").Value));
					count++;
				}
				return mg;
			}

		}
		protected override void Render(System.Web.UI.HtmlTextWriter writer)
		{

			// Debug - needs logic
			string[] config = _configuration.Split("|".ToCharArray());
			Cms.BusinessLogic.Member.MemberGroup mg = new umbraco.cms.businesslogic.member.MemberGroup(int.Parse(config[2]));

			writer.WriteLine("<input type=\"hidden\" Name=\"" + this.ClientID + "_doSend\" id=\"" + this.ClientID + "_doSend\" value=\"" + umbraco.helper.Request(this.ClientID + "_doSend") + "\" />");
			writer.WriteLine("<input type=\"hidden\" Name=\"" + this.ClientID + "_doTest\" id=\"" + this.ClientID + "_doTest\" value=\"" + umbraco.helper.Request(this.ClientID + "_doTest") + "\" />");

			if (umbraco.helper.Request(this.ClientID + "_doTest") == "" && umbraco.helper.Request(this.ClientID + "_doSend") == "")
				base.Render (writer);
			else 
			{
				writer.WriteLine("<div class=\"propertypane\" style=\"margin: 10px; padding: 10px; width: 100%;height: 100%;background-color: light-blue\">");

				if (umbraco.helper.Request(this.ClientID + "_sendButton") != "") 
				{
					// Test mail
					if (umbraco.helper.Request(this.ClientID + "_doTest") != "") 
					{
						writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to test...</h3><br/>");
						mailerLogic.SendTestmail(umbraco.helper.Request(this.ClientID + "_test_rcp"), new Cms.BusinessLogic.property.Property(_data.PropertyId), config[0], config[1], true);
						writer.WriteLine("Test mail sent to: <b>" + umbraco.helper.Request(this.ClientID + "_test_rcp") + "</b><br/>");
					} 
					else 
					{
						writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to all...</h3><br/>");
						mailerLogic.SendMail(mg, new Cms.BusinessLogic.property.Property(_data.PropertyId), config[0], config[1], true);
						writer.WriteLine("Sent...<br/>");

						}
				} 
				else 
				{
					if (umbraco.helper.Request(this.ClientID + "_doTest") != "")  
					{
						writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to test...</h3><br/>");
						writer.WriteLine("Send test to: <input type=\"text\" Name=\"" + this.ClientID + "_test_rcp\" id=\"" + this.ClientID + "_test_rcp\"/>");
						writer.WriteLine("<input type=\"submit\" Name=\"" + this.ClientID + "_sendButton\" class=\"guiInputButton\" value=\"Send\"/>");
					}
					else 
					{
						writer.WriteLine(
						"			<div id=\"ultraSimpleMailerAnimDiv\" style=\"DISPLAY: none; TEXT-ALIGN: left\"><br /><br /><span style=\"border: #999 1px solid; PADDING: 15px; BACKGROUND: white; WIDTH: 300px; TEXT-ALIGN: center\"><img id=\"ultraSimpleMailerAnim\" height=\"42\" alt=\"Sending mails...\" src=\"images/anims/publishPages.gif\"" + 
						"			width=\"150\" /><br />\n" + 
						"		<script>\n" + 
						"		umbPgStep = 1;\n" + 
						"		umbPgIgnoreSteps = true;\n" + 
						"		</script>\n" + 
						"		<span class=\"guiDialogTiny\" style=\"TEXT-ALIGN: center\">Sending mails...</span>\n" + 
						"		<br />\n" + 
						"		<br />\n");

						// Progressbar
						pb.ID = "ultraSimpleMailerUpgradeStatus";
						pb.Width = 200;
						pb.RenderControl(writer);
						writer.WriteLine("		</span><br /><br /></div>\n" + 
						"<div id=\"ultraSimpleMailerFormDiv\">");
						writer.WriteLine("<h3 style=\"margin-left: -1px;\">Send newsletter to all...</h3><br/>");
						writer.WriteLine("Please confirm that you want to send this message to <b>" + mailerLogic.GetTotalReceiptients(mg).ToString() + "</b> recipients<br/>");
						writer.WriteLine("<input type=\"checkbox\" Name=\"" + this.ClientID + "_sendButton\" id=\"" + this.ClientID + "_sendButton\" value=\"1\"/> Yes<br/>");
						writer.WriteLine("<input style=\"margin-left: -10px;\" type=\"button\" onClick=\"if (document.getElementById('" + this.ClientID + "_sendButton').checked) {ultraSimpleMailerDoSend('" + this.ClientID + "');} else {alert('Please confirm');}\" value=\"Send\"/>");
						writer.WriteLine("</div>");
					}

				}
				writer.WriteLine("</div>");
			}

		}
Esempio n. 13
0
        public static bool IsHq(int id)
        {
            Member m = new Member(id);

            return(m.Groups.ContainsKey(MemberGroup.GetByName("HQ").Id));
        }
Esempio n. 14
0
 public static int GetTotalReceiptients(umbraco.cms.businesslogic.member.MemberGroup Group)
 {
     return(SqlHelper.ExecuteScalar <int>("select count(*) from cmsMember inner join cmsMember2memberGroup on cmsmember.nodeId = cmsMember2MemberGroup.member where memberGroup = @memberGroupId", SqlHelper.CreateParameter("@memberGroupId", Group.Id)));
 }