
// MODxBB # PluginBB # by N!Ce (A.S.) September, 2010
// Version 0.9.4
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



$event = & $modx->Event;
if ($event->name == "OnWUsrFormRender") {
	$MODxID = $event->params['id'];
	$phpBBIDR = $modx->db->select("phone", $modx->getFullTableName('web_user_attributes'), "id='".$MODxID."'");
	$phpBBID = $modx->db->getValue($phpBBIDR);
}
elseif ($event->name == "OnUserFormRender") {
	$MODxID = $modx->db->escape($_GET['id']);
	$MODxUserR = $modx->db->select("username", $modx->getFullTableName('manager_users'), "id='".$MODxID."'");
	$MODxUser = $modx->db->getValue($MODxUserR);
	$MODxIDR = $modx->db->select("id", $modx->getFullTableName('web_users'), "username='".$MODxUser."'");
	$MODxID = $modx->db->getValue($MODxIDR);
	$phpBBIDR = $modx->db->select("phone", $modx->getFullTableName('web_user_attributes'), "id='".$MODxID."'");
	$phpBBID = $modx->db->getValue($phpBBIDR);
}

// Never cast an unknown fraction to integer!
if (stristr($phpBBID,'/') || stristr($phpBBID,'.')) {
	$phpBBID = false;
}

if ($phpBBID && is_int((int) $phpBBID)) {
	$html = "<div class=\"sectionHeader\">MODxBB</div>
	<div class=\"sectionBody\">
	<a href=\"../forum/memberlist.php?mode=viewprofile&u=" . $phpBBID . "\">View phpBB profile</a>
	</div>";
	$event->output($html);
}
else {
	$html = "<div class=\"sectionHeader\">MODxBB</div>
	<div class=\"sectionBody\">
	<div style=\"color:red\">No phpBB profile found for this user.</div>
	</div>";
	$event->output($html);
}