function ratings_view_topic() { global $userdata, $template, $db, $board_config, $theme, $phpbb_root_path, $phpEx, $lang, $page_title, $forum_id, $topic_id; $rath_auth_data = rate_auth($userdata['user_id'], $forum_id, $topic_id); if ($rath_auth_data == RATE_AUTH_NONE) { $template->assign_block_vars("noauth", array("RATE_TOPIC_USER" => '')); } else { if ($rath_auth_data != RATE_AUTH_PRVIATE || $rath_auth_data == RATE_AUTH_PRVIATE && $userdata['user_id'] != ANONYMOUS) { if ($rath_auth_data == RATE_AUTH_DENY) { $template->assign_block_vars("noauth", array("RATE_TOPIC_USER" => sprintf($lang['Not_Authorized_To_Rate']))); } else { $select_rate_choices = "<select name=\"rating\">"; for ($i = 1; $i <= $board_config['rating_max']; $i++) { $select_rate_choices .= "<option value=\"" . $i . "\"{$selected}>" . $i . "</option>"; } $select_rate_choices .= "</select>"; if (!rating_inserted($userdata['user_id'], $topic_id)) { $template->assign_block_vars("rate", array("L_CHOOSE_RATING" => $lang['Choose_Rating'], "L_RATE" => $lang['Rate'], "S_RATE_SELECT" => $select_rate_choices, "S_HIDDEN_FIELDS" => '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="rate_mode" value="rate" />', "S_RATE_ACTION" => append_sid("rate.{$phpEx}"), "RATE_TOPIC_USER" => "")); } else { if ($board_config['allow_rerate']) { $template->assign_block_vars("rerate", array("L_CHANGE_RATING" => $lang['Change_Rating'], "L_RATE" => $lang['Rate'], "S_RATE_SELECT" => $select_rate_choices, "S_HIDDEN_FIELDS" => '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="rate_mode" value="rerate" />', "S_RATE_ACTION" => append_sid("rate.{$phpEx}"))); } $template->assign_block_vars("rated", array("RATE_TOPIC_USER" => sprintf($lang['Already_Rated'], rating_value($userdata['user_id'], $topic_id)))); } } // //Common Output Variables // $rating_row = rating_stats($topic_id); $template->assign_vars(array("L_RATE_TOPIC_USER_ANON" => $board_config['check_anon_ip_when_rating'] && $userdata['user_id'] == ANONYMOUS ? sprintf($lang['Or_Someone_From_IP']) : "", "RATE_TOPIC_STATS" => sprintf($lang['Rate_Stats'], $rating_row['average'], $rating_row['minimum'], $rating_row['maximum'], $rating_row['number_of_rates']), "TOPIC_TITLE" => id_to_value($topic_id, 'topic'), "L_SUMMARY" => $lang['Summary'])); if ($board_config['allow_ext_rating']) { $template->assign_vars(array("FULL_STATS_URL" => sprintf($lang['View_Details'], append_sid("rate.{$phpEx}?rate_mode=detailed&topic_id=" . $topic_id)))); } $template->set_filenames(array("rate_viewtopic" => "rate_viewtopic.tpl")); $template->assign_var_from_handle('RATING_VIEWTOPIC', 'rate_viewtopic'); } } }
function ratings_view_topic() { global $db, $config, $template, $theme, $user, $lang, $forum_id, $topic_id; $rath_auth_data = rate_auth($user->data['user_id'], $forum_id, $topic_id); if ($rath_auth_data == RATE_AUTH_NONE) { $template->assign_block_vars('noauth', array('RATE_TOPIC_USER' => $lang['Not_Authorized_To_Rate'])); } elseif ($rath_auth_data != RATE_AUTH_PRIVATE || $rath_auth_data == RATE_AUTH_PRIVATE && $user->data['user_id'] != ANONYMOUS) { if ($rath_auth_data == RATE_AUTH_DENY) { $template->assign_block_vars('noauth', array('RATE_TOPIC_USER' => $lang['Not_Authorized_To_Rate'])); } else { if (!rating_inserted($user->data['user_id'], $topic_id)) { $rating_inserted = false; $template->assign_block_vars('rate_link', array()); $rate_value = 1; } else { $rating_inserted = true; $template->assign_block_vars('rerate_link', array()); $rate_value = rating_value($user->data['user_id'], $topic_id); } $select_rate_choices = '<select id="rating" name="rating" onchange="set_rate(this.selectedIndex+1,' . $config['rating_max'] . ')">'; for ($i = 1; $i <= $config['rating_max']; $i++) { $selected = $i == $rate_value ? ' selected="selected"' : ''; $select_rate_choices .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; if ($i <= $rate_value) { $rate_class = 'img-rate-on'; } else { $rate_class = 'img-rate-off'; } $hover_action = 'set_rate(' . $i . ',' . $config['rating_max'] . ');'; $click_action = $hover_action . ' submit_rate(); return false;'; if ($rating_inserted == false) { $template->assign_block_vars('rate_link.rate_row', array('RATE_LINK' => '<a href="#" onclick="' . $click_action . '" class="' . $rate_class . '" onmouseover="' . $hover_action . '" id="rate' . $i . '"> </a>')); } else { $template->assign_block_vars('rerate_link.rate_row', array('RATE_LINK' => '<a href="#" onclick="' . $click_action . '" class="' . $rate_class . '" onmouseover="' . $hover_action . '" id="rate' . $i . '"> </a>')); } } $select_rate_choices .= '</select>'; if ($rating_inserted == false) { $template->assign_block_vars('rate', array('L_CHOOSE_RATING' => $lang['Choose_Rating'], 'L_RATE' => $lang['Rate'], 'S_RATE_SELECT' => $select_rate_choices, 'S_HIDDEN_FIELDS' => '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="rate_mode" value="rate" />', 'S_RATE_ACTION' => append_sid('rate.' . PHP_EXT), 'RATE_TOPIC_USER' => '')); } else { if ($config['allow_rerate']) { $template->assign_block_vars('rerate', array('L_CHANGE_RATING' => $lang['Change_Rating'], 'L_RATE' => $lang['Rate'], 'S_RATE_SELECT' => $select_rate_choices, 'S_HIDDEN_FIELDS' => '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="rate_mode" value="rerate" />', 'S_RATE_ACTION' => append_sid('rate.' . PHP_EXT))); } $template->assign_block_vars('rated', array('RATE_TOPIC_USER' => sprintf($lang['Already_Rated'], $rate_value))); } } //Common Output Variables $rating_row = rating_stats($topic_id); $template->assign_vars(array('L_RATE_TOPIC_USER_ANON' => $config['check_anon_ip_when_rating'] && $user->data['user_id'] == ANONYMOUS ? sprintf($lang['Or_Someone_From_IP']) : '', 'RATE_TOPIC_STATS' => sprintf($lang['Rate_Stats'], $rating_row['average'], $rating_row['minimum'], $rating_row['maximum'], $rating_row['number_of_rates']), 'RATE_AVERAGE' => $rating_row['average'], 'RATE_MINIMUM' => empty($rating_row['minimum']) ? 0 : $rating_row['minimum'], 'RATE_MAXIMUM' => empty($rating_row['maximum']) ? 0 : $rating_row['maximum'], 'NUMBER_OF_RATES' => $rating_row['number_of_rates'], 'L_SUMMARY' => $lang['Summary'])); if (!empty($config['allow_ext_rating']) && $rating_row['number_of_rates'] > 0 || $rating_row['number_of_rates'] > 0 && $user->data['user_level'] == ADMIN) { $template->assign_vars(array('FULL_STATS_URL' => '[ ' . sprintf($lang['View_Details'], append_sid('rate.' . PHP_EXT . '?rate_mode=detailed&topic_id=' . $topic_id)) . ' ]')); } $template->set_filenames(array('rate_viewtopic' => 'rate_viewtopic.tpl')); $template->assign_var_from_handle('RATING_VIEWTOPIC', 'rate_viewtopic'); } }