Arrow Home arrow Forums
larger font smaller font default font Fixed screen resolution Auto adjust screen size

Joomlapolis Forums  


<< Start < Prev 1 2 3 4 Next > End >>
account expiration and integration with cb rc2
Date: 2006/01/20 03:34 By: alibak Status: User  
Karma: 0  
Fresh Joomlapolitan

Posts: 15
graphgraph
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.
Click here to see the profile of this user The topic has been locked.

Re:account expiration and integration with cb rc2
Date: 2006/01/28 00:45 By: larpo Status: User  
Karma: 0  
Fresh Joomlapolitan

Posts: 20
graphgraph
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-dTH: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
Click here to see the profile of this user The topic has been locked.

Re:account expiration and integration with cb rc2
Date: 2006/01/28 01:38 By: alibak Status: User  
Karma: 0  
Fresh Joomlapolitan

Posts: 15
graphgraph
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
Click here to see the profile of this user The topic has been locked.

Re:account expiration and integration with cb rc2
Date: 2006/02/03 23:58 By: larpo Status: User  
Karma: 0  
Fresh Joomlapolitan

Posts: 20
graphgraph
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...
Click here to see the profile of this user The topic has been locked.

Re:account expiration and integration with cb rc2
Date: 2006/02/04 10:42 By: scubaguy Status: User  
Karma: 20  
Expert Joomlapolitan

Posts: 116
graphgraph
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 http://www.webgeekcafe.org
YourTribe.com - group social events - http://www.yourtribe.com
Click here to see the profile of this user The topic has been locked.

Re:account expiration and integration with cb rc2
Date: 2006/02/08 03:10 By: jimspice Status: CB Doc subscriber  
Karma: 0  
Fresh Joomlapolitan

Posts: 4
graphgraph
Keep us updated. I'd love to see this plugin!

Spice
Click here to see the profile of this user The topic has been locked.

<< Start < Prev 1 2 3 4 Next > End >>

Documentation

Documentation Subscription Service
(updated for CB 1.2 RC4)

What?

Why?

Where?

Just click here for answers!

Click here for a yearly subscription: subscribe now

Download Latest Release

The latest stable Community Builder Release is version 1.1 for Joomla 1.0 and Mambo.
You need to be a registered member of Joomlapolis to download.

The latest release candidate of Community Builder is version 1.2 RC4, native for Joomla 1.0, 1.5 and Mambo.
It is available as "thank you" to all CB documentation subscribers and now also to all registered joomlapolitans.

CB Login