/// <summary> /// 获取投票信息 /// </summary> public void GetPollInfo() { pollinfo = Polls.GetPollInfo(topicid); voters = Polls.GetVoters(topicid, userid, username, out allowvote); if (pollinfo.Uid != userid && useradminid != 1) //当前用户不是投票发起人或不是管理组成员 { if (pollinfo.Visible == 1 && //当为投票才可见时 (allowvote || (userid == -1 && !Utils.InArray(topicid.ToString(), ForumUtils.GetCookie("dnt_polled"))))) //当允许投票或为游客(且并未投过票时)时 { showpollresult = false; } } if (Utils.StrIsNullOrEmpty(pollinfo.Expiration)) { pollinfo.Expiration = DateTime.Now.ToString(); } if (DateTime.Parse(pollinfo.Expiration) < DateTime.Now) { allowvote = false; } }
protected override void ShowPage() { if (!ispost) { if (tid <= 0) { AddErrLine("不存在的主题ID"); return; } TopicInfo topic = Topics.GetTopicInfo(tid); if (topic == null) { AddErrLine("不存在的主题"); return; } switch (action) { case "emailfriend": title = "分享"; emailcontent = "你好!我在 {0} 看到了这篇帖子,认为很有价值,特推荐给你。\r\n{1}\r\n地址 {2}\r\n希望你能喜欢。"; if (topic != null) { topictitle = topic.Title; emailcontent = string.Format(emailcontent, config.Forumtitle, topictitle, DNTRequest.GetUrlReferrer()); } break; case "viewvote": title = "参与投票的会员"; PollInfo pollinfo = Polls.GetPollInfo(tid); if (pollinfo == null) { AddErrLine("不存在的调查"); return; } if (!(pollinfo.Allowview == 1 || pollinfo.Uid == userid || Moderators.IsModer(useradminid, userid, topic.Fid))) { AddErrLine("您没有查看投票人的权限"); return; } pollOptionList = Polls.GetPollOptionList(tid); bool allowvote; if (polloptionid == "0" || polloptionid == "") { voters = Polls.GetVoters(tid, userid, username, out allowvote); } else { foreach (DataRow dr in pollOptionList.Rows) { if (dr["polloptionid"].ToString() == polloptionid.ToString()) { string[] votername = Utils.SplitString(dr["votername"].ToString().Trim(), " <"); foreach (string user in votername) { voters += "<li>" + (user.StartsWith("<") ? user : "******" + user) + "</li>"; } } } if (voters == "") { voters = "<li>暂无人投票</li>"; } } break; } } else { SendEmail(); } }