mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-72592 block_myprofile: Add lastlogin date to myprofile block
This commit is contained in:
parent
17ee072693
commit
d5c144c14a
@ -120,6 +120,13 @@ class myprofile implements renderable, templatable {
|
||||
$data->userlastip = $USER->lastip;
|
||||
}
|
||||
|
||||
if (!empty($this->config->display_lastlogin)) {
|
||||
if (empty($USER->lastlogin)) {
|
||||
$data->userlastlogin = 0;
|
||||
} else {
|
||||
$data->userlastlogin = userdate($USER->lastlogin);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -119,5 +119,12 @@ class block_myprofile_edit_form extends block_edit_form {
|
||||
} else {
|
||||
$mform->setDefault('config_display_lastip', '0');
|
||||
}
|
||||
|
||||
$mform->addElement('selectyesno', 'config_display_lastlogin', get_string('display_lastlogin', 'block_myprofile'));
|
||||
if (isset($this->block->config->display_lastlogin)) {
|
||||
$mform->setDefault('config_display_lastlogin', $this->block->config->display_lastlogin);
|
||||
} else {
|
||||
$mform->setDefault('config_display_lastlogin', '0');
|
||||
}
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ $string['display_address'] = 'Display address';
|
||||
$string['display_firstaccess'] = 'Display first access';
|
||||
$string['display_lastaccess'] = 'Display last access';
|
||||
$string['display_currentlogin'] = 'Display current login';
|
||||
$string['display_lastlogin'] = 'Display last login';
|
||||
$string['display_lastip'] = 'Display last IP';
|
||||
$string['myprofile:addinstance'] = 'Add a new logged in user block';
|
||||
$string['myprofile:myaddinstance'] = 'Add a new logged in user block to Dashboard';
|
||||
|
@ -42,6 +42,7 @@
|
||||
* userlastaccess
|
||||
* usercurrentlogin
|
||||
* userlastip
|
||||
* userlastlogin
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
@ -58,7 +59,8 @@
|
||||
"userfirstaccess": "Friday, 6 July 2018, 9:03 AM",
|
||||
"userlastaccess": "Wednesday, 26 September 2018, 8:05 AM",
|
||||
"usercurrentlogin": "Wednesday, 26 September 2018, 7:17 AM",
|
||||
"userlastip": "0:0:0:0:0:0:0:1"
|
||||
"userlastip": "0:0:0:0:0:0:0:1",
|
||||
"userlastlogin": "Wednesday, 25 September 2018, 9:01 AM"
|
||||
}
|
||||
}}
|
||||
<div>
|
||||
@ -138,6 +140,12 @@
|
||||
{{ usercurrentlogin }}
|
||||
</div>
|
||||
{{/usercurrentlogin}}
|
||||
{{#userlastlogin}}
|
||||
<div class="myprofileitem lastlogin">
|
||||
<span>{{#str}} lastlogin {{/str}}:</span>
|
||||
{{ userlastlogin }}
|
||||
</div>
|
||||
{{/userlastlogin}}
|
||||
{{#userlastip}}
|
||||
<div class="myprofileitem lastip">
|
||||
<span>IP:</span>
|
||||
|
@ -231,3 +231,22 @@ Feature: The logged in user block allows users to view their profile information
|
||||
| Display ID number | Yes |
|
||||
And I press "Save changes"
|
||||
And I should see "ID number:" in the "Logged in user" "block"
|
||||
|
||||
Scenario: Configure the logged in user block to show / hide the users last login
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | One | teacher1@example.com |
|
||||
And I log in as "teacher1"
|
||||
And I press "Customise this page"
|
||||
When I add the "Logged in user" block
|
||||
And I configure the "Logged in user" block
|
||||
And I set the following fields to these values:
|
||||
| Display last login | No |
|
||||
And I press "Save changes"
|
||||
Then I should see "Teacher One" in the "Logged in user" "block"
|
||||
And I should not see "Last login:" in the "Logged in user" "block"
|
||||
And I configure the "Logged in user" block
|
||||
And I set the following fields to these values:
|
||||
| Display last login | Yes |
|
||||
And I press "Save changes"
|
||||
And I should see "Last login:" in the "Logged in user" "block"
|
||||
|
Loading…
x
Reference in New Issue
Block a user