Esempio n. 1
0
<?php

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');
$debate = new Debate($f_fk_language_id, $f_debate_nr);
if ($debate->exists()) {
    foreach ($debate->getTranslations() as $translation) {
        $existing[$translation->getLanguageId()] = true;
    }
    $title = $debate->getProperty('title');
    $question = $debate->getProperty('question');
    $is_used_as_default = false;
}
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('Translate Debate'), '')));
?>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" class="action_buttons" style="padding-top: 5px;">
<TR>
    <TD><A HREF="index.php"><IMG SRC="<?php 
echo $Campsite["ADMIN_IMAGE_BASE_URL"];
?>
/left_arrow.png" BORDER="0"></A></TD>
    <TD><A HREF="index.php"><B><?php 
putGS("Debate List");
?>
Esempio n. 2
0
<?php

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');
$debate = new Debate($f_fk_language_id, $f_debate_nr);
if (!$debate->exists()) {
    camp_html_display_error(getGS('Debate does not exists.'));
    exit;
}
$title = $debate->getProperty('title');
$question = $debate->getProperty('question');
$date_begin = $debate->getProperty('date_begin');
$date_end = $debate->getProperty('date_end');
$fk_language_id = $debate->getProperty('fk_language_id');
$votes_per_user = $debate->getProperty('votes_per_user');
/*
$topArray = array('Pub' => $publicationObj, 'Issue' => $issueObj,
                  'Section' => $sectionObj);
camp_html_content_top(getGS('Add new article'), $topArray, true, false, array(getGS("Articles") => "/$ADMIN/articles/?f_publication_id=$f_publication_id&f_issue_number=$f_issue_number&f_section_number=$f_section_number&f_language_id=$f_language_id"));
*/
?>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" class="action_buttons" style="padding-top: 5px;">
<TR>
    <TD><A HREF="index.php"><IMG SRC="<?php 
Esempio n. 3
0
<?php

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');
$f_from = Input::Get('f_from', 'string', false);
$debate = new Debate($f_fk_language_id, $f_debate_nr);
if ($debate->exists()) {
    // edit existing debate
    $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();
Esempio n. 4
0
 /**
  * Gets an issue list based on the given parameters.
  *
  * @param array $p_parameters
  *    An array of ComparisonOperation objects
  * @param string item
  *    An indentifier which assignment should be used (publication/issue/section/article)
  * @param string $p_order
  *    An array of columns and directions to order by
  * @param integer $p_start
  *    The record number to start the list
  * @param integer $p_limit
  *    The offset. How many records from $p_start will be retrieved.
  *
  * @return array $issuesList
  *    An array of Issue objects
  */
 public static function GetList(array $p_parameters, $p_item = null, $p_order = null, $p_start = 0, $p_limit = 0, &$p_count)
 {
     global $g_ado_db;
     if (!is_array($p_parameters)) {
         return null;
     }
     // adodb::selectLimit() interpretes -1 as unlimited
     if ($p_limit == 0) {
         $p_limit = -1;
     }
     $selectClauseObj = new SQLSelectClause();
     // sets the where conditions
     foreach ($p_parameters as $param) {
         $comparisonOperation = self::ProcessListParameters($param);
         if (empty($comparisonOperation)) {
             continue;
         }
         if (strpos($comparisonOperation['left'], '_assign_publication_id') !== false) {
             $assign_publication_id = $comparisonOperation['right'];
         } elseif (strpos($comparisonOperation['left'], '_assign_issue_nr') !== false) {
             $assign_issue_nr = $comparisonOperation['right'];
         } elseif (strpos($comparisonOperation['left'], '_assign_section_nr') !== false) {
             $assign_section_nr = $comparisonOperation['right'];
         } elseif (strpos($comparisonOperation['left'], '_assign_article_nr') !== false) {
             $assign_article_nr = $comparisonOperation['right'];
         } elseif (strpos($comparisonOperation['left'], '_current') !== false) {
             $whereCondition = "date_begin <= NOW()";
             $selectClauseObj->addWhere($whereCondition);
             $whereCondition = "date_end >= NOW()";
             $selectClauseObj->addWhere($whereCondition);
         } elseif (strpos($comparisonOperation['left'], 'language_id') !== false) {
             $language_id = $comparisonOperation['right'];
             $whereCondition = $g_ado_db->escapeOperation($comparisonOperation);
             $selectClauseObj->addWhere($whereCondition);
         } elseif (strpos($comparisonOperation['left'], 'number') !== false) {
             $whereCondition = $g_ado_db->escapeOperation($comparisonOperation);
             $selectClauseObj->addWhere($whereCondition);
         } else {
             $whereCondition = $g_ado_db->escapeOperation($comparisonOperation);
             $selectClauseObj->addWhere($whereCondition);
         }
     }
     // sets the columns to be fetched
     $tmpPoll = new Debate();
     $columnNames = $tmpPoll->getColumnNames(true);
     foreach ($columnNames as $columnName) {
         $selectClauseObj->addColumn($columnName);
     }
     // sets the main table for the query
     $mainTblName = $tmpPoll->getDbTableName();
     $selectClauseObj->setTable($mainTblName);
     unset($tmpPoll);
     switch ($p_item) {
         case 'publication':
             if (empty($assign_publication_id)) {
                 return;
             }
             $tmpAssignObj = new DebatePublication();
             $assignTblName = $tmpAssignObj->getDbTableName();
             $join = "LEFT JOIN `{$assignTblName}` AS j\n                            ON\n                            j.fk_debate_nr = `{$mainTblName}`.debate_nr\n                            AND j.fk_publication_id = '{$assign_publication_id}'";
             $selectClauseObj->addJoin($join);
             $selectClauseObj->addWhere('j.fk_debate_nr IS NOT NULL');
             $selectClauseObj->setDistinct('plugin_debate.debate_nr');
             break;
         case 'issue':
             if (empty($assign_publication_id) || empty($assign_issue_nr)) {
                 return;
             }
             $tmpAssignObj = new DebateIssue();
             $assignTblName = $tmpAssignObj->getDbTableName();
             $join = "LEFT JOIN {$assignTblName} AS j\n                            ON\n                            j.fk_debate_nr = `{$mainTblName}`.debate_nr\n                            AND j.fk_issue_nr = '{$assign_issue_nr}'\n                            AND j.fk_publication_id = '{$assign_publication_id}'";
             if (isset($language_id)) {
                 $join .= " AND j.fk_issue_language_id = '{$language_id}'";
             }
             $selectClauseObj->addJoin($join);
             $selectClauseObj->addWhere('j.fk_debate_nr IS NOT NULL');
             $selectClauseObj->setDistinct('plugin_debate.debate_nr');
             break;
         case 'section':
             if (empty($assign_publication_id) || empty($assign_issue_nr) || empty($assign_section_nr)) {
                 return;
             }
             $tmpAssignObj = new DebateSection();
             $assignTblName = $tmpAssignObj->getDbTableName();
             $join = "LEFT JOIN `{$assignTblName}` AS j\n                            ON\n                            j.fk_debate_nr = `{$mainTblName}`.debate_nr\n                            AND j.fk_section_nr = '{$assign_section_nr}'\n                            AND j.fk_issue_nr = '{$assign_issue_nr}'\n                            AND j.fk_publication_id = '{$assign_publication_id}'";
             if (isset($language_id)) {
                 $join .= " AND j.fk_section_language_id = '{$language_id}'";
             }
             $selectClauseObj->addJoin($join);
             $selectClauseObj->addWhere('j.fk_debate_nr IS NOT NULL');
             $selectClauseObj->setDistinct('plugin_debate.debate_nr');
             break;
         case 'article':
             if (empty($assign_article_nr)) {
                 return;
             }
             $tmpAssignObj = new DebateArticle();
             $assignTblName = $tmpAssignObj->getDbTableName();
             $join = "LEFT JOIN `{$assignTblName}` AS j\n                            ON\n                            j.fk_debate_nr = `{$mainTblName}`.debate_nr\n                            AND j.fk_article_nr = '{$assign_article_nr}'";
             if (isset($language_id)) {
                 $join .= " AND j.fk_article_language_id = '{$language_id}'";
             }
             $selectClauseObj->addJoin($join);
             $selectClauseObj->addWhere('j.fk_debate_nr IS NOT NULL');
             $selectClauseObj->setDistinct('plugin_debate.debate_nr');
             break;
     }
     if (is_array($p_order)) {
         $order = Debate::ProcessListOrder($p_order);
         // sets the order condition if any
         foreach ($order as $orderField => $orderDirection) {
             $selectClauseObj->addOrderBy($orderField . ' ' . $orderDirection);
         }
     }
     $sqlQuery = $selectClauseObj->buildQuery();
     // count all available results
     $countRes = $g_ado_db->Execute($sqlQuery);
     if (!is_null($countRes)) {
         $p_count = $countRes->recordCount();
     }
     //get the wanted rows
     $debateRes = $g_ado_db->SelectLimit($sqlQuery, $p_limit, $p_start);
     // builds the array of debate objects
     $debatesList = array();
     while ($debate = $debateRes->FetchRow()) {
         $debateObj = new Debate($debate['fk_language_id'], $debate['debate_nr']);
         if ($debateObj->exists()) {
             $debatesList[] = $debateObj;
         }
     }
     return $debatesList;
 }
Esempio n. 5
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;
 }