Exemple #1
0
        public ActionResult CreatePost(vmForumTopicView model)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            // ************************ VALIDATION **********************************************
            // Check posting flood control
            if (!db_Forum.PassedPostFloodTest(UserIDX))
            {
                TempData["Error"] = "Please wait at least 30 seconds between posts";
                return(RedirectToAction("ShowTopic", new { slug = model.Topic.Slug }));
            }

            // Log user out if they are LockedOut but still authenticated
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(UserIDX);

            if (u != null && u.LOCKOUT_ENABLED)
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("Index", "Home"));
            }

            //required fields
            if (model.NewPostContent == null)
            {
                TempData["Error"] = "You must supply post content.";
                return(RedirectToAction("ShowTopic", new { slug = model.Topic.Slug }));
            }
            // ************************ END VALIDATION **********************************************


            Guid?_postID = db_Forum.InsertUpdatePost(null, model.NewPostContent, null, null, false, false, false, null, null, model.Topic.Id, UserIDX, false);

            if (_postID != null)
            {
                //set topic last post date
                db_Forum.UpdateTopic_SetLastPostDate(model.Topic.Id, null);

                // Success send any notifications
                NotifyTopics(model.Topic.Id, UserIDX, "Post");

                // 4. Update the users points score for posting
                db_Forum.InsertUpdateMembershipUserPoints(null, 1, System.DateTime.UtcNow, 0, _postID, null, UserIDX);

                // Update Azure search
                AzureSearch.PopulateSearchIndexForumPost(_postID);
            }


            // Return view
            return(RedirectToAction("ShowTopic", "Forum", new { slug = model.Topic.Slug }));
        }
Exemple #2
0
        public ActionResult ShowTopic(string slug, int?p, string order, Guid?id)
        {
            // Set initial stuff
            //var pageIndex = p ?? 1;
            int UserIDX = db_Accounts.GetUserIDX();

            // Get the topic
            var _topic = new Topic();

            if (slug != null)
            {
                _topic = db_Forum.GetTopic_fromSlug(slug);
            }
            else if (id != null)
            {
                _topic = db_Forum.GetTopic_ByID(id.ConvertOrDefault <Guid>());
            }


            if (_topic != null)
            {
                //add view count (only if not the person who created topic) and only if not a bot
                if (_topic.MembershipUser_Id != UserIDX && !BotUtils.UserIsBot())
                {
                    db_Forum.TopicAddView(_topic.Id);
                    _topic.Views = _topic.Views + 1;
                }

                var model = new vmForumTopicView();
                model.Topic              = _topic;
                model.TopicTags          = db_Forum.GetTopicTags_ByAttributeSelected(_topic.Id, "Topic Tag");
                model.StarterPost        = db_Forum.GetPost_StarterForTopic(_topic.Id, UserIDX);
                model.Posts              = db_Forum.GetPost_NonStarterForTopic(_topic.Id, UserIDX, order);
                model.IsSubscribed       = db_Forum.NotificationIsUserSubscribed(_topic.Id, UserIDX);
                model.LastPostDatePretty = db_Forum.GetTopic_LastPostPrettyDate(_topic.Id);
                //model.DisablePosting = false;
                model.NewPostContent = "";

                return(View(model));
            }
            else
            {
                TempData["Error"] = "No topic found";
                return(RedirectToAction("Index", "Forum"));
            }
        }
Exemple #3
0
        public ActionResult CreatePost(vmForumTopicView model)
        {
            int UserIDX = db_Accounts.GetUserIDX();

            // ************************ VALIDATION **********************************************
            // Check posting flood control
            if (!db_Forum.PassedPostFloodTest(UserIDX))
            {
                TempData["Error"] = "Please wait at least 30 seconds between posts";
                return(RedirectToAction("ShowTopic", new { slug = model.Topic.Slug }));
            }

            // Log user out if they are LockedOut but still authenticated
            T_OE_USERS u = db_Accounts.GetT_OE_USERSByIDX(UserIDX);

            if (u != null && u.LOCKOUT_ENABLED)
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("Index", "Home"));
            }

            //required fields
            if (model.NewPostContent == null)
            {
                TempData["Error"] = "You must supply post content.";
                return(RedirectToAction("ShowTopic", new { slug = model.Topic.Slug }));
            }
            // ************************ END VALIDATION **********************************************


            Guid?_postID = db_Forum.InsertUpdatePost(null, model.NewPostContent, null, null, false, false, false, null, null, model.Topic.Id, UserIDX, false);

            if (_postID != null)
            {
                // Success send any notifications
                NotifyTopics(model.Topic.Id, UserIDX, "Post");
            }


            // Return view
            return(RedirectToAction("ShowTopic", "Forum", new { slug = model.Topic.Slug }));
        }
Exemple #4
0
        public ActionResult ShowTopic(string slug, int?p, string order, Guid?id, Guid?p_id)
        {
            // Set initial stuff
            //var pageIndex = p ?? 1;
            int UserIDX = db_Accounts.GetUserIDX();

            // Get the topic
            var _topic = new Topic();

            if (slug != null)
            {
                _topic = db_Forum.GetTopic_fromSlug(slug);
            }
            else if (id != null)
            {
                _topic = db_Forum.GetTopic_ByID(id.ConvertOrDefault <Guid>());
            }
            else if (p_id != null)
            {
                _topic = db_Forum.GetTopic_ByPostID(p_id.ConvertOrDefault <Guid>());
            }


            if (_topic != null)
            {
                //add view count (only if not the person who created topic) and only if not a bot
                if (_topic.MembershipUser_Id != UserIDX && !BotUtils.UserIsBot())
                {
                    db_Forum.TopicAddView(_topic.Id);
                    _topic.Views = _topic.Views + 1;
                }

                var model = new vmForumTopicView
                {
                    Topic              = _topic,
                    TopicTags          = db_Forum.GetTopicTags_ByAttributeSelected(_topic.Id, "Topic Tag"),
                    StarterPost        = db_Forum.GetPost_StarterForTopic(_topic.Id, UserIDX),
                    Posts              = db_Forum.GetPost_NonStarterForTopic(_topic.Id, UserIDX, order),
                    IsSubscribed       = db_Forum.NotificationIsUserSubscribed(_topic.Id, UserIDX),
                    LastPostDatePretty = db_Forum.GetTopic_LastPostPrettyDate(_topic.Id),
                    //model.DisablePosting = false;
                    NewPostContent = ""
                };

                //poll handling
                if (_topic.Poll_Id != null)
                {
                    Guid p1 = _topic.Poll_Id.ConvertOrDefault <Guid>();
                    model.Poll = new vmForumPoll {
                        Poll                = db_Forum.GetPoll_ByID(p1),
                        TotalVotesInPoll    = db_Forum.GetPollVotes_ByPollID(p1),
                        UserHasAlreadyVoted = db_Forum.HasUserVotedInPoll(p1, UserIDX),
                        PollAnswers         = db_Forum.GetPollAnswersWithVotes_ByPollID(p1)
                    };
                }

                return(View(model));
            }
            else
            {
                TempData["Error"] = "No topic found";
                return(RedirectToAction("Index", "Forum"));
            }
        }