Welcome to Geeklog, Anonymous Monday, November 25 2024 @ 11:37 am EST

Geeklog Forums

User Manager add last login


Status: offline

Sniper12

Forum User
Regular Poster
Registered: 11/25/03
Posts: 81
Location:Denmark
Is it possible in User Manager. That it can certain when an user have it been logget in last.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Erm, it's already doing that ...

bye, Dirk
 Quote

Status: offline

Sniper12

Forum User
Regular Poster
Registered: 11/25/03
Posts: 81
Location:Denmark
Yes it do, if you click on the user, But I will gladly have it to that where all the users names are.
 Quote

Status: offline

varian vega

Forum User
Newbie
Registered: 05/21/04
Posts: 10
Hello Sniper,
to show the last login date in the admin userlist you have to hack the admin/user.php and the related template. I did this a while ago if you are interested drop a line and I write the details.
Bye, varian
 Quote

Status: offline

Sniper12

Forum User
Regular Poster
Registered: 11/25/03
Posts: 81
Location:Denmark
Yes I still interested in how to do this, I have traded but I’m not the best programmer.
 Quote

Status: offline

varian vega

Forum User
Newbie
Registered: 05/21/04
Posts: 10
Ok here we go:

Open the admin/user.php and look for the function listusers. Then look for the a line like the following and replace the code with this:

Text Formatted Code
$offset = (($curpage - 1) * $limit);

    if (!empty($query)) {
        $sql = "SELECT u.uid,u.username,u.fullname,u.email,i.lastlogin FROM {$_TABLES['users']} AS u, {$_TABLES['userinfo']} AS i WHERE u.uid=i.uid AND u.uid > 1 AND (u.username LIKE '$query' OR u.email LIKE '$query' OR u.fullname LIKE '$query') LIMIT $offset,$limit";
    } else {
        $sql = "SELECT u.uid,u.username,u.fullname,u.email,i.lastlogin FROM {$_TABLES['users']} AS u, {$_TABLES['userinfo']} AS i WHERE u.uid=i.uid AND u.uid > 1 LIMIT $offset,$limit";
    }
    $result = DB_query($sql);
    $nrows = DB_numRows($result);
   
    for ($i = 0; $i < $nrows; $i++) {
        $A = DB_fetchArray($result);
        $lasttime = COM_getUserDateTimeFormatShort ($A['lastlogin']);
        $user_templates->set_var('user_id', $A['uid']);
        $user_templates->set_var('username', $A['username']);
        $user_templates->set_var('user_fullname', $A['fullname']);
        $user_templates->set_var('user_email', $A['email']);
        $user_templates->set_var('lang_lastlogin', $LANG28[35]);
        if (empty ($A['lastlogin'])) {
            $user_templates->set_var('user_lastlogin', $LANG28[36]);
        } else {
           $user_templates->set_var('user_lastlogin', $lasttime[0]);
        }
        $user_templates->parse('user_row', 'row', true);
        }
 


after that you have to change the related templates in your layout directory. first, edit admin/userslist.thtml:
look for code like following and replace it with this:

Text Formatted Code
<table border="0" cellspacing="0" cellpadding="2" width="100%">
                                <tr>
                                    <th align="left">{lang_username}</th>
                                    <th>{lang_fullname}</th>
                                    <th>{lang_emailaddress}</th>
                                    <th>{lang_lastlogin}</th>
                                </tr>
                                {user_row}
                                </tr>
                            </table>
 


next, edit admin/listitem.thtml:

Text Formatted Code
                                <tr align="center">
                                    <td align="left"><a href="{site_url}/users.php?mode=profile&uid={user_id}"><img src="{layout_url}/images/person.gif" border="0" alt=""></a> <a href="{site_admin_url}/user.php?mode=edit&uid={user_id}">{username}</a></td>
                                    <td>{user_fullname}</td>
                                    <td>{user_email}</td>
                                    <td>{user_lastlogin}</td>
                                </tr>
 


Thats it.

Bye, varian
 Quote

Status: offline

Sniper12

Forum User
Regular Poster
Registered: 11/25/03
Posts: 81
Location:Denmark
Okay I have tray to do it and I get this error

Fatal error: Call to undefined function: com_getuserdatetimeformatshort() in /customers/sugecrew.dk/sugecrew.dk/httpd.www/prideofvbk/geeklog/public_html/admin/user.php on line 417


And it is this line I think

$lasttime = COM_getUserDateTimeFormatShort ($A['lastlogin']);
 Quote

Status: offline

varian vega

Forum User
Newbie
Registered: 05/21/04
Posts: 10
Hi Sniper!

Sorry, I had added that function to my lib-custom.php to get a shorter time format. Change that line to
Text Formatted Code
COM_getUserDateTimeFormat($A['lastlogin']);
 

and it should work.
If you want the shorter date displayed (like I preferred), you have to add this function to your lib-custom.php in your systems folder (and then you do not have to change line above).

Text Formatted Code
function COM_getUserDateTimeFormatShort( $date='' )
{
    global $_TABLES, $_USER, $_CONF;

    // Get display format for time

    if( $_USER['uid'] > 1 )
    {
        if( empty( $_USER['format'] ))
        {
            $dateformat = $_CONF['daytime'];
        }
        else
        {
            $dateformat = $_USER['format'];
        }
    }
    else
    {
        $dateformat = $_CONF['daytime'];
    }

    if( empty( $date ))
    {
        // Date is empty, get current date/time
        $stamp = time();
    }
    else if( is_numeric( $date ))
    {
        // This is a timestamp
        $stamp = $date;
    }
    else
    {
        // This is a string representation of a date/time
        $stamp = strtotime( $date );
    }

    // Format the date

    $date = strftime( $dateformat, $stamp );

    return array( $date, $stamp );
}
 


If you still get errors, post a reply / send a pm.

varian
 Quote

Status: offline

Sniper12

Forum User
Regular Poster
Registered: 11/25/03
Posts: 81
Location:Denmark
I have edit the lib-custom.php file and now it works 100% . Now I can see I have 2 users that never have ben on the site.
 Quote

Status: offline

varian vega

Forum User
Newbie
Registered: 05/21/04
Posts: 10
Glad I could help you
 Quote

All times are EST. The time is now 11:37 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content