From 557ad2d1fd70d41a52f2805f8f8e7fbfd9303f99 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 13 Feb 2016 00:51:43 +0100 Subject: [PATCH] Show user registration IP to users who can see ModLog --- .../RegisterThrottlePlugin.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plugins/RegisterThrottle/RegisterThrottlePlugin.php b/plugins/RegisterThrottle/RegisterThrottlePlugin.php index 9d3be3b8a2..b1e352474f 100644 --- a/plugins/RegisterThrottle/RegisterThrottlePlugin.php +++ b/plugins/RegisterThrottle/RegisterThrottlePlugin.php @@ -134,6 +134,37 @@ class RegisterThrottlePlugin extends Plugin return true; } + function onEndShowSections(Action $action) + { + if (!$action instanceof ShowstreamAction) { + // early return for actions we're not interested in + return true; + } + + $scoped = $action->getScoped(); + if (!$scoped instanceof Profile || !$scoped->hasRight(self::VIEWMODLOG)) { + // only continue if we are allowed to VIEWMODLOG + return true; + } + + $ri = Registration_ip::getKV('user_id', $profile->id); + $ipaddress = null; + if ($ri instanceof Registration_ip) { + $ipaddress = $ri->ipaddress; + unset($ri); + } + + $action->elementStart('div', array('id' => 'entity_mod_log', + 'class' => 'section')); + + $action->element('h2', null, _('Registration IP')); + + $action->element('strong', null, _('Registered from:')); + $action->element('span', ['class'=>'ipaddress'], $ipaddress ?: 'unknown'); + + $action->elementEnd('div'); + } + /** * Called after someone registers, by any means. *