INVISION4MAMBO - Invison Board User Database Integration
--------------------------------------------------------
Version: 1.0 BETA 1 By Kim (www.alt-man.co.uk)


-----------
Description
-----------
This will integrate your mambo into your invision board users database, so your users have 1 password and username for both mambo and invision board and your users will only have to login once.


------------
Requirements 
------------
(These are what this integration was built using, may work on other version though)
Invision Board 2.0.3
Mambo 4.5.1
IPB SDK Beta 3


-----------------------------------------
Things you should know before you install
-----------------------------------------
This integration can only be used with either:
A fresh install of both invision board and mambo (no users in each)
OR
An already installed invision board and a fresh copy mambo (users in invision board, none in mambo)

Ive done it this way simply because i 

Both invision board and mambo MUST use the same database.

If you already have users on your invision board then they will only be added to mambo when they next logon to your site. If your users have cookies set they will have to logout and then log back in.

Some modifications to invision board and mambo may interfere with the way the integration works.
PLEASE MAKE SURE YOU FOLLOW ALL STEPS IN THIS FILE!
REMEMBER THIS IS ONLY THE FIRST BETA VERSION OF THIS SOFTWARE, SO IT MAY CONTAIN BUGS, THINGS IVE MISSED, ETC.
ITS A GOOD IDEA TO BACKUP YOUR DATA...


------------------
Mambo File Changes
------------------
mambo/index.php
mambo/includes/mambo.php
mambo/components/com_registration (entire folder)
mambo/components/com_user (entire folder)
mambo/components/com_login (entire folder)
mambo/administrator/components/com_users (entire folder)


---------------------------
Invision Board File Changes
---------------------------
forums/invision4mambo.php
forums/index.php
forums/admin.php
forums/modules/ipb_member_sync.php


---------------------------
Invision Board Skin Changes
---------------------------
Login In -> Show Form
Board Index -> PageTop
All Global HTML -> error_log_in
All Global HTML -> member_bar



-------------
Initial Setup
-------------

------
STEP 1
------
Install Invision Board
Take note of the admin details - username, password, email

Also take note of your board url and full path to your board.

If its already installed then skip this step.


------
STEP 2
------
Install and configure IBSDK (http://ipbsdk.sourceforge.net)
Make sure it is working correctly by running the example files that come with it.

take note of your IBSDK path

------
STEP 3
------
Install Mambo, when you are doing it use the same password and email as the admin account on ib

take note of your mambo url and path

------
STEP 4
------
Run the following query on your database:
UPDATE mos_users SET id=1

------
STEP 5
------
Login to the mambo administration and goto:
Site -> User Manager -> Add/Edit Users

You will see the admin account, click the username to edit it, change the name and username to your invisionboard admin username.



-------------------------------
Uploading the integration files
-------------------------------

--------------------
STEP 1 - Mambo Setup
--------------------
Overwrite the following files with the ones in this zip found in the mambo dir.
your-mambo-dir/index.php
your-mambo-dir/includes/mambo.php
your-mambo-dir/components/com_registration (entire folder)
your-mambo-dir/components/com_user (entire folder)
your-mambo-dir/components/com_login (entire folder)
your-mambo-dir/administrator/components/com_users (entire folder)


-----------------------
STEP 2 - Invision setup
-----------------------
Copy invision4mambo.php to your forums root dir.
Overwrite ipb_member_sync.php with the one from this zip.



-----------------------------------------
Editing the source files (INVISION BOARD)
-----------------------------------------

--------------------------------------
STEP 1 - Open your-forum-dir/index.php
--------------------------------------

Find:

$ibforums->js_base_url = $ibforums->vars['board_url'].'/index.'.$ibforums->vars['php_ext'].'?s='.$ibforums->session_id.'&';

Add Below:
//INVISION4MAMBO
require_once (ROOT_PATH."invision4mambo.php");
$invision4mambo = new invision4mambo();


--------------------------------------
STEP 2 - Open your-forum-dir/admin.php
--------------------------------------

Find:

//------------------------------------------------
// Admin.php Rules:
//
// No adsess number?
// -----------------
//
// Then we log into the admin CP


Add Above:
//INVISION4MAMBO
require_once (ROOT_PATH."invision4mambo.php");
$invision4mambo = new invision4mambo();


--------------------------------
Editing the source files (MAMBO)
--------------------------------

--------------------------------------
STEP 1 - Open your-mambo-dir/index.php
--------------------------------------

Configure the following variables near the top of the file:
//INVISION4MAMBO
//SDK Setup - Change the path to the path to IBSDK/ipbsdk_class.inc.php
require_once "./sdkb3/ipbsdk_class.inc.php";
$SDK =& new IPBSDK();

require_once ("./forums/invision4mambo.php");
$invision4mambo = new invision4mambo();

//Invision Board Variables (Change to the path to your forums)
$invisionboard->vars['url'] = "http://www.your-site.com/forums/";



---------------------------------
Editing your invision board skins
---------------------------------

----------------------------------------------------------------------------------------
Goto AdminCP skin section. Open:

Login In -> Show Form

GET RID OF ALL THE CODE INSIDE AND PASTE THE FOLLOWING CODE
Change www.your-site.com/ to your mambo url:
----------------------------------------------------------------------------------------

<script language='JavaScript' type="text/javascript">
<!--
function ValidateForm() {
	var Check = 0;
	if (document.LOGIN.UserName.value == '') { Check = 1; }
	if (document.LOGIN.PassWord.value == '') { Check = 1; }
	if (Check == 1) {
		alert("{ipb.lang['blank_fields']}");
		return false;
	} else {
		document.LOGIN.submit.disabled = true;
		return true;
	}
}
//-->
</script> 
<form action="http://www.your-site.com/index.php?option=login" method="post" name="LOGIN" onsubmit="return ValidateForm()">
	<input type="hidden" name="referer" value="$referer" />
	<div class="borderwrap">
		<div class="maintitle"><{CAT_IMG}>&nbsp;{ipb.lang['log_in']}</div>
		<div class="formsubtitle">$message</div>
		<div class="errorwrap">
			<h4>Attention!</h4>
			<p>{ipb.lang['login_text']}</p>
			<p><b>{ipb.lang['forgot_pass']} <a href="{ipb.vars['board_url']}/index.{ipb.vars['php_ext']}?act=Reg&amp;CODE=10">{ipb.lang['pass_link']}</a></b></p>
		</div>
		<table cellspacing="1">
			<tr>
				<td width="60%" valign="top">
					<fieldset>
						<legend><b>{ipb.lang['log_in']}</b></legend>
						<table cellspacing="1">
							<tr>
<if="ipb.vars['converge_login_method'] == 'username'">
<td width="50%"><b>{ipb.lang['enter_name']}</b></td>
								<td width="50%"><input type="text" size="25" maxlength="64" name="username" class="forminput" /></td>
</if>
<else>
<td width="50%"><b>{ipb.lang['enter_email']}</b></td>
								<td width="50%"><input type="text" size="25" value="{ipb.input['UserName']}" maxlength="64" name="username" class="forminput" /></td>
</else>

							</tr>
							<tr>
								<td width="50%"><b>{ipb.lang['enter_pass']}</b></td>
								<td width="50%"><input type="password" size="25" name="passwd" class="forminput" /></td>
							</tr>
						</table>
					</fieldset>
				</td>
				<td width="40%" valign="top">
					<fieldset>
						<legend><b>{ipb.lang['options']}</b></legend>
						<table cellspacing="1">
							<tr>
								<td width="10%"><input type="checkbox" name="remember" value="1" checked="checked" /></td>
								<td width="90%"><b>{ipb.lang['rememberme']}</b><br /><span class="desc">{ipb.lang['notrecommended']}</span></td>
							</tr>
							<tr>
								<td width="10%"><input type="checkbox" name="Privacy" value="1" /></td>
								<td width="90%"><b>{ipb.lang['form_invisible']}</b><br /><span class="desc">{ipb.lang['anon_name']}</span></td>
							</tr>
						</table>
					</fieldset>
				</td>
			</tr>
			<tr>
				<td class="formbuttonrow" colspan="2"><input class="button" type="submit" name="submit" value="{ipb.lang['log_in_submit']}" /></td>
			</tr>
			<tr>
				<td class="catend" colspan="2"><!-- no content --></td>
			</tr>
		</table>
	</div>
</form>



----------------------------------------------------------------------------------------
Open:

Board Index -> PageTop

GET RID OF ALL THE CODE INSIDE AND PASTE THE FOLLOWING CODE
Change www.your-site.com/ to your mambo url:
----------------------------------------------------------------------------------------

<script type="text/javascript" src="jscripts/ipb_board.js"></script>
<table cellspacing="0" class="newslink">
	<tr>
		<td><b>{ipb.lang['welcome_back_text']}: <span>$lastvisit</span></b><!-- IBF.NEWSLINK --></td>
		<td align="right" valign="middle">
<if="ipb.member['id'] == 0">
<form action="http://www.your-site.com/index.php?option=login&amp;remember=1" method="post">
				<input type="text" size="20" name="username" onfocus="this.value=''" value="{ipb.lang['qli_name']}" />
				<input type="password" size="20" name="passwd" onfocus="this.value=''" value="ibfrules" />
				<input class="button" type="image" src="{ipb.vars['img_url']}/login-button.gif" />
			</form>
</if>
<else>
<form action="{ipb.script_url}act=Search&amp;CODE=01&amp;forums=all" method="post">
				<input type="text" size="30" name="keywords"  onfocus="this.value=''" value="{ipb.lang['enter_search_words']}" />
				<input class="button" type="image" src="{ipb.vars['img_url']}/login-button.gif" />
			</form>
</else>

		</td>
	</tr>
</table>
<br />



----------------------------------------------------------------------------------------
Open:

All Global HTML -> error_log_in

GET RID OF ALL THE CODE INSIDE AND PASTE THE FOLLOWING CODE
Change www.your-site.com/ to your mambo url:
----------------------------------------------------------------------------------------

<form action="http://www.your-site.com/index.php" method="post">
	<input type="hidden" name="option" value="login" />
	<input type="hidden" name="remember" value="1" />
	<h4>{ipb.lang['er_log_in_title']}</h4>
	<div class="fieldwrap">
<if="ipb.vars['converge_login_method'] == 'username'">
<h4>{ipb.lang['erl_enter_name']}</h4>
		<input type="text" size="20" maxlength="64" name="username" />
</if>
<else>
<h4>{ipb.lang['erl_email']}</h4>
		<input type="text" size="20" maxlength="128" name="username" />
</else>

		<h4>{ipb.lang['erl_enter_pass']}</h4>
		<input type="password" size="20" name="passwd" />
		<p class="formbuttonrow1"><input class="button" type="submit" name="submit" value="{ipb.lang['erl_log_in_submit']}" /></p>
	</div>
</form>

----------------------------------------------------------------------------------------
Open:

All Global HTML -> member_bar

GET RID OF ALL THE CODE INSIDE AND PASTE THE FOLLOWING CODE
Change www.your-site.com/ to your mambo url:
----------------------------------------------------------------------------------------

<if="ipb.member['id']">
<div id="userlinks">
	<p class="home"><b>{ipb.lang['logged_in_as']} <a href="{ipb.script_url}showuser={ipb.member['id']}">{ipb.member['name']}</a></b> ( <a href="http://www.your-site.com/index.php?option=logout">{ipb.lang['log_out']}</a> )</p>
	<p>
</if>
<else>
<div id="userlinksguest">
	<p class="pcen"><b>{ipb.lang['guest_stuff']}</b> ( <a href="{ipb.script_url}act=Login&amp;CODE=00">{ipb.lang['log_in']}</a> | <a href="{ipb.script_url}act=Reg&amp;CODE=00">{ipb.lang['register']}</a> )
</else>
<if="ipb.member['mgroup'] == ipb.vars['auth_group']">
<b><a href="{ipb.script_url}act=reg&amp;CODE=reval">{ipb.lang['resend_val']}</a></b> &middot;
</if>
<if="ipb.member['g_access_cp']">
<b><a href="{ipb.vars['board_url']}/admin.{ipb.vars['php_ext']}" target="_blank">{ipb.lang['admin_cp']}</a></b> &middot;
</if>
<if="ipb.member['has_blog'] == 1">
&nbsp;<b><a href="{ipb.script_url}automodule=blog&amp;cmd=showblog&amp;mid={ipb.member['id']}">{ipb.lang['myblog']}</a></b> &middot;
</if>
<if="ipb.member['id']">
&nbsp;<b><a href="{ipb.script_url}act=UserCP&amp;CODE=00" title="{ipb.lang['cp_tool_tip']}">{ipb.lang['your_cp']}</a></b> &middot;&nbsp;<a href="{ipb.script_url}act=Search&amp;CODE=getnew">{ipb.lang['view_new_posts']}</a>&nbsp;&middot;&nbsp;<a href="javascript:buddy_pop();" title="{ipb.lang['bb_tool_tip']}">{ipb.lang['l_qb']}</a>
</if>
<if="ipb.member['g_use_pm']">
&nbsp;&middot;&nbsp;<a href="{ipb.script_url}act=Msg&amp;CODE=01">{$msg[TEXT]}</a>
</if>

	</p>
</div>