public void updateForumsList(Forum[] forums) { clearList(); for (int i = 0; i < forums.Length; i++) createNewLine(forums[i].forumName); }
//页面加载 protected void Page_Load(object sender, EventArgs e) { try { id = Int32.Parse(Request.QueryString["id"]).ToString(); } catch { Response.Redirect("../Default.aspx"); return; } index = Int32.Parse(floor.Value); if (Request.QueryString["id"] != null) { RepeaterDataBind(); SubjectInfo si = new Forum().GetSubjectById(Convert.ToInt32(Request.QueryString["id"])); lbTitle.Text = "主题:" + si.StrTheme; UserControl_ThemeOfMsg theme = this.ThemeOfMsg1; theme.Subject = si; } //第一次加载 if (!IsPostBack) { //胡媛媛添加,使游客无法发表留言,2010-6-22 if (Session["UserName"] == null) { submitMsg.Enabled = false; } //胡媛媛添加,使游客无法发表留言,2010-6-22 } }
public void ForumUpdate_WithoutUid_ThrowsError() { var commentForum = new Forum { Id = "" }; var readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>(); var site = mocks.DynamicMock<ISite>(); var cacheManager = mocks.DynamicMock<ICacheManager>(); //readerCreator.Stub(x => x.CreateDnaDataReader("getmoderationclasslist")).Return(reader); mocks.ReplayAll(); var context = new Context(null, readerCreator, cacheManager, null); try { context.UpdateForum(commentForum, site, null); throw new Exception("Error not thrown within code"); } catch (ApiException ex) { Assert.AreEqual("Forum uid is empty, null or exceeds 255 characters.", ex.Message); Assert.AreEqual(ErrorType.InvalidForumUid, ex.type); } readerCreator.AssertWasNotCalled(x => x.CreateDnaDataReader("commentforumcreate")); }
public AdminDialog(int forumId, string adderUsrName, string adderPswd, Forum.RegPolicy policy) { InitializeComponent(); this.forumId = forumId; this.pswd = adderPswd; this.usrName = adderUsrName; initAddRemoveTab(); initModeratorPermissionsTab(); initMessagesTab(); initCommentsTab(); initRepliersTab(); //show confirm option only if this is the forum policy if (policy == Forum.RegPolicy.ADMIN_CONFIRMATION) { initConfirmUsersTab(); } else { for (int i = 0; i < tabControl1.TabPages.Count; i++) { if (tabControl1.TabPages[i].Name.Equals("tabConfirm", StringComparison.OrdinalIgnoreCase)) { tabControl1.TabPages.RemoveAt(i); break; } } } }
public AccessFlag GetAccessFlag(User user, Forum forum) { // TODO: return AccessFlag.Create | AccessFlag.Delete | AccessFlag.Moderator | AccessFlag.Poll | AccessFlag.Priority | AccessFlag.Priority | AccessFlag.Read | AccessFlag.Reply | AccessFlag.Update | AccessFlag.Upload | AccessFlag.Vote; }
protected void Save_Click(Object sender, EventArgs e) { if (IsValid) { Forum _frm = new Forum(this.ConnectionString); if (ViewState["forumId"] != null) { _frm.LitePopulate(ViewState["forumId"], false); } _frm.Title = txt_Title.Text; _frm.Description = txt_Desc.Text; _frm.Active = ch_Active.Checked; if (_frm.Save()) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", "alert('Record has been updated successfully.');self.location = 'Forums.aspx';", true); } else { lbl_Error.Text = "An unexpected error has occurred. Please try again."; lbl_Error.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HtmlGenericControl _nc = (HtmlGenericControl)Master.FindControl("navForum"); _nc.Attributes.Add("class", "active"); String _forumId = Request.QueryString["forumId"]; if (!String.IsNullOrEmpty(_forumId)) { ViewState.Add("forumId", _forumId); Forum _frm = new Forum(this.ConnectionString); _frm.LitePopulate(ViewState["forumId"], false); txt_Desc.Text = _frm.Description; txt_Title.Text = _frm.Title; ch_Active.Checked = _frm.Active; lbl_Header.Text = String.Format("{0}", _frm.Title); } else { lbl_Header.Text = "Add Forum"; } } }
public void ChangeTopicForum(int topicid, int forumid) { ForumInfo newforum = new Forum().GetById(forumid); string updateSql = "UPDATE " + Config.ForumTablePrefix + "TOPICS SET FORUM_ID=@ForumId, CAT_ID=@CatId WHERE TOPIC_ID=@TopicId; "; if (newforum.Status == (int)Enumerators.PostStatus.Closed) //forum locked so lock all posts { updateSql = updateSql + "UPDATE " + Config.ForumTablePrefix + "TOPICS SET T_STATUS=0 WHERE TOPIC_ID=@TopicId; "; updateSql = updateSql + "UPDATE " + Config.ForumTablePrefix + "REPLY SET R_STATUS=0 WHERE TOPIC_ID=@TopicId; "; } else if (newforum.ModerationLevel == (int) Enumerators.Moderation.UnModerated) { //change status of posts if coming from moderated forum updateSql = updateSql + "UPDATE " + Config.ForumTablePrefix + "TOPICS SET T_STATUS=1 WHERE TOPIC_ID=@TopicId AND T_STATUS > 1; "; updateSql = updateSql + "UPDATE " + Config.ForumTablePrefix + "REPLY SET R_STATUS=1 WHERE TOPIC_ID=@TopicId AND R_STATUS > 1; "; } updateSql = updateSql + "UPDATE " + Config.ForumTablePrefix + "REPLY SET FORUM_ID=@ForumId, CAT_ID=@CatId WHERE TOPIC_ID=@TopicId; "; List<SqlParameter> parms = new List<SqlParameter> { new SqlParameter("@TopicId", SqlDbType.Int) {Value = topicid}, new SqlParameter("@ForumId", SqlDbType.Int) {Value = forumid}, new SqlParameter("@CatId", SqlDbType.Int) {Value = newforum.CatId} }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, updateSql, parms.ToArray()); }
public ActionResult About() { var f = new Forum(); f.Name = "Hi"; _forumRepo.Add(f); return View(); }
public void SetAvailableShortName(Forum forum) { if (forum == null || forum.ShortName == null) { throw new ArgumentNullException("Forum.ShortName"); } forum.ShortName = _dataAccess.GetAvailableShortName(forum.ShortName); }
protected string GetModeratorLinks(Forum forum, string linkStyle, string separator) { if (forum.Moderators == null || forum.Moderators.Count < 1) return "-"; else { return GetModeratorLinks(forum.Moderators, linkStyle, separator); } }
protected void BindData() { Forum _for = new Forum(this.ConnectionString); gv_Forum.DataSource = _for.GetForums(true); gv_Forum.DataBind(); gv_ForumNotActive.DataSource = _for.GetForums(false); gv_ForumNotActive.DataBind(); }
protected bool HasPermission(Forum forum) { ManageForumPermissionSetNode managePermission = PostBOV5.Instance.GetForumPermissonSet(forum); bool has = managePermission.HasPermissionForSomeone(My, ManageForumPermissionSetNode.ActionWithTarget.DeleteAnyThreads); if (IsRecycleBin && has == false) has = managePermission.HasPermissionForSomeone(My, ManageForumPermissionSetNode.ActionWithTarget.ApproveThreads); return has; }
public Forum Create(string name) { using (var context = _contextManager.GetContext()) { var forum = new Forum(name); context.Add(forum); context.SaveChanges(); return forum; } }
public static Topic GetATopic(Forum forum) { var topicService = TestHelper.Resolve<ITopicsService>(); List<Topic> topicList = topicService.GetByForum(forum.Id, 0, 1, null); if (topicList.Count == 0) { Assert.Inconclusive("There is no topic in the db to perform this test."); } Topic topic = topicService.Get(topicList[0].Id); return topic; }
public int Forums_Save(int PortalId, Forum fi, bool isNew, bool UseGroup) { try { var fc = new ForumController(); return fc.Forums_Save(PortalId, fi, isNew, UseGroup); } catch (Exception ex) { return -1; } }
/// <summary> /// Updates the forum /// </summary> /// <param name="forum"></param> /// <param name="userId">User that is updating the forum</param> public void Edit(Forum f, int userId) { DbCommand comm = this.GetCommand("SPForumsUpdate"); comm.AddParameter(this.Factory, "ForumShortName", DbType.String, f.ShortName); comm.AddParameter(this.Factory, "ForumName", DbType.String, f.Name); comm.AddParameter(this.Factory, "ForumDescription", DbType.String, f.Description); comm.AddParameter(this.Factory, "CategoryId", DbType.String, f.Category.Id); comm.AddParameter(this.Factory, "UserId", DbType.Int32, userId); comm.AddParameter(this.Factory, "ReadAccessGroupId", DbType.Int16, f.ReadAccessRole); comm.AddParameter(this.Factory, "PostAccessGroupId", DbType.Int16, f.PostAccessRole); comm.SafeExecuteNonQuery(); }
/// <summary> /// Implements generating the XML for the More Journal page /// </summary> /// <param name="journalID">Journal ID of the page to return</param> /// <param name="userID">User ID of the page to return</param> /// <param name="skip">Number of articles to skip</param> /// <param name="show">Number of articles to show</param> private void TryCreateMoreJournalXML(int journalID, int userID, int skip, int show) { //Clean any existing XML. RootElement.RemoveAll(); XmlElement journal = AddElementTag(RootElement, "JOURNAL"); AddAttribute(journal, "USERID", userID); Forum forum = new Forum(InputContext); forum.GetJournal(_journalID, show, skip, false); AddInside(forum, "JOURNAL"); }
public UserDialog(Forum site, String userName) { this.Build (); this.site = site; this.userName = userName; this.userId = site.getUserId (userName); if (!userId.Equals(string.Empty)) { this.image2.Pixbuf = new Gdk.Pixbuf (getAvatar ()); this.labelNumPosts.Text = site.getUserPostCount (userName).ToString (); this.labelLastActivity.Text = site.getUserLastActivityTime (userName).ToString (); userInfoLoaded = true; } }
public void UnFollow(Forum forum) { if (forum == null) { throw new ArgumentNullException("forum"); } User user = this.userProvider.CurrentUser; if (user == null) { throw new NoAuthenticatedUserFoundException(); } FollowForum ff = this.forumRepo.ByUserAndForum(forum, user); if (ff != null) { this.forumRepo.Delete(ff); } }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <param name="forum"></param> /// <returns>null, if the user does can not access the forum</returns> public ForumTracker GetTrackingInfo(User user, Forum forum) { if (user != null) { throw new ArgumentNullException("user"); } if (forum != null) { throw new ArgumentNullException("forum"); } // Can the user access the forum? if (this.permService.HasAccess(user, forum)) { return null; } return this.ftRepo.ByUserAndForum(user, forum); }
/// <summary> /// Method for creating a new topic. /// </summary> /// <param name="forum">The parent forum of the topic.</param> /// <param name="subject">The subject of the topic.</param> /// <param name="message">The content/message of the topic.</param> /// <param name="type">The type of the topic </param> /// <param name="customPropties"></param> /// <returns>The newly created topic.</returns> public Topic Create(Forum forum, String subject, String message, TopicType type, IDictionary<String, Object> customPropties = null) { if (forum == null) { throw new ArgumentNullException("forum"); } if (String.IsNullOrWhiteSpace(subject)) { throw new ArgumentNullException("subject"); } if (String.IsNullOrWhiteSpace(message)) { throw new ArgumentNullException("message"); } forum = this.forumRepo.Read(f => f.Id == forum.Id); if (forum == null) { throw new ArgumentException("forum does not exist"); } this.logger.WriteFormat("Create called on TopicService, subject: {0}, forum id: {1}", subject, forum.Id); AccessFlag flag = this.permService.GetAccessFlag(this.userProvider.CurrentUser, forum); if ((flag & AccessFlag.Create) != AccessFlag.Create) { this.logger.WriteFormat("User does not have permissions to create a new topic in forum {1}, subject: {0}", subject, forum.Id); throw new PermissionException("topic, create"); } if (type != TopicType.Regular && (flag & AccessFlag.Priority) != AccessFlag.Priority) { this.logger.WriteFormat("User does not have permissions to set topic type on new topic in forum {1}, subject: {0}", subject, forum.Id); throw new PermissionException("topic, type"); } Topic t = new Topic { Author = this.userProvider.CurrentUser, AuthorId = this.userProvider.CurrentUser.Id, Changed = DateTime.UtcNow, Created = DateTime.UtcNow, Editor = this.userProvider.CurrentUser, EditorId = this.userProvider.CurrentUser.Id, Forum = forum, ForumId = forum.Id, Message = message, State = TopicState.None, Subject = subject, Type = type }; t.SetCustomProperties(customPropties); this.topicRepo.Create(t); this.logger.WriteFormat("Topic created in TopicService, Id: {0}", t.Id); this.eventPublisher.Publish<TopicCreated>(new TopicCreated { Topic = t }); this.logger.WriteFormat("Create events in TopicService fired, Id: {0}", t.Id); return t; }
public Result Store(Forum forum) { SqlConnection conn = null; try { using (TransactionScope scope = new TransactionScope()) { conn = (SqlConnection)DatabaseManager.DatabaseEngine.GetConnection(); SqlCommand cmd = new SqlCommand("Forum_Store", conn); cmd.CommandType = CommandType.StoredProcedure; SqlParameter prm = new SqlParameter("@ForumID", forum.ForumID); prm.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(prm); cmd.Parameters.Add(NewSqlParameter("@ForumCategoryID", forum.ForumCategoryID, SqlDbType.BigInt)); cmd.Parameters.Add(NewSqlParameter("@ForumCode", forum.ForumCode, SqlDbType.NVarChar)); cmd.Parameters.Add(NewSqlParameter("@Name", forum.Name, SqlDbType.NVarChar)); cmd.Parameters.Add(NewSqlParameter("@Description", forum.Description, SqlDbType.NVarChar)); cmd.Parameters.Add(NewSqlParameter("@URLToken", forum.URLToken, SqlDbType.NVarChar)); cmd.Parameters.Add(NewSqlParameter("@DateCreated", forum.DateCreated, SqlDbType.DateTime)); cmd.Parameters.Add(NewSqlParameter("@Rank", forum.Rank, SqlDbType.Int)); cmd.Parameters.Add(NewSqlParameter("@PostWriteAccess", forum.PostWriteAccess, SqlDbType.SmallInt)); cmd.Parameters.Add(NewSqlParameter("@ReplyWriteAccess", forum.ReplyWriteAccess, SqlDbType.SmallInt)); cmd.Parameters.Add(NewSqlParameter("@ReadAccess", forum.ReadAccess, SqlDbType.SmallInt)); cmd.Parameters.Add(NewSqlParameter("@PostWriteAccessRoleID", forum.PostWriteAccessRoleID, SqlDbType.BigInt)); cmd.Parameters.Add(NewSqlParameter("@ReplyWriteAccessRoleID", forum.ReplyWriteAccessRoleID, SqlDbType.BigInt)); cmd.Parameters.Add(NewSqlParameter("@ReadAccessRoleID", forum.ReadAccessRoleID, SqlDbType.BigInt)); cmd.Parameters.Add(NewSqlParameter("@ModeratorRoleID", forum.ModeratorRoleID, SqlDbType.BigInt)); cmd.Parameters.Add(NewSqlParameter("@MarkupLevel", forum.MarkupLevel, SqlDbType.SmallInt)); cmd.Parameters.Add(NewSqlParameter("@ShowSignatures", forum.ShowSignatures, SqlDbType.Bit)); cmd.Parameters.Add(NewSqlParameter("@AllowImagesInMessages", forum.AllowImagesInMessages, SqlDbType.Bit)); cmd.Parameters.Add(NewSqlParameter("@AllowImagesInSignatures", forum.AllowImagesInSignatures, SqlDbType.Bit)); cmd.Parameters.Add(NewSqlParameter("@RequireModeration", forum.RequireModeration, SqlDbType.Bit)); cmd.Parameters.Add(NewSqlParameter("@AllowVoting", forum.AllowVoting, SqlDbType.Bit)); cmd.Parameters.Add(NewSqlParameter("@TopicDisplayOrder", forum.TopicDisplayOrder, SqlDbType.SmallInt)); cmd.Parameters.Add(NewSqlParameter("@Locked", forum.Locked, SqlDbType.Bit)); cmd.ExecuteNonQuery(); forum.ForumID = (long)prm.Value; scope.Complete(); } } catch (Exception ex) { return new Result(ex.Message); } finally { DatabaseManager.DatabaseEngine.ReleaseConnection(conn); } return new Result(); }
public void Follow(Forum forum) { if (forum == null) { throw new ArgumentNullException("forum"); } User user = this.userProvider.CurrentUser; if (user == null) { throw new NoAuthenticatedUserFoundException(); } // TODO: Permissions?? if (this.forumRepo.ByUserAndForum(forum, user) == null) { this.forumRepo.Create(new FollowForum { ForumId = forum.Id, UserId = user.Id }); } }
public void UpdateForumTracking(User user, Forum forum) { if (this.permService.HasAccess(user, forum)) { ForumTracker ft = this.GetTrackingInfo(user, forum); if (ft == null) { this.ftRepo.Create(new ForumTracker { ForumId = forum.Id, UserId = user.Id, LastViewed = DateTime.UtcNow }); } else { ft.LastViewed = DateTime.UtcNow; this.ftRepo.Update(ft); } } }
protected void CreateForumBtn_Click(object sender, EventArgs e) { Forum forum = new Forum(); forum.Name = Request.Form["forumname"]; forum.ParentId = Util.GetIntFromString(Request.Form["parentid"]); forum.RewriteName = Request.Form["rewritename"]; forum.AllowBbcode = (Request.Form["allowbbcode"] == "on") ? 1 : 0; forum.AllowImgcode = (Request.Form["allowimg"] == "on") ? 1 : 0; forum.AllowSmilies = (Request.Form["allowsmilies"] == "on") ? 1 : 0; forum.Description = Request.Form["forumdescription"]; forum.Moderators = Request.Form["moderlist"]; forum.ModNewPosts = (Request.Form["modnewposts"] == "on") ? 1 : 0; forum.SeoKeywords = Request.Form["seokey"]; forum.Status = (Request.Form["status"] == "on") ? 1 : 0; ds.ForumCreate(forum); msg = "创建成功!"; }
/// <summary> /// ������ /// </summary> /// <param name="orginalPost">���۱�</param> /// <param name="currentForum">�Ҽ�����</param> /// <param name="description">����</param> public Thread(Post orginalPost, Forum currentForum, string description) { if (orginalPost == null) throw new ArgumentNullException("orginalPost", "��Ÿ�� ������, ���۱� ������ �����ؾ� �մϴ�."); if (currentForum == null) throw new ArgumentNullException("currentForum", "��Ÿ�� ������, �Ҽ������� �����Ǿ�� �մϴ�."); // TODO : ORM �����, �����Ǿ�� �մϴ�. Id = Guid.NewGuid(); OriginalPost = orginalPost; CurrentForum = currentForum; Description = description; CreateDate = DateTime.Now; UpdateDate = DateTime.Now; }
/// <summary> /// 确定提交按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btSubmitSubject_Click(object sender, EventArgs e) { Forum thisForum = new Forum(); Search search = new Search(); SubjectInfo subject = new SubjectInfo(); Teacher t = new Teacher(); if (Session["UserName"] != null) { //课程名 subject.StrCourseName = course; //提交时间 subject.DtReleaseTime = DateTime.Now; //提交内容 subject.StrContents = tbxSubjectContent.Text.Replace("\r\n", "<br/>"); //用户名 if (Convert.ToString(Session["Type"]) == "Student") { subject.StrReleasePsnName = search.GetStudentByUsername(Convert.ToString(Session["UserName"])).StrStudentName; } else { subject.StrReleasePsnName = t.GetTeacherByUserName(Convert.ToString(Session["UserName"])).StrTeacherName; } //主题 subject.StrTheme = subjectname.Text.Trim(); if (thisForum.AddSubeject(subject)) { //Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert","<script>alert('发表成功!')</script>"); Response.Redirect("SubjectList.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('发表失败!')</script>"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('您还未登录!')</script>"); //胡媛媛添加,当匿名用户添加留言时清空内容,2009-10-30 subjectname.Text = null; tbxSubjectContent.Text = null; } }
protected void btnAdd_Click(object sender, EventArgs e) { Forum f = new Forum(); if (!string.IsNullOrEmpty(txtForumName.Text.Trim())) { int cateid; int.TryParse(DropDownListCate.SelectedValue, out cateid); if (cateid > 0) { f.CateID = cateid; f.ForumName = txtForumName.Text.Trim(); f.ForumNameSlug = LanguageConvert.GenerateDesc(txtForumName.Text.Trim()); f.Order = 0; f.Active = true; ForumDA.Insert(f); mess = "Thêm Forum thành công."; GridView1.DataBind(); } } }
public ActionResult Save(Forum entity) { if (entity.ID == Guid.Empty) { entity.ID = Guid.NewGuid(); this.ForumManager.Save(entity); } else { var model = this.ForumManager.Get(entity.ID); model.Name = entity.Name; model.NameEn = entity.NameEn; model.OrderNo = entity.OrderNo; model.IsEnabled = entity.IsEnabled; this.ForumManager.Update(model); } return Json(new { IsSuccess = true, Message = "保存成功" }, "text/html", JsonRequestBehavior.AllowGet); }
public void BindData() { hlHome.NavigateUrl = CommonHelper.GetStoreLocation(); hlForumsHome.NavigateUrl = SEOHelper.GetForumMainURL(); //topic ForumTopic forumTopic = ForumManager.GetTopicByID(this.ForumTopicID); if (forumTopic != null) { hlForumTopic.NavigateUrl = SEOHelper.GetForumTopicURL(forumTopic.ForumTopicID); hlForumTopic.Text = Server.HtmlEncode(forumTopic.Subject); } else { phForumTopic.Visible = false; } //forum Forum forum = null; if (forumTopic != null) { forum = ForumManager.GetForumByID(forumTopic.ForumID); } else { forum = ForumManager.GetForumByID(this.ForumID); } if (forum != null) { hlForum.NavigateUrl = SEOHelper.GetForumURL(forum); hlForum.Text = Server.HtmlEncode(forum.Name); } else { phForum.Visible = false; } //forum group ForumGroup forumGroup = null; if (forum != null) { forumGroup = ForumManager.GetForumGroupByID(forum.ForumGroupID); } else { forumGroup = ForumManager.GetForumGroupByID(this.ForumGroupID); } if (forumGroup != null) { hlForumGroup.NavigateUrl = SEOHelper.GetForumGroupURL(forumGroup); hlForumGroup.Text = Server.HtmlEncode(forumGroup.Name); } else { phForumTopic.Visible = false; } }
public IEnumerable <Post> GetFilteredPosts(Forum forum, string searchQuery) { return(string.IsNullOrEmpty(searchQuery) ? forum.Posts : forum.Posts.Where(post => post.Title.ToLower(CultureInfo.CurrentCulture).Contains(searchQuery) || post.Content.ToLower(CultureInfo.CurrentCulture).Contains(searchQuery))); }
/// <summary> /// Creates the text for the "Last Post" information on a forum listing. /// Detects user permissions and disables links if they have none. /// </summary> /// <param name="row">Current data row</param> /// <returns>Formatted "Last Post" text</returns> protected string FormatLastPost(System.Data.DataRow row) { if (row["RemoteURL"] != DBNull.Value) { return("-"); } int ForumID = Convert.ToInt32(row["ForumID"]); // defaults to "no posts" text string strTemp = ForumPage.GetText("NO_POSTS"); if (!row.IsNull("LastPosted")) { strTemp = ForumPage.GetThemeContents("ICONS", (DateTime.Parse(Convert.ToString(row["LastPosted"])) > Mession.LastVisit) ? "ICON_NEWEST" : "ICON_LATEST"); if (int.Parse(row["ReadAccess"].ToString()) > 0) { strTemp = String.Format("{0}<br/>{1}<br/>{2} <a title=\"{4}\" href=\"{5}\"><img src=\"{3}\"></a>", ForumPage.FormatDateTimeTopic((DateTime)row["LastPosted"]), String.Format(ForumPage.GetText("in"), String.Format("<a href=\"{0}\">{1}</a>", Forum.GetLink(Pages.posts, "t={0}", row["LastTopicID"]), Truncate(Utils.BadWordReplace(row["LastTopicName"].ToString()), 50))), String.Format(ForumPage.GetText("by"), String.Format("<a href=\"{0}\">{1}</a>", OrionGlobals.resolveBase(string.Format("userinfo.aspx?id={0}", row["LastUserID"])), BBCode.EncodeHTML(row["LastUser"].ToString()))), strTemp, ForumPage.GetText("GO_LAST_POST"), Forum.GetLink(Pages.posts, "m={0}#{0}", row["LastMessageID"]) ); } else { // no access to this forum... disable links strTemp = String.Format("{0}<br/>{1}<br/>{2}", ForumPage.FormatDateTimeTopic((DateTime)row["LastPosted"]), String.Format(ForumPage.GetText("in"), String.Format("{0}", Truncate(row["LastTopicName"].ToString(), 50))), String.Format(ForumPage.GetText("by"), String.Format("<a href=\"{0}\">{1}</a>", OrionGlobals.resolveBase(string.Format("userinfo.aspx?id={0}", row["LastUserID"])), row["LastUser"])) ); } } return(strTemp); }
public ForumPermissionContext GetPermissionContext(Forum forum, User user) { return(GetPermissionContext(forum, user, null)); }
private void SaveQuickReply() { int iFloodInterval = MainSettings.FloodInterval; if (iFloodInterval > 0) { UserProfileController upc = new UserProfileController(); UserProfileInfo upi = upc.Profiles_Get(SiteId, InstanceId, this.UserId); if (upi != null) { if (SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Second, upi.DateLastPost, DateTime.Now) < iFloodInterval) { Controls.InfoMessage im = new Controls.InfoMessage(); im.Message = "<div class=\"afmessage\">" + string.Format(Utilities.GetSharedResource("[RESX:Error:FloodControl]"), iFloodInterval) + "</div>"; plhMessage.Controls.Add(im); return; } } } //TODO: Fix for anon //If Not Current.Request.IsAuthenticated Then // If Not ctlCaptcha.IsValid Or txtUserName.Value = "" Then // Exit Sub // End If //End If //Dim ui As New UserProfileInfo //If UserId > 0 Then // Dim upc As New UserProfileController // ui = upc.Profiles_Get(PortalId, ForumModuleId, UserId) //Else // ui.TopicCount = 0 // ui.ReplyCount = 0 // ui.RewardPoints = 0 // ui.IsMod = False // ui.TrustLevel = -1 //End If ForumController fc = new ForumController(); Forum forumInfo = fc.Forums_Get(SiteId, InstanceId, ForumId, this.UserId, true, false, TopicId); bool UserIsTrusted = false; UserIsTrusted = Utilities.IsTrusted((int)forumInfo.DefaultTrustValue, ControlConfig.User.TrustLevel, Permissions.HasPerm(forumInfo.Security.Trust, ForumUser.UserRoles), forumInfo.AutoTrustLevel, ControlConfig.User.PostCount); bool isApproved = false; isApproved = Convert.ToBoolean(((forumInfo.IsModerated == true) ? false : true)); if (UserIsTrusted || Permissions.HasPerm(forumInfo.Security.ModApprove, ForumUser.UserRoles)) { isApproved = true; } ReplyInfo ri = new ReplyInfo(); Data.Topics db = new Data.Topics(); //im rc As New ReplyController int ReplyId = -1; string sUsername = string.Empty; if (HttpContext.Current.Request.IsAuthenticated) { sUsername = ControlConfig.User.DisplayName; } else { sUsername = Utilities.CleanString(SiteId, txtUserName.Value, false, EditorTypes.TEXTBOX, true, false, InstanceId, ThemePath, false); } string sBody = string.Empty; //TODO: Check for allowhtml bool allowHtml = false; //If forumInfo.AllowHTML Then // allowHtml = isHTMLPermitted(forumInfo.EditorPermittedUsers, IsTrusted, forumInfo.Security.ModEdit) //End If sBody = Utilities.CleanString(SiteId, HttpContext.Current.Request.Form["txtBody"], allowHtml, EditorTypes.TEXTBOX, forumInfo.UseFilter, forumInfo.AllowScript, InstanceId, ThemePath, forumInfo.AllowEmoticons); DateTime createDate = DateTime.Now; ri.TopicId = TopicId; ri.ReplyToId = TopicId; ri.Content.AuthorId = UserId; ri.Content.AuthorName = sUsername; ri.Content.Body = sBody; ri.Content.DateCreated = createDate; ri.Content.DateUpdated = createDate; ri.Content.IsDeleted = false; ri.Content.Subject = Subject; ri.Content.Summary = string.Empty; ri.IsApproved = isApproved; ri.IsDeleted = false; ri.Content.IPAddress = HttpContext.Current.Request.UserHostAddress; ReplyId = db.Reply_Save(ri); //Check if is subscribed if (HttpContext.Current.Request.Params["chkSubscribe"] != null) { if (HttpContext.Current.Request.Params["chkSubscribe"] == "1" && UserId > 0) { if (!(Subscriptions.IsSubscribed(SiteId, InstanceId, ForumId, TopicId, SubscriptionTypes.Instant, UserId))) { //TODO: Fix Subscriptions //Dim sc As New Data.Tracking //sc.Subscription_Update(SiteId, InstanceId, ForumId, TopicId, 1, UserId) } } } if (isApproved) { //Send Subscriptions try { string sURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); Subscriptions.SendSubscriptions(SiteId, InstanceId, PageId, ForumId, TopicId, ReplyId, UserId); #if !SKU_LITE try { Social oSocial = new Social(); oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", sURL, Subject, sBody); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } #endif } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } //Redirect to show post string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); HttpContext.Current.Response.Redirect(fullURL, false); } else if (isApproved == false) { Email oEmail = new Email(); oEmail.SendEmailToModerators(forumInfo.ModNotifyTemplateId, SiteId, ForumId, ri.TopicId, ReplyId, InstanceId, PageId, string.Empty); string[] Params = { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=confirmaction", "afmsg=pendingmod", ParamKeys.TopicId + "=" + TopicId }; HttpContext.Current.Response.Redirect(Utilities.NavigateUrl(PageId, "", Params), false); } else { string fullURL = Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ForumId + "=" + ForumId, ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.TopicId + "=" + TopicId, ParamKeys.ContentJumpId + "=" + ReplyId }); #if !SKU_LITE try { Modules.ActiveForums.Social oSocial = new Modules.ActiveForums.Social(); oSocial.AddForumItemToJournal(SiteId, InstanceId, UserId, "forumreply", fullURL, Subject, sBody); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); } #endif HttpContext.Current.Response.Redirect(fullURL, false); } //End If }
public void AddForum(Forum forum) { _forum = forum; }
public ForumPermissionContext GetPermissionContext(Forum forum, User user, Topic topic) { var context = new ForumPermissionContext { DenialReason = string.Empty }; var viewRestrictionRoles = _forumRepository.GetForumViewRoles(forum.ForumID); var postRestrictionRoles = _forumRepository.GetForumPostRoles(forum.ForumID); // view if (viewRestrictionRoles.Count == 0) { context.UserCanView = true; } else { context.UserCanView = false; if (user != null && viewRestrictionRoles.Where(user.IsInRole).Any()) { context.UserCanView = true; } } // post if (user == null || !context.UserCanView) { context.UserCanPost = false; context.DenialReason = Resources.LoginToPost; } else if (!user.IsApproved) { context.DenialReason += "You can't post until you have verified your account. "; context.UserCanPost = false; } else { if (postRestrictionRoles.Count == 0) { context.UserCanPost = true; } else { if (postRestrictionRoles.Where(user.IsInRole).Any()) { context.UserCanPost = true; } else { context.DenialReason += Resources.ForumNoPost + ". "; context.UserCanPost = false; } } } if (topic != null && topic.IsClosed) { context.UserCanPost = false; context.DenialReason = Resources.Closed + ". "; } if (topic != null && topic.IsDeleted) { if (user == null || !user.IsInRole(PermanentRoles.Moderator)) { context.UserCanView = false; } context.DenialReason += "Topic is deleted. "; } if (forum.IsArchived) { context.UserCanPost = false; context.DenialReason += Resources.Archived + ". "; } // moderate context.UserCanModerate = false; if (user != null && (user.IsInRole(PermanentRoles.Admin) || user.IsInRole(PermanentRoles.Moderator))) { context.UserCanModerate = true; } return(context); }
public void Add(Forum t) { throw new NotImplementedException(); }
public Task AddAsync(Forum t) { throw new NotImplementedException(); }
//forums public static ForumModel ToModel(this Forum entity) { return(Mapper.Map <Forum, ForumModel>(entity)); }
public void NotifyForumUpdate(Forum forum) { _forumsHubContext.Clients.All.InvokeAsync("notifyForumUpdate", new { forum.ForumID, TopicCount = forum.TopicCount.ToString("N0"), PostCount = forum.PostCount.ToString("N0"), LastPostTime = _timeFormattingService.GetFormattedTime(forum.LastPostTime, null), forum.LastPostName, Utc = forum.LastPostTime.ToString("o"), Image = "NewIndicator.png" }); }
public async Task Should_delete_forum_and_reorder_other_forums_and_add_event() { var options = Shared.CreateContextOptions(); var categoryId = Guid.NewGuid(); var siteId = Guid.NewGuid(); var category = new Category(categoryId, siteId, "Category", 1, Guid.NewGuid()); var forum1 = new Forum(categoryId, "Forum 1", "my-forum-1", "Forum 1", 1); var forum2 = new Forum(categoryId, "Forum 2", "my-forum-2", "Forum 2", 2); var forum3 = new Forum(categoryId, "Forum 3", "my-forum-3", "Forum 3", 3); var forum4 = new Forum(categoryId, "Forum 4", "my-forum-4", "Forum 4", 4); using (var dbContext = new AtlesDbContext(options)) { dbContext.Categories.Add(category); dbContext.Forums.Add(forum1); dbContext.Forums.Add(forum2); dbContext.Forums.Add(forum3); dbContext.Forums.Add(forum4); await dbContext.SaveChangesAsync(); } using (var dbContext = new AtlesDbContext(options)) { var command = Fixture.Build <DeleteForum>() .With(x => x.SiteId, siteId) .With(x => x.Id, forum2.Id) .Create(); var cacheManager = new Mock <ICacheManager>(); var createValidator = new Mock <IValidator <CreateForum> >(); var updateValidator = new Mock <IValidator <UpdateForum> >(); var sut = new ForumService(dbContext, cacheManager.Object, createValidator.Object, updateValidator.Object); await sut.DeleteAsync(command); var forum1Reordered = await dbContext.Forums.FirstOrDefaultAsync(x => x.Id == forum1.Id); var forum2Deleted = await dbContext.Forums.FirstOrDefaultAsync(x => x.Id == forum2.Id); var forum3Reordered = await dbContext.Forums.FirstOrDefaultAsync(x => x.Id == forum3.Id); var forum4Reordered = await dbContext.Forums.FirstOrDefaultAsync(x => x.Id == forum4.Id); var forum1Event = await dbContext.Events.FirstOrDefaultAsync(x => x.TargetId == forum1.Id); var forum2Event = await dbContext.Events.FirstOrDefaultAsync(x => x.TargetId == forum2.Id); var forum3Event = await dbContext.Events.FirstOrDefaultAsync(x => x.TargetId == forum3.Id); var forum4Event = await dbContext.Events.FirstOrDefaultAsync(x => x.TargetId == forum4.Id); Assert.AreEqual(forum1.SortOrder, forum1Reordered.SortOrder); Assert.AreEqual(ForumStatusType.Deleted, forum2Deleted.Status); Assert.AreEqual(forum2.SortOrder, forum3Reordered.SortOrder); Assert.AreEqual(forum3.SortOrder, forum4Reordered.SortOrder); Assert.NotNull(forum1Event); Assert.NotNull(forum2Event); Assert.NotNull(forum3Event); Assert.NotNull(forum4Event); } }
public void Can_save_and_load_forumtopic() { var customer = GetTestCustomer(); var customerFromDb = SaveAndLoadEntity(customer); customerFromDb.ShouldNotBeNull(); var forumGroup = new ForumGroup { Name = "Forum Group 1", Description = "Forum Group 1 Description", DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; var forumGroupFromDb = SaveAndLoadEntity(forumGroup); forumGroupFromDb.ShouldNotBeNull(); forumGroupFromDb.Name.ShouldEqual("Forum Group 1"); forumGroupFromDb.Description.ShouldEqual("Forum Group 1 Description"); forumGroupFromDb.DisplayOrder.ShouldEqual(1); var forum = new Forum { ForumGroup = forumGroupFromDb, Name = "Forum 1", Description = "Forum 1 Description", ForumGroupId = forumGroupFromDb.Id, DisplayOrder = 10, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, NumPosts = 25, NumTopics = 15 }; forumGroup.Forums.Add(forum); var forumFromDb = SaveAndLoadEntity(forum); forumFromDb.ShouldNotBeNull(); forumFromDb.Name.ShouldEqual("Forum 1"); forumFromDb.Description.ShouldEqual("Forum 1 Description"); forumFromDb.DisplayOrder.ShouldEqual(10); forumFromDb.NumTopics.ShouldEqual(15); forumFromDb.NumPosts.ShouldEqual(25); forumFromDb.ForumGroupId.ShouldEqual(forumGroupFromDb.Id); var forumTopic = new ForumTopic { Subject = "Forum Topic 1", Forum = forumFromDb, ForumId = forumFromDb.Id, TopicTypeId = (int)ForumTopicType.Sticky, Views = 123, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, NumPosts = 100, CustomerId = customerFromDb.Id, Published = true }; var forumTopicFromDb = SaveAndLoadEntity(forumTopic); forumTopicFromDb.ShouldNotBeNull(); forumTopicFromDb.Subject.ShouldEqual("Forum Topic 1"); forumTopicFromDb.Views.ShouldEqual(123); forumTopicFromDb.NumPosts.ShouldEqual(100); forumTopicFromDb.TopicTypeId.ShouldEqual((int)ForumTopicType.Sticky); forumTopicFromDb.ForumId.ShouldEqual(forumFromDb.Id); }
public IEnumerable <Post> GetFilteredPosts(Forum forum, string searchQuery) { return(String.IsNullOrEmpty(searchQuery) ? forum.Posts : forum.Posts.Where(post => post.Title.Contains(searchQuery) || post.Content.Contains(searchQuery))); }
private static bool LoadDiscussions(Forum forum, int startRow, int endRow) { bool res = false; try { forum.Clear(); string query = "MessagesList"; using (SqlConnection cnn = new SqlConnection(Configurations.ConnectionString)) { using (SqlCommand cmd = new SqlCommand(query, cnn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@ForumId", SqlDbType.SmallInt, 2, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Default, forum.ForumId)); cmd.Parameters.Add(new SqlParameter("@PageId", forum.PageId)); cmd.Parameters.Add(new SqlParameter("@StartRow", startRow)); cmd.Parameters.Add(new SqlParameter("@EndRow", endRow)); foreach (SqlParameter Parameter in cmd.Parameters) { if (Parameter.Value == null) { Parameter.Value = DBNull.Value; } } cnn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader != null && reader.HasRows) { // Every message belongs to a discussion in a forum Discussion discussion = null; DiscussionMessage message = null; DiscussionMessage parent = null; Int32 parentId = 0; Int32 discussionId = 0; Int32 messageId = 0; while (reader.Read()) { message = null; discussionId = Repository.Utils.Convert.ToInt32(reader["DiscussionId"]); parentId = Repository.Utils.Convert.ToInt32(reader["ParentId"]); messageId = Repository.Utils.Convert.ToInt32(reader["MessageId"]); // Update current discussion if (discussion != null) { // This message is in current discussion if (discussionId == discussion.Id) { // Do nothing. Current discussion is OK! } else { // This is a message inside a discussion // Or a root (a discussion) record so // Let's find discussion by it's id discussion = forum.FindDiscussion(discussionId); } } // If discussion not found, create and add it if (discussion == null) { discussion = new Discussion(discussionId, forum); forum.Add(discussion); if (messageId == discussionId) { // If this record is a discussion message message = discussion; } else { // This is a message inside a discussion that does not exist?! // An empty discussion created. Maybe filled later on // Let next step handle message related stuff } } // This is a message with an unknown parent inside a known discussion if (parentId <= 0 && message == null) { // Add it to the root of the discussion message = new DiscussionMessage(); discussion.Replies.Add(message); message.Parent = discussion; } else if (parentId > 0)// A new message { message = new DiscussionMessage(); // Find parent if (parent == null || parent.Id != parentId) { parent = discussion.FindMessage(parentId); } // Parent not found? Add it to the root of discussion if (parent == null) { parent = discussion; } parent.Replies.Add(message); message.Parent = parent; } message.Discussion = discussion; // At this point message must be at the right position // Try load it's data. // load message message.Id = messageId; message.IsVisible = Repository.Utils.Convert.ToBool(reader["IsVisible"]); message.IsAbuse = Repository.Utils.Convert.ToInt16(reader["IsAbuse"]); message.Type = (Repository.Memory.Forums.MessageTypes)Repository.Utils.Convert.ToInt16(reader["MessageType"]); message.InsertTime = Repository.Utils.Convert.ToDateTime(reader["InsertTime"]); message.UpdateTime = Repository.Utils.Convert.ToDateTime(reader["UpdateTime"]); message.UserId = Repository.Utils.Convert.ToInt64(reader["UserId"]); message.UserName = Repository.Utils.Convert.ToString(reader["UserName"]); message.UserIp = Repository.Utils.Convert.ToString(reader["UserIp"]); message.Subject = Repository.Utils.Convert.ToString(reader["MessageSubject"]); message.Body = Repository.Utils.Convert.ToString(reader["MessageBody"]); } reader.NextResult(); if (reader.Read()) { forum.TotalMessageCount = Repository.Utils.Convert.ToInt32(reader["TotalRows"]); } res = true; } cnn.Close(); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(string.Format("Exception:{0}", ex.ToString())); } return(res); }
private void AddUser_Click(object sender, System.EventArgs e) { Forum.Redirect(Pages.mod_forumuser, "f={0}", PageForumID); }