mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 17:59:21 +02:00
refactoring
This commit is contained in:
parent
9a065cebb5
commit
6c589065ad
12 changed files with 34 additions and 27 deletions
|
@ -671,13 +671,16 @@ function getRequiredExtensions() {
|
|||
* meta HTML code. This allows to have a common design for all module pages.
|
||||
*
|
||||
* @param string|null $module Name of account module
|
||||
* @param htmlElement|htmlElement[] $input htmlElement or array of htmlElement elements
|
||||
* @param htmlElement|htmlElement[]|null $input htmlElement or array of htmlElement elements
|
||||
* @param array $values List of values which override the defaults in $input (name => value)
|
||||
* @param boolean $restricted If true then no buttons will be displayed
|
||||
* @param string|null $scope Account type
|
||||
* @return array List of input field names and their type (name => type)
|
||||
*/
|
||||
function parseHtml($module, $input, $values, $restricted, $scope) {
|
||||
if ($input === null) {
|
||||
return [];
|
||||
}
|
||||
if ($input instanceof htmlElement) {
|
||||
return $input->generateHTML($module, $input, $values, $restricted, $scope);
|
||||
}
|
||||
|
|
|
@ -911,7 +911,7 @@ class fixed_ip extends baseModule {
|
|||
*/
|
||||
public function getListRenderFunction(string $attributeName): ?callable {
|
||||
if ($attributeName === 'fixed_ips') {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
// find all fixed addresses:
|
||||
$entries = searchLDAP($entry['dn'], 'objectClass=dhcpHost', ['dhcpstatements', 'dhcphwaddress', 'cn']);
|
||||
if (count($entries) > 0) {
|
||||
|
@ -959,7 +959,7 @@ class fixed_ip extends baseModule {
|
|||
}
|
||||
return $group;
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -411,7 +411,7 @@ class imapAccess extends baseModule {
|
|||
/**
|
||||
* Creates the mailbox for a user.
|
||||
*
|
||||
* @param Horde_Imap_Client_Socket $client IMAP client
|
||||
* @param Client $client IMAP client
|
||||
* @param string $userName user name
|
||||
* @param string $email_domain email domain
|
||||
* @return array error messages
|
||||
|
@ -452,7 +452,7 @@ class imapAccess extends baseModule {
|
|||
/**
|
||||
* Sets the mailbox quota for a user.
|
||||
*
|
||||
* @param Horde_Imap_Client_Socket $client IMAP client
|
||||
* @param Client $client IMAP client
|
||||
* @param string $userName user name
|
||||
* @param string $email_domain email domain
|
||||
* @param string $quota mailbox quota
|
||||
|
@ -927,27 +927,31 @@ class imapAccess extends baseModule {
|
|||
/**
|
||||
* Returns if the mailbox exists.
|
||||
*
|
||||
* @param $client IMAP client
|
||||
* @param Client $client IMAP client
|
||||
* @param string $path mailbox path
|
||||
* @return bool is existing
|
||||
*/
|
||||
private function isMailboxExisting($client, string $path): bool {
|
||||
$list = $client->getConnection()->folders($path);
|
||||
return ($list !== null) && is_array($list->data()) && (count($list->data()) >= 1);
|
||||
return is_array($list->data()) && (count($list->data()) >= 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quota data for the user.
|
||||
*
|
||||
* @param $client IMAP client
|
||||
* @param Client $client IMAP client
|
||||
* @param string $user user name
|
||||
* @return array array with keys QUOTA_USAGE and QUOTA_LIMIT
|
||||
*/
|
||||
private function getQuota($client, string $user): array {
|
||||
$user = $client->getConnection()->escapeString($user);
|
||||
$connection = $client->getConnection();
|
||||
if (!($connection instanceof ImapProtocol)) {
|
||||
return [];
|
||||
}
|
||||
$user = $connection->escapeString($user);
|
||||
$quota_values = [];
|
||||
try {
|
||||
$quota = $client->getConnection()->requestAndResponse('GETQUOTA', [$user]);
|
||||
$quota = $connection->requestAndResponse('GETQUOTA', [$user]);
|
||||
$quota = $quota->data();
|
||||
if (isset($quota[0][2][0]) && ($quota[0][2][0] === 'STORAGE')) {
|
||||
$quota_values = [
|
||||
|
|
|
@ -4138,7 +4138,7 @@ class inetOrgPerson extends baseModule implements passwordService, AccountStatus
|
|||
};
|
||||
}
|
||||
elseif ($attributeName === 'jpegphoto') {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] !== '')) {
|
||||
if (strlen($entry[$attribute][0]) < 100) {
|
||||
// looks like we have read broken binary data, reread photo
|
||||
|
@ -4162,7 +4162,7 @@ class inetOrgPerson extends baseModule implements passwordService, AccountStatus
|
|||
$image->setCSSClasses(['thumbnail']);
|
||||
return $image;
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -820,7 +820,7 @@ class range extends baseModule {
|
|||
*/
|
||||
public function getListRenderFunction(string $attributeName): ?callable {
|
||||
if ($attributeName === 'dhcprange') {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
if (!empty($entry[$attribute][0])) {
|
||||
$table = new htmlTable();
|
||||
$table->setCSSClasses(['nowrap']);
|
||||
|
@ -861,7 +861,7 @@ class range extends baseModule {
|
|||
}
|
||||
return $table;
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -3089,7 +3089,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
|
|||
*/
|
||||
public function getListRenderFunction(string $attributeName): ?callable {
|
||||
if ($attributeName === 'sambakickofftime') {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
if (!empty($entry[$attribute][0])) {
|
||||
if ($entry[$attribute][0] > 2147483648) {
|
||||
return new htmlOutputText("∞");
|
||||
|
@ -3099,7 +3099,7 @@ class sambaSamAccount extends baseModule implements passwordService, AccountStat
|
|||
return new htmlOutputText($date->format('d.m.Y'));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1036,12 +1036,12 @@ class shadowAccount extends baseModule implements passwordService, AccountStatus
|
|||
*/
|
||||
public function getListRenderFunction(string $attributeName): ?callable {
|
||||
if (($attributeName === 'shadowexpire') || ($attributeName === 'shadowlastchange')) {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
if (!empty($entry[$attribute][0])) {
|
||||
$time = new DateTime('@' . $entry[$attribute][0] * 24 * 3600, getTimeZone());
|
||||
return new htmlOutputText($time->format('d.m.Y'));
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1126,7 +1126,7 @@ class windowsGroup extends baseModule {
|
|||
};
|
||||
}
|
||||
elseif (($attributeName === 'managedby') || ($attributeName === 'member')) {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
if (!empty($entry[$attribute][0])) {
|
||||
$typeManager = new TypeManager();
|
||||
$values = $entry[$attribute];
|
||||
|
@ -1149,7 +1149,7 @@ class windowsGroup extends baseModule {
|
|||
}
|
||||
return new htmlDiv(null, new htmlOutputText(implode('<br>', $values), false), ['rightToLeftText']);
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -414,7 +414,7 @@ class windowsHost extends baseModule {
|
|||
};
|
||||
}
|
||||
elseif ($attributeName === 'managedby') {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
if (!empty($entry[$attribute][0])) {
|
||||
$value = $entry[$attribute][0];
|
||||
$typeManager = new TypeManager();
|
||||
|
@ -431,7 +431,7 @@ class windowsHost extends baseModule {
|
|||
}
|
||||
return new htmlDiv(null, new htmlOutputText($value, false), ['rightToLeftText']);
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -4808,7 +4808,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
|
|||
};
|
||||
}
|
||||
elseif (($attributeName === 'jpegphoto') || ($attributeName === 'thumbnailphoto')) {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
if (isset($entry[$attribute][0]) && ($entry[$attribute][0] !== '')) {
|
||||
if (strlen($entry[$attribute][0]) < 100) {
|
||||
// looks like we have read broken binary data, reread photo
|
||||
|
@ -4832,7 +4832,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
|
|||
$image->setCSSClasses(['thumbnail']);
|
||||
return $image;
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
elseif ($attributeName === 'accountexpires') {
|
||||
|
@ -4848,7 +4848,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
|
|||
};
|
||||
}
|
||||
elseif ($attributeName === 'manager') {
|
||||
return function(array $entry, string $attribute): ?htmlElement {
|
||||
return function(array $entry, string $attribute): htmlElement {
|
||||
if (!empty($entry[$attribute][0])) {
|
||||
$value = $entry[$attribute][0];
|
||||
$typeManager = new TypeManager();
|
||||
|
@ -4865,7 +4865,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
|
|||
}
|
||||
return new htmlDiv(null, new htmlOutputText($value, false), ['rightToLeftText']);
|
||||
}
|
||||
return null;
|
||||
return new htmlGroup();
|
||||
};
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -6,6 +6,7 @@ use \htmlStatusMessage;
|
|||
use \htmlSubTitle;
|
||||
use \htmlOutputText;
|
||||
use \htmlImage;
|
||||
use LAM\SCHEMA\ObjectClass;
|
||||
use function \LAM\SCHEMA\get_schema_objectclasses;
|
||||
use function \LAM\SCHEMA\get_cached_schema;
|
||||
/*
|
||||
|
|
|
@ -15,7 +15,6 @@ parameters:
|
|||
analyseAndScan:
|
||||
- */lists/changePassword.php
|
||||
ignoreErrors:
|
||||
- '#.* on an unknown class .*#'
|
||||
- '#.* has invalid type .*#'
|
||||
- '#Function [a-zA-Z0-9\\_-]+ not found.#'
|
||||
- '#Used function [a-zA-Z0-9\\_-]+ not found.#'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue