Bug : | Enable field page_rating in the table sed_pages |
Status : | Fixed |
Severity : | Enhancement |
Reporter : | Amro ![]() |
Updated by : | Amro ![]() |
Category | General |
Version : | 173 |
Frequency : | Consistently |
Fixed in : | 175 |
Details : | Need to use a field page_rating in the table sed_pages storage page rank, similar to the comments page_com =========================== Задействовать поле page_rating в таблице sed_pages Modified function sed_build_ratings /* ------------------ */ function sed_build_ratings($code, $url, $display, $allow = TRUE) { global $db_ratings, $db_rated, $db_users, $db_pages, $cfg, $usr, $sys, $L; list($usr['auth_read_rat'], $usr['auth_write_rat'], $usr['isadmin_rat']) = sed_auth('ratings', 'a'); if ($cfg['disable_ratings'] || !$usr['auth_read_rat']) { return (array('','')); } $sql = sed_sql_query("SELECT * FROM $db_ratings WHERE rating_code='$code' LIMIT 1"); if ($row = sed_sql_fetchassoc($sql)) { $rating_average = $row['rating_average']; $yetrated = TRUE; if ($rating_average<1) { $rating_average = 1; } elseif ($rating_average>10) { $rating_average = 10; } $rating_cntround = round($rating_average, 0); } else { $yetrated = FALSE; $rating_average = 0; $rating_cntround = 0; } $res = "<a href=\"".$url."&ratings=1\"><img src=\"skins/".$usr['skin']."/img/system/vote".$rating_cntround.".gif\" alt=\"\" /></a>"; if ($display) { $ina = sed_import('ina','G','ALP'); $newrate = sed_import('newrate','P','INT'); $alr_rated = sed_sql_result(sed_sql_query("SELECT COUNT(*) FROM ".$db_rated." WHERE rated_userid=".$usr['id']." AND rated_code = '".sed_sql_prep($code)."'"), 0, 'COUNT(*)'); if ($ina=='send' && $newrate>=1 && $newrate<=10 && $usr['auth_write_rat'] && $alr_rated<=0 && $allow) { /* == Hook for the plugins == */ $extp = sed_getextplugins('ratings.send.first'); if (is_array($extp)) { foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } } /* ===== */ if (!$yetrated) { $sql = sed_sql_query("INSERT INTO $db_ratings (rating_code, rating_state, rating_average, rating_creationdate, rating_text) VALUES ('".sed_sql_prep($code)."', 0, ".(int)$newrate.", ".(int)$sys['now_offset'].", '') "); } $sql = sed_sql_query("INSERT INTO $db_rated (rated_code, rated_userid, rated_value) VALUES ('".sed_sql_prep($code)."', ".(int)$usr['id'].", ".(int)$newrate.")"); $sql = sed_sql_query("SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code'"); $rating_voters = sed_sql_result($sql, 0, "COUNT(*)"); $ratingnewaverage = ($rating_average * ($rating_voters - 1) + $newrate) / ( $rating_voters ); $sql = sed_sql_query("UPDATE $db_ratings SET rating_average='$ratingnewaverage' WHERE rating_code='$code'"); //------------------------------- if (mb_substr($code, 0, 1) == 'p') { $page_id = mb_substr($code, 1, 10); $sql = sed_sql_query("UPDATE $db_pages SET page_rating='$ratingnewaverage' WHERE page_id=".$page_id); } //------------------------------- /* == Hook for the plugins == */ $extp = sed_getextplugins('ratings.send.done'); if (is_array($extp)) { foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } } /* ===== */ header("Location: $url&ratings=1&ina=added"); exit; } $votedcasted = ($ina=='added') ? 1 : 0; $rate_form = "<input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"1\" /><img src=\"skins/".$usr['skin']."/img/system/vote1.gif\" alt=\"\" /> 1 - ".$L['rat_choice1']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"2\" /><img src=\"skins/".$usr['skin']."/img/system/vote2.gif\" alt=\"\" /> 2 - ".$L['rat_choice2']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"3\" /><img src=\"skins/".$usr['skin']."/img/system/vote3.gif\" alt=\"\" /> 3 - ".$L['rat_choice3']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"4\" /><img src=\"skins/".$usr['skin']."/img/system/vote4.gif\" alt=\"\" /> 4 - ".$L['rat_choice4']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"5\" checked=\"checked\" /><img src=\"skins/".$usr['skin']."/img/system/vote5.gif\" alt=\"\" /> 5 - ".$L['rat_choice5']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"6\" /><img src=\"skins/".$usr['skin']."/img/system/vote6.gif\" alt=\"\" /> 6 - ".$L['rat_choice6']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"7\" /><img src=\"skins/".$usr['skin']."/img/system/vote7.gif\" alt=\"\" /> 7 - ".$L['rat_choice7']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"8\" /><img src=\"skins/".$usr['skin']."/img/system/vote8.gif\" alt=\"\" /> 8 - ".$L['rat_choice8']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"9\" /><img src=\"skins/".$usr['skin']."/img/system/vote9.gif\" alt=\"\" /> 9 - ".$L['rat_choice9']."<br /><input type=\"radio\" class=\"radio\" name=\"newrate\" value=\"10\" /><img src=\"skins/".$usr['skin']."/img/system/vote10.gif\" alt=\"\" /> 10 - ".$L['rat_choice10']; if ($usr['id']>0) { $sql1 = sed_sql_query("SELECT rated_value FROM $db_rated WHERE rated_code='$code' AND rated_userid='".$usr['id']."' LIMIT 1"); if ($row1 = sed_sql_fetchassoc($sql1)) { $alreadyvoted = TRUE; $rating_uservote = $L['rat_alreadyvoted']." (".$row1['rated_value'].")"; } } $t = new XTemplate(sed_skinfile('ratings')); /* == Hook for the plugins == */ $extp = sed_getextplugins('ratings.main'); if (is_array($extp)) { foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } } /* ===== */ if (!empty($error_string)) { $t->assign("RATINGS_ERROR_BODY",$error_string); $t->parse("RATINGS.RATINGS_ERROR"); } if ($yetrated) { $sql = sed_sql_query("SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code' "); $rating_voters = sed_sql_result($sql, 0, "COUNT(*)"); $rating_average = $row['rating_average']; $rating_since = $L['rat_since']." ".date($cfg['dateformat'], $row['rating_creationdate'] + $usr['timezone'] * 3600); if ($rating_average<1) { $rating_average = 1; } elseif ($ratingaverage>10) { $rating_average = 10; } $rating = round($rating_average,0); $rating_averageimg = "<img src=\"skins/".$usr['skin']."/img/system/vote".$rating.".gif\" alt=\"\" />"; $sql = sed_sql_query("SELECT COUNT(*) FROM $db_rated WHERE rated_code='$code' "); $rating_voters = sed_sql_result($sql, 0, "COUNT(*)"); } else { $rating_voters = 0; $rating_since = ''; $rating_average = $L['rat_notyetrated']; $rating_averageimg = ''; } $t->assign(array( "RATINGS_AVERAGE" => $rating_average, "RATINGS_AVERAGEIMG" => $rating_averageimg, "RATINGS_VOTERS" => $rating_voters, "RATINGS_SINCE" => $rating_since )); if ($usr['id']>0 && $votedcasted && $allow) { $t->assign(array( "RATINGS_EXTRATEXT" => $L['rat_votecasted'], )); $t->parse("RATINGS.RATINGS_EXTRA"); } elseif ($usr['id']>0 && $alreadyvoted && $allow) { $t->assign(array( "RATINGS_EXTRATEXT" => $rating_uservote, )); $t->parse("RATINGS.RATINGS_EXTRA"); } elseif ($usr['id']==0 && $allow) { $t->assign(array( "RATINGS_EXTRATEXT" => $L['rat_registeredonly'], )); $t->parse("MAIN.RATINGS_EXTRA"); } elseif ($usr['id']>0 && !$alreadyvoted && $allow) { $t->assign(array( "RATINGS_NEWRATE_FORM_SEND" => $url."&ratings=1&ina=send", "RATINGS_NEWRATE_FORM_VOTER" => $usr['name'], "RATINGS_NEWRATE_FORM_RATE" => $rate_form )); $t->parse("RATINGS.RATINGS_NEWRATE"); } /* ==== sed 173 */ if (!$allow) { $t-> assign(array( "RATINGS_DISABLETEXT" => $L['rat_disable'] )); $t->parse("RATINGS.RATINGS_DISABLE"); } /* === /* == Hook for the plugins == */ $extp = sed_getextplugins('ratings.tags'); if (is_array($extp)) { foreach($extp as $k => $pl) { include('plugins/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } } /* ===== */ $t->parse("RATINGS"); $res_display = $t->text("RATINGS"); } else { $res_display = ''; } return(array($res, $res_display)); } /* ------------------ */
|
Items affected : | functions.php |
07-04-13 01:11 Amro ![]() И ещё одна ошибка : $t->parse("MAIN.RATINGS_EXTRA"); надоб поправить на $t->parse("RATINGS.RATINGS_EXTRA"); |