Page 1 of 1

FrontendUsers: The expire field can not be set. The users expire striaght away.

Posted: Fri Nov 24, 2006 6:31 am
by Bradleyenator
Hi,

The problem is this you can create as many users and groups, etc as you like however every time you go to set the expiry date it resets back to 0000-00-00 and hence the user can not login because they are already expired right from their creation.

Ok I have seen posts about this before however they are old and I assumed this problem would have been fixed by now. So I started a new thread.

I am using the 1.0.2 Maui and 1.1.1 FrontEndUsers.

Thanks Brad

Re: FrontendUsers: The expire field can not be set. The users expire striaght aw

Posted: Fri Nov 24, 2006 9:02 am
by ID2020
Same problem here, only my users can still login.  ???

Other problem is, i can't change the users inside the Frontendusers console inside cmsms. But i can change them by clicking on change my settings. :'(

Mayby it has got something to do with Selfreg?

Wil try to remove selfreg and see if the problem still exists.

Greetz ID2020

Re: FrontendUsers: The expire field can not be set. The users expire striaght aw

Posted: Mon Nov 27, 2006 2:43 am
by Bradleyenator
Well thats strange. What versions are you running even if my users can login with an expiry date of nothing well thats better I guess.

I ain't using selfreg so I don't know where the problem is.

Re: FrontendUsers: The expire field can not be set. The users expire striaght aw

Posted: Mon Nov 27, 2006 9:18 am
by ID2020
I'm using frontendusers v1.1.1 and selfreg v1.1.0-beta1. Also i use customcontent v1.4.3.
Oh i'm using it in the Dutch language.

It's not related to selfreg i checked.

I don't recieve error messages either.

Wil try to install a fresh copy and see what happens.

Greetz.

Re: FrontendUsers: The expire field can not be set. The users expire striaght aw

Posted: Mon Mar 19, 2007 2:05 pm
by kazkas
Subject: FEUsers v.1.1.3 beta 1, CMS MS v.1.0.4, database: MySQL v.5.0.33

I've soved problem with non-expiry users editing function IsAccountExpired in 166 line of FrontEndUsers.api.php Now it looks like this:

  function IsAccountExpired( $uid )
  {
    $db =& $this->GetDb();
   
    $q = "SELECT * FROM ".cms_db_prefix()."module_feusers_users
          WHERE id = ? AND (expires > NOW())";
    $parms = array($uid);
    $dbresult = $db->Execute($q, array($uid));
    if( $dbresult && $dbresult->RecordCount() == 1 )
      {
return false;
      }

    return true;
  }

Leave original copy of file somewhere just in case if it will not work for you.

P.S. for module author:
1. Why create $params array, if you not use it in Execute?
2. I think it's easier to do

  return (!(isset($dbresult) && $dbresult->RecordCount() == 1 ))

  instead of

    if( $dbresult && $dbresult->RecordCount() == 1 )
      {
return false;
      }

    return true;
  Sorry if I'm not tottaly wrong about that, but will it work on all machines without causing warnings when $dbresult is not set?  :-\

Re: FrontendUsers: The expire field can not be set. The users expire striaght aw

Posted: Mon Mar 19, 2007 2:30 pm
by calguy1000
A) NOW() is afaik specific to mysql, therefore people using postgress will find that this solution makes the problem worse.
 
B) the proper solution is here (it's been in SVN for a while.  it's a problem with adodb and adodb-lite, and DATETIME fields.  many modules experienced similar problems.  These fixes have been in SVN for a while).

Code: Select all

  function IsAccountExpired( $uid )
  {
    $db =& $this->GetDb();

    $q = "SELECT * FROM ".cms_db_prefix()."module_feusers_users
          WHERE id = ? AND expires > ?";
    $parms = array( $uid, $db->DbTimeStamp(time(),"'") );
    $dbresult = $db->Execute( $q, array( $uid,
                                         $db->DbTimeStamp(time(),"'") ) );
    if( $dbresult && $dbresult->RecordCount() == 1 )
      {
        return false;
      }
    return true;
  }
c) Regarding your PS:
This line:

Code: Select all

$dbresult = $db->Execute( $q, array( $uid, $db->DbTimeStamp(time(),"'") ) );
means that $dbresult exists, and is set (it just may be set to false).  so isset($dbresult) will always return true.  After that.... it's just a matter of choice as to how you organize your code.  I go for readability wherever possible.

:)

Re: FrontendUsers: The expire field can not be set. The users expire striaght aw

Posted: Mon Mar 19, 2007 3:06 pm
by kazkas
sorry  ::)