Exemplo n.º 1
0
 function display_poll($tID, $preview = false, $uID = null)
 {
     global $tplt, $wgRequest;
     if ($uID == null) {
         $uID = isset($this->uID) ? $this->uID : '0';
     }
     if (!isset($tplt->tplts['poll_display_results']) or empty($tplt->tplts['poll_display_results'])) {
         $tplt->add_tplts(array("'poll_display_options'", "'poll_display_results'", "'poll_opt_options'", "'poll_display_result_bars'", "'poll_display'"), true);
     }
     $word['word_poll_question'] = get_awcsforum_word('word_poll_question');
     $Pass['thread_link'] = null;
     if ($preview) {
         $word['word_votes'] = get_awcsforum_word('word_votes');
         $word['word_total_percent'] = get_awcsforum_word('word_total_percent');
         $word['word_poll_option'] = get_awcsforum_word('word_poll_option');
         $word['word_total_votes'] = get_awcsforum_word('word_total_votes');
         $opt = null;
         foreach ($_POST as $k => $v) {
             if (!empty($v)) {
                 if (strstr($k, 'poll_opt')) {
                     ++$opt;
                     if (trim(awcsforum_post_cls::CleanThreadTitle($v)) != '') {
                         $p['poll_choice']['poll_opt' . $opt] = trim(awcsforum_post_cls::CleanThreadTitle($v));
                     }
                 }
             }
         }
         $p['poll_results'] = array();
         #$p['poll_results'] = '0';
         $Pass = self::display_result_bars($p);
         $Pass['poll_q'] = $wgRequest->getVal('pollq');
         $poll = $tplt->phase($word, $Pass, 'poll_display', true);
         //$poll .= '<br /><br />';
         require awc_dir . 'includes/post_box.php';
         $posting_box = new awcs_forum_posting_box();
         $posting_box->tID = $this->tID;
         $posting_box->fID = $this->fID;
         $poll .= $posting_box->poll_form_display();
         return $poll;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $awc_f_polls = $dbr->tableName('awc_f_polls');
     $awc_f_forums = $dbr->tableName('awc_f_forums');
     //  $awc_f_threads = $dbr->tableName( 'awc_f_threads' );
     // die($tID);
     $poll_sql = "SELECT * FROM {$awc_f_polls} WHERE poll_threadid={$tID} ORDER BY poll_id ASC";
     // poll_open
     // elseif($this->t_poll AND $this->t_pollopen == 0 AND UserPerm >= 2) {
     // word_pollClosed
     $poll = null;
     $poll_res = $dbr->query($poll_sql);
     # $poll_r = $dbr->fetchRow($poll_res);
     while ($poll_r = $dbr->fetchObject($poll_res)) {
         // $poll_r = $dbr->fetchRow($poll_res);
         $Pass['pollID'] = $poll_r->poll_id;
         $Pass['tID'] = $poll_r->poll_threadid;
         $Pass['poll_q'] = $poll_r->poll_q;
         $Pass['poll_q'] = '<a href="' . awc_url . 'st/id' . $tID . '">' . $Pass['poll_q'] . '</a> ';
         $p = array();
         $p['poll_choice'] = @unserialize($poll_r->poll_choice);
         $p['poll_results'] = @unserialize($poll_r->poll_a);
         $p['poll_whovoted'] = @unserialize($poll_r->poll_whovoted);
         $p['poll_q'] = '<a href="' . awc_url . 'st/id' . $tID . '">' . $poll_r->poll_q . '</a> ';
         // $Pass['thread_link'] = '<a href="'.awc_url.'/st/id'.$tID.'">'.get_awcsforum_word('word_votes').'</a> ';
         $poll_buttons = self::poll_buttons($poll_r->poll_open, $poll_r->poll_id, $tID);
         // 2.5.8
         #unset($poll_r, $p_res);
         if (!@array_key_exists($uID, $p['poll_whovoted']) and $uID != 0) {
             # $p['options'] =  $calling_class->skin_thread->poll_displayoptions_select($p['poll_choice'],$pIDs );
             if ($poll_r->poll_open == 1) {
                 $t = 0;
                 $Pass['select_options'] = null;
                 foreach ($p['poll_choice'] as $f => $v) {
                     if ($v != '') {
                         ++$t;
                         $Pass['url'] = awc_url . 'post/todo_poll_vote';
                         $Pass['value'] = $f;
                         $Pass['id'] = "polloption{$f}";
                         $word['option'] = $v;
                         // word_pollnovote
                         #$word['option'] = get_awcsforum_word('word_votes');
                         $word['submit'] = get_awcsforum_word('word_vote');
                         $Pass['select_options'] .= $tplt->phase($word, $Pass, 'poll_opt_options');
                     }
                 }
                 $Pass['value'] = '-1';
                 $Pass['id'] = "polloption_opt" . ($t + 1);
                 $word['option'] = get_awcsforum_word('word_pollnovote');
                 $Pass['select_options'] .= $tplt->phase($word, $Pass, 'poll_opt_options');
                 $Pass['options'] = $tplt->phase($word, $Pass, 'poll_display_options');
             } else {
                 $Pass = self::display_result_bars($p);
                 $Pass['poll_q'] = $p['poll_q'];
                 $Pass['options'] .= get_awcsforum_word('word_pollClosed');
                 // 2.5.8
             }
             $Pass['options'] .= $poll_buttons;
             // 2.5.8
         } elseif ($uID != 0) {
             if (!empty($p['poll_results'])) {
                 $Pass = self::display_result_bars($p);
                 $Pass['poll_q'] = $p['poll_q'];
             } else {
                 $Pass['options'] = null;
             }
             if ($poll_r->poll_open == 0) {
                 $Pass['options'] .= get_awcsforum_word('word_pollClosed');
                 // 2.5.8
             }
             $Pass['options'] .= $poll_buttons;
             // 2.5.8
         } else {
             if ($poll_r->poll_open == 0) {
                 $Pass = self::display_result_bars($p);
                 $Pass['poll_q'] = $p['poll_q'];
                 $Pass['options'] .= get_awcsforum_word('word_pollClosed');
                 // 2.5.8
             } else {
                 $option = null;
                 foreach ($p['poll_choice'] as $f => $v) {
                     if ($v != '') {
                         $option .= $v . '<br />';
                     }
                 }
                 $Pass['options'] = $option;
             }
             #$Pass['options'] = get_awcsforum_word('word_poll_guest_message');
         }
         if (!isset($tplt->tplts['poll_display']) or empty($tplt->tplts['poll_display'])) {
             $tplt->add_tplts(array("'poll_display'"), true);
             // need to find out why some severs need this and some dont.
         }
         $poll .= $tplt->phase($word, $Pass, 'poll_display');
         if ($this->multi_polls == '0') {
             break;
         }
     }
     return $poll;
 }
Exemplo n.º 2
0
 function poll_form()
 {
     global $wgOut;
     if ($this->polls_enabled != '1') {
         return '';
     }
     require awc_dir . 'includes/post_box.php';
     $posting_box = new awcs_forum_posting_box();
     $posting_box->tID = $this->tID;
     $posting_box->fID = $this->fID;
     $html = $posting_box->poll_form_display();
     $wgOut->addHTML($html);
 }