Esempio n. 1
0
<?php 
include_once $GLOBALS['g_campsiteDir'] . "/{$ADMIN_DIR}/javascript_common.php";
camp_html_display_msgs();
?>

<P>
<FORM NAME="edit_debate" METHOD="POST" ACTION="do_translate.php" onsubmit="return <?php 
camp_html_fvalidate();
?>
;">
<?php 
echo SecurityToken::FormParameter();
if ($debate) {
    ?>
<INPUT TYPE="HIDDEN" NAME="f_debate_nr" VALUE="<?php 
    p($debate->getNumber());
    ?>
">
<INPUT TYPE="HIDDEN" NAME="f_fk_language_id" VALUE="<?php 
    p($debate->getLanguageId());
    ?>
">
<?php 
}
?>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="6" class="table_input">
<TR>
    <td valign="top">
        <table>
          <TR>
            <TD ALIGN="RIGHT" ><?php 
Esempio n. 2
0
camp_load_translation_strings("plugin_debate");
// Check permissions
if (!$g_user->hasPermission('plugin_debate_admin')) {
    camp_html_display_error(getGS('You do not have the right to manage debates.'));
    exit;
}
$allLanguages = Language::GetLanguages();
$f_debate_nr = Input::Get('f_debate_nr', 'int');
$f_fk_language_id = Input::Get('f_fk_language_id', 'int');
if ($f_debate_nr && $f_fk_language_id) {
    $debate = new Debate($f_fk_language_id, $f_debate_nr);
    if (Input::Get('submit', 'boolean')) {
        // create the hitlist
    } elseif ($debate->exists()) {
        $debate_nr = $debate->getNumber();
        $title = $debate->getProperty('title');
        $question = $debate->getProperty('question');
        $date_begin = $debate->getProperty('date_begin');
        $date_end = $debate->getProperty('date_end');
        $nr_of_answers = $debate->getProperty('nr_of_answers');
        $fk_language_id = $debate->getProperty('fk_language_id');
        $is_display_expired = $debate->getProperty('is_display_expired');
        $is_used_as_default = $debate->getProperty('is_used_as_default');
        $debate_answers = $debate->getAnswers();
        foreach ($debate_answers as $debate_answer) {
            $answers[$debate_answer->getProperty('nr_answer')] = $debate_answer->getProperty('answer');
        }
    }
}
?>
Esempio n. 3
0
 /**
  * Create a copy of an debate.
  *
  * @param string $p_title
  * @param string $p_question
  * @param array $p_answers
  * @return Debate
  */
 public function createCopy($p_data, $p_answers)
 {
     // Construct the duplicate debate object.
     $debate_copy = new Debate();
     $debate_copy->m_data['debate_nr'] = Debate::generatePollNumber();
     $debate_copy->m_data['parent_debate_nr'] = $this->m_data['debate_nr'];
     $debate_copy->m_data['fk_language_id'] = $this->m_data['fk_language_id'];
     // Create the record
     $values = array('title' => $p_data['title'], 'question' => $p_data['question'], 'date_begin' => $p_data['date_begin'], 'date_end' => $p_data['date_end'], 'nr_of_answers' => count($p_answers), 'votes_per_user' => $p_data['votes_per_user']);
     $success = $debate_copy->__create($values);
     if (!$success) {
         return false;
     }
     // create an set of answers
     DebateAnswer::CreateCopySet($debate_copy->getNumber(), $this->m_data['fk_language_id'], $this->m_data['debate_nr'], $p_answers);
     $debate_copy->triggerStatistics();
     /*
     if (function_exists("camp_load_translation_strings")) {
         camp_load_translation_strings("api");
     }
     $logtext = getGS('Article #$1 "$2" ($3) translated to "$5" ($4)',
         $this->getArticleNumber(), $this->getTitle(), $this->getLanguageName(),
         $articleCopy->getTitle(), $articleCopy->getLanguageName());
     Log::Message($logtext, null, 31);
     */
     return $debate_copy;
 }
Esempio n. 4
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;