Code: Selecteer alles
## MOD Title: Topic Points
## MOD Author: drathbun < N/A > (Dave Rathbun) http://www.phpBBDoctor.com
## MOD Description: This MOD will allow users to assign points (+1, 0, -1) to a topic.
## MOD Version: 0.6.4
1:
Top 10 hoogst beoordeelde topics all time.
2:
Top 5 hoogst beoordeelde topics vandaag
3:
Ezportal, die het nieuws etc "fetched" van mijn forum, bij deze ook de rating meepakt...
4:
Iets anders: In fetchpost.php staat dit
Code: Selecteer alles
// img
$text = str_replace("[img:$uid]","", $text);
$text = str_replace("[/img:$uid]", "", $text);
Ben alvast aan de slag gegaan met 3, maar er verschijnt niks (ook geen foutmelding ofzo)
Code: Selecteer alles
#
#-----[ OPEN ]-------------------------------------
#
fetchposts.php
#
#-----[ FIND ]-------------------------------------
# On or about line 147; find text might not be a complete line
#
p.post_id
#
#-----[ IN-LINE FIND ]-------------------------------------
#
t.topic_vote
#
#-----[ IN-LINE AFTER, ADD ]-------------------------------------
#
, t.topic_rating, t.topic_votes, t.topic_poster, f.topic_points_enabled
#
#-----[ FIND ]-------------------------------------
# On or about line 149; find text might not be a complete line
#
$sql = "SELECT t.topic_id,
#
#-----[ IN-LINE FIND ]-------------------------------------
#
t.topic_vote
#
#-----[ IN-LINE AFTER, ADD ]-------------------------------------
#
, t.topic_rating, t.topic_votes, t.topic_poster, f.topic_points_enabled
#
#-----[ FIND ]-------------------------------------
# On or about line 571; find text might not be a complete line
#
make_jumpbox('viewforum.'.$phpEx, $forum_id);
#
#-----[ AFTER, ADD ]-------------------------------------
#
// BEGIN Topic Points 0.6.4 (www.phpBBDoctor.com)
// First, check to see if topic ratings are enabled for
// this board, then check to see if ratings are enabled
// for this forum. If not, we're already done.
if ( $board_config['phpbbdoctor_topic_points_enabled'] && $forum_topic_data['topic_points_enabled'] )
{
// Skip the next block if the user is not logged in, as
// we require a user_id to record the topic point vote
// Also check to see if a user is allowed to rate their
// own topic.
$allow_vote = TRUE;
if ( !($board_config['phpbbdoctor_topic_points_user_rate_self']) && ($userdata['user_id'] == $forum_topic_data['topic_poster']) )
{
$allow_vote = FALSE;
}
if ( !($userdata['session_logged_in']) )
{
$allow_vote = FALSE;
}
if ( $allow_vote )
{
// Note: the overhead of an extra query here is far
// outweighed by an outer join in the topic query,
// so in this case it really is more efficient to
// run a separate query than to join into a larger
// query above. By creating a separate query we
// don't need to worry about an outer join, and
// we skip all of this processing for guests too.
$sql = 'SELECT topic_point
FROM ' . TOPIC_POINTS_TABLE . '
WHERE topic_id = ' . $topic_id . '
AND user_id = ' . $userdata['user_id'];
if (!($result = $db->sql_query($sql)))
{
message_die(GENERAL_ERROR, 'DEBUG: Unable to query user topic point table');
}
if ( $row = $db->sql_fetchrow($result) )
{
$current_topic_point = $row['topic_point'];
}
else
{
$current_topic_point = TOPIC_POINT_MISSING;
}
$db->sql_freeresult($result);
}
else
{
$current_topic_point = TOPIC_POINT_NOVOTE;
}
$s_ratings = $lang['Topic_points_rate_this_topic'];
// Build out images
$img_point_minus = '<img src="templates/' . $theme['template_name'] . '/images/tp_minus_' . ($current_topic_point == TOPIC_POINT_MINUS ? 'on' : 'off') . '.gif" border="0" hspace="0" alt="Topic Points" title="' . $lang['Topic_points_minus_1'] . '" />';
$img_point_neutral = '<img src="templates/' . $theme['template_name'] . '/images/tp_neut_' . ($current_topic_point == TOPIC_POINT_ZERO ? 'on' : 'off') . '.gif" border="0" hspace="0" alt="Topic Points" title="' . $lang['Topic_points_plus_0'] . '" />';
$img_point_plus = '<img src="templates/' . $theme['template_name'] . '/images/tp_plus_' . ($current_topic_point == TOPIC_POINT_PLUS ? 'on' : 'off') . '.gif" border="0" hspace="0" alt="Topic Points" title="' . $lang['Topic_points_plus_1'] . '" />';
// Geez, is this code ugly or what? Whatever, it works...
// The problem is you have to build three links based on five
// scenarios. The user might have voted already,
// and there are three options for past votes. The user
// might not have voted, that's four. And if the user
// is the topic starter and the config doesn't allow
// voting for your own topics, thats five. And if there
// is a guest viewing, that's six. Bleh.
$base_url = "topicpoints.$phpEx?t=$topic_id&start=$start";
switch ($current_topic_point)
{
case TOPIC_POINT_MINUS:
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_MINUS."&x=1") . '">' . $img_point_minus . '</a>';
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_ZERO."&x=0") . '">' . $img_point_neutral . '</a>';
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_PLUS."&x=0") . '">' . $img_point_plus . '</a>';
break;
case TOPIC_POINT_ZERO:
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_MINUS."&x=0") . '">' . $img_point_minus . '</a>';
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_ZERO."&x=1") . '">' . $img_point_neutral . '</a>';
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_PLUS."&x=0") . '">' . $img_point_plus . '</a>';
break;
case TOPIC_POINT_PLUS:
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_MINUS."&x=0") . '">' . $img_point_minus . '</a>';
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_ZERO."&x=0") . '">' . $img_point_neutral . '</a>';
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_PLUS."&x=1") . '">' . $img_point_plus . '</a>';
break;
case TOPIC_POINT_MISSING:
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_MINUS."&x=0") . '">' . $img_point_minus . '</a>';
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_ZERO."&x=0") . '">' . $img_point_neutral . '</a>';
$s_ratings .= '<a href="' . append_sid("$base_url&mode=".TOPIC_POINT_PLUS."&x=0") . '">' . $img_point_plus . '</a>';
break;
case TOPIC_POINT_NOVOTE:
if ($userdata['user_id'] == $forum_topic_data['topic_poster'])
{
$s_ratings = $lang['Topic_points_cannot_rate_self'];
}
else
{
$s_ratings = $lang['Topic_points_no_guest_vote'];
}
break;
}
// If there aren't any votes, then we don't need to display
// the icon to view the vote history
// Figure out if the topic has any votes or not, set up
// related links or text strings based on results.
if ($forum_topic_data['topic_votes'])
{
$topic_rating = sprintf($lang['Topic_points_current_rating'], $forum_topic_data['topic_rating'], $forum_topic_data['topic_votes']);
$s_ratings .= '<a href="' . append_sid("viewpoints.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '"><img src="templates/' . $theme['template_name'] . '/images/tp_view.gif" hspace="3" border="0" alt="' . $lang['Topic_rating_view'] . '" /></a>';
if ( $userdata['user_level'] == ADMIN )
{
$s_ratings .= '<a href="' . append_sid("modpoints.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '"><img src="templates/' . $theme['template_name'] . '/images/tp_tools.gif" border="0" alt="' . $lang['Topic_rating_tools'] . '" /></a>';
}
}
else
{
$topic_rating = $lang['Topic_points_no_rating'];
}
$template->assign_vars(array(
'S_RATINGS' => $s_ratings,
'TOPIC_RATING' => $topic_rating
));
}
// END Topic Points 0.6.4 (www.phpBBDoctor.com)
Code: Selecteer alles
#-----[ OPEN ]-------------------------------------
#
subsilver/portal_body.tpl
#
#-----[ ADD SOMEWHERE ]-------------------------------------
#
{fetchpost_row.TOPIC_RATING} {fetchpost_row.S_RATINGS}