Ejemplo n.º 1
0
        public List<SubscriptionInfo> Subscription_GetSubscribers(int PortalId, int ForumId, int TopicId, SubscriptionTypes Mode, int AuthorId, string CanSubscribe)
        {
            SubscriptionInfo si;
            var sl = new List<SubscriptionInfo>();
            IDataReader dr = DataProvider.Instance().Subscriptions_GetSubscribers(PortalId, ForumId, TopicId, (int)Mode);
            while (dr.Read())
            {
                if (AuthorId != Convert.ToInt32(dr["UserId"]))
                {
                    si = new SubscriptionInfo
                             {
                                 DisplayName = dr["DisplayName"].ToString(),
                                 Email = dr["Email"].ToString(),
                                 FirstName = dr["FirstName"].ToString(),
                                 LastName = dr["LastName"].ToString(),
                                 UserId = Convert.ToInt32(dr["UserId"]),
                                 Username = dr["Username"].ToString()
                             };

                    if (! (sl.Contains(si)))
                    {
                        if (Permissions.HasPerm(CanSubscribe, si.UserId, PortalId))
                        {
                            sl.Add(si);
                        }
                    }
                }
            }
            dr.Close();
            return sl;
        }
Ejemplo n.º 2
0
		public static void SendEmail(int templateId, int portalId, int moduleId, int tabId, int forumId, int topicId, int replyId, string comments, Author author)
		{
			var portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
			var mainSettings = DataCache.MainSettings(moduleId);
		    var sTemplate = string.Empty;
			var tc = new TemplateController();
			var ti = tc.Template_Get(templateId, portalId, moduleId);
			var subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, portalId, moduleId, tabId, forumId, topicId, replyId, string.Empty, author.AuthorId, portalSettings.TimeZoneOffset);
			var bodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, portalId, moduleId, tabId, forumId, topicId, replyId, string.Empty, author.AuthorId, portalSettings.TimeZoneOffset);
			var bodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, portalId, moduleId, tabId, forumId, topicId, replyId, string.Empty, author.AuthorId, portalSettings.TimeZoneOffset);
			bodyText = bodyText.Replace("[REASON]", comments);
			bodyHTML = bodyHTML.Replace("[REASON]", comments);
		    var fc = new ForumController();
			var fi = fc.Forums_Get(forumId, -1, false, true);
			var sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : portalSettings.Email;
			
            //Send now
			
            var oEmail = new Email();
			var subs = new List<SubscriptionInfo>();
			var si = new SubscriptionInfo
			             {
			                 DisplayName = author.DisplayName,
			                 Email = author.Email,
			                 FirstName = author.FirstName,
			                 LastName = author.LastName,
			                 UserId = author.AuthorId,
			                 Username = author.Username
			             };

		    subs.Add(si);

			oEmail.UseQueue = mainSettings.MailQueue;
			oEmail.Recipients = subs;
			oEmail.Subject = subject;
			oEmail.From = sFrom;
			oEmail.BodyText = bodyText;
			oEmail.BodyHTML = bodyHTML;

			new Thread(oEmail.Send).Start();
		}
Ejemplo n.º 3
0
		public static void SendEmailToModerators(int templateId, int portalId, int forumId, int topicId, int replyId, int moduleID, int tabID, string comments, UserInfo user)
		{
			var portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
			var mainSettings = DataCache.MainSettings(moduleID);
			var fc = new ForumController();
			var fi = fc.Forums_Get(forumId, -1, false, true);
			if (fi == null)
				return;

			var subs = new List<SubscriptionInfo>();
			var rc = new Security.Roles.RoleController();
			var uc = new Entities.Users.UserController();
		    var modApprove = fi.Security.ModApprove;
			var modRoles = modApprove.Split('|')[0].Split(';');
		    foreach (var r in modRoles)
		    {
		        if (string.IsNullOrEmpty(r)) continue;
		        var rid = Convert.ToInt32(r);
		        var rName = rc.GetRole(rid, portalId).RoleName;
		        foreach (UserRoleInfo usr in rc.GetUserRolesByRoleName(portalId, rName))
		        {
		            var ui = uc.GetUser(portalId, usr.UserID);
		            var si = new SubscriptionInfo
		                         {
		                             UserId = ui.UserID,
		                             DisplayName = ui.DisplayName,
		                             Email = ui.Email,
		                             FirstName = ui.FirstName,
		                             LastName = ui.LastName
		                         };
		            if (! (subs.Contains(si)))
		            {
		                subs.Add(si);
		            }
		        }
		    }

		    if (subs.Count <= 0)
				return;

		    var sTemplate = string.Empty;
			var tc = new TemplateController();
			var ti = tc.Template_Get(templateId, portalId, moduleID);
			var subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, portalSettings.TimeZoneOffset);
			var bodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, comments, user, -1, portalSettings.TimeZoneOffset);
			var bodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, comments, user, -1, portalSettings.TimeZoneOffset);
		    var sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : portalSettings.Email;

			var oEmail = new Email
			                 {
			                     Recipients = subs,
			                     Subject = subject,
			                     From = sFrom,
			                     BodyText = bodyText,
			                     BodyHTML = bodyHTML,
                                 UseQueue = mainSettings.MailQueue
			                 };


			new Thread(oEmail.Send).Start();
		}
Ejemplo n.º 4
0
        public void SendEmailToModerators(int TemplateId, int PortalId, int ForumId, int TopicId, int ReplyId, int ModuleID, int TabID, string Comments, DotNetNuke.Entities.Users.UserInfo User)
        {
            var _portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
            SettingsInfo MainSettings = DataCache.MainSettings(ModuleID);
            var fc = new ForumController();
            Forum fi = fc.Forums_Get(ForumId, -1, false, true);
            if (fi == null)
            {
                return;
            }
            var subs = new List<SubscriptionInfo>();
            var rc = new Security.Roles.RoleController();
            var uc = new Entities.Users.UserController();
            SubscriptionInfo si;
            string modApprove = fi.Security.ModApprove;
            string[] modRoles = modApprove.Split('|')[0].Split(';');
            if (modRoles != null)
            {
                foreach (string r in modRoles)
                {
                    if (! (string.IsNullOrEmpty(r)))
                    {
                        int rid = Convert.ToInt32(r);
                        string rName = rc.GetRole(rid, PortalId).RoleName;
                        foreach (Entities.Users.UserRoleInfo usr in rc.GetUserRolesByRoleName(PortalId, rName))
                        {
                            var ui = uc.GetUser(PortalId, usr.UserID);
                            si = new SubscriptionInfo
                                     {
                                         UserId = ui.UserID,
                                         DisplayName = ui.DisplayName,
                                         Email = ui.Email,
                                         FirstName = ui.FirstName,
                                         LastName = ui.LastName
                                     };
                            if (! (subs.Contains(si)))
                            {
                                subs.Add(si);
                            }
                        }
                    }
                }
            }

            if (subs.Count <= 0)
            {
                return;
            }
            string Subject;
            string BodyText;
            string BodyHTML;
            string sTemplate = string.Empty;
            var tc = new TemplateController();
            TemplateInfo ti = tc.Template_Get(TemplateId, PortalId, ModuleID);
            Subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, PortalId, ModuleID, TabID, ForumId, TopicId, ReplyId, _portalSettings.TimeZoneOffset);
            BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleID, TabID, ForumId, TopicId, ReplyId, Comments, User, -1, _portalSettings.TimeZoneOffset);
            BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleID, TabID, ForumId, TopicId, ReplyId, Comments, User, -1, _portalSettings.TimeZoneOffset);
            string sFrom;

            sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : _portalSettings.Email;

            var oEmail = new Email
                             {
                                 Recipients = subs,
                                 Subject = Subject,
                                 From = sFrom,
                                 BodyText = BodyText,
                                 BodyHTML = BodyHTML,
                                 SmtpServer = Convert.ToString(_portalSettings.HostSettings["SMTPServer"]),
                                 SmtpUserName = Convert.ToString(_portalSettings.HostSettings["SMTPUsername"]),
                                 SmtpPassword = Convert.ToString(_portalSettings.HostSettings["SMTPPassword"]),
                                 SmtpAuthentication = Convert.ToString(_portalSettings.HostSettings["SMTPAuthentication"])
                             };

            //#if SKU_ENTERPRISE
            oEmail.UseQueue = MainSettings.MailQueue;
            //#endif
            var objThread = new System.Threading.Thread(oEmail.Send);
            objThread.Start();
        }
Ejemplo n.º 5
0
 public void SendEmail(int TemplateId, int PortalId, int ModuleId, int TabId, int ForumId, int TopicId, int ReplyId, string Comments, Author author)
 {
     var _portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
     SettingsInfo MainSettings = DataCache.MainSettings(ModuleId);
     string Subject;
     string BodyText;
     string BodyHTML;
     string sTemplate = string.Empty;
     var tc = new TemplateController();
     TemplateInfo ti = tc.Template_Get(TemplateId, PortalId, ModuleId);
     Subject = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, author.AuthorId, _portalSettings.TimeZoneOffset);
     BodyText = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, author.AuthorId, _portalSettings.TimeZoneOffset);
     BodyHTML = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, PortalId, ModuleId, TabId, ForumId, TopicId, ReplyId, string.Empty, author.AuthorId, _portalSettings.TimeZoneOffset);
     BodyText = BodyText.Replace("[REASON]", Comments);
     BodyHTML = BodyHTML.Replace("[REASON]", Comments);
     string sFrom;
     var fc = new ForumController();
     Forum fi = fc.Forums_Get(ForumId, -1, false, true);
     sFrom = fi.EmailAddress != string.Empty ? fi.EmailAddress : _portalSettings.Email;
     //Send now
     var oEmail = new Email();
     var subs = new List<SubscriptionInfo>();
     var si = new SubscriptionInfo
                  {
                      DisplayName = author.DisplayName,
                      Email = author.Email,
                      FirstName = author.FirstName,
                      LastName = author.LastName,
                      UserId = author.AuthorId,
                      Username = author.Username
                  };
     subs.Add(si);
     oEmail.UseQueue = MainSettings.MailQueue;
     oEmail.Recipients = subs;
     oEmail.Subject = Subject;
     oEmail.From = sFrom;
     oEmail.BodyText = BodyText;
     oEmail.BodyHTML = BodyHTML;
     oEmail.SmtpServer = Convert.ToString(_portalSettings.HostSettings["SMTPServer"]);
     oEmail.SmtpUserName = Convert.ToString(_portalSettings.HostSettings["SMTPUsername"]);
     oEmail.SmtpPassword = Convert.ToString(_portalSettings.HostSettings["SMTPPassword"]);
     oEmail.SmtpAuthentication = Convert.ToString(_portalSettings.HostSettings["SMTPAuthentication"]);
     var objThread = new System.Threading.Thread(oEmail.Send);
     objThread.Start();
 }