Verified Commit 4a6b89cb authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(freeradius) Fix identation and code style

Also removed useless or wrong attribute parameters

issue #6040
parent 23017768
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2009 GONICUS GmbH
Copyright (C) 2012 WILLIAME Jeremy
Copyright (C) 2011-2016 FusionDirectory
Copyright (C) 2011-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -20,7 +21,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class freeradiusAccount extends simplePlugin
{
protected $displayHeader = TRUE;
......@@ -29,7 +29,7 @@ class freeradiusAccount extends simplePlugin
{
return [
'plShortName' => _('Freeradius'),
'plDescription' => _('This Plugin is for Radius accounting based in FreeRadius'),
'plDescription' => _('Radius accounting based on FreeRadius'),
'plFilter' => '(objectClass=radiusprofile)',
'plIcon' => 'geticon.php?context=applications&icon=freeradius&size=48',
'plSmallIcon' => 'geticon.php?context=applications&icon=freeradius&size=16',
......@@ -42,14 +42,10 @@ class freeradiusAccount extends simplePlugin
];
}
/*!
* \brief The main function : information about attributes
*/
static function getAttributesInfo (): array
{
return [
// Attributes are grouped by section
'section1' => [
'section1' => [
'name' => _('Support 802.1x'),
'attrs' => [
new StringAttribute(
......@@ -57,15 +53,14 @@ class freeradiusAccount extends simplePlugin
'radiusTunnelMediumType', TRUE,
'IEEE-802'
),
new StringAttribute(
new StringAttribute(
_('Tunnel type'), _('Name of the tunnel type'),
'radiusTunnelType', TRUE,
'VLAN'
),
new StringAttribute(
_('VLAN id'), _('VLAN identifier'),
'radiusTunnelPrivateGroupId', FALSE,
''
'radiusTunnelPrivateGroupId', FALSE
),
new DateAttribute(
_('Expiration date'), _('Date of the expiration account'),
......@@ -78,74 +73,69 @@ class freeradiusAccount extends simplePlugin
'name' => _('Groups'),
'attrs' => [
new SetAttribute(
new SelectAttribute(
_('Groups'),
_('FreeRadius Group'),
'radiusGroupName',
FALSE,
[""]
new SelectAttribute(
_('Groups'), _('FreeRadius Groups'),
'radiusGroupName', FALSE
)
),
],
],
'section3' => [
'name' => _('User preferences'),
'attrs' => [
new StringAttribute(
_('Protocol'), _('Protocol'),
'radiusFramedProtocol', FALSE,
'PPP'
),
new StringAttribute(
_('IP Address'), _('IP Address'),
'radiusFramedIPAddress', FALSE,
'255.255.255.254'
),
new StringAttribute(
_('IP Netmask'), _('IP Netmask'),
'radiusFramedIPNetmask', FALSE,
''
),
new IntAttribute(
_('Framed-MTU'), _('Framed-MTU'),
'radiusFramedMTU', FALSE,
0,
FALSE,
1500
),
new StringAttribute(
_('Compression'), _('Compression'),
'radiusFramedCompression', FALSE,
'Van-Jacobsen-TCP-IP'
),
new StringAttribute(
_('Service type'), _('Service type'),
'radiusServiceType', FALSE,
'Framed-User'
),
new IntAttribute(
_('Session Timeout'), _('Session Timeout'),
'radiusSessionTimeout', FALSE,
FALSE,
FALSE,
""
),
new IntAttribute(
_('Idle Timeout'), _('Idle Timeout'),
'radiusIdleTimeout', FALSE,
"",
FALSE,
10
),
new IntAttribute(
_('Port limit'), _('Port limit'),
'radiusPortLimit', FALSE,
0,
FALSE,
2
)
]
'attrs' => [
new StringAttribute(
_('Protocol'), _('Protocol'),
'radiusFramedProtocol', FALSE,
'PPP'
),
new StringAttribute(
_('IP Address'), _('IP Address'),
'radiusFramedIPAddress', FALSE,
'255.255.255.254'
),
new StringAttribute(
_('IP Netmask'), _('IP Netmask'),
'radiusFramedIPNetmask', FALSE
),
new IntAttribute(
_('Framed-MTU'), _('Framed-MTU'),
'radiusFramedMTU', FALSE,
0,
FALSE,
1500
),
new StringAttribute(
_('Compression'), _('Compression'),
'radiusFramedCompression', FALSE,
'Van-Jacobsen-TCP-IP'
),
new StringAttribute(
_('Service type'), _('Service type'),
'radiusServiceType', FALSE,
'Framed-User'
),
new IntAttribute(
_('Session Timeout'), _('Session Timeout'),
'radiusSessionTimeout', FALSE,
FALSE,
FALSE
),
new IntAttribute(
_('Idle Timeout'), _('Idle Timeout'),
'radiusIdleTimeout', FALSE,
FALSE,
FALSE,
10
),
new IntAttribute(
_('Port limit'), _('Port limit'),
'radiusPortLimit', FALSE,
0,
FALSE,
2
)
]
]
];
}
......@@ -153,13 +143,13 @@ class freeradiusAccount extends simplePlugin
* \brief Constructor of the freeradiusAccount
* It will build the select groups choices
*/
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
function __construct (string $dn = NULL, $object = NULL, $parent = NULL, bool $mainTab = FALSE)
{
global $config;
parent::__construct($dn, $object, $parent, $mainTab);
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->search('(objectClass=radiusprofile)', ['cn']);
$ldap->search('(&(objectClass=radiusprofile)(cn=*))', ['cn']);
$groups = [];
while ($attrs = $ldap->fetch()) {
$groups[] = $attrs['cn'][0];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment