Пример #1
0
 /**
  * Creates the list of objects. Sets the parameter $p_hasNextElements to
  * true if this list is limited and elements still exist in the original
  * list (from which this was truncated) after the last element of this
  * list.
  *
  * @param int $p_start
  * @param int $p_limit
  * @param bool $p_hasNextElements
  * @return array
  */
 protected function CreateList($p_start = 0, $p_limit = 0, array $p_parameters, &$p_count)
 {
     $context = CampTemplate::singleton()->context();
     $debate = new Debate($context->debate->language_id, $context->debate->number);
     // the template current debate
     switch ($debate->getProperty('results_time_unit')) {
         case 'daily':
             $rangeUnit = 86400;
             break;
         case 'weekly':
             $rangeUnit = 604800;
             break;
         case 'monthly':
             $rangeUnit = 2629744;
             break;
     }
     $dateStart = $context->debate->date_begin;
     $dateEnd = $p_limit != 0 ? strtotime(strftime('%D', $dateStart) . ' + ' . ($p_limit - 1) . ' days') : $context->debate->date_end;
     $dateRange = array($dateStart);
     $dateStartString = strftime('%F %T', $dateStart);
     while (current($dateRange) < $dateEnd) {
         $dateRange[] = strtotime($dateStartString . ' + 1 day');
         $dateStartString = strftime('%F %T', next($dateRange));
     }
     // @todo check the end range here for daylight savings time thing also..
     $dateVotes = DebateVote::getResults($context->debate->number, $context->debate->language_id, $dateStart, $dateEnd + 86399);
     $dateResults = array();
     foreach ($dateRange as $timestamp) {
         $found = 0;
         foreach ($dateVotes as $vote) {
             if (strftime('%D', $vote['time']) == strftime('%D', $timestamp)) {
                 $found = $vote;
                 break;
             }
         }
         if ($found) {
             $dateResults[] = $found;
         } else {
             $dateResults[] = array('time' => $timestamp, 'total_count' => 0);
         }
     }
     $dateArray = array();
     foreach ($dateResults as $date) {
         $dateArray[] = new MetaDebateDays($date);
     }
     return $dateArray;
 }
Пример #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');
$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 
echo $Campsite["ADMIN_IMAGE_BASE_URL"];
Пример #3
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');
$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");
?>
</B></A></TD>
Пример #4
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();
Пример #5
0
        ?>
%
              </td>
            </tr>
            <?php 
    }
    ?>
    </table>
    <p>
<?php 
}
?>

<h3 style="margin-left:30px">
    <?php 
echo ucfirst($debate->getProperty('results_time_unit'));
?>
 results:
</h3>

<div class="results">

	<div class="item-def">
		<div class="value">
        <?php 
foreach ($answers as $answer) {
    ?>
        	<div><?php 
    echo $answer->getProperty('nr_answer');
    ?>
. <?php 
Пример #6
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');
        }
    }
}
?>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1" class="action_buttons" style="padding-top: 5px;">
Пример #7
0
 /**
  * Get vote results
  * @param int $p_fk_debate_nr
  * @param int $p_fk_debate_lang
  * @param int $limit from end time backwards
  */
 public function getResults($p_fk_debate_nr, $p_fk_debate_lang, $limit = null, $start = null)
 {
     $debate = new Debate($p_fk_debate_lang, $p_fk_debate_nr);
     $tunit = strtolower($debate->getProperty('results_time_unit'));
     $query = "\n        \tSELECT\n\t\t\t\t`fk_debate_nr`,\n                COUNT(`id_vote`) as `vote_cnt`,\n                `fk_answer_nr`,\n                %s `dg`,\n                UNIX_TIMESTAMP(DATE(`added`)) `time`\n\t\t\tFROM `plugin_debate_vote`\n            WHERE `fk_debate_nr` = '{$p_fk_debate_nr}' %s %s\n            GROUP BY `dg`, `fk_answer_nr`\n            ORDER BY `dg` ASC, `fk_answer_nr` ASC";
     $sqlLimit = '';
     if (!is_null($limit)) {
         $sqlLimit = "AND UNIX_TIMESTAMP(`added`) > {$limit}";
     }
     $sqlStart = '';
     if (!is_null($start)) {
         $sqlStart = "AND UNIX_TIMESTAMP(`added`) < {$start}";
     }
     switch ($tunit) {
         case 'daily':
             $query = sprintf($query, "YEAR(added)*1000 + DAYOFYEAR(added)", $sqlLimit, $sqlStart);
             break;
         case 'weekly':
             $query = sprintf($query, "YEAR(added)*100 + WEEKOFYEAR(added)", $sqlLimit, $sqlStart);
             break;
         case 'monthly':
             $query = sprintf($query, "YEAR(added)*100 + MONTH(added)", $sqlLimit, $sqlStart);
             break;
         default:
             return array();
     }
     global $g_ado_db;
     $sqlr = $g_ado_db->execute($query);
     $vote_total = 0;
     $tunit = null;
     $results = $current_result = array();
     while ($row = $sqlr->fetchRow()) {
         if ($tunit != $row['dg']) {
             $tunit = $row['dg'];
             $current_result['total_count'] = $vote_total;
             $vote_total = 0;
             $current_result =& $results[];
             $current_result['time'] = $row['time'];
         }
         $vote_total += $row['vote_cnt'];
         $current_result[] = array('answer_nr' => $row['fk_answer_nr'], 'value' => $row['vote_cnt']);
     }
     $current_result['total_count'] = $vote_total;
     return $results;
 }
Пример #8
0
 public static function SyncNrOfAnswers($p_fk_language_id, $p_fk_debate_nr)
 {
     global $g_ado_db;
     $debate = new Debate($p_fk_language_id, $p_fk_debate_nr);
     if (count($debate->getTranslations()) > 1) {
         $nr_of_answers = $debate->getProperty('nr_of_answers');
         $query = "DELETE FROM   plugin_debate_answer\n                      WHERE         fk_debate_nr = {$p_fk_debate_nr}\n                                AND fk_language_id = {$p_fk_language_id}\n                                AND nr_answer > {$nr_of_answers}";
         $g_ado_db->execute($query);
         Debate::triggerStatistics($p_fk_debate_nr);
     }
 }