Add some class properties type & coments and clean errors detected by PHPstan (level 2)

This commit is contained in:
Benjamin Renard 2022-12-31 21:15:19 +01:00
parent 8a02680114
commit bbde10bbf0
161 changed files with 2526 additions and 1277 deletions

View file

@ -2,14 +2,17 @@ stages:
- tests
tests:
image: composer
image:
name: brenard/ldapsaisie:dev
entrypoint: ["/bin/sh", "-c"]
stage: tests
rules:
- changes:
- src/*
script:
- composer install
- ./vendor/bin/phpstan analyse --no-interaction --configuration=phpstan.neon --error-format=junit > tests-report.xml
- service slapd start
- ./vendor/bin/phpstan analyse --no-interaction --configuration=.phpstan/config.neon --error-format=junit > tests-report.xml
artifacts:
when: always
paths:

15
.phpstan/config.neon Normal file
View file

@ -0,0 +1,15 @@
parameters:
level: 2
paths:
- ../src
excludePaths:
- ../src/local
- ../src/tmp
bootstrapFiles:
- ../src/includes/core.php
- init.php
typeAliases:
LSformat: 'string'
universalObjectCratesClasses:
- LSsearchEntry
- LSurlRequest

10
.phpstan/init.php Normal file
View file

@ -0,0 +1,10 @@
<?php
require 'Net/LDAP2.php';
require 'Console/Table.php';
require 'Zxcvbn/autoload.php';
require '/usr/share/php/phpseclib/autoload.php';
require 'CAS.php';
spl_autoload_register(array('LSsession', 'loadLSclass'));
LSsession :: initialize();

78
composer.lock generated Normal file
View file

@ -0,0 +1,78 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "37f736b754e8e0455f279bf0da013262",
"packages": [],
"packages-dev": [
{
"name": "phpstan/phpstan",
"version": "1.9.4",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "d03bccee595e2146b7c9d174486b84f4dc61b0f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/d03bccee595e2146b7c9d174486b84f4dc61b0f2",
"reference": "d03bccee595e2146b7c9d174486b84f4dc61b0f2",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.9.4"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"time": "2022-12-17T13:33:52+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
}

View file

@ -480,12 +480,12 @@ les possibilités de contribution.</para>
/**
* Args autocompleter for CLI my_custom_cli_cmd command
*
* @param array $command_args List of already typed words of the command
* @param array[string] $command_args List of already typed words of the command
* @param int $comp_word_num The command word number to autocomplete
* @param string $comp_word The command word to autocomplete
* @param array $opts List of global available options
* @param array[string] $opts List of global available options
*
* @return array List of available options for the word to autocomplete
* @return array[string] List of available options for the word to autocomplete
**/
public static function cli_my_custom_cli_cmd_autocompleter($command_args, $comp_word_num, $comp_word, $opts) {
$opts = array_merge($opts, array ('-f', '--force'));

View file

@ -8,7 +8,7 @@ RUN wget -O - http://ldapsaisie.org/debian/ldapsaisie.gpg.key | apt-key add -
COPY apt.list /etc/apt/sources.list.d/ldapsaisie.list
RUN apt-get update
# Install dependencies
RUN DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get install -y git slapd apache2 php-ldap libapache2-mod-php php-cli smarty3 php-net-ldap2 php-net-ftp php-mail php-mail-mime php-console-table ldapvi locales sed bash-completion liquidprompt vim curl jq iproute2 net-tools
RUN DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get install -y git slapd apache2 php-ldap libapache2-mod-php php-cli smarty3 php-net-ldap2 php-net-ftp php-mail php-mail-mime php-console-table ldapvi locales sed bash-completion liquidprompt vim curl jq iproute2 net-tools composer php-cas php-zxcvbn php-phpseclib
# Add fr_FR* locales
RUN sed -i 's/^# fr_FR/fr_FR/' /etc/locale.gen
RUN locale-gen

View file

@ -1,32 +0,0 @@
parameters:
level: 1
paths:
- src
excludePaths:
- src/local
- src/tmp
# Error message "Class Smarty_Resource_LdapSaisie extends unknown class Smarty_Resource_Custom." cannot be ignored, use excludePaths instead.
- src/includes/class/class.LStemplate_smarty3_support.php
bootstrapFiles:
- src/includes/core.php
universalObjectCratesClasses:
- LSsearch
- LSsearchEntry
- LSrelation
- LSlog_handler
- LSlog_logger
- LSldapObject
- LSurlRequest
ignoreErrors:
- "#Instantiated class (Smarty|Console_Table|ZxcvbnPhp\\\\Zxcvbn|phpseclib\\\\Crypt\\\\RSA|phpseclib\\\\Net\\\\SFTP|phpseclib\\\\Net\\\\SSH2|Net_FTP) not found\\.#"
- "#Call to static method (connect|isError)\\(\\) on an unknown class Net_LDAP2\\.#"
- "#(Class|Constant) (Net_LDAP2_Filter|Net_LDAP2_Entry|PEAR_Error) not found\\.#"
- "#Call to static method (create|parse|combine|escape)\\(\\) on an unknown class Net_LDAP2_Filter\\.#"
- "#Call to static method (createFresh)\\(\\) on an unknown class Net_LDAP2_Entry\\.#"
- "#Call to static method (forceAuthentication|getUser|logout|setDebug|client|setNoCasServerValidation|setCasServerCACert|setExtraCurlOption)\\(\\) on an unknown class phpCAS\\.#"
-
message: "#Call to static method factory\\(\\) on an unknown class Mail\\.#"
path: src/includes/addons/LSaddons.mail.php
-
message: "#Instantiated class Mail_mime not found\\.#"
path: src/includes/addons/LSaddons.mail.php

View file

@ -24,16 +24,19 @@
// Support
LSerror :: defineError('ASTERISK_SUPPORT_01',
___("Asterisk Support : The constant %{const} is not defined.")
___("Asterisk Support: The constant %{const} is not defined.")
);
LSerror :: defineError('ASTERISK_01',
___("Asterisk : The function %{function} only work with %{objectName}.")
___("Asterisk: The function %{function} only work with %{objectName}.")
);
LSerror :: defineError('ASTERISK_02',
___("Asterisk : The attribute %{dependency} is missing. Unable to generate MD5 hashed password.")
___("Asterisk: The attribute %{dependency} is missing. Unable to generate MD5 hashed password.")
);
LSerror :: defineError('ASTERISK_03',
___("Asterisk : Clear password not availlable. Unable to generate MD5 hashed password.")
___("Asterisk: Clear password not availlable. Unable to generate MD5 hashed password.")
);
LSerror :: defineError('ASTERISK_04',
___("Asterisk: The LDAP attribute type of the attribute %{attr} is incorrect: its must be password.")
);
/**
@ -104,6 +107,16 @@ LSerror :: defineError('ASTERISK_03',
return;
}
if (
!is_a(
$ldapObject -> attrs[ LS_ASTERISK_USERPASSWORD_ATTR ] -> ldap,
'LSattr_ldap_password'
)
) {
LSerror :: addErrorCode('ASTERISK_04', LS_ASTERISK_USERPASSWORD_ATTR);
return;
}
$password = $ldapObject -> attrs[ LS_ASTERISK_USERPASSWORD_ATTR ] -> ldap -> getClearPassword();
if (!$password) {
LSerror :: addErrorCode('ASTERISK_03');

View file

@ -81,7 +81,7 @@ function LSaddon_mailquota_support() {
/**
* Get IMAP mailbox usage
*
* @param LSldapObject $ldapobject The LDAP object
* @param LSldapObject &$LSldapObject The LDAP object
*
* @return array|false Array with mailbox usage and quota, or false
**/
@ -144,7 +144,7 @@ function mailquota_get_usage(&$LSldapObject) {
* [...]
* );
*
* @param LSldapObject $ldapobject The LDAP object
* @param LSldapObject &$LSldapObject The LDAP object
*
* @return true in any case
**/

View file

@ -112,7 +112,7 @@ function get_ppolicy_object($dn) {
/**
* Retrieve ppolicy password max age
*
* @param string $dn Optional DN of the ppolicy object to use
* @param string|null $ppolicy_dn Optional DN of the ppolicy object to use
*
* @return int|null|false The ppolicy password max age (in second) if defined, null if no password max age is defined or false in case of error
*
@ -134,9 +134,9 @@ function get_ppolicy_password_max_age($ppolicy_dn=null) {
/**
* Format and return HTML code of a badge
*
* @param string $dn The text of the badge
* @param string $dn The background color of the badge (optional, default: green)
* @param string $dn The text color of the badge (optional, default: white)
* @param string $text The text of the badge
* @param string $bg_color The background color of the badge (optional, default: green)
* @param string $color The text color of the badge (optional, default: white)
*
* @return string The HTML code of the badge
*
@ -195,6 +195,8 @@ function ppolicy_extraDisplayColumn_password_expiration($entry) {
* Write LSsearch result as CSV and force download of it.
*
* @param LSsearch $LSsearch The LSsearch object
* @param boolean $as_csv True for CSV export, False for JSON export
* @param boolean $return Set to true to return data instead of trigger the download of it
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
@ -432,12 +434,12 @@ function cli_export_ppolicy_info($command_args) {
/**
* Args autocompleter for CLI export_ppolicy_info command
*
* @param string $dn List of already typed words of the command
* @param string $dn The command word number to autocomplete
* @param string $dn The command word to autocomplete
* @param string $dn List of global available options
* @param array[string] $command_args List of already typed words of the command
* @param int $comp_word_num The command word number to autocomplete
* @param string $comp_word The command word to autocomplete
* @param array[string] $opts List of global available options
*
* @return array List of available options for the word to autocomplete
* @return array[string] List of available options for the word to autocomplete
**/
function cli_export_ppolicy_info_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) {
$opts = array_merge($opts, array ('-o', '--output', '-j', '--json', '-p', '--pretty'));

View file

@ -36,16 +36,19 @@ LSerror :: defineError('SAMBA_SUPPORT_03',
// Autres erreurs
LSerror :: defineError('SAMBA_01',
___("SAMBA Support: The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.")
___("SAMBA: The attribute %{dependency} is missing. Unable to forge the attribute %{attr}.")
);
LSerror :: defineError('SAMBA_02',
___("SAMBA Support: Can't get the sambaUnixIdPool object.")
___("SAMBA: Can't get the sambaUnixIdPool object.")
);
LSerror :: defineError('SAMBA_03',
___("SAMBA Support: Error modifying the sambaUnixIdPool object.")
___("SAMBA: Error modifying the sambaUnixIdPool object.")
);
LSerror :: defineError('SAMBA_04',
___("SAMBA Support: The %{attr} of the sambaUnixIdPool object is incorrect.")
___("SAMBA: The %{attr} of the sambaUnixIdPool object is incorrect.")
);
LSerror :: defineError('SAMBA_05',
___("SAMBA: The LDAP attribute type of the attribute %{attr} is incorrect: its must be password.")
);
// CONSTANTES
@ -110,7 +113,7 @@ function LSaddon_samba_support() {
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
*
* @author Benjamin Renard <brenard@easter-eggs.com>
* @param LSldapObjet $ldapObject The LSldapObjet object
* @param LSldapObject $ldapObject The LSldapObject object
* @param string $unix_attr The UNIX attribute name
* @param integer $base_number The base number value
*
@ -139,7 +142,7 @@ function generate_sambaSID($ldapObject, $unix_attr, $base_number) {
* Number = LS_SAMBA_UIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_USER
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return string User SambaSID value on success, false otherwise
@ -156,7 +159,7 @@ function generate_user_sambaSID($ldapObject) {
* Number = LS_SAMBA_UIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_USER
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return string User SambaSID value on success, false otherwise
@ -179,7 +182,7 @@ function generate_sambaUserSID($ldapObject) {
* Number = LS_SAMBA_GIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_GROUP
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
*
* @param LSldapObjet $ldapObject The group LSldapObjet object
* @param LSldapObject $ldapObject The group LSldapObject object
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return string Group SambaSID value on success, false otherwise
@ -194,7 +197,7 @@ function generate_group_sambaSID($ldapObject) {
* Note: old-name of the function keep for retro-compatibility. An error
* message is raised when this function is used.
*
* @param LSldapObjet $ldapObject The group LSldapObjet object
* @param LSldapObject $ldapObject The group LSldapObject object
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return string Group SambaSID value on success, false otherwise
@ -217,7 +220,7 @@ function generate_sambaGroupSID($ldapObject) {
* Number = LS_SAMBA_GIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_GROUP
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
*
* @param LSldapObjet $ldapObject The LSldapObjet object
* @param LSldapObject $ldapObject The LSldapObject object
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return string The sambaPrimaryGroupSID value on success, false otherwise
@ -232,7 +235,7 @@ function generate_sambaPrimaryGroupSID($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return string|false sambaNTPassword value on success, false otherwise
*/
@ -242,6 +245,15 @@ function generate_sambaPrimaryGroupSID($ldapObject) {
return;
}
if (
!is_a(
$ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ] -> ldap,
'LSattr_ldap_password'
)
) {
LSerror :: addErrorCode('SAMBA_05', LS_SAMBA_USERPASSWORD_ATTR);
return;
}
$password = $ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ] -> ldap -> getClearPassword();
$sambapassword = new smbHash;
$sambaNTPassword = $sambapassword -> nthash($password);
@ -257,7 +269,7 @@ function generate_sambaPrimaryGroupSID($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return string|false sambaLMPassword value on success, false otherwise
*/
@ -267,6 +279,16 @@ function generate_sambaPrimaryGroupSID($ldapObject) {
return;
}
if (
!is_a(
$ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ] -> ldap,
'LSattr_ldap_password'
)
) {
LSerror :: addErrorCode('SAMBA_05', LS_SAMBA_USERPASSWORD_ATTR);
return;
}
$password = $ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ] -> ldap -> getClearPassword();
$sambapassword = new smbHash;
$sambaLMPassword = $sambapassword -> lmhash($password);
@ -282,7 +304,7 @@ function generate_sambaPrimaryGroupSID($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $unix_attr The sambaUnixIdPool attribute name that contain next ID value
* @param string $attr The sambaUnixIdPool attribute name that contain next ID value
*
* @return integer UNIX ID value on success, false otherwise
*/
@ -295,12 +317,12 @@ function get_samba_unix_pool_next_id($attr) {
}
$next_id = $unix_id_pool->getValue($attr, 'single');
if (Net_LDAP2::isError($next_id) || $next_id == 0) {
if (Net_LDAP2::isError($next_id) || $next_id == '0') {
LSerror :: addErrorCode('SAMBA_04', $attr);
return;
}
$unix_id_pool->replace(array($attr => ($next_id+1)));
$unix_id_pool->replace(array($attr => (intval($next_id) + 1)));
$res = $unix_id_pool->update();
if(!Net_LDAP2::isError($res)) {
return $next_id;
@ -316,7 +338,7 @@ function get_samba_unix_pool_next_id($attr) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return integer|false uidNumber value on success, false otherwise
*/
@ -332,7 +354,7 @@ function generate_samba_uidNumber($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return integer|false uidNumber value on success, false otherwise
*/
@ -353,7 +375,7 @@ function generate_uidNumber_withSambaDomainObject($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return integer|false gidNumber value on success, false otherwise
*/
@ -369,7 +391,7 @@ function generate_samba_gidNumber($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return integer|false gidNumber value on success, false otherwise
*/
@ -457,7 +479,7 @@ function generate_sambaDomainName($anything) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return string The sambaHomePath attribute value
*/
@ -470,7 +492,7 @@ function generate_sambaHomePath($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return string The sambaProfilePath attribute value
*/
@ -484,7 +506,7 @@ function generate_sambaProfilePath($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return string The shadowExpire attribute value
*/
@ -500,7 +522,7 @@ function generate_shadowExpire_from_sambaPwdMustChange($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return string Timestamp corresponding to shadowExpire
*/
@ -517,7 +539,7 @@ function generate_timestamp_from_shadowExpire($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return string The sambaPwdMustChange attribute value
*/
@ -531,7 +553,7 @@ function generate_sambaPwdMustChange_from_shadowExpire($ldapObject) {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObjet $ldapObject The user LSldapObjet object
* @param LSldapObject $ldapObject The user LSldapObject object
*
* @return string The sambaKickoffTime attribute value
*/

View file

@ -163,7 +163,7 @@ LSerror :: defineError('SSH_07',
return false;
}
if (isset($sftp))
if ($sftp)
$cnx = new SFTP($host, $port, $timeout);
else
$cnx = new SSH2($host, $port, $timeout);
@ -182,12 +182,12 @@ LSerror :: defineError('SSH_07',
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param array $params Connection parameters
* @param array $connection_params Connection parameters
* @param array|string $dirs The directory/ies to add
* @param boolean $sftp The directory/ies mode as an octal number (do not forget leading zero,
* @param int $chmod The directory/ies mode as an octal number (do not forget leading zero,
* example: 0755 or 02755, default : default umask on the SSH server)
* @param boolean $sftp Enable recursive mode (default : false)
* @param boolean $sftp Enable continue mode : do not on error (default : false)
* @param boolean $recursive Enable recursive mode (default : false)
* @param boolean $continue Enable continue mode : do not on error (default : false)
*
* @return boolean
*/
@ -216,10 +216,10 @@ LSerror :: defineError('SSH_07',
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param array $params Connection parameters
* @param array $connection_params Connection parameters
* @param array|string $dirs The directory/ies to remove
* @param boolean $sftp Enable recursive mode (default : false)
* @param boolean $sftp Enable continue mode : do not on error (default : false)
* @param boolean $recursive Enable recursive mode (default : false)
* @param boolean $continue Enable continue mode : do not on error (default : false)
*
* @return boolean
*/
@ -248,9 +248,9 @@ LSerror :: defineError('SSH_07',
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param array $params Connection parameters
* @param array $params The actual directory path to rename
* @param array $params The new directory path
* @param array $connection_params Connection parameters
* @param string $old The actual directory path to rename
* @param string $new The new directory path
*
* @return boolean
*/
@ -272,8 +272,8 @@ LSerror :: defineError('SSH_07',
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param array $params Connection parameters
* @param array $params The command to run on remote server
* @param array $connection_params Connection parameters
* @param string $cmd The command to run on remote server
*
* @return mixed False if connection fail and an array otherwise, with
* exit code as first value and the command outup as second

View file

@ -277,7 +277,7 @@ function generate_eduPersonOrgDN($ldapObject) {
*
* {SUPANN}S410
*
* @param string $val La valeur
* @param string $value La valeur
*
* @return array Un tableau cle->valeur contenant label et value ou False
**/
@ -522,7 +522,7 @@ function supannSearchParrainByPattern($pattern, $max_matches=10) {
* @param string $label L'étiquette de la valeur (optionnel)
* @param string $value La valeur
*
* @return booleab True si valide, False sinon
* @return bool True si valide, False sinon
**/
function supannValidateNomenclatureValue($table, $label, $value) {
if (!supannLoadNomenclature($table))

View file

@ -29,23 +29,39 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass');
*/
class LSattr_html extends LSlog_staticLoggerClass {
// The attribute name
var $name;
/**
* The attribute name
* @var string
*/
var string $name;
// The attribute configuration
var $config;
/**
* Attribute configuration (LSobjects.<type>.attrs.<attr_name>)
* @var array<string,mixed>
*/
var array $config;
// The reference of the parent LSattribute object
var $attribute;
/**
* The reference of the parent LSattribute object
* @var LSattribute
*/
var LSattribute $attribute;
// The corresponding LSformElement object type
var $LSformElement_type = false;
/**
* The corresponding LSformElement object type
* Note: Must be set in implemented classes
* @var string
*/
var string $LSformElement_type = '';
// If true, this LSattr_html type is considered as able to only support
// the first and unique value of the attribute. If more than one value
// is passed to this LSattr_html type, an LSattr_html_03 error will be
// triggered.
protected $singleValue = false;
/**
* If true, this LSattr_html type is considered as able to only support
* the first and unique value of the attribute. If more than one value
* is passed to this LSattr_html type, an LSattr_html_03 error will be
* triggered.
* @var bool
*/
protected bool $singleValue = false;
/**
* Constructeur
@ -123,7 +139,7 @@ class LSattr_html extends LSlog_staticLoggerClass {
/**
* Effectue les tâches nécéssaires au moment du rafraichissement du formulaire
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur formatée de l'attribut
**/
@ -145,9 +161,9 @@ class LSattr_html extends LSlog_staticLoggerClass {
/**
* Return a configuration parameter (or default value)
*
* @param[] $param The configuration parameter
* @param[] $default The default value (default : null)
* @param[] $cast Cast resulting value in specific type (default : disabled)
* @param string $param The configuration parameter
* @param mixed $default The default value (default : null)
* @param string $cast Cast resulting value in specific type (default : disabled)
*
* @return mixed The configuration parameter value or default value if not set
**/

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_boolean extends LSattr_html {
var $LSformElement_type = 'boolean';
var string $LSformElement_type = 'boolean';
}

View file

@ -27,7 +27,7 @@
*/
class LSattr_html_date extends LSattr_html {
var $LSformElement_type = 'date';
var string $LSformElement_type = 'date';
/**
* Ajoute l'attribut au formualaire passer en paramètre
@ -36,7 +36,7 @@ class LSattr_html_date extends LSattr_html {
* @param string $idForm L'identifiant du formulaire
* @param array|string|null $data Valeur du champs du formulaire
*
* @return LSformElement L'element du formulaire ajouté
* @return LSformElement_date L'element du formulaire ajouté
*/
function addToForm (&$form,$idForm,$data=NULL) {
$element = parent::addToForm($form,$idForm,$data);
@ -46,8 +46,8 @@ class LSattr_html_date extends LSattr_html {
array(
'msg' => _('Invalid value'),
'params' => array(
'format' => $element -> getFormat(),
'special_values' => array_keys($element -> getSpecialValues()),
'format' => $element -> getFormat(), // @phpstan-ignore-line
'special_values' => array_keys($element -> getSpecialValues()), // @phpstan-ignore-line
)
)
);

View file

@ -27,7 +27,7 @@
*/
class LSattr_html_image extends LSattr_html {
var $LSformElement_type = 'image';
protected $singleValue = true;
var string $LSformElement_type = 'image';
protected bool $singleValue = true;
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_jsonCompositeAttribute extends LSattr_html {
var $LSformElement_type = 'jsonCompositeAttribute';
var string $LSformElement_type = 'jsonCompositeAttribute';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_labeledValue extends LSattr_html {
var $LSformElement_type = 'labeledValue';
var string $LSformElement_type = 'labeledValue';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_mail extends LSattr_html {
var $LSformElement_type = 'mail';
var string $LSformElement_type = 'mail';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_mailQuota extends LSattr_html {
var $LSformElement_type = 'mailQuota';
var string $LSformElement_type = 'mailQuota';
}

View file

@ -29,7 +29,12 @@ LSsession :: loadLSaddon('maildir');
*/
class LSattr_html_maildir extends LSattr_html {
var $LSformElement_type = 'maildir';
var string $LSformElement_type = 'maildir';
/**
* Registered actions to do on object events
* @var array
*/
var $_toDo = array();
public function __construct($name, $config, &$attribute) {

View file

@ -27,7 +27,7 @@
*/
class LSattr_html_password extends LSattr_html {
var $LSformElement_type = 'password';
protected $singleValue = true;
var string $LSformElement_type = 'password';
protected bool $singleValue = true;
}

View file

@ -29,6 +29,6 @@ LSsession :: loadLSclass('LSattr_html_textarea');
*/
class LSattr_html_postaladdress extends LSattr_html_textarea {
var $LSformElement_type = 'postaladdress';
var string $LSformElement_type = 'postaladdress';
}

View file

@ -29,6 +29,6 @@ LSsession :: loadLSclass('LSattr_html_textarea');
*/
class LSattr_html_pre extends LSattr_html_textarea {
var $LSformElement_type = 'pre';
var string $LSformElement_type = 'pre';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_quota extends LSattr_html {
var $LSformElement_type = 'quota';
var string $LSformElement_type = 'quota';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_rss extends LSattr_html {
var $LSformElement_type = 'rss';
var string $LSformElement_type = 'rss';
}

View file

@ -27,14 +27,14 @@ LSsession :: loadLSclass('LSattr_html_select_box');
*/
class LSattr_html_sambaAcctFlags extends LSattr_html_select_box {
var $LSformElement_type = 'sambaAcctFlags';
var string $LSformElement_type = 'sambaAcctFlags';
/**
* Retourne un tableau des valeurs possibles de la liste
*
* @param array $options Attribute options (optional)
* @param string $name Attribute name (optional)
* @param LSldapObject &$ldapObject Related LSldapObject (optional)
* @param array|false $options Attribute options (optional)
* @param string|false $name Attribute name (optional)
* @param LSldapObject|false &$ldapObject Related LSldapObject (optional)
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*

View file

@ -33,6 +33,6 @@ LSsession :: loadLSclass('LSattr_html_select_list');
*/
class LSattr_html_select_box extends LSattr_html_select_list {
var $LSformElement_type = 'select_box';
var string $LSformElement_type = 'select_box';
}

View file

@ -42,7 +42,7 @@
*/
class LSattr_html_select_list extends LSattr_html{
var $LSformElement_type = 'select';
var string $LSformElement_type = 'select';
/**
* Ajoute l'attribut au formualaire passer en paramètre
@ -84,9 +84,9 @@ class LSattr_html_select_list extends LSattr_html{
/**
* Return array of possible values with translated labels (if enabled)
*
* @param array $options Attribute HTML options (optional)
* @param string $name Attribute name (optional)
* @param LSldapObject &$ldapObject Related LSldapObject (optional)
* @param array|false $options Attribute HTML options (optional)
* @param string|false $name Attribute name (optional)
* @param LSldapObject|false &$ldapObject Related LSldapObject (optional)
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
@ -302,7 +302,7 @@ class LSattr_html_select_list extends LSattr_html{
* @param string|array $attr OTHER_ATTRIBUTE configuration value
* @param array|false $options Attribute HTML options
* @param string $name Attribute name
* @param LSform &$form reference
* @param LSldapObject &$ldapObject The related LSldapObject reference
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*

View file

@ -27,8 +27,14 @@
*/
class LSattr_html_select_object extends LSattr_html{
var $LSformElement_type = 'select_object';
var $unrecognizedValues=false;
var string $LSformElement_type = 'select_object';
/**
* Array of unrecognized values
* @see LSattr_html_select_object::getFormValues()
* @var array<int,string>
*/
var array $unrecognizedValues = array();
/**
* Ajoute l'attribut au formualaire passer en paramètre
@ -61,7 +67,7 @@ class LSattr_html_select_object extends LSattr_html{
* Récupère un array du type array('DNs' => 'displayName') à partir d'une
* liste de DNs.
*
* @param mixed $data La valeur de l'attribut (liste de DNs)
* @param mixed $data The attribute value (liste de DNs)
*
* @return mixed La valeur formatée de l'attribut (array('DNs' => 'displayName'))
**/

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_ssh_key extends LSattr_html {
var $LSformElement_type = 'ssh_key';
var string $LSformElement_type = 'ssh_key';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannActivite extends LSattr_html {
var $LSformElement_type = 'supannActivite';
var string $LSformElement_type = 'supannActivite';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannAdressePostalePrivee extends LSattr_html {
var $LSformElement_type = 'supannAdressePostalePrivee';
var string $LSformElement_type = 'supannAdressePostalePrivee';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannCodePopulation extends LSattr_html {
var $LSformElement_type = 'supannCodePopulation';
var string $LSformElement_type = 'supannCodePopulation';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEmpCorps extends LSattr_html {
var $LSformElement_type = 'supannEmpCorps';
var string $LSformElement_type = 'supannEmpCorps';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEmpProfil extends LSattr_html {
var $LSformElement_type = 'supannEmpProfil';
var string $LSformElement_type = 'supannEmpProfil';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEtablissement extends LSattr_html {
var $LSformElement_type = 'supannEtablissement';
var string $LSformElement_type = 'supannEtablissement';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEtuDiplome extends LSattr_html {
var $LSformElement_type = 'supannEtuDiplome';
var string $LSformElement_type = 'supannEtuDiplome';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEtuElementPedagogique extends LSattr_html {
var $LSformElement_type = 'supannEtuElementPedagogique';
var string $LSformElement_type = 'supannEtuElementPedagogique';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEtuEtape extends LSattr_html {
var $LSformElement_type = 'supannEtuEtape';
var string $LSformElement_type = 'supannEtuEtape';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEtuInscription extends LSattr_html {
var $LSformElement_type = 'supannEtuInscription';
var string $LSformElement_type = 'supannEtuInscription';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEtuRegimeInscription extends LSattr_html {
var $LSformElement_type = 'supannEtuRegimeInscription';
var string $LSformElement_type = 'supannEtuRegimeInscription';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEtuSecteurDisciplinaire extends LSattr_html {
var $LSformElement_type = 'supannEtuSecteurDisciplinaire';
var string $LSformElement_type = 'supannEtuSecteurDisciplinaire';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannEtuTypeDiplome extends LSattr_html {
var $LSformElement_type = 'supannEtuTypeDiplome';
var string $LSformElement_type = 'supannEtuTypeDiplome';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannExtProfil extends LSattr_html {
var $LSformElement_type = 'supannExtProfil';
var string $LSformElement_type = 'supannExtProfil';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannLabeledValue extends LSattr_html {
var $LSformElement_type = 'supannLabeledValue';
var string $LSformElement_type = 'supannLabeledValue';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannMailPrive extends LSattr_html {
var $LSformElement_type = 'supannMailPrive';
var string $LSformElement_type = 'supannMailPrive';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannRessourceEtat extends LSattr_html {
var $LSformElement_type = 'supannRessourceEtat';
var string $LSformElement_type = 'supannRessourceEtat';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannRessourceEtatDate extends LSattr_html {
var $LSformElement_type = 'supannRessourceEtatDate';
var string $LSformElement_type = 'supannRessourceEtatDate';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannRoleEntite extends LSattr_html {
var $LSformElement_type = 'supannRoleEntite';
var string $LSformElement_type = 'supannRoleEntite';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannRoleGenerique extends LSattr_html {
var $LSformElement_type = 'supannRoleGenerique';
var string $LSformElement_type = 'supannRoleGenerique';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannTelephonePrive extends LSattr_html {
var $LSformElement_type = 'supannTelephonePrive';
var string $LSformElement_type = 'supannTelephonePrive';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_supannTypeEntite extends LSattr_html {
var $LSformElement_type = 'supannTypeEntite';
var string $LSformElement_type = 'supannTypeEntite';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_tel extends LSattr_html {
var $LSformElement_type = 'tel';
var string $LSformElement_type = 'tel';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_text extends LSattr_html {
var $LSformElement_type = 'text';
var string $LSformElement_type = 'text';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_textarea extends LSattr_html {
var $LSformElement_type = 'textarea';
var string $LSformElement_type = 'textarea';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_url extends LSattr_html {
var $LSformElement_type = 'url';
var string $LSformElement_type = 'url';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_valueWithUnit extends LSattr_html {
var $LSformElement_type = 'valueWithUnit';
var string $LSformElement_type = 'valueWithUnit';
}

View file

@ -29,6 +29,6 @@ LSsession :: loadLSclass('LSattr_html_textarea');
*/
class LSattr_html_wysiwyg extends LSattr_html_textarea {
var $LSformElement_type = 'wysiwyg';
var string $LSformElement_type = 'wysiwyg';
}

View file

@ -27,6 +27,6 @@
*/
class LSattr_html_xmpp extends LSattr_html {
var $LSformElement_type = 'xmpp';
var string $LSformElement_type = 'xmpp';
}

View file

@ -23,15 +23,29 @@
LSsession :: loadLSclass('LSlog_staticLoggerClass');
/**
* Base d'un type d'attribut Ldap
* Basic implementatin of a LDAP attribute type
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_ldap extends LSlog_staticLoggerClass {
var $name;
var $config;
var $attribute;
/**
* LDAP attribute name
* @var string
*/
var string $name;
/**
* Attribute configuration (LSobjects.<type>.attrs.<attr_name>)
* @var array<string,mixed>
*/
var array $config;
/**
* The reference of the parent LSattribute object
* @var LSattribute
*/
var LSattribute $attribute;
/**
* Constructeur
@ -63,22 +77,22 @@ class LSattr_ldap extends LSlog_staticLoggerClass {
}
/**
* Retourne la valeur de l'attribut après traitement lié à son type ldap
* Return the update value of the attribute after handling it acording to its LDAP type
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur traitée de l'attribut
* @return mixed The processed attribute value
*/
public function getUpdateData($data) {
return ensureIsArray($data);
}
/**
* Retourne la valeur d'affichage de l'attribut après traitement lié à son type ldap
* Return the display value of the attribute after handling it acording to its LDAP type
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur d'affichage de l'attribut
* @return mixed The display value of the attribute
*/
public function getDisplayValue($data) {
return ensureIsArray($data);
@ -103,9 +117,9 @@ class LSattr_ldap extends LSlog_staticLoggerClass {
/**
* Return a configuration parameter (or default value)
*
* @param[] $param The configuration parameter
* @param[] $default The default value (default : null)
* @param[] $cast Cast resulting value in specific type (default : disabled)
* @param string $param The configuration parameter
* @param mixed $default The default value (default : null)
* @param string $cast Cast resulting value in specific type (default : disabled)
*
* @return mixed The configuration parameter value or default value if not set
**/

View file

@ -21,20 +21,20 @@
******************************************************************************/
/**
* Type d'attribut Ldap compositeValueToJSON
* Convertit les attributes composite du format suivant :
* LDAP attribute type compositeValueToJSON
* Convert the composite attributes in the following format:
* [key1=value1][key2=value2]..
* Au format JSON (utilisable par le LSformElement_jsonCompositeAttribute ) :
* To JSON format (usable with LSattr_jsonCompositeAttribute):
* {"key1":"value1","key2":"value2"}
*/
class LSattr_ldap_compositeValueToJSON extends LSattr_ldap {
/**
* Retourne la valeur d'affichage de l'attribut après traitement lié à son type ldap
* Return the display value of the attribute after handling it acording to its LDAP type
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur d'affichage de l'attribut
* @return mixed The display value of the attribute
*/
public function getDisplayValue($data) {
$ret = array();
@ -44,11 +44,11 @@ class LSattr_ldap_compositeValueToJSON extends LSattr_ldap {
}
/**
* Retourne la valeur de l'attribut après traitement lié à son type ldap
* Return the update value of the attribute after handling it acording to its LDAP type
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur traitée de l'attribut
* @return mixed The processed attribute value
*/
public function getUpdateData($data) {
$ret = array();
@ -57,6 +57,11 @@ class LSattr_ldap_compositeValueToJSON extends LSattr_ldap {
return $ret;
}
/**
* Parse a value
* @param string $value The value to parse
* @return array|null The parse value as array, or null in case of error
*/
public static function parseValue($value) {
if (preg_match_all('/\[([^=]*)=([^\]]*)\]/', $value, $matches)) {
$parseValue = array();
@ -68,6 +73,11 @@ class LSattr_ldap_compositeValueToJSON extends LSattr_ldap {
return;
}
/**
* Compute a composite value
* @param array $value The value to encode
* @return string|false The computed composite value as string, or False in case of error
*/
public static function encodeValue($value) {
if (is_array($value)) {
$ret = "";

View file

@ -21,17 +21,17 @@
******************************************************************************/
/**
* Type d'attribut Ldap date
* LDAP attribute type date
*
*/
class LSattr_ldap_date extends LSattr_ldap {
/**
* Retourne la valeur d'affichage de l'attribut après traitement lié à son type ldap
* Return the display value of the attribute after handling it acording to its LDAP type
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur d'affichage de l'attribut
* @return mixed The display value of the attribute
*/
public function getDisplayValue($data) {
$data = ensureIsArray($data);
@ -49,11 +49,11 @@ class LSattr_ldap_date extends LSattr_ldap {
}
/**
* Retourne la valeur de l'attribut après traitement lié à son type ldap
* Return the update value of the attribute after handling it acording to its LDAP type
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur traitée de l'attribut
* @return mixed The processed attribute value
*/
public function getUpdateData($data) {
$data = ensureIsArray($data);
@ -76,9 +76,9 @@ class LSattr_ldap_date extends LSattr_ldap {
}
/**
* Retourne le format de stockage de la date
* Return the storage date format
*
* @return string Le format de la date
* @return string The storage date format
**/
public function getFormat() {
return $this -> getConfig('ldap_options.format', 'YmdHisO');

View file

@ -21,7 +21,7 @@
******************************************************************************/
/**
* Type d'attribut Ldap image
* LDAP attribute type image
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/

View file

@ -21,7 +21,7 @@
******************************************************************************/
/**
* Type d'attribut Ldap numeric
* LDAP attribute type numeric
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/

View file

@ -26,7 +26,13 @@
*/
class LSattr_ldap_password extends LSattr_ldap {
var $clearPassword = NULL;
/**
* Cache of the new password in raw format (=clear, not hashed)
* @see LSattr_ldap_password::getUpdateData()
* @see LSattr_ldap_password::getClearPassword()
* @var string
*/
private string $clearPassword = '';
/**
* Return the display value of this attribute
@ -84,9 +90,11 @@ class LSattr_ldap_password extends LSattr_ldap {
* Note : Password encoding was strongly inspired of the project phpLdapAdmin.
* URL : http://phpldapadmin.sourceforge.net/
*
* @param mixed $data The clear password
* @param string $clearPassword The clear password
* @param string|null $encode The encoding type
* @param callable $encode_function The encoding callable
*
* @return strinf The encode password
* @return string The encode password
*/
public function encodePassword($clearPassword, $encode=null, $encode_function=null, $salt=null) {
if (is_null($encode))
@ -238,6 +246,12 @@ class LSattr_ldap_password extends LSattr_ldap {
return $clearPassword;
}
/**
* Verify if the clear specified password match with specified hashed password(s)
* @param string $clearPassword The clear password to check
* @param string|array|null $hashedPassword The hashed password(s) (optional, default: check againt attibute values)
* @return bool True if clear password matched, False otherwise
*/
function verify($clearPassword, $hashedPassword=null) {
// If $hashedPassword is not provided, use attribute values
if (is_null($hashedPassword))

View file

@ -21,17 +21,17 @@
******************************************************************************/
/**
* Type d'attribut Ldap postaladdress
* RFC4519 : les retours a la ligne sont remplace par des '$'
* LDAP attribute type postaladdress
* See RFC4519: Line returns are replaced with '$'.
*/
class LSattr_ldap_postaladdress extends LSattr_ldap {
/**
* Retourne la valeur d'affichage de l'attribut après traitement lié à son type ldap
* Return the display value of the attribute after handling it acording to its LDAP type
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur d'affichage de l'attribut
* @return mixed The display value of the attribute
*/
public function getDisplayValue($data) {
$ret = array();
@ -41,11 +41,11 @@ class LSattr_ldap_postaladdress extends LSattr_ldap {
}
/**
* Retourne la valeur de l'attribut après traitement lié à son type ldap
* Return the update value of the attribute after handling it acording to its LDAP type
*
* @param mixed $data La valeur de l'attribut
* @param mixed $data The attribute value
*
* @return mixed La valeur traitée de l'attribut
* @return mixed The processed attribute value
*/
public function getUpdateData($data) {
$ret = array();

View file

@ -84,6 +84,11 @@ class LSattr_ldap_pwdHistory extends LSattr_ldap {
);
}
/**
* Encode a value
* @param array $value The value to encode
* @return string The encoded value
*/
public function encodeValue($value) {
if (!is_array($value)) {
self :: log_warning($this."->encodeValue($value): Provided value is not an array.");
@ -91,7 +96,7 @@ class LSattr_ldap_pwdHistory extends LSattr_ldap {
}
$datetime = date_create_from_format('YmdHisO', $value['time']);
if (!is_a($datetime, 'DateTime')) {
self :: log_warning($this."->encodeValue($value): Fail to create DateTime object from timestamp '".varDump($value['time'])."'.");
self :: log_warning($this."->encodeValue(".varDump($value)."): Fail to create DateTime object from timestamp '".varDump($value['time'])."'.");
return;
}
$datetime -> setTimezone('UTC');

View file

@ -21,7 +21,7 @@
******************************************************************************/
/**
* LDAP Attribute shadowExpire
* LDAP attribute type shadowExpire
*
* This class permit to manage shadowExpire attribute as a timestamp, and consequently
* permit to use LSattr_html_date to manage it value in the interface.

View file

@ -33,18 +33,93 @@ LSsession :: loadLSclass('LSattr_html');
*/
class LSattribute extends LSlog_staticLoggerClass {
var $name;
var $config;
var $ldapObject;
var $ldap;
var $html;
var $data;
/**
* Attribute name
* @var string
*/
var string $name;
/**
* Attribute configuration (LSobjects.<type>.attrs.<attr_name>)
* @var array<string,mixed>
*/
var array $config;
/**
* The reference of the parent LSldapObject object
* @var LSldapObject
*/
var LSldapObject $ldapObject;
/**
* The implemented LSattr_ldap object
* @see LSattribute::__construct()
* @var LSattr_ldap
*/
var LSattr_ldap $ldap;
/**
* The implemented LSattr_ldap object
* @see LSattribute::__construct()
* @var LSattr_html
*/
var LSattr_html $html;
/**
* Attribute data
* @var array
*/
var array $data;
/**
* Attribute updated data
* @see LSattribute::setUpdateData()
* @see LSattribute::getUpdateData()
* @see LSattribute::isUpdate()
* @see LSattribute::reloadData()
* @see LSattribute::generateValue()
* @var array|false
*/
var $updateData=false;
var $is_validate=false;
var $_finalUpdateData=false;
var $_myRights=NULL;
var $_events=array();
var $_objectEvents=array();
/**
* Telltale of the validation state of the new attibute data
* @see LSattribute::validate()
* @see LSattribute::isValidate()
* @see LSattribute::reloadData()
* @var bool
*/
var bool $is_validate=false;
/**
* Cache of the validated new attribute data
* @see LSattribute::getUpdateData()
* @var array<string>
*/
var array $_finalUpdateData=array();
/**
* Cache of the current connected user right on this attribute
* @see LSattribute::myRights()
* @var null|string
*/
var $_myRights=null;
/**
* Object registered hooks on event
* @see LSattribute::addEvent()
* @see LSattribute::fireEvent()
* @var array<string,array>
*/
var array $_events=array();
/**
* Object registered hooks on event trigger object methods
* @see LSattribute::addObjectEvent()
* @see LSattribute::fireEvent()
* @var array<string,array>
*/
var array $_objectEvents=array();
/**
* Constructeur
@ -56,7 +131,7 @@ class LSattribute extends LSlog_staticLoggerClass {
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $name Nom de l'attribut ldap
* @param string $name Configuration de l'objet
* @param array $config Configuration de l'objet
* @param LSldapObject &$ldapObject L'objet ldap parent
*
* @return boolean Retourne true si la création a réussi, false sinon.
@ -170,7 +245,7 @@ class LSattribute extends LSlog_staticLoggerClass {
/**
* Return attribute's display value
*
* @param string $name Custom attribute data (optional, default: current attribute data)
* @param string|false $data Custom attribute data (optional, default: current attribute data)
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
@ -313,7 +388,7 @@ class LSattribute extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObject &$ldapObject The LSform object
* @param LSform &$form The LSform object
* @param boolean $api_mode True if it's a view in API mode (=all accessible attributes present,
* optional, default: false)
*
@ -335,7 +410,7 @@ class LSattribute extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param LSldapObject &$ldapObject The LSform object
* @param LSform &$form The LSform object
*
* @return boolean True on success, False otherwise
*/
@ -355,7 +430,7 @@ class LSattribute extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param object $form The LSform object
* @param LSform $form The LSform object
*
* @return LSformElement|False LSformElement object on success, False otherwise
*/
@ -387,7 +462,7 @@ class LSattribute extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param object $form LSform Le formulaire dans lequel doit être ajouté l'attribut
* @param LSform $form LSform Le formulaire dans lequel doit être ajouté l'attribut
* @param string $idForm L'identifiant du formulaire
*
* @return boolean true si la valeur a été rafraichie ou que ce n'est pas nécessaire, false sinon
@ -413,7 +488,7 @@ class LSattribute extends LSlog_staticLoggerClass {
/**
* Return the form display value
*
* @param string $name Custom attribute data (optional, default: current attribute data)
* @param mixed $data Custom attribute data (optional, default: current attribute data)
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
@ -431,7 +506,7 @@ class LSattribute extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $idForm Les données de mise à jour.
* @param mixed $data Les données de mise à jour.
*
* @return void
*/
@ -607,9 +682,9 @@ class LSattribute extends LSlog_staticLoggerClass {
/**
* Ajouter une action lors d'un événement
*
* @param string $name Le nom de l'événement
* @param string $name Le nom de la fonction à exectuer
* @param string $name Paramètres pour le lancement de la fonction
* @param string $event Le nom de l'événement
* @param callable $fct Le nom de la fonction à exectuer
* @param array $params Paramètres pour le lancement de la fonction
* @param string $class Nom de la classe possèdant la méthode $fct à executer
*
* @return void
@ -625,10 +700,10 @@ class LSattribute extends LSlog_staticLoggerClass {
/**
* Ajouter une action sur un objet lors d'un événement
*
* @param string $name Le nom de l'événement
* @param object $obj L'objet dont la méthode doit être executé
* @param string $name Le nom de la méthode
* @param string $name Paramètres d'execution de la méthode
* @param string $event Le nom de l'événement
* @param object &$obj L'objet dont la méthode doit être executé
* @param string $meth Le nom de la méthode
* @param array $params Paramètres d'execution de la méthode
*
* @return void
*/
@ -643,7 +718,7 @@ class LSattribute extends LSlog_staticLoggerClass {
/**
* Lance les actions à executer lors d'un événement
*
* @param string $name Le nom de l'événement
* @param string $event Le nom de l'événement
*
* @return boolean True si tout c'est bien passé, false sinon
*/
@ -736,9 +811,9 @@ class LSattribute extends LSlog_staticLoggerClass {
/**
* Return a configuration parameter (or default value)
*
* @param[] $param The configuration parameter
* @param[] $default The default value (default : null)
* @param[] $cast Cast resulting value in specific type (default : disabled)
* @param string $param The configuration parameter
* @param mixed $default The default value (default : null)
* @param string $cast Cast resulting value in specific type (default : disabled)
*
* @return mixed The configuration parameter value or default value if not set
**/

View file

@ -98,9 +98,9 @@ class LSauth extends LSlog_staticLoggerClass {
/**
* Return a configuration parameter (or default value)
*
* @param[] $param The configuration parameter
* @param[] $default The default value (default : null)
* @param[] $cast Cast resulting value in specific type (default : disabled)
* @param string $param The configuration parameter
* @param mixed $default The default value (default : null)
* @param string $cast Cast resulting value in specific type (default : disabled)
*
* @return mixed The configuration parameter value or default value if not set
**/
@ -198,7 +198,7 @@ class LSauth extends LSlog_staticLoggerClass {
/**
* Get user password attribute name
*
* @param LSldapObject &object The user object
* @param LSldapObject &$object The user object
*
* @return string|false The user password attribute name or false if not configured
*/
@ -215,7 +215,7 @@ class LSauth extends LSlog_staticLoggerClass {
*
* Return LDAP credentials or false
*
* @params[in] $user The LSldapObject of the user authificated
* @param LSldapObject $user The LSldapObject of the user authificated
*
* @return array|false Array of LDAP credentials array('dn','pwd') or False
**/

View file

@ -106,7 +106,7 @@ class LSauthMethod extends LSlog_staticLoggerClass {
*
* Return LDAP credentials or false
*
* @params[in] $user The LSldapObject of the user authificated
* @param LSldapObject $user The LSldapObject of the authenticated user
*
* @return array|false Array of LDAP credentials array('dn','pwd') or False
**/

View file

@ -29,10 +29,18 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass');
*/
class LScli extends LSlog_staticLoggerClass {
// Configured commands
private static $commands = array();
/**
* Configured commands
* @see LScli::add_command()
* @var array
*/
private static array $commands = array();
// Store current executed command
/**
* Store current executed command
* @see LScli::handle_args()
* @var null|string
*/
private static $current_command = null;
/**
@ -609,7 +617,7 @@ class LScli extends LSlog_staticLoggerClass {
* @param array $opts Available options
* @param string $prefix Option name prefix (optional, default=empty string)
* @param boolean $case_sensitive Set to false if options are case insensitive (optional, default=true)
* @param boolean $quote_char Quote character (optional, if not set, $prefix will be unquoted and its
* @param string $quote_char Quote character (optional, if not set, $prefix will be unquoted and its
* quote char (if detected) will be used to quote options)
*
* @return array List of matched options
@ -665,7 +673,7 @@ class LScli extends LSlog_staticLoggerClass {
*
* @param string $prefix Option prefix (optional, default=empty string)
* @param boolean $case_sensitive Set to false if options are case insensitive (optional, default=true)
* @param boolean $quote_char Quote character (optional, if not set, $prefix will be unquoted and its
* @param string $quote_char Quote character (optional, if not set, $prefix will be unquoted and its
* quote char (if detected) will be used to quote options)
*
* @return array List of available options
@ -720,7 +728,7 @@ class LScli extends LSlog_staticLoggerClass {
* @param string $objType LSobject type
* @param string $prefix Option prefix (optional, default=empty string)
* @param boolean $case_sensitive Set to false if options are case insensitive (optional, default=true)
* @param boolean $quote_char Quote character (optional, if not set, $prefix will be unquoted and its
* @param string $quote_char Quote character (optional, if not set, $prefix will be unquoted and its
* quote char (if detected) will be used to quote options)
*
* @return array List of available options
@ -759,7 +767,7 @@ class LScli extends LSlog_staticLoggerClass {
* @param string $objType LSobject type
* @param string $prefix Option prefix (optional, default=empty string)
* @param boolean $case_sensitive Set to false if options are case insensitive (optional, default=true)
* @param boolean $quote_char Quote character (optional, if not set, $prefix will be unquoted and its
* @param string $quote_char Quote character (optional, if not set, $prefix will be unquoted and its
* quote char (if detected) will be used to quote options)
*
* @return array List of available options

View file

@ -27,7 +27,13 @@
*/
class LSconfig {
// Configuration Data
/**
* Configuration Data
* @see LSconfig::start()
* @see $GLOBALS['LSconfig']
* @see $GLOBALS['LSaddons']
* @var array<string,mixed>
*/
private static $data=array();
/**

View file

@ -29,6 +29,10 @@
*/
class LSerror {
/**
* Registered error codes
* @var array<string,array>
*/
private static $_errorCodes = array(
'0' => array('msg' => "%{msg}")
);
@ -45,7 +49,7 @@ class LSerror {
*
* @return void
*/
public static function defineError($code=-1, $msg='', $escape=True) {
public static function defineError($code='-1', $msg='', $escape=True) {
self :: $_errorCodes[$code] = array(
'msg' => $msg,
'escape' => boolval($escape),
@ -104,7 +108,7 @@ class LSerror {
*
* @return void
*/
public static function stop($code=-1, $msg='', $escape=true) {
public static function stop($code='-1', $msg='', $escape=true) {
if(!empty($_SESSION['LSerror'])) {
print "<h1>"._('Errors')."</h1>\n";
print self :: display(true);
@ -118,7 +122,7 @@ class LSerror {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retvat string Le texte des erreurs
* @return string Le texte des erreurs
*/
public static function getErrors() {
$return = (
@ -133,9 +137,13 @@ class LSerror {
/**
* Format error message
*
* @param string|null $code The error code
* @param mixed $message Error message data for registred errors or the error message as string, or null
* @param bool $escape Set to false to disable escaping error message
* @param callable $escape_method The escape method (default: htmlentities)
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retvat string Le texte des erreurs
* @return string Le texte des erreurs
*/
private static function formatError($code=null, $message=null, $escape=True, $escape_method=null) {
if ($code && array_key_exists($code, self :: $_errorCodes)) {
@ -165,7 +173,7 @@ class LSerror {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retvat boolean
* @return boolean
*/
public static function errorsDefined() {
return (
@ -180,7 +188,7 @@ class LSerror {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @retvat void
* @return void
*/
private static function resetError() {
if (isset($_SESSION['LSerror']))

View file

@ -31,30 +31,129 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass');
*/
class LSform extends LSlog_staticLoggerClass {
/**
* Reference of the related LSldapObject
* @var LSldapObject
*/
var $ldapObject;
/**
* Identifier of the form (create/update/...)
* @var string
*/
var $idForm;
var $config;
var $can_validate = true;
var $elements = array();
var $_rules = array();
var $_postData = array();
/**
* Configuration (LSobjects.<type>.LSform)
* @see LSform::__construct()
* @var array
*/
var array $config;
var $_elementsErrors = array();
/**
* Validation ability telltale
* @see LSform::validate()
* @see LSform::setElementError()
* @var boolean
*/
var bool $can_validate = true;
/**
* Form elements with attribute name as key and an implemented LSformElement as value
* @see LSform::addElement()
* @see LSattr_html::addToForm()
* @var array<string,LSformElement>
*/
var array $elements = array();
/**
* Registred elements's rules
* @var array<string,array>
*/
var array $_rules = array();
/**
* Post data of the form
* @see LSform::getPostData()
* @var array<string,array>
*/
var array $_postData = array();
/**
* Registered elements's errors
* @see LSform::setElementError()
* @see LSform::definedError()
* @see LSform::getErrors()
* @var array<string,array>
*/
var array $_elementsErrors = array();
/**
* Validation telltale
* @see LSform::validate()
* @var boolean
*/
var $_isValidate = false;
/**
* List of attributes explicitly declared as not updated
* @see LSformElement_password::getPostData()
* @var array<string,bool>
*/
var $_notUpdate = array();
/**
* MAX_FILE_SIZE value of the form
* @see LSform::setMaxFileSize()
* @var int|null
*/
var $maxFileSize = NULL;
/**
* Name of the applied data entry form
* @see LSform::applyDataEntryForm()
* @var string|null
*/
var $dataEntryForm = NULL;
/**
* Configuration of the applied data entry form
* (LSobjects.<type>.LSform.dataEntryForm.<dataEntryForm_name>)
* @see LSform::applyDataEntryForm()
* @var array|null
*/
var $dataEntryFormConfig = NULL;
var $warnings = array();
/**
* Registred warnings
* @see LSform::addWarning()
* @var array<int,string>
*/
var array $warnings = array();
var $api_mode = false;
/**
* Telltale of the API mode
* @see LSform::__construct()
* @var bool
*/
var bool $api_mode = false;
private $submited = false;
/**
* Submited telltale
* @see LSform::setSubmited()
* @see LSform::isSubmit()
* @var bool
*/
private bool $submited = false;
/**
* The submit button value
* Note: used to detect the submited state of the form from the current request data
* @see LSform::__construct()
* @see LSform::isSubmit()
* @var string|null
*/
private $submit = null;
/**
@ -64,19 +163,16 @@ class LSform extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $idForm L'identifiant du formulaire
* @param string $submit La valeur du bouton submit
* @param LSldapObject &$ldapObject The related LSldapObject
* @param string $idForm The form identifier
* @param string|null $submit The submit button value
* @param bool $api_mode Set to True to enable API mode
*
* @return void
*/
public function __construct(&$ldapObject, $idForm, $submit=NULL, $api_mode=false){
$this -> idForm = $idForm;
if (!$submit) {
$this -> submit = _("Validate");
}
else {
$this -> submit = $submit;
}
$this -> submit = ($submit?$submit:_("Validate"));
$this -> api_mode = $api_mode;
$this -> ldapObject =& $ldapObject;
$this -> config = $ldapObject -> getConfig('LSform');
@ -86,9 +182,9 @@ class LSform extends LSlog_staticLoggerClass {
/**
* Return a configuration parameter (or default value)
*
* @param[] $param The configuration parameter
* @param[] $default The default value (default : null)
* @param[] $cast Cast resulting value in specific type (default : disabled)
* @param string $param The configuration parameter
* @param mixed $default The default value (default : null)
* @param string $cast Cast resulting value in specific type (default : disabled)
*
* @return mixed The configuration parameter value or default value if not set
**/
@ -288,21 +384,22 @@ class LSform extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $attrLe nom du champ
* @param string $msg Le format du message d'erreur à afficher (pouvant comporter
* @param LSformElement $element Le nom du champ
* @param string|null $msg Le format du message d'erreur à afficher (pouvant comporter
* des valeurs %{[n'importe quoi]} qui seront remplacé par le label
* du champs concerné.
* @param array|null $extra_values Extra values to compute the LSformat of the message
* (optional, by default, only the field label is provided to getFData)
*
* @return void
*/
public function setElementError($attr,$msg=NULL) {
if($msg!='') {
$msg_error=getFData($msg,$attr->getLabel());
}
else {
$msg_error=getFData(_("%{label} attribute data is not valid."),$attr->getLabel());
}
$this -> _elementsErrors[$attr->name][]=$msg_error;
public function setElementError($element, $msg=null, $extra_values=null) {
$this -> _elementsErrors[$element->name][] = getFData(
$msg?$msg:_("%{label} attribute data is not valid."),
is_array($extra_values)?
array_merge(array('label' => $element->getLabel()), $extra_values):
$element->getLabel()
);
$this -> can_validate=false;
}
@ -311,7 +408,7 @@ class LSform extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $attrLe nom de l'élement
* @param string|null $element Le nom de l'élement
*
* @return boolean
*/
@ -411,13 +508,13 @@ class LSform extends LSlog_staticLoggerClass {
}
/**
* Vérifie si au moins une valeur est présente dans le tableau
* Check if at least one non-empty value is present in the specifed array
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $submit tableau de valeurs
* @param array $data Array of values
*
* @return boolean true si au moins une valeur est présente, false sinon
* @return boolean True if at least one non-empty value is present, false otherwise
*/
public function checkRequired($data) {
foreach($data as $val) {
@ -542,10 +639,11 @@ class LSform extends LSlog_staticLoggerClass {
*
* Ajoute un élément au formulaire et définis les informations le concernant.
*
* @param string $submit Le type de l'élément
* @param string $submit Le nom de l'élément
* @param string $submit Le label de l'élément
* @param string $submit Paramètres supplémentaires
* @param string $type Le type de l'élément
* @param string $name Le nom de l'élément
* @param string $label Le label de l'élément
* @param array $params Paramètres supplémentaires
* @param LSattr_html &$attr_html The related LSattr_html
*
* @return LSformElement
*/
@ -570,7 +668,7 @@ class LSform extends LSlog_staticLoggerClass {
/**
* Check if form has a specified element (by attr name)
*
* @param string $submit The element/attribute name
* @param string $name The element/attribute name
*
* @return boolean
**/
@ -581,12 +679,12 @@ class LSform extends LSlog_staticLoggerClass {
/**
* Check if a specified element (by attr name) is freezed
*
* @param string $submit The element/attribute name
* @param string $name The element/attribute name
*
* @return boolean
**/
public function isFreeze($name) {
return isset($this -> elements[$name]) && $this -> elements[$name] -> isFreeze($name);
return isset($this -> elements[$name]) && $this -> elements[$name] -> isFreeze();
}
/**
@ -594,9 +692,9 @@ class LSform extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $submit Le nom de l'élément conserné
* @param string $submit Le nom de la règle à ajouter
* @param string $submit Options (facultative)
* @param string $element Le nom de l'élément conserné
* @param string $rule Le nom de la règle à ajouter
* @param array $options Options (facultative)
*
* @return boolean
*/
@ -628,15 +726,16 @@ class LSform extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $submit Le nom de l'élément conserné
* @param string $element Le nom de l'élément conserné
*
* @return boolean
*/
public function setRequired($element) {
if (isset( $this -> elements[$element] ) )
return $this -> elements[$element] -> setRequired();
else
return;
if (isset( $this -> elements[$element] ) ) {
$this -> elements[$element] -> setRequired();
return true;
}
return false;
}
/**
@ -646,7 +745,8 @@ class LSform extends LSlog_staticLoggerClass {
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $submit Le nom de l'élément conserné
* @param string $rule The rule name
* @return bool
*/
public function isRuleRegistered($rule) {
LSsession :: loadLSclass('LSformRule');
@ -697,7 +797,7 @@ class LSform extends LSlog_staticLoggerClass {
if ($this -> isSubmit() && $this -> _postData) {
return $this -> _postData[$element];
}
return $this -> elements[$element] -> getValue();
return $this -> elements[$element] -> values;
}
/**
@ -718,8 +818,8 @@ class LSform extends LSlog_staticLoggerClass {
/**
* Return the HTML code of an empty form field
*
* @param string $submit The form element name
* @param string|null $LSform_action The value index (optional, default: null == 0)
* @param string $element The form element name
* @param int|null $value_idx The value index (optional, default: null == 0)
*
* @return string|null The HTML code of the specified field if exist, null otherwise
*/
@ -747,7 +847,7 @@ class LSform extends LSlog_staticLoggerClass {
/**
* Applique un masque de saisie au formulaire
*
* @param string $submit Le nom du masque de saisie
* @param string $dataEntryForm Le nom du masque de saisie
*
* @return boolean True si le masque de saisie a été appliqué, False sinon
**/
@ -781,7 +881,7 @@ class LSform extends LSlog_staticLoggerClass {
/**
* Liste les dataEntryForm disponible pour un type d'LSldapObject
*
* @param string $submit Le type d'LSldapObject
* @param string $type Le type d'LSldapObject
*
* @return array Tableau contenant la liste de dataEntryForm disponible pour ce type d'LSldapObject (nom => label)
**/
@ -807,7 +907,7 @@ class LSform extends LSlog_staticLoggerClass {
/**
* Ajoute un avertissement au sujet du formulaire
*
* @param string $submit Le texte de l'avertissement
* @param string $txt Le texte de l'avertissement
*
* @return void
**/
@ -845,9 +945,10 @@ class LSform extends LSlog_staticLoggerClass {
/**
* CLI autocompleter for form attributes values
*
* @param array &$opts Array of avalaible autocomplete options
* @param string $submit The command word to autocomplete
* @param string $submit The multiple value delimiter (optional, default: "|")
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The command word to autocomplete
* @param string $multiple_value_delimiter The multiple value delimiter
* (optional, default: "|")
*
* @return void
*/

View file

@ -32,17 +32,81 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass');
class LSformElement extends LSlog_staticLoggerClass {
var $name;
var $label;
var $params;
var $values = array();
/**
* The attribute name
* @var string
*/
var string $name;
/**
* The attribute label
* @see LSformElement::__construct()
* @see LSformElement::getLabel()
* @var string
*/
var string $label;
/**
* Attribute configuration (LSobjects.<type>.attrs.<attr_name>)
* @see LSformElement::getParam()
* @var array<string,mixed>
*/
var array $params;
/**
* Values of the element
* @var array<mixed>
*/
var array $values = array();
/**
* Reference of the related LSform object
* @var LSform
*/
var $form = null;
var $_required = false;
var $_freeze = false;
/**
* Require telltale
* @see LSformElement::setRequired()
* @see LSformElement::isRequired()
* @var bool
*/
var bool $_required = false;
/**
* Freeze telltale (=read-only element)
* @see LSformElement::freeze()
* @see LSformElement::isFreeze()
* @var bool
*/
var bool $_freeze = false;
/**
* Reference to the related LSattr_html object
* @var LSattr_html
*/
var $attr_html;
var $fieldTemplate = 'LSformElement_field.tpl';
var $template = 'LSformElement.tpl';
var $fetchVariables = array();
/**
* The one-value template filename (=for one vaue of the form element)
* Note: commonly overwrite in implementated classes
* @var string
*/
var string $fieldTemplate = 'LSformElement_field.tpl';
/**
* The template filename (of the form complement element)
* Note: may be overwrite in implementated classes
* @var string
*/
var string $template = 'LSformElement.tpl';
/**
* Template variables passed to Smarty computing the form element template
* Note: this variables are commonly added in implementated classes
* @var array<string,mixed>
*/
var array $fetchVariables = array();
/**
* Constructor
@ -51,9 +115,9 @@ class LSformElement extends LSlog_staticLoggerClass {
*
* @param LSform &$form The LSform parent object
* @param string $name The name of the element
* @param string $name The label of the element
* @param string $name The parameters of the element
* @param LSform &$form The LSattr_html object of the corresponding attribute
* @param string $label The label of the element
* @param array $params The parameters of the element
* @param LSattr_html &$attr_html The LSattr_html object of the corresponding attribute
*
* @return void
*/
@ -178,9 +242,15 @@ class LSformElement extends LSlog_staticLoggerClass {
}
/**
* Retourne le label de l'élement
* Return label info of the element:
* array(
* 'label' => 'The label',
* 'required' => true|false,
* 'help_info' => 'The help info of the element',
* 'help_info_in_view' => true|false,
* )
*
* @return void
* @return array The label info
*/
public function getLabelInfos() {
if ($this -> isRequired()) {
@ -234,7 +304,7 @@ class LSformElement extends LSlog_staticLoggerClass {
* Retrieve the value of the element specified by its name ($name)
* from POST data (provided as $post).
*
* @param array &$return Reference of the array for input POST data
* @param array &$post Reference of the array for input POST data
* @param string $name POST data element name
*
* @return mixed Array of POST data value if present, false otherwise
@ -279,8 +349,8 @@ class LSformElement extends LSlog_staticLoggerClass {
/**
* Return HTML code of the LSformElement based on its (smarty) template file
*
* @param string $name The template filename (optional, default: $this -> template)
* @param string $name Array of template variables to assign before template compilation (optional)
* @param string $template The template filename (optional, default: $this -> template)
* @param array $variables Array of template variables to assign before template compilation (optional)
*
* @return string HTML code of the LSformElement
*/
@ -326,9 +396,9 @@ class LSformElement extends LSlog_staticLoggerClass {
/**
* Return a parameter (or default value)
*
* @param[] $param The configuration parameter
* @param[] $default The default value (default : null)
* @param[] $cast Cast resulting value in specific type (default : disabled)
* @param string $param The configuration parameter
* @param mixed $default The default value (default : null)
* @param string $cast Cast resulting value in specific type (default : disabled)
*
* @return mixed The parameter value or default value if not set
**/
@ -339,12 +409,14 @@ class LSformElement extends LSlog_staticLoggerClass {
/**
* CLI autocompleter for form element attribute values
*
* @param array &$return Array of avalaible autocomplete options
* @param string $name The (unquoted) command word to autocomplete
* @param string $name The current attribute value in command word to autocomplete
* (optional, default: empty string)
* @param string $name The multiple value delimiter (optional, default: "|")
* @param string $name The quote character detected (optional, default: empty string)
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The (unquoted) command word to autocomplete
* @param string $attr_value The current attribute value in command word to
* autocomplete (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter
* (optional, default: "|")
* @param string $quote_char The quote character detected
* (optional, default: empty string)
*
* @return void
*/
@ -355,12 +427,15 @@ class LSformElement extends LSlog_staticLoggerClass {
/**
* CLI autocompleter helper to split form element attribute values
*
* @param string $attr_value The current attribute value in command word to autocomplete
* (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter (optional, default: "|")
* @param array &$attr_values &array Array that will contain splited attribute values without
* last-one
* @param string &$last_attr_value Array that will contain the last splited attribute value
* @param string $attr_value The current attribute value in command word
* to autocomplete
* (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter
* (optional, default: "|")
* @param array &$attr_values Array that will contain splited attribute
* values without last-one
* @param string &$last_attr_value Array that will contain the last splited
* attribute value
*
* @return boolean True on success, False otherwise
*/
@ -385,7 +460,7 @@ class LSformElement extends LSlog_staticLoggerClass {
* @param string $multiple_value_delimiter The multiple value delimiter (optional, default: "|")
* @param string $quote_char The quote character (optional, default: empty string)
*
* @return boolean True on success, False otherwise
* @return void
*/
protected function add_autocomplete_attr_value_opts(&$opts, &$attr_values, $value, $multiple_value_delimiter='|', $quote_char='') {
if (in_array($value, $attr_values)) {
@ -403,8 +478,8 @@ class LSformElement extends LSlog_staticLoggerClass {
/**
* Retrieve value as return in API response
*
* @param boolean $onlyIfPresent If true, returned values will contain details if this field type
* support it (optional, default: false)
* @param boolean $details If true, returned values will contain details if this field
* type support it (optional, default: false)
*
* @return mixed API value(s) or null/empty array if no value
*/
@ -427,4 +502,14 @@ class LSformElement extends LSlog_staticLoggerClass {
return $values[0];
}
/**
* Get display info of the form element
*
* @return array
*/
public function getDisplay(){
$return = $this -> getLabelInfos();
$return['html'] = $this -> fetchTemplate();
return $return;
}
}

View file

@ -32,8 +32,8 @@
class LSformElement_boolean extends LSformElement {
var $fieldTemplate = 'LSformElement_boolean_field.tpl';
var $template = 'LSformElement_boolean.tpl';
var string $fieldTemplate = 'LSformElement_boolean_field.tpl';
var string $template = 'LSformElement_boolean.tpl';
/**
* Retourne les infos d'affichage de l'élément
@ -67,11 +67,14 @@ class LSformElement_boolean extends LSformElement {
/**
* CLI autocompleter for form element attribute values
*
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The (unquoted) command word to autocomplete
* @param string $attr_value The current attribute value in command word to autocomplete (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter (optional, default: "|")
* @param string $quote_char The quote character detected (optional, default: empty string)
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The (unquoted) command word to autocomplete
* @param string $attr_value The current attribute value in command word to
* autocomplete (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter
* (optional, default: "|")
* @param string $quote_char The quote character detected
* (optional, default: empty string)
*
* @return void
*/

View file

@ -32,9 +32,9 @@
class LSformElement_date extends LSformElement {
var $fieldTemplate = 'LSformElement_date_field.tpl';
var string $fieldTemplate = 'LSformElement_date_field.tpl';
var $_php2js_format = array(
var array $_php2js_format = array(
"a" => "a",
"A" => "A",
"b" => "b",
@ -60,9 +60,9 @@ class LSformElement_date extends LSformElement {
"%" => "%",
);
var $_cache_php2js_format=array();
var array $_cache_php2js_format=array();
var $default_style="vista";
var string $default_style="vista";
/**
* Définis la valeur de l'élément date

View file

@ -31,9 +31,7 @@
class LSformElement_image extends LSformElement {
var $postImage = NULL;
var $tmp_file = array();
var $fieldTemplate = 'LSformElement_image_field.tpl';
var string $fieldTemplate = 'LSformElement_image_field.tpl';
/**
* Retourne les infos d'affichage de l'élément
@ -167,7 +165,7 @@ class LSformElement_image extends LSformElement {
/**
* Retrieve value as return in API response
*
* @param boolean $onlyIfPresent If true, returned values will contain details if this field type
* @param boolean $details If true, returned values will contain details if this field type
* support it (optional, default: false)
*
* @return mixed API value(s) or null/empty array if no value

View file

@ -32,8 +32,8 @@ LSsession :: loadLSclass('LSformElement');
class LSformElement_jsonCompositeAttribute extends LSformElement {
var $template = 'LSformElement_jsonCompositeAttribute.tpl';
var $fieldTemplate = 'LSformElement_jsonCompositeAttribute_field.tpl';
var string $template = 'LSformElement_jsonCompositeAttribute.tpl';
var string $fieldTemplate = 'LSformElement_jsonCompositeAttribute_field.tpl';
public function __construct(&$form, $name, $label, $params, &$attr_html){
parent :: __construct($form, $name, $label, $params,$attr_html);
@ -151,7 +151,7 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
* - translated : translated value
*
* @param string $c The component name
* @param string $c The value
* @param string $value The value
* @param boolean $inLoop Internal param to control recursion
*
* @return array
@ -204,7 +204,7 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
* Retrieve value's label of an select_list component
*
* @param string $c The component name
* @param string $c The value
* @param string $value The value
*
* @return array
**/
@ -230,8 +230,8 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
* it to feed the array passed in paramater.
*
* @param array &$return Reference of the array for retrieved values
* @param boolean $inLoop If true and data of this element is not present in POST data,
* just ignore it.
* @param boolean $onlyIfPresent If true and data of this element is not present
* in POST data, just ignore it.
*
* @return boolean true if value is in POST data, false instead
*/
@ -378,8 +378,8 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
/**
* Check one component's values
*
* @param[] $c The component name
* @param[] $value The values of the component
* @param string $c The component name
* @param mixed $value The values of the component
*
* @return void
**/
@ -420,8 +420,8 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
/**
* Check one select_list component's value
*
* @param[] $c The component name
* @param[] $value The value to check
* @param string $c The component name
* @param string $value The value to check
*
* @return void
**/
@ -443,10 +443,10 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
/**
* Return a configuration parameter for a specific component (or default value)
*
* @param[] $component The component name
* @param[] $param The configuration parameter
* @param[] $default The default value (default : null)
* @param[] $cast Cast resulting value in specific type (default : disabled)
* @param string $component The component name
* @param string $param The configuration parameter
* @param mixed $default The default value (default : null)
* @param string|null $cast Cast resulting value in specific type (default : disabled)
*
* @return mixed The configuration parameter value or default value if not set
**/
@ -460,7 +460,7 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
/**
* Retrieve value as return in API response
*
* @param boolean $inLoop If true, returned values will contain details if this field type
* @param boolean $details If true, returned values will contain details if this field type
* support it (optional, default: false)
*
* @return mixed API value(s) or null/empty array if no value

View file

@ -33,8 +33,8 @@ LSsession :: loadLSclass('LSformElement');
class LSformElement_labeledValue extends LSformElement {
var $template = 'LSformElement_labeledValue.tpl';
var $fieldTemplate = 'LSformElement_labeledValue_field.tpl';
var string $template = 'LSformElement_labeledValue.tpl';
var string $fieldTemplate = 'LSformElement_labeledValue_field.tpl';
/**
* Retourne les infos d'affichage de l'élément

View file

@ -33,20 +33,20 @@ LSsession :: loadLSclass('LSformElement_text');
class LSformElement_mail extends LSformElement_text {
var $JSscripts = array(
var array $JSscripts = array(
'LSformElement_mail.js'
);
var $fetchVariables = array(
var array $fetchVariables = array(
'additionalCssClass' => array('LSformElement_mail'),
'uriPrefix' => 'mailto:'
);
var $fieldTemplate = 'LSformElement_uri_field.tpl';
var string $fieldTemplate = 'LSformElement_uri_field.tpl';
// Flag to trigger warning about old Autocomplete config style
// (detect in constructor and show on getDisplay())
private $warnOldAutocompleteConfigStyle = false;
private bool $warnOldAutocompleteConfigStyle = false;
/**
* Constructor

View file

@ -32,9 +32,9 @@
class LSformElement_mailQuota extends LSformElement {
var $fieldTemplate = 'LSformElement_mailQuota_field.tpl';
var string $fieldTemplate = 'LSformElement_mailQuota_field.tpl';
var $sizeFacts = array(
var array $sizeFacts = array(
1 => 'o',
1000 => 'Ko',
1000000 => 'Mo',
@ -52,7 +52,7 @@ class LSformElement_mailQuota extends LSformElement {
public function parseValue($value, $details=true) {
if (preg_match('/^([0-9]+)'.$this -> getSuffix().'$/', $value, $regs)) {
$infos = array(
'size' => $regs[1],
'size' => intval($regs[1]),
);
if (!$details)
return $infos['size'];

View file

@ -52,14 +52,12 @@ LSsession :: loadLSclass('LSformElement_text');
class LSformElement_maildir extends LSformElement_text {
var $_toDo=null;
var $JSscripts = array(
var array $JSscripts = array(
'LSformElement_maildir_field.js',
'LSformElement_maildir.js'
);
var $fetchVariables = array(
var array $fetchVariables = array(
'additionalCssClass' => array('LSformElement_maildir'),
);
@ -109,9 +107,23 @@ class LSformElement_maildir extends LSformElement_text {
}
if ($action) {
$new = $this -> attr_html -> getRemoteRootPathRegex($new);
$cur = $this -> attr_html -> getRemoteRootPathRegex($cur);
$this -> attr_html -> doOnModify($action,$cur,$new);
if (is_a($this -> attr_html, 'LSattr_html_maildir')) {
$new = $this -> attr_html -> getRemoteRootPathRegex($new);
$cur = $this -> attr_html -> getRemoteRootPathRegex($cur);
$this -> attr_html -> doOnModify($action,$cur,$new);
}
else {
$this -> form -> setElementError(
$this -> attr_html,
_(
"%{label}: the attribute HTML type is not maildir (but %{type}). ".
"Can't handle on modify hook."
),
array('type' => get_class($this -> attr_html))
);
unset($return[$this -> name]);
return false;
}
}
}
}

View file

@ -32,9 +32,15 @@ LSsession :: loadLSclass('LSformElement');
class LSformElement_password extends LSformElement {
var $fieldTemplate = 'LSformElement_password_field.tpl';
var $template = 'LSformElement_password.tpl';
var string $fieldTemplate = 'LSformElement_password_field.tpl';
var string $template = 'LSformElement_password.tpl';
/**
* Mail to send info
* @see self::getPostData()
* @see self::send()
* @var array|false
*/
var $sendMail = false;
/**
@ -219,7 +225,7 @@ class LSformElement_password extends LSformElement {
$defaultConfirmChangeQuestion = ___('%{label}: Do you confirm the password change?');
$params['confirmChangeQuestion'] = $this -> attr_html -> attribute -> ldapObject -> getDisplayFData(
__($this -> getParam('html_options.confirmChangeQuestion', $defaultConfirmChangeQuestion)),
$this -> label
array('password_label' => $this -> label)
);
}
@ -227,7 +233,7 @@ class LSformElement_password extends LSformElement {
$defaultConfirmInputError = ___('Passwords entered did not match.');
$params['confirmInputError'] = $this -> attr_html -> attribute -> ldapObject -> getDisplayFData(
__($this -> getParam('html_options.confirmInputError', $defaultConfirmInputError)),
$this -> label
array('password_label' => $this -> label)
);
}
@ -280,9 +286,10 @@ class LSformElement_password extends LSformElement {
if ($this -> isLoginPassword()) {
return LSsession :: checkUserPwd($this -> attr_html -> attribute -> ldapObject, $pwd);
}
else {
elseif (is_a($this -> attr_html -> attribute -> ldap, 'LSattr_ldap_password')) {
return $this -> attr_html -> attribute -> ldap -> verify($pwd);
}
return false;
}
public function getMailAttrs() {
@ -444,11 +451,14 @@ class LSformElement_password extends LSformElement {
/**
* CLI autocompleter for form element attribute values
*
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The (unquoted) command word to autocomplete
* @param string $attr_value The current attribute value in command word to autocomplete (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter (optional, default: "|")
* @param string $quote_char The quote character detected (optional, default: empty string)
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The (unquoted) command word to autocomplete
* @param string $attr_value The current attribute value in command word to
* autocomplete (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter
* (optional, default: "|")
* @param string $quote_char The quote character detected
* (optional, default: empty string)
*
* @return void
*/

View file

@ -30,7 +30,12 @@ LSsession :: loadLSclass('LSformElement_textarea');
class LSformElement_postaladdress extends LSformElement_textarea {
var $fieldTemplateExtraClass = 'LSformElement_postaladdress';
/**
* Extra CSS class for the pre HTML element
* @see LSformElement_textarea::getDisplay()
* @var string
*/
var string $fieldTemplateExtraClass = 'LSformElement_postaladdress';
/**
* Retourne les infos d'affichage de l'élément

View file

@ -30,7 +30,12 @@ LSsession :: loadLSclass('LSformElement_textarea');
class LSformElement_pre extends LSformElement_textarea {
var $fieldTemplateExtraClass = 'LSformElement_pre';
/**
* Extra CSS class for the pre HTML element
* @see LSformElement_textarea::getDisplay()
* @var string
*/
var string $fieldTemplateExtraClass = 'LSformElement_pre';
/**
* Retourne les infos d'affichage de l'élément

View file

@ -32,9 +32,9 @@
class LSformElement_quota extends LSformElement {
var $fieldTemplate = 'LSformElement_quota_field.tpl';
var string $fieldTemplate = 'LSformElement_quota_field.tpl';
var $sizeFacts = array(
var array $sizeFacts = array(
1 => 'o',
1024 => 'Ko',
1048576 => 'Mo',
@ -53,7 +53,7 @@ class LSformElement_quota extends LSformElement {
public function parseValue($value, $details=true) {
if (preg_match('/^([0-9]+)$/', $value, $regs)) {
$infos = array(
'size' => ceil($regs[1]/$this -> getFactor()),
'size' => ceil(intval($regs[1]) / $this -> getFactor()),
);
if (!$details)
return $infos['size'];

View file

@ -33,15 +33,15 @@ LSsession :: loadLSclass('LSformElement_text');
class LSformElement_rss extends LSformElement_text {
var $JSscripts = array(
var array $JSscripts = array(
'LSformElement_rss.js'
);
var $fetchVariables = array(
var array $fetchVariables = array(
'additionalCssClass' => array('LSformElement_rss'),
'uriPrefix' => ''
);
var $fieldTemplate = 'LSformElement_uri_field.tpl';
var string $fieldTemplate = 'LSformElement_uri_field.tpl';
public function getDisplay() {
LStemplate :: addHelpInfo(

View file

@ -32,8 +32,8 @@
class LSformElement_select extends LSformElement {
var $template = 'LSformElement_select.tpl';
var $fieldTemplate = 'LSformElement_select.tpl';
var string $template = 'LSformElement_select.tpl';
var string $fieldTemplate = 'LSformElement_select.tpl';
/**
* Return display data of this element
@ -91,7 +91,7 @@ class LSformElement_select extends LSformElement {
}
$ret=False;
if (is_array($possible_values) && isset($value)) {
if (is_array($possible_values)) {
foreach($possible_values as $key => $name) {
if (is_array($name)) {
if (!is_array($name['possible_values'])) continue;
@ -116,11 +116,14 @@ class LSformElement_select extends LSformElement {
/**
* CLI autocompleter for form element attribute values
*
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The (unquoted) command word to autocomplete
* @param string $comp_word The current attribute value in command word to autocomplete (optional, default: empty string)
* @param string $comp_word The multiple value delimiter (optional, default: "|")
* @param string $comp_word The quote character detected (optional, default: empty string)
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The (unquoted) command word to autocomplete
* @param string $attr_value The current attribute value in command word to
* autocomplete (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter
* (optional, default: "|")
* @param string $quote_char The quote character detected
* (optional, default: empty string)
*
* @return void
*/

View file

@ -33,8 +33,8 @@ LSsession :: loadLSclass('LSformElement_select');
class LSformElement_select_box extends LSformElement_select {
var $template = 'LSformElement_select_box.tpl';
var $fieldTemplate = 'LSformElement_select_box.tpl';
var string $template = 'LSformElement_select_box.tpl';
var string $fieldTemplate = 'LSformElement_select_box.tpl';
/**
* Return display data of this element

View file

@ -43,8 +43,14 @@ LSsession :: loadLSclass('LSformElement');
class LSformElement_select_object extends LSformElement {
var $fieldTemplate = 'LSformElement_select_object_field.tpl';
var $template = 'LSformElement_select_object.tpl';
var string $fieldTemplate = 'LSformElement_select_object_field.tpl';
var string $template = 'LSformElement_select_object.tpl';
/**
* Reference to the related LSattr_html_select_object object
* @var LSattr_html_select_object
*/
var $attr_html;
/**
* Return display informations of the element
@ -198,7 +204,7 @@ class LSformElement_select_object extends LSformElement {
*
* @param string $pattern The pattern of the search
*
* @return array(dn -> displayName) Found objects
* @return array Found objects with DN as key and display name as value
*/
public function searchAdd($pattern) {
$objs = array();
@ -289,11 +295,14 @@ class LSformElement_select_object extends LSformElement {
/**
* CLI autocompleter for form element attribute values
*
* @param array &$opts Array of avalaible autocomplete options
* @param string $va The (unquoted) command word to autocomplete
* @param string $va The current attribute value in command word to autocomplete (optional, default: empty string)
* @param string $va The multiple value delimiter (optional, default: "|")
* @param string $va The quote character detected (optional, default: empty string)
* @param array &$opts Array of avalaible autocomplete options
* @param string $comp_word The (unquoted) command word to autocomplete
* @param string $attr_value The current attribute value in command word to
* autocomplete (optional, default: empty string)
* @param string $multiple_value_delimiter The multiple value delimiter
* (optional, default: "|")
* @param string $quote_char The quote character detected
* (optional, default: empty string)
*
* @return void
*/

View file

@ -32,8 +32,8 @@
class LSformElement_ssh_key extends LSformElement {
var $template = 'LSformElement_ssh_key.tpl';
var $fieldTemplate = 'LSformElement_ssh_key_field.tpl';
var string $template = 'LSformElement_ssh_key.tpl';
var string $fieldTemplate = 'LSformElement_ssh_key_field.tpl';
/**

View file

@ -34,8 +34,8 @@ LSsession :: loadLSaddon('supann');
class LSformElement_supannCompositeAttribute extends LSformElement {
var $template = 'LSformElement_supannCompositeAttribute.tpl';
var $fieldTemplate = 'LSformElement_supannCompositeAttribute_field.tpl';
var string $template = 'LSformElement_supannCompositeAttribute.tpl';
var string $fieldTemplate = 'LSformElement_supannCompositeAttribute_field.tpl';
/*
* Composants des valeurs composites :
@ -76,9 +76,9 @@ class LSformElement_supannCompositeAttribute extends LSformElement {
*
* @param LSform &$form The LSform parent object
* @param string $name The name of the element
* @param string $name The label of the element
* @param string $name The parameters of the element
* @param LSform &$form The LSattr_html object of the corresponding attribute
* @param string $label The label of the element
* @param array $params The parameters of the element
* @param LSattr_html &$attr_html The LSattr_html object of the corresponding attribute
*
* @return void
*/
@ -241,8 +241,8 @@ class LSformElement_supannCompositeAttribute extends LSformElement {
* - value : la valeur brute
* - translated : la valeur traduite ou la valeur elle même
*
* @param string $name Le nom du composant
* @param string $name La valeur
* @param string $c Le nom du composant
* @param string $val La valeur
*
* @return array
**/
@ -519,7 +519,7 @@ class LSformElement_supannCompositeAttribute extends LSformElement {
$form = $object -> getForm($_REQUEST['idform']);
$field = $form -> getElement($_REQUEST['attribute']);
if (isset($field->components[$_REQUEST['component']])) {
$data['possibleValues'] = $field -> searchComponentPossibleValues(
$data['possibleValues'] = $field -> searchComponentPossibleValues( // @phpstan-ignore-line
$_REQUEST['component'], $_REQUEST['pattern']
);
}
@ -564,7 +564,7 @@ class LSformElement_supannCompositeAttribute extends LSformElement {
/**
* Retrieve value as return in API response
*
* @param boolean $onlyIfPresent If true, returned values will contain details if this field type
* @param boolean $details If true, returned values will contain details if this field type
* support it (optional, default: false)
*
* @return mixed API value(s) or null/empty array if no value

View file

@ -34,10 +34,21 @@ LSsession :: loadLSaddon('supann');
class LSformElement_supannLabeledValue extends LSformElement {
var $template = 'LSformElement_supannLabeledValue.tpl';
var $fieldTemplate = 'LSformElement_supannLabeledValue_field.tpl';
var string $template = 'LSformElement_supannLabeledValue.tpl';
var string $fieldTemplate = 'LSformElement_supannLabeledValue_field.tpl';
/**
* Nomenclature table of this form element's values
* @see supannGetNomenclaturePossibleValues()
* @var string|null
*/
var $supannNomenclatureTable = null;
/**
* Nomenclature table for the labels of this form element's values
* @see supannGetNomenclaturePossibleValues()
* @var string|null
*/
var $supannLabelNomenclatureTable = null;
// HTML field type: text or textarea (only for field without nomenclature table)

View file

@ -76,7 +76,7 @@ class LSformElement_supannRessourceEtatDate extends LSformElement_supannComposit
/**
* Parse une valeur composite gérer par ce type d'attribut
*
* @param $value string La valeur à parser
* @param string $value La valeur à parser
* @return array|null La valeur parsée, ou NULL en cas de problème
*/
public function parseCompositeValue($value) {
@ -96,7 +96,7 @@ class LSformElement_supannRessourceEtatDate extends LSformElement_supannComposit
/**
* Format une valeur composite gérer par ce type d'attribut
*
* @param $value string La valeur à parser
* @param string $value La valeur à parser
* @return array|null|false La valeur formatée, NULL en cas de valeur vide, ou False en cas de problème
*/
public function formatCompositeValue($value) {

View file

@ -33,12 +33,12 @@ LSsession :: loadLSclass('LSformElement_text');
class LSformElement_tel extends LSformElement_text {
var $fetchVariables = array(
var array $fetchVariables = array(
'additionalCssClass' => array('LSformElement_tel'),
'uriPrefix' => 'tel:'
);
var $fieldTemplate = 'LSformElement_uri_field.tpl';
var string $fieldTemplate = 'LSformElement_uri_field.tpl';
public function getDisplay() {
$this -> fetchVariables['uriLinkTitle'] = $this -> attr_html -> attribute -> ldapObject ->getDisplayName();

View file

@ -33,12 +33,26 @@ LSsession :: loadLSclass('LSformElement');
class LSformElement_text extends LSformElement {
var $JSscripts = array();
var $CSSfiles = array(
/**
* Extra JS scripts to load for handling this form element
* Note: commonly overwrite in children LSformElement classes
* @see LSformElement_text::getDisplay()
* @var array
*/
var array $JSscripts = array();
/**
* Extra CSS file to load for handling this form element
* Note: commonly overwrite in children LSformElement classes
* @see LSformElement_text::getDisplay()
* @var array
*/
var array $CSSfiles = array(
'LSformElement_text.css',
);
var $fieldTemplate = 'LSformElement_text_field.tpl';
var $fetchVariables = array(
var string $fieldTemplate = 'LSformElement_text_field.tpl';
var array $fetchVariables = array(
'additionalCssClass' => array(),
);
@ -82,7 +96,7 @@ class LSformElement_text extends LSformElement {
* Return HTML code of the LSformElement based on its (smarty) template file
*
* @param string $template The template filename (optional, default: $this -> template)
* @param string $template Array of template variables to assign before template compilation (optional)
* @param array $variables Array of template variables to assign before template compilation (optional)
*
* @return string HTML code of the LSformElement
*/

Some files were not shown because too many files have changed in this diff Show more