Пример #1
0
 function testEditPoll()
 {
     // Test the forum edits
     ocf_edit_poll($poll_id = $this->poll_id, $question = 'Who am I?', $is_private = 1, $is_open = 1, $minimum_selections = 1, $maximum_selections = 4, $requires_reply = 1, $answers = array(1, 2, 3), $reason = 'nothing');
     // Test the forum was actually created
     $this->assertTrue('Who am I?' == $GLOBALS['FORUM_DB']->query_value('f_polls', 'po_question ', array('id' => $this->poll_id)));
 }
Пример #2
0
 /**
  * The actualiser to edit a poll.
  *
  * @return tempcode		The UI
  */
 function _edit_poll()
 {
     $poll_id = get_param_integer('id');
     $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 'id', array('t_poll_id' => $poll_id));
     if (is_null($topic_id)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $question = post_param('question', STRING_MAGIC_NULL);
     $is_private = post_param_integer('is_private', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $is_open = post_param_integer('is_open', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $minimum_selections = post_param_integer('minimum_selections', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $maximum_selections = post_param_integer('maximum_selections', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     $reason = post_param('reason', STRING_MAGIC_NULL);
     $requires_reply = post_param_integer('requires_reply', fractional_edit() ? INTEGER_MAGIC_NULL : 0);
     if (fractional_edit()) {
         $answers = collapse_1d_complexity('pa_answer', $GLOBALS['FORUM_DB']->query_select('f_poll_answers', array('pa_answer'), array('pa_poll_id' => $poll_id)));
         foreach ($answers as $i => $answer) {
             $answers[$i] = post_param('answer_' . strval($i), $answer);
         }
     } else {
         $answers = array();
         foreach ($_POST as $key => $val) {
             if (!is_string($val)) {
                 continue;
             }
             if (substr($key, 0, 7) == 'answer_') {
                 if (get_magic_quotes_gpc()) {
                     $val = stripslashes($val);
                 }
                 if ($val != '') {
                     $answers[] = $val;
                 }
             }
         }
     }
     require_code('ocf_polls_action');
     require_code('ocf_polls_action2');
     ocf_edit_poll($poll_id, $question, $is_private, $is_open, $minimum_selections, $maximum_selections, $requires_reply, $answers, $reason);
     return $this->redirect_to('EDIT_TOPIC_POLL', $topic_id);
 }