Page 3 of 3
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 6:34 pm
by Dee
There's a difference between the DBTimeStamp functions of full ADOdb and Lite and some other issues with the datetime data field. See
this thread for some more info.
I might implement the same solutions in FEUsers in the coming days (and look at the other issues that were brought up in this thread).
Regards,
D
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 6:53 pm
by mahjong
I rewrote the SQL query to bypass completely this issue :
Code: Select all
$q = "SELECT * FROM ".cms_db_prefix()."module_feusers_users WHERE id = ? AND expires > NOW()";
$dbresult = $db->Execute( $q, array( $uid ) );
Should execute 0.0001s faster. (^_^)
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 7:01 pm
by Dee
Dee wrote:
There's a difference between the DBTimeStamp functions of full ADOdb and Lite
More exactly: the ADOdb field type DT only exists in the adodb_lite datadict, not in full/original adodb.
ADOdb uses T for datetime, ADOdb T for time and DT for datetime.
Also, in cmsmadesimple-0.13 an altered ADOdb Lite was used which didn't surround the return value of DBTimeStamp with quotes.
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 7:08 pm
by mahjong
Now I understand the origin of all the bugs. I think everything is solved. I'll post in a few minutes the corrections that need to be added in SVN.
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 7:14 pm
by mahjong
FrontEndUser.api.php
Code: Select all
// userid api function
// returns array
function AddUser( $name, $password, $expires )
{
$db =& $this->GetDb();
// see if it exists already or not (by name)
$q = "SELECT * FROM ".cms_db_prefix().
"module_feusers_users WHERE username = ?";
$dbresult = $db->Execute( $q, array( $name ) );
if( !$dbresult )
{
return array(FALSE,$db->ErrorMsg());
}
$row = $dbresult->FetchRow();
if( $row )
{
$module =& $this->GetModule();
return array(FALSE,$module->Lang('error_username_exists'));
}
// generate the sequence
$uid =
$db->GenID( cms_db_prefix()."module_feusers_users_seq" );
// insert the record
$q = "INSERT INTO ".cms_db_prefix().
"module_feusers_users VALUES (?,?,?,?,?)";
$dbresult = $db->Execute( $q, array(
$uid,
$name,
md5($password),
trim( $db->DBTimeStamp( time() ) , "'") ,
trim( $db->DBTimeStamp( $expires ) , "'")
)
);
if( !$dbresult )
{
return array(FALSE,$db->ErrorMsg());
}
return array(TRUE,$uid);
}
Code: Select all
function IsAccountExpired( $uid )
{
$db =& $this->GetDb();
$q = "SELECT * FROM ".cms_db_prefix()."module_feusers_users WHERE id = ? AND expires > NOW()";
$dbresult = $db->Execute( $q, array( $uid ) );
if( $dbresult && $dbresult->RecordCount() )
{
return false;
}
return true;
}
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 7:28 pm
by mahjong
Everything is fine now.
The bugs were caused by missing "trim"s around the "DBTimeStamp"s. See the corrections I've posted.
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 8:40 pm
by jmcgin51
Ok, so Mahjong, are you saying that the latest SVN version of FrontEndUsers.api.php contains all your updates and is ready to be used?
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 9:36 pm
by mahjong
No, I'm not authorised to make changes in SVN.
Cut and paste the corrections yourself.
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 9:50 pm
by jmcgin51
ok. I'll admit I'm a bit confused by all the edits, so I'm going to wait for Dee or one of the other developers to post the changes, and then I'll get the latest version. My system is working OK now (crossing fingers), so I'll leave it alone for the moment. Thanks for all your work on this, Mahjong!
Re: Frontend Users not expiring
Posted: Sat Dec 09, 2006 10:43 pm
by jmcgin51
oh, dear...
I was incorrect earlier, Mahjong, when I said my system was working properly. I failed to notice that the user I was testing with was assigned to a group that did not have access to the content. So it was not the expiration date that prevented him from seeing the content, it was the fact that he was not a member of an authorized group.
To recap, I just created a user TEST, assigned him as a member of all groups, so that he would have access to all content, and set his expire date as 12/1/06 at 17:00:00. The date shows correctly in the admin panel, but TEST can still log in and view all content, though he should be expired.
Maybe I'll have to look at making the FEU api changes now instead of waiting until they're incorporated into the SVN code...
I feel like such a dunce.
Re: Frontend Users not expiring
Posted: Sun Dec 10, 2006 3:07 am
by jmcgin51
I added Mahjong's changes to my FEU api file, and my expired user now cannot log in ("account is expired").
well done, Mahjong!
Calguy - 2 thumbs up for originally writing this module, CustomContent and SelfReg...
Re: Frontend Users not expiring
Posted: Sun Dec 10, 2006 7:11 pm
by Dee
Added the changes
posted by mahjong to SVN.
In the IsAccountExpired method, instead of using the MySQL function NOW(), I also used trim( $db->DBTimeStamp(time()) , "'") so it will also work on other databases like Postgres.
mahjong: thanks again!
Re: Frontend Users not expiring
Posted: Sun Dec 17, 2006 7:16 pm
by mahjong
Added the changes posted by mahjong to SVN.
And a few days later, inexplicably, calguy1000 overwrote the fixes in FrontEndUsers.api.php with rev.107
Please update your working copy before committing changes...
Re: Frontend Users not expiring
Posted: Sun Dec 17, 2006 8:17 pm
by tsw
shouldn't svn give error about conflicts?
of course one can force the commit...