Example #1
0
        public async Task <ActionResult> load_stats()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            //var data = JsonConvert.DeserializeObject<ClassifiedEntity>(json);

            var _forums = await ForumBLLC.Count(_context, new ForumEntity()
            {
                ispublic = true
            });

            var _topics = await ForumTopicBLL.Count(_context, new ForumTopicEntity()
            {
                ispublic   = true,
                isfeatured = FeaturedTypes.Featured,
                nofilter   = false
            });

            var _blogs = await Jugnoon.Blogs.BlogsBLL.Count(_context, new Jugnoon.Blogs.BlogEntity()
            {
                ispublic = true
            });

            var _users = await UserBLL.Count(_context, new Jugnoon.Entity.MemberEntity()
            {
                nofilter = true
            });


            return(Ok(new { forums = _forums, topics = _topics, blogs = _blogs, users = _users }));
        }
Example #2
0
        public async Task <ActionResult> load()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <ForumTopicEntity>(json);

            data.isdropdown = false;
            data.issummary  = false;
            var _posts = await ForumTopicBLL.LoadItems(_context, data);

            /* setup thumb path */
            foreach (var topic in _posts)
            {
                topic.url        = Forum_Urls.Prepare_Topic_Url(topic.id, topic.title, false);
                topic.author_url = UserUrlConfig.ProfileUrl(topic.author, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);
            }
            var _records = 0;

            if (data.id == 0)
            {
                _records = await ForumTopicBLL.Count(_context, data);
            }

            var _settings = new
            {
                general = Jugnoon.Forums.Configs.GeneralSettings
            };

            return(Ok(new { posts = _posts, records = _records, settings = _settings }));
        }
Example #3
0
        public async Task <ActionResult> load_reports()
        {
            var json     = new StreamReader(Request.Body).ReadToEnd();
            var data     = JsonConvert.DeserializeObject <ForumTopicEntity>(json);
            var _reports = await ForumTopicBLL.LoadReport(_context, data);

            return(Ok(new { data = _reports }));
        }
Example #4
0
        public ActionResult authorize_author()
        {
            var json     = new StreamReader(Request.Body).ReadToEnd();
            var data     = JsonConvert.DeserializeObject <JGN_ForumTopics>(json);
            var isaccess = ForumTopicBLL.Check(_context, data.id, data.userid);

            return(Ok(new { isaccess = isaccess }));
        }
Example #5
0
        public async Task <ActionResult> action()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <List <ForumTopicEntity> >(json);

            await ForumTopicBLL.ProcessAction(_context, data);

            return(Ok(new { status = "success", message = SiteConfig.generalLocalizer["_records_processed"].Value }));
        }
Example #6
0
        public async Task <IActionResult> remove(long?id)
        {
            if (id == null)
            {
                return(Redirect(Config.GetUrl("forum")));
            }
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect(Config.GetUrl("forum?status=notsigned")));
            }

            if (!ForumTopicBLL.Check(_context, (long)id, SiteConfig.userManager.GetUserName(User)))
            {
                return(Redirect(Config.GetUrl("forum?status=authfailed")));
            }

            var _obj = await ForumTopicBLL.LoadItems(_context, new ForumTopicEntity()
            {
                id         = (long)id,
                pagenumber = 1,
                pagesize   = 1000,
                singlepost = true,
                loadall    = true
            });

            if (_obj.Count > 0)
            {
                var Item = _obj[0];
                await ForumTopicBLL.Delete(_context, Item.id, Item.forumid, Item.userid);

                if (Item.replyid > 0)
                {
                    // get post info
                    Item.replies--;
                    if (Item.replies < 0)
                    {
                        Item.replies = 0;
                    }

                    await ForumTopicBLL.Update_Value_V3(_context, Item.replyid, "replies", Item.replies);
                }
            }

            return(Redirect(Config.GetUrl("forum?status=removed")));
        }
Example #7
0
        public async Task <IActionResult> resolved()
        {
            long   TopicID      = 0;
            long   PostID       = 0;
            int    isresolved   = 0;
            string Postusername = "";
            string ElementID    = ""; // div element id where you want to load box with close link

            if (HttpContext.Request.Query["t"].Count > 0)
            {
                TopicID = Convert.ToInt64(HttpContext.Request.Query["t"]);
            }
            if (HttpContext.Request.Query["p"].Count > 0)
            {
                PostID = Convert.ToInt64(HttpContext.Request.Query["p"]);
            }
            if (HttpContext.Request.Query["res"].Count > 0)
            {
                isresolved = Convert.ToInt32(HttpContext.Request.Query["res"]);
            }
            if (HttpContext.Request.Query["pusr"].Count > 0)
            {
                Postusername = HttpContext.Request.Query["pusr"].ToString();
            }
            if (HttpContext.Request.Query["cnt"].Count > 0)
            {
                ElementID = HttpContext.Request.Query["cnt"].ToString();
            }

            // mark content as resolved
            await ForumTopicBLL.MarkAsResolved(_context, TopicID, PostID, Postusername, isresolved);

            // wrap output
            if (isresolved == 1)
            {
                return(this.Content(SiteConfig.forumLocalizer["_remove_answer"], "text/plain"));
            }
            else
            {
                return(this.Content(SiteConfig.forumLocalizer["_mark_answer"], "text/plain"));
            }
        }
Example #8
0
 private void MailTemplateProcess(long tid, string subject, string content, string url, string username, long groupid)
 {
     //if sending mail option enabled
     if (Jugnoon.Settings.Configs.SmtpSettings.enable_email)
     {
         var lst = MailTemplateBLL.Get_Template(_context, "FORUMTREP").Result;
         if (lst.Count > 0)
         {
             string TopicAuthorusername = ForumTopicBLL.Return_Value(_context, tid, "username");
             //// send email to admin
             //string emailaddress = UserBLL.Return_Value(model.username, "email");
             //Send_Email(model.username,"admin", subject, content, url, lst);
             // send mail to all other usernames who already post topi on model content
             var cuserlist = UserBLL.LoadItems(_context, new MemberEntity()
             {
                 topicid = tid
             }).Result;
             if (cuserlist.Count > 0)
             {
                 int i = 0;
                 for (i = 0; i <= cuserlist.Count - 1; i++)
                 {
                     //if (cuserlist[i].isautomail == 1)
                     //{
                     if (cuserlist[i].UserName == TopicAuthorusername)
                     {
                         // topic author
                         GroupMailProcessTemplate(TopicAuthorusername, subject, username, cuserlist[i].Email, url, groupid);
                     }
                     else
                     {
                         // normal user
                         Send_Email(username, cuserlist[i].UserName, cuserlist[i].Email, subject, content, url, lst);
                     }
                     //}
                 }
             }
         }
     }
 }
Example #9
0
        public async Task <ActionResult> getinfo()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <ForumTopicEntity>(json);

            int pagesize     = 10;
            int TotalRecords = await ForumTopicBLL.Count(_context, new ForumTopicEntity()
            {
                id         = data.id,
                isenabled  = EnabledTypes.All,
                isapproved = ApprovedTypes.All,
                loadall    = true
            });

            if (TotalRecords == 0)
            {
                return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_no_records"].Value }));
            }

            bool DisablePost = false;

            var _lst = await ForumTopicBLL.LoadItems(_context, new ForumTopicEntity()
            {
                id         = data.id,
                loadall    = true,
                pagenumber = data.pagenumber,
                pagesize   = pagesize,
                iscache    = false,
                singlepost = false
            });

            foreach (var topic in _lst)
            {
                topic.img_url = UserUrlConfig.ProfilePhoto(topic.userid, topic.author.picturename, 0);
            }

            return(Ok(new { status = "success", posts = _lst, disable = DisablePost, total = TotalRecords }));
        }
Example #10
0
        public async Task <ActionResult> getinfo_acc()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <ForumTopicEntity>(json);

            var _lst = await ForumTopicBLL.LoadItems(_context, new ForumTopicEntity()
            {
                id         = data.id,
                iscache    = false,
                singlepost = true
            });

            if (_lst.Count == 0)
            {
                return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_no_records"].Value }));
            }

            foreach (var topic in _lst)
            {
                topic.img_url = UserUrlConfig.ProfilePhoto(topic.userid, topic.author.picturename, 0);
            }

            return(Ok(new { status = "success", post = _lst[0] }));
        }
Example #11
0
        private List <ForumItem> GetForumData()
        {
            string key  = "mn_forum_cache";
            var    data = new List <ForumItem>();

            if (!SiteConfig.Cache.TryGetValue(key, out data))
            {
                var _list = CategoryBLL.LoadItems(_context, new CategoryEntity()
                {
                    type     = (int)CategoryBLL.Types.Forum,
                    ispublic = true,
                    iscache  = false,
                    order    = "title asc",
                    pagesize = 50
                }).Result;
                var _Data = new List <ForumItem>();
                if (_list.Count > 0)
                {
                    foreach (var Item in _list)
                    {
                        var _data = new ForumItem()
                        {
                            Type      = 12,
                            Title     = Item.title,
                            Term      = Item.term,
                            ForumList = ForumBLLC.LoadItems(_context, new ForumEntity()
                            {
                                order        = "priority desc",
                                categoryname = Item.term,
                                //categories_str = Item.term,
                                iscache = false
                            }).Result
                        };
                        // attach last post id
                        foreach (var Itm in _data.ForumList)
                        {
                            Itm.lastpost = new List <JGN_ForumTopics>();
                            if (Itm.lastpostid != null && Itm.lastpostid > 0)
                            {
                                Itm.lastpost = ForumTopicBLL.Load_Last_Post(_context, (long)Itm.lastpostid);
                            }
                        }
                        _Data.Add(_data);
                    }
                }

                var cacheEntryOptions = new MemoryCacheEntryOptions()
                                        // Keep in cache for this time, reset time if accessed.
                                        .SetSlidingExpiration(TimeSpan.FromSeconds(3600));

                data = _Data;
                // Save data in cache.
                SiteConfig.Cache.Set(key, _Data, cacheEntryOptions);
            }
            else
            {
                data = (List <ForumItem>)SiteConfig.Cache.Get(key);
            }

            return(data);
        }
Example #12
0
        // GET: forums/post
        public async Task <IActionResult> post(long?id)
        {
            var model = new PostTopicViewModel();

            model.AlertType  = AlertTypes.Error;
            model.PostAccess = true;

            long TopicID = 0;

            if (id != null)
            {
                TopicID = (long)id;
            }

            if (!User.Identity.IsAuthenticated)
            {
                string redirect_url = Config.GetUrl() + "forums/post";
                return(Redirect(Config.GetUrl() + "login?returnUrl=" + redirect_url));
            }

            model.isAdmin = false;


            model.UserName = SiteConfig.userManager.GetUserName(User);

            if (HttpContext.Request.Query["gd"].Count > 0)
            {
                model.GroupID = Convert.ToInt64(HttpContext.Request.Query["gd"]);
            }

            model.showTitle       = true;
            model.showTags        = true;
            model.showForumOption = true;

            if (HttpContext.Request.Query["f"].Count > 0)
            {
                model.ForumID         = Convert.ToInt32(HttpContext.Request.Query["f"]);
                model.showForumOption = false;
            }
            else
            {
                // load forums for manual selection
                model.ForumList = await ForumBLLC.LoadItems(_context, new ForumEntity()
                {
                    loadall = true,
                    iscache = true
                });
            }


            // use for posting reply
            if (HttpContext.Request.Query["t"].Count > 0)
            {
                model.ReplyID = Convert.ToInt32(HttpContext.Request.Query["t"]);

                var status = Load_Topic_Info(model);
                if (status != "OK")
                {
                    model.Message = status;
                    return(View(model));
                }
            }


            // use for updat posting only
            if (TopicID > 0)
            {
                model.TopicID         = TopicID;
                model.showForumOption = false;

                if (!model.isAdmin)
                {
                    // Security Validation -> Awnership Check
                    if (!ForumTopicBLL.Check(_context, model.TopicID, SiteConfig.userManager.GetUserName(User)))
                    {
                        model.PostAccess  = false;
                        model.PostMessage = SiteConfig.generalLocalizer["_authentication_failed"];
                        return(View(model));
                    }
                }
                var _lst = await ForumTopicBLL.LoadItems(_context, new ForumTopicEntity()
                {
                    id      = model.TopicID,
                    loadall = true
                });

                if (_lst.Count > 0)
                {
                    model.Title   = _lst[0].title;
                    model.Tags    = _lst[0].tags;
                    model.ForumID = _lst[0].forumid;
                    string desc = _lst[0].description;
                    model.Description = _lst[0].description;
                }
                else
                {
                    model.ReplyID = 0;
                    model.Message = SiteConfig.forumLocalizer["_forum_post_msg_01"].Value; //  "No existing topic found to post reply, add new topic"
                    return(View(model));
                }
            }

            if (model.ReplyID > 0)
            {
                model.HeadingTitle = SiteConfig.forumLocalizer["_post_reply"].Value;
            }
            else if (TopicID > 0)
            {
                model.HeadingTitle = "Update Post";
            }
            else
            {
                model.HeadingTitle = SiteConfig.forumLocalizer["_post_new_topic"].Value;
            }


            ViewBag.title = model.HeadingTitle;
            return(View(model));
        }
Example #13
0
        public string Load_Topic_Info(PostTopicViewModel model)
        {
            var _lst = ForumTopicBLL.LoadItems(_context, new ForumTopicEntity()
            {
                id         = model.ReplyID,
                loadall    = true,
                singlepost = true
            }).Result;

            if (_lst.Count > 0)
            {
                // further validation
                if (_lst[0].replyid > 0)
                {
                    model.ReplyID = 0;
                    return(SiteConfig.forumLocalizer["_forum_post_msg_02"].Value);
                }
                if (_lst[0].type == 1)
                {
                    model.ReplyID = 0; // reset it to post new topic
                    return(SiteConfig.forumLocalizer["_forum_post_msg_03"].Value);
                }
                if (_lst[0].islocked == 1)
                {
                    model.ReplyID = 0; // reset it to post new topic
                    return(SiteConfig.forumLocalizer["_forum_post_msg_04"].Value);
                }
                if (_lst[0].isresolved == 1)
                {
                    model.ReplyID = 0; // reset it to post new topic
                    return(SiteConfig.forumLocalizer["_forum_post_msg_05"].Value);
                }
                if (_lst[0].isapproved == 0)
                {
                    model.ReplyID = 0; // reset it to post new topic
                    return(SiteConfig.forumLocalizer["_forum_post_msg_06"].Value);
                }
                if (_lst[0].isenabled == (byte)EnabledTypes.Disabled)
                {
                    model.ReplyID = 0; // reset it to post new topic
                    return(SiteConfig.forumLocalizer["_forum_post_msg_07"].Value);
                }
                // Validation completed
                model.showTitle       = false;
                model.showTags        = false;
                model.showForumOption = false;
                model.ForumID         = _lst[0].forumid;
                model.Title           = "Re: " + _lst[0].title;
                model.Tags            = _lst[0].tags;

                if (HttpContext.Request.Query["nq"].Count > 0)
                {
                    if (HttpContext.Request.Query["nq"].ToString() == "0")
                    {
                        // quote is on
                        if (HttpContext.Request.Query["p"].Count > 0)
                        {
                            long postid = Convert.ToInt64(HttpContext.Request.Query["p"]);
                            if (postid > 0)
                            {
                                string desc = ForumTopicBLL.Return_Value(_context, postid, "description");
                                desc = UtilityBLL.CompressCodeBreak(desc); // replace \n with <br />
                                desc = WebUtility.HtmlDecode(desc);
                                model.Description = "\n[quote]" + desc + "[/quote]\n";
                            }
                        }
                    }
                }
                return("OK");
            }
            else
            {
                model.ReplyID = 0;
                return(SiteConfig.forumLocalizer["_forum_post_msg_08"].Value);
            }
        }
Example #14
0
        public async Task <ActionResult> proc()
        {
            var json  = new StreamReader(Request.Body).ReadToEnd();
            var model = JsonConvert.DeserializeObject <JGN_ForumTopics>(json);

            // new topic posted
            if (model.replyid == 0)
            {
                // check title
                if (model.title.Length < 5)
                {
                    return(Ok(new { status = "error", message = SiteConfig.generalLocalizer["_invalid_title"].Value }));
                }
            }

            // Add information in table
            var topics = new JGN_ForumTopics();

            if (model.id > 0)
            {
                topics.id = model.id;
            }

            string content = UGeneral.SanitizeText(model.description);

            topics.description = content;
            topics.title       = model.title;
            if (topics.title.Length > 200)
            {
                topics.title = topics.title.Substring(0, 199);
            }
            topics.tags    = model.tags;
            topics.forumid = model.forumid;
            topics.userid  = model.userid;
            int isapproved = 1;

            topics.isapproved = (byte)isapproved;
            topics.isenabled  = 1;
            topics.replyid    = model.replyid;


            topics = await ForumTopicBLL.Process(_context, topics, true);

            if (model.tags != "" && model.replyid == 0 && model.id == 0)
            {
                // Process tags
                TagsBLL.Process_Tags(_context, model.tags, TagsBLL.Types.Forums, 0);
            }


            // Mail Procesing Section
            if (model.id == 0 && model.replyid == 0)
            {
                //  ProcessMail(tid, topics.replyid, topics.username, model.GroupID, model.Description, model.Title);
                // add newly added topic id in struct for user activity and group posting
                //topics.id = topics.id;
            }

            topics.url        = Forum_Urls.Prepare_Topic_Url(topics.id, topics.title, true);
            topics.author_url = UserUrlConfig.ProfileUrl(topics.author, Jugnoon.Settings.Configs.RegistrationSettings.uniqueFieldOption);

            return(Ok(new { status = "success", record = topics, message = SiteConfig.generalLocalizer["_record_created"].Value }));
        }
Example #15
0
        // GET: forums/category
        public async Task <IActionResult> category(string title, int?pagenumber)
        {
            if (title == null)
            {
                return(Redirect(Config.GetUrl("forums/")));
            }
            if (pagenumber == null)
            {
                pagenumber = 1;
            }

            string _term        = UtilityBLL.ReplaceHyphinWithSpace(title);
            string categoryName = UtilityBLL.UppercaseFirst(_term);


            string _title = categoryName + " Forums";
            /* List Initialization */
            var ListEntity = new ForumListViewModel()
            {
                isListStatus = false,
                QueryOptions = new ForumEntity()
                {
                    pagenumber   = (int)pagenumber,
                    categoryname = _term,
                    //categories_str = _term,
                    iscache  = true,
                    ispublic = true,
                    pagesize = 20,
                    order    = "priority desc",
                },
                DefaultUrl        = Config.GetUrl("forums/category/" + title + "/"),
                PaginationUrl     = Config.GetUrl("forums/category/" + title + "/[p]/"),
                NoRecordFoundText = SiteConfig.generalLocalizer["_no_records"].Value,
                headingTitle      = _title
            };

            ListEntity.Records = await ForumBLLC.Count(_context, ListEntity.QueryOptions);

            if (ListEntity.Records > 0)
            {
                ListEntity.Data = await ForumBLLC.LoadItems(_context, ListEntity.QueryOptions);

                foreach (var Item in ListEntity.Data)
                {
                    // attach last post id
                    foreach (var Itm in ListEntity.Data)
                    {
                        Itm.lastpost = ForumTopicBLL.Load_Last_Post(_context, (long)Itm.lastpostid);
                    }
                }
            }

            if (pagenumber > 1)
            {
                _title = _title + " - Page: " + pagenumber;
            }

            ViewBag.title = _title;

            return(View(ListEntity));
        }
Example #16
0
        // GET: topic
        public async Task <IActionResult> Index(long?tid, string title, int?id)
        {
            int pagenumber = 1;

            if (id != null)
            {
                pagenumber = (int)id;
            }

            if (tid == null)
            {
                return(Redirect(Config.GetUrl("forums")));
            }

            var model = new TopicListViewModel();

            model.isAllowed   = true;
            model.isAdmin     = false;
            model.DisablePost = false;

            if (title != "")
            {
                model.TopicTitle = UtilityBLL.UppercaseFirst(UtilityBLL.ReplaceHyphinWithSpace(title), true);
            }
            else
            {
                model.TopicTitle = "default-topic";
            }


            model.TopicID = (long)tid;

            model.QueryOptions = new ForumTopicEntity()
            {
                pagenumber = pagenumber,
                pagesize   = Jugnoon.Settings.Configs.GeneralSettings.pagesize
            };

            model.TotalRecords = await ForumTopicPostsBLL.Count(_context, new ForumTopicEntity()
            {
                id       = model.TopicID,
                ispublic = true,
                loadall  = true
            });

            if (model.TotalRecords == 0)
            {
                model.isAllowed     = false;
                model.DetailMessage = SiteConfig.forumLocalizer["norecordfound"].Value;
                return(View(model));
            }
            model.DisablePost = false;

            var _lst = await ForumTopicPostsBLL.LoadItems(_context, new ForumTopicEntity()
            {
                id         = model.TopicID,
                loadall    = true,
                pagenumber = model.QueryOptions.pagenumber,
                pagesize   = model.QueryOptions.pagesize,
                singlepost = false
            });

            if (_lst.Count > 0)
            {
                if (_lst[0].isadult == 1)
                {
                    // 1:-> adult content, 0:-> non adult content
                    var getValue = HttpContext.Session.GetString("adultmember");
                    if (getValue == null)
                    {
                        string surl = Forum_Urls.Prepare_Topic_Url(_lst[0].id, _lst[0].title, false);
                        return(Redirect(Config.GetUrl("home/validateadult?surl=" + WebUtility.UrlEncode(surl) + "")));
                    }
                }

                // increment views
                await ForumTopicBLL.Increment_Views(_context, model.TopicID, _lst[0].views);

                // other settings
                model.ForumID = _lst[0].forumid;
                string forumtitle = _lst[0].forum_title;
                model.ForumTitle = forumtitle;
                // load topic and posts
                model.Topics = _lst;

                model.DefaultUrl    = "topic/" + model.TopicID + "/" + title;
                model.PaginationUrl = "topic/" + model.TopicID + "/" + title + "/[p]";

                string _title = _lst[0].title;
                if (model.QueryOptions.pagenumber > 1)
                {
                    _title = _title + " Page: " + model.QueryOptions.pagenumber;
                }
                string _desc = UtilityBLL.StripHTML(_lst[0].description);
                if (_desc.Length > 80)
                {
                    _desc = _desc.Substring(0, 80);
                }

                model.HeadingTitle  = _title;
                ViewBag.title       = _title;
                ViewBag.description = _desc;
            }
            else
            {
                model.isAllowed     = false;
                model.DetailMessage = SiteConfig.forumLocalizer["norecordfound"].Value;
                return(View(model));
            }
            return(View(model));
        }
Example #17
0
        public async Task <IActionResult> post(PostTopicViewModel model)
        {
            if (ModelState.IsValid)
            {
                // new topic posted
                if (model.ReplyID == 0)
                {
                    // check title
                    if (model.Title.Length < 10)
                    {
                        model.Message = SiteConfig.forumLocalizer["_forum_post_msg_09"].Value;
                        return(View(model));
                    }

                    if (UtilityBLL.isLongWordExist(model.Title) || UtilityBLL.isLongWordExist(model.Title))
                    {
                        model.Message = SiteConfig.generalLocalizer["_invalid_title"];
                        return(View(model));
                    }
                }

                // Add information in table
                var topics = new JGN_ForumTopics();
                if (model.TopicID > 0)
                {
                    topics.id = model.TopicID;
                }

                topics.forumid = model.ForumID;

                string content = UGeneral.SanitizeText(model.Description);

                // Process Contents -> links, bbcodes etc
                // content = UtilityBLL.Process_Content_Text(content);
                // Generate Album Preview
                //content = AlbumsBLL.Generate_Blog_Gallery_Previews(content);

                topics.description = content;

                if (model.ReplyID > 0)
                {
                    var _lst = await ForumTopicBLL.LoadItems(_context, new ForumTopicEntity()
                    {
                        id      = model.TopicID,
                        loadall = true
                    });

                    if (_lst.Count > 0)
                    {
                        topics.tags    = _lst[0].tags;
                        topics.title   = _lst[0].title;
                        topics.forumid = _lst[0].forumid;
                        if (topics.title.Length > 200)
                        {
                            topics.title = topics.title.Substring(0, 199);
                        }
                    }
                }
                else
                {
                    if (model.Tags != null)
                    {
                        topics.tags = model.Tags;
                        if (topics.tags.Length > 300)
                        {
                            topics.tags = topics.tags.Substring(0, 299);
                        }
                    }

                    topics.title = model.Title;
                }
                topics.userid = model.UserName;

                int isapproved = 1;
                if (Jugnoon.Settings.Configs.GeneralSettings.content_approval == 0 && !model.isAdmin && model.ReplyID == 0)
                {
                    isapproved = 0; // manual approval
                }
                topics.isapproved = (byte)isapproved;
                topics.isenabled  = 1;
                topics.replyid    = model.ReplyID;

                topics = await ForumTopicBLL.Process(_context, topics, model.isAdmin);

                if (model.Tags != "")
                {
                    // Process tags
                    TagsBLL.Process_Tags(_context, model.Tags, TagsBLL.Types.Forums, 0);
                }


                // Mail Procesing Section
                if (model.TopicID == 0 && model.ReplyID == 0)
                {
                    ProcessMail(topics.id, topics.replyid, topics.userid, model.GroupID, model.Description, model.Title);
                    // add newly added topic id in struct for user activity and group posting
                    //topics.topicid = topics.topicid;
                }

                if (model.ReplyID > 0)
                {
                    // topic is posted in reply
                    // redirect to topic
                    return(Redirect(Forum_Urls.Prepare_Topic_Url(topics.replyid, topics.title, model.isAdmin) + "?status=posted"));
                }

                return(Redirect(Forum_Urls.Prepare_Topic_Url(topics.id, topics.title, model.isAdmin) + "?status=posted"));
            }

            // initialize values
            if (model.ForumID == 0)
            {
                model.ForumList = await ForumBLLC.LoadItems(_context, new ForumEntity()
                {
                    loadall = true,

                    iscache = true
                });
            }
            model.Message = "Validation Error";
            return(View(model));
        }
Example #18
0
        // GET: forums
        public async Task <IActionResult> Index(int?fid, string title, int?id)
        {
            ViewBag.ForumTabCss = "active";

            int pagenumber = 1;

            if (id != null)
            {
                pagenumber = (int)id;
            }
            if (fid == null || title == null)
            {
                return(Redirect(Config.GetUrl("forums")));
            }

            string forum       = title.Trim().ToLower();
            string forum_title = UtilityBLL.UppercaseFirst(UtilityBLL.ReplaceHyphinWithSpace(forum), true);
            int    forumid     = Convert.ToInt32(fid);

            /* List Initialization */
            var ListEntity = new ForumTopicsListViewModel()
            {
                ForumID      = forumid,
                isListStatus = false,
                QueryOptions = new ForumTopicEntity()
                {
                    issummary  = false,
                    loadall    = false,
                    pagenumber = (int)pagenumber,
                    term       = "",
                    iscache    = true,
                    ispublic   = true,
                    pagesize   = 20,
                    type       = 2, // all
                    order      = "topic.created_at desc",
                    forumid    = forumid
                },
                ListObject = new Jugnoon.Scripts.ListItems()
                {
                    ListType = Jugnoon.Scripts.ListType.List, // 0: grid 1: list
                },
                DefaultUrl        = Config.GetUrl("forum/" + fid + "/" + title),
                PaginationUrl     = Config.GetUrl("forum/" + fid + "/" + title + "/[p]/"),
                NoRecordFoundText = SiteConfig.generalLocalizer["_no_records"].Value,
                HeadingTitle      = forum_title
            };

            ListEntity.Records = await ForumTopicBLL.Count(_context, ListEntity.QueryOptions);

            if (ListEntity.Records > 0)
            {
                ListEntity.Data = await ForumTopicBLL.LoadItems(_context, ListEntity.QueryOptions);
            }

            /* Page Title Adjustment */
            string _title = forum_title;

            if (pagenumber > 1)
            {
                _title = _title + " - Page: " + pagenumber;
            }

            ViewBag.title = _title;


            return(View(ListEntity));
        }
Example #19
0
        public async Task <IActionResult> post(long?id)
        {
            if (id == null)
            {
                return(Redirect(Config.GetUrl("forums")));
            }

            var model = new TopicListViewModel();

            model.isAllowed   = true;
            model.isAdmin     = false;
            model.DisablePost = true;

            model.TopicTitle = ForumTopicBLL.Return_Value(_context, (long)id, "title");

            model.TopicID      = (long)id;
            model.QueryOptions = new ForumTopicEntity()
            {
                singlepost = true,
                id         = model.TopicID,
                ispublic   = true,
                loadall    = true,
                pagenumber = 1
            };


            model.DisablePost = false;
            var _lst = await ForumTopicPostsBLL.LoadItems(_context, model.QueryOptions);

            if (_lst.Count > 0)
            {
                /*if (_lst[0].isadult == 1)
                 * {
                 *  // 1:-> adult content, 0:-> non adult content
                 *  if (Session["adultmember"] == null)
                 *  {
                 *      string surl = Forum_Urls.Prepare_Topic_Url(_lst[0].topicid, _lst[0].title, false);
                 *      return Redirect(Config.GetUrl("home/validateadult?surl=" + WebUtility.UrlEncode(surl) + ""));
                 *  }
                 * }*/
                // increment views
                await ForumTopicBLL.Increment_Views(_context, model.TopicID, _lst[0].views);

                // other settings
                int    forumid    = _lst[0].forumid;
                string forumtitle = _lst[0].forum_title;
                model.ForumTitle = forumtitle;
                // load topic and posts
                model.Topics = _lst;

                string _title = _lst[0].title + " Post: " + model.TopicID;

                string _desc = UtilityBLL.StripHTML(_lst[0].description);
                if (_desc.Length > 80)
                {
                    _desc = _desc.Substring(0, 80);
                }

                model.HeadingTitle = _title;

                ViewBag.title       = _title;
                ViewBag.description = _desc + " Post: " + model.TopicID;
            }
            else
            {
                model.isAllowed     = false;
                model.DetailMessage = SiteConfig.forumLocalizer["norecordfound"].Value;
                return(View(model));
            }

            return(View(model));
        }