예제 #1
0
파일: Search.cs 프로젝트: pcstx/OA
        /// <summary>
        /// All applications use the same SearchBarrel. This method provides default access to it.
        /// </summary>
        public void InsertIntoSearchBarrel(Hashtable words, Post post, int settingsID, int totalBodyWords)
        {
            foreach(int key in words.Keys)
            {
                Word w = words[key] as Word;
                w.Weight = CalculateWordRank(w,post,totalBodyWords);
            }

            CommonDataProvider dp = CommonDataProvider.Instance();
            dp.InsertIntoSearchBarrel(words, post, settingsID);
        }
예제 #2
0
파일: Emails.cs 프로젝트: pcstx/OA
        // *********************************************************************
        //  PostApproved
        //
        /// <summary>
        /// This method sends an email to the user whose post has just been approved.
        /// </summary>
        /// <param name="PostID">Specifies the ID of the Post that was just approved.</param>
        /// 
        // ********************************************************************/
        public static void PostApproved(Post post)
        {
            if (post == null)
                return;

            // Make sure we can send the email
            //
            if (!CanSend(post.User))
                return;

            EnqueuEmail(CreatePost(post, EmailType.MessageApproved, post.User, null, null, true));
        }
예제 #3
0
파일: PostSet.cs 프로젝트: pcstx/OA
 public bool Organize()
 {
     if(replies == null)
     {
         replies = new ArrayList();
         foreach(Post p in posts)
         {
             if(p.PostLevel != 1)
             {
                 replies.Add(p);
             }
             else
             {
                 post = p;
             }
         }
     }
     //No need to use the organized posts if the main
     //partent can not be found
     return ThreadStarter != null;
 }
예제 #4
0
파일: Emails.cs 프로젝트: pcstx/OA
        /// <summary>
        /// Based on the postID, this method will retrieve subscribers to the post and section.
        /// It will then create a unique list between them and call the method supplied vai the 
        /// EnquePostEmails delegate
        /// </summary>
        /// <param name="post">Post to send</param>
        /// <param name="epm">Method used to Enque the email</param>
        protected static void SectionTracking(Post post, EnquePostEmails epm, FormatList formats)
        {
            if (post == null)
                return;

            Hashtable threadSubscribers = GetEmailsTrackingThread(post.PostID);
            Hashtable sectionSubscribers = GetEmailsTrackingSectionByPostID(post.PostID);

            foreach(string email in threadSubscribers.Keys)
            {
                User sectionUser = sectionSubscribers[email] as User;
                if(sectionUser != null)
                    sectionSubscribers.Remove(email);
            }

            foreach(string email in sectionSubscribers.Keys)
            {
                threadSubscribers.Add(email,sectionSubscribers[email] as User);
            }

            sectionSubscribers.Clear();

            foreach (string email in threadSubscribers.Keys)
            {
                User subscriber = threadSubscribers[email] as User;
                // Make sure we don't send an email to the user that posted the message
                //
                if (subscriber.Email != post.User.Email)
                {
                    EnqueuEmail(epm(post,subscriber,formats));
                }
            }
        }
예제 #5
0
파일: CSEvents.cs 프로젝트: pcstx/OA
 /// <summary>
 /// Raises all RatePost events. These events are raised after a post is rated.
 /// </summary>
 public static void RatePost(Post post, ApplicationType appType)
 {
     CSApplication.Instance().ExecuteRatePostEvents(post,appType);
 }
예제 #6
0
 public abstract void AddPostAttachment(Post post, PostAttachment attachment);
예제 #7
0
 public static void PopulateIndexPostFromIDataReader(IDataReader dr, Post post)
 {
     // Populate Post
     //
     post.PostID             = Convert.ToInt32(dr["PostID"]);
     post.ParentID           = Convert.ToInt32(dr["ParentID"]);
     post.FormattedBody      = Convert.ToString(dr["FormattedBody"]).Trim();
     post.Body               = Convert.ToString(dr["Body"]).Trim();
     post.SectionID            = Convert.ToInt32(dr["SectionID"]);
     post.PostDate           = Convert.ToDateTime(dr["PostDate"]);
     post.PostLevel          = Convert.ToInt32(dr["PostLevel"]);
     post.SortOrder          = Convert.ToInt32(dr["SortOrder"]);
     post.Subject            = Convert.ToString(dr["Subject"]).Trim();
     post.ThreadDate         = Convert.ToDateTime(dr["ThreadDate"]);
     post.ThreadID           = Convert.ToInt32(dr["ThreadID"]);
     post.Replies            = Convert.ToInt32(dr["Replies"]);
     post.Username           = Convert.ToString(dr["Username"]).Trim();
     post.IsApproved         = Convert.ToBoolean(dr["IsApproved"]);
     post.IsLocked           = Convert.ToBoolean(dr["IsLocked"]);
     post.Views              = Convert.ToInt32(dr["TotalViews"]);
     post.HasRead            = Convert.ToBoolean(dr["HasRead"]);
     post.UserHostAddress    = (string) dr["IPAddress"];
     post.PostType           = (PostType) dr["PostType"];
     post.EmoticonID			= (int) dr["EmoticonID"];
     post.PostConfiguration  =   (int) dr["PostConfiguration"];
 }
예제 #8
0
파일: CSApplication.cs 프로젝트: pcstx/OA
 internal void ExecuteRatePostEvents(Post post, ApplicationType appType)
 {
     ExecutePostEvent(EventRatePost,post,ObjectState.None,appType);
 }
예제 #9
0
파일: Emails.cs 프로젝트: pcstx/OA
        public static void UserToUser(User fromUser, User toUser, Post post)
        {
            MailMessage email;

            email = GenericEmail(EmailType.SendEmail, toUser, null, null, true, toUser.EnableHtmlEmail);
            email.From = GenericEmailFormatter(email.From, fromUser, post);
            email.Subject = GenericEmailFormatter(email.Subject, toUser, post);
            email.Body = GenericEmailFormatter(email.Body, toUser, post);

            Emails.EnqueuEmail(email);
        }
예제 #10
0
파일: Emails.cs 프로젝트: pcstx/OA
        public static void UsersInRole(Guid roleID, Post post)
        {
            // Get Role
            Role role = Roles.GetRole(roleID);

            UserSet countSet;
            UserSet emailSet;

            // special case for Forums-Everyone (roleID == 0)
            if (roleID == Guid.Empty) {
                // find total users
                countSet = Users.GetUsers(0,1,true,false);

                // get all users
                emailSet = Users.GetUsers(0,countSet.TotalRecords,true,false);

            } else {
                // find total users in role
                countSet = Roles.UsersInRole(0,1,SortUsersBy.Username,SortOrder.Ascending,roleID);

                // get all users in role
                emailSet = Roles.UsersInRole(0,countSet.TotalRecords,SortUsersBy.Username,SortOrder.Ascending,roleID);
            }

            foreach (User user in emailSet.Users) {
                MailMessage email;

                email = GenericEmail(EmailType.RoleEmail, user, null, null, true, user.EnableHtmlEmail);
                email.From = GenericEmailFormatter(email.From, user, post);
                email.Subject = GenericEmailFormatter(email.Subject, user, post);
                email.Body = GenericEmailFormatter(email.Body, user, post, user.EnableHtmlEmail, false).Replace("[RoleName]",role.Name);

                Emails.EnqueuEmail(email);
            }
        }
예제 #11
0
파일: Emails.cs 프로젝트: pcstx/OA
 public static void ThreadJoined(Post parent, Post child)
 {
 }
예제 #12
0
파일: Emails.cs 프로젝트: pcstx/OA
        public static void PrivateMessageNotifications(Post post, ArrayList users)
        {
            foreach (User user in users) {

                if (post.User.UserID != user.UserID)
                    EnqueuEmail( CreatePost(post, EmailType.PrivateMessageNotification, user, null, null, false));
            }
        }
예제 #13
0
파일: Emails.cs 프로젝트: pcstx/OA
        // *********************************************************************
        //  PostRemoved
        //
        /// <summary>
        /// Email sent when a post is removed.
        /// </summary>
        // ********************************************************************/
        public static void PostRemoved(Post post, User moderatedBy, string reason)
        {
            if (post == null)
                return;

            // Make sure we can send the email
            //
            if (!CanSend(post.User))
                return;

            MailMessage email = CreatePost(post, EmailType.MessageDeleted, post.User, null, null, true);

            email.Body = email.Body.Replace("[DeleteReasons]", reason);
            email.Body = email.Body.Replace("[DeletedByID]", moderatedBy.UserID.ToString());
            email.Body = email.Body.Replace("[Moderator]", moderatedBy.Username);

            EnqueuEmail(email);
        }
예제 #14
0
파일: Search.cs 프로젝트: pcstx/OA
 protected abstract double CalculateWordRank(Word word, Post post, int totalBodyWords);
예제 #15
0
파일: PollSummary.cs 프로젝트: pcstx/OA
 // *********************************************************************
 //  PollSummary
 //
 /// <summary>
 /// Constructor
 /// </summary>
 // ***********************************************************************/
 public PollSummary(Post post)
 {
     this.post = post;
     GetPoll();
 }
예제 #16
0
파일: Emails.cs 프로젝트: pcstx/OA
 protected static MailMessage CreatePost(Post post, string emailType)
 {
     return CreatePost(post, emailType, null, null, null, true);
 }
예제 #17
0
파일: CSApplication.cs 프로젝트: pcstx/OA
 internal void ExecutePrePostUpdateEvents(Post post, ObjectState state, ApplicationType appType)
 {
     ExecutePostEvent(EventPrePostUpdate,post,state,appType);
 }
예제 #18
0
파일: Emails.cs 프로젝트: pcstx/OA
 protected static MailMessage CreatePost(Post post, string emailType, User userTo, string[] cc, string[] bcc, bool sendToUser)
 {
     return CreatePost(post, emailType, userTo, cc, bcc, true, false);
 }
예제 #19
0
파일: CSApplication.cs 프로젝트: pcstx/OA
 //        internal void ExecutePrePostRender(Post post, ApplicationType appType)
 //        {
 //            ExecutePostEvent(EventPreRenderPost,post,ObjectState.None,appType);
 //        }
 protected void ExecutePostEvent(object EventKey, Post post,ObjectState state, ApplicationType appType)
 {
     CSPostEventHandler handler = Events[EventKey] as CSPostEventHandler;
     if (handler != null)
     {
         handler(post, new CSEventArgs(state,appType));
     }
 }
예제 #20
0
파일: Emails.cs 프로젝트: pcstx/OA
        protected static MailMessage CreatePost(Post post, string emailType, User userTo, string[] cc, string[] bcc, bool sendToUser, bool html)
        {
            MailMessage email;

            // Get the email template we're going to use
            //
            email = GenericEmail(emailType, userTo, cc, bcc, sendToUser, html);

            if (userTo != null)
                email.To = userTo.Email;

            email.From = GenericEmailFormatter(email.From, null, post);
            email.Body = GenericEmailFormatter(email.Body, null, post, html);
            email.Subject = GenericEmailFormatter(email.Subject, null, post);

            return email;
        }
예제 #21
0
        public static void PopulatePostFromIDataReader(IDataReader dr, Post post)
        {
            // Populate Post
            //
            post.PostID             = Convert.ToInt32(dr["PostID"]);
            post.ParentID           = Convert.ToInt32(dr["ParentID"]);
            post.FormattedBody      = Convert.ToString(dr["FormattedBody"]).Trim();
            post.Body               = Convert.ToString(dr["Body"]).Trim();
            post.SectionID            = Convert.ToInt32(dr["SectionID"]);
            post.PostDate           = Convert.ToDateTime(dr["PostDate"]);
            post.PostLevel          = Convert.ToInt32(dr["PostLevel"]);
            post.SortOrder          = Convert.ToInt32(dr["SortOrder"]);
            post.Subject            = Convert.ToString(dr["Subject"]).Trim();
            post.ThreadDate         = Convert.ToDateTime(dr["ThreadDate"]);
            post.ThreadID           = Convert.ToInt32(dr["ThreadID"]);
            post.Replies            = Convert.ToInt32(dr["Replies"]);

            // �޸�Ϊ��ʾ�dz�
            post.Username           = Convert.ToString(dr["Nickname"]).Trim();
            if (post.Username == "")
                post.Username		= Convert.ToString(dr["Username"]).Trim();

            post.IsApproved         = Convert.ToBoolean(dr["IsApproved"]);
            post.AttachmentFilename = dr["AttachmentFilename"] as string;
            post.IsLocked           = Convert.ToBoolean(dr["IsLocked"]);
            post.Views              = Convert.ToInt32(dr["TotalViews"]);
            post.HasRead            = Convert.ToBoolean(dr["HasRead"]);
            post.UserHostAddress    = (string) dr["IPAddress"];
            post.PostType           = (PostType) dr["PostType"];
            post.EmoticonID			= (int) dr["EmoticonID"];
            post.PostConfiguration  = (int) dr["PostConfiguration"];

            //post.DeserializeExtendedAttributes(dr["StringNameValues"] as byte[]);
            SerializerData data = PopulateSerializerDataIDataReader(dr, SerializationType.Post);
            post.SetSerializerData(data);

            try {
                post.IsTracked          = (bool) dr["UserIsTrackingThread"];
            } catch {}

            try {
                post.EditNotes = dr["EditNotes"] as string;
            } catch {}

            try {
                post.ThreadIDNext = (int) dr["NextThreadID"];
                post.ThreadIDPrev = (int) dr["PrevThreadID"];
            } catch {}

            // Populate User
            //
            post.User = cs_PopulateUserFromIDataReader(dr);
        }
예제 #22
0
파일: Emails.cs 프로젝트: pcstx/OA
 protected static string GenericEmailFormatter(string stringToFormat, User user, Post post, bool html)
 {
     return GenericEmailFormatter (stringToFormat, user, post, html, false);
 }
예제 #23
0
 public abstract void InsertIntoSearchBarrel(Hashtable words, Post post, int settingsID);
예제 #24
0
파일: Emails.cs 프로젝트: pcstx/OA
        protected static string GenericEmailFormatter(string stringToFormat, User user, Post post, bool html, bool truncateMessage )
        {
            //            string timeSend = string.Format(ResourceManager.GetString("Utility_CurrentTime_formatGMT"), DateTime.Now.ToString(ResourceManager.GetString("Utility_CurrentTime_dateFormat")));
            DateTime time = DateTime.Now;

            // set the timesent and sitename
            stringToFormat = Regex.Replace(stringToFormat, "\\[timesent\\]", time.ToString(ResourceManager.GetString("Utility_CurrentTime_dateFormat")) + " " + string.Format( ResourceManager.GetString("Utility_CurrentTime_formatGMT"), CSContext.Current.SiteSettings.TimezoneOffset.ToString() ), RegexOptions.IgnoreCase | RegexOptions.Compiled);
            stringToFormat = Regex.Replace(stringToFormat, "\\[moderatorl\\]", Globals.GetSiteUrls().Moderate, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            stringToFormat = Regex.Replace(stringToFormat, "\\[sitename\\]", CSContext.Current.SiteSettings.SiteName.Trim(), RegexOptions.IgnoreCase | RegexOptions.Compiled);
            stringToFormat = Regex.Replace(stringToFormat, "\\[websiteurl\\]", Globals.GetSiteUrls().Home, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            stringToFormat = Regex.Replace(stringToFormat, "\\[adminemail\\]", (CSContext.Current.SiteSettings.AdminEmailAddress.Trim() != "" ) ? CSContext.Current.SiteSettings.AdminEmailAddress.Trim() : "*****@*****.**", RegexOptions.IgnoreCase | RegexOptions.Compiled);

            if(CSContext.Current.Context != null)
            {
                stringToFormat = Regex.Replace(stringToFormat, "\\[loginurl\\]", Globals.HostPath(CSContext.Current.Context.Request.Url) + Globals.GetSiteUrls().LoginReturnHome, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[passwordchange\\]", Globals.HostPath(CSContext.Current.Context.Request.Url) + Globals.GetSiteUrls().UserChangePassword, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            }
            else
            {
                stringToFormat = Regex.Replace(stringToFormat, "\\[loginurl\\]", Globals.HostPath(new Uri(CSContext.Current.RawUrl)) + Globals.GetSiteUrls().LoginReturnHome, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[passwordchange\\]", Globals.HostPath(new Uri(CSContext.Current.RawUrl)) + Globals.GetSiteUrls().UserChangePassword, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            }

            // return a generic email address if it isn't set.
            //
            string adminEmailAddress = (CSContext.Current.SiteSettings.AdminEmailAddress.Trim() != "" ) ? CSContext.Current.SiteSettings.AdminEmailAddress.Trim() : "*****@*****.**";
            string siteName = CSContext.Current.SiteSettings.SiteName.Trim();
            stringToFormat = Regex.Replace(stringToFormat, "\\[adminemailfrom\\]", string.Format( ResourceManager.GetString("AutomatedEmail").Trim(), siteName, adminEmailAddress), RegexOptions.IgnoreCase | RegexOptions.Compiled);

            // Specific to a user
            //
            if (user != null) {
                stringToFormat = Regex.Replace(stringToFormat, "\\[username\\]", user.Username.Trim(), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[email\\]", user.Email.Trim(), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[publicemail\\]", user.Profile.PublicEmail.Trim(), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[datecreated\\]", user.GetTimezone(user.DateCreated).ToString(user.Profile.DateFormat), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[lastlogin\\]", user.GetTimezone(user.LastLogin).ToString(user.Profile.DateFormat), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[profileurl\\]", Globals.GetSiteUrls().UserEditProfile, RegexOptions.IgnoreCase | RegexOptions.Compiled);

                if (user.Password != null)
                    stringToFormat = Regex.Replace(stringToFormat, "\\[password\\]", user.Password.Trim(), RegexOptions.IgnoreCase | RegexOptions.Compiled);

            }

            // make urls clickable, don't do it if we have a post,
            // because we're going to do it again before adding the post contents
            if (html && post == null) stringToFormat = Regex.Replace(stringToFormat,@"(http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?","<a href=\"$0\">$0</a>",RegexOptions.IgnoreCase | RegexOptions.Compiled);

            if (post != null) {
                stringToFormat = Regex.Replace(stringToFormat, "\\[postedby\\]", post.Username.Trim(), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[subject\\]", post.Subject.Trim(), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[postdate\\]", post.User.GetTimezone(post.PostDate).ToString(), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[replyurl\\]", Globals.GetSiteUrls().Post(post.PostID), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                stringToFormat = Regex.Replace(stringToFormat, "\\[moderatePostUrl\\]", Globals.GetSiteUrls().Post(post.PostID), RegexOptions.IgnoreCase | RegexOptions.Compiled);

                if(CSContext.Current.Context != null)
                    stringToFormat = Regex.Replace(stringToFormat, "\\[posturl\\]", Globals.HostPath(CSContext.Current.Context.Request.Url) + Globals.GetSiteUrls().Post(post.PostID), RegexOptions.IgnoreCase | RegexOptions.Compiled);
                else
                    stringToFormat = Regex.Replace(stringToFormat, "\\[posturl\\]", Globals.HostPath(new Uri(CSContext.Current.RawUrl)) + Globals.GetSiteUrls().Post(post.PostID), RegexOptions.IgnoreCase | RegexOptions.Compiled);

                if(post.Section != null)
                    stringToFormat = Regex.Replace(stringToFormat, "\\[forumname\\]", post.Section.Name.Trim(), RegexOptions.IgnoreCase | RegexOptions.Compiled);

                //stringToFormat = Regex.Replace(stringToFormat, "\\[forumUrl\\]", Globals.HostPath(CSContext.Current.Context.Request.Url) + ForumUrls.Instance().Forum(post.SectionID), RegexOptions.IgnoreCase | RegexOptions.Compiled);

                // make urls clickable before adding post HTML
                if (html) stringToFormat = Regex.Replace(stringToFormat,@"(http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?^=%&:\$/~\+#]*[\w\-\@?^=%&/~\+#])?","<a href=\"$0\">$0</a>",RegexOptions.IgnoreCase | RegexOptions.Compiled);

                // strip html from post if necessary
                string postbody = post.FormattedBody;

                // if the user doesn't want HTML and the post is HTML, then strip it
                if (!html && post.PostType == PostType.HTML)
                    postbody = Emails.FormatHtmlAsPlainText(postbody);

                    // if the user wants HTML and the post is PlainText, then add HTML to it
                else if (html &&  post.PostType == PostType.BBCode)
                    postbody = Emails.FormatPlainTextAsHtml(postbody);

                // Finally, trim this post so the user doesn't get a huge email
                //
                postbody.Trim();

                if (truncateMessage) {
                    // if we throw an error, the post was too short to cut anyhow
                    //
                    try {
                        postbody = Formatter.CheckStringLength(postbody, 300);
                    }
                    catch {}
                }

                stringToFormat = Regex.Replace(stringToFormat, "\\[postbody\\]", postbody, RegexOptions.IgnoreCase | RegexOptions.Compiled);
            }

            return stringToFormat;
        }
예제 #25
0
파일: CSEvents.cs 프로젝트: pcstx/OA
 /// <summary>
 /// Raises all BeforePost events. These events are raised before a post is commited to the datastore
 /// </summary>
 public static void BeforePost(Post post, ObjectState state, ApplicationType appType)
 {
     CSApplication.Instance().ExecutePrePostUpdateEvents(post,state,appType);
 }
예제 #26
0
파일: Formatter.cs 프로젝트: pcstx/OA
        public static string PostIPAddress(Post post)
        {
            if (post.UserHostAddress == "000.000.000.000")
                return string.Format(ResourceManager.GetString("PostFlatView_IPAddress"), ResourceManager.GetString("NotLogged"));

            if (CSContext.Current.SiteSettings.DisplayPostIP) {
                return string.Format(ResourceManager.GetString("PostFlatView_IPAddress"), post.UserHostAddress);
            } else if ((CSContext.Current.SiteSettings.DisplayPostIPAdminsModeratorsOnly) && ((CSContext.Current.User.IsForumAdministrator) || (CSContext.Current.User.IsModerator)) ){
                return string.Format(ResourceManager.GetString("PostFlatView_IPAddress"), post.UserHostAddress);
            } else {
                return string.Format(ResourceManager.GetString("PostFlatView_IPAddress"), ResourceManager.GetString("Logged"));
            }
        }