diff --git a/lam/lib/modules/eduPerson.inc b/lam/lib/modules/eduPerson.inc
index 0e5b23ac2..5cb16587a 100644
--- a/lam/lib/modules/eduPerson.inc
+++ b/lam/lib/modules/eduPerson.inc
@@ -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
@@ -20,56 +20,56 @@
*/
/**
-* Manages the eduPerson extension for user accounts.
-*
-* @package modules
-* @author Roland Gruber
-*/
+ * Manages the eduPerson extension for user accounts.
+ *
+ * @package modules
+ * @author Roland Gruber
+ */
use LAM\TYPES\ConfiguredType;
/**
-* Manages the eduPerson extension for user accounts.
-*
-* @package modules
-*/
+ * Manages the eduPerson extension for user accounts.
+ *
+ * @package modules
+ */
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.
- *
- * @param string $scope account type (user, group, host)
- */
+ * Creates a new eduPerson object.
+ *
+ * @param string $scope account type (user, group, host)
+ */
function __construct($scope) {
parent::__construct($scope);
$this->autoAddObjectClasses = false;
}
/**
- * Returns true if this module can manage accounts of the current type, otherwise false.
- *
- * @return boolean true if module fits
- */
+ * Returns true if this module can manage accounts of the current type, otherwise false.
+ *
+ * @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']);
}
/**
- * Returns meta data that is interpreted by parent class
- *
- * @return array array with meta data
- *
- * @see baseModule::get_metaData()
- */
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ *
+ * @see baseModule::get_metaData()
+ */
function get_metaData() {
$return = [];
// icon
@@ -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',
- 'eduPersonOrgDN', 'eduPersonOrgUnitDN',
- 'eduPersonPrimaryAffiliation', 'eduPersonPrincipalName',
- 'eduPersonEntitlement', 'eduPersonPrimaryOrgUnitDN',
- 'eduPersonScopedAffiliation', 'eduPersonAssurance');
+ $return['attributes'] = ['eduPersonAffiliation', 'eduPersonNickname',
+ 'eduPersonOrgDN', 'eduPersonOrgUnitDN',
+ 'eduPersonPrimaryAffiliation', 'eduPersonPrincipalName',
+ 'eduPersonEntitlement', 'eduPersonPrimaryOrgUnitDN',
+ '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(
+ _('Multiple values are separated by comma.')
+ ],
+ '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(
+ _('Multiple values are separated by comma.')
+ ],
+ '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,40 +238,40 @@ class eduPerson extends baseModule {
'primaryOrgUnitDN' => _('Primary organisational unit'),
'scopedAffiliation' => _('Scoped affiliations'),
'eduPersonAssurance' => _('Assurance profiles'),
- );
+ ];
return $return;
}
/**
- * This function fills the error message array with messages
- */
+ * 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.')];
}
/**
* {@inheritDoc}
*/
- public function loadAttributesFromAccountCopy(array $ldapAttributes, array $attributesToIgnore = []) : void {
+ public function loadAttributesFromAccountCopy(array $ldapAttributes, array $attributesToIgnore = []): void {
$attributesToIgnore = array_merge(baseModule::ATTRIBUTES_TO_IGNORE_ON_COPY_DEFAULT, self::ATTRIBUTES_TO_IGNORE_ON_COPY);
parent::loadAttributesFromAccountCopy($ldapAttributes, $attributesToIgnore);
}
/**
- * This functions return true if all needed settings are done.
- *
- * @return boolean true, if all is ok
- */
+ * This functions return true if all needed settings are done.
+ *
+ * @return boolean true, if all is ok
+ */
function module_complete() {
if (($this->getAccountContainer()->rdn == 'eduPersonPrincipalName') && !isset($this->attributes['eduPersonPrincipalName'][0])) {
return false;
@@ -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 {
@@ -374,18 +374,18 @@ class eduPerson extends baseModule {
}
/**
- * Processes user input of the primary module page.
- * It checks if all input values are correct and updates the associated LDAP attributes.
- *
- * @return array list of info/error messages
- */
+ * Processes user input of the primary module page.
+ * It checks if all input values are correct and updates the associated LDAP attributes.
+ *
+ * @return array list of info/error messages
+ */
function process_attributes() {
if (isset($_POST['addObjectClass'])) {
$this->attributes['objectClass'][] = 'eduPerson';
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]]);
@@ -452,10 +452,10 @@ class eduPerson extends baseModule {
}
/**
- * Loads the values of an account profile into internal variables.
- *
- * @param array $profile hash array with profile values (identifier => value)
- */
+ * Loads the values of an account profile into internal variables.
+ *
+ * @param array $profile hash array with profile values (identifier => value)
+ */
function load_profile($profile) {
parent::load_profile($profile);
// add extension
@@ -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'),
- );
+ ];
}
}
diff --git a/lam/lib/modules/fixed_ip.inc b/lam/lib/modules/fixed_ip.inc
index 836013b3c..ccb131fd5 100644
--- a/lam/lib/modules/fixed_ip.inc
+++ b/lam/lib/modules/fixed_ip.inc
@@ -1,4 +1,5 @@
get_scope(), array('dhcp'));
+ return in_array($this->get_scope(), ['dhcp']);
}
/**
- * Returns meta data that is interpreted by parent class
- *
- * @return array array with meta data
- *
- * @see baseModule::get_metaData()
- */
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ *
+ * @see baseModule::get_metaData()
+ */
public function get_metaData() {
$return = [];
// alias name
@@ -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,20 +131,20 @@ 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.'), ''];
}
/**
- * Controls if the module button the account page is visible and activated.
- *
- * @return string status ("enabled", "disabled", "hidden")
- */
+ * Controls if the module button the account page is visible and activated.
+ *
+ * @return string status ("enabled", "disabled", "hidden")
+ */
public function getButtonStatus() {
- if ($this->isRootNode()) {
+ if ($this->isRootNode()) {
return "hidden";
- }
+ }
else {
- return "enabled";
+ return "enabled";
}
}
@@ -156,7 +156,7 @@ class fixed_ip extends baseModule {
**/
private function isNotOverlappedIp($ip) {
if (in_array($ip, $this->overlapd)) {
- return false;
+ return false;
}
$this->overlapd[] = $ip;
@@ -166,9 +166,9 @@ class fixed_ip extends baseModule {
/**
* Reset the overlapped_range() function
**/
- private function reset_overlapped_ip() {
- $this->overlapd = [];
- }
+ private function reset_overlapped_ip() {
+ $this->overlapd = [];
+ }
/**
*
@@ -178,13 +178,13 @@ class fixed_ip extends baseModule {
* @return bool true, if mac is invalid
**/
public function check_mac($mac): bool {
- $ex = explode(":", $mac);
+ $ex = explode(":", $mac);
$invalid = false;
if (count($ex) != 6) {
- $invalid = true;
+ $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;
}
@@ -202,21 +202,21 @@ class fixed_ip extends baseModule {
public function reload_ips() {
$ip_edit = false; // IPs were edited?
// 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) {
- 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'))) {
- // Range anpassen:
+ if (is_array($this->fixed_ip)) {
+ $ex_subnet = explode(".", $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]);
+ 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'))) {
+ // Range anpassen:
$ex = explode(".", $this->fixed_ip[$id]['ip']);
$tmp = $this->fixed_ip[$id]['ip'];
- $this->fixed_ip[$id]['ip'] = $ex_subnet['0'].".".$ex_subnet['1'].".".$ex_subnet['2'].".".$ex['3'];
- if ($tmp!=$this->fixed_ip[$id]['ip']) {
+ $this->fixed_ip[$id]['ip'] = $ex_subnet['0'] . "." . $ex_subnet['1'] . "." . $ex_subnet['2'] . "." . $ex['3'];
+ if ($tmp != $this->fixed_ip[$id]['ip']) {
$ip_edit = true;
}
- }
- }
+ }
+ }
}
return $ip_edit;
}
@@ -227,9 +227,9 @@ class fixed_ip extends baseModule {
* @param array $attr list of attributes
*/
function load_attributes($attr) {
- if (!$this->isRootNode()) {
- $searchAttributes = array('cn', 'dhcphwaddress', 'dhcpstatements', 'dhcpcomments');
- $entries = searchLDAP($this->getAccountContainer()->dn_orig, '(objectClass=dhcpHost)', $searchAttributes);
+ if (!$this->isRootNode()) {
+ $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]);
$dhcphwaddress = array_pop($dhcphwaddress);
@@ -263,7 +263,7 @@ class fixed_ip extends baseModule {
* Orders the host entries by IP address.
*/
private function orderByIP() {
- // sort by IP
+ // sort by IP
$order = [];
foreach ($this->fixed_ip as $key => $value) {
$order[$key] = '';
@@ -280,11 +280,11 @@ class fixed_ip extends baseModule {
}
/**
- * Processes user input of the primary module page.
- * It checks if all input values are correct and updates the associated LDAP attributes.
- *
- * @return array list of info/error messages
- */
+ * Processes user input of the primary module page.
+ * It checks if all input values are correct and updates the associated LDAP attributes.
+ *
+ * @return array list of info/error messages
+ */
public function process_attributes() {
$errors = [];
if ($this->isRootNode()) {
@@ -294,102 +294,102 @@ class fixed_ip extends baseModule {
$this->reset_overlapped_ip();
- if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]!="") {
+ if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0] != "") {
$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])) {
+ // Check if ip is to drop
+ if (isset($_POST['drop_ip_' . $id])) {
// Drop ip:
unset($this->fixed_ip[$id]);
- continue;
- }
+ continue;
+ }
// MAC address
$_POST['mac_' . $id] = strtolower(trim($_POST['mac_' . $id]));
$invalid = $this->check_mac($_POST['mac_' . $id]);
if ($invalid) {
- $error = true;
+ $error = true;
}
- $this->fixed_ip[$id]['mac'] = $_POST['mac_'.$id];
+ $this->fixed_ip[$id]['mac'] = $_POST['mac_' . $id];
// description
- if (!get_preg($_POST['description_'.$id], 'ascii')) {
- $error = true;
+ if (!get_preg($_POST['description_' . $id], 'ascii')) {
+ $error = true;
}
- $this->fixed_ip[$id]['description'] = $_POST['description_'.$id];
+ $this->fixed_ip[$id]['description'] = $_POST['description_' . $id];
// active
$this->fixed_ip[$id]['active'] = (isset($_POST['active_' . $id]) && ($_POST['active_' . $id] == 'on'));
// Ip address
- if (!empty($_POST['ip_'.$id])) {
- $_POST['ip_'.$id] = trim($_POST['ip_'.$id]);
+ if (!empty($_POST['ip_' . $id])) {
+ $_POST['ip_' . $id] = trim($_POST['ip_' . $id]);
}
- if ((!empty($_POST['ip_'.$id]) && !(check_ip($_POST['ip_'.$id])))
- || (!empty($_POST['ip_'.$id]) && !$this->isNotOverlappedIp($_POST['ip_'.$id]))) {
+ if ((!empty($_POST['ip_' . $id]) && !(check_ip($_POST['ip_' . $id])))
+ || (!empty($_POST['ip_' . $id]) && !$this->isNotOverlappedIp($_POST['ip_' . $id]))) {
$error = true;
- $this->fixed_ip[$id]['ip'] = $_POST['ip_'.$id];
+ $this->fixed_ip[$id]['ip'] = $_POST['ip_' . $id];
}
else {
- $this->fixed_ip[$id]['ip'] = $_POST['ip_'.$id];
+ $this->fixed_ip[$id]['ip'] = $_POST['ip_' . $id];
}
// Is ip correct with subnet:
- if (!empty($_POST['ip_'.$id]) && check_ip($_POST['ip_'.$id]) && !range::check_subnet_range($_POST['ip_'.$id],
- $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0],
- $this->getAccountContainer()->getAccountModule('dhcp_settings')->getDHCPOption('subnet-mask'))) {
- $error = true;
+ if (!empty($_POST['ip_' . $id]) && check_ip($_POST['ip_' . $id]) && !range::check_subnet_range($_POST['ip_' . $id],
+ $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0],
+ $this->getAccountContainer()->getAccountModule('dhcp_settings')->getDHCPOption('subnet-mask'))) {
+ $error = true;
}
// cn:
- if (!empty($_POST['pc_'.$id])) {
- $_POST['pc_'.$id] = trim($_POST['pc_'.$id]);
+ if (!empty($_POST['pc_' . $id])) {
+ $_POST['pc_' . $id] = trim($_POST['pc_' . $id]);
}
- if (!empty($_POST['pc_'.$id])) {
+ if (!empty($_POST['pc_' . $id])) {
// name already in use
- if (in_array($_POST['pc_'.$id], $pcs) ) {
- $error = true;
+ if (in_array($_POST['pc_' . $id], $pcs)) {
+ $error = true;
}
else {
- $pcs[] = $_POST['pc_'.$id];
+ $pcs[] = $_POST['pc_' . $id];
}
}
else {
$error = true;
}
- if (strlen($_POST['pc_'.$id])>30) {
- $error = true;
+ if (strlen($_POST['pc_' . $id]) > 30) {
+ $error = true;
}
- if (!preg_match("/^[A-Za-z0-9\\._-]*$/",$_POST['pc_'.$id])) {
- $error = true;
+ if (!preg_match("/^[A-Za-z0-9\\._-]*$/", $_POST['pc_' . $id])) {
+ $error = true;
}
- $this->fixed_ip[$id]['cn'] = $_POST['pc_'.$id];
+ $this->fixed_ip[$id]['cn'] = $_POST['pc_' . $id];
}
if ($error) {
- $errors[] = $this->messages['errors'][0];
+ $errors[] = $this->messages['errors'][0];
}
}
// Add new IP
if (isset($_POST['add_ip']) || ($_POST['pc_add'] != '') || ($_POST['mac_add'] != '')) {
- // Add IP:
- $active = (isset($_POST['active_add']) && ($_POST['active_add'] == 'on'));
- $dhcpstatements = [];
- $this->setActive($dhcpstatements, $active);
- $this->setIP($dhcpstatements, $_POST['ip_add']);
- $this->fixed_ip[] = array(
+ // Add IP:
+ $active = (isset($_POST['active_add']) && ($_POST['active_add'] == 'on'));
+ $dhcpstatements = [];
+ $this->setActive($dhcpstatements, $active);
+ $this->setIP($dhcpstatements, $_POST['ip_add']);
+ $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();
}
@@ -403,12 +403,12 @@ class fixed_ip extends baseModule {
*/
public function display_html_attributes() {
$return = new htmlResponsiveRow();
- if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]=="") {
+ if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0] == "") {
$return->add(new htmlStatusMessage('ERROR', _("Please fill out the DHCP settings first.")), 12);
return $return;
- }
+ }
$this->initCache();
- // auto-completion for host names
+ // auto-completion for host names
$autoNames = [];
if (!empty($this->hostCache) && (sizeof($this->hostCache) < 200)) {
foreach ($this->hostCache as $attrs) {
@@ -418,9 +418,9 @@ 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
+ // Reset oberlaped ips
$this->reset_overlapped_ip();
// If $ranges is not a array, then create one:
@@ -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])) {
@@ -437,13 +437,13 @@ class fixed_ip extends baseModule {
}
if ($this->processed) {
if (strlen($this->fixed_ip[$id]['cn']) > 20) {
- $messages[] = new htmlStatusMessage('ERROR', _("The PC name may not be longer than 20 characters."), htmlspecialchars($this->fixed_ip[$id]['cn']));
+ $messages[] = new htmlStatusMessage('ERROR', _("The PC name may not be longer than 20 characters."), htmlspecialchars($this->fixed_ip[$id]['cn']));
}
elseif (strlen($this->fixed_ip[$id]['cn']) < 2) {
- $messages[] = new htmlStatusMessage('ERROR', _("The PC name needs to be at least 2 characters long."), htmlspecialchars($this->fixed_ip[$id]['cn']));
+ $messages[] = new htmlStatusMessage('ERROR', _("The PC name needs to be at least 2 characters long."), htmlspecialchars($this->fixed_ip[$id]['cn']));
}
- elseif (in_array($this->fixed_ip[$id]['cn'], $pcs) ) {
- $messages[] = new htmlStatusMessage('ERROR', _("This PC name already exists."), htmlspecialchars($this->fixed_ip[$id]['cn']));
+ elseif (in_array($this->fixed_ip[$id]['cn'], $pcs)) {
+ $messages[] = new htmlStatusMessage('ERROR', _("This PC name already exists."), htmlspecialchars($this->fixed_ip[$id]['cn']));
}
elseif (isset($_POST['pc_' . $id]) && !preg_match("/^[A-Za-z0-9\\._-]*$/", $_POST['pc_' . $id])) {
$messages[] = new htmlStatusMessage('ERROR', _("The PC name may only contain A-Z, a-z and 0-9."), htmlspecialchars($_POST['pc_' . $id]));
@@ -456,12 +456,12 @@ class fixed_ip extends baseModule {
// MAC address
if ($this->processed && $this->check_mac($this->fixed_ip[$id]['mac'])) {
- $messages[] = new htmlStatusMessage('ERROR', _("Invalid MAC address."), htmlspecialchars($this->fixed_ip[$id]['mac']));
+ $messages[] = new htmlStatusMessage('ERROR', _("Invalid MAC address."), htmlspecialchars($this->fixed_ip[$id]['mac']));
}
// description
if ($this->processed && !get_preg($this->fixed_ip[$id]['description'], 'ascii')) {
- $messages[] = new htmlStatusMessage('ERROR', _("Invalid description."), htmlspecialchars($this->fixed_ip[$id]['description']));
+ $messages[] = new htmlStatusMessage('ERROR', _("Invalid description."), htmlspecialchars($this->fixed_ip[$id]['description']));
}
// fixed ip
@@ -470,25 +470,25 @@ class fixed_ip extends baseModule {
$messages[] = new htmlStatusMessage('ERROR', _("The IP address is invalid."), htmlspecialchars($this->fixed_ip[$id]['ip']));
}
elseif (!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'))) {
- $messages[] = new htmlStatusMessage('ERROR', _("The IP address does not match the subnet."), htmlspecialchars($this->fixed_ip[$id]['ip']));
+ $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0],
+ $this->getAccountContainer()->getAccountModule('dhcp_settings')->getDHCPOption('subnet-mask'))) {
+ $messages[] = new htmlStatusMessage('ERROR', _("The IP address does not match the subnet."), htmlspecialchars($this->fixed_ip[$id]['ip']));
}
elseif (!$this->isNotOverlappedIp($this->fixed_ip[$id]['ip'])) {
- $messages[] = new htmlStatusMessage('ERROR', _("The IP address is already in use."), htmlspecialchars($this->fixed_ip[$id]['ip']));
+ $messages[] = new htmlStatusMessage('ERROR', _("The IP address is already in use."), htmlspecialchars($this->fixed_ip[$id]['ip']));
}
}
$entry = [];
- $entry[] = new htmlInputField('ip_'.$id, $this->fixed_ip[$id]['ip']);
- $pcInput = new htmlInputField('pc_'.$id, $this->fixed_ip[$id]['cn']);
+ $entry[] = new htmlInputField('ip_' . $id, $this->fixed_ip[$id]['ip']);
+ $pcInput = new htmlInputField('pc_' . $id, $this->fixed_ip[$id]['cn']);
if (!empty($autoNames)) {
$pcInput->enableAutocompletion($autoNames);
}
$entry[] = $pcInput;
- $entry[] = new htmlInputField('mac_'.$id, $this->fixed_ip[$id]['mac']);
- $entry[] = new htmlInputField('description_'.$id, $this->fixed_ip[$id]['description']);
- $entry[] = new htmlInputCheckbox('active_'.$id, $this->fixed_ip[$id]['active']);
- $entry[] = new htmlButton('drop_ip_'.$id, 'del.svg', true);
+ $entry[] = new htmlInputField('mac_' . $id, $this->fixed_ip[$id]['mac']);
+ $entry[] = new htmlInputField('description_' . $id, $this->fixed_ip[$id]['description']);
+ $entry[] = new htmlInputCheckbox('active_' . $id, $this->fixed_ip[$id]['active']);
+ $entry[] = new htmlButton('drop_ip_' . $id, 'del.svg', true);
$data[] = $entry;
}
// add host
@@ -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)];
}
}
}
@@ -610,43 +610,43 @@ class fixed_ip extends baseModule {
}
/**
- * Processes user input of the add host page.
- * It checks if all input values are correct and updates the associated LDAP attributes.
- *
- * @return array list of info/error messages
- */
+ * Processes user input of the add host page.
+ * It checks if all input values are correct and updates the associated LDAP attributes.
+ *
+ * @return array list of info/error messages
+ */
public function process_addHost() {
$errors = [];
if (isset($_POST['form_subpage_fixed_ip_attributes_addHost'])) {
$val = explode('####', $_POST['host']);
- $dhcpstatements = [];
- $this->setActive($dhcpstatements, true);
- $this->setIP($dhcpstatements, $val[1]);
- $this->fixed_ip[] = array(
+ $dhcpstatements = [];
+ $this->setActive($dhcpstatements, true);
+ $this->setIP($dhcpstatements, $val[1]);
+ $this->fixed_ip[] = [
'cn' => $val[0],
'mac' => $val[2],
'description' => '',
'ip' => $val[1],
'dhcpstatements' => $dhcpstatements,
'active' => true,
- );
+ ];
$this->orderByIP();
}
return $errors;
}
/**
- * Returns a list of modifications which have to be made to the LDAP account.
- *
- * @return array list of modifications
- *
This function returns an array with 3 entries:
- *
array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
- *
DN is the DN to change. It may be possible to change several DNs (e.g. create a new user and add him to some groups via attribute memberUid)
- *
"add" are attributes which have to be added to LDAP entry
- *
"remove" are attributes which have to be removed from LDAP entry
- *
"modify" are attributes which have to been modified in LDAP entry
- *
"info" are values with informational value (e.g. to be used later by pre/postModify actions)
- */
+ * Returns a list of modifications which have to be made to the LDAP account.
+ *
+ * @return array list of modifications
+ *
This function returns an array with 3 entries:
+ *
array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
+ *
DN is the DN to change. It may be possible to change several DNs (e.g. create a new user and add him to some groups via attribute memberUid)
+ *
"add" are attributes which have to be added to LDAP entry
+ *
"remove" are attributes which have to be removed from LDAP entry
+ *
"modify" are attributes which have to been modified in LDAP entry
+ *
"info" are values with informational value (e.g. to be used later by pre/postModify actions)
+ */
public function save_attributes() {
}
@@ -654,72 +654,72 @@ 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()) {
$ldapSuffix = ',cn=' . $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0] . ',' . $this->getAccountContainer()->get_type()->getSuffix();
- $add = [];
- $mod = []; // DN => array(attr => values)
- $delete = [];
+ $add = [];
+ $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) {
- if ($this->orig_ips[$id]['cn'] == $this->fixed_ip[$idB]['cn']) {
- $in_arr = true;
+ 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
- if($this->orig_ips[$id]['ip'] != $this->fixed_ip[$idB]['ip']) {
+ if ($this->orig_ips[$id]['ip'] != $this->fixed_ip[$idB]['ip']) {
$this->setIP($this->fixed_ip[$idB]['dhcpstatements'], $this->fixed_ip[$idB]['ip']);
$mod['cn=' . $this->orig_ips[$id]['cn'] . $ldapSuffix]['dhcpstatements'] = $this->fixed_ip[$idB]['dhcpstatements'];
}
// check if active changed
- if($this->orig_ips[$id]['active'] != $this->fixed_ip[$idB]['active']) {
+ if ($this->orig_ips[$id]['active'] != $this->fixed_ip[$idB]['active']) {
$this->setActive($this->fixed_ip[$idB]['dhcpstatements'], $this->fixed_ip[$idB]['active']);
$mod['cn=' . $this->orig_ips[$id]['cn'] . $ldapSuffix]['dhcpstatements'] = $this->fixed_ip[$idB]['dhcpstatements'];
}
// 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']);
+ if ($this->orig_ips[$id]['mac'] != $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']) {
+ if ($this->orig_ips[$id]['description'] != $this->fixed_ip[$idB]['description']) {
$mod['cn=' . $this->orig_ips[$id]['cn'] . $ldapSuffix]['dhcpComments'][] = $this->fixed_ip[$idB]['description'];
}
break;
- }
+ }
}
- if (!$in_arr) {
- $delete[] = $this->orig_ips[$id]['cn'];
- }
- }
+ if (!$in_arr) {
+ $delete[] = $this->orig_ips[$id]['cn'];
+ }
+ }
if (!is_array($this->fixed_ip)) {
- $this->fixed_ip = [];
+ $this->fixed_ip = [];
}
- // Which entries are new:
- foreach($this->fixed_ip AS $id => $arr) {
- $in_arr = false;
- foreach($this->orig_ips AS $idB => $arr) {
- if ($this->orig_ips[$idB]['cn'] == $this->fixed_ip[$id]['cn']) {
- $in_arr = true;
- }
- }
- if (!$in_arr) {
- $add[] = $this->fixed_ip[$id];
- }
- }
-
- foreach($delete AS $cn) {
- ldap_delete($_SESSION['ldap']->server(), 'cn=' . $cn . $ldapSuffix);
+ // Which entries are new:
+ foreach ($this->fixed_ip as $id => $arr) {
+ $in_arr = false;
+ foreach ($this->orig_ips as $idB => $arr) {
+ if ($this->orig_ips[$idB]['cn'] == $this->fixed_ip[$id]['cn']) {
+ $in_arr = true;
+ }
+ }
+ if (!$in_arr) {
+ $add[] = $this->fixed_ip[$id];
+ }
}
- foreach($add AS $id => $arr) {
+ foreach ($delete as $cn) {
+ ldap_delete($_SESSION['ldap']->server(), 'cn=' . $cn . $ldapSuffix);
+ }
+
+ foreach ($add as $id => $arr) {
$attr = [];
$attr['cn'] = $add[$id]['cn'];
$attr['objectClass'][0] = 'top';
@@ -738,11 +738,11 @@ class fixed_ip extends baseModule {
if ($attr['cn'] != "") {
ldap_add($_SESSION['ldap']->server(), 'cn=' . $add[$id]['cn'] . $ldapSuffix, $attr);
}
- }
- // entries to modify
- foreach ($mod as $dn => $attrs) {
- ldap_modify($_SESSION['ldap']->server(), $dn, $attrs);
- }
+ }
+ // entries to modify
+ foreach ($mod as $dn => $attrs) {
+ ldap_modify($_SESSION['ldap']->server(), $dn, $attrs);
+ }
}
return [];
}
@@ -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,11 +936,11 @@ 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';
}
- $dhcphwaddress = explode(" ",$entries[$i]['dhcphwaddress'][0]);
+ $dhcphwaddress = explode(" ", $entries[$i]['dhcphwaddress'][0]);
$ipAddress = fixed_ip::extractIP($dhcpstatements);
$ip = new htmlOutputText($ipAddress);
$ip->setCSSClasses($cssClasses);
diff --git a/lam/lib/modules/freeRadius.inc b/lam/lib/modules/freeRadius.inc
index 20660347e..1a8c998ea 100644
--- a/lam/lib/modules/freeRadius.inc
+++ b/lam/lib/modules/freeRadius.inc
@@ -20,61 +20,61 @@
*/
/**
-* Manages FreeRadius accounts.
-*
-* @package modules
-* @author Roland Gruber
-*/
+ * Manages FreeRadius accounts.
+ *
+ * @package modules
+ * @author Roland Gruber
+ */
use LAM\TYPES\ConfiguredType;
/**
-* Manages FreeRadius accounts.
-*
-* @package modules
-*/
+ * Manages FreeRadius accounts.
+ *
+ * @package modules
+ */
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',
- '06' => 'Jun', '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'
- );
+ 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;
/**
- * Creates a new freeRadius object.
- *
- * @param string $scope account type (user, group, host)
- */
+ * Creates a new freeRadius object.
+ *
+ * @param string $scope account type (user, group, host)
+ */
function __construct($scope) {
parent::__construct($scope);
$this->autoAddObjectClasses = false;
}
/**
- * Returns true if this module can manage accounts of the current type, otherwise false.
- *
- * @return boolean true if module fits
- */
+ * Returns true if this module can manage accounts of the current type, otherwise false.
+ *
+ * @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']);
}
/**
- * Returns meta data that is interpreted by parent class
- *
- * @return array array with meta data
- *
- * @see baseModule::get_metaData()
- */
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ *
+ * @see baseModule::get_metaData()
+ */
function get_metaData() {
$return = [];
// icon
@@ -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'] = [];
@@ -289,19 +289,19 @@ class freeRadius extends baseModule {
}
/**
- * Returns a list of configuration options.
- *
- * Calling this method does not require the existence of an enclosing {@link accountContainer}.
- *
- * The field names are used as keywords to load and save settings.
- * We recommend to use the module name as prefix for them (e.g. posixAccount_homeDirectory) to avoid naming conflicts.
- *
- * @param array $scopes account types (user, group, host)
- * @param array $allScopes list of all active account modules and their scopes (module => array(scopes))
- * @return mixed htmlElement or array of htmlElement
- *
- * @see htmlElement
- */
+ * Returns a list of configuration options.
+ *
+ * Calling this method does not require the existence of an enclosing {@link accountContainer}.
+ *
+ * The field names are used as keywords to load and save settings.
+ * We recommend to use the module name as prefix for them (e.g. posixAccount_homeDirectory) to avoid naming conflicts.
+ *
+ * @param array $scopes account types (user, group, host)
+ * @param array $allScopes list of all active account modules and their scopes (module => array(scopes))
+ * @return mixed htmlElement or array of htmlElement
+ *
+ * @see htmlElement
+ */
public function get_configOptions($scopes, $allScopes) {
$configContainer = new htmlResponsiveRow();
$configContainer->add(new htmlResponsiveInputField(_('Profile DN'), 'freeRadius_profileDN', '', 'profileDN'), 12);
@@ -323,29 +323,29 @@ class freeRadius extends baseModule {
}
/**
- * This function fills the error message array with messages
- */
+ * 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!')];
}
/**
* {@inheritDoc}
*/
- public function loadAttributesFromAccountCopy(array $ldapAttributes, array $attributesToIgnore = []) : void {
+ public function loadAttributesFromAccountCopy(array $ldapAttributes, array $attributesToIgnore = []): void {
$attributesToIgnore = array_merge(baseModule::ATTRIBUTES_TO_IGNORE_ON_COPY_DEFAULT, self::ATTRIBUTES_TO_IGNORE_ON_COPY);
parent::loadAttributesFromAccountCopy($ldapAttributes, $attributesToIgnore);
}
@@ -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 {
@@ -437,18 +437,18 @@ class freeRadius extends baseModule {
}
/**
- * Processes user input of the primary module page.
- * It checks if all input values are correct and updates the associated LDAP attributes.
- *
- * @return array list of info/error messages
- */
+ * Processes user input of the primary module page.
+ * It checks if all input values are correct and updates the associated LDAP attributes.
+ *
+ * @return array list of info/error messages
+ */
function process_attributes() {
if (isset($_POST['addObjectClass'])) {
$this->attributes['objectClass'][] = 'radiusprofile';
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]]);
@@ -518,17 +518,16 @@ class freeRadius extends baseModule {
}
/**
- * This function will create the meta HTML code to show a page to change the expiration date.
- *
- * @return htmlElement meta HTML code
- */
+ * This function will create the meta HTML code to show a page to change the expiration date.
+ *
+ * @return htmlElement meta HTML code
+ */
function display_html_expiration() {
$return = new htmlResponsiveRow();
$attr = 'radiusExpiration';
- // TODO display in local time
- $date = new DateTime('@' . (time() + 3600*24*365), getTimeZone());
+ $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'));
+ $date = DateTime::createFromFormat('d M Y H:i', $this->attributes[$attr][0], new DateTimeZone('UTC'));
$date->setTimezone(getTimeZone());
}
$dateInput = new htmlResponsiveInputField(_('Expiration date'), 'expirationTime', $date->format('Y-m-d H:i'), 'radiusExpiration');
@@ -549,10 +548,10 @@ class freeRadius extends baseModule {
}
/**
- * Processes user input of the time selection page.
- *
- * @return array list of info/error messages
- */
+ * Processes user input of the time selection page.
+ *
+ * @return array list of info/error messages
+ */
function process_expiration() {
$return = [];
// find button name
@@ -589,17 +588,17 @@ class freeRadius extends baseModule {
}
/**
- * Returns a list of modifications which have to be made to the LDAP account.
- *
- * @return array list of modifications
- *
This function returns an array with 3 entries:
- *
array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
- *
DN is the DN to change. It may be possible to change several DNs (e.g. create a new user and add him to some groups via attribute memberUid)
- *
"add" are attributes which have to be added to LDAP entry
- *
"remove" are attributes which have to be removed from LDAP entry
- *
"modify" are attributes which have to been modified in LDAP entry
- *
"info" are values with informational value (e.g. to be used later by pre/postModify actions)
- */
+ * Returns a list of modifications which have to be made to the LDAP account.
+ *
+ * @return array list of modifications
+ *
This function returns an array with 3 entries:
+ *
array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
+ *
DN is the DN to change. It may be possible to change several DNs (e.g. create a new user and add him to some groups via attribute memberUid)
+ *
"add" are attributes which have to be added to LDAP entry
+ *
"remove" are attributes which have to be removed from LDAP entry
+ *
"modify" are attributes which have to been modified in LDAP entry
+ *
"info" are values with informational value (e.g. to be used later by pre/postModify actions)
+ */
function save_attributes() {
if (!in_array('radiusprofile', $this->attributes['objectClass']) && !in_array('radiusprofile', $this->orig['objectClass'])) {
// skip saving if the extension was not added/modified
@@ -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);
@@ -687,8 +688,8 @@ class freeRadius extends baseModule {
}
/**
- * {@inheritDoc}
- */
+ * {@inheritDoc}
+ */
function check_profileOptions($options, $typeId) {
$messages = parent::check_profileOptions($options, $typeId);
// group names
@@ -707,10 +708,10 @@ class freeRadius extends baseModule {
}
/**
- * Loads the values of an account profile into internal variables.
- *
- * @param array $profile hash array with profile values (identifier => value)
- */
+ * Loads the values of an account profile into internal variables.
+ *
+ * @param array $profile hash array with profile values (identifier => value)
+ */
function load_profile($profile) {
// profile mappings in meta data
parent::load_profile($profile);
@@ -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'),
- );
+ ];
}
}
@@ -813,7 +814,7 @@ if (interface_exists('\LAM\JOB\Job', false)) {
* @return String name
*/
public function getAlias() {
- return _('FreeRadius') . ': ' . _('Cleanup expired user accounts');
+ return _('FreeRadius') . ': ' . _('Cleanup expired user accounts');
}
/**
@@ -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']);
}
/**
diff --git a/lam/lib/modules/generalInformation.inc b/lam/lib/modules/generalInformation.inc
index 98356e6e7..987437027 100644
--- a/lam/lib/modules/generalInformation.inc
+++ b/lam/lib/modules/generalInformation.inc
@@ -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
@@ -20,38 +20,38 @@
*/
/**
-* Shows general information like the creation time of an account.
-*
-* @package modules
-* @author Roland Gruber
-*/
+ * Shows general information like the creation time of an account.
+ *
+ * @package modules
+ * @author Roland Gruber
+ */
use LAM\TYPES\ConfiguredType;
use LAM\TYPES\TypeManager;
/**
-* Shows general information like the creation time of an account.
-*
-* @package modules
-*/
+ * Shows general information like the creation time of an account.
+ *
+ * @package modules
+ */
class generalInformation extends baseModule {
/**
- * Returns true if this module can manage accounts of the current type, otherwise false.
- *
- * @return boolean true if module fits
- */
+ * Returns true if this module can manage accounts of the current type, otherwise false.
+ *
+ * @return boolean true if module fits
+ */
public function can_manage() {
return in_array($this->get_scope(), LAM\TYPES\getTypes());
}
/**
- * Returns meta data that is interpreted by parent class
- *
- * @return array array with meta data
- *
- * @see baseModule::get_metaData()
- */
+ * Returns meta data that is interpreted by parent class
+ *
+ * @return array array with meta data
+ *
+ * @see baseModule::get_metaData()
+ */
public function get_metaData() {
$return = [];
// icon
@@ -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) {
@@ -146,11 +146,11 @@ class generalInformation extends baseModule {
}
/**
- * Processes user input of the primary module page.
- * It checks if all input values are correct and updates the associated LDAP attributes.
- *
- * @return array list of info/error messages
- */
+ * Processes user input of the primary module page.
+ * It checks if all input values are correct and updates the associated LDAP attributes.
+ *
+ * @return array list of info/error messages
+ */
public function process_attributes() {
return [];
}
@@ -158,7 +158,7 @@ class generalInformation extends baseModule {
/**
* {@inheritDoc}
*/
- public function loadAttributesFromAccountCopy(array $ldapAttributes, array $attributesToIgnore = []) : void {
+ public function loadAttributesFromAccountCopy(array $ldapAttributes, array $attributesToIgnore = []): void {
// no action for this module
}
@@ -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')
- );
+ ];
}
}