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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
Bradleyenator

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

Post 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
ID2020
Forum Members
Forum Members
Posts: 39
Joined: Wed Feb 08, 2006 12:47 am

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

Post 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
Bradleyenator

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

Post 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.
ID2020
Forum Members
Forum Members
Posts: 39
Joined: Wed Feb 08, 2006 12:47 am

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

Post 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.
kazkas

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

Post 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?  :-\
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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.

:)
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Locked

Return to “CMSMS Core”