refactoring

This commit is contained in:
Roland Gruber 2024-06-11 19:28:49 +02:00
parent 03c7e0868d
commit 22e0f49efb
4 changed files with 548 additions and 545 deletions

View file

@ -2,7 +2,7 @@
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2022 Roland Gruber
Copyright (C) 2009 - 2024 Roland Gruber
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
@ -38,11 +38,11 @@ class eduPerson extends baseModule {
/**
* These attributes will be ignored by default if a new account is copied from an existing one.
*/
const ATTRIBUTES_TO_IGNORE_ON_COPY = array('eduPersonNickname', 'eduPersonPrincipalName');
const ATTRIBUTES_TO_IGNORE_ON_COPY = ['eduPersonNickname', 'eduPersonPrincipalName'];
/** possible affiliation types */
private $affiliationTypes = array('faculty', 'student', 'staff', 'alum',
'member', 'affiliate', 'employee', 'library-walk-in');
private $affiliationTypes = ['faculty', 'student', 'staff', 'alum',
'member', 'affiliate', 'employee', 'library-walk-in'];
/**
* Creates a new eduPerson object.
@ -60,7 +60,7 @@ class eduPerson extends baseModule {
* @return boolean true if module fits
*/
public function can_manage() {
return in_array($this->get_scope(), array('user'));
return in_array($this->get_scope(), ['user']);
}
/**
@ -77,157 +77,157 @@ class eduPerson extends baseModule {
// alias name
$return["alias"] = _("EDU person");
// module dependencies
$return['dependencies'] = array('depends' => [], 'conflicts' => []);
$return['dependencies'] = ['depends' => [], 'conflicts' => []];
// managed object classes
$return['objectClasses'] = array('eduPerson');
$return['objectClasses'] = ['eduPerson'];
// managed attributes
$return['attributes'] = array('eduPersonAffiliation', 'eduPersonNickname',
$return['attributes'] = ['eduPersonAffiliation', 'eduPersonNickname',
'eduPersonOrgDN', 'eduPersonOrgUnitDN',
'eduPersonPrimaryAffiliation', 'eduPersonPrincipalName',
'eduPersonEntitlement', 'eduPersonPrimaryOrgUnitDN',
'eduPersonScopedAffiliation', 'eduPersonAssurance');
'eduPersonScopedAffiliation', 'eduPersonAssurance'];
// RDN attribute
$return["RDN"] = array('eduPersonPrincipalName' => 'low');
$return["RDN"] = ['eduPersonPrincipalName' => 'low'];
// help Entries
$return['help'] = array(
'primaryAffiliation' => array(
$return['help'] = [
'primaryAffiliation' => [
"Headline" => _("Primary affiliation"), 'attr' => 'eduPersonPrimaryAffiliation',
"Text" => _("Specifies the person's primary relationship to the institution in broad categories such as student, faculty, staff, alum, etc.")
),
'scopedAffiliation' => array(
],
'scopedAffiliation' => [
"Headline" => _("Scoped affiliations"), 'attr' => 'eduPersonScopedAffiliation',
"Text" => _("Specifies the person's affiliation within a particular security domain in broad categories such as student, faculty, staff, alum, etc.")
),
'scopedAffiliationUpload' => array(
],
'scopedAffiliationUpload' => [
"Headline" => _("Scoped affiliations"), 'attr' => 'eduPersonScopedAffiliation',
"Text" => _("Specifies the person's affiliation within a particular security domain in broad categories such as student, faculty, staff, alum, etc.") . " " .
_('Multiple values are separated by comma.')
),
'eduPersonNickname' => array(
],
'eduPersonNickname' => [
"Headline" => _("Nick names"), 'attr' => 'eduPersonNickname',
"Text" => _("This is a list of nick names for this user.")
),
'affiliation' => array(
],
'affiliation' => [
"Headline" => _("Affiliations"), 'attr' => 'eduPersonAffiliation',
"Text" => _("Specifies the person's relationships to the institution in broad categories such as student, faculty, staff, alum, etc.")
),
'affiliationUpload' => array(
],
'affiliationUpload' => [
"Headline" => _("Affiliations"), 'attr' => 'eduPersonAffiliation',
"Text" => _("Specifies the person's relationships to the institution in broad categories such as student, faculty, staff, alum, etc.") . " " .
_('Multiple values are separated by comma.')
),
'eduPersonPrincipalName' => array(
],
'eduPersonPrincipalName' => [
"Headline" => _("Principal name"), 'attr' => 'eduPersonPrincipalName',
"Text" => _("The \"NetID\" of the person for the purposes of inter-institutional authentication. It should be represented in the form \"user@scope\" where scope defines a local security domain.")
),
'eduPersonEntitlement' => array(
],
'eduPersonEntitlement' => [
"Headline" => _("Entitlements"), 'attr' => 'eduPersonEntitlement',
"Text" => _("URI (either URN or URL) that indicates a set of rights to specific resources.")
),
'entitlementUpload' => array(
],
'entitlementUpload' => [
"Headline" => _("Entitlements"), 'attr' => 'eduPersonEntitlement',
"Text" => _("URI (either URN or URL) that indicates a set of rights to specific resources.") . " " . _('Multiple values are separated by comma.')
),
'eduPersonOrgDN' => array(
],
'eduPersonOrgDN' => [
"Headline" => _("Organisation"), 'attr' => 'eduPersonOrgDN',
"Text" => _("The DN of the directory entry representing the institution with which the person is associated.")
),
'eduPersonPrimaryOrgUnitDN' => array(
],
'eduPersonPrimaryOrgUnitDN' => [
"Headline" => _("Primary organisational unit"), 'attr' => 'eduPersonPrimaryOrgUnitDN',
"Text" => _("The DN of the directory entry representing the person's primary organisational unit.")
),
'eduPersonOrgUnitDN' => array(
],
'eduPersonOrgUnitDN' => [
"Headline" => _("Organisational units"), 'attr' => 'eduPersonOrgUnitDN',
"Text" => _("The DNs of the directory entries representing the person's organisational units.")
),
'orgUnitDNUpload' => array(
],
'orgUnitDNUpload' => [
"Headline" => _("Organisational units"), 'attr' => 'eduPersonOrgUnitDN',
"Text" => _("The DNs of the directory entries representing the person's organisational units.") . ' ' . _('Multiple values are separated by comma.')
),
'eduPersonAssurance' => array(
],
'eduPersonAssurance' => [
"Headline" => _('Assurance profiles'), 'attr' => 'eduPersonAssurance',
"Text" => _('Assurance profiles are the set of standards that are met by an identity assertion.')
),
'eduPersonAssuranceUpload' => array(
],
'eduPersonAssuranceUpload' => [
"Headline" => _('Assurance profiles'), 'attr' => 'eduPersonAssurance',
"Text" => _('Assurance profiles are the set of standards that are met by an identity assertion.') . " " . _('Multiple values are separated by comma.')
),
'autoAdd' => array(
],
'autoAdd' => [
"Headline" => _("Automatically add this extension"),
"Text" => _("This will enable the extension automatically if this profile is loaded.")
));
]];
// profile options
$profileContainer = new htmlResponsiveRow();
$profileContainer->add(new htmlResponsiveInputCheckbox('eduPerson_addExt', false, _('Automatically add this extension'), 'autoAdd'), 12);
$return['profile_options'] = $profileContainer;
// upload fields
$return['upload_columns'] = array(
array(
$return['upload_columns'] = [
[
'name' => 'eduPerson_principalName',
'description' => _('Principal name'),
'help' => 'eduPersonPrincipalName',
'example' => _('user@company.com'),
'unique' => true
),
array(
],
[
'name' => 'eduPerson_primaryAffiliation',
'description' => _('Primary affiliation'),
'help' => 'primaryAffiliation',
'example' => 'student',
'values' => implode(", ", $this->affiliationTypes)
),
array(
],
[
'name' => 'eduPerson_scopedAffiliation',
'description' => _('Scoped affiliations'),
'help' => 'scopedAffiliationUpload',
'example' => 'student@domain, student@domain2'
),
array(
],
[
'name' => 'eduPerson_affiliation',
'description' => _('Affiliations'),
'help' => 'affiliationUpload',
'example' => 'student, employee',
'values' => implode(", ", $this->affiliationTypes)
),
array(
],
[
'name' => 'eduPerson_nickname',
'description' => _('Nick names'),
'help' => 'eduPersonNickname',
'example' => _('Steve, Stevo')
),
array(
],
[
'name' => 'eduPerson_entitlement',
'description' => _('Entitlements'),
'help' => 'entitlementUpload',
'example' => 'http://xstor.com/contracts/HEd123'
),
array(
],
[
'name' => 'eduPerson_orgDN',
'description' => _('Organisation'),
'help' => 'eduPersonOrgDN',
'example' => _('ou=accounts,dc=yourdomain,dc=org')
),
array(
],
[
'name' => 'eduPerson_primaryOrgUnitDN',
'description' => _('Primary organisational unit'),
'help' => 'eduPersonPrimaryOrgUnitDN',
'example' => _('ou=accounts,dc=yourdomain,dc=org')
),
array(
],
[
'name' => 'eduPerson_orgUnitDN',
'description' => _('Organisational units'),
'help' => 'orgUnitDNUpload',
'example' => _('ou=accounts,dc=yourdomain,dc=org')
),
array(
],
[
'name' => 'eduPerson_assurance',
'description' => _('Assurance profiles'),
'help' => 'eduPersonAssuranceUpload',
'example' => 'urn:mace:incommon:IAQ:sample, http://idm.example.org/LOA#sample'
),
);
],
];
// available PDF fields
$return['PDF_fields'] = array(
$return['PDF_fields'] = [
'affiliation' => _('Affiliations'),
'nickname' => _('Nick names'),
'orgDN' => _('Organisation'),
@ -238,7 +238,7 @@ class eduPerson extends baseModule {
'primaryOrgUnitDN' => _('Primary organisational unit'),
'scopedAffiliation' => _('Scoped affiliations'),
'eduPersonAssurance' => _('Assurance profiles'),
);
];
return $return;
}
@ -246,17 +246,17 @@ class eduPerson extends baseModule {
* This function fills the error message array with messages
*/
function load_Messages() {
$this->messages['eduPersonPrincipalName'][0] = array('ERROR', _('Principal name is invalid!'));
$this->messages['eduPersonPrincipalName'][1] = array('ERROR', _('Account %s:') . ' eduPerson_principalName', _('Principal name is invalid!'));
$this->messages['eduPersonOrgDN'][0] = array('ERROR', _('Please enter a valid DN in the field:') . ' ' . _("Organisation"));
$this->messages['eduPersonOrgDN'][1] = array('ERROR', _('Account %s:') . ' eduPerson_orgDN', _('This is not a valid DN!'));
$this->messages['eduPersonPrimaryOrgUnitDN'][0] = array('ERROR', _('Please enter a valid DN in the field:') . ' ' . _("Primary organisational unit"));
$this->messages['eduPersonPrimaryOrgUnitDN'][1] = array('ERROR', _('Account %s:') . ' eduPerson_primaryOrgUnitDN', _('This is not a valid DN!'));
$this->messages['eduPersonOrgUnitDN'][0] = array('ERROR', _('Organisational units contains an invalid entry.'));
$this->messages['eduPersonOrgUnitDN'][1] = array('ERROR', _('Account %s:') . ' eduPerson_orgUnitDN', _('This is not a valid list of DNs!'));
$this->messages['primaryAffiliation'][0] = array('ERROR', _('Account %s:') . ' eduPerson_primaryAffiliation', _('Please enter a valid primary affiliation.'));
$this->messages['scopedAffiliation'][0] = array('ERROR', _('Account %s:') . ' eduPerson_scopedAffiliation', _('Please enter a valid scoped affiliation.'));
$this->messages['affiliation'][0] = array('ERROR', _('Account %s:') . ' eduPerson_affiliation', _('Please enter a valid list of affiliations.'));
$this->messages['eduPersonPrincipalName'][0] = ['ERROR', _('Principal name is invalid!')];
$this->messages['eduPersonPrincipalName'][1] = ['ERROR', _('Account %s:') . ' eduPerson_principalName', _('Principal name is invalid!')];
$this->messages['eduPersonOrgDN'][0] = ['ERROR', _('Please enter a valid DN in the field:') . ' ' . _("Organisation")];
$this->messages['eduPersonOrgDN'][1] = ['ERROR', _('Account %s:') . ' eduPerson_orgDN', _('This is not a valid DN!')];
$this->messages['eduPersonPrimaryOrgUnitDN'][0] = ['ERROR', _('Please enter a valid DN in the field:') . ' ' . _("Primary organisational unit")];
$this->messages['eduPersonPrimaryOrgUnitDN'][1] = ['ERROR', _('Account %s:') . ' eduPerson_primaryOrgUnitDN', _('This is not a valid DN!')];
$this->messages['eduPersonOrgUnitDN'][0] = ['ERROR', _('Organisational units contains an invalid entry.')];
$this->messages['eduPersonOrgUnitDN'][1] = ['ERROR', _('Account %s:') . ' eduPerson_orgUnitDN', _('This is not a valid list of DNs!')];
$this->messages['primaryAffiliation'][0] = ['ERROR', _('Account %s:') . ' eduPerson_primaryAffiliation', _('Please enter a valid primary affiliation.')];
$this->messages['scopedAffiliation'][0] = ['ERROR', _('Account %s:') . ' eduPerson_scopedAffiliation', _('Please enter a valid scoped affiliation.')];
$this->messages['affiliation'][0] = ['ERROR', _('Account %s:') . ' eduPerson_affiliation', _('Please enter a valid list of affiliations.')];
}
/**
@ -292,7 +292,7 @@ class eduPerson extends baseModule {
// primary affiliation
$primaryAffiliation = [];
if (isset($this->attributes['eduPersonPrimaryAffiliation'][0])) {
$primaryAffiliation = array($this->attributes['eduPersonPrimaryAffiliation'][0]);
$primaryAffiliation = [$this->attributes['eduPersonPrimaryAffiliation'][0]];
}
$return->add(new htmlResponsiveSelect('primaryAffiliation', $this->affiliationTypes, $primaryAffiliation, _('Primary affiliation'), 'primaryAffiliation'), 12);
// scoped affiliations
@ -303,7 +303,7 @@ class eduPerson extends baseModule {
if (isset($this->attributes['eduPersonScopedAffiliation'][0])) {
for ($i = 0; $i < sizeof($this->attributes['eduPersonScopedAffiliation']); $i++) {
$parts = explode('@', $this->attributes['eduPersonScopedAffiliation'][$i]);
$scopedAffiliationPrefix = array($parts[0]);
$scopedAffiliationPrefix = [$parts[0]];
$scopedAffiliation = substr($this->attributes['eduPersonScopedAffiliation'][$i], strlen($parts[0]) + 1);
$scopedAffiliationContainer = new htmlTable();
$scopedAffiliationContainer->addElement(new htmlSelect('scopedAffiliationPrefix' . $i, $this->affiliationTypes, $scopedAffiliationPrefix));
@ -329,7 +329,7 @@ class eduPerson extends baseModule {
$affiliations = new htmlTable();
if (isset($this->attributes['eduPersonAffiliation'][0])) {
for ($i = 0; $i < sizeof($this->attributes['eduPersonAffiliation']); $i++) {
$affiliations->addElement(new htmlSelect('affiliation' . $i, $this->affiliationTypes, array($this->attributes['eduPersonAffiliation'][$i])));
$affiliations->addElement(new htmlSelect('affiliation' . $i, $this->affiliationTypes, [$this->attributes['eduPersonAffiliation'][$i]]));
$affiliationButton = new htmlButton('delAffiliation' . $i, 'del.svg', true);
$affiliations->addElement($affiliationButton);
if ($i === 0) {
@ -364,7 +364,7 @@ class eduPerson extends baseModule {
// remove button
$return->addVerticalSpacer('2rem');
$remButton = new htmlButton('remObjectClass', _('Remove EDU person extension'));
$remButton->setCSSClasses(array('lam-danger'));
$remButton->setCSSClasses(['lam-danger']);
$return->add($remButton, 12, 12, 12, 'text-center');
}
else {
@ -385,7 +385,7 @@ class eduPerson extends baseModule {
return [];
}
elseif (isset($_POST['remObjectClass'])) {
$this->attributes['objectClass'] = array_delete(array('eduPerson'), $this->attributes['objectClass']);
$this->attributes['objectClass'] = array_delete(['eduPerson'], $this->attributes['objectClass']);
for ($i = 0; $i < sizeof($this->meta['attributes']); $i++) {
if (isset($this->attributes[$this->meta['attributes'][$i]])) {
unset($this->attributes[$this->meta['attributes'][$i]]);
@ -474,7 +474,9 @@ class eduPerson extends baseModule {
$messages = [];
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
if (!in_array("eduPerson", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "eduPerson";
if (!in_array("eduPerson", $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = "eduPerson";
}
// principal name
if ($rawAccounts[$i][$ids['eduPerson_principalName']] != "") {
if (!preg_match('/^[0-9a-z_\\.@-]+$/i', $rawAccounts[$i][$ids['eduPerson_principalName']])) {
@ -570,7 +572,7 @@ class eduPerson extends baseModule {
* @inheritDoc
*/
public function getListAttributeDescriptions(ConfiguredType $type): array {
return array(
return [
'edupersonaffiliation' => _('Affiliations'),
'edupersonnickname' => _('Nick names'),
'edupersonorgdn' => _('Organisation'),
@ -581,7 +583,7 @@ class eduPerson extends baseModule {
'edupersonprimaryorgunitdn' => _('Primary organisational unit'),
'edupersonscopedaffiliation' => _('Scoped affiliations'),
'edupersonassurance' => _('Assurance profiles'),
);
];
}
}

View file

@ -1,4 +1,5 @@
<?php
use \LAM\PDF\PDFTable;
use \LAM\PDF\PDFTableCell;
use \LAM\PDF\PDFTableRow;
@ -8,7 +9,7 @@ use LAM\TYPES\ConfiguredType;
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2008 Thomas Manninger
2008 - 2023 Roland Gruber
2008 - 2024 Roland Gruber
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
@ -41,7 +42,6 @@ use LAM\TYPES\ConfiguredType;
*
* @package modules
*/
class fixed_ip extends baseModule {
/** fixed ips */
@ -71,7 +71,7 @@ class fixed_ip extends baseModule {
* @return boolean true if module fits
*/
public function can_manage() {
return in_array($this->get_scope(), array('dhcp'));
return in_array($this->get_scope(), ['dhcp']);
}
/**
@ -90,40 +90,40 @@ class fixed_ip extends baseModule {
// icon
$return['icon'] = 'computer.svg';
// RDN attribute
$return["RDN"] = array("cn" => "high");
$return["RDN"] = ["cn" => "high"];
// LDAP filter
$return["ldap_filter"] = [];
// module dependencies
$return['dependencies'] = array('depends' => array('dhcp_settings'), 'conflicts' => []);
$return['dependencies'] = ['depends' => ['dhcp_settings'], 'conflicts' => []];
// managed object classes
$return['objectClasses'] = [];
// managed attributes
$return['attributes'] = array('dhcpOption');
$return['attributes'] = ['dhcpOption'];
// help Entries
$return['help'] = array(
'pc' => array(
$return['help'] = [
'pc' => [
"Headline" => _("PC name"), 'attr' => 'dhcpOption, host-name',
"Text" => _("The name of the PC.")
),
'mac' => array(
],
'mac' => [
"Headline" => _("MAC address"), 'attr' => 'dhcpHWAddress',
"Text" => _("The MAC address of the PC. Example: 11:22:33:44:55:aa")
),
'ip' => array(
],
'ip' => [
"Headline" => _("IP address"), 'attr' => 'dhcpStatements, fixed-address',
"Text" => _("The IP address of the PC.")
),
'description' => array(
],
'description' => [
"Headline" => _("Description"), 'attr' => 'dhcpComments',
"Text" => _("Optional description for the PC.")
),
'active' => array(
],
'active' => [
"Headline" => _("Active"), 'attr' => 'dhcpStatements, booting',
"Text" => _("Inactive hosts will not be able to get an address from the DHCP server.")
),
);
],
];
// available PDF fields
$return['PDF_fields'] = array('IPlist' => _('IP list'));
$return['PDF_fields'] = ['IPlist' => _('IP list')];
return $return;
}
@ -131,7 +131,7 @@ class fixed_ip extends baseModule {
* This function fills the error message array with messages.
*/
public function load_Messages() {
$this->messages['errors'][0] = array('ERROR', _('One or more errors occurred. The invalid fields are marked.'), '');
$this->messages['errors'][0] = ['ERROR', _('One or more errors occurred. The invalid fields are marked.'), ''];
}
/**
@ -184,7 +184,7 @@ class fixed_ip extends baseModule {
$invalid = true;
}
foreach($ex AS $value) {
foreach ($ex as $value) {
if (!preg_match("/[0-9a-fA-F][0-9a-fA-F]/", $value) || strlen($value) != "2") {
$invalid = true;
}
@ -204,7 +204,7 @@ class fixed_ip extends baseModule {
// Only run it, when ranges already exists:
if (is_array($this->fixed_ip)) {
$ex_subnet = explode(".", $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]);
foreach ($this->fixed_ip AS $id=>$arr) {
foreach ($this->fixed_ip as $id => $arr) {
if (!empty($this->fixed_ip[$id]['ip']) && !range::check_subnet_range($this->fixed_ip[$id]['ip'],
$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0],
$this->getAccountContainer()->getAccountModule('dhcp_settings')->getDHCPOption('subnet-mask'))) {
@ -228,7 +228,7 @@ class fixed_ip extends baseModule {
*/
function load_attributes($attr) {
if (!$this->isRootNode()) {
$searchAttributes = array('cn', 'dhcphwaddress', 'dhcpstatements', 'dhcpcomments');
$searchAttributes = ['cn', 'dhcphwaddress', 'dhcpstatements', 'dhcpcomments'];
$entries = searchLDAP($this->getAccountContainer()->dn_orig, '(objectClass=dhcpHost)', $searchAttributes);
for ($i = 0; $i < sizeof($entries); $i++) {
$dhcphwaddress = explode(" ", $entries[$i]['dhcphwaddress'][0]);
@ -298,7 +298,7 @@ class fixed_ip extends baseModule {
$error = false; // errors by process_attributes()?
$pcs = [];
foreach($this->fixed_ip AS $id=>$arr) {
foreach ($this->fixed_ip as $id => $arr) {
// Check if ip is to drop
if (isset($_POST['drop_ip_' . $id])) {
@ -382,14 +382,14 @@ class fixed_ip extends baseModule {
$dhcpstatements = [];
$this->setActive($dhcpstatements, $active);
$this->setIP($dhcpstatements, $_POST['ip_add']);
$this->fixed_ip[] = array(
$this->fixed_ip[] = [
'cn' => $_POST['pc_add'],
'mac' => $_POST['mac_add'],
'description' => $_POST['description_add'],
'ip' => $_POST['ip_add'],
'dhcpstatements' => $dhcpstatements,
'active' => $active,
);
];
$this->orderByIP();
}
@ -418,7 +418,7 @@ class fixed_ip extends baseModule {
}
$autoNames = array_values(array_unique($autoNames));
}
$titles = array(_('IP address'), _('PC name'), _('MAC address'), _('Description'), _('Active'), ' ');
$titles = [_('IP address'), _('PC name'), _('MAC address'), _('Description'), _('Active'), ' '];
$data = [];
// Reset oberlaped ips
$this->reset_overlapped_ip();
@ -429,7 +429,7 @@ class fixed_ip extends baseModule {
}
$pcs = [];
$messages = [];
foreach($this->fixed_ip AS $id => $arr) {
foreach ($this->fixed_ip as $id => $arr) {
// pc name
$existsInDifferentDn = false;
if (!empty($_POST['pc_' . $id])) {
@ -506,7 +506,7 @@ class fixed_ip extends baseModule {
$data[] = $newEntry;
$table = new htmlResponsiveTable($titles, $data);
$table->setWidths(array('20%', '20%', '20%', '25%', '10%', '5%'));
$table->setWidths(['20%', '20%', '20%', '25%', '10%', '5%']);
$table->colspan = 100;
$return->add($table, 12);
@ -535,7 +535,7 @@ class fixed_ip extends baseModule {
if ($name === $host['name']) {
$dn = $host['dn'];
if ($this->getAccountContainer()->isNewAccount || strpos($dn, $this->getAccountContainer()->dn_orig) === false) {
return array($dn, $this->getHostNameSuggestion($name));
return [$dn, $this->getHostNameSuggestion($name)];
}
}
}
@ -622,14 +622,14 @@ class fixed_ip extends baseModule {
$dhcpstatements = [];
$this->setActive($dhcpstatements, true);
$this->setIP($dhcpstatements, $val[1]);
$this->fixed_ip[] = array(
$this->fixed_ip[] = [
'cn' => $val[0],
'mac' => $val[2],
'description' => '',
'ip' => $val[1],
'dhcpstatements' => $dhcpstatements,
'active' => true,
);
];
$this->orderByIP();
}
return $errors;
@ -654,11 +654,11 @@ class fixed_ip extends baseModule {
/**
* This function is overwritten because the fixed IPs are set after the ldap_add command.
*
* @see baseModule::postModifyActions()
*
* @param boolean $newAccount
* @param array $attributes LDAP attributes of this entry
* @return array array which contains status messages. Each entry is an array containing the status message parameters.
* @see baseModule::postModifyActions()
*
*/
public function postModifyActions($newAccount, $attributes) {
if (!$this->isRootNode()) {
@ -667,10 +667,10 @@ class fixed_ip extends baseModule {
$mod = []; // DN => array(attr => values)
$delete = [];
// Which dns are to delete and to add
foreach($this->orig_ips AS $id => $arr) {
foreach ($this->orig_ips as $id => $arr) {
// Exist cn still?
$in_arr = false;
foreach($this->fixed_ip AS $idB => $arr) {
foreach ($this->fixed_ip as $idB => $arr) {
if ($this->orig_ips[$id]['cn'] == $this->fixed_ip[$idB]['cn']) {
$in_arr = true;
// check if IP changed
@ -685,7 +685,7 @@ class fixed_ip extends baseModule {
}
// check if MAC changed
if ($this->orig_ips[$id]['mac'] != $this->fixed_ip[$idB]['mac']) {
$mod['cn=' . $this->orig_ips[$id]['cn'] . $ldapSuffix]['dhcpHWAddress'] = array('ethernet ' . $this->fixed_ip[$idB]['mac']);
$mod['cn=' . $this->orig_ips[$id]['cn'] . $ldapSuffix]['dhcpHWAddress'] = ['ethernet ' . $this->fixed_ip[$idB]['mac']];
}
// check if description changed
if ($this->orig_ips[$id]['description'] != $this->fixed_ip[$idB]['description']) {
@ -703,9 +703,9 @@ class fixed_ip extends baseModule {
$this->fixed_ip = [];
}
// Which entries are new:
foreach($this->fixed_ip AS $id => $arr) {
foreach ($this->fixed_ip as $id => $arr) {
$in_arr = false;
foreach($this->orig_ips AS $idB => $arr) {
foreach ($this->orig_ips as $idB => $arr) {
if ($this->orig_ips[$idB]['cn'] == $this->fixed_ip[$id]['cn']) {
$in_arr = true;
}
@ -715,11 +715,11 @@ class fixed_ip extends baseModule {
}
}
foreach($delete AS $cn) {
foreach ($delete as $cn) {
ldap_delete($_SESSION['ldap']->server(), 'cn=' . $cn . $ldapSuffix);
}
foreach($add AS $id => $arr) {
foreach ($add as $id => $arr) {
$attr = [];
$attr['cn'] = $add[$id]['cn'];
$attr['objectClass'][0] = 'top';
@ -868,9 +868,9 @@ class fixed_ip extends baseModule {
if ($this->hostCache != null) {
return;
}
$attrs = array('cn', 'iphostnumber', 'macaddress');
$attrs = ['cn', 'iphostnumber', 'macaddress'];
$this->hostCache = [];
$result = searchLDAPByAttribute('cn', '*', null, $attrs, array('host'));
$result = searchLDAPByAttribute('cn', '*', null, $attrs, ['host']);
foreach ($result as $attributes) {
$this->hostCache[] = $attributes;
}
@ -893,13 +893,13 @@ class fixed_ip extends baseModule {
if ($this->existingDhcpHostsCache != null) {
return $this->existingDhcpHostsCache;
}
$entries = searchLDAPByAttribute('cn', '*', 'dhcpHost', array('cn'), array('dhcp'));
$entries = searchLDAPByAttribute('cn', '*', 'dhcpHost', ['cn'], ['dhcp']);
$this->existingDhcpHostsCache = [];
foreach ($entries as $entry) {
$this->existingDhcpHostsCache[] = array(
$this->existingDhcpHostsCache[] = [
'dn' => $entry['dn'],
'name' => $entry['cn'][0]
);
];
}
}
@ -907,9 +907,9 @@ class fixed_ip extends baseModule {
* @inheritDoc
*/
public function getListAttributeDescriptions(ConfiguredType $type): array {
return array(
return [
"fixed_ips" => _("IP address") . ' / ' . _('MAC address') . ' / ' . _("Description")
);
];
}
/**
@ -919,7 +919,7 @@ class fixed_ip extends baseModule {
if ($attributeName === 'fixed_ips') {
return function(array $entry, string $attribute): ?htmlElement {
// find all fixed addresses:
$entries = searchLDAP($entry['dn'], 'objectClass=dhcpHost', array('dhcpstatements', 'dhcphwaddress', 'cn'));
$entries = searchLDAP($entry['dn'], 'objectClass=dhcpHost', ['dhcpstatements', 'dhcphwaddress', 'cn']);
if (sizeof($entries) > 0) {
// sort by IP
$order = [];
@ -936,7 +936,7 @@ class fixed_ip extends baseModule {
if (isset($entries[$i]['dhcpstatements'][0])) {
$dhcpstatements = $entries[$i]['dhcpstatements'];
}
$cssClasses = array('nowrap');
$cssClasses = ['nowrap'];
if (!fixed_ip::isActive($dhcpstatements)) {
$cssClasses[] = 'strike-through';
}

View file

@ -38,12 +38,12 @@ class freeRadius extends baseModule {
/**
* These attributes will be ignored by default if a new account is copied from an existing one.
*/
const ATTRIBUTES_TO_IGNORE_ON_COPY = array('radiusFramedIPAddress');
const ATTRIBUTES_TO_IGNORE_ON_COPY = ['radiusFramedIPAddress'];
/** list of possible months */
private static $monthList = array('01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May',
private static $monthList = ['01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May',
'06' => 'Jun', '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'
);
];
/** cache for profile DNs */
private $profileCache;
@ -65,7 +65,7 @@ class freeRadius extends baseModule {
* @return boolean true if module fits
*/
public function can_manage() {
return in_array($this->get_scope(), array('user'));
return in_array($this->get_scope(), ['user']);
}
/**
@ -82,81 +82,81 @@ class freeRadius extends baseModule {
// alias name
$return["alias"] = _("FreeRadius");
// module dependencies
$return['dependencies'] = array('depends' => array(array('posixAccount', 'inetOrgPerson')), 'conflicts' => []);
$return['dependencies'] = ['depends' => [['posixAccount', 'inetOrgPerson']], 'conflicts' => []];
// managed object classes
$return['objectClasses'] = array('radiusprofile');
$return['objectClasses'] = ['radiusprofile'];
// managed attributes
$return['attributes'] = array('radiusFramedIPAddress', 'radiusFramedIPNetmask', 'radiusRealm', 'radiusGroupName',
'radiusExpiration', 'radiusIdleTimeout', 'dialupAccess', 'radiusProfileDn');
$return['attributes'] = ['radiusFramedIPAddress', 'radiusFramedIPNetmask', 'radiusRealm', 'radiusGroupName',
'radiusExpiration', 'radiusIdleTimeout', 'dialupAccess', 'radiusProfileDn'];
// help Entries
$return['help'] = array(
'radiusFramedIPAddress' => array(
$return['help'] = [
'radiusFramedIPAddress' => [
"Headline" => _("IP address"), 'attr' => 'radiusFramedIPAddress',
"Text" => _("This is the IP address for the user (e.g. 123.123.123.123).")
),
'radiusFramedIPNetmask' => array(
],
'radiusFramedIPNetmask' => [
"Headline" => _("Net mask"), 'attr' => 'radiusFramedIPNetmask',
"Text" => _("The net mask for the IP address.")
),
'radiusRealm' => array(
],
'radiusRealm' => [
"Headline" => _("Realm"), 'attr' => 'radiusRealm',
"Text" => _("The Radius realm of this account.")
),
'radiusGroupName' => array(
],
'radiusGroupName' => [
"Headline" => _("Group names"), 'attr' => 'radiusGroupName',
"Text" => _("The group names for this account.")
),
'radiusGroupNameList' => array(
],
'radiusGroupNameList' => [
"Headline" => _("Group names"), 'attr' => 'radiusGroupName',
"Text" => _("The group names for this account.") . ' ' . _("Multiple values are separated by semicolon.")
),
'radiusExpiration' => array(
],
'radiusExpiration' => [
"Headline" => _("Expiration date"), 'attr' => 'radiusExpiration',
"Text" => _("The account will be locked after this date.")
),
'radiusIdleTimeout' => array(
],
'radiusIdleTimeout' => [
"Headline" => _("Idle timeout"), 'attr' => 'radiusIdleTimeout',
"Text" => _("Specifies the maximum number of seconds that a connection can be idle before the session is terminated.")
),
'dialupAccess' => array(
],
'dialupAccess' => [
"Headline" => _("Enabled"), 'attr' => 'dialupAccess',
"Text" => _("Specifies if the user may authenticate with FreeRadius.")
),
'profileDN' => array(
],
'profileDN' => [
"Headline" => _("Profile DN"), 'attr' => 'radiusProfileDn',
"Text" => _('DN where Radius profile templates are stored.')
),
'radiusProfileDn' => array(
],
'radiusProfileDn' => [
"Headline" => _("Profile"), 'attr' => 'radiusProfileDn',
"Text" => _('Radius profile for this user.')
),
'hiddenOptions' => array(
],
'hiddenOptions' => [
"Headline" => _("Hidden options"),
"Text" => _("The selected options will not be managed inside LAM. You can use this to reduce the number of displayed input fields.")
),
'autoAdd' => array(
],
'autoAdd' => [
"Headline" => _("Automatically add this extension"),
"Text" => _("This will enable the extension automatically if this profile is loaded.")
),
);
],
];
// profile settings
$profileElements = [];
// auto add extension
$profileElements[] = new htmlResponsiveInputCheckbox('freeRadius_addExt', false, _('Automatically add this extension'), 'autoAdd');
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusFramedIPNetmask')) {
$profileElements[] = new htmlResponsiveInputField(_('Net mask'), 'freeRadius_radiusFramedIPNetmask', null, 'radiusFramedIPNetmask');
$return['profile_checks']['freeRadius_radiusFramedIPNetmask'] = array(
$return['profile_checks']['freeRadius_radiusFramedIPNetmask'] = [
'type' => 'ext_preg',
'regex' => 'ip',
'error_message' => $this->messages['radiusFramedIPNetmask'][0]);
'error_message' => $this->messages['radiusFramedIPNetmask'][0]];
$return['profile_mappings']['freeRadius_radiusFramedIPNetmask'] = 'radiusFramedIPNetmask';
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusRealm')) {
$profileElements[] = new htmlResponsiveInputField(_('Realm'), 'freeRadius_radiusRealm', null, 'radiusRealm');
$return['profile_checks']['freeRadius_radiusRealm'] = array(
$return['profile_checks']['freeRadius_radiusRealm'] = [
'type' => 'ext_preg',
'regex' => 'DNSname',
'error_message' => $this->messages['radiusRealm'][0]);
'error_message' => $this->messages['radiusRealm'][0]];
$return['profile_mappings']['freeRadius_radiusRealm'] = 'radiusRealm';
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusGroupName')) {
@ -164,25 +164,25 @@ class freeRadius extends baseModule {
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusIdleTimeout')) {
$profileElements[] = new htmlResponsiveInputField(_('Idle timeout'), 'freeRadius_radiusIdleTimeout', null, 'radiusIdleTimeout');
$return['profile_checks']['freeRadius_radiusIdleTimeout'] = array(
$return['profile_checks']['freeRadius_radiusIdleTimeout'] = [
'type' => 'ext_preg',
'regex' => 'digit',
'error_message' => $this->messages['radiusIdleTimeout'][0]);
'error_message' => $this->messages['radiusIdleTimeout'][0]];
$return['profile_mappings']['freeRadius_radiusIdleTimeout'] = 'radiusIdleTimeout';
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideDialupAccess')) {
$enabledOptions = array('-' => '', _('Yes') => 'true', _('No') => 'false');
$dialupAccessSelect = new htmlResponsiveSelect('freeRadius_dialupAccess', $enabledOptions, array('true'), _('Enabled'), 'dialupAccess');
$enabledOptions = ['-' => '', _('Yes') => 'true', _('No') => 'false'];
$dialupAccessSelect = new htmlResponsiveSelect('freeRadius_dialupAccess', $enabledOptions, ['true'], _('Enabled'), 'dialupAccess');
$dialupAccessSelect->setHasDescriptiveElements(true);
$profileElements[] = $dialupAccessSelect;
$return['profile_mappings']['freeRadius_dialupAccess'] = 'dialupAccess';
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusProfileDn') && isLoggedIn()) {
$profileOptions = array('-' => '');
$profileOptions = ['-' => ''];
foreach ($this->getProfiles() as $dn) {
$profileOptions[getAbstractDN($dn)] = $dn;
}
$profileSelect = new htmlResponsiveSelect('freeRadius_radiusProfileDn', $profileOptions, array(''), _('Profile'), 'radiusProfileDn');
$profileSelect = new htmlResponsiveSelect('freeRadius_radiusProfileDn', $profileOptions, [''], _('Profile'), 'radiusProfileDn');
$profileSelect->setHasDescriptiveElements(true);
$profileElements[] = $profileSelect;
$return['profile_mappings']['freeRadius_radiusProfileDn'] = 'radiusProfileDn';
@ -195,69 +195,69 @@ class freeRadius extends baseModule {
// upload fields
$return['upload_columns'] = [];
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusRealm')) {
$return['upload_columns'][] = array(
$return['upload_columns'][] = [
'name' => 'freeRadius_radiusRealm',
'description' => _('Realm'),
'help' => 'radiusRealm',
'example' => _('company.com')
);
];
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusGroupName')) {
$return['upload_columns'][] = array(
$return['upload_columns'][] = [
'name' => 'freeRadius_radiusGroupName',
'description' => _('Group names'),
'help' => 'radiusGroupNameList',
'example' => _('group01;group02')
);
];
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusFramedIPAddress')) {
$return['upload_columns'][] = array(
$return['upload_columns'][] = [
'name' => 'freeRadius_radiusFramedIPAddress',
'description' => _('IP address'),
'help' => 'radiusFramedIPAddress',
'example' => '123.123.123.123',
);
];
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusFramedIPNetmask')) {
$return['upload_columns'][] = array(
$return['upload_columns'][] = [
'name' => 'freeRadius_radiusFramedIPNetmask',
'description' => _('Net mask'),
'help' => 'radiusFramedIPNetmask',
'example' => '255.255.255.0'
);
];
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusExpiration')) {
$return['upload_columns'][] = array(
$return['upload_columns'][] = [
'name' => 'freeRadius_radiusExpiration',
'description' => _('Expiration date'),
'help' => 'radiusExpiration',
'example' => '2035-11-22 00:00'
);
];
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusIdleTimeout')) {
$return['upload_columns'][] = array(
$return['upload_columns'][] = [
'name' => 'freeRadius_radiusIdleTimeout',
'description' => _('Idle timeout'),
'help' => 'radiusIdleTimeout',
'example' => '3600'
);
];
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideDialupAccess')) {
$return['upload_columns'][] = array(
$return['upload_columns'][] = [
'name' => 'freeRadius_dialupAccess',
'description' => _('Enabled'),
'help' => 'dialupAccess',
'example' => 'true',
'values' => 'true, false'
);
];
}
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusProfileDn')) {
$return['upload_columns'][] = array(
$return['upload_columns'][] = [
'name' => 'freeRadius_radiusProfileDn',
'description' => _('Profile'),
'help' => 'radiusProfileDn',
'example' => 'cn=profile,ou=radiusProfile,dc=example,dc=com'
);
];
}
// available PDF fields
$return['PDF_fields'] = [];
@ -326,20 +326,20 @@ class freeRadius extends baseModule {
* This function fills the error message array with messages
*/
function load_Messages() {
$this->messages['radiusFramedIPAddress'][0] = array('ERROR', _('The IP address is invalid.'));
$this->messages['radiusFramedIPAddress'][1] = array('ERROR', _('Account %s:') . ' freeRadius_radiusFramedIPAddress', _('The IP address is invalid.'));
$this->messages['radiusFramedIPNetmask'][0] = array('ERROR', _('The net mask is invalid.'));
$this->messages['radiusFramedIPNetmask'][1] = array('ERROR', _('Account %s:') . ' freeRadius_radiusFramedIPNetmask', _('The net mask is invalid.'));
$this->messages['radiusRealm'][0] = array('ERROR', _('Please enter a valid realm.'));
$this->messages['radiusRealm'][1] = array('ERROR', _('Account %s:') . ' freeRadius_radiusRealm', _('Please enter a valid realm.'));
$this->messages['radiusGroupName'][0] = array('ERROR', _('Please enter a valid list of group names.'));
$this->messages['radiusGroupName'][1] = array('ERROR', _('Account %s:') . ' freeRadius_radiusGroupName', _('Please enter a valid list of group names.'));
$this->messages['radiusExpiration'][0] = array('ERROR', _('The expiration date must be in format DD.MM.YYYY HH:MM.'));
$this->messages['radiusExpiration'][1] = array('ERROR', _('Account %s:') . ' freeRadius_radiusExpiration', _('The expiration date must be in format DD.MM.YYYY HH:MM.'));
$this->messages['radiusIdleTimeout'][0] = array('ERROR', _('Please enter a numeric value for the idle timeout.'));
$this->messages['radiusIdleTimeout'][1] = array('ERROR', _('Account %s:') . ' freeRadius_radiusIdleTimeout', _('Please enter a numeric value for the idle timeout.'));
$this->messages['dialupAccess'][0] = array('ERROR', _('Account %s:') . ' freeRadius_dialupAccess', _('This value can only be "true" or "false".'));
$this->messages['radiusProfileDn'][0] = array('ERROR', _('Account %s:') . ' freeRadius_radiusProfileDn', _('This is not a valid DN!'));
$this->messages['radiusFramedIPAddress'][0] = ['ERROR', _('The IP address is invalid.')];
$this->messages['radiusFramedIPAddress'][1] = ['ERROR', _('Account %s:') . ' freeRadius_radiusFramedIPAddress', _('The IP address is invalid.')];
$this->messages['radiusFramedIPNetmask'][0] = ['ERROR', _('The net mask is invalid.')];
$this->messages['radiusFramedIPNetmask'][1] = ['ERROR', _('Account %s:') . ' freeRadius_radiusFramedIPNetmask', _('The net mask is invalid.')];
$this->messages['radiusRealm'][0] = ['ERROR', _('Please enter a valid realm.')];
$this->messages['radiusRealm'][1] = ['ERROR', _('Account %s:') . ' freeRadius_radiusRealm', _('Please enter a valid realm.')];
$this->messages['radiusGroupName'][0] = ['ERROR', _('Please enter a valid list of group names.')];
$this->messages['radiusGroupName'][1] = ['ERROR', _('Account %s:') . ' freeRadius_radiusGroupName', _('Please enter a valid list of group names.')];
$this->messages['radiusExpiration'][0] = ['ERROR', _('The expiration date must be in format DD.MM.YYYY HH:MM.')];
$this->messages['radiusExpiration'][1] = ['ERROR', _('Account %s:') . ' freeRadius_radiusExpiration', _('The expiration date must be in format DD.MM.YYYY HH:MM.')];
$this->messages['radiusIdleTimeout'][0] = ['ERROR', _('Please enter a numeric value for the idle timeout.')];
$this->messages['radiusIdleTimeout'][1] = ['ERROR', _('Account %s:') . ' freeRadius_radiusIdleTimeout', _('Please enter a numeric value for the idle timeout.')];
$this->messages['dialupAccess'][0] = ['ERROR', _('Account %s:') . ' freeRadius_dialupAccess', _('This value can only be "true" or "false".')];
$this->messages['radiusProfileDn'][0] = ['ERROR', _('Account %s:') . ' freeRadius_radiusProfileDn', _('This is not a valid DN!')];
}
/**
@ -394,7 +394,7 @@ class freeRadius extends baseModule {
}
// profile DN
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusProfileDn')) {
$profiles = array('-' => '-');
$profiles = ['-' => '-'];
foreach ($this->getProfiles() as $dn) {
$profiles[getAbstractDN($dn)] = $dn;
}
@ -411,15 +411,15 @@ class freeRadius extends baseModule {
}
// enabled
if (!$this->isBooleanConfigOptionSet('freeRadius_hideDialupAccess')) {
$enabled = array('');
$enabled = [''];
if (!empty($this->attributes['dialupAccess'][0])) {
$enabled = array($this->attributes['dialupAccess'][0]);
$enabled = [$this->attributes['dialupAccess'][0]];
// value in LDAP may be anything other than "false" to count as "true"
if (!in_array($this->attributes['dialupAccess'][0], array('true', 'false', 'TRUE', 'FALSE'))) {
$enabled = array('true');
if (!in_array($this->attributes['dialupAccess'][0], ['true', 'false', 'TRUE', 'FALSE'])) {
$enabled = ['true'];
}
}
$enabledOptions = array('-' => '', _('Yes') => 'true', _('No') => 'false');
$enabledOptions = ['-' => '', _('Yes') => 'true', _('No') => 'false'];
$enabledSelect = new htmlResponsiveSelect('dialupAccess', $enabledOptions, $enabled, _('Enabled'), 'dialupAccess');
$enabledSelect->setHasDescriptiveElements(true);
$return->add($enabledSelect, 12);
@ -427,7 +427,7 @@ class freeRadius extends baseModule {
// button to remove extension
$return->addVerticalSpacer('2rem');
$remButton = new htmlButton('remObjectClass', _('Remove FreeRadius extension'));
$remButton->setCSSClasses(array('lam-danger'));
$remButton->setCSSClasses(['lam-danger']);
$return->add($remButton, 12, 12, 12, 'text-center');
}
else {
@ -448,7 +448,7 @@ class freeRadius extends baseModule {
return [];
}
elseif (isset($_POST['remObjectClass'])) {
$this->attributes['objectClass'] = array_delete(array('radiusprofile'), $this->attributes['objectClass']);
$this->attributes['objectClass'] = array_delete(['radiusprofile'], $this->attributes['objectClass']);
for ($i = 0; $i < sizeof($this->meta['attributes']); $i++) {
if (isset($this->attributes[$this->meta['attributes'][$i]])) {
unset($this->attributes[$this->meta['attributes'][$i]]);
@ -525,7 +525,6 @@ class freeRadius extends baseModule {
function display_html_expiration() {
$return = new htmlResponsiveRow();
$attr = 'radiusExpiration';
// TODO display in local time
$date = new DateTime('@' . (time() + 3600 * 24 * 365), getTimeZone());
if (!empty($this->attributes[$attr][0])) {
$date = DateTime::createFromFormat('d M Y H:i', $this->attributes[$attr][0], new DateTimeZone('UTC'));
@ -616,7 +615,9 @@ class freeRadius extends baseModule {
$errors = [];
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
if (!in_array("radiusprofile", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "radiusprofile";
if (!in_array("radiusprofile", $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = "radiusprofile";
}
// IP address
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'freeRadius_radiusFramedIPAddress', 'radiusFramedIPAddress',
'ip', $this->messages['radiusFramedIPAddress'][1], $errors);
@ -637,7 +638,7 @@ class freeRadius extends baseModule {
}
else {
$errMsg = $this->messages['radiusExpiration'][1];
array_push($errMsg, array($i));
array_push($errMsg, [$i]);
$errors[] = $errMsg;
}
}
@ -646,12 +647,12 @@ class freeRadius extends baseModule {
'digit', $this->messages['radiusIdleTimeout'][1], $errors);
// enabled
if (!empty($rawAccounts[$i][$ids['freeRadius_dialupAccess']])) {
if (in_array($rawAccounts[$i][$ids['freeRadius_dialupAccess']], array('true', 'false'))) {
if (in_array($rawAccounts[$i][$ids['freeRadius_dialupAccess']], ['true', 'false'])) {
$partialAccounts[$i]['dialupAccess'] = $rawAccounts[$i][$ids['freeRadius_dialupAccess']];
}
else {
$errMsg = $this->messages['dialupAccess'][0];
array_push($errMsg, array($i));
array_push($errMsg, [$i]);
$errors[] = $errMsg;
}
}
@ -678,7 +679,7 @@ class freeRadius extends baseModule {
}
if (isset($this->attributes['dialupAccess'][0])) {
$enabled = _('Yes');
if (in_array($this->attributes['dialupAccess'][0], array('false', 'FALSE'))) {
if (in_array($this->attributes['dialupAccess'][0], ['false', 'FALSE'])) {
$enabled = _('No');
}
$this->addPDFKeyValue($return, 'dialupAccess', _('Enabled'), $enabled);
@ -754,7 +755,7 @@ class freeRadius extends baseModule {
if (empty($this->moduleSettings['freeRadius_profileDN'][0])) {
return [];
}
$list = searchLDAP($this->moduleSettings['freeRadius_profileDN'][0], '(objectClass=radiusProfile)', array('dn'));
$list = searchLDAP($this->moduleSettings['freeRadius_profileDN'][0], '(objectClass=radiusProfile)', ['dn']);
if (empty($list)) {
return [];
}
@ -772,17 +773,17 @@ class freeRadius extends baseModule {
* @return array list of jobs
*/
public function getSupportedJobs(&$config) {
return array(
return [
new FreeRadiusAccountExpirationCleanupJob(),
new FreeRadiusAccountExpirationNotifyJob()
);
];
}
/**
* @inheritDoc
*/
public function getListAttributeDescriptions(ConfiguredType $type): array {
return array(
return [
'radiusframedipaddress' => _('IP address'),
'radiusframedipnetmask' => _('Net mask'),
'radiusrealm' => _('Realm'),
@ -791,7 +792,7 @@ class freeRadius extends baseModule {
'radiusidletimeout' => _('Idle timeout'),
'dialupaccess' => _('Enabled'),
'radiusprofiledn' => _('Profile'),
);
];
}
}
@ -834,8 +835,8 @@ if (interface_exists('\LAM\JOB\Job', false)) {
*/
protected function findUsers($jobID, $options) {
// read users
$attrs = array('radiusExpiration');
return searchLDAPByFilter('(radiusExpiration=*)', $attrs, array('user'));
$attrs = ['radiusExpiration'];
return searchLDAPByFilter('(radiusExpiration=*)', $attrs, ['user']);
}
/**
@ -898,10 +899,10 @@ if (interface_exists('\LAM\JOB\Job', false)) {
*/
protected function findUsers($jobID, $options) {
// read users
$sysattrs = array('radiusExpiration', $_SESSION['cfgMain']->getMailAttribute());
$sysattrs = ['radiusExpiration', $_SESSION['cfgMain']->getMailAttribute()];
$attrs = $this->getAttrWildcards($jobID, $options);
$attrs = array_values(array_unique(array_merge($attrs, $sysattrs)));
return searchLDAPByFilter('(&(radiusExpiration=*)(' . $_SESSION['cfgMain']->getMailAttribute() . '=*))', $attrs, array('user'));
return searchLDAPByFilter('(&(radiusExpiration=*)(' . $_SESSION['cfgMain']->getMailAttribute() . '=*))', $attrs, ['user']);
}
/**

View file

@ -2,7 +2,7 @@
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2011 - 2022 Roland Gruber
Copyright (C) 2011 - 2024 Roland Gruber
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
@ -59,12 +59,12 @@ class generalInformation extends baseModule {
// alias name
$return["alias"] = _("General information");
// module dependencies
$return['dependencies'] = array('depends' => [], 'conflicts' => []);
$return['dependencies'] = ['depends' => [], 'conflicts' => []];
// managed attributes
$return['attributes'] = array('creatorsname', 'createtimestamp', 'modifiersname',
'modifytimestamp', 'hassubordinates', 'memberof');
$return['hiddenAttributes'] = array('creatorsname', 'createtimestamp', 'modifiersname',
'modifytimestamp', 'hassubordinates');
$return['attributes'] = ['creatorsname', 'createtimestamp', 'modifiersname',
'modifytimestamp', 'hassubordinates', 'memberof'];
$return['hiddenAttributes'] = ['creatorsname', 'createtimestamp', 'modifiersname',
'modifytimestamp', 'hassubordinates'];
return $return;
}
@ -112,7 +112,7 @@ class generalInformation extends baseModule {
// group memberships
if (isset($this->attributes['memberof'][0])) {
$typeManager = new TypeManager();
$scopes = array('gon', 'group');
$scopes = ['gon', 'group'];
$types = $typeManager->getConfiguredTypesForScopes($scopes);
$suffixList = [];
foreach ($types as $type) {
@ -166,14 +166,14 @@ class generalInformation extends baseModule {
* @inheritDoc
*/
public function getListAttributeDescriptions(ConfiguredType $type): array {
return array(
return [
'creatorsname' => _('Created by'),
'createtimestamp' => _('Creation time'),
'modifiersname' => _('Modified by'),
'modifytimestamp' => _('Modification time'),
'hassubordinates' => _('Has subentries'),
'memberof' => _('Groups')
);
];
}
}