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 })); }
//******************************************************************************** // SEND MAIL TO AUTHOR OF TOPIC, ADMIN (MODERATOR) OR ALL USERS WHO POST Comments) //********************************************************************************* // Mail Logic // If user post new topic mail will be sent to user and admin (moderator) // If admin approve topic mail will be sent to author (in case of manual review) // If normal user post reply, mail will be sent to author and all users who contribute replies and admin private void ProcessMail(long tid, long replyid, string username, long groupid, string description, string title) { try { string subject = title; string content = UtilityBLL.StripHTML(description); string url = Forum_Urls.Prepare_Topic_Url(tid, subject, false); if (replyid == 0) { // New Topic Posted Mail Will Be Sent To Admin AND Author // send mail to admin var alst = MailTemplateBLL.Get_Template(_context, "FORUMTOPIC").Result; Send_Email(username, "admin", "", subject, content, url, alst); // send mail to author var tlst = MailTemplateBLL.Get_Template(_context, "FORUMTA").Result; string authoremail = UserBLL.Return_Value_UserId(_context, username, "email"); var authormailpermission = Convert.ToByte(UserSettingsBLL.Get_Field_Value(_context, username, "isemail")); if (authormailpermission == 1) { Send_Email("", username, authoremail, subject, content, url, tlst); } } else { // User Post Reply, Mail will be sent to autho, admin and all users who contribute replies MailTemplateProcess(replyid, subject, content, url, username, groupid); } } catch (Exception ex) { ErrorLgBLL.Add(_context, "Mail Processing Error", "", ex.Message); } }
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 })); }
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)); }
// 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)); }