Ejemplo n.º 1
0
            echo '<div>
        ' . JText::_('FELDOLGOZAS_TURELMET_KEREK') . '
      </div>
      <script type="text/javascript">
        function feldolgozasRefresh() {
          location="' . JURI::base() . 'index.php?option=com_szavazasok&view=szavazasok&task=eredmeny&szavazas=' . $this->Szavazas_id . '&temakor=' . $this->Temakor_id . '";
        }
        setTimeout("feldolgozasRefresh()",5000);
      </script>
      ';
            return;
        }
    }
    // ha már nem történt szavazat generálás akkor a condordce feldolgozás és az eredményt
    // tároljuk a cahe -ba
    $schulze = new Condorcet($db, $organization, $pollid);
    $report = $schulze->report();
    $db->setQuery('delete from #__poll_value_cache where pollid="' . $pollid . '"');
    $db->query();
    // a kiértékelés eredményét csak lezárt szavazásnál cacheljük
    if ($poll->lezart == 1) {
        $db->setQuery('insert into #__poll_value_cache values (
    "' . $organization . '","' . $pollid . '","' . $voteCount . '","' . urlencode($report) . '"
    )');
        $db->query();
    }
} else {
    // ha van akkor a cahcelt reportot jelenitjuük meg
    $report = urldecode($res[0]->report);
}
// részletező infó kiirása
Ejemplo n.º 2
0
	limit 1');
                                    $szavazas = $db->loadObject();
                                    JRequest::setVar('szavazas', $szavazas->id);
                                    JRequest::setVar('temakor', $szavazas->temakor_id);
                                    if ($szavazas) {
                                        // ha van cachelt eredmény beolvasom azt  és azt használom
                                        $db->setQuery('select * from #__poll_value_cache where pollid="' . $szavazas->id . '" and vote_count = -1');
                                        $res = $db->loadObject();
                                        if ($res) {
                                            $result1 = JSON_decode($res->report);
                                            $result = $result->result;
                                            $result->voters = $result1->voters;
                                            $result->api_status = $result1->api_status;
                                        } else {
                                            // ha nincs most képzem az eredményt
                                            $c = new Condorcet($db, $szavazas->temmakor_id, $szavazas->id);
                                            $result = $c->report('json');
                                            $db->setQuery('select count(*) cc from #__szavazok where szavazas_id = ' . $db->quote($szavazas->id));
                                            $res = $db->loadObject();
                                            $result->voters = $res->cc;
                                            $result->api_status = "OK";
                                            // ha lezárt szavazás akkor tárolom a cache -be
                                            if ($szavazas->lezart == 1) {
                                                $db->setQuery('INSERT INTO #__poll_value_cache 
	        VALUES (' . $szavazas->temakor_id . ', 
	         ' . $szavazas->id . ', 
	         -1, 
	         ' . $db->quote(JSON_encode($result)) . '
	        )');
                                                /*
                                                $fp = fopen('debug.txt','w+');