public void ComplainsIfNoTestIsRunning() { var polls = new Polls(); var result = polls.ProcessCommand("vote 1"); Assert.AreEqual("The poll is not currently running. Use `poll start` to start a poll.", result.Responses.Single().Message); }
public void Update(Polls polls, int inx) { this.polls = polls; this.inx = inx; StatusLabel.Text = string.Format("{0}: {1}표", polls.Options[inx].Name, polls.Options[inx].Count); }
protected void Page_Load(object sender, EventArgs e) { if (PollId == 0) { return; } PollFormView.Visible = (Config.ActivePoll > 0 || PollId > 0); TopicInfo topic = (TopicInfo)Post; var polls = new List <PollInfo> { Polls.GetTopicPoll(PollId) }; PollFormView.DataSource = polls; PollFormView.DataBind(); Literal user = (Literal)PollFormView.FindControl("postedBy"); if (user != null) { user.Text = "Asked by " + topic.AuthorProfilePopup; } buttonBar.Post = Post; //popuplink.Text = String.Format("<a href='{0}' title='{1}'>{2}</a>", topic.AuthorProfileLink, String.Format(Resources.webResources.lblViewProfile,topic.AuthorName), topic.AuthorName); //AuthorProfile.AuthorId = topic.AuthorId; msgBody.Text = topic.Message.ReplaceNoParseTags().ParseVideoTags().ParseWebUrls(); }
private void SimulatePoll(int polls, int options) { for (int i = 1; i <= polls; i++) { Polls.Add(new Poll { Title = "Poll " + i, Date = DateTime.Now.Date.ToString().Substring(0, 9), Options = new ObservableCollection <Poll.Option>() }); } for (int i = 1; i <= Polls.Count; i++) { for (int j = 1; j <= options; j++) { Polls[i - 1].Options.Add(new Poll.Option() { Text = "Poll " + i + " Option " + j }); } } for (int i = 1; i <= polls; i++) { if (i > 3) { Polls[i - 1].isActive = true; } } }
private static void CreatePoll(string topicPoll, int topicid) { var poll = new Regex(@"(?<poll>\[poll=\x22(?<question>.+?)\x22](?<answers>.+?)\[\/poll])", RegexOptions.Singleline); var answers = new Regex(@"\[\*=(?<sort>[0-9]+)](?<answer>.+?)\[/\*]", RegexOptions.Singleline | RegexOptions.ExplicitCapture); string question = ""; var s = new SortedList <int, string>(); MatchCollection mc = poll.Matches(topicPoll); if (mc.Count > 0) { foreach (Match m in mc) { question = m.Groups["question"].Value; string answer = m.Groups["answers"].Value; MatchCollection ans = answers.Matches(answer); foreach (Match match in ans) { s.Add(Convert.ToInt32(match.Groups["sort"].Value), match.Groups["answer"].Value); } } Polls.AddTopicPoll(topicid, question, s); } }
public override void OnActionExecuting(ActionExecutingContext context) { long pollId = (long)context.ActionArguments.First().Value; _poll = _db.Polls.Find(pollId); if (_poll == null) { context.Result = Content("Poll not found"); return; } if (_poll.Status != (long)PollStatus.Published) { TempData["ErrorMessage"] = "You can't vote on not published poll!"; context.Result = RedirectToAction("Show", "Polls"); return; } // load poll choices for later unsafe _pollChoices = _db.PollChoices.Where(choice => choice.PollId == pollId).ToArray(); _ip = HttpContext.Connection.RemoteIpAddress.ToString(); _ua = context.HttpContext.Request.Headers["User-Agent"]; base.OnActionExecuting(context); }
public ActionResult Add(PollAddModel model) { Polls.AddPoll(model.Topic, model.Description, model.AllowMultiple, model.HideResultsUntilFinished, model.HideVoters, model.EndDate, model.EndTime, model.Options, MemberSession.GetMemberId()); return(RedirectToAction("AllPolls")); }
public async Task <IActionResult> CreatePoll(Polls model) { if (!authorize.AuthorizeUser("admin")) { return(RedirectToAction("login", "user")); } if (ModelState.IsValid) { using (client) { client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data")); //HTTP Get HttpResponseMessage response = await client.PostAsJsonAsync( "api/polls/CreatePollApi/", model); if (response.IsSuccessStatusCode == true) { TempData["msg"] = "Poll Created Successfully"; return(RedirectToAction("createpoll", "admin")); } return(Content("Some Internal Error Occur")); } } return(View(model)); }
public Polls ToPolls(long pollId, long memberId) { Polls entity = new Polls() { AllowMultipleSelections = this.AllowMultipleSelections ? 1 : 0, HideLink2pollOwner = this.HideLink2pollOwner ? 1 : 0, HideVotingResults = this.HideVotingResults ? 1 : 0, ShowResultsWhenClosed = this.ShowResultsWhenClosed ? 1 : 0, IsClosedLabel = this.IsClosedLabel, PollTopicId = (long)this.PollTopicId, Question = this.Question, SeeResultsLabel = this.SeeResultsLabel, TextAbove = this.TextAbove, TextBelow = this.TextBelow, TotalVotesLabel = this.TotalVotesLabel, VoteButtonLabel = this.VoteButtonLabel, VotersLabel = this.VotersLabel, Status = (long)PollStatus.NotReady, Id = pollId, MemberId = memberId }; if (HasImage() && this.Image.ImageId > 0) { entity.ImageId = this.Image.ImageId; } return(entity); }
private void SetupForEditMessage() { string msg = String.Empty; //fetch original message from db switch (_type) { case "reply": ReplyInfo reply = Replies.GetReply(_recId); SubjectDiv.Visible = false; ForumDiv.Visible = false; msg = HttpUtility.HtmlDecode(reply.Message); break; case "topics": ForumDiv.Visible = (IsAdministrator || (_inModeratedList && !Config.RestrictModeratorMove)); ForumDropDown.SelectedValue = _thisTopic.ForumId.ToString(); SubjectDiv.Visible = true; tbxSubject.Text = HttpUtility.HtmlDecode(_thisTopic.Subject); string poll = ""; if (_thisTopic.PollId != null) { poll = Polls.GetTopicPollString(_thisTopic.PollId); } msg = poll + HttpUtility.HtmlDecode(_thisTopic.Message); break; } Message.Text = msg; }
public ActionResult Show(long pollId, [FromQuery] bool embed = false) { Polls poll = _db.Polls.Find(pollId); if (poll == null) { return(Content("Poll not found")); } if (poll.ImageId != null) { ViewData["PollImage"] = _db.PollImages.Find(poll.ImageId); } if (0 == poll.HideLink2pollOwner) { ViewData["PollCreator"] = _db.Users.Find(poll.MemberId); } if (poll.AllowMultipleSelections > 0) { ViewBag.UriForVote = string.Format("{0}://{1}/vote/multiple/{2}", Request.Scheme, Request.Host, poll.Id); ViewData["VotesCount"] = _db.PollVotes2.Count(v2 => v2.PollId == pollId); } else { long [] choices = _db.PollChoices.Where(c => c.PollId == pollId) .Select(c => c.Id) .ToArray(); ViewBag.UriForVote = string.Format("{0}://{1}/vote/single/{2}", Request.Scheme, Request.Host, poll.Id); ViewData["VotesCount"] = _db.PollVotes1.Count(v1 => choices.Contains(v1.PollChoiceId)); } if (poll.HideVotingResults > 0) { ViewData["ShouldSeeResults"] = false; } else if (poll.Status == (long)PollStatus.Closed) { ViewData["ShouldSeeResults"] = (poll.ShowResultsWhenClosed > 0); } else { ViewData["ShouldSeeResults"] = true; } ViewData["Choices"] = _db.GetPollChoices(pollId); if (embed) { ViewBag.UriForPoll = string.Format("{0}://{1}/polls/show/{2}", Request.Scheme, Request.Host, poll.Id); return(View("ShowEmbedded", poll)); } ViewData["PollTopic"] = _db.PollTopics.Find(poll.PollTopicId); return(View(poll)); }
public static PollsDTO PollsToDTO(Polls todoItem) => new PollsDTO { Id = todoItem.Id, QuestionId = todoItem.QuestionId, Poll = todoItem.Poll, Votes = todoItem.Votes };
public void CanCreateAPoll() { var polls = new Polls(); var result = polls.ProcessCommand("start poll"); Assert.AreEqual("Polling started. Use `poll add <some choice>` to add choices " + "and `vote 1` to vote for a particular option, then `poll finish` to show the results.", result.Responses.Single().Message); }
public static PollPercentageViewModel PollsToPercentage(Polls todoItem, int percentage) => new PollPercentageViewModel { Id = todoItem.Id, QuestionId = todoItem.QuestionId, Poll = todoItem.Poll, Votes = todoItem.Votes, Percentage = percentage };
public void ComplainsIfPollCreatedWhilePollIsRunning() { var polls = new Polls(); polls.ProcessCommand(new Command("poll-channel", "user", "start poll")); var result = polls.ProcessCommand(new Command("other-channel", "user", "start poll")); Assert.AreEqual("A poll is already running in poll-channel", result.Responses.Single().Message); }
public void CanAddOptionToPoll() { var polls = new Polls(); polls.ProcessCommand("poll start"); var result = polls.ProcessCommand("poll add some choice"); Assert.AreEqual("Choice added. Use `vote 1` to vote for it.", result.Responses.Single().Message); }
public void CanVoteForOption() { var polls = new Polls(); polls.ProcessCommand("poll start"); polls.ProcessCommand("poll add some choice"); var result = polls.ProcessCommand("vote 1"); Assert.AreEqual("Vote added for choice 1 (some choice). You can change your vote by voting for something else.", result.Responses.Single().Message); }
public ActionResult Results(long pollId) { Polls poll = _db.Polls.Find(pollId); if (poll == null) { return(Content("Poll not found")); } List <string> choices = null; if (poll.AllowMultipleSelections > 0) { PollChoices [] pollChoices = _db.PollChoices.Where(c => c.PollId == pollId) .ToArray(); string [] linesOfVotes = _db.PollVotes2.Where(v2 => v2.PollId == pollId) .Select(v2 => v2.PollChoices) .ToArray(); long [] votes = string.Join(",", linesOfVotes) .Split(',') .Select(choiceIdStr => long.Parse(choiceIdStr)) .ToArray(); choices = new List <string>(); foreach (var cho in pollChoices) { choices.Add( string.Format("{0} => {1}", cho.Choice, votes.Count(v => v == cho.Id) ) ); } } else { string sql = "SELECT id, poll_id, ordinal, choice, " + " (SELECT count(*) FROM poll_votes1 WHERE poll_votes1.poll_choice_id = poll_choices.id) AS image_id " + " FROM poll_choices " + " WHERE poll_id = {0}"; // HACK: ImagesId will hold the votes count choices = _db.PollChoices.FromSql(sql, pollId) .Select(cho => string.Format("{0} => {1}", cho.Choice, cho.ImageId)) .ToList(); } return(Content(string.Join("\n", choices))); }
/// <summary> /// Start the poll /// </summary> public void Start() { EssLang.Broadcast("POLL_STARTED", Name, Description); var thiz = this; lock (Polls) Polls.Add(Name, thiz); if (Duration > 0) { Task.Create() .Id("Poll Stop") .Delay(TimeSpan.FromSeconds(Duration)) .Action(() => { lock (Polls) { if (!Polls.ContainsKey(thiz.Name)) { return; } thiz.Stop(); } }) .Submit(); } if (!UEssentials.Config.EnablePollRunningMessage) { return; } var interval = UEssentials.Config.PollRunningMessageCooldown * 1000; Task.Create() .Id("Poll Running Message") .Interval(interval) .UseIntervalAsDelay() .Action(task => { lock (Polls) { if (!Polls.ContainsKey(thiz.Name)) { task.Cancel(); return; } EssLang.Broadcast("POLL_RUNNING", thiz.Name, thiz.Description, thiz.YesVotes, thiz.NoVotes); } }) .Submit(); }
/// <summary> /// Called on server response. /// </summary> protected void Handle_Vote_Response(string response, Handler_Type type) { if (response.Contains("500")) { Message.ShowMessage("Error interno del servidor."); return; } if (User.User_Info.Polls_Data.Exists(x => x.id == poll.Id)) { User.User_Info.Polls_Data.Find(x => x.id == poll.Id).response = temp_vote; } else { User.User_Info.Polls_Data.Add(new User.Vote_Data() { id = poll.Id, response = temp_vote }); } for (int x = 0; x < poll.Vote_Voters.Count; x++) { if (poll.Vote_Voters[x].Exists(a => a.Id == User.User_Info.Id)) { poll.Vote_Voters[x].Remove(poll.Vote_Voters[x].Find(a => a.Id == User.User_Info.Id)); } } poll.Vote_Voters[temp_vote].Add(User.User_Info); poll.Status = poll.Vote_Types[temp_vote]; poll.Selected_Option_Idx = temp_vote; List <Data_struct> polls = Polls.Data_List_Get(typeof(Polls)); for (int x = 0; x < polls.Count; x++) { if (polls[x].Id == poll.Id) { polls[x] = poll; Polls.Data_List_Set(typeof(Polls), polls); break; } } Message.ShowMessage("Base de datos actualizada con éxito."); if (this != null) { Show_Poll_Details(); Set_Interactable(true); } Database_Handler.Update_Unread(Handler_Type.polls); }
public IActionResult CreatePollApi([FromBody] Polls model) { if (ModelState.IsValid) { dbContext.calendar.Add(model.calendar); dbContext.polls.Add(model); dbContext.SaveChanges(); return(Ok()); } return(BadRequest(ModelState)); }
public static PollModel CheckUpdatePollState(PollModel pm) { if (pm.PollDetails.EndDate < DateTime.Now) { // pozivamo funkciju koja ce da updatuje bazu Polls.ClosePoll(pm.PollDetails.PollId); // menjamo vrednost propertija objekta pm.PollDetails.State = Enumerations.PollState.Zatvoreno; } return(pm); }
protected void ResultsDataListDataBinding(object sender, EventArgs e) { _totalVotes = Polls.GetTotalVotes(PollId); // Display the # of votes var totalVotesLabel = PollFormView.FindControl("TotalVotesLabel") as Label; if (totalVotesLabel != null) { totalVotesLabel.Text = string.Format("{0:d} votes...", _totalVotes); } }
public static List <PollModel> GetAllPollModels() { var polls = Polls.GetAllPolls(); var pollModels = new List <PollModel>(); foreach (var p in polls) { pollModels.Add(Load(p.PollId)); } return(pollModels); }
public ActionResult DeletPoll(int PollID) { using (ProjectJobEntities db = new ProjectJobEntities()) { Polls pollDetail = db.Polls.Find(PollID); db.Polls.Remove(pollDetail); db.SaveChanges(); var alertt = "ลบเสร็จสิ้น"; return(Json(alertt)); } }
/// <summary> /// Start the poll /// </summary> public void Start() { EssLang.POLL_STARTED.Broadcast(Name, Description); lock (Polls) Polls.Add(Name, this); var thiz = this; if (Duration > 0) { Tasks.New(task => { lock ( Polls ) { if (!Polls.ContainsKey(thiz.Name)) { return; } thiz.Stop(); } }).Delay(Duration * 1000).Go(); } if (!UEssentials.Config.EnablePollRunningMessage) { return; } var interval = UEssentials.Config.PollRunningMessageCooldown * 1000; Tasks.New(task => { lock ( Polls ) { if (!Polls.ContainsKey(thiz.Name)) { task.Cancel(); return; } EssLang.POLL_RUNNING.Broadcast( thiz.Name, thiz.Description, thiz.YesVotes, thiz.NoVotes ); } }).Interval(interval).Delay(interval).Go(); }
public Polls ParsePolls(JObject obj) { var polls = new Polls { EndDateTime = ParseTwitterDateTime(obj["end_datetime"].ToString()), DurationMinutes = obj["duration_minutes"].ToObject <int>() }; var options = obj["options"].ToObject <JArray>(); polls.Options = ParseArray(options, ParsePollsOption); return(polls); }
public void PrintsResultsWhenPollIsClosed() { var polls = new Polls(); polls.ProcessCommand("poll start"); polls.ProcessCommand("poll add some choice"); polls.ProcessCommand("poll add some other choice"); polls.ProcessCommand(new Command("channel", "user-1", "vote 1")); polls.ProcessCommand(new Command("channel", "user-2", "vote 1")); polls.ProcessCommand(new Command("channel", "user-3", "vote 2")); var result = polls.ProcessCommand("poll finish"); Assert.AreEqual("Polls closed! The winner is choice 1 (some choice).\n`##` some choice\n`#` some other choice", result.Responses.Single().Message); }
// ______________________________________ // // 3. SORT. // ______________________________________ // public static List <Data_struct> Sort_List() { List <Data_struct> Unsorted_List = Polls.Data_List_Get(typeof(Polls)); DateTime[] date_Times = new DateTime[Unsorted_List.Count]; for (int x = 0; x < date_Times.Length; x++) { date_Times[x] = ((Poll)Unsorted_List[x]).Creation_Time; } List <Data_struct> Sorted_List = Utils.Bubble_Sort_DateTime(Unsorted_List, date_Times); return(Sorted_List); }
protected void Page_Load(object sender, EventArgs e) { PollFormView.Visible = (Config.ActivePoll > 0 || ViewState["PollID"] != null); if (PollId == 0) { return; } var polls = new List <PollInfo> { Polls.GetTopicPoll(PollId) }; PollFormView.DataSource = polls; PollFormView.DataBind(); }
public static Elections[] GetWinner(Polls[] polls) { Elections[] finalList = polls[0].elections; for (int i = 1; i < polls.Length; i++) { for (int j = 0; j < polls[i].elections.Length; j++) for (int z = 0; z < finalList.Length; z++) { if (finalList[z].candidate == polls[i].elections[j].candidate) { finalList[z].votes += polls[i].elections[j].votes; break; } } } OrderListOfCandidatesByVotes(ref finalList); return finalList; }
private string ParseContent(DataRow dr, string tempate, int rowcount) { var sOutput = tempate; var replyId = dr.GetInt("ReplyId"); var topicId = dr.GetInt("TopicId"); var postId = replyId == 0 ? topicId : replyId; var contentId = dr.GetInt("ContentId"); var dateCreated = dr.GetDateTime("DateCreated"); var dateUpdated = dr.GetDateTime("DateUpdated"); var authorId = dr.GetInt("AuthorId"); var username = dr.GetString("Username"); var firstName = dr.GetString("FirstName"); var lastName = dr.GetString("LastName"); var displayName = dr.GetString("DisplayName"); var userTopicCount = dr.GetInt("TopicCount"); var userReplyCount = dr.GetInt("ReplyCount"); var postCount = userTopicCount + userReplyCount; var userCaption = dr.GetString("UserCaption"); var body = dr.GetString("Body"); var subject = dr.GetString("Subject"); var tags = dr.GetString("Tags"); var signature = dr.GetString("Signature"); var ipAddress = dr.GetString("IPAddress"); var memberSince = dr.GetDateTime("MemberSince"); var avatarDisabled = dr.GetBoolean("AvatarDisabled"); var userRoles = dr.GetString("UserRoles"); var isUserOnline = dr.GetBoolean("IsUserOnline"); var replyStatusId = dr.GetInt("StatusId"); var totalPoints = _enablePoints ? dr.GetInt("UserTotalPoints") : 0; var answerCount = dr.GetInt("AnswerCount"); var rewardPoints = dr.GetInt("RewardPoints"); var dateLastActivity = dr.GetDateTime("DateLastActivity"); var signatureDisabled = dr.GetBoolean("SignatureDisabled"); // Populate the user object with the post author info. var up = new User { UserId = authorId, UserName = username, FirstName = firstName.Replace("&#", "&#"), LastName = lastName.Replace("&#", "&#"), DisplayName = displayName.Replace("&#", "&#"), Profile = { UserCaption = userCaption, Signature = signature, DateCreated = memberSince, AvatarDisabled = avatarDisabled, Roles = userRoles, ReplyCount = userReplyCount, TopicCount = userTopicCount, AnswerCount = answerCount, RewardPoints = rewardPoints, DateLastActivity = dateLastActivity, PrefBlockAvatars = UserPrefHideAvatars, PrefBlockSignatures = UserPrefHideSigs, IsUserOnline = isUserOnline, SignatureDisabled = signatureDisabled } }; //Perform Profile Related replacements sOutput = TemplateUtils.ParseProfileTemplate(sOutput, up, PortalId, ModuleId, ImagePath, CurrentUserType, true, UserPrefHideAvatars, UserPrefHideSigs, ipAddress, UserId, TimeZoneOffset); // Replace Tags Control if (string.IsNullOrWhiteSpace(tags)) sOutput = TemplateUtils.ReplaceSubSection(sOutput, string.Empty, "[AF:CONTROL:TAGS]", "[/AF:CONTROL:TAGS]"); else { sOutput = sOutput.Replace("[AF:CONTROL:TAGS]", string.Empty); sOutput = sOutput.Replace("[/AF:CONTROL:TAGS]", string.Empty); var tagList = string.Empty; foreach (var tag in tags.Split(',')) { if (tagList != string.Empty) tagList += ", "; tagList += "<a href=\"" + Utilities.NavigateUrl(TabId, string.Empty, new[] { ParamKeys.ViewType + "=search", ParamKeys.Tags + "=" + HttpUtility.UrlEncode(tag) }) + "\">" + tag + "</a>"; } sOutput = sOutput.Replace("[AF:LABEL:TAGS]", tagList); } // Use a string builder from here on out. var sbOutput = new StringBuilder(sOutput); // Row CSS Classes if (rowcount % 2 == 0) { sbOutput.Replace("[POSTINFOCSS]", "afpostinfo afpostinfo1"); sbOutput.Replace("[POSTTOPICCSS]", "afposttopic afpostreply1"); sbOutput.Replace("[POSTREPLYCSS]", "afpostreply afpostreply1"); } else { sbOutput.Replace("[POSTTOPICCSS]", "afposttopic afpostreply2"); sbOutput.Replace("[POSTINFOCSS]", "afpostinfo afpostinfo2"); sbOutput.Replace("[POSTREPLYCSS]", "afpostreply afpostreply2"); } // Description if (replyId == 0) { sbOutput.Replace("[POSTID]", topicId.ToString()); _topicDescription = Utilities.StripHTMLTag(body).Trim(); _topicDescription = _topicDescription.Replace(System.Environment.NewLine, string.Empty); if (_topicDescription.Length > 255) _topicDescription = _topicDescription.Substring(0, 255); } else { sbOutput.Replace("[POSTID]", replyId.ToString()); } sbOutput.Replace("[FORUMID]", ForumId.ToString()); sbOutput.Replace("[REPLYID]", replyId.ToString()); sbOutput.Replace("[TOPICID]", topicId.ToString()); sbOutput.Replace("[POSTDATE]", GetDate(dateCreated)); sbOutput.Replace("[DATECREATED]", GetDate(dateCreated)); // Parse Roles -- This should actually be taken care of in ParseProfileTemplate //if (sOutput.Contains("[ROLES:")) // sOutput = TemplateUtils.ParseRoles(sOutput, (up.UserId == -1) ? string.Empty : up.Profile.Roles); // Delete Action if (_bModDelete || ((_bDelete && authorId == UserId && !_bLocked) && ((replyId == 0 && _replyCount == 0) || replyId > 0))) { if (_useListActions) sbOutput.Replace("[ACTIONS:DELETE]", "<li class=\"af-delete\" onclick=\"amaf_postDel(" + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><em></em>[RESX:Delete]</li>"); else sbOutput.Replace("[ACTIONS:DELETE]", "<a href=\"javascript:void(0);\" class=\"af-actions af-delete\" onclick=\"amaf_postDel(" + topicId + "," + replyId + ");\" title=\"[RESX:Delete]\"><em></em>[RESX:Delete]</a>"); } else { sbOutput.Replace("[ACTIONS:DELETE]", string.Empty); } // Edit Action if (_bModEdit || (_bEdit && authorId == UserId && (_editInterval == 0 || SimulateDateDiff.DateDiff(SimulateDateDiff.DateInterval.Minute, dateCreated, DateTime.Now) < _editInterval))) { var sAction = "re"; if (replyId == 0) sAction = "te"; var editParams = new[] { ParamKeys.ViewType + "=post", "action=" + sAction, ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, "postid=" + postId }; if (_useListActions) sbOutput.Replace("[ACTIONS:EDIT]", "<li class=\"af-edit\" onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", editParams) + "';\" title=\"[RESX:Edit]\"><em></em>[RESX:Edit]</li>"); else sbOutput.Replace("[ACTIONS:EDIT]", "<a class=\"af-actions af-edit\" href=\"" + Utilities.NavigateUrl(TabId, "", editParams) + "\" title=\"[RESX:Edit]\"><em></em>[RESX:Edit]</a>"); } else { sbOutput.Replace("[ACTIONS:EDIT]", string.Empty); } // Reply and Quote Actions if (!_bLocked && CanReply) { var quoteParams = new[] { ParamKeys.ViewType + "=post", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.QuoteId + "=" + postId }; var replyParams = new[] { ParamKeys.ViewType + "=post", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + postId }; if (_useListActions) { sbOutput.Replace("[ACTIONS:QUOTE]", "<li class=\"af-quote\" onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", quoteParams) + "';\" title=\"[RESX:Quote]\"><em></em>[RESX:Quote]</li>"); sbOutput.Replace("[ACTIONS:REPLY]", "<li class=\"af-reply\" onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", replyParams) + "';\" title=\"[RESX:Reply]\"><em></em>[RESX:Reply]</li>"); } else { sbOutput.Replace("[ACTIONS:QUOTE]", "<a class=\"af-actions af-quote\" href=\"" + Utilities.NavigateUrl(TabId, "", quoteParams) + "\" title=\"[RESX:Quote]\"><em></em>[RESX:Quote]</a>"); sbOutput.Replace("[ACTIONS:REPLY]", "<a class=\"af-actions af-reply\" href=\"" + Utilities.NavigateUrl(TabId, "", replyParams) + "\" title=\"[RESX:Reply]\"><em></em>[RESX:Reply]</a>"); } } else { sbOutput.Replace("[ACTIONS:QUOTE]", string.Empty); sbOutput.Replace("[ACTIONS:REPLY]", string.Empty); } // Status if (_statusId <= 0 || (_statusId == 3 && replyStatusId == 0)) { sbOutput.Replace("[ACTIONS:ANSWER]", string.Empty); } else if (replyStatusId == 1) { // Answered if (_useListActions) sbOutput.Replace("[ACTIONS:ANSWER]", "<li class=\"af-answered\" title=\"[RESX:Status:Answer]\"><em></em>[RESX:Status:Answer]</li>"); else sbOutput.Replace("[ACTIONS:ANSWER]", "<span class=\"af-actions af-answered\" title=\"[RESX:Status:Answer]\"><em></em>[RESX:Status:Answer]</span>"); } else { // Not Answered if ((UserId == _topicAuthorId && !_bLocked) || _bModEdit) { // Can mark answer if (_useListActions) sbOutput.Replace("[ACTIONS:ANSWER]", "<li class=\"af-markanswer\" onclick=\"amaf_markAnswer(" + topicId.ToString() + "," + replyId.ToString() + ");\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</li>"); else sbOutput.Replace("[ACTIONS:ANSWER]", "<a class=\"af-actions af-markanswer\" href=\"#\" onclick=\"amaf_markAnswer(" + topicId.ToString() + "," + replyId.ToString() + "); return false;\" title=\"[RESX:Status:SelectAnswer]\"><em></em>[RESX:Status:SelectAnswer]</a>"); } else { // Display Nothing sbOutput.Replace("[ACTIONS:ANSWER]", string.Empty); } } // User Edit Date if (dateUpdated == dateCreated || dateUpdated == DateTime.MinValue || dateUpdated == Utilities.NullDate()) { sbOutput.Replace("[EDITDATE]", string.Empty); } else { sbOutput.Replace("[EDITDATE]", Utilities.GetDate(dateUpdated, ModuleId, TimeZoneOffset)); } // Mod Edit Date if (_bModEdit) { if (dateCreated == dateUpdated || dateUpdated == DateTime.MinValue || dateUpdated == Utilities.NullDate()) sbOutput.Replace("[MODEDITDATE]", string.Empty); else sbOutput.Replace("[MODEDITDATE]", Utilities.GetDate(dateUpdated, ModuleId, TimeZoneOffset)); } else { sbOutput.Replace("[MODEDITDATE]", string.Empty); } // Poll Results if (sOutput.Contains("[POLLRESULTS]") ) { if (_topicType == 1) { var polls = new Polls(); sbOutput.Replace("[POLLRESULTS]", polls.PollResults(topicId, ImagePath)); } else { sbOutput.Replace("[POLLRESULTS]", string.Empty); } } // Mod Alert var alertParams = new[] { ParamKeys.ViewType + "=modreport", ParamKeys.ForumId + "=" + ForumId, ParamKeys.TopicId + "=" + topicId, ParamKeys.ReplyId + "=" + postId }; if (Request.IsAuthenticated) { if (_useListActions) sbOutput.Replace("[ACTIONS:ALERT]", "<li class=\"af-alert\" onclick=\"window.location.href='" + Utilities.NavigateUrl(TabId, "", alertParams) + "';\" title=\"[RESX:Alert]\"><em></em>[RESX:Alert]</li>"); else sbOutput.Replace("[ACTIONS:ALERT]", "<a class=\"af-actions af-alert\" href=\"" + Utilities.NavigateUrl(TabId, "", alertParams) + "\" title=\"[RESX:Alert]\"><em></em>[RESX:Alert]</a>"); } else { sbOutput.Replace("[ACTIONS:ALERT]", string.Empty); } // Process Body if (string.IsNullOrEmpty(body)) body = " <br />"; var sBody = Utilities.ManageImagePath(body); sBody = sBody.Replace("[", "["); sBody = sBody.Replace("]", "]"); if (sBody.ToUpper().Contains("[CODE]")) { sBody = Regex.Replace(sBody, "([CODE])", "[CODE]", RegexOptions.IgnoreCase); sBody = Regex.Replace(sBody, "([\\/CODE])", "[/CODE]", RegexOptions.IgnoreCase); } //sBody = sBody.Replace("<CODE>", "<CODE>") if (Regex.IsMatch(sBody, "\\[CODE([^>]*)\\]", RegexOptions.IgnoreCase)) { var objCode = new CodeParser(); sBody = CodeParser.ParseCode(Utilities.HTMLDecode(sBody)); } sBody = Utilities.StripExecCode(sBody); if (MainSettings.AutoLinkEnabled) sBody = Utilities.AutoLinks(sBody, Request.Url.Host); if (sBody.Contains("<%@")) sBody = sBody.Replace("<%@ ", "<%@ "); if (body.ToLowerInvariant().Contains("runat")) sBody = Regex.Replace(sBody, "runat", "runat", RegexOptions.IgnoreCase); sbOutput.Replace("[BODY]", sBody); // Subject sbOutput.Replace("[SUBJECT]", subject); // Attachments var sAttach = (_dtAttach.Rows.Count > 0) ? GetAttachments(contentId, _bAttach, PortalId, ModuleId) : string.Empty; sbOutput.Replace("[ATTACHMENTS]", sAttach); // Switch back from the string builder to a normal string before we perform the image/thumbnail replacements. sOutput = sbOutput.ToString(); // [IMAGE:38] if (sOutput.Contains("[IMAGE:")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/"; const string pattern = "([IMAGE:(.+?)])"; sOutput = Regex.Replace(sOutput, pattern, match => "<img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + match.Groups[2].Value + "\" border=\"0\" class=\"afimg\" />"); } // [THUMBNAIL:38] if (sOutput.Contains("[THUMBNAIL:")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(Request)) + "/"; const string pattern = "([THUMBNAIL:(.+?)])"; sOutput = Regex.Replace(sOutput, pattern, match => { var thumbId = match.Groups[2].Value.Split(':')[0]; var parentId = match.Groups[2].Value.Split(':')[1]; return "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + parentId + "\" target=\"_blank\"><img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + PortalId + "&moduleid=" + ModuleId + "&attachid=" + thumbId + "\" border=\"0\" class=\"afimg\" /></a>"; }); } return sOutput; }