Code:
<?php
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("datahandler_user_update", "profilexlg_update");
$plugins->add_hook('postbit', 'profilexlg_parse');
$plugins->add_hook('postbit_pm', 'profilexlg_parse');
$plugins->add_hook('postbit_announcement', 'profilexlg_parse');
$plugins->add_hook('postbit_prev', 'profilexlg_parse');
$plugins->add_hook('usercp_profile_start', 'profilexlg_templateupdate');
$plugins->add_hook('member_profile_end', 'profilexlg_profile');
function profilexlg_info()
{
return array(
"name" => "Profile and Postbit Xbox Live Gamertag",
"description" => "Adds a Profile Xbox Live Gamertag to the Profile and User PostBit",
"website" => "http://www.xpresionzone.net/",
"author" => "Walkman 5.0",
"authorsite" => "http://www.xpresionzone.net/",
"version" => "1.5",
"guid" => "a2ab1c6951e53e14ca6528fc61fe2d50",
"compatibility" => "14*"
);
}
function profilexlg_install ()
{
global $db;
$db->delete_query("templates", "title='xlg_usercp'"); //delete old templates with this name
//insert the template for rules
$xlgusrcp = array(
"title" => "xlg_usercp",
"template" => "<br />
<fieldset class=\"trow2\">
<legend><strong>Xbox Live Gamertag</strong></legend>
<table cellspacing=\"0\" cellpadding=\"{\$theme[tablespace]}\" width=\"100%\">
<tr>
<td valign=\"top\" width=\"1\"><input type=\"checkbox\" class=\"checkbox\" name=\"xlgno\" id=\"xlgno\" {\$fb_selected} value=\"1\" /></td>
<td><span class=\"smalltext\"><label for=\"invisible\">Xbox Live Gamertag</label></span></td>
</tr>
<tr>
<td colspan=\"2\"><span class=\"smalltext\">Xbox Live Gamertag</span></td>
</tr>
<tr>
<td colspan=\"2\" ><input type=\"text\" class=\"textbox\" name=\"xlg\" size=\"30\" value=\"{\$mybb->user[\'xlg\']}\" /></td>
</tr>
</table>
</fieldset>
",
"sid" => '-1',
"version" => '',
"dateline" => TIME_NOW
);
$db->insert_query("templates", $xlgusrcp);
// definizione variabili di configurazione plugin
$db->query("ALTER TABLE ".TABLE_PREFIX."users ADD xlgno INT(1) NOT NULL AFTER msn");
$db->query("ALTER TABLE ".TABLE_PREFIX."users ADD xlg VARCHAR(50) NOT NULL AFTER xlgno");
}
function profilexlg_is_installed()
{
global $db;
if($db->field_exists("xlg", "users"))
{
return true;
}
return false;
}
function profilexlg_activate()
{
global $db;
include MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets("usercp_profile", "#".preg_quote('{$awaysection}')."#i", '{$xlgusercp}{$awaysection}');
find_replace_templatesets("postbit", "#".preg_quote('{$post[\'user_details\']}')."#i", '{$post[\'user_details\']} <br />{$post[\'iconxlg\']}');
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'user_details\']}')."#i", '{$post[\'user_details\']} <br />{$post[\'iconxlg\']}');
find_replace_templatesets("member_profile", "#".preg_quote('<td class="trow2"><a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&imtype=msn&uid={$uid}\', \'imcenter\', 450, 300);">{$memprofile[\'msn\']}</a></td>')."#i", '<td class="trow2"><a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&imtype=msn&uid={$uid}\', \'imcenter\', 450, 300);">{$memprofile[\'msn\']}</a></td>{$faceprofile}');
// update plugin from v.2.0 to v.2.1 add a field privacy to setting if not exist
$query = $db->simple_select("settings", "*", "name='xlgprivacy'");
$result = $db->num_rows($query);
if($result)
{
return true;
} else
{
$insertArray = array('name' => 'xlgprivacy',
'title' => 'xlg privacy',
'description' => 'If yes the groups id 1 - 5 - 7 can not see the user profile xlg ',
'optionscode' => 'yesno',
'value' => 'yes',
'disporder' => 100,
'gid' => 9
);
$db->insert_query('settings', $insertArray);
rebuild_settings();
}
}
function profilexlg_deactivate()
{
global $db;
// pulizia template da variazioni
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("usercp_profile", "#".preg_quote('{$xlgusercp}')."#i", '', 0);
find_replace_templatesets("postbit", "#".preg_quote('<br />{$post[\'iconxlg\']}')."#i", '', 0);
find_replace_templatesets("postbit_classic", "#".preg_quote('<br />{$post[\'iconxlg\']}')."#i", '', 0);
find_replace_templatesets("member_profile", "#".preg_quote('{$faceprofile}')."#i", '', 0);
}
function profilexlg_uninstall()
{
global $db;
// pulizia tabelle settinggroups e setting
$db->query("ALTER TABLE ".TABLE_PREFIX."users DROP COLUMN xlgno");
$db->query("ALTER TABLE ".TABLE_PREFIX."users DROP COLUMN xlg");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN('xlgprivacy')");
rebuild_settings();
}
function profilexlg_update()
{
global $mybb, $db;
if ($mybb->input['xlgno'] == "1")
{
$temp_query = " xlgno = '1', ";
}else{
$temp_query = " xlgno = '0', ";
}
$temp_query = $temp_query . "xlg = '" . $db->escape_string($mybb->input['xlg']) . "'";
$db->query("UPDATE ".TABLE_PREFIX."users SET " . $temp_query . " WHERE uid = " . $mybb->user['uid']);
}
function profilexlg_parse($post)
{
global $mybb;
$a = array(1, 5, 7);
if ($post["xlg"] != '')
{
if($post["xlgno"] != 0)
{
if($mybb->settings['xlgprivacy']==1)
{
if(!in_array($mybb->user['usergroup'],$a, true))
{
$post["iconxlg"] = '<iframe src="http://gamercard.xbox.com/' . $post["xlg"] .'.card" scrolling="no" frameBorder="0" height="140" width="204">' . $post["xlg"] .'</iframe>';
} else
{
}
} else {
$post["iconxlg"] = '<iframe src="http://gamercard.xbox.com/' . $post["xlg"] .'.card" scrolling="no" frameBorder="0" height="140" width="204">' . $post["xlg"] .'</iframe>';
}
}
else
{
if($mybb->settings['xlgprivacy']==1)
{
if(!in_array($mybb->user['usergroup'],$a, true))
{
$post["iconxlg"] = '<<iframe src="http://gamercard.xbox.com/' . $post["xlg"] .'.card" scrolling="no" frameBorder="0" height="140" width="204">' . $post["xlg"] .'</iframe>';
} else {
}
} else {
$post["iconxlg"] = '<iframe src="http://gamercard.xbox.com/' . $post["xlg"] .'.card" scrolling="no" frameBorder="0" height="140" width="204">' . $post["xlg"] .'</iframe>';
}
}
}
else { }
}
function profilexlg_templateupdate()
{
global $mybb, $templates, $theme, $xlgusercp,$xlgno,$xlg;
if ($mybb->user['xlgno'] == "1") {
$fb_selected = " checked ";
}else{
$fb_selected = " ";
}
eval("\$xlgusercp = \"".$templates->get("xlg_usercp")."\";");
}
function profilexlg_profile()
{
global $mybb, $memprofile, $faceprofile;
if ($memprofile["xlg"] != '')
{
if($memprofile["xlgno"] != 0)
{
$faceid= 'Gamercard';
$profilexlg = '<iframe src="http://gamercard.xbox.com/' . $memprofile["xlg"] . '.card" scrolling="no" frameBorder="0" height="140" width="204">' . $memprofile["xlg"] . '</iframe>';
}
else
{
$faceid= 'ID';
$profilexlg = '<iframe src="http://gamercard.xbox.com/' . $memprofile["xlg"] . '.card" scrolling="no" frameBorder="0" height="140" width="204">' . $memprofile["xlg"] . '</iframe>';
}
if($mybb->settings['xlgprivacy']==1)
{
$a = array(1, 5, 7);
if(!in_array($mybb->user['usergroup'],$a, true))
{
$faceprofile="</tr><tr><td class=\"trow1\"><strong>$faceid :</strong></td><td class=\"trow1\">$profilexlg</td>";
} else {
}
} else {
$faceprofile="</tr><tr><td class=\"trow1\"><strong>$faceid :</strong></td><td class=\"trow1\">$profilexlg</td>";
}
}
else { }
}
?>