2008-08-08, 10:21 PM
I had that script in 1.2 and was wondering if there was an updated version for 1.4.
Here is the 1.2 script if anybody would be kind enough to update it.
Thanks.
Here is the 1.2 script if anybody would be kind enough to update it.
<?php
if(!defined("IN_MYBB"))
{
die("This file cannot be accessed directly.");
}
$plugins->add_hook('member_profile_end', 'showrefer', 1);
// The information that shows up on the plugin manager
function showrefer_info()
{
return array(
"name" => "Referral in Profile",
"description" => "This plugin displays the user's referrals in their profiles.",
"website" => "http://jeffchan.org",
"author" => "Jeff Chan",
"authorsite" => "http://jeffchan.org",
"version" => "1.0",
);
}
// This function runs when the plugin is activated.
function showrefer_activate()
{
global $db;
// Insert code into profile template
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("member_profile", '#{\$reputation}#', "{\$reputation}\n{\$showrefer}\n");
$showrefer_template = array(
"title" => 'member_profile_showrefer',
"template" => "<tr>
<td class=\"trow1\"><strong>Referrals ({\$showrefer_count})</strong></td>
<td class=\"trow1\">{\$showrefer_referrals}</td>
</tr>",
"sid" => -1,
"version" => 120,
"status" => '',
"dateline" => 1134703642,
);
//Create Referrals in Profiles template
$db->insert_query(TABLE_PREFIX.'templates', $showrefer_template);
}
// This function runs when the plugin is deactivated.
function showrefer_deactivate()
{
global $db;
// Remove code from template
require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("member_profile", '#(\n?){\$showrefer}(\n?)#', '', 0);
//Delete Referrals in Profiles template
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='member_profile_showrefer'");
//Rebuild settings.php
rebuild_settings();
}
function showrefer()
{
global $mybb, $templates, $db, $theme, $showrefer_count, $showrefer, $showrefer_referrals;
$query = $db->query("SELECT username,uid FROM ".TABLE_PREFIX."users WHERE referrer='".$mybb->input['uid']."'");
$showrefer_count = $db->num_rows($query);
if($showrefer_count > 0)
{
$sep = "";
while($referral = $db->fetch_array($query))
{
$showrefer_referrals .= $sep.build_profile_link($referral['username'], $referral['uid']);
$sep = ", ";
}
}
else
{
$showrefer_referrals = "None";
}
eval("\$showrefer = \"".$templates->get('member_profile_showrefer')."\";");
}
if(!function_exists("rebuild_settings")) {
function rebuild_settings() {
global $db;
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."settings ORDER BY title ASC");
while($setting = $db->fetch_array($query)) {
$setting['value'] = addslashes($setting['value']);
$settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";
}
$settings = "<?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?>";
$file = fopen(MYBB_ROOT."/inc/settings.php", "w");
fwrite($file, $settings);
fclose($file);
}
}
?>
Thanks.