Example #1
0
            <TD ALIGN="RIGHT" ><?php 
putGS("Question");
?>
:</TD>
            <TD>
            <TEXTAREA NAME="f_question" class="input_textarea" cols="28" alt="blank" emsg="<?php 
putGS('You must fill in the $1 field.', getGS('Question'));
?>
"><?php 
echo htmlspecialchars($question);
?>
</TEXTAREA>
            </TD>
        </TR>
        <?php 
foreach ($debate->getAnswers() as $answer) {
    ?>
            <tr>
                <TD ALIGN="RIGHT" ><?php 
    putGS("Answer \$1", $answer->getNumber());
    ?>
:</TD>
                <TD>
                <INPUT TYPE="TEXT" NAME="f_answer[<?php 
    p($answer->getNumber());
    ?>
]" SIZE="40" MAXLENGTH="255" class="input_text" alt="blank" emsg="<?php 
    putGS('You must fill in the $1 field.', getGS('Answer $1', $answer->getNumber()));
    ?>
" value="<?php 
    p(htmlspecialchars($answer->getProperty('answer')));
 /**
  * Create a copy of an answer set.
  *
  * @param int $p_fk_debate_nr
  * @param int $p_parent_nr
  * @param array $p_answers
  * @return Article
  */
 function CreateCopySet($p_debate_nr, $p_language_id, $p_parent_nr)
 {
     $ParentDebate = new Debate($p_language_id, $p_parent_nr);
     $parentAnswers = $ParentDebate->getAnswers();
     foreach ($parentAnswers as $ParentDebateAnswer) {
         $TargetDebateAnswer = new DebateAnswer($p_language_id, $p_debate_nr, $ParentDebateAnswer->getNumber());
         if ($TargetDebateAnswer->exists()) {
             $parentDebateAnswerAttachments = $ParentDebateAnswer->getDebateAnswerAttachments();
             foreach ($parentDebateAnswerAttachments as $ParentDebateAnswerAttachment) {
                 $TargetDebateAnswerAttachment = new DebateAnswerAttachment($p_debate_nr, $ParentDebateAnswerAttachment->getProperty('fk_debateanswer_nr'), $ParentDebateAnswerAttachment->getProperty('fk_attachment_id'));
                 $TargetDebateAnswerAttachment->create();
             }
         }
     }
 }
Example #3
0
 /**
  * Reads the input parameters and vote the debate
  *
  * @param array $p_input
  */
 public function __construct(array $p_input)
 {
     $this->m_defined = true;
     $this->m_name = 'debate';
     if (!isset($p_input['f_debate_nr']) || empty($p_input['f_debate_nr'])) {
         $this->m_error = new PEAR_Error('The debate number is missing.', ACTION_DEBATE_ERR_NO_DEBATE_NUMBER);
         return false;
     }
     $this->m_properties['debate_nr'] = $p_input['f_debate_nr'];
     if (!isset($p_input['f_debate_language_id']) || empty($p_input['f_debate_language_id'])) {
         $this->m_error = new PEAR_Error('The debate language is missing.', ACTION_DEBATE_ERR_NO_LANGUAGE_ID);
         return false;
     }
     $this->m_properties['debate_language_id'] = $p_input['f_debate_language_id'];
     if ($p_input['f_debate_mode'] !== 'standard' && $p_input['f_debate_mode'] !== 'ajax') {
         $this->m_error = new PEAR_Error('The debate mode parameter is invalid.', ACTION_DEBATE_ERR_INVLID_MODE);
         return false;
     }
     $this->m_properties['debate_mode'] = $p_input['f_debate_mode'];
     $Debate = new Debate($this->m_properties['debate_language_id'], $this->m_properties['debate_nr']);
     if (!$Debate->exists()) {
         $this->m_error = new PEAR_Error('Debate does not exists.', ACTION_DEBATE_ERR_NOT_EXISTS);
         return false;
     }
     // need to check this by user also and here if I try to get the user from CampContext it breaks
     // if (!$Debate->isVotable()) {
     //    $this->m_error = new PEAR_Error('Debate is not votable.', ACTION_DEBATE_ERR_NOT_VOTABLE);
     //    syslog(LOG_WARNING, 221);
     //    return false;
     //
     // } else {
     switch ($p_input['f_debate_mode']) {
         case 'ajax':
             $allowed_values = $_SESSION['camp_debate_maxvote'][$this->m_properties['debate_nr']][$this->m_properties['debate_language_id']];
             if (!is_array($allowed_values)) {
                 $this->m_error = new PEAR_Error('Invalid debate voting value.', ACTION_DEBATE_ERR_INVALID_VALUE);
                 return false;
             }
             foreach ($Debate->getAnswers() as $DebateAnswer) {
                 $nr = $DebateAnswer->getNumber();
                 if (isset($p_input['f_debateanswer_' . $nr]) && !empty($p_input['f_debateanswer_' . $nr])) {
                     // check if value is valid
                     if (!array_key_exists($p_input['f_debateanswer_' . $nr], $allowed_values[$nr])) {
                         $this->m_error = new PEAR_Error('Invalid debate voting value.', ACTION_DEBATE_ERR_INVALID_VALUE);
                         return false;
                     }
                     $this->m_properties['debateanswer_nr'] = $nr;
                     $this->m_properties['value'] = $p_input['f_debateanswer_' . $nr];
                     break;
                 }
             }
             if (!$this->m_properties['value']) {
                 $this->m_error = new PEAR_Error('No answer value was given.', ACTION_DEBATE_ERR_NOANSWER_VALUE);
                 return false;
             }
             break;
         case 'standard':
             if (!isset($p_input['f_debateanswer_nr']) || empty($p_input['f_debateanswer_nr'])) {
                 $this->m_error = new PEAR_Error('Invalid debate voting value.', ACTION_DEBATE_ERR_INVALID_VALUE);
                 return false;
             }
             $this->m_properties['debateanswer_nr'] = $p_input['f_debateanswer_nr'];
             $this->m_properties['value'] = 1;
             break;
     }
     // }
     $this->m_debate = $Debate;
 }
Example #4
0
    $parent_debate_nr = $debate->getProperty('parent_debate_nr');
    $is_extended = $debate->isExtended();
    $title = $debate->getProperty('title');
    $question = $debate->getProperty('question');
    $date_begin = $debate->getProperty('date_begin');
    $date_end = $debate->getProperty('date_end');
    $time_begin = strftime('%H:%M', strtotime($date_begin));
    $time_end = strftime('%H:%M', strtotime($date_end));
    $date_begin = strftime('%Y-%m-%d', strtotime($date_begin));
    $date_end = strftime('%Y-%m-%d', strtotime($date_end));
    $nr_of_answers = $debate->getProperty('nr_of_answers');
    $fk_language_id = $debate->getProperty('fk_language_id');
    $votes_per_user = $debate->getProperty('votes_per_user');
    $allow_not_logged_in = $debate->getProperty('allow_not_logged_in');
    $results_time_unit = $debate->getProperty('results_time_unit');
    $debate_answers = $debate->getAnswers();
    foreach ($debate_answers as $debate_answer) {
        $answers[$debate_answer->getProperty('nr_answer')] = $debate_answer->getProperty('answer');
    }
} else {
    // language_id may preset from from assign_popup.php
    $fk_language_id = Input::Get('f_language_id', 'int');
}
if (empty($GLOBALS['_popup'])) {
    $pageTitle = $debate->exists() ? getGS('Edit Debate') : getGS('Add new Debate');
    echo camp_html_breadcrumbs(array(array(getGS('Plugins'), $Campsite['WEBSITE_URL'] . '/admin/plugins/manage.php'), array(getGS('Debates'), $Campsite['WEBSITE_URL'] . '/admin/debate/index.php'), array($pageTitle, '')));
}
if (!isset($f_include) || !$f_include) {
    ?>
    <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" class="action_buttons" style="padding-top: 5px;">
        <tr>
Example #5
0
$f_debate_nr = Input::Get('f_debate_nr', 'int');
$f_fk_language_id = Input::Get('f_fk_language_id', 'int');
$f_nr_answer = Input::Get('f_nr_answer', 'int');
$debate = new Debate($f_fk_language_id, $f_debate_nr);
$format = '%.2f';
$display[] = $debate;
foreach ($debate->getTranslations() as $translation) {
    if ($translation->getLanguageId() != $debate->getLanguageId()) {
        $display[] = $translation;
    }
}
echo camp_html_breadcrumbs(array(array(getGS('Plugins'), $Campsite['WEBSITE_URL'] . '/admin/plugins/manage.php'), array(getGS('Debates'), $Campsite['WEBSITE_URL'] . '/admin/debate/index.php'), array(getGS('Result'), '')));
?>

<?php 
$answers = $debate->getAnswers($f_debate_nr, $f_fk_language_id);
?>

<style type="text/css">
.results
{
	border: 1px solid #ccc;
	margin: 0 30px 30px 30px;
	box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
	background-color: #f3f3f3;
}
    .results .item-def
    {
    	float: left;
    	border-right: 1px solid #ccc;
    	height: <?php