I was looking through the forum and i saw this thread. I've actually fixed Invite A Friend so that it'll work together with CB. It requires extensive hacking of CB, and because of how Invite A Friend works itself, register globals
must be set to ON.
First, we need to edit components/com_invite/includes/registration.php. Delete everything inside and replace with
Code: Select all
<?php
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
require_once( $mosConfig_absolute_path . "/components/com_comprofiler/comprofiler.html.php" );
include_once( $mosConfig_absolute_path . "/components/com_comprofiler/comprofiler.php" );
switch( $task ) {
case 'lostPassword':
lostPassForm( $option );
break;
case 'sendNewPass':
sendNewPass( $option );
break;
case 'register':
registerForm( $option, $mosConfig_emailpass );
break;
case 'activate':
activate( $option );
break;
}
?>
This will call CB's registration form everytime a registration request is called from com_invite.
Next comes the complicated parts. First go to components/com_comprofiler/comprofiler.html.php and search for the function registerForm(). Go to around line 1126 and you'll see the textbox for email is (i'm using CB 1.0 so line # may be off). Add the following codes there:
Code: Select all
<?php
$showemail = "";
if ($option == "com_invite") $showemail = $_GET['email'];
elseif ($option == "com_comprofiler") {
if (isset($row->email)) $showemail = $row->email;
}
?>
These codes are inside a php tag so you can add it anywhere as long as they're ABOVE the actual textbox where users enter their email. Next go to the "value" tag of the textbox and change
Code: Select all
<?php if (isset($row->email)) echo $row->email; ?>
to
The purpose of this is to automatically set the email field to the referred email in the address line.
Scroll down further (around line 1180) until you come to a list of hidden fields used by CB. Add the following codes
Code: Select all
<?php
if ($option == "com_invite") {?>
<input type="hidden" name="ref_str" value="<?php echo $_GET['ref_str']; ?>" />
<input type="hidden" name="ref_email" value="<?php echo $_GET['email']; ?>" />
<?php
}
?>
As you can see, this is where Register Globals is required to be set to ON. The extra 2 hidden fields are required to store the referred address and referer string needed to update Invite A Friend's tables.
Got it so far? Great! Now let's go to components/com_comprofiler/comprofiler.php and search for the function userProfile(). Add the following line just below the global declarations, on the second line of the function:
Code: Select all
if ($option != "com_comprofiler") return false;
This is to escape from function userProfile()! The default case statement for CB's $task is function userProfile(), so we'll need to exit this function first, or it'll give you some irrelevant message.
Simple enough? Here comes the last step! Also in comprofiler.php, search for the function saveRegistration(). Scroll alllllllll the way down until you're at the last line (which is "echo $messagesToUser;") and add the following codes just above the last line so it looks like this:
Code: Select all
if ($option == "com_invite") {
//confirm invite
$ref_str = $_POST['ref_str'];
$ref_email = $_POST['ref_email'];
$sql = "update `#__invite_sent` set `joined` = '1' where `email` = '$ref_email' and `ref_str` = '$ref_str'";
$database->setQuery($sql);
$database->query();
$sql = "insert into `#__invite_joined` values ('', '$row->id', '$ref_email', '$ref_str')";
$database->setQuery($sql);
$database->query();
}
echo $messagesToUser;
This will update the Invite A Friend tables accordingly. Of course, since it's a rudimentary hack using address line variables, mischevious users can still bypass it by changing the referer string or email in the address line, but it'll work well otherwise

Hope this helps!
Regards, Mike