enable activation CB 1.2.1 with cb_plugin [SOLVED]

Conwell 07 Oct, 2009
Hi all!
Sorry for my language, English not first my language.

I get some trouble earlier with CB activation in cf_cb_registration plugin. Activation code generate in plugin was not work when apply his in comprofiler. Some changes need in cf_cb_registration.php:
add after line 266 where *CB part*

function cbMakeRandomString( $stringLength = 8, $noCaps = false ) {
	if ( $noCaps ) {
		$chars        =    'abchefghjkmnpqrstuvwxyz0123456789';
	} else {
		$chars        =    'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
	}
	$len            =    strlen( $chars );
	$rndString        =    '';
	mt_srand( 10000000 * (double) microtime() );
	for ( $i = 0; $i < $stringLength; $i++ ) {
	$rndString    .=    $chars[mt_rand( 0, $len - 1 )];
	}
	return $rndString;
}

function makeRandomHashedID ($newUserId){
	global $mainframe;
	$randomHash = md5(cbMakeRandomString());
	$scrambleSeed    = (int) hexdec(substr( md5 ( $mainframe->getCfg( 'secret' ) . $mainframe->getCfg( 'db' ) ), 0, 7));
	$scrambledId = $scrambleSeed ^ ((int) $newUserId );
	$cbactivation = "reg" . $randomHash . sprintf( "%08x", $scrambledId );
	return ($cbactivation);
}
$actionlink = makeRandomHashedID ($user->get('id'));

This code create confirmCode identically Community Builder.
next:
line
$fields2 = array('id', 'user_id');

change with
$fields2 = array('id', 'user_id', 'confirmed', 'approved', 'cbactivation');

line
$database->setQuery( "INSERT INTO #__comprofiler (".implode(",",$fields2).") VALUES  ('".$user->get('id')."','".$user->get('id')."','".implode("','",$fields3)."');" );

change with
$database->setQuery( "INSERT INTO #__comprofiler (".implode(",",$fields2).") VALUES  ('".$user->get('id')."','".$user->get('id')."','0','0','".$actionlink."','".implode("','",$fields3)."');" );

This save confirmcode to Community Builder table
and some more
line
$this->_sendMail($user, $password, $params->get('emailuser'), $params->get('emailadmins'));

change with
$this->_sendMail($user, $actionlink, $password, $params->get('emailuser'), $params->get('emailadmins'));

line
function _sendMail(&$user, $password, $emailuser, $emailadmins)

change with
function _sendMail(&$user, $actionlink, $password, $emailuser, $emailadmins)

line
$message = sprintf ( JText::_( 'SEND_MSG_ACTIVATE' ), $name, $sitename, $siteURL."index.php?option=com_user&task=activate&activation=".$user->get('activation'), $siteURL, $username, $password);

change with
$message = sprintf ( JText::_( 'SEND_MSG_ACTIVATE' ), $name, $sitename, $siteURL."index.php?option=com_comprofiler&task=confirm&confirmcode=".$actionlink."", $siteURL, $username, $password);

This changes for create right confirmcode e-mail

Save file and now you can use activation by Community Builder.
GreyHead 07 Oct, 2009
Hi Conwell,

Thanks very much for this. I've been meaning to update the CB Registration Plugin for a while and this will be very useful.

Bob
This topic is locked and no more replies can be posted.