Exemplo n.º 1
0
    $debate->setProperty('allow_not_logged_in', $f_allow_not_logged_in);
    foreach ($f_answers as $nr_answer => $text) {
        if (trim($text) != '') {
            $answer = new DebateAnswer($f_fk_language_id, $f_debate_nr, $nr_answer);
            if ($answer->exists()) {
                $answer->setProperty('answer', $text);
            } else {
                $answer->create($text);
            }
        }
    }
    DebateAnswer::SyncNrOfAnswers($f_fk_language_id, $f_debate_nr);
} else {
    // create new debate
    $debate = new Debate($f_fk_language_id);
    $f_date_begin = strftime("%F %H:%M:%S", strtotime($f_date_begin . " " . $f_time_begin));
    $f_date_end = strftime("%F %H:%M:%S", strtotime($f_date_end . " " . $f_time_end));
    $success = $debate->create($f_title, $f_question, $f_date_begin, $f_date_end, $f_nr_of_answers, $f_votes_per_user);
    if ($success) {
        $debate->setProperty('is_extended', $f_is_extended);
        foreach ($f_answers as $nr_answer => $text) {
            if (trim($text) != '') {
                $answer = new DebateAnswer($f_fk_language_id, $debate->getNumber(), $nr_answer);
                $success = $answer->create($text);
            }
        }
    }
}
$f_from = Input::Get('f_from', 'string', 'index.php');
header('Location: ' . $f_from);
exit;