Example #1
0
                }
                $poll_questions_array[$poll_question['QUESTION_ID']] = $poll_question;
            }
        }
    } else {
        $poll_questions_array = poll_get_default_questions_array();
    }
}
if (sizeof($poll_questions_array) == 0) {
    $poll_questions_array = poll_get_default_questions_array();
}
if (isset($_POST['add_option']) && is_array($_POST['add_option'])) {
    list($question_id) = array_keys($_POST['add_option']);
    if (isset($poll_questions_array[$question_id])) {
        $option_id = sizeof($poll_questions_array[$question_id]['OPTIONS_ARRAY']) + 1;
        $poll_questions_array[$question_id]['OPTIONS_ARRAY'][] = poll_get_option_array($option_id);
    }
}
if (isset($_POST['add_question'])) {
    $question_id = sizeof($poll_questions_array) + 1;
    $poll_questions_array[] = poll_get_question_array($question_id);
}
if (isset($_POST['delete_option']) && is_array($_POST['delete_option'])) {
    foreach ($_POST['delete_option'] as $question_id => $option_id_array) {
        if (!is_array($option_id_array)) {
            continue;
        }
        if (sizeof($poll_questions_array[$question_id]['OPTIONS_ARRAY']) > 1) {
            foreach (array_keys($option_id_array) as $option_id) {
                unset($poll_questions_array[$question_id]['OPTIONS_ARRAY'][$option_id]);
            }
Example #2
0
function poll_get_question_array($question_id)
{
    return array('QUESTION_ID' => $question_id, 'QUESTION' => '', 'ALLOW_MULTI' => 'N', 'OPTIONS_ARRAY' => array(1 => poll_get_option_array(1), 2 => poll_get_option_array(2)));
}