function cms_block_poll() { global $db, $cache, $config, $template, $images, $user, $lang, $block_id, $cms_config_vars; global $kb_mode_append, $is_auth, $lofi, $bbcode; $template->_tpldata['poll_option.'] = array(); if ($cms_config_vars['md_poll_type'][$block_id] == 0) { $order_sql = 'ORDER BY t.topic_time DESC'; } else { $order_sql = 'ORDER BY RAND()'; } if ($cms_config_vars['md_poll_type'][$block_id] != 2 && !empty($cms_config_vars['md_poll_forum_id'][$block_id])) { $in_sql = 't.forum_id IN (' . $cms_config_vars['md_poll_forum_id'][$block_id] . ') AND'; } elseif (!empty($cms_config_vars['md_poll_topic_id'][$block_id])) { $in_sql = 't.topic_id = ' . intval($cms_config_vars['md_poll_topic_id'][$block_id]) . ' AND'; } $sql = "SELECT t.*\n\t\t\tFROM " . TOPICS_TABLE . " AS t\n\t\t\tWHERE " . $in_sql . " t.topic_status <> " . TOPIC_LOCKED . "\n\t\t\t\tAND t.topic_status <> " . TOPIC_MOVED . "\n\t\t\t\tAND t.poll_start <> 0\n\t\t\t" . $order_sql . "\n\t\t\tLIMIT 0,1"; $result = $db->sql_query($sql); $total_topics = $db->sql_numrows($result); if (!empty($total_topics)) { $topic_data = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!class_exists('class_topics')) { @(include_once IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT); } $class_topics = new class_topics(); // Set some vars to make sure block is displayed correctly $forum_id_append = POST_FORUM_URL . '=' . $topic_data['forum_id']; $topic_id_append = POST_TOPIC_URL . '=' . $topic_data['topic_id']; // Store temp config value $portal_vote_graphic_length = $cms_config_vars['md_poll_bar_length'][$block_id]; $config_vote_graphic_length = $config['vote_graphic_length']; $config['vote_graphic_length'] = $portal_vote_graphic_length; $class_topics->poll_display($topic_data, true); // Reset original config value $config['vote_graphic_length'] = $config_vote_graphic_length; $template->assign_vars(array('S_POLL_EXISTS' => true, 'U_VIEW_RESULTS' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . $forum_id_append . '&' . $topic_id_append))); } else { $template->assign_vars(array('S_POLL_EXISTS' => false)); } }
'S_MARK_AR_IMG' => $s_mark_ar_img, // UPI2DB - END 'U_TOPIC_VIEWED' => $topic_viewed_link, 'U_VIEW_FORUM' => $view_forum_url, 'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url, 'U_VIEW_NEWER_TOPIC' => $view_next_topic_url, 'U_THANKS' => $thank_topic_url, 'U_POST_NEW_TOPIC' => $new_topic_url, 'U_POST_REPLY_TOPIC' => $reply_topic_url ) ); // Does this topic contain a poll? if (!empty($forum_topic_data['poll_start'])) { $class_topics->poll_display($forum_topic_data, false); } // Event Registration - BEGIN include(IP_ROOT_PATH . 'includes/viewtopic_events_reg.' . PHP_EXT); // Event Registration - END init_display_post_attachments($forum_topic_data['topic_attachment']); // Begin Thanks Mod // Get topic thanks if ($show_thanks) { // Select Format for the date $timeformat = "d F"; $sql = "SELECT u.user_id, u.username, u.user_active, u.user_color, t.thanks_time