/// <summary> /// The get poll id. /// </summary> /// <returns> /// Returns the Poll Id /// </returns> private bool?GetPollID() { if (int.TryParse(this.PollExpire.Text.Trim(), out this._daysPollExpire)) { this._datePollExpire = DateTime.UtcNow.AddDays(this._daysPollExpire); } // we are just using existing poll if (this.PollId != null) { string questionPath = this.QuestionObjectPath.Text.Trim(); string questionMime = string.Empty; if (questionPath.IsSet()) { long length; questionMime = ImageHelper.GetImageParameters(new Uri(questionPath), out length); if (questionMime.IsNotSet()) { YafContext.Current.AddLoadMessage(this.GetTextFormatted("POLLIMAGE_INVALID", questionPath)); return(false); } if (length > this.Get <YafBoardSettings>().PollImageMaxFileSize * 1024) { YafContext.Current.AddLoadMessage( this.GetTextFormatted( "POLLIMAGE_TOOBIG", length / 1024, this.Get <YafBoardSettings>().PollImageMaxFileSize, questionPath)); return(false); } } LegacyDb.poll_update( this.PollId, this.Question.Text, this._datePollExpire, this.IsBoundCheckBox.Checked, this.IsClosedBoundCheckBox.Checked, this.AllowMultipleChoicesCheckBox.Checked, this.ShowVotersCheckBox.Checked, this.AllowSkipVoteCheckBox.Checked, questionPath, questionMime); foreach (RepeaterItem ri in this.ChoiceRepeater.Items) { string choice = ((TextBox)ri.FindControl("PollChoice")).Text.Trim(); string chid = ((HiddenField)ri.FindControl("PollChoiceID")).Value; string choiceObjectPath = ((TextBox)ri.FindControl("ObjectPath")).Text.Trim(); string choiceImageMime = string.Empty; // update choice if (choiceObjectPath.IsSet()) { long length; choiceImageMime = ImageHelper.GetImageParameters(new Uri(choiceObjectPath), out length); if (choiceImageMime.IsNotSet()) { YafContext.Current.AddLoadMessage( this.GetTextFormatted("POLLIMAGE_INVALID", choiceObjectPath.Trim())); return(false); } if (length > this.Get <YafBoardSettings>().PollImageMaxFileSize * 1024) { YafContext.Current.AddLoadMessage( this.GetTextFormatted( "POLLIMAGE_TOOBIG", length / 1024, this.Get <YafBoardSettings>().PollImageMaxFileSize, choiceObjectPath)); return(false); } } if (string.IsNullOrEmpty(chid) && !string.IsNullOrEmpty(choice)) { // add choice LegacyDb.choice_add(this.PollId, choice, choiceObjectPath, choiceImageMime); } else if (!string.IsNullOrEmpty(chid) && !string.IsNullOrEmpty(choice)) { LegacyDb.choice_update(chid, choice, choiceObjectPath, choiceImageMime); } else if (!string.IsNullOrEmpty(chid) && string.IsNullOrEmpty(choice)) { // remove choice LegacyDb.choice_delete(chid); } } return(true); } else { // User wishes to create a poll // The value was selected, we attach an existing poll if (this.PollGroupListDropDown.SelectedIndex.ToType <int>() > 0) { int result = LegacyDb.pollgroup_attach( this.PollGroupListDropDown.SelectedValue.ToType <int>(), this._topicId, this._forumId, this._categoryId, this._boardId); if (result == 1) { this.PageContext.AddLoadMessage(this.GetText("POLLEDIT", "POLLGROUP_ATTACHED")); } return(true); } string questionPath = this.QuestionObjectPath.Text.Trim(); string questionMime = string.Empty; if (questionPath.IsSet()) { long length; questionMime = ImageHelper.GetImageParameters(new Uri(questionPath), out length); if (questionMime.IsNotSet()) { YafContext.Current.AddLoadMessage( this.GetTextFormatted("POLLIMAGE_INVALID", this.QuestionObjectPath.Text.Trim())); return(false); } if (length > this.Get <YafBoardSettings>().PollImageMaxFileSize * 1024) { YafContext.Current.AddLoadMessage( this.GetTextFormatted( "POLLIMAGE_TOOBIG", length / 1024, this.Get <YafBoardSettings>().PollImageMaxFileSize, questionPath)); } } var pollSaveList = new List <PollSaveList>(); var rawChoices = new string[3, this.ChoiceRepeater.Items.Count]; int j = 0; foreach (RepeaterItem ri in this.ChoiceRepeater.Items) { string choiceObjectPath = ((TextBox)ri.FindControl("ObjectPath")).Text.Trim(); string choiceObjectMime = string.Empty; if (choiceObjectPath.IsSet()) { long length; choiceObjectMime = ImageHelper.GetImageParameters(new Uri(choiceObjectPath), out length); if (choiceObjectMime.IsNotSet()) { YafContext.Current.AddLoadMessage( this.GetTextFormatted("POLLIMAGE_INVALID", choiceObjectPath.Trim())); return(false); } if (length > this.Get <YafBoardSettings>().PollImageMaxFileSize * 1024) { YafContext.Current.AddLoadMessage( this.GetTextFormatted( "POLLIMAGE_TOOBIG", length / 1024, this.Get <YafBoardSettings>().PollImageMaxFileSize, choiceObjectPath)); return(false); } } rawChoices[0, j] = HtmlHelper.StripHtml(((TextBox)ri.FindControl("PollChoice")).Text.Trim()); rawChoices[1, j] = choiceObjectPath; rawChoices[2, j] = choiceObjectMime; j++; } int?realTopic = this._topicId; if (this._topicId == null) { realTopic = this._editTopicId; } if (this._datePollExpire == null && this.PollExpire.Text.Trim().IsSet()) { this._datePollExpire = DateTime.UtcNow.AddDays(this.PollExpire.Text.Trim().ToType <int>()); } pollSaveList.Add( new PollSaveList( this.Question.Text, rawChoices, this._datePollExpire, this.PageContext.PageUserID, realTopic, this._forumId, this._categoryId, this._boardId, questionPath, questionMime, this.IsBoundCheckBox.Checked, this.IsClosedBoundCheckBox.Checked, this.AllowMultipleChoicesCheckBox.Checked, this.ShowVotersCheckBox.Checked, this.AllowSkipVoteCheckBox.Checked)); LegacyDb.poll_save(pollSaveList); return(true); } }