← Back to team overview

mahara-contributors team mailing list archive

[Bug 922031] Re: Suspended date time on a suspended user is not properly displayed when he tries to login

 

** Changed in: mahara
       Status: In Progress => Fix Released

** Changed in: mahara
    Milestone: 1.5.0 => None

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
https://bugs.launchpad.net/bugs/922031

Title:
  Suspended date time on a suspended user is not properly displayed when
  he tries to login

Status in Mahara ePortfolio:
  Fix Released

Bug description:
  Mahara master 1.5 dev from git, using MySQL on Linux

  When an user is suspended, its suspended date time is stored in table
  usr as a formatted string yyyy-mm-dd : hh:nn like in most other places
  of Mahara.

  But when the user tries to connect, the error message gives 'your
  account has been suspended on 1 january 1970 , 1:13  reason : ....'

  this is due to the fact that the function
  ensure_user_account_is_active() defined in auth/lib.php does not
  convert back the formatted datetime to an Unix timestamp before
  calling strftime function :

   $suspendedctime  = strftime(get_string('strftimedaydate'),
  $user->get('suspendedctime'));

  where it should be :

   $suspendedctime  = strftime(get_string('strftimedaydate'),
  strtotime($user->suspendedctime));

  This is likely due to the fact that at that moment the global variable $USER 
  still contains all its date informations as formatted strings and not yet as time stamps  (why ?)   as shown by this output of a print_r($USER) at the beginning of function ensure_user_account_is_active() :

              [logout_time] => 1327668801
              [id] => 5835
              [username] => ppollet2
              [password] => 3f9fbb213d671167a3de67eed512cb460f801ae0
              [salt] => 8ef00c74
              [passwordchange] => 0
              [active] => 1
              [deleted] => 0
              [expiry] => 
              [expirymailsent] => 0
              [lastlogin] => 2012-01-26 13:53:21       <---------
              [lastlastlogin] => 2012-01-26 12:25:57   <----------
              [lastaccess] => 2012-01-26 13:53:21      <-----------
              [inactivemailsent] => 0
              [staff] => 0
              [admin] => 0
              ....
              [profileicon] => 
              [suspendedctime] => 2012-01-26 11:03:09   <--------
              [suspendedreason] => doublon 
              [suspendedcusr] => 1
              [quota] => 5242880
              [quotaused] => 0
              [authinstance] => 1


  Attached a small patch against master ( 1.5dev)  where I also changed get_string('strftimedaydate' to
  get_string('strftimedaydatetime' to also display the time of suspension which is available

  according to a grep into all code , this should be fixed also in some
  other authentication plugins such as saml and xmlrpc

  [root@vm107-04 mahara]# grep -Rin strftimedaydate * |grep suspendedctime
  auth/lib.php:1417:        $suspendedctime  = strftime(get_string('strftimedaydate'), $user->get('suspendedctime'));
  auth/saml/lib.php:147:                die_info(get_string('accountsuspended', 'mahara', strftime(get_string('strftimedaydate'), $user->get('suspendedctime')), $user->get('suspendedreason')));
  auth/saml/index.php:583:        $suspendedctime  = strftime(get_string('strftimedaydate'), $USER->suspendedctime);
  auth/xmlrpc/lib.php:173:                die_info(get_string('accountsuspended', 'mahara', strftime(get_string('strftimedaydate'), $user->get('suspendedctime')), $user->get('suspendedreason')));

  Cheers

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/922031/+subscriptions


References