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

Bug #922031 reported by Patrick Pollet
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Low
Richard Mansfield

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

Revision history for this message
Patrick Pollet (pp-c) wrote :
Patrick Pollet (pp-c)
description: updated
Changed in mahara:
status: New → Triaged
importance: Undecided → Low
milestone: none → 1.5.0
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

See https://reviews.mahara.org/1038 - I think this was broken by me in commit 725ba92940, so I'll fix it there (in the commit function) rather than by reformatting the time again.

Changed in mahara:
assignee: nobody → Richard Mansfield (richard-mansfield)
status: Triaged → In Progress
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/1038
Committed: http://gitorious.org/mahara/mahara/commit/245abd15d607123a34fe705c0b696abd7b269fd1
Submitter: Francois Marier (<email address hidden>)
Branch: master

commit 245abd15d607123a34fe705c0b696abd7b269fd1
Author: Richard Mansfield <email address hidden>
Date: Tue Feb 7 11:06:17 2012 +1300

    Convert suspended date when reloading user object (bug #922031)

    Commit 725ba9294039b82bec947be5301acf160f4744ae tries to reload
    certain admin-settable fields from the database into a LiveUser when
    committing, but fails to convert the suspended date to a timestamp
    when doing so. This causes the date to be displayed incorrectly to
    suspended users when they log in.

    The same problem was fixed for expiry dates in commit f7dcdf818b, bug

    Change-Id: I3ce83f53183cbd9003226466149f54e878749d1e
    Signed-off-by: Richard Mansfield <email address hidden>

Changed in mahara:
status: In Progress → Fix Released
milestone: 1.5.0 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.