account expiration and integration with cb rc2

18 years 3 months ago #4281 by alibak
Hi, i looked through the forums and I haven't seen a final solution for integrating rc2 with the account expiration 0.6 version that's just come out.

it available somewhere? if yes, could you please be kind enough to post the url here again?

if it's not available, just wondering how difficult it would be for a programmer to make a plugin? or integration for it?

which is better plugin or integration hack?

thanks

hope to see soomeone reply to this.

Please Log in to join the conversation.

18 years 2 months ago #4905 by larpo
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

Please Log in to join the conversation.

18 years 2 months ago #4908 by alibak
this hack that you wrote is for joomla and not for cb I assume?

hopefully, someone with expertise will make a plugin and also an integration/incorporation of this component to the cb

thanks

Please Log in to join the conversation.

18 years 2 months ago #5508 by larpo
Sorry, to be clear, this is the hack that ships with the account expiry component. It involves hacking joomla mod_login. I posted it here in the hope that someone with more PHP skills than I have can adapt the code for CB login etc...

Please Log in to join the conversation.

18 years 2 months ago #5532 by scubaguy
the best way to do this would be to write a plugin that does what the registration hack is intended to do. I am going to give this a shot as I modified the hack originally to work with CB RC1. However I'm not sure if I will have time to get to this util next week.

CB 3rd Party Developer
Web Geek Cafe - development and training www.webgeekcafe.org
YourTribe.com - group social events - www.yourtribe.com

Please Log in to join the conversation.

18 years 2 months ago #5766 by jimspice
Keep us updated. I'd love to see this plugin!

Spice

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.189 seconds

Facebook Twitter LinkedIn