/** * @param User $oldUser * @param User $newUser * @return bool */ public static function onMergeAccountFromTo(User &$oldUser, User &$newUser) { $dbr = wfGetDB(DB_SLAVE); // Get the last login for both old and new $res = $dbr->select('accountaudit_login', array('aa_user', 'aa_lastlogin'), array($dbr->makeList(array('aa_user='******'aa_user=' . $dbr->addQuotes($newUser->getId())), LIST_OR))); $greatest = 0; foreach ($res as $row) { if ($row->aa_lastlogin > $greatest) { $greatest = $row->aa_lastlogin; } } if ($greatest !== 0) { // Set the last login for the new account to most recent // of both accounts AccountAudit::updateLastLogin($newUser, $greatest); } return true; }
Modes There are two different modes of this page: load: Virgin load with no data except a ledger_id, account name, account balance, and audit date. save: Form data with edited comments and date. */ $current_page = 'audit'; require 'include.php'; if (!isset($_SESSION['login_id'])) { // redirect to login if they have not logged in header("Location: login.php"); } // Initialize defaults $error = ''; $audit = new AccountAudit(); if (isset($_GET['ledger_id'])) { // First load of the screen $audit->Load_basic_audit($_GET['ledger_id'], $_GET['account_total']); } elseif (isset($_GET['audit_id'])) { // Load from an audit id $audit->Load_account_audit($_GET['audit_id']); } elseif (isset($_POST['save'])) { // Did a submit; try to load the result $error = $audit->Init_account_audit($_POST['ledger_id'], $_POST['audit_date'], $_POST['account_balance'], $_POST['audit_comment'], $_POST['account_name'], $_POST['audit_id']); if ($error == '') { // Attempt to save the data $error = $audit->Save_account_audit(); } } elseif (isset($_POST['delete'])) { // Attempt to delete this record
/** * Implementation of the hook for onUserLoginComplete. * * Calls AccountAudit::updateLastLogin to update the timestamp of the last * login for the user * * @param User $user * @param $inject_html * * @return bool */ static function onUserLoginComplete(User &$user, &$inject_html) { AccountAudit::updateLastLogin($user); // Always return true, we should never block execution on failure return true; }