refactoring

This commit is contained in:
Roland Gruber 2025-07-22 17:29:33 +02:00
parent c368a748dd
commit bd7008f39f
4 changed files with 13 additions and 15 deletions

View file

@ -902,7 +902,7 @@ function searchLDAP($suffix, $filter, $attributes, $limit = -1) {
/** /**
* Returns the LDAP server handle. * Returns the LDAP server handle.
* *
* @return handle LDAP handle * @return Connection LDAP handle
*/ */
function getLDAPServerHandle() { function getLDAPServerHandle() {
if (!empty($_SESSION['ldap'])) { if (!empty($_SESSION['ldap'])) {
@ -910,7 +910,7 @@ function getLDAPServerHandle() {
return $_SESSION['ldap']->server(); return $_SESSION['ldap']->server();
} }
else { else {
// self service // self-service
return $_SESSION['ldapHandle']->getServer(); return $_SESSION['ldapHandle']->getServer();
} }
} }

View file

@ -1340,7 +1340,7 @@ abstract class baseModule {
* *
* Calling this method requires the existence of an enclosing {@link accountContainer}. * Calling this method requires the existence of an enclosing {@link accountContainer}.
* *
* @return htmlElement meta HTML object * @return htmlElement|htmlElement[] meta HTML object
* *
* @see htmlElement * @see htmlElement
*/ */

View file

@ -7,7 +7,7 @@ use LAM\TYPES\TypeManager;
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz Copyright (C) 2003 - 2006 Tilo Lutz
2007 - 2024 Roland Gruber 2007 - 2025 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -194,7 +194,7 @@ class sambaGroupMapping extends baseModule {
/** /**
* Gets the GID number from the Unix group module. * Gets the GID number from the Unix group module.
* *
* @return String GID number * @return string|null GID number
*/ */
private function getGID() { private function getGID() {
$modules = ['posixGroup', 'rfc2307bisPosixGroup']; $modules = ['posixGroup', 'rfc2307bisPosixGroup'];
@ -212,9 +212,9 @@ class sambaGroupMapping extends baseModule {
/** /**
* Gets the cn from the Unix group module. * Gets the cn from the Unix group module.
* *
* @return String cn attribute * @return string|null cn attribute
*/ */
private function getCn() { private function getCn(): ?string {
$modules = ['posixGroup', 'groupOfNames', 'groupOfUniqueNames']; $modules = ['posixGroup', 'groupOfNames', 'groupOfUniqueNames'];
for ($i = 0; $i < count($modules); $i++) { for ($i = 0; $i < count($modules); $i++) {
if ($this->getAccountContainer()->getAccountModule($modules[$i]) != null) { if ($this->getAccountContainer()->getAccountModule($modules[$i]) != null) {
@ -302,7 +302,7 @@ class sambaGroupMapping extends baseModule {
$rid = $this->rids[$rid]; $rid = $this->rids[$rid];
} }
// check if RID has to be calculated // check if RID has to be calculated
if (($rid == "") || (!isset($rid))) { if (($rid == "")) {
$ridBase = $nameToRIDBase[$rawAccounts[$i][$ids['sambaGroupMapping_domain']]]; $ridBase = $nameToRIDBase[$rawAccounts[$i][$ids['sambaGroupMapping_domain']]];
$partialAccounts[$i]['sambaSID'] = $domSID . "-" . (($partialAccounts[$i]['gidNumber'] * 2) + $ridBase + 1); $partialAccounts[$i]['sambaSID'] = $domSID . "-" . (($partialAccounts[$i]['gidNumber'] * 2) + $ridBase + 1);
} }
@ -341,6 +341,7 @@ class sambaGroupMapping extends baseModule {
if (isset($this->attributes['sambaSID'][0])) { if (isset($this->attributes['sambaSID'][0])) {
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
} }
$SID = '';
for ($i = 0; $i < count($sambaDomains); $i++) { for ($i = 0; $i < count($sambaDomains); $i++) {
// List with all valid domains // List with all valid domains
$sambaDomainNames[] = $sambaDomains[$i]->name; $sambaDomainNames[] = $sambaDomains[$i]->name;
@ -590,13 +591,10 @@ class sambaGroupMapping extends baseModule {
/** /**
* This function is used to check if this module page can be displayed. * {@inheritDoc}
* It returns false if a module depends on data from other modules which was not yet entered.
*
* @return boolean true, if page can be displayed
*/ */
function module_ready() { function module_ready() {
return ($this->getGID() != null) && ($this->getGID() != ''); return ($this->getGID() !== null) && ($this->getGID() !== '');
} }
/** /**
@ -653,6 +651,8 @@ class sambaGroupMapping extends baseModule {
$this->attributes['sambaGroupType'][0] = $this->sambaGroupTypes[$_POST['sambaGroupType']]; $this->attributes['sambaGroupType'][0] = $this->sambaGroupTypes[$_POST['sambaGroupType']];
// Get Domain SID from name // Get Domain SID from name
$SID = '';
$RIDbase = 1000;
for ($i = 0; $i < count($sambaDomains); $i++) { for ($i = 0; $i < count($sambaDomains); $i++) {
if (!isset($_POST['sambaDomainName'])) { if (!isset($_POST['sambaDomainName'])) {
break; break;
@ -663,7 +663,6 @@ class sambaGroupMapping extends baseModule {
} }
} }
// Load attributes // Load attributes
$this->attributes['displayName'][0] = $_POST['displayName'];
$rids = array_keys($this->rids); $rids = array_keys($this->rids);
$wrid = false; $wrid = false;
for ($i = 0; $i < count($rids); $i++) { for ($i = 0; $i < count($rids); $i++) {

View file

@ -20,6 +20,5 @@ parameters:
- '#Function [a-zA-Z0-9\\_-]+ not found.#' - '#Function [a-zA-Z0-9\\_-]+ not found.#'
- '#Used function [a-zA-Z0-9\\_-]+ not found.#' - '#Used function [a-zA-Z0-9\\_-]+ not found.#'
- '#Variable \$helpArray might not be defined.#' - '#Variable \$helpArray might not be defined.#'
- '#Function [a-zA-Z0-9\(\)\\_-]+ has invalid return type [a-zA-Z0-9\\_-]+.#'
- '#Binary operation .* between .* and .* results in an error.#' - '#Binary operation .* between .* and .* results in an error.#'
- '#Offset .SID. on array.*in isset\(\) always exists.*#' - '#Offset .SID. on array.*in isset\(\) always exists.*#'