Yes, I'd also like to see this. The hacks to the core files seem quite simple.
To complete the installation you need to change your <root_dir>/includes/joomla.php, <root_dir>/modules/mod_login.php and <root_dir>/components/com_registration/com_registration.php files.
Please, MAKE A BACKUP OF THESE FILES BEFORE ANY CHANGES!!!
On mod_login.php you need to change the call when users click on "Create one" link for create a new account on your site.
You just need to change this file if you want to use integration with payment systems and for default expiration setting work properly.
Look on the file for the piece of code below and edit the line in red font, from "option=com_registration" to "option=com_acctexp".
if ( $registration_enabled ) {
?>
<tr>
<td>
<?php echo _NO_ACCOUNT; ?>
<a href="<?php echo sefRelToAbs( 'index.php?option=com_acctexp&task=register' ); ?>">
<</a>
</td>
</tr>
<?php
}
On joomla.php, first look in the begining of the file for a series of require_once instructions.
Between the last instruction and the comments stating "Class to support ..." insert (only) the lines in red, as I show below:
require_once( $mosConfig_absolute_path . "/includes/joomla.xml.php" );
require_once( $mosConfig_absolute_path . '/includes/phpInputFilter/class.inputfilter.php' );
// Hack for integration with Account Expiration Component
if (file_exists( $mosConfig_absolute_path . "/administrator/components/com_acctexp/includes/login.validate.php" ) ) {
include_once( $mosConfig_absolute_path . "/administrator/components/com_acctexp/includes/login.validate.php" );
}
// End of code for Account Expiration Control Component
/**
* Class to support function caching
Next, look for the function login, on the same file, and change it according to the code below. Remember, code that must be inserted are in RED - just a few lines including comments.
function login( $username=null,$passwd=null ) {
global $acl;
$usercookie = mosGetParam( $_COOKIE, 'usercookie', '' );
$sessioncookie = mosGetParam( $_COOKIE, 'sessioncookie', '' );
if (!$username || !$passwd) {
$username = mosGetParam( $_POST, 'username', '' );
$passwd = mosGetParam( $_POST, 'passwd', '' );
$passwd = md5( $passwd );
$bypost = 1;
}
$remember = mosGetParam( $_POST, 'remember', '' );
if (!$username || !$passwd) {
echo "\n";
exit();
} else {
$query = "SELECT *"
. "\n FROM #__users"
. "\n WHERE username = '$username'"
. "\n AND password = '$passwd'"
;
$this->_db->setQuery( $query );
$row = null;
if ($this->_db->loadObject( $row )) {
if ($row->block == 1) {
mosErrorAlert(_LOGIN_BLOCKED);
}
// Hack for integration with Account Expiration Component
// check if the user account has not been expired
// IMPORTANT: Remove this line BEFORE uninstall the component
loginValidate($username);
// End of code for Account Expiration Control Component
// fudge the group stuff
$grp = $acl->getAroGroup( $row->id );
$row->gid = 1;
if ($acl->is_group_child_of( $grp->name, 'Registered', 'ARO' ) ||
$acl->is_group_child_of( $grp->name, 'Public Backend', 'ARO' )) {
// fudge Authors, Editors, Publishers and Super Administrators into the Special Group
$row->gid = 2;
}
$row->usertype = $grp->name;
$session =& $this->_session;
$session->guest = 0;
$session->username = $username;
$session->userid = intval( $row->id );
$session->usertype = $row->usertype;
$session->gid = intval( $row->gid );
$session->update();
$currentDate = date("Y-m-d\TH:i:«»s"«»);
$query = "UPDATE #__users"
. "\n SET lastvisitDate = '$currentDate'"
. "\n WHERE id = $session->userid"
;
$this->_db->setQuery($query);
if (!$this->_db->query()) {
die($this->_db->stderr(true));
}
if ($remember=="yes"«») {
$lifetime = time() + 365*24*60*60;
setcookie( "usercookie[username]", $username, $lifetime, "/" );
setcookie( "usercookie[password]", $passwd, $lifetime, "/" );
}
//mosCache::cleanCache('com_content');
mosCache::cleanCache();
} else {
if (isset($bypost)) {
mosErrorAlert(_LOGIN_INCORRECT);
} else {
$this->logout();
mosRedirect("index.php"«»);
}
exit();
}
}
}
On com_registration.php, you need to disable the user link to it through browser's address bar.
Insert (only) the lines in red, as I show below:
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
// Hack for integration with Account Expiration Component - Disabling direct registration
echo "Hacking attempt.";
return;
// End of code for Account Expiration Control Component
Can this be adapted for the cb login etc?
Post edited by: larpo, at: 2006/01/27 18:47