Skip to content

Commit

Permalink
MDL-18633 User profile: add last ip field to user view
Browse files Browse the repository at this point in the history
  • Loading branch information
danielneis committed Feb 18, 2014
1 parent 692d247 commit 9d9361e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions admin/settings/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
'msnid' => new lang_string('msnid'),
'firstaccess' => new lang_string('firstaccess'),
'lastaccess' => new lang_string('lastaccess'),
'lastip' => new lang_string('lastip'),
'mycourses' => new lang_string('mycourses'),
'groups' => new lang_string('groups'),
'suspended' => new lang_string('suspended', 'auth'),
Expand Down
1 change: 1 addition & 0 deletions lang/en/moodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@
$string['last'] = 'Last';
$string['lastaccess'] = 'Last access';
$string['lastedited'] = 'Last edited';
$string['lastip'] = 'Last IP address';
$string['lastlogin'] = 'Last login';
$string['lastmodified'] = 'Last modified';
$string['lastname'] = 'Surname';
Expand Down
10 changes: 10 additions & 0 deletions lib/db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,16 @@
'clonepermissionsfrom' => 'moodle/user:update'
),

'moodle/user:viewlastip' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'read',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/user:update'
),

'moodle/user:viewhiddendetails' => array(

'riskbitmask' => RISK_PERSONAL,
Expand Down
11 changes: 11 additions & 0 deletions user/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@
echo html_writer::tag('dd', $datestring);
}

if (has_capability('moodle/user:viewlastip', $usercontext) && !isset($hiddenfields['lastip'])) {
if ($user->lastip) {
$iplookupurl = new moodle_url('/iplookup/index.php', array('ip' => $user->lastip, 'user' => $USER->id));
$ipstring = html_writer($iplookupurl, $user->lastip);
} else {
$ipstring = get_string("none");
}
echo html_writer::tag('dt', get_string('lastip'));
echo html_writer::tag('dd', $ipstring);
}

/// Printing tagged interests
if (!empty($CFG->usetags)) {
if ($interests = tag_get_tags_csv('user', $user->id) ) {
Expand Down
11 changes: 11 additions & 0 deletions user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,17 @@
echo html_writer::tag('dd', get_string('suspended', 'auth'));
}
}

if (has_capability('moodle/user:viewlastip', $usercontext) && !isset($hiddenfields['lastip'])) {
if ($user->lastip) {
$iplookupurl = new moodle_url('/iplookup/index.php', array('ip' => $user->lastip, 'user' => $USER->id));
$ipstring = html_writer($iplookupurl, $user->lastip);
} else {
$ipstring = get_string("none");
}
echo html_writer::tag('dt', get_string('lastip'));
echo html_writer::tag('dd', $ipstring);
}
echo html_writer::end_tag('dl');
echo "</div></div>"; // Closing desriptionbox and userprofilebox.
// Print messaging link if allowed
Expand Down

0 comments on commit 9d9361e

Please sign in to comment.