Hello
I want to show the reputation details of any member as a table on usercp.php (On the Main page of usercp, under "Brief Account Summary" table).
The reputation details table must include this columns:
1) Username who gave reputation ---> "{$reputation_vote['username']}"
2) Point ---> "{$reputation_vote['user_reputation']}"
3) Comment who gave reputation ---> "{$reputation_vote['comments']}"
How can I do that?
Thank you.
Hello
open
usercp
find
eval("\$usercp = \"".$templates->get("usercp")."\";");
Above it add
//Start reputation
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;
// Fetch the reputations which will be displayed on this page
$query = $db->query("
SELECT r.*, r.uid AS rated_uid, u.uid, u.username, u.reputation AS user_reputation, u.usergroup AS user_usergroup, u.displaygroup AS user_displaygroup
FROM ".TABLE_PREFIX."reputation r
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=r.adduid)
WHERE r.uid='{$mybb->user['uid']}'
ORDER BY dateline
");
while($get_rep = $db->fetch_array($query))
{
$get_rep['username'] = build_profile_link($get_rep['username'], $get_rep['uid']);
if($get_rep['reputation'] < 0)
{
$status_class = "trow_reputation_negative";
$vote_type_class = "reputation_negative";
$vote_type = "Negative";
}
// This is a neutral reputation
else if($get_rep['reputation'] == 0)
{
$status_class = "trow_reputation_neutral";
$vote_type_class = "reputation_neutral";
$vote_type = "Neutral";
}
// Otherwise, this is a positive reputation
else
{
$status_class = "trow_reputation_positive";
$vote_type_class = "reputation_positive";
$vote_type = "Positive";
}
// Get the reputation for the user who posted this comment
if($get_rep['adduid'] == 0)
{
$get_rep['user_reputation'] = '0';
}
$get_rep['user_reputation'] = get_reputation($get_rep['user_reputation'], $get_rep['adduid']);
if($get_rep['username'])
{
$get_rep['user_reputation'] = " <span class=\"smalltext\">({$get_rep['user_reputation']})";
}
else
{
$get_rep['user_reputation'] = '';
}
$last_updated_date = my_date($mybb->settings['dateformat'], $get_rep['dateline']);
$last_updated_time = my_date($mybb->settings['timeformat'], $get_rep['dateline']);
// Parse smilies in the reputation vote
$reputation_parser = array(
"allow_html" => "no",
"allow_mycode" => "no",
"allow_smilies" => "yes",
"allow_imgcode" => "no"
);
$get_rep['comments'] = $parser->parse_message($get_rep['comments'], $reputation_parser);
$rep_rows .= "<tr><td class=\"{$status_class}\">{$get_rep['username']}</td><td class=\"{$status_class}\">{$get_rep['user_reputation']}</td><td class=\"{$status_class}\"><span class=\"{$vote_type_class}\">{$vote_type}</span>: {$get_rep['comments']} </td><td class=\"{$vote_type_class}\">{$last_updated_date}, {$last_updated_time}</td></tr>";
}
Now in
usercp template find
{$reputation}
</table>
below it add
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr><td colspan="4" align="center" class="thead">Reputation</td></tr>
<tr><td align="center" class="tcat">Username</td><td align="center" class="tcat">Reputation</td><td align="center" class="tcat">Comments</td><td align="center" class="tcat">Last update</td></tr>
{$rep_rows}
</table>
It works great.
Thank you very much.
I missed something:
Can you add "Last Updated --> {$last_updated}" column to the table please?
I have updated the code above.
Update is in both templates and php codes.
Wonderful.
Thank you so much.
I thought another thing:
How can we show the thread title (subject) which a user gave reputation to another user in a columun on that table?
The database doesn't store any information regarding the place this reputation was given from.
And umm don't PM please every time you start or reply to a thread, I look at all the threads don't worry
and i take yours in consideration because most never been asked before.
I understand.
So, can we add an entry for it (thread title) to the database and store that information for reputation?
Which modification must we make for this?
But as you know, you don't add reputation directly from the thread, you add it from the reputation details page or from the profile
But with following codes, it is possible to give reputation from postbit_author_user:
in functions_post.php:
// Work out the reputation this user has
if($usergroup['usereputationsystem'] != "no" && $mybb->settings['enablereputation'] == "yes")
{
$post['userreputation'] = get_reputation($post['reputation'], $post['uid']);
eval("\$post['replink'] = \"".$templates->get("postbit_reputation")."\";");
}
in postbit_author_user template:
{$post['replink']}
in postbit_reputation template:
<br />{$lang->postbit_reputation} {$post['userreputation']}
Am I wrong?
By default it takes you to the reputation details page as i have mentioned, it doesn't pop up directly asking you to add a reputation.