Extension:LastLoginTime

What can this extension do?
This Extension is a simple one which displays User's Last login time at the top of the page as a personal url.I wrote this Extension because i thought this will be a good idea to display last login time for the users.It may help others if they have same requirement for their application.

Usage
This extension is as mentioned a simple one so usage is not a big deal. Just confirm the table and column names in the code are according to your Database. Install it and that's it.

Installation
Copy the code given at LastLoginTime.php Save it in Extension directory as LastLoginTime.php Include it in LocalSettings.php That's all you need to do.

Changes to LocalSettings.php
require_once("$IP/extensions/LastLoginTime.php");

Code
 "LastLoginTime (version-1.0)",    'author' => 'Sanjeev Sanjeev' );

$wgHooks['UserLoginComplete'][] = 'wfLastLoginTime';

$wgHooks['PersonalUrls'][] = 'wfShowLastLoginTime';

function wfShowLastLoginTime(&$personal_urls, &$wgTitle) {       #displays the Last Login Time for the current user as a personal url. if( isset($_SESSION['wsLastLogin']) ) {               $personal_urls['lastlogin'] = array(                        'text' => $_SESSION['wsLastLogin']                        ); }       return true; }
 * 1) Event Handler for PersonalUrls Hook

function wfLastLoginTime {               #The last login time is read from databease in stored in session. $dbr =& wfGetDB( DB_SLAVE ); $lastLogin = $dbr->selectField('mwuser','user_touched',                       array('user_name' => $_SESSION['wsUserName']),                                _METHOD_); if(isset($lastLogin)) {                       $day = substr($lastLogin,8,2); $month = substr($lastLogin,5,2); $month = getMonth($month); $time = substr($lastLogin,11,5); $year = substr($lastLogin,0,4); $dateTime = $time.", ".$day." ".$month." ".$year; $_SESSION['wsLastLogin'] = $dateTime; }	  #the login time is updated with the current time $dbw =& wfGetDB( DB_MASTER ); $dbw->update( 'mwuser',                       /* SET */ array( 'user_touched' => 'now' ),                       /* WHERE */ array( 'user_name' => $_SESSION['wsUserName'])                          ); return true; }
 * 1) Event Handler for UserLoginComplete

function getMonth($month) {       $months = array('01'=>'Jan','02'=>'Feb','03'=>'Mar','04'=>'Apr','05'=>'May','06'=>'Jun',	'07'=>'Jul','08'=>'Aug','09'=>'Sep','10'=>'Oct','11'=>'Nov','12'=>'Dec'); return $months[$month]; } ?>
 * 1) This function will return month Name.

Contact
In case of any issues please get in touch with me. Sanjeev Thanks!!!