]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/RegisterThrottle/actions/ipregistrations.php
listGet was not meant for that really
[quix0rs-gnu-social.git] / plugins / RegisterThrottle / actions / ipregistrations.php
1 <?php
2
3 if (!defined('GNUSOCIAL')) { exit(1); }
4
5 class IpregistrationsAction extends ManagedAction
6 {
7     protected $needLogin = true;
8
9     protected $ipaddress = null;
10
11     function title()
12     {
13         return sprintf(_('Registrations from IP %s'), $this->ipaddress);
14     }
15
16     protected function doPreparation()
17     {
18         if (!$this->scoped->hasRight(Right::SILENCEUSER) && !$this->scoped->hasRole(Profile_role::ADMINISTRATOR)) {
19             throw new AuthorizationException(_('You are not authorized to view this page.'));
20         }
21
22         $this->ipaddress    = $this->trimmed('ipaddress');
23         $this->profile_ids  = Registration_ip::usersByIP($this->ipaddress);
24     }
25
26     public function showContent()
27     {
28         $this->elementStart('ul');
29         $profile = Profile::multiGet('id', $this->profile_ids);
30         while ($profile->fetch()) {
31             $this->elementStart('li');
32             try {
33                 $this->element('a', ['href'=>$profile->getUrl()], $profile->getFancyName());
34             } catch (InvalidUrlException $e) {
35                 $this->element('span', null, $profile->getFancyName());
36             }
37             $this->elementEnd('li');
38         }
39         $this->elementEnd('ul');
40     }
41 }