From bbde10bbf0294cde574f30bf4bda7d37646de70d Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sat, 31 Dec 2022 21:15:19 +0100 Subject: [PATCH] Add some class properties type & coments and clean errors detected by PHPstan (level 2) --- .gitlab-ci.yml | 7 +- .phpstan/config.neon | 15 + .phpstan/init.php | 10 + composer.lock | 78 ++++ doc/contrib/contrib.docbook | 6 +- docker/Dockerfile | 2 +- phpstan.neon | 32 -- src/includes/addons/LSaddons.asterisk.php | 21 +- src/includes/addons/LSaddons.mailquota.php | 4 +- src/includes/addons/LSaddons.ppolicy.php | 20 +- src/includes/addons/LSaddons.samba.php | 72 ++-- src/includes/addons/LSaddons.ssh.php | 26 +- src/includes/addons/LSaddons.supann.php | 4 +- src/includes/class/class.LSattr_html.php | 50 ++- .../class/class.LSattr_html_boolean.php | 2 +- src/includes/class/class.LSattr_html_date.php | 8 +- .../class/class.LSattr_html_image.php | 4 +- ...ass.LSattr_html_jsonCompositeAttribute.php | 2 +- .../class/class.LSattr_html_labeledValue.php | 2 +- src/includes/class/class.LSattr_html_mail.php | 2 +- .../class/class.LSattr_html_mailQuota.php | 2 +- .../class/class.LSattr_html_maildir.php | 7 +- .../class/class.LSattr_html_password.php | 4 +- .../class/class.LSattr_html_postaladdress.php | 2 +- src/includes/class/class.LSattr_html_pre.php | 2 +- .../class/class.LSattr_html_quota.php | 2 +- src/includes/class/class.LSattr_html_rss.php | 2 +- .../class.LSattr_html_sambaAcctFlags.php | 8 +- .../class/class.LSattr_html_select_box.php | 2 +- .../class/class.LSattr_html_select_list.php | 10 +- .../class/class.LSattr_html_select_object.php | 12 +- .../class/class.LSattr_html_ssh_key.php | 2 +- .../class.LSattr_html_supannActivite.php | 2 +- ...LSattr_html_supannAdressePostalePrivee.php | 2 +- ...class.LSattr_html_supannCodePopulation.php | 2 +- .../class.LSattr_html_supannEmpCorps.php | 2 +- .../class.LSattr_html_supannEmpProfil.php | 2 +- .../class.LSattr_html_supannEtablissement.php | 2 +- .../class.LSattr_html_supannEtuDiplome.php | 2 +- ...Sattr_html_supannEtuElementPedagogique.php | 2 +- .../class.LSattr_html_supannEtuEtape.php | 2 +- ...class.LSattr_html_supannEtuInscription.php | 2 +- ...LSattr_html_supannEtuRegimeInscription.php | 2 +- ...ttr_html_supannEtuSecteurDisciplinaire.php | 2 +- ...class.LSattr_html_supannEtuTypeDiplome.php | 2 +- .../class.LSattr_html_supannExtProfil.php | 2 +- .../class.LSattr_html_supannLabeledValue.php | 2 +- .../class.LSattr_html_supannMailPrive.php | 2 +- .../class.LSattr_html_supannRessourceEtat.php | 2 +- ...ss.LSattr_html_supannRessourceEtatDate.php | 2 +- .../class.LSattr_html_supannRoleEntite.php | 2 +- .../class.LSattr_html_supannRoleGenerique.php | 2 +- ...class.LSattr_html_supannTelephonePrive.php | 2 +- .../class.LSattr_html_supannTypeEntite.php | 2 +- src/includes/class/class.LSattr_html_tel.php | 2 +- src/includes/class/class.LSattr_html_text.php | 2 +- .../class/class.LSattr_html_textarea.php | 2 +- src/includes/class/class.LSattr_html_url.php | 2 +- .../class/class.LSattr_html_valueWithUnit.php | 2 +- .../class/class.LSattr_html_wysiwyg.php | 2 +- src/includes/class/class.LSattr_html_xmpp.php | 2 +- src/includes/class/class.LSattr_ldap.php | 40 +- ...class.LSattr_ldap_compositeValueToJSON.php | 28 +- src/includes/class/class.LSattr_ldap_date.php | 18 +- .../class/class.LSattr_ldap_image.php | 2 +- .../class/class.LSattr_ldap_numeric.php | 2 +- .../class/class.LSattr_ldap_password.php | 20 +- .../class/class.LSattr_ldap_postaladdress.php | 16 +- .../class/class.LSattr_ldap_pwdHistory.php | 7 +- .../class/class.LSattr_ldap_shadowExpire.php | 2 +- src/includes/class/class.LSattribute.php | 135 ++++-- src/includes/class/class.LSauth.php | 10 +- src/includes/class/class.LSauthMethod.php | 2 +- src/includes/class/class.LScli.php | 22 +- src/includes/class/class.LSconfig.php | 8 +- src/includes/class/class.LSerror.php | 20 +- src/includes/class/class.LSform.php | 219 +++++++--- src/includes/class/class.LSformElement.php | 155 +++++-- .../class/class.LSformElement_boolean.php | 17 +- .../class/class.LSformElement_date.php | 8 +- .../class/class.LSformElement_image.php | 6 +- ...s.LSformElement_jsonCompositeAttribute.php | 30 +- .../class.LSformElement_labeledValue.php | 4 +- .../class/class.LSformElement_mail.php | 8 +- .../class/class.LSformElement_mailQuota.php | 6 +- .../class/class.LSformElement_maildir.php | 26 +- .../class/class.LSformElement_password.php | 30 +- .../class.LSformElement_postaladdress.php | 7 +- .../class/class.LSformElement_pre.php | 7 +- .../class/class.LSformElement_quota.php | 6 +- .../class/class.LSformElement_rss.php | 6 +- .../class/class.LSformElement_select.php | 19 +- .../class/class.LSformElement_select_box.php | 4 +- .../class.LSformElement_select_object.php | 25 +- .../class/class.LSformElement_ssh_key.php | 4 +- ...LSformElement_supannCompositeAttribute.php | 18 +- ...class.LSformElement_supannLabeledValue.php | 15 +- ....LSformElement_supannRessourceEtatDate.php | 4 +- .../class/class.LSformElement_tel.php | 4 +- .../class/class.LSformElement_text.php | 24 +- .../class/class.LSformElement_textarea.php | 10 +- .../class/class.LSformElement_url.php | 6 +- .../class.LSformElement_valueWithUnit.php | 2 +- .../class/class.LSformElement_wysiwyg.php | 2 +- .../class/class.LSformElement_xmpp.php | 6 +- src/includes/class/class.LSformRule.php | 54 ++- ...rmRule_LSformElement_select_validValue.php | 10 +- .../class/class.LSformRule_alphanumeric.php | 12 +- .../class/class.LSformRule_callable.php | 8 +- .../class/class.LSformRule_compare.php | 43 +- src/includes/class/class.LSformRule_date.php | 22 +- .../class.LSformRule_differentPassword.php | 12 +- src/includes/class/class.LSformRule_email.php | 14 +- .../class/class.LSformRule_filesize.php | 16 +- .../class/class.LSformRule_imagefile.php | 10 +- .../class/class.LSformRule_imagesize.php | 20 +- .../class/class.LSformRule_inarray.php | 6 +- .../class/class.LSformRule_integer.php | 12 +- .../class/class.LSformRule_ldapSearchURI.php | 12 +- .../class/class.LSformRule_lettersonly.php | 10 +- .../class/class.LSformRule_maxlength.php | 14 +- .../class/class.LSformRule_mimetype.php | 12 +- .../class/class.LSformRule_minlength.php | 14 +- .../class/class.LSformRule_nonzero.php | 10 +- .../class/class.LSformRule_nopunctuation.php | 10 +- .../class/class.LSformRule_numberOfValues.php | 16 +- .../class/class.LSformRule_numeric.php | 10 +- .../class/class.LSformRule_password.php | 24 +- .../class/class.LSformRule_rangelength.php | 16 +- src/includes/class/class.LSformRule_regex.php | 14 +- .../class/class.LSformRule_required.php | 10 +- .../class/class.LSformRule_ssh_pub_key.php | 4 +- .../class.LSformRule_telephonenumber.php | 12 +- .../class/class.LSformRule_zxcvbn.php | 9 +- src/includes/class/class.LSio.php | 36 +- src/includes/class/class.LSioFormat.php | 31 +- src/includes/class/class.LSioFormatCSV.php | 50 ++- src/includes/class/class.LSioFormatDriver.php | 18 +- src/includes/class/class.LSlang.php | 133 +++++- src/includes/class/class.LSldap.php | 117 ++--- src/includes/class/class.LSldapObject.php | 305 ++++++++----- src/includes/class/class.LSlog.php | 52 ++- src/includes/class/class.LSlog_console.php | 16 +- src/includes/class/class.LSlog_email.php | 17 +- src/includes/class/class.LSlog_file.php | 4 +- src/includes/class/class.LSlog_handler.php | 89 ++-- src/includes/class/class.LSlog_logger.php | 29 +- .../class/class.LSlog_staticLoggerClass.php | 4 +- src/includes/class/class.LSlog_syslog.php | 32 +- src/includes/class/class.LSlog_system.php | 12 +- .../class/class.LSobjects.LSgroup.php | 6 +- src/includes/class/class.LSrelation.php | 77 +++- src/includes/class/class.LSsearch.php | 122 ++++-- src/includes/class/class.LSsearchEntry.php | 95 +++-- src/includes/class/class.LSselect.php | 8 +- src/includes/class/class.LSsession.php | 399 +++++++++++------- src/includes/class/class.LStemplate.php | 152 ++++--- .../class.LStemplate_smarty2_support.php | 2 + src/includes/class/class.LSurl.php | 29 +- src/includes/class/class.LSurlRequest.php | 40 +- src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po | 2 +- 161 files changed, 2526 insertions(+), 1277 deletions(-) create mode 100644 .phpstan/config.neon create mode 100644 .phpstan/init.php create mode 100644 composer.lock delete mode 100644 phpstan.neon diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 162ef6f1..532a028a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/.phpstan/config.neon b/.phpstan/config.neon new file mode 100644 index 00000000..75457b58 --- /dev/null +++ b/.phpstan/config.neon @@ -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 diff --git a/.phpstan/init.php b/.phpstan/init.php new file mode 100644 index 00000000..a8dc2da6 --- /dev/null +++ b/.phpstan/init.php @@ -0,0 +1,10 @@ + /** * 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')); diff --git a/docker/Dockerfile b/docker/Dockerfile index 2b9492c7..56e618a5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index a9dcc7b6..00000000 --- a/phpstan.neon +++ /dev/null @@ -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 diff --git a/src/includes/addons/LSaddons.asterisk.php b/src/includes/addons/LSaddons.asterisk.php index c7241fec..554de26f 100644 --- a/src/includes/addons/LSaddons.asterisk.php +++ b/src/includes/addons/LSaddons.asterisk.php @@ -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'); diff --git a/src/includes/addons/LSaddons.mailquota.php b/src/includes/addons/LSaddons.mailquota.php index 2d55e7b1..4e812d32 100644 --- a/src/includes/addons/LSaddons.mailquota.php +++ b/src/includes/addons/LSaddons.mailquota.php @@ -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 **/ diff --git a/src/includes/addons/LSaddons.ppolicy.php b/src/includes/addons/LSaddons.ppolicy.php index 7a86e285..7af52b58 100644 --- a/src/includes/addons/LSaddons.ppolicy.php +++ b/src/includes/addons/LSaddons.ppolicy.php @@ -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 * @@ -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')); diff --git a/src/includes/addons/LSaddons.samba.php b/src/includes/addons/LSaddons.samba.php index 61804442..5ebf6700 100644 --- a/src/includes/addons/LSaddons.samba.php +++ b/src/includes/addons/LSaddons.samba.php @@ -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 - * @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 * * @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 * * @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 * * @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 * * @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 * * @return string The sambaPrimaryGroupSID value on success, false otherwise @@ -232,7 +235,7 @@ function generate_sambaPrimaryGroupSID($ldapObject) { * * @author Benjamin Renard * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @param LSldapObjet $ldapObject The user LSldapObjet object + * @param LSldapObject $ldapObject The user LSldapObject object * * @return string The sambaKickoffTime attribute value */ diff --git a/src/includes/addons/LSaddons.ssh.php b/src/includes/addons/LSaddons.ssh.php index cb0f5b02..abc38c87 100644 --- a/src/includes/addons/LSaddons.ssh.php +++ b/src/includes/addons/LSaddons.ssh.php @@ -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 * - * @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 * - * @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 * - * @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 * - * @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 diff --git a/src/includes/addons/LSaddons.supann.php b/src/includes/addons/LSaddons.supann.php index d3c70779..83a01d10 100644 --- a/src/includes/addons/LSaddons.supann.php +++ b/src/includes/addons/LSaddons.supann.php @@ -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)) diff --git a/src/includes/class/class.LSattr_html.php b/src/includes/class/class.LSattr_html.php index d41f0ca5..a0a8d578 100644 --- a/src/includes/class/class.LSattr_html.php +++ b/src/includes/class/class.LSattr_html.php @@ -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..attrs.) + * @var array + */ + 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 **/ diff --git a/src/includes/class/class.LSattr_html_boolean.php b/src/includes/class/class.LSattr_html_boolean.php index 694947b7..f7034603 100644 --- a/src/includes/class/class.LSattr_html_boolean.php +++ b/src/includes/class/class.LSattr_html_boolean.php @@ -27,6 +27,6 @@ */ class LSattr_html_boolean extends LSattr_html { - var $LSformElement_type = 'boolean'; + var string $LSformElement_type = 'boolean'; } diff --git a/src/includes/class/class.LSattr_html_date.php b/src/includes/class/class.LSattr_html_date.php index d8bb9446..c7c6e82a 100644 --- a/src/includes/class/class.LSattr_html_date.php +++ b/src/includes/class/class.LSattr_html_date.php @@ -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 ) ) ); diff --git a/src/includes/class/class.LSattr_html_image.php b/src/includes/class/class.LSattr_html_image.php index d1d6e90f..f0ddded0 100644 --- a/src/includes/class/class.LSattr_html_image.php +++ b/src/includes/class/class.LSattr_html_image.php @@ -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; } diff --git a/src/includes/class/class.LSattr_html_jsonCompositeAttribute.php b/src/includes/class/class.LSattr_html_jsonCompositeAttribute.php index 4b87ba62..959fb856 100644 --- a/src/includes/class/class.LSattr_html_jsonCompositeAttribute.php +++ b/src/includes/class/class.LSattr_html_jsonCompositeAttribute.php @@ -27,6 +27,6 @@ */ class LSattr_html_jsonCompositeAttribute extends LSattr_html { - var $LSformElement_type = 'jsonCompositeAttribute'; + var string $LSformElement_type = 'jsonCompositeAttribute'; } diff --git a/src/includes/class/class.LSattr_html_labeledValue.php b/src/includes/class/class.LSattr_html_labeledValue.php index a22e16f1..c314875a 100644 --- a/src/includes/class/class.LSattr_html_labeledValue.php +++ b/src/includes/class/class.LSattr_html_labeledValue.php @@ -27,6 +27,6 @@ */ class LSattr_html_labeledValue extends LSattr_html { - var $LSformElement_type = 'labeledValue'; + var string $LSformElement_type = 'labeledValue'; } diff --git a/src/includes/class/class.LSattr_html_mail.php b/src/includes/class/class.LSattr_html_mail.php index 0d29809c..148f71a7 100644 --- a/src/includes/class/class.LSattr_html_mail.php +++ b/src/includes/class/class.LSattr_html_mail.php @@ -27,6 +27,6 @@ */ class LSattr_html_mail extends LSattr_html { - var $LSformElement_type = 'mail'; + var string $LSformElement_type = 'mail'; } diff --git a/src/includes/class/class.LSattr_html_mailQuota.php b/src/includes/class/class.LSattr_html_mailQuota.php index d8e20dcb..bc174379 100644 --- a/src/includes/class/class.LSattr_html_mailQuota.php +++ b/src/includes/class/class.LSattr_html_mailQuota.php @@ -27,6 +27,6 @@ */ class LSattr_html_mailQuota extends LSattr_html { - var $LSformElement_type = 'mailQuota'; + var string $LSformElement_type = 'mailQuota'; } diff --git a/src/includes/class/class.LSattr_html_maildir.php b/src/includes/class/class.LSattr_html_maildir.php index e71aa094..76e24ae6 100644 --- a/src/includes/class/class.LSattr_html_maildir.php +++ b/src/includes/class/class.LSattr_html_maildir.php @@ -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) { diff --git a/src/includes/class/class.LSattr_html_password.php b/src/includes/class/class.LSattr_html_password.php index 2f6e16d6..80cd1a80 100644 --- a/src/includes/class/class.LSattr_html_password.php +++ b/src/includes/class/class.LSattr_html_password.php @@ -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; } diff --git a/src/includes/class/class.LSattr_html_postaladdress.php b/src/includes/class/class.LSattr_html_postaladdress.php index 55ae8fe9..ad1ad085 100644 --- a/src/includes/class/class.LSattr_html_postaladdress.php +++ b/src/includes/class/class.LSattr_html_postaladdress.php @@ -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'; } diff --git a/src/includes/class/class.LSattr_html_pre.php b/src/includes/class/class.LSattr_html_pre.php index d76e6b6e..6b18b007 100644 --- a/src/includes/class/class.LSattr_html_pre.php +++ b/src/includes/class/class.LSattr_html_pre.php @@ -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'; } diff --git a/src/includes/class/class.LSattr_html_quota.php b/src/includes/class/class.LSattr_html_quota.php index a169df45..7942680c 100644 --- a/src/includes/class/class.LSattr_html_quota.php +++ b/src/includes/class/class.LSattr_html_quota.php @@ -27,6 +27,6 @@ */ class LSattr_html_quota extends LSattr_html { - var $LSformElement_type = 'quota'; + var string $LSformElement_type = 'quota'; } diff --git a/src/includes/class/class.LSattr_html_rss.php b/src/includes/class/class.LSattr_html_rss.php index ce41737f..57750077 100644 --- a/src/includes/class/class.LSattr_html_rss.php +++ b/src/includes/class/class.LSattr_html_rss.php @@ -27,6 +27,6 @@ */ class LSattr_html_rss extends LSattr_html { - var $LSformElement_type = 'rss'; + var string $LSformElement_type = 'rss'; } diff --git a/src/includes/class/class.LSattr_html_sambaAcctFlags.php b/src/includes/class/class.LSattr_html_sambaAcctFlags.php index cb7ddafd..cc7b74be 100644 --- a/src/includes/class/class.LSattr_html_sambaAcctFlags.php +++ b/src/includes/class/class.LSattr_html_sambaAcctFlags.php @@ -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 * diff --git a/src/includes/class/class.LSattr_html_select_box.php b/src/includes/class/class.LSattr_html_select_box.php index b9f6fc0b..d6e2b07d 100644 --- a/src/includes/class/class.LSattr_html_select_box.php +++ b/src/includes/class/class.LSattr_html_select_box.php @@ -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'; } diff --git a/src/includes/class/class.LSattr_html_select_list.php b/src/includes/class/class.LSattr_html_select_list.php index cb8767ee..ea2a0c61 100644 --- a/src/includes/class/class.LSattr_html_select_list.php +++ b/src/includes/class/class.LSattr_html_select_list.php @@ -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 * @@ -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 * diff --git a/src/includes/class/class.LSattr_html_select_object.php b/src/includes/class/class.LSattr_html_select_object.php index fac10d73..2ec7b13c 100644 --- a/src/includes/class/class.LSattr_html_select_object.php +++ b/src/includes/class/class.LSattr_html_select_object.php @@ -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 + */ + 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')) **/ diff --git a/src/includes/class/class.LSattr_html_ssh_key.php b/src/includes/class/class.LSattr_html_ssh_key.php index 153d7f86..b10386e6 100644 --- a/src/includes/class/class.LSattr_html_ssh_key.php +++ b/src/includes/class/class.LSattr_html_ssh_key.php @@ -27,6 +27,6 @@ */ class LSattr_html_ssh_key extends LSattr_html { - var $LSformElement_type = 'ssh_key'; + var string $LSformElement_type = 'ssh_key'; } diff --git a/src/includes/class/class.LSattr_html_supannActivite.php b/src/includes/class/class.LSattr_html_supannActivite.php index 144129e1..09cc42bf 100644 --- a/src/includes/class/class.LSattr_html_supannActivite.php +++ b/src/includes/class/class.LSattr_html_supannActivite.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannActivite extends LSattr_html { - var $LSformElement_type = 'supannActivite'; + var string $LSformElement_type = 'supannActivite'; } diff --git a/src/includes/class/class.LSattr_html_supannAdressePostalePrivee.php b/src/includes/class/class.LSattr_html_supannAdressePostalePrivee.php index 8b51edf2..b06141c1 100644 --- a/src/includes/class/class.LSattr_html_supannAdressePostalePrivee.php +++ b/src/includes/class/class.LSattr_html_supannAdressePostalePrivee.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannAdressePostalePrivee extends LSattr_html { - var $LSformElement_type = 'supannAdressePostalePrivee'; + var string $LSformElement_type = 'supannAdressePostalePrivee'; } diff --git a/src/includes/class/class.LSattr_html_supannCodePopulation.php b/src/includes/class/class.LSattr_html_supannCodePopulation.php index ffc9b99b..8d311a69 100644 --- a/src/includes/class/class.LSattr_html_supannCodePopulation.php +++ b/src/includes/class/class.LSattr_html_supannCodePopulation.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannCodePopulation extends LSattr_html { - var $LSformElement_type = 'supannCodePopulation'; + var string $LSformElement_type = 'supannCodePopulation'; } diff --git a/src/includes/class/class.LSattr_html_supannEmpCorps.php b/src/includes/class/class.LSattr_html_supannEmpCorps.php index 839f1307..7946aeb7 100644 --- a/src/includes/class/class.LSattr_html_supannEmpCorps.php +++ b/src/includes/class/class.LSattr_html_supannEmpCorps.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEmpCorps extends LSattr_html { - var $LSformElement_type = 'supannEmpCorps'; + var string $LSformElement_type = 'supannEmpCorps'; } diff --git a/src/includes/class/class.LSattr_html_supannEmpProfil.php b/src/includes/class/class.LSattr_html_supannEmpProfil.php index e11a2a0a..cbfe73f9 100644 --- a/src/includes/class/class.LSattr_html_supannEmpProfil.php +++ b/src/includes/class/class.LSattr_html_supannEmpProfil.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEmpProfil extends LSattr_html { - var $LSformElement_type = 'supannEmpProfil'; + var string $LSformElement_type = 'supannEmpProfil'; } diff --git a/src/includes/class/class.LSattr_html_supannEtablissement.php b/src/includes/class/class.LSattr_html_supannEtablissement.php index 91411313..fa46ed11 100644 --- a/src/includes/class/class.LSattr_html_supannEtablissement.php +++ b/src/includes/class/class.LSattr_html_supannEtablissement.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEtablissement extends LSattr_html { - var $LSformElement_type = 'supannEtablissement'; + var string $LSformElement_type = 'supannEtablissement'; } diff --git a/src/includes/class/class.LSattr_html_supannEtuDiplome.php b/src/includes/class/class.LSattr_html_supannEtuDiplome.php index e078e93d..aafb835a 100644 --- a/src/includes/class/class.LSattr_html_supannEtuDiplome.php +++ b/src/includes/class/class.LSattr_html_supannEtuDiplome.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEtuDiplome extends LSattr_html { - var $LSformElement_type = 'supannEtuDiplome'; + var string $LSformElement_type = 'supannEtuDiplome'; } diff --git a/src/includes/class/class.LSattr_html_supannEtuElementPedagogique.php b/src/includes/class/class.LSattr_html_supannEtuElementPedagogique.php index 245ef50f..4ccd11ad 100644 --- a/src/includes/class/class.LSattr_html_supannEtuElementPedagogique.php +++ b/src/includes/class/class.LSattr_html_supannEtuElementPedagogique.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEtuElementPedagogique extends LSattr_html { - var $LSformElement_type = 'supannEtuElementPedagogique'; + var string $LSformElement_type = 'supannEtuElementPedagogique'; } diff --git a/src/includes/class/class.LSattr_html_supannEtuEtape.php b/src/includes/class/class.LSattr_html_supannEtuEtape.php index 2f55e6ea..b40de4b9 100644 --- a/src/includes/class/class.LSattr_html_supannEtuEtape.php +++ b/src/includes/class/class.LSattr_html_supannEtuEtape.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEtuEtape extends LSattr_html { - var $LSformElement_type = 'supannEtuEtape'; + var string $LSformElement_type = 'supannEtuEtape'; } diff --git a/src/includes/class/class.LSattr_html_supannEtuInscription.php b/src/includes/class/class.LSattr_html_supannEtuInscription.php index d2713583..b1cc28ed 100644 --- a/src/includes/class/class.LSattr_html_supannEtuInscription.php +++ b/src/includes/class/class.LSattr_html_supannEtuInscription.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEtuInscription extends LSattr_html { - var $LSformElement_type = 'supannEtuInscription'; + var string $LSformElement_type = 'supannEtuInscription'; } diff --git a/src/includes/class/class.LSattr_html_supannEtuRegimeInscription.php b/src/includes/class/class.LSattr_html_supannEtuRegimeInscription.php index 0ce8f915..28e9a3a2 100644 --- a/src/includes/class/class.LSattr_html_supannEtuRegimeInscription.php +++ b/src/includes/class/class.LSattr_html_supannEtuRegimeInscription.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEtuRegimeInscription extends LSattr_html { - var $LSformElement_type = 'supannEtuRegimeInscription'; + var string $LSformElement_type = 'supannEtuRegimeInscription'; } diff --git a/src/includes/class/class.LSattr_html_supannEtuSecteurDisciplinaire.php b/src/includes/class/class.LSattr_html_supannEtuSecteurDisciplinaire.php index 118b0edb..e714516e 100644 --- a/src/includes/class/class.LSattr_html_supannEtuSecteurDisciplinaire.php +++ b/src/includes/class/class.LSattr_html_supannEtuSecteurDisciplinaire.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEtuSecteurDisciplinaire extends LSattr_html { - var $LSformElement_type = 'supannEtuSecteurDisciplinaire'; + var string $LSformElement_type = 'supannEtuSecteurDisciplinaire'; } diff --git a/src/includes/class/class.LSattr_html_supannEtuTypeDiplome.php b/src/includes/class/class.LSattr_html_supannEtuTypeDiplome.php index ac9e9d15..ced79697 100644 --- a/src/includes/class/class.LSattr_html_supannEtuTypeDiplome.php +++ b/src/includes/class/class.LSattr_html_supannEtuTypeDiplome.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannEtuTypeDiplome extends LSattr_html { - var $LSformElement_type = 'supannEtuTypeDiplome'; + var string $LSformElement_type = 'supannEtuTypeDiplome'; } diff --git a/src/includes/class/class.LSattr_html_supannExtProfil.php b/src/includes/class/class.LSattr_html_supannExtProfil.php index 587344ed..736c0109 100644 --- a/src/includes/class/class.LSattr_html_supannExtProfil.php +++ b/src/includes/class/class.LSattr_html_supannExtProfil.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannExtProfil extends LSattr_html { - var $LSformElement_type = 'supannExtProfil'; + var string $LSformElement_type = 'supannExtProfil'; } diff --git a/src/includes/class/class.LSattr_html_supannLabeledValue.php b/src/includes/class/class.LSattr_html_supannLabeledValue.php index bf8313b1..6b9f2e88 100644 --- a/src/includes/class/class.LSattr_html_supannLabeledValue.php +++ b/src/includes/class/class.LSattr_html_supannLabeledValue.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannLabeledValue extends LSattr_html { - var $LSformElement_type = 'supannLabeledValue'; + var string $LSformElement_type = 'supannLabeledValue'; } diff --git a/src/includes/class/class.LSattr_html_supannMailPrive.php b/src/includes/class/class.LSattr_html_supannMailPrive.php index e232aec3..2fa2ff1f 100644 --- a/src/includes/class/class.LSattr_html_supannMailPrive.php +++ b/src/includes/class/class.LSattr_html_supannMailPrive.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannMailPrive extends LSattr_html { - var $LSformElement_type = 'supannMailPrive'; + var string $LSformElement_type = 'supannMailPrive'; } diff --git a/src/includes/class/class.LSattr_html_supannRessourceEtat.php b/src/includes/class/class.LSattr_html_supannRessourceEtat.php index 6e0a24bb..e6969691 100644 --- a/src/includes/class/class.LSattr_html_supannRessourceEtat.php +++ b/src/includes/class/class.LSattr_html_supannRessourceEtat.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannRessourceEtat extends LSattr_html { - var $LSformElement_type = 'supannRessourceEtat'; + var string $LSformElement_type = 'supannRessourceEtat'; } diff --git a/src/includes/class/class.LSattr_html_supannRessourceEtatDate.php b/src/includes/class/class.LSattr_html_supannRessourceEtatDate.php index 66550a8c..f870f6b8 100644 --- a/src/includes/class/class.LSattr_html_supannRessourceEtatDate.php +++ b/src/includes/class/class.LSattr_html_supannRessourceEtatDate.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannRessourceEtatDate extends LSattr_html { - var $LSformElement_type = 'supannRessourceEtatDate'; + var string $LSformElement_type = 'supannRessourceEtatDate'; } diff --git a/src/includes/class/class.LSattr_html_supannRoleEntite.php b/src/includes/class/class.LSattr_html_supannRoleEntite.php index 78bd1c5f..98d45ecd 100644 --- a/src/includes/class/class.LSattr_html_supannRoleEntite.php +++ b/src/includes/class/class.LSattr_html_supannRoleEntite.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannRoleEntite extends LSattr_html { - var $LSformElement_type = 'supannRoleEntite'; + var string $LSformElement_type = 'supannRoleEntite'; } diff --git a/src/includes/class/class.LSattr_html_supannRoleGenerique.php b/src/includes/class/class.LSattr_html_supannRoleGenerique.php index 8e3c4bad..4d13643d 100644 --- a/src/includes/class/class.LSattr_html_supannRoleGenerique.php +++ b/src/includes/class/class.LSattr_html_supannRoleGenerique.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannRoleGenerique extends LSattr_html { - var $LSformElement_type = 'supannRoleGenerique'; + var string $LSformElement_type = 'supannRoleGenerique'; } diff --git a/src/includes/class/class.LSattr_html_supannTelephonePrive.php b/src/includes/class/class.LSattr_html_supannTelephonePrive.php index 64a76dac..91e0545c 100644 --- a/src/includes/class/class.LSattr_html_supannTelephonePrive.php +++ b/src/includes/class/class.LSattr_html_supannTelephonePrive.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannTelephonePrive extends LSattr_html { - var $LSformElement_type = 'supannTelephonePrive'; + var string $LSformElement_type = 'supannTelephonePrive'; } diff --git a/src/includes/class/class.LSattr_html_supannTypeEntite.php b/src/includes/class/class.LSattr_html_supannTypeEntite.php index b175ca65..ee9dfa31 100644 --- a/src/includes/class/class.LSattr_html_supannTypeEntite.php +++ b/src/includes/class/class.LSattr_html_supannTypeEntite.php @@ -27,6 +27,6 @@ */ class LSattr_html_supannTypeEntite extends LSattr_html { - var $LSformElement_type = 'supannTypeEntite'; + var string $LSformElement_type = 'supannTypeEntite'; } diff --git a/src/includes/class/class.LSattr_html_tel.php b/src/includes/class/class.LSattr_html_tel.php index fe5d79b0..f870f55d 100644 --- a/src/includes/class/class.LSattr_html_tel.php +++ b/src/includes/class/class.LSattr_html_tel.php @@ -27,6 +27,6 @@ */ class LSattr_html_tel extends LSattr_html { - var $LSformElement_type = 'tel'; + var string $LSformElement_type = 'tel'; } diff --git a/src/includes/class/class.LSattr_html_text.php b/src/includes/class/class.LSattr_html_text.php index 9e993b65..738040a5 100644 --- a/src/includes/class/class.LSattr_html_text.php +++ b/src/includes/class/class.LSattr_html_text.php @@ -27,6 +27,6 @@ */ class LSattr_html_text extends LSattr_html { - var $LSformElement_type = 'text'; + var string $LSformElement_type = 'text'; } diff --git a/src/includes/class/class.LSattr_html_textarea.php b/src/includes/class/class.LSattr_html_textarea.php index 72fbccc8..27c7062c 100644 --- a/src/includes/class/class.LSattr_html_textarea.php +++ b/src/includes/class/class.LSattr_html_textarea.php @@ -27,6 +27,6 @@ */ class LSattr_html_textarea extends LSattr_html { - var $LSformElement_type = 'textarea'; + var string $LSformElement_type = 'textarea'; } diff --git a/src/includes/class/class.LSattr_html_url.php b/src/includes/class/class.LSattr_html_url.php index 31aeb80a..17671dc8 100644 --- a/src/includes/class/class.LSattr_html_url.php +++ b/src/includes/class/class.LSattr_html_url.php @@ -27,6 +27,6 @@ */ class LSattr_html_url extends LSattr_html { - var $LSformElement_type = 'url'; + var string $LSformElement_type = 'url'; } diff --git a/src/includes/class/class.LSattr_html_valueWithUnit.php b/src/includes/class/class.LSattr_html_valueWithUnit.php index a06e7921..3b7004df 100644 --- a/src/includes/class/class.LSattr_html_valueWithUnit.php +++ b/src/includes/class/class.LSattr_html_valueWithUnit.php @@ -27,6 +27,6 @@ */ class LSattr_html_valueWithUnit extends LSattr_html { - var $LSformElement_type = 'valueWithUnit'; + var string $LSformElement_type = 'valueWithUnit'; } diff --git a/src/includes/class/class.LSattr_html_wysiwyg.php b/src/includes/class/class.LSattr_html_wysiwyg.php index 45629717..196da319 100644 --- a/src/includes/class/class.LSattr_html_wysiwyg.php +++ b/src/includes/class/class.LSattr_html_wysiwyg.php @@ -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'; } diff --git a/src/includes/class/class.LSattr_html_xmpp.php b/src/includes/class/class.LSattr_html_xmpp.php index 8add37c3..bdcc7936 100644 --- a/src/includes/class/class.LSattr_html_xmpp.php +++ b/src/includes/class/class.LSattr_html_xmpp.php @@ -27,6 +27,6 @@ */ class LSattr_html_xmpp extends LSattr_html { - var $LSformElement_type = 'xmpp'; + var string $LSformElement_type = 'xmpp'; } diff --git a/src/includes/class/class.LSattr_ldap.php b/src/includes/class/class.LSattr_ldap.php index d9f6c8d6..9cca9a04 100644 --- a/src/includes/class/class.LSattr_ldap.php +++ b/src/includes/class/class.LSattr_ldap.php @@ -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 */ class LSattr_ldap extends LSlog_staticLoggerClass { - var $name; - var $config; - var $attribute; + /** + * LDAP attribute name + * @var string + */ + var string $name; + + /** + * Attribute configuration (LSobjects..attrs.) + * @var array + */ + 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 **/ diff --git a/src/includes/class/class.LSattr_ldap_compositeValueToJSON.php b/src/includes/class/class.LSattr_ldap_compositeValueToJSON.php index 91b40888..b16dcf2e 100644 --- a/src/includes/class/class.LSattr_ldap_compositeValueToJSON.php +++ b/src/includes/class/class.LSattr_ldap_compositeValueToJSON.php @@ -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 = ""; diff --git a/src/includes/class/class.LSattr_ldap_date.php b/src/includes/class/class.LSattr_ldap_date.php index b530d7d4..e195bbce 100644 --- a/src/includes/class/class.LSattr_ldap_date.php +++ b/src/includes/class/class.LSattr_ldap_date.php @@ -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'); diff --git a/src/includes/class/class.LSattr_ldap_image.php b/src/includes/class/class.LSattr_ldap_image.php index 3a2604e0..84ab7e88 100644 --- a/src/includes/class/class.LSattr_ldap_image.php +++ b/src/includes/class/class.LSattr_ldap_image.php @@ -21,7 +21,7 @@ ******************************************************************************/ /** - * Type d'attribut Ldap image + * LDAP attribute type image * * @author Benjamin Renard */ diff --git a/src/includes/class/class.LSattr_ldap_numeric.php b/src/includes/class/class.LSattr_ldap_numeric.php index 6f4a9c4a..c6e109b1 100644 --- a/src/includes/class/class.LSattr_ldap_numeric.php +++ b/src/includes/class/class.LSattr_ldap_numeric.php @@ -21,7 +21,7 @@ ******************************************************************************/ /** - * Type d'attribut Ldap numeric + * LDAP attribute type numeric * * @author Benjamin Renard */ diff --git a/src/includes/class/class.LSattr_ldap_password.php b/src/includes/class/class.LSattr_ldap_password.php index 898e33d8..3baa0b27 100644 --- a/src/includes/class/class.LSattr_ldap_password.php +++ b/src/includes/class/class.LSattr_ldap_password.php @@ -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)) diff --git a/src/includes/class/class.LSattr_ldap_postaladdress.php b/src/includes/class/class.LSattr_ldap_postaladdress.php index f3971677..ee499433 100644 --- a/src/includes/class/class.LSattr_ldap_postaladdress.php +++ b/src/includes/class/class.LSattr_ldap_postaladdress.php @@ -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(); diff --git a/src/includes/class/class.LSattr_ldap_pwdHistory.php b/src/includes/class/class.LSattr_ldap_pwdHistory.php index 8ffac9ee..dbc86e3b 100644 --- a/src/includes/class/class.LSattr_ldap_pwdHistory.php +++ b/src/includes/class/class.LSattr_ldap_pwdHistory.php @@ -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'); diff --git a/src/includes/class/class.LSattr_ldap_shadowExpire.php b/src/includes/class/class.LSattr_ldap_shadowExpire.php index be2a7e2a..6b831724 100644 --- a/src/includes/class/class.LSattr_ldap_shadowExpire.php +++ b/src/includes/class/class.LSattr_ldap_shadowExpire.php @@ -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. diff --git a/src/includes/class/class.LSattribute.php b/src/includes/class/class.LSattribute.php index 536aab58..56ad002e 100644 --- a/src/includes/class/class.LSattribute.php +++ b/src/includes/class/class.LSattribute.php @@ -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..attrs.) + * @var array + */ + 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 + */ + 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 + */ + var array $_events=array(); + + /** + * Object registered hooks on event trigger object methods + * @see LSattribute::addObjectEvent() + * @see LSattribute::fireEvent() + * @var array + */ + var array $_objectEvents=array(); /** * Constructeur @@ -56,7 +131,7 @@ class LSattribute extends LSlog_staticLoggerClass { * @author Benjamin Renard * * @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 * @@ -313,7 +388,7 @@ class LSattribute extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @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 * - * @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 * - * @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 * - * @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 * @@ -431,7 +506,7 @@ class LSattribute extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @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 **/ diff --git a/src/includes/class/class.LSauth.php b/src/includes/class/class.LSauth.php index 62c1c83d..00de562a 100644 --- a/src/includes/class/class.LSauth.php +++ b/src/includes/class/class.LSauth.php @@ -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 **/ diff --git a/src/includes/class/class.LSauthMethod.php b/src/includes/class/class.LSauthMethod.php index 9c127105..18519ce4 100644 --- a/src/includes/class/class.LSauthMethod.php +++ b/src/includes/class/class.LSauthMethod.php @@ -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 **/ diff --git a/src/includes/class/class.LScli.php b/src/includes/class/class.LScli.php index 431c13ac..2a71973e 100644 --- a/src/includes/class/class.LScli.php +++ b/src/includes/class/class.LScli.php @@ -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 diff --git a/src/includes/class/class.LSconfig.php b/src/includes/class/class.LSconfig.php index b8ac7594..58e2a584 100644 --- a/src/includes/class/class.LSconfig.php +++ b/src/includes/class/class.LSconfig.php @@ -27,7 +27,13 @@ */ class LSconfig { - // Configuration Data + /** + * Configuration Data + * @see LSconfig::start() + * @see $GLOBALS['LSconfig'] + * @see $GLOBALS['LSaddons'] + * @var array + */ private static $data=array(); /** diff --git a/src/includes/class/class.LSerror.php b/src/includes/class/class.LSerror.php index 4a2d8971..e0cce271 100644 --- a/src/includes/class/class.LSerror.php +++ b/src/includes/class/class.LSerror.php @@ -29,6 +29,10 @@ */ class LSerror { + /** + * Registered error codes + * @var 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 "

"._('Errors')."

\n"; print self :: display(true); @@ -118,7 +122,7 @@ class LSerror { * * @author Benjamin Renard * - * @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 * - * @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 * - * @retvat boolean + * @return boolean */ public static function errorsDefined() { return ( @@ -180,7 +188,7 @@ class LSerror { * * @author Benjamin Renard * - * @retvat void + * @return void */ private static function resetError() { if (isset($_SESSION['LSerror'])) diff --git a/src/includes/class/class.LSform.php b/src/includes/class/class.LSform.php index aa5340ab..c61acb24 100644 --- a/src/includes/class/class.LSform.php +++ b/src/includes/class/class.LSform.php @@ -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..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 + */ + var array $elements = array(); + + /** + * Registred elements's rules + * @var array + */ + var array $_rules = array(); + + /** + * Post data of the form + * @see LSform::getPostData() + * @var array + */ + var array $_postData = array(); + + /** + * Registered elements's errors + * @see LSform::setElementError() + * @see LSform::definedError() + * @see LSform::getErrors() + * @var 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 + */ 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..LSform.dataEntryForm.) + * @see LSform::applyDataEntryForm() + * @var array|null + */ var $dataEntryFormConfig = NULL; - var $warnings = array(); + /** + * Registred warnings + * @see LSform::addWarning() + * @var array + */ + 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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 * - * @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 */ diff --git a/src/includes/class/class.LSformElement.php b/src/includes/class/class.LSformElement.php index 1825ccea..7bd0552e 100644 --- a/src/includes/class/class.LSformElement.php +++ b/src/includes/class/class.LSformElement.php @@ -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..attrs.) + * @see LSformElement::getParam() + * @var array + */ + var array $params; + + /** + * Values of the element + * @var array + */ + 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 + */ + 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; + } } diff --git a/src/includes/class/class.LSformElement_boolean.php b/src/includes/class/class.LSformElement_boolean.php index cc87d9c9..486fa1ec 100644 --- a/src/includes/class/class.LSformElement_boolean.php +++ b/src/includes/class/class.LSformElement_boolean.php @@ -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 */ diff --git a/src/includes/class/class.LSformElement_date.php b/src/includes/class/class.LSformElement_date.php index c44db788..52a0fad4 100644 --- a/src/includes/class/class.LSformElement_date.php +++ b/src/includes/class/class.LSformElement_date.php @@ -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 diff --git a/src/includes/class/class.LSformElement_image.php b/src/includes/class/class.LSformElement_image.php index 946c92a3..bb4158b7 100644 --- a/src/includes/class/class.LSformElement_image.php +++ b/src/includes/class/class.LSformElement_image.php @@ -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 diff --git a/src/includes/class/class.LSformElement_jsonCompositeAttribute.php b/src/includes/class/class.LSformElement_jsonCompositeAttribute.php index 2e0a03a8..b7569e56 100644 --- a/src/includes/class/class.LSformElement_jsonCompositeAttribute.php +++ b/src/includes/class/class.LSformElement_jsonCompositeAttribute.php @@ -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 diff --git a/src/includes/class/class.LSformElement_labeledValue.php b/src/includes/class/class.LSformElement_labeledValue.php index 6e3f2bb8..4dcd504a 100644 --- a/src/includes/class/class.LSformElement_labeledValue.php +++ b/src/includes/class/class.LSformElement_labeledValue.php @@ -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 diff --git a/src/includes/class/class.LSformElement_mail.php b/src/includes/class/class.LSformElement_mail.php index 517723aa..322be4eb 100644 --- a/src/includes/class/class.LSformElement_mail.php +++ b/src/includes/class/class.LSformElement_mail.php @@ -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 diff --git a/src/includes/class/class.LSformElement_mailQuota.php b/src/includes/class/class.LSformElement_mailQuota.php index 221d73f5..56da168e 100644 --- a/src/includes/class/class.LSformElement_mailQuota.php +++ b/src/includes/class/class.LSformElement_mailQuota.php @@ -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']; diff --git a/src/includes/class/class.LSformElement_maildir.php b/src/includes/class/class.LSformElement_maildir.php index 115f038d..99ff784a 100644 --- a/src/includes/class/class.LSformElement_maildir.php +++ b/src/includes/class/class.LSformElement_maildir.php @@ -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; + } } } } diff --git a/src/includes/class/class.LSformElement_password.php b/src/includes/class/class.LSformElement_password.php index c580f745..82072f0d 100644 --- a/src/includes/class/class.LSformElement_password.php +++ b/src/includes/class/class.LSformElement_password.php @@ -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 */ diff --git a/src/includes/class/class.LSformElement_postaladdress.php b/src/includes/class/class.LSformElement_postaladdress.php index a3dd13da..f444ce7d 100644 --- a/src/includes/class/class.LSformElement_postaladdress.php +++ b/src/includes/class/class.LSformElement_postaladdress.php @@ -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 diff --git a/src/includes/class/class.LSformElement_pre.php b/src/includes/class/class.LSformElement_pre.php index 97b77a1d..95bd1ed9 100644 --- a/src/includes/class/class.LSformElement_pre.php +++ b/src/includes/class/class.LSformElement_pre.php @@ -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 diff --git a/src/includes/class/class.LSformElement_quota.php b/src/includes/class/class.LSformElement_quota.php index debc73cc..cab41a40 100644 --- a/src/includes/class/class.LSformElement_quota.php +++ b/src/includes/class/class.LSformElement_quota.php @@ -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']; diff --git a/src/includes/class/class.LSformElement_rss.php b/src/includes/class/class.LSformElement_rss.php index bcc996f4..10d63ca7 100644 --- a/src/includes/class/class.LSformElement_rss.php +++ b/src/includes/class/class.LSformElement_rss.php @@ -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( diff --git a/src/includes/class/class.LSformElement_select.php b/src/includes/class/class.LSformElement_select.php index 340d8830..26ca60b4 100644 --- a/src/includes/class/class.LSformElement_select.php +++ b/src/includes/class/class.LSformElement_select.php @@ -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 */ diff --git a/src/includes/class/class.LSformElement_select_box.php b/src/includes/class/class.LSformElement_select_box.php index cda5a580..01faf928 100644 --- a/src/includes/class/class.LSformElement_select_box.php +++ b/src/includes/class/class.LSformElement_select_box.php @@ -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 diff --git a/src/includes/class/class.LSformElement_select_object.php b/src/includes/class/class.LSformElement_select_object.php index d5bbe996..f705b889 100644 --- a/src/includes/class/class.LSformElement_select_object.php +++ b/src/includes/class/class.LSformElement_select_object.php @@ -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 */ diff --git a/src/includes/class/class.LSformElement_ssh_key.php b/src/includes/class/class.LSformElement_ssh_key.php index 4636eab8..5fcf6578 100644 --- a/src/includes/class/class.LSformElement_ssh_key.php +++ b/src/includes/class/class.LSformElement_ssh_key.php @@ -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'; /** diff --git a/src/includes/class/class.LSformElement_supannCompositeAttribute.php b/src/includes/class/class.LSformElement_supannCompositeAttribute.php index 9f8b5638..5d374390 100644 --- a/src/includes/class/class.LSformElement_supannCompositeAttribute.php +++ b/src/includes/class/class.LSformElement_supannCompositeAttribute.php @@ -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 diff --git a/src/includes/class/class.LSformElement_supannLabeledValue.php b/src/includes/class/class.LSformElement_supannLabeledValue.php index 37f3f6f0..a3d0b643 100644 --- a/src/includes/class/class.LSformElement_supannLabeledValue.php +++ b/src/includes/class/class.LSformElement_supannLabeledValue.php @@ -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) diff --git a/src/includes/class/class.LSformElement_supannRessourceEtatDate.php b/src/includes/class/class.LSformElement_supannRessourceEtatDate.php index 042d6143..fcfbaa23 100644 --- a/src/includes/class/class.LSformElement_supannRessourceEtatDate.php +++ b/src/includes/class/class.LSformElement_supannRessourceEtatDate.php @@ -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) { diff --git a/src/includes/class/class.LSformElement_tel.php b/src/includes/class/class.LSformElement_tel.php index f9199c9b..73c7fd8a 100644 --- a/src/includes/class/class.LSformElement_tel.php +++ b/src/includes/class/class.LSformElement_tel.php @@ -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(); diff --git a/src/includes/class/class.LSformElement_text.php b/src/includes/class/class.LSformElement_text.php index 25472273..6977dea5 100644 --- a/src/includes/class/class.LSformElement_text.php +++ b/src/includes/class/class.LSformElement_text.php @@ -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 */ diff --git a/src/includes/class/class.LSformElement_textarea.php b/src/includes/class/class.LSformElement_textarea.php index 4b7641b2..b1227545 100644 --- a/src/includes/class/class.LSformElement_textarea.php +++ b/src/includes/class/class.LSformElement_textarea.php @@ -32,8 +32,14 @@ class LSformElement_textarea extends LSformElement { - var $fieldTemplate = 'LSformElement_textarea_field.tpl'; - var $fieldTemplateExtraClass = ''; + var string $fieldTemplate = 'LSformElement_textarea_field.tpl'; + + /** + * Extra CSS class for the pre HTML element + * @see LSformElement_textarea::getDisplay() + * @var string + */ + var string $fieldTemplateExtraClass = ''; /** * Retourne les infos d'affichage de l'élément diff --git a/src/includes/class/class.LSformElement_url.php b/src/includes/class/class.LSformElement_url.php index 99db10aa..b6b2a8a5 100644 --- a/src/includes/class/class.LSformElement_url.php +++ b/src/includes/class/class.LSformElement_url.php @@ -33,16 +33,16 @@ LSsession :: loadLSclass('LSformElement_text'); class LSformElement_url extends LSformElement_text { - var $JSscripts = array( + var array $JSscripts = array( 'LSformElement_url.js' ); - var $fetchVariables = array( + var array $fetchVariables = array( 'additionalCssClass' => array('LSformElement_url'), 'uriPrefix' => '' ); - var $fieldTemplate = 'LSformElement_uri_field.tpl'; + var string $fieldTemplate = 'LSformElement_uri_field.tpl'; public function getDisplay() { LStemplate :: addHelpInfo( diff --git a/src/includes/class/class.LSformElement_valueWithUnit.php b/src/includes/class/class.LSformElement_valueWithUnit.php index ce0a18b0..92e9013f 100644 --- a/src/includes/class/class.LSformElement_valueWithUnit.php +++ b/src/includes/class/class.LSformElement_valueWithUnit.php @@ -32,7 +32,7 @@ class LSformElement_valueWithUnit extends LSformElement { - var $fieldTemplate = 'LSformElement_valueWithUnit_field.tpl'; + var string $fieldTemplate = 'LSformElement_valueWithUnit_field.tpl'; /** * Retourne les unites de l'attribut diff --git a/src/includes/class/class.LSformElement_wysiwyg.php b/src/includes/class/class.LSformElement_wysiwyg.php index 2a2d8630..56c113b4 100644 --- a/src/includes/class/class.LSformElement_wysiwyg.php +++ b/src/includes/class/class.LSformElement_wysiwyg.php @@ -31,7 +31,7 @@ class LSformElement_wysiwyg extends LSformElement { - var $fieldTemplate = 'LSformElement_wysiwyg_field.tpl'; + var string $fieldTemplate = 'LSformElement_wysiwyg_field.tpl'; /** * Retourne les infos d'affichage de l'élément diff --git a/src/includes/class/class.LSformElement_xmpp.php b/src/includes/class/class.LSformElement_xmpp.php index e7d83264..e28e18f0 100644 --- a/src/includes/class/class.LSformElement_xmpp.php +++ b/src/includes/class/class.LSformElement_xmpp.php @@ -32,16 +32,16 @@ LSsession :: loadLSclass('LSformElement_text'); */ class LSformElement_xmpp extends LSformElement_text { - var $JSscripts = array( + var array $JSscripts = array( 'LSformElement_xmpp.js' ); - var $fetchVariables = array( + var array $fetchVariables = array( 'additionalCssClass' => array('LSformElement_xmpp'), 'uriPrefix' => 'xmpp:' ); - var $fieldTemplate = 'LSformElement_uri_field.tpl'; + var string $fieldTemplate = 'LSformElement_uri_field.tpl'; public function getDisplay() { LStemplate :: addHelpInfo( diff --git a/src/includes/class/class.LSformRule.php b/src/includes/class/class.LSformRule.php index 6d18a1f6..46220ded 100644 --- a/src/includes/class/class.LSformRule.php +++ b/src/includes/class/class.LSformRule.php @@ -29,24 +29,32 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); */ class LSformRule extends LSlog_staticLoggerClass { - // Validate values one by one or all together + /** + * Validate values one by one or all together + * @see LSformRule::validate_values() + * @var boolean + */ const validate_one_by_one = True; - // CLI parameters autocompleters - // - // This array accept as key the parameter name and as value a callable - // to autocomplete the parameter value. This callable will receive as - // first parameter the prefix of the parameter value already enter by - // user and must return - protected static $cli_params_autocompleters = array(); + /** + * CLI parameters autocompleters + * + * This array accept as key the parameter name and as value a callable + * to autocomplete the parameter value. This callable will receive as + * first parameter the prefix of the parameter value already enter by + * user and must return + * @see LSformRule::cli_test_form_rule_param_name_autocompleter() + * @var array + */ + protected static array $cli_params_autocompleters = array(); /** * Validate form element values with specified rule * - * @param mixed $rule_name The LSformRule name - * @param mixed $value The values to validate + * @param string $rule_name The LSformRule name + * @param mixed $values The values to validate * @param array $options Validation options - * @param object $formElement The attached LSformElement object + * @param LSformElement &$formElement The attached LSformElement object * * @return boolean True if value is valid, False otherwise */ @@ -87,9 +95,9 @@ class LSformRule extends LSlog_staticLoggerClass { /** * Validate form element value * - * @param mixed $value The value to validate + * @param mixed $value The value to validate * @param array $options Validation options - * @param object $formElement The attached LSformElement object + * @param LSformElement &$formElement The attached LSformElement object * * @return boolean True if value is valid, False otherwise */ @@ -152,12 +160,12 @@ class LSformRule extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI test_form_rule command * - * @param array $command_args List of already typed words of the command - * @param array $command_args The command word number to autocomplete - * @param array $command_args The command word to autocomplete - * @param array $command_args 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 **/ public static function cli_test_form_rule_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $opts = array_merge($opts, array('-p', '--param')); @@ -236,10 +244,10 @@ class LSformRule extends LSlog_staticLoggerClass { /** * Args autocompleter for parameter name of CLI test_form_rule command * - * @param array $command_args Parameter name prefix (optional, default=empty string) + * @param string $prefix Parameter name prefix (optional, default=empty string) * @param string $quote_char Quote character (optional, default=empty string) * - * @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_test_form_rule_param_name_autocompleter($prefix='', $quote_char='') { $opts = LScli :: autocomplete_opts(array_keys(static :: $cli_params_autocompleters), $prefix); @@ -252,11 +260,11 @@ class LSformRule extends LSlog_staticLoggerClass { /** * Args autocompleter for parameter name of CLI test_form_rule command * - * @param array $command_args The parameter name - * @param array $command_args Parameter name prefix (optional, default=empty string) + * @param string $param_name The parameter name + * @param string $prefix Parameter name prefix (optional, default=empty string) * @param string $quote_char Quote character (optional, default=empty string) * - * @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_test_form_rule_param_value_autocompleter($param_name, $prefix='', $quote_char='') { if ( diff --git a/src/includes/class/class.LSformRule_LSformElement_select_validValue.php b/src/includes/class/class.LSformRule_LSformElement_select_validValue.php index ab6e24de..64e6b4a8 100644 --- a/src/includes/class/class.LSformRule_LSformElement_select_validValue.php +++ b/src/includes/class/class.LSformRule_LSformElement_select_validValue.php @@ -28,13 +28,13 @@ class LSformRule_LSformElement_select_validValue extends LSformRule { /** - * Validate value + * Validate form element value * - * @param string $values The value to validate - * @param array $options Validation options - * @param object $formElement The related formElement object + * @param mixed $value The value to validate + * @param array $options Validation options: + * @param LSformElement_select &$formElement The related LSformElement object * - * @return boolean true if the value is valide, false if not + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $ret = $formElement -> isValidValue($value); diff --git a/src/includes/class/class.LSformRule_alphanumeric.php b/src/includes/class/class.LSformRule_alphanumeric.php index 2cfa9a0e..7b73150f 100644 --- a/src/includes/class/class.LSformRule_alphanumeric.php +++ b/src/includes/class/class.LSformRule_alphanumeric.php @@ -28,19 +28,19 @@ class LSformRule_alphanumeric extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'withAccents' => array('LScli', 'autocomplete_bool'), ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $value Value à vérifier - * @param array $options Options de validation : + * @param mixed $value The value to validate + * @param array $options Validation options: * - $options['params']['withAccents'] : set if accents is allowed - * @param object $formElement L'objet formElement attaché + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { diff --git a/src/includes/class/class.LSformRule_callable.php b/src/includes/class/class.LSformRule_callable.php index af242d85..a7a00c27 100644 --- a/src/includes/class/class.LSformRule_callable.php +++ b/src/includes/class/class.LSformRule_callable.php @@ -28,7 +28,7 @@ class LSformRule_callable extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'callable' => null, ); @@ -36,13 +36,13 @@ class LSformRule_callable extends LSformRule { * Check the value using the callable object * * @param mixed $value The value to check - * @param array $options Validation option - * - $options['params']['callable'] : the function use to check the value + * @param array $options Validation options: + * - $options['params']['callable'] : the function use to check the value * * The callable object will be run to check the value. The given parameters are the * same of this method. * - * @param object $formElement The LSformElement object + * @param LSformElement $formElement The related LSformElement object * * @return boolean true if the value is valid, false otherwise */ diff --git a/src/includes/class/class.LSformRule_compare.php b/src/includes/class/class.LSformRule_compare.php index 03a56ae7..35e4b176 100644 --- a/src/includes/class/class.LSformRule_compare.php +++ b/src/includes/class/class.LSformRule_compare.php @@ -26,11 +26,15 @@ */ class LSformRule_compare extends LSformRule { - // Validate values one by one or all together + /** + * Validate values one by one or all together + * @see LSformRule::validate_values() + * @var boolean + */ const validate_one_by_one = False; // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'operator' => null, ); @@ -44,21 +48,21 @@ class LSformRule_compare extends LSformRule { '<=' => 'lte', ); static protected $_operators_to_compare_function = array( - 'eq' => function($a, $b) {return floatval($a) == floatval($b);}, - 'neq' => function($a, $b) {return floatval($a) != floatval($b);}, - 'gt' => function($a, $b) {return $a > $b;}, - 'gte' => function($a, $b) {return $a >= $b;}, - 'lt' => function($a, $b) {return $a < $b;}, - 'lte' => function($a, $b) {return $a <= $b;}, + 'eq' => '_LSformRule_compare_eq', + 'neq' => '_LSformRule_compare_neq', + 'gt' => '_LSformRule_compare_gt', + 'gte' => '_LSformRule_compare_gte', + 'lt' => '_LSformRule_compare_lt', + 'lte' => '_LSformRule_compare_lte', ); /** * Return the compare function associated with the specified operator * * @access private - * @param string The operator name + * @param string $operator_name The operator name * - * @return function The compare function + * @return callable The compare function */ private static function _findOperatorCompareFunction($operator_name) { if (empty($operator_name)) @@ -71,14 +75,14 @@ class LSformRule_compare extends LSformRule { } /** - * Vérification des valeurs. + * Validate form element values * - * @param string $values Valeurs à vérifier - * @param array $options Options de validation : - * - Operateur : $options['params']['operator'] - * @param object $formElement L'objet formElement attaché + * @param mixed $values The values to validate + * @param array $options Validation options: + * - Operator : $options['params']['operator'] allowed values + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($values, $options, &$formElement) { $operator = LSconfig :: get('params.operator', null, 'string', $options); @@ -91,3 +95,10 @@ class LSformRule_compare extends LSformRule { } } + +function _LSformRule_compare_eq($a, $b) {return floatval($a) == floatval($b);} +function _LSformRule_compare_neq($a, $b) {return floatval($a) != floatval($b);} +function _LSformRule_compare_gt($a, $b) {return $a > $b;} +function _LSformRule_compare_gte($a, $b) {return $a >= $b;} +function _LSformRule_compare_lt($a, $b) {return $a < $b;} +function _LSformRule_compare_lte($a, $b) {return $a <= $b;} diff --git a/src/includes/class/class.LSformRule_date.php b/src/includes/class/class.LSformRule_date.php index 55043632..c587ebb7 100644 --- a/src/includes/class/class.LSformRule_date.php +++ b/src/includes/class/class.LSformRule_date.php @@ -28,22 +28,22 @@ class LSformRule_date extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'format' => null, 'special_values' => null, ); /** - * Validation de données - * - * @param mixed $value Données à valider - * @param array $options Options de validation - * $options['params']['format']: le format de la date - * $options['params']['special_values']: array of special allowed values - * @param object $formElement L'objet formElement attaché - * - * @return boolean True si les données sont valide, False sinon. - */ + * Validate form element value + * + * @param mixed $value The value to validate + * @param array $options Validation options: + * $options['params']['format']: the date format + * $options['params']['special_values']: array of special allowed values + * @param LSformElement &$formElement The related LSformElement object + * + * @return boolean True if value is valid, False otherwise + */ public static function validate($value, $options, &$formElement) { $special_values = LSconfig :: get('params.special_values', array(), null, $options); if (in_array($value, $special_values)) diff --git a/src/includes/class/class.LSformRule_differentPassword.php b/src/includes/class/class.LSformRule_differentPassword.php index 614cd2a3..cf8f79ba 100644 --- a/src/includes/class/class.LSformRule_differentPassword.php +++ b/src/includes/class/class.LSformRule_differentPassword.php @@ -28,19 +28,19 @@ class LSformRule_differentPassword extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'otherPasswordAttributes' => null, ); /** - * Check the value + * Validate form element value * - * @param string $values Value to check - * @param array $options Validation options : + * @param mixed $value The value to validate + * @param array $options Validation options: * - Other attribute : $options['params']['otherPasswordAttributes'] - * @param object $formElement The linked LSformElement object + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $otherPasswordAttributes = LSconfig :: get('params.otherPasswordAttributes', null, null, $options); diff --git a/src/includes/class/class.LSformRule_email.php b/src/includes/class/class.LSformRule_email.php index 6151b85d..3561fc20 100644 --- a/src/includes/class/class.LSformRule_email.php +++ b/src/includes/class/class.LSformRule_email.php @@ -28,20 +28,20 @@ class LSformRule_email extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'domain' => null, 'checkDomain' => array('LScli', 'autocomplete_bool'), ); - /** - * Vérification de la valeur. + /** + * Validate form element value * - * @param string $value Valeur à vérifier - * @param array $options Options de validation : + * @param mixed $value The value to validate + * @param array $options Validation options: * - Check domain : $options['params']['checkDomain'] - * @param object $formElement L'objet formElement attaché + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { return checkEmail( diff --git a/src/includes/class/class.LSformRule_filesize.php b/src/includes/class/class.LSformRule_filesize.php index 330f38ed..916e1be6 100644 --- a/src/includes/class/class.LSformRule_filesize.php +++ b/src/includes/class/class.LSformRule_filesize.php @@ -28,21 +28,21 @@ class LSformRule_filesize extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'minSize' => array('LScli', 'autocomplete_int'), 'maxSize' => array('LScli', 'autocomplete_int'), ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation : - * - Taille max (en octet) : $options['params']['maxSize'] - * - Taille min (en octet) : $options['params']['minSize'] - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options: + * - Max size (in byte) : $options['params']['maxSize'] + * - Min size (in byte) : $options['params']['minSize'] + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { // According to PHP doc, strlen() returns the number of bytes rather diff --git a/src/includes/class/class.LSformRule_imagefile.php b/src/includes/class/class.LSformRule_imagefile.php index 63c8679b..a97482a4 100644 --- a/src/includes/class/class.LSformRule_imagefile.php +++ b/src/includes/class/class.LSformRule_imagefile.php @@ -30,15 +30,15 @@ LSsession :: loadLSclass('LSformRule_mimetype'); class LSformRule_imagefile extends LSformRule { /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation : + * @param mixed $value The value to validate + * @param array $options Validation options: * - Type MIME : $options['params']['mimeType'] * - Type MIME (regex) : $options['params']['mimeTypeRegEx'] - * @param object $formElement L'objet formElement attaché + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $file = LSsession :: getTmpFile($value); diff --git a/src/includes/class/class.LSformRule_imagesize.php b/src/includes/class/class.LSformRule_imagesize.php index 314684dd..92e3113b 100644 --- a/src/includes/class/class.LSformRule_imagesize.php +++ b/src/includes/class/class.LSformRule_imagesize.php @@ -28,7 +28,7 @@ class LSformRule_imagesize extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'minWidth' => array('LScli', 'autocomplete_int'), 'maxWitdh' => array('LScli', 'autocomplete_int'), 'minHeight' => array('LScli', 'autocomplete_int'), @@ -36,17 +36,17 @@ class LSformRule_imagesize extends LSformRule { ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation : - * - Largeur max : $options['params']['maxWidth'] - * - Largeur min : $options['params']['minWidth'] - * - Hauteur max : $options['params']['maxHeight'] - * - Hauteur min : $options['params']['minHeight'] - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options: + * - Max width: $options['params']['maxWidth'] + * - Min width: $options['params']['minWidth'] + * - Max height: $options['params']['maxHeight'] + * - Min height: $options['params']['minHeight'] + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $file = LSsession :: getTmpFile($value); diff --git a/src/includes/class/class.LSformRule_inarray.php b/src/includes/class/class.LSformRule_inarray.php index e7047766..98807ca9 100644 --- a/src/includes/class/class.LSformRule_inarray.php +++ b/src/includes/class/class.LSformRule_inarray.php @@ -28,7 +28,7 @@ class LSformRule_inarray extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'possible_values' => null, 'reverse' => array('LScli', 'autocomplete_bool'), ); @@ -36,12 +36,12 @@ class LSformRule_inarray extends LSformRule { /** * Check the value in configured list * - * @param string $values The value to check + * @param string $value The value to check * @param array $options Check options: * - possible_values: the list of valid values (required) * - reverse: if true, reverse the logic of the check * (list values are prohibited, optional, default: False) - * @param object $formElement The linked LSformElement object + * @param LSformElement &$formElement The related LSformElement object * * @return boolean true if the value is valid, false otherwise */ diff --git a/src/includes/class/class.LSformRule_integer.php b/src/includes/class/class.LSformRule_integer.php index e33cdf07..353ca0c3 100644 --- a/src/includes/class/class.LSformRule_integer.php +++ b/src/includes/class/class.LSformRule_integer.php @@ -28,7 +28,7 @@ class LSformRule_integer extends LSformRule{ // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'positive' => array('LScli', 'autocomplete_bool'), 'negative' => array('LScli', 'autocomplete_bool'), 'minHeight' => array('LScli', 'autocomplete_int'), @@ -36,17 +36,17 @@ class LSformRule_integer extends LSformRule{ ); /** - * Verification value. + * Validate form element value * - * @param string $values The value - * @param array $options Validation options + * @param mixed $value The value to validate + * @param array $options Validation options: * - Maximum value : $options['params']['max'] * - Minimum value : $options['params']['min'] * - Allow only negative value : $options['params']['negative'] * - Allow only positive value : $options['params']['positive'] - * @param object $formElement The formElement object + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true if the value is valided, false otherwise + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $max = LSconfig :: get('params.max', null, 'int', $options); diff --git a/src/includes/class/class.LSformRule_ldapSearchURI.php b/src/includes/class/class.LSformRule_ldapSearchURI.php index 70de9bee..2e2c80c4 100644 --- a/src/includes/class/class.LSformRule_ldapSearchURI.php +++ b/src/includes/class/class.LSformRule_ldapSearchURI.php @@ -28,7 +28,7 @@ class LSformRule_ldapSearchURI extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'check_resolving_ldap_host' => array('LScli', 'autocomplete_bool'), 'host_required' => array('LScli', 'autocomplete_bool'), 'scope_required' => array('LScli', 'autocomplete_bool'), @@ -38,13 +38,13 @@ class LSformRule_ldapSearchURI extends LSformRule { ); /** - * Check an LDAP search URI value + * Validate form element value * - * @param mixed $value The value to check - * @param array $options Validation option - * @param object $formElement The LSformElement object + * @param mixed $value The value to validate + * @param array $options Validation options + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true if the value is valid, false otherwise + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { self :: log_trace("validate($value): options = ".varDump($options)); diff --git a/src/includes/class/class.LSformRule_lettersonly.php b/src/includes/class/class.LSformRule_lettersonly.php index c850eb6f..6d676906 100644 --- a/src/includes/class/class.LSformRule_lettersonly.php +++ b/src/includes/class/class.LSformRule_lettersonly.php @@ -28,13 +28,13 @@ class LSformRule_lettersonly extends LSformRule { /** - * Vérification de la valeur. + * Validate form element value * - * @param string $value Value à vérifier - * @param array $options Options de validation (inutile ici) - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $regex = '/^[a-zA-Z]+$/'; diff --git a/src/includes/class/class.LSformRule_maxlength.php b/src/includes/class/class.LSformRule_maxlength.php index 3b8aa818..eff3fb1d 100644 --- a/src/includes/class/class.LSformRule_maxlength.php +++ b/src/includes/class/class.LSformRule_maxlength.php @@ -28,19 +28,19 @@ class LSformRule_maxlength extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'limit' => array('LScli', 'autocomplete_int'), ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation : - * - Longueur max : $options['params']['limit'] - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options: + * - Maximum length : $options['params']['limit'] + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $limit = LSconfig :: get('params.limit', null, 'int', $options); diff --git a/src/includes/class/class.LSformRule_mimetype.php b/src/includes/class/class.LSformRule_mimetype.php index c7aebeed..c641e056 100644 --- a/src/includes/class/class.LSformRule_mimetype.php +++ b/src/includes/class/class.LSformRule_mimetype.php @@ -28,21 +28,21 @@ class LSformRule_mimetype extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'mimeType' => null, 'mimeTypeRegEx' => null, ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation : + * @param mixed $value The value to validate + * @param array $options Validation options: * - Type MIME : $options['params']['mimeType'] * - Type MIME (regex) : $options['params']['mimeTypeRegEx'] - * @param object $formElement L'objet formElement attaché + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $file = LSsession :: getTmpFile($value); diff --git a/src/includes/class/class.LSformRule_minlength.php b/src/includes/class/class.LSformRule_minlength.php index 92470e98..8bee1411 100644 --- a/src/includes/class/class.LSformRule_minlength.php +++ b/src/includes/class/class.LSformRule_minlength.php @@ -28,19 +28,19 @@ class LSformRule_minlength extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'limit' => array('LScli', 'autocomplete_int'), ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation : - * - Longueur min : $options['params']['limit'] - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options: + * - Minimum length : $options['params']['limit'] + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $limit = LSconfig :: get('params.limit', null, 'int', $options); diff --git a/src/includes/class/class.LSformRule_nonzero.php b/src/includes/class/class.LSformRule_nonzero.php index e119a5ea..c60b5dbf 100644 --- a/src/includes/class/class.LSformRule_nonzero.php +++ b/src/includes/class/class.LSformRule_nonzero.php @@ -28,13 +28,13 @@ class LSformRule_nonzero extends LSformRule { /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation (inutile ici) - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $regex = '/^-?[1-9][0-9]*/'; diff --git a/src/includes/class/class.LSformRule_nopunctuation.php b/src/includes/class/class.LSformRule_nopunctuation.php index 5f5837b2..896f1462 100644 --- a/src/includes/class/class.LSformRule_nopunctuation.php +++ b/src/includes/class/class.LSformRule_nopunctuation.php @@ -28,13 +28,13 @@ class LSformRule_nopunctuation extends LSformRule { /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation (inutile ici) - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $regex = '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/'; diff --git a/src/includes/class/class.LSformRule_numberOfValues.php b/src/includes/class/class.LSformRule_numberOfValues.php index a4bc24cc..ba75bc6a 100644 --- a/src/includes/class/class.LSformRule_numberOfValues.php +++ b/src/includes/class/class.LSformRule_numberOfValues.php @@ -27,23 +27,27 @@ */ class LSformRule_numberOfValues extends LSformRule { - // Validate values one by one or all together + /** + * Validate values one by one or all together + * @see LSformRule::validate_values() + * @var boolean + */ const validate_one_by_one = False; // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'min' => array('LScli', 'autocomplete_int'), 'max' => array('LScli', 'autocomplete_int'), ); /** - * Validate value + * Validate form element value * - * @param string $values The value to validate + * @param mixed $value The value to validate * @param array $options Validation options - * @param object $formElement The related formElement object + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true if the value is valide, false if not + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $max_values = LSconfig :: get('params.max', null, 'int', $options); diff --git a/src/includes/class/class.LSformRule_numeric.php b/src/includes/class/class.LSformRule_numeric.php index 9c7249d2..d4cee9a7 100644 --- a/src/includes/class/class.LSformRule_numeric.php +++ b/src/includes/class/class.LSformRule_numeric.php @@ -28,13 +28,13 @@ class LSformRule_numeric extends LSformRule{ /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation (inutile ici) - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $regex = '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/'; diff --git a/src/includes/class/class.LSformRule_password.php b/src/includes/class/class.LSformRule_password.php index 25cbcce8..8c6a8d7c 100644 --- a/src/includes/class/class.LSformRule_password.php +++ b/src/includes/class/class.LSformRule_password.php @@ -28,7 +28,7 @@ class LSformRule_password extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'minlength' => array('LScli', 'autocomplete_int'), 'maxlength' => array('LScli', 'autocomplete_int'), 'prohibitedValues' => null, @@ -37,20 +37,18 @@ class LSformRule_password extends LSformRule { ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation - * - 'minLength' : la longueur maximale - * - 'maxLength' : la longueur minimale - * - 'prohibitedValues' : Un tableau de valeurs interdites - * - 'regex' : une ou plusieurs expressions régulières - * devant matche - * - 'minValidRegex' : le nombre minimun d'expressions - * régulières à valider - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options + * - 'minLength' : la maximun length + * - 'maxLength' : la minimum length + * - 'prohibitedValues' : array of prohibited values + * - 'regex' : one or multiple regex to match + * - 'minValidRegex' : minimum number of regex that must matched + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $errors = array(); diff --git a/src/includes/class/class.LSformRule_rangelength.php b/src/includes/class/class.LSformRule_rangelength.php index 0e770d71..e817b595 100644 --- a/src/includes/class/class.LSformRule_rangelength.php +++ b/src/includes/class/class.LSformRule_rangelength.php @@ -28,20 +28,20 @@ class LSformRule_rangelength extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'limits' => null, ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation : - * - Longueur min : $options['params']['limits'][0] - * - Longueur max : $options['params']['limits'][1] - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options: + * - Minimum length : $options['params']['limits'][0] + * - Maximum length : $options['params']['limits'][1] + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $limits = LSconfig :: get('params.limits', null, null, $options); diff --git a/src/includes/class/class.LSformRule_regex.php b/src/includes/class/class.LSformRule_regex.php index 2be18264..804bcb83 100644 --- a/src/includes/class/class.LSformRule_regex.php +++ b/src/includes/class/class.LSformRule_regex.php @@ -28,19 +28,19 @@ class LSformRule_regex extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'regex' => null, ); /** - * Vérification de la valeur. + * Validate form element value * - * @param string $values Valeur à vérifier - * @param array $options Options de validation : - * - Regex : $options['params']['regex'] ou $options - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options + * - Regex : $options['params']['regex'] or $options + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { if (is_array($options)) { diff --git a/src/includes/class/class.LSformRule_required.php b/src/includes/class/class.LSformRule_required.php index 39317971..8df6a04b 100644 --- a/src/includes/class/class.LSformRule_required.php +++ b/src/includes/class/class.LSformRule_required.php @@ -28,13 +28,13 @@ class LSformRule_required extends LSformRule { /** - * Vérification de la valeur. + * Validate form element value * - * @param string $value Value à vérifier - * @param array $options Options de validation (inutile ici) - * @param object $formElement L'objet formElement attaché + * @param mixed $value The value to validate + * @param array $options Validation options + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { return ((string)$value != ''); diff --git a/src/includes/class/class.LSformRule_ssh_pub_key.php b/src/includes/class/class.LSformRule_ssh_pub_key.php index 98038ee0..bb3ab198 100644 --- a/src/includes/class/class.LSformRule_ssh_pub_key.php +++ b/src/includes/class/class.LSformRule_ssh_pub_key.php @@ -30,9 +30,9 @@ class LSformRule_ssh_pub_key extends LSformRule { /** * Validate SSH public key value * - * @param string $values The value to validate + * @param string $value The value to validate * @param array $options Validation options - * @param object $formElement The related formElement object + * @param LSformElement &$formElement The related formElement object * * @return boolean true if the value is valide, false if not */ diff --git a/src/includes/class/class.LSformRule_telephonenumber.php b/src/includes/class/class.LSformRule_telephonenumber.php index 4d5853b2..482a488c 100644 --- a/src/includes/class/class.LSformRule_telephonenumber.php +++ b/src/includes/class/class.LSformRule_telephonenumber.php @@ -27,14 +27,14 @@ */ class LSformRule_telephonenumber extends LSformRule { - /** - * V�rification de la valeur. + /** + * Validate form element value * - * @param string $value Valeur � v�rifier - * @param array $options Options de validation : - * @param object $formElement L'objet formElement attach� + * @param mixed $value The value to validate + * @param array $options Validation options + * @param LSformElement &$formElement The related LSformElement object * - * @return boolean true si la valeur est valide, false sinon + * @return boolean True if value is valid, False otherwise */ public static function validate($value, $options, &$formElement) { $regex = '/^(01|02|03|04|05|06|08|09)[0-9]{8}$/'; diff --git a/src/includes/class/class.LSformRule_zxcvbn.php b/src/includes/class/class.LSformRule_zxcvbn.php index 59cb663d..93e979bb 100644 --- a/src/includes/class/class.LSformRule_zxcvbn.php +++ b/src/includes/class/class.LSformRule_zxcvbn.php @@ -28,7 +28,7 @@ class LSformRule_zxcvbn extends LSformRule { // CLI parameters autocompleters - protected static $cli_params_autocompleters = array( + protected static array $cli_params_autocompleters = array( 'minScore' => array('LScli', 'autocomplete_int'), 'userDataAttrs' => null, 'showWarning' => array('LScli', 'autocomplete_bool'), @@ -37,12 +37,11 @@ class LSformRule_zxcvbn extends LSformRule { ); /** - * Validate form element values with specified rule + * Validate form element value * - * @param mixed $rule_name The LSformRule name - * @param mixed $value The values to validate + * @param mixed $value The value to validate * @param array $options Validation options - * @param object $formElement The attached LSformElement object + * @param LSformElement &$formElement The related LSformElement object * * @return boolean True if value is valid, False otherwise */ diff --git a/src/includes/class/class.LSio.php b/src/includes/class/class.LSio.php index 4b28b402..4a5104ca 100644 --- a/src/includes/class/class.LSio.php +++ b/src/includes/class/class.LSio.php @@ -171,12 +171,12 @@ class LSio extends LSlog_staticLoggerClass { * ) * ) * - * @param string $action The LSobject type - * @param string $action The LSioFormat name + * @param string $LSobject The LSobject type + * @param string $ioFormat The LSioFormat name * @param string|resource $input_file The input file path * @param boolean $updateIfExists If true and object to import already exists, update it. If false, * an error will be triggered. (optional, default: false) - * @param boolean $updateIfExists If true, enable just-try mode: just check input data but do not really + * @param boolean $justTry If true, enable just-try mode: just check input data but do not really * import objects in LDAP directory. (optional, default: false) * * @author Benjamin Renard @@ -196,7 +196,7 @@ class LSio extends LSlog_staticLoggerClass { ); // Load LSobject - if (!isset($LSobject) || !LSsession::loadLSobject($LSobject)) { + if (!$LSobject || !LSsession::loadLSobject($LSobject)) { LSerror :: addErrorCode('LSio_02'); return $return; } @@ -338,8 +338,8 @@ class LSio extends LSlog_staticLoggerClass { /** * Export objects * - * @param LSldapObject $LSobject An instance of the object type - * @param string $action The LSioFormat name + * @param LSldapObject $object An instance of the object type + * @param string $ioFormat The LSioFormat name * @param resource|null $stream The output stream (optional, default: STDOUT) * * @author Benjamin Renard @@ -401,7 +401,7 @@ class LSio extends LSlog_staticLoggerClass { /** * CLI import command * - * @param string $action Command arguments: + * @param string $command_args Command arguments: * - Positional arguments: * - LSobject type * - LSioFormat name @@ -506,12 +506,12 @@ class LSio extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI import command * - * @param string $action List of already typed words of the command - * @param string $action The command word number to autocomplete - * @param string $action The command word to autocomplete - * @param string $action 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 **/ public static function cli_import_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $opts = array_merge($opts, array ('-i', '--input', '-U', '--update', '-j', '--just-try')); @@ -560,7 +560,7 @@ class LSio extends LSlog_staticLoggerClass { /** * CLI export command * - * @param string $action Command arguments: + * @param string $command_args Command arguments: * - Positional arguments: * - LSobject type * - LSioFormat name @@ -610,12 +610,12 @@ class LSio extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI export command * - * @param string $action List of already typed words of the command - * @param string $action The command word number to autocomplete - * @param string $action The command word to autocomplete - * @param string $action 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 **/ public static function cli_export_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $opts = array_merge($opts, array ('-o', '--output')); diff --git a/src/includes/class/class.LSioFormat.php b/src/includes/class/class.LSioFormat.php index d3a3a144..bc25db20 100644 --- a/src/includes/class/class.LSioFormat.php +++ b/src/includes/class/class.LSioFormat.php @@ -29,8 +29,23 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); */ class LSioFormat extends LSlog_staticLoggerClass { + /** + * Configuration of the IOformat + * (LSobjects..ioFormat.) + * @see LSioFormat::__construct() + * @see LSioFormat::getConfig() + * @see LSioFormat::ready() + * @var array|false + */ var $config = false; - var $driver = False; + + /** + * The related LSioFormatDriver object + * @see LSioFormat::__construct() + * @see LSioFormat::ready() + * @var LSioFormatDriver|false + */ + var $driver = false; /** * Constructor @@ -68,9 +83,9 @@ class LSioFormat 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 **/ @@ -124,24 +139,26 @@ class LSioFormat extends LSlog_staticLoggerClass { $objects_data = array(); foreach($objects as $object) { - $objects_data[$object -> getDn()] = array(); + $dn = $object -> getDn(); + $objects_data[$dn] = array(); // Build a LSform object $export = new LSform($object, 'export'); // Add attributes to export and put their values to data to export foreach($fields as $key => $attr_name) { - $objects_data[$object -> getDn()][$key] = null; + $objects_data[$dn][$key] = null; if (!isset($object -> attrs[$attr_name])) { self :: log_warning("exportObjects($object): attribute '$attr_name' does not exist !"); continue; } $object -> attrs[$attr_name] -> addToExport($export); if (!isset($export -> elements[$attr_name])) { + // @phpstan-ignore-next-line self :: log_debug("exportObjects($object): attribute '$attr_name' not added to export : may be user can't read it"); continue; } - $objects_data[$object -> getDn()][$key] = $export -> elements[$attr_name] -> getApiValue(false); + $objects_data[$dn][$key] = $export -> elements[$attr_name] -> getApiValue(false); } } self :: log_trace('exportObjects(): objects data = '.varDump($objects_data)); diff --git a/src/includes/class/class.LSioFormatCSV.php b/src/includes/class/class.LSioFormatCSV.php index 8f3fd846..14204787 100644 --- a/src/includes/class/class.LSioFormatCSV.php +++ b/src/includes/class/class.LSioFormatCSV.php @@ -29,13 +29,61 @@ LSsession :: loadLSclass('LSioFormatDriver'); */ class LSioFormatCSV extends LSioFormatDriver { + /** + * Fields value delimiter + * @see fgetcsv() + * @see LSioFormatCSV::__construct() + * @var string|null + */ private $delimiter = null; + + /** + * Fields value enclosure + * @see fgetcsv() + * @see LSioFormatCSV::__construct() + * @var string|null + */ private $enclosure = null; + + /** + * Fields value escape character + * @see fgetcsv() + * @see LSioFormatCSV::__construct() + * @var string|null + */ private $escape = null; + + /** + * Fields value maximum length + * @see fgetcsv() + * @see LSioFormatCSV::__construct() + * @var string|null + */ private $length = null; + + /** + * Delimiter for multiple-value inside a field value + * @see LSioFormatCSV::__construct() + * @var string|null + */ private $multiple_value_delimiter = null; + /** + * CSV file parsed rows + * @see LSioFormatCSV::loadFile() + * @see LSioFormatCSV::isValid() + * @see LSioFormatCSV::getAll() + * @var array|null + */ private $rows = null; + + /** + * CSV file parsed header row + * @see LSioFormatCSV::loadFile() + * @see LSioFormatCSV::isValid() + * @see LSioFormatCSV::getAll() + * @var array|null + */ private $headers = null; /** @@ -68,7 +116,7 @@ class LSioFormatCSV extends LSioFormatDriver { /** * Load file * - * @param array $options The file path to load + * @param string $path The file path to load * * @return boolean True if file is loaded, false otherwise **/ diff --git a/src/includes/class/class.LSioFormatDriver.php b/src/includes/class/class.LSioFormatDriver.php index 0437f919..2ca0cf35 100644 --- a/src/includes/class/class.LSioFormatDriver.php +++ b/src/includes/class/class.LSioFormatDriver.php @@ -29,7 +29,15 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); */ class LSioFormatDriver extends LSlog_staticLoggerClass { - protected $options=array(); + /** + * Driver options + * (LSobjects..ioFormat..driver_options) + * @see LSioFormat::__construct() + * @see LSioFormatDriver::__construct() + * @see LSioFormatDriver::getOption() + * @var array + */ + protected array $options = array(); /** * Constructor @@ -45,7 +53,7 @@ class LSioFormatDriver extends LSlog_staticLoggerClass { /** * Load file * - * @param string $file The file path to load + * @param string $path The file path to load * * @return boolean True if file is loaded, false otherwise **/ @@ -160,9 +168,9 @@ class LSioFormatDriver extends LSlog_staticLoggerClass { /** * Return a option 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 option parameter value or default value if not set **/ diff --git a/src/includes/class/class.LSlang.php b/src/includes/class/class.LSlang.php index 67ec661c..6738a190 100644 --- a/src/includes/class/class.LSlang.php +++ b/src/includes/class/class.LSlang.php @@ -25,8 +25,20 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); class LSlang extends LSlog_staticLoggerClass { - // Current lang and encoding + /** + * Current lang + * @see LSlang::setLocale() + * @see LSlang::getLang() + * @var string|null + */ private static $lang = NULL; + + /** + * Current encoding + * @see LSlang::setLocale() + * @see LSlang::getEncoding() + * @var string|null + */ private static $encoding = NULL; /** @@ -34,7 +46,7 @@ class LSlang extends LSlog_staticLoggerClass { * * @param string|null $lang The lang (optional, default: default current LDAP * server lang, or default lang) - * @param string|null $lang The encoding (optional, default: default current LDAP + * @param string|null $encoding The encoding (optional, default: default current LDAP * server encoding, or default encoding) * * @return void @@ -122,10 +134,10 @@ class LSlang extends LSlog_staticLoggerClass { /** * Return list of available languages * - * @param string|null $lang Specify encoding for lang selection. If null, use self :: encoding value, + * @param string|null $encoding Specify encoding for lang selection. If null, use self :: encoding value, * if false, do not filter on encoding, otherwise filter available lang for * specified encoding (optional, default: null) - * @params[in] $with_encoding Return available lang list with encoding (optional, default: false) + * @param bool $with_encoding Return available lang list with encoding (optional, default: false) * * @return array List of available languages. **/ @@ -195,7 +207,7 @@ class LSlang extends LSlog_staticLoggerClass { * Check a locale exists * * @param string $lang The language (ex: fr_FR) - * @param string $lang The encoding (ex: UTF8) + * @param string $encoding The encoding (ex: UTF8) * * @return boolean True if the locale is available, False otherwise **/ @@ -224,15 +236,13 @@ class LSlang extends LSlog_staticLoggerClass { */ if (php_sapi_name() != "cli") return true; -/** - * CLI generate_lang_file command - * - * @param string $lang Command arguments - * - * @return boolean True on success, false otherwise - **/ global $LSlang_cli_logger, $available_onlys, $available_withouts; +/** + * Convert relative path to absolute + * @param string $path The path to convert + * @return string The converted absolute path + */ function _cli_relative2absolute_path($path) { if ($path[0] == '/') return $path; @@ -240,6 +250,11 @@ function _cli_relative2absolute_path($path) { return realpath($curdir)."/".$path; } +/** + * Convert absolute path to relative + * @param string $path The path to convert + * @return string The converted relative path + */ function _cli_absolute2relative_path($path) { if ($path[0] == '/') $path = realpath($path); @@ -248,6 +263,12 @@ function _cli_absolute2relative_path($path) { return $path; } +/** + * CLI Helper to ask user to translate a string + * @param string $context The context of the string to translate + * @param string $msg The string to convert + * @return boolean True on success, False otherwise + */ function _cli_interactive_ask($context, $msg) { global $copyoriginalvalue, $interactive_exit; @@ -306,6 +327,12 @@ function _cli_interactive_ask($context, $msg) { return true; } +/** + * CLI helper to add string to translate + * @param string $msg The string to translate + * @param string|null $context The context of the string to translate + * @return void + */ function _cli_add_str_to_translate($msg, $context=null) { global $LSlang_cli_logger, $lang, $data, $translations, $interactive, $interactive_exit, $copyoriginalvalue, $format; $LSlang_cli_logger -> trace("_cli_add_str_to_translate($msg, $context)"); @@ -318,7 +345,7 @@ function _cli_add_str_to_translate($msg, $context=null) { if (array_key_exists($msg, $data)) { if ($context && !in_array($context, $data[$msg]['contexts'])) $data[$msg]['contexts'][] = $context; - return True; + return; } // Handle translation @@ -332,7 +359,7 @@ function _cli_add_str_to_translate($msg, $context=null) { elseif ($interactive && $format != 'pot') { $translation = _cli_interactive_ask($context, $msg); if (!is_string($translation)) - return true; + return; } $data[$msg] = array ( 'translation' => $translation, @@ -340,14 +367,23 @@ function _cli_add_str_to_translate($msg, $context=null) { ); } -function _cli_add_str_to_translate_from_LSconfig($pattern, $value='value', $excludes=array()) { +/** + * CLI helper to add string to translate from LSconfig + * @param string $pattern The LSconfig parameter pattern used to find strings to translate + * @param string $what Where to find string to translate. Possible values: + * - key : The LSconfig parameter key + * - value : The LSconfig parameter value + * @param array $excludes Array of string to exclude + * @return void + */ +function _cli_add_str_to_translate_from_LSconfig($pattern, $what='value', $excludes=array()) { global $LSlang_cli_logger; $LSlang_cli_logger -> trace("_cli_add_str_to_translate_from_LSconfig($pattern, array(".implode(',', $excludes)."))"); $keys = LSconfig :: getMatchingKeys($pattern); $LSlang_cli_logger -> trace("addFromLSconfig : ".count($keys)." matching key(s)"); foreach ($keys as $key => $value) { $LSlang_cli_logger -> trace("addFromLSconfig : $key = ".varDump($value)); - if ($value == 'key') { + if ($what == 'key') { // Get the last key parts as value and all other as key $key_parts = explode('.', $key); $value = $key_parts[count($key_parts)-1]; @@ -358,6 +394,13 @@ function _cli_add_str_to_translate_from_LSconfig($pattern, $value='value', $excl } } +/** + * CLI helper to add string to translate from list of possible values retreive from LSconfig + * @param string $context The context == prefix of the LSconfig parameter key to retreive possible values + * @param array[string] $withouts FIXME + * @param integer $level The level of the possible value (used to identify recursion level) + * @return void + */ function _cli_add_possible_values_from_LSconfig($context, $withouts, $level=0) { global $LSlang_cli_logger; $LSlang_cli_logger -> trace("_cli_add_possible_values_from_LSconfig($context)"); @@ -403,6 +446,11 @@ function _cli_add_possible_values_from_LSconfig($context, $withouts, $level=0) { } } +/** + * CLI helper to parse a template file to locate strings to translate + * @param string $file The file path + * @return void + */ function _cli_parse_template_file($file) { global $LSlang_cli_logger; $LSlang_cli_logger -> debug("Looking for string to translate in '$file' template file"); @@ -420,6 +468,12 @@ function _cli_parse_template_file($file) { $LSlang_cli_logger -> trace("_cli_parse_template_file($file) : done."); } +/** + * CLI helper to find and parse all template files of the specified directory + * to locate strings to translate + * @param string $dir The directory path + * @return void + */ function _cli_find_and_parse_template_file($dir) { if (is_dir($dir)) { if ($dh = opendir($dir)) { @@ -437,6 +491,11 @@ function _cli_find_and_parse_template_file($dir) { } } +/** + * CLI helper to parse a PHP file to locate strings to translate + * @param string $file The file path + * @return void + */ function _cli_parse_php_file($file) { global $LSlang_cli_logger; $LSlang_cli_logger -> debug("Looking for string to translate in '$file' PHP file"); @@ -498,6 +557,12 @@ function _cli_parse_php_file($file) { } } +/** + * CLI helper to find and parse all PHP files of the specified directory + * to locate strings to translate + * @param string $dir The directory path + * @return void + */ function _cli_find_and_parse_php_file($dir, $filename_regex) { if (is_dir($dir)) { if ($dh = opendir($dir)) { @@ -511,6 +576,11 @@ function _cli_find_and_parse_php_file($dir, $filename_regex) { } } +/** + * CLI helper to generate output PHP translation file + * @param resource $fd The file descriptor where to write to generated output + * @return void + */ function _cli_output_php($fd) { global $LSlang_cli_logger, $additionalfileformat, $data, $copyoriginalvalue, $keep_unused, $translations; fwrite($fd, " $key_data) { @@ -585,6 +665,15 @@ function _cli_output_pot($fd) { $available_onlys = array("config", "templates", "addons", "auth_methods", "includes"); $available_withouts = array_merge($available_onlys, array("select-list")); + + +/** + * CLI generate_lang_file command + * + * @param string $command_args Command arguments + * + * @return boolean True on success, false otherwise + **/ function cli_generate_lang_file($command_args) { // Use global variables to share it with sub-functions global $LSlang_cli_logger, $available_onlys, $available_withouts, $data, $translations, $interactive, @@ -955,12 +1044,12 @@ function cli_generate_lang_file($command_args) { /** * Args autocompleter for CLI command generate_lang_file * - * @param string $lang List of already typed words of the command - * @param string $lang The command word number to autocomplete - * @param string $lang The command word to autocomplete - * @param string $lang List of global available options + * @param array $comp_words 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_generate_lang_file_args_autocompleter($comp_words, $comp_word_num, $comp_word, $opts) { global $available_withouts, $available_onlys; @@ -1039,7 +1128,7 @@ LScli :: add_command( /** * CLI generate_ldapsaisie_pot command * - * @param string $lang Command arguments + * @param string $command_args Command arguments * * @return boolean True on success, false otherwise **/ diff --git a/src/includes/class/class.LSldap.php b/src/includes/class/class.LSldap.php index de1e49f5..cc5255c8 100644 --- a/src/includes/class/class.LSldap.php +++ b/src/includes/class/class.LSldap.php @@ -31,7 +31,24 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); */ class LSldap extends LSlog_staticLoggerClass { - private static $config; + /** + * LDAP connection configuration + * (LSconfig.ldap_servers..ldap_config) + * @see LSsession::LSldapConnect() + * @see LSldap::setConfig() + * @see LSldap::getConfig() + * @var array + */ + private static array $config = array(); + + /** + * LDAP connection (Net_LDAP2 object) + * @see LSldap::connect() + * @see LSldap::reconnectAs() + * @see LSldap::isConnected() + * @see LSldap::close() + * @var Net_LDAP2|null + */ private static $cnx = NULL; /** @@ -56,11 +73,11 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param array $config LDAP configuration array in format of Net_LDAP2 + * @param array|null $config LDAP configuration array in format of Net_LDAP2 * * @return boolean true if connected, false instead */ - public static function connect($config = null) { + public static function connect($config=null) { if ($config) { self :: setConfig($config); } @@ -78,9 +95,9 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param array $config Bind DN - * @param array $config Bind password - * @param array $config LDAP configuration array in format of Net_LDAP2 + * @param string $dn Bind DN + * @param string $pwd Bind password + * @param array|null $config LDAP configuration array as expected by Net_LDAP2 * (optional, default: keep current) * * @return boolean true if connected, false instead @@ -109,7 +126,7 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param array $config Bind DN + * @param string $dn Bind DN * * @return boolean true if authz proxy controle is set, false otherwise */ @@ -147,6 +164,7 @@ class LSldap extends LSlog_staticLoggerClass { */ public static function close() { self :: $cnx -> done(); + self :: $cnx = null; } /** @@ -156,9 +174,9 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $filterThe search LDAP filter - * @param array $config The base DN of the search - * @param array $config Array to search parameters as accepted by Net_LDAP2::search() + * @param string $filter The search LDAP filter + * @param string $basedn The base DN of the search + * @param array $params Array to search parameters as accepted by Net_LDAP2::search() * * @see Net_LDAP2::search() * @@ -169,7 +187,7 @@ class LSldap extends LSlog_staticLoggerClass { * - attrs: Associative array of the entry's attributes values */ public static function search($filter, $basedn=NULL, $params=array()) { - $filterstr = (is_a($filter, 'Net_LDAP2_Filter')?$filter->as_string():$filter); + $filterstr = (is_a($filter, 'Net_LDAP2_Filter')?$filter->asString():$filter); if (is_empty($basedn)) { $basedn = self :: getConfig('basedn'); if (is_empty($basedn)) { @@ -207,9 +225,9 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $filterThe search LDAP filter - * @param array $config The base DN of the search - * @param array $config Array to search parameters as accepted by Net_LDAP2::search() + * @param string $filter The search LDAP filter + * @param string $basedn The base DN of the search + * @param array $params Array to search parameters as accepted by Net_LDAP2::search() * * @see Net_LDAP2::search() * @@ -218,7 +236,7 @@ class LSldap extends LSlog_staticLoggerClass { public static function getNumberResult($filter, $basedn=NULL, $params=array()) { if (empty($filter)) $filter = NULL; - $filterstr = (is_a($filter, 'Net_LDAP2_Filter')?$filter->as_string():$filter); + $filterstr = (is_a($filter, 'Net_LDAP2_Filter')?$filter->asString():$filter); if (is_empty($basedn)) { $basedn = self :: getConfig('basedn'); if (is_empty($basedn)) { @@ -246,8 +264,8 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param array $config DN de l'entré Ldap - * @param array $config LDAP filter string (optional, default: null == '(objectClass=*)') + * @param string $dn DN de l'entré Ldap + * @param string|Net_LDAP2_Filter|null $filter LDAP filter string (optional, default: null == '(objectClass=*)') * @param array|null $attrs Array of requested attribute (optional, default: null == all attributes, excepted internal) * @param boolean $include_internal If true, internal attributes will be included (default: false) * @@ -284,14 +302,14 @@ class LSldap extends LSlog_staticLoggerClass { } /** - * Return a attribute value + * Check if an attribute exists in specified attributes collection * * It performs a case-insensitive search. * * @author Emmanuel Saracco * - * @param array $config Array of LDAP attributes - * @param array $config Name of a attribute + * @param array $attrs Array of LDAP attributes + * @param string $name Name of a attribute * * @return boolean true if found */ @@ -306,13 +324,13 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Emmanuel Saracco * - * @param array $config Array of LDAP attributes - * @param array $config Name of a attribute - * @param boolean $include_internal true if we must return array + * @param array $attrs Array of LDAP attributes + * @param string $name Name of a attribute + * @param boolean $multiple true if we must return array * * @return mixed Found value (or array of values) or null */ - public static function getAttr($attrs, $name, $multiple = false) { + public static function getAttr($attrs, $name, $multiple=false) { $name = strtolower($name); foreach ($attrs as $k => $v) { if (strtolower($k) === $name) { @@ -327,8 +345,8 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param array $config The object type - * @param array $config The DN of the LDAP entry + * @param string $object_type The object type + * @param string $dn The DN of the LDAP entry * * @return Net_LDAP2_Entry|array A Net_LDAP2_Entry object or an array if * it's a new entry: @@ -366,10 +384,10 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param array $config DN of the requested LDAP entry + * @param string $dn DN of the requested LDAP entry * @param array|null $attrs Array of requested attribute (optional, default: null == all attributes, excepted internal) * - * @return Net_LDAP2_Entry|boolean A Net_LDAP2_Entry object or false if error occured + * @return Net_LDAP2_Entry|false A Net_LDAP2_Entry object or false if error occured */ public static function getLdapEntry($dn, $attrs=null) { $entry = self :: $cnx -> getEntry($dn, (is_array($attrs)?$attrs:array())); @@ -386,7 +404,7 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param array $config DN of the LDAP entry to check + * @param string $dn DN of the LDAP entry to check * * @return boolean True if entry exists, false otherwise */ @@ -397,9 +415,10 @@ class LSldap extends LSlog_staticLoggerClass { /** * Return a new Net_LDAP2_Entry object * - * @param array $config The DN of the object - * @param array $config Array of the object's object classes - * @param array $config Array of object attributes values. Format: array('attr_name' => attr_value, ...) + * @param string $dn The DN of the object + * @param array[string] $objectClass Array of the object's object classes + * @param array $attrs Array of the object's attributes values + * @param boolean $add Set to true to add the new entry to LDAP directory (default: false) * * @return Net_LDAP2_Entry|False A Net_LDAP2_Entry object on success, False otherwise */ @@ -416,7 +435,7 @@ class LSldap extends LSlog_staticLoggerClass { } if($add) { if(!self :: $cnx -> add($newentry)) { - return; + return false; } } return $newentry; @@ -429,9 +448,9 @@ class LSldap extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param array $config The object type - * @param array $config DN of the LDAP object - * @param array $config Array of object attributes changes + * @param string $object_type The object type + * @param string $dn DN of the LDAP object + * @param array $change Array of object attributes changes * * @return boolean True if object was updated, False otherwise. */ @@ -592,8 +611,8 @@ class LSldap extends LSlog_staticLoggerClass { /** * Move an entry in LDAP directory * - * @param array $config The current object DN - * @param array $config The new object DN + * @param string $old The current object DN + * @param string $new The new object DN * * @return boolean True if object was moved, False otherwise. */ @@ -610,17 +629,17 @@ class LSldap extends LSlog_staticLoggerClass { /** * Combine LDAP Filters * - * @param array $config The combine logical operator. May be "and", + * @param string $op The combine logical operator. May be "and", * "or", "not" or the subsequent logical * equivalents "&", "|", "!". - * @param array $config Array of LDAP filters (as string or + * @param array[string|Net_LDAP2_Filter] $filters Array of LDAP filters (as string or * Net_LDAP2_Filter object) - * @param boolean $include_internal Set to true if you want to retreive + * @param boolean $asStr Set to true if you want to retreive * combined filter as string instead of * as a Net_LDAP2_Filter object (optional, * default: false) * - * @return Net_LDAP2_Filter | False The combined filter or False + * @return string|Net_LDAP2_Filter|false The combined filter or False in case of error **/ public static function combineFilters($op, $filters, $asStr=false) { if (is_array($filters) && !empty($filters)) { @@ -651,7 +670,7 @@ class LSldap extends LSlog_staticLoggerClass { /** * Check LDAP Filters String * - * @params string A LDAP filter as string + * @param string $filter A LDAP filter as string * * @return boolean True only if the filter could be parsed **/ @@ -672,9 +691,9 @@ class LSldap extends LSlog_staticLoggerClass { * * This method uses LDAP controls when possible (Net_LDAP2 does not). * - * @param array $config The object type - * @param array $config Array of changed attributes - * @param array $config DN of the LDAP object + * @param string $object_type The object type + * @param array $changed_attrs Array of changed attributes + * @param string $dn DN of the LDAP object * * @author Emmanuel Saracco * @@ -721,9 +740,9 @@ class LSldap 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 **/ diff --git a/src/includes/class/class.LSldapObject.php b/src/includes/class/class.LSldapObject.php index 5ce6b256..f15a501b 100644 --- a/src/includes/class/class.LSldapObject.php +++ b/src/includes/class/class.LSldapObject.php @@ -28,25 +28,97 @@ LSsession :: loadLSclass('LSattribute'); * * Cette classe définis la base de tout objet ldap géré par LdapSaisie * + * @property-read string $subDnValue + * @property-read string $subDnName + * @property-read string $rdn + * @property-read string $type * @author Benjamin Renard */ class LSldapObject extends LSlog_staticLoggerClass { - var $config = array(); - var $type_name; - var $attrs = array(); - var $forms; + /** + * Object configuration + * @var array + */ + var array $config = array(); + + /** + * Object type name + * @var string + */ + var string $type_name; + + /** + * Object attributes + * @var array + */ + var array $attrs = array(); + + /** + * Object active forms + * @var array + */ + var array $forms; + + /** + * Active LSview + * @var LSform + */ var $view; + + /** + * Object DN + * @var string|boolean + */ var $dn=false; + + /** + * Object old DN (before moving it in LDAP directory) + * @var string|boolean + */ var $oldDn=false; - var $other_values=array(); + + /** + * Array of registred values, used to add custom info to compute LSformat + * @var array + */ + var array $other_values=array(); + + /** + * Cache of LSsession::whoami() result for the current connected user + * @var string|null + */ var $_whoami=NULL; - var $_LSrelationsCache=array(); - var $_events=array(); - var $_objectEvents=array(); + /** + * Cache of related objects + * @see LSldapObject::updateLSrelationsCache() + * @var array + */ + var array $_LSrelationsCache=array(); - var $cache=array(); + /** + * Object registered hooks on event + * @see LSldapObject::addEvent() + * @see LSldapObject::fireEvent() + * @var array + */ + var array $_events=array(); + + /** + * Object registered hooks on event trigger object methods + * @see LSldapObject::addObjectEvent() + * @see LSldapObject::fireEvent() + * @var array + */ + var array $_objectEvents=array(); + + /** + * Chache of the object computed information + * @see LSldapObject::__get() + * @var array + */ + var array $cache=array(); /** * Constructeur @@ -95,7 +167,7 @@ class LSldapObject extends LSlog_staticLoggerClass { $this -> dn = $dn; $filter = $this -> getObjectFilter(); if ($additional_filter) { - if (!is_a($additional_filter, Net_LDAP2_Filter)) + if (!is_a($additional_filter, 'Net_LDAP2_Filter')) $additional_filter = Net_LDAP2_Filter :: parse($additional_filter); $filter = Net_LDAP2_Filter :: combine( 'and', @@ -173,7 +245,7 @@ class LSldapObject extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $dn Format de la chaine + * @param string $format Format de la chaine * * @return string Valeur d'une chaine formatée */ @@ -190,11 +262,15 @@ class LSldapObject extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $dn Format de la chaine + * @param LSformat $format String LSformat + * @param array|null $extraValues Extra values to compute the LSformat * * @return string Valeur d'une chaine formatee */ - public function getDisplayFData($format) { + public function getDisplayFData($format, $extraValues=null) { + if (is_array($extraValues)) + foreach($extraValues as $key => $val) + $this -> registerOtherValue($key, $val); return getFData($format,$this,'getDisplayValue'); } @@ -203,8 +279,8 @@ class LSldapObject extends LSlog_staticLoggerClass { * * This method create a LSform from the object and its attributes configurations. * - * @param string $dn Form identifier (required) - * @param string $dn DN of a similar object. If defined, attributes values of this object will be loaded in the form. + * @param string $idForm Form identifier (required) + * @param string $load DN of a similar object. If defined, attributes values of this object will be loaded in the form. * @param boolean $api_mode Enable API mode (defaut: false) * * @author Benjamin Renard @@ -292,7 +368,7 @@ class LSldapObject extends LSlog_staticLoggerClass { * _updateData() protected method. * * @param string $idForm Form ID - * @param boolean $api_mode to enable just check mode + * @param boolean $justCheck to enable just check mode * * @see _updateData() * @@ -333,9 +409,9 @@ class LSldapObject extends LSlog_staticLoggerClass { * This method implement the continuation and the end of the object data * udpate. * - * @param string $dn of object data + * @param array $new_data New of object data * @param string $idForm Form ID - * @param boolean $api_mode to enable just check mode + * @param boolean $justCheck to enable just check mode * * @author Benjamin Renard * @@ -403,8 +479,8 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Validate data returned by form * - * @param string $dn The source LSform ID - * @param boolean $api_mode to enable just check mode (do not validate data using LDAP search) + * @param string $idForm The source LSform ID + * @param boolean $justCheck Set to true to enable just check mode (do not validate data using LDAP search) * * @author Benjamin Renard * @@ -456,9 +532,9 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Validate one attribute's data returned by form * - * @param string $dn The source LSform ID + * @param LSform $LSform The source LSform * @param LSattribute &$attr The attribute to validate - * @param boolean $api_mode to enable just check mode (do not validate data using LDAP search) + * @param boolean $justCheck Set to true to enable just check mode (do not validate data using LDAP search) * * @author Benjamin Renard * @@ -652,7 +728,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Submit changes made to LDAP directory * - * @param string $dn The source LSform ID + * @param string $idForm The source LSform ID * * @author Benjamin Renard * @@ -821,7 +897,7 @@ class LSldapObject extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $dn Le mot clé recherché + * @param string $pattern Le mot clé recherché * @param bool $approx booléen Booléen activant ou non la recherche approximative * * @return string le filtre ldap correspondant @@ -845,9 +921,9 @@ class LSldapObject extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $dn (ou string) Filtre de recherche Ldap / Tableau de filtres de recherche - * @param string $dn DN de base pour la recherche - * @param string $dn Paramètres de recherche au format Net_LDAP2::search() + * @param Net_LDAP2_Filter|string|array|null $filter Filtre de recherche Ldap / Tableau de filtres de recherche + * @param string|null $basedn DN de base pour la recherche + * @param array $params Search parameters (as expected by Net_LDAP2::search()) * * @return array Tableau d'objets correspondant au resultat de la recherche */ @@ -865,7 +941,7 @@ class LSldapObject extends LSlog_staticLoggerClass { if (is_array($params)) { $sparams=array_merge($sparams,$params); } - $LSsearch = new LSsearch($this -> type_name,'LSldapObjet::listObjects',$sparams,true); + $LSsearch = new LSsearch($this -> type_name,'LSldapObject::listObjects',$sparams,true); $LSsearch -> run(); @@ -880,10 +956,11 @@ class LSldapObject extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $dn Filtre de recherche Ldap - * @param string $dn DN de base pour la recherche - * @param string $dn Paramètres de recherche au format Net_LDAP2::search() - * @param string $dn Format d'affichage du nom des objets + * @param Net_LDAP2_Filter|string|null $filter LDAP search filter + * @param string|null $sbasedn Base DN of the search + * @param array $sparams Search parameters (as expected by Net_LDAP2::search()) + * @param string|false $displayFormat LSformat of objects's display name + * @param bool $cache Enable/disable cache (default: true) * * @return array Tableau dn => name correspondant au resultat de la recherche */ @@ -922,10 +999,10 @@ class LSldapObject extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $dn Valeur de son RDN ou de la valeur pour composer le filtre - * @param string $dn Le DN de base de la recherche - * @param string $dn Le filtre de recherche de l'objet - * @param string $dn Tableau de paramètres + * @param string $name RDN value or value to compute filter + * @param string|null $basedn Base DN of the search + * @param Net_LDAP2_Filter|string|null $filter LDAP search filter + * @param array $params Search parameters (as expected by Net_LDAP2::search()) * * @return array Tableau d'objets correspondant au resultat de la recherche */ @@ -952,9 +1029,9 @@ class LSldapObject extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $dn The requested value - * @param boolean $api_mode If true and the result is an array, return only the first value (optional, default: false) - * @param string $dn Default value if unknown (optional, default: a space caracter = ' ') + * @param string $val The requested value + * @param boolean $first If true and the result is an array, return only the first value (optional, default: false) + * @param string $default Default value if unknown (optional, default: a space caracter = ' ') * * @return mixed The requested value or $default if unknown */ @@ -989,7 +1066,7 @@ class LSldapObject extends LSlog_staticLoggerClass { * * @author Benjamin Renard * - * @param string $dn Le nom de la valeur demandee + * @param string $val Le nom de la valeur demandee * * @return mixed la valeur demandee ou ' ' si celle-ci est inconnue. */ @@ -1008,8 +1085,8 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Ajoute une valeur dans le tableau $this -> other_values * - * @param string $dn Le nom de la valeur - * @param string $dn La valeur + * @param string $name Le nom de la valeur + * @param string $value La valeur * * @return void **/ @@ -1130,7 +1207,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Retrieve object type translated label * - * @param string|Net_LDAP2_Filter|null $additional_filter The object type (optional, default: called class name) + * @param string $type The object type (optional, default: called class name) * * @author Benjamin Renard * @@ -1182,7 +1259,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Retourne la valeur (DN) du subDn de l'objet * - * @parram[in] $dn string Un DN + * @param string $dn Un DN * * @return string La valeur du subDn de l'object */ @@ -1201,7 +1278,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Retourne la nom du subDn de l'objet * - * @parram[in] $dn string Un DN + * @param string $dn Un DN * * @return string Le nom du subDn de l'object */ @@ -1565,8 +1642,8 @@ class LSldapObject extends LSlog_staticLoggerClass { * @param string $attrValue La valeur que doit avoir l'attribut : * - soit le dn (par defaut) * - soit la valeur [0] d'un attribut - * @param string $canEditFunction Le nom de la fonction pour vérifier que la - * relation avec l'objet est éditable par le user + * @param string|null $canEditFunction Le nom de la fonction pour vérifier que la + * relation avec l'objet est éditable par le user * @param array $attrValues L'ensembe des valeurs que peut avoir l'attribut avant mise à jour : * - soit le dn (par defaut) * - soit une des valeurs d'un attribut @@ -1612,11 +1689,11 @@ class LSldapObject extends LSlog_staticLoggerClass { * Renome un objet en relation dans l'attribut $attr de $this * * @param LSldapObject $object Un objet de type $objectType à renomer - * @param string|Net_LDAP2_Filter|null $additional_filter Le(s) ancienne(s) valeur(s possible(s) - * faisant référence à l'objet + * @param string|array[string] $oldValues Le(s) ancienne(s) valeur(s possible(s) + * faisant référence à l'objet * @param string $attr L'attribut dans lequel l'objet doit être supprimé * @param string $objectType Le type d'objet en relation - * @param array $attrValue La valeur que doit avoir l'attribut : + * @param array|string $attrValue La valeur que doit avoir l'attribut : * - soit le dn (par defaut) * - soit la valeur [0] d'un attribut * @@ -1659,16 +1736,16 @@ class LSldapObject extends LSlog_staticLoggerClass { * de type $objectType en modifiant la valeur de leur attribut $attr des objets * en relation * - * @param string $dn Un object (type : $this -> userObjectType) : l'utilisateur + * @param LSldapObject $object Un object (type : $this -> userObjectType) : l'utilisateur * @param array[string] $listDns Un tableau des DNs des objets en relation * @param string $attr L'attribut dans lequel l'utilisateur doit apparaitre * @param string $objectType Le type d'objet en relation * @param string $attrValue La valeur que doit avoir l'attribut : * - soit le dn (par defaut) * - soit la valeur [0] d'un attribut - * @param string $canEditFunction Le nom de la fonction pour vérifier que la + * @param string|null $canEditFunction Le nom de la fonction pour vérifier que la * relation avec l'objet est éditable par le user - * @param array|string $attrValues L'ensembe des valeurs que peut avoir l'attribut avant mise à jour : + * @param array|string|null $attrValues L'ensembe des valeurs que peut avoir l'attribut avant mise à jour : * - soit le dn (par defaut) * - soit une des valeurs d'un attribut * @@ -1718,9 +1795,9 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Ajouter une action lors d'un événement * - * @param string $dn Le nom de l'événement - * @param string $dn Le nom de la fonction à exectuer - * @param string $dn Paramètre pour le lancement de la fonction + * @param string $event Le nom de l'événement + * @param string $fct Le nom de la fonction à exectuer + * @param array $param Paramètre pour le lancement de la fonction * @param string $class Nom de la classe possèdant la méthode $fct à executer * * @return void @@ -1736,10 +1813,10 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Ajouter une action sur un objet lors d'un événement * - * @param string $dn Le nom de l'événement + * @param string $event Le nom de l'événement * @param object $obj L'objet dont la méthode doit être executé - * @param string $dn Le nom de la méthode - * @param string $dn Paramètre d'execution de la méthode + * @param string $meth Le nom de la méthode + * @param string $param Paramètre d'execution de la méthode * * @return void */ @@ -1754,7 +1831,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Lance les actions à executer lors d'un événement * - * @param string $dn 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 */ @@ -1858,7 +1935,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Lance les actions à executer lors d'un événement sur l'objet lui-même * - * @param string $dn 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 **/ @@ -1891,7 +1968,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Access to infos of the object * - * @param string $dn The name of the value + * @param string $key The name of the value * * @return mixed The value **/ @@ -1928,7 +2005,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Check if object type have a specified attribute * - * @param string $dn The attribute name + * @param string $attr_name The attribute name * * @teval boolean True if object type have a attribute of this name, False otherwise */ @@ -1955,7 +2032,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Check if an IOformat is valid for this object type * - * @param string $dn The IOformat name to check + * @param string $f The IOformat name to check * * @return boolean True if it's a valid IOformat, false otherwise **/ @@ -1966,9 +2043,9 @@ class LSldapObject 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 **/ @@ -1988,7 +2065,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Return string representation of the object * - * @param boolean $api_mode If true, result will be enclosed using "< >" (optional, default: true) + * @param boolean $enclosed If true, result will be enclosed using "< >" (optional, default: true) * * @return string The string representation of the LdapObject */ @@ -2013,7 +2090,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI show command * - * @param string $dn Command arguments : + * @param array $command_args Command arguments : * - Positional arguments : * - LSobject type * - object DN @@ -2067,12 +2144,12 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI show search * - * @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 **/ public static function cli_show_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $opts = array_merge($opts, array ('-r', '--raw-values', '-j', '--json', '-p', '--pretty')); @@ -2121,7 +2198,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI helper to show the object info * - * @param string $dn Show attributes raw values (instead of display ones) + * @param bool $raw_values Show attributes raw values (instead of display ones) * * @return void **/ @@ -2170,9 +2247,9 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI helper to show the attribute * - * @param string $dn The attribute name - * @param string $dn Show attributes raw values (instead of display ones) - * @param string $dn Prefix for each line displayed (optional, default: no prefix) + * @param string $attr_name The attribute name + * @param bool $raw_values Show attributes raw values (instead of display ones) + * @param string $prefix Prefix for each line displayed (optional, default: no prefix) * * @return string The formated attribute message **/ @@ -2186,9 +2263,9 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI helper to show the attribute values * - * @param string $dn The attribute name - * @param string $dn Attribute values - * @param string $dn Prefix for each line displayed (optional, default: no prefix) + * @param string $attr_name The attribute name + * @param string|array[string] $values Attribute values + * @param string $prefix Prefix for each line displayed (optional, default: no prefix) * * @return string The formated attribute values message **/ @@ -2212,8 +2289,8 @@ class LSldapObject extends LSlog_staticLoggerClass { * CLI helper to show the attributes values * * @param array $attrs_values attrs The attributes values - * @param string|Net_LDAP2_Filter|null $additional_filter The label text to show before attributes values - * @param string $dn Prefix for each line displayed (optional, default: no prefix) + * @param string|null $label The label text to show before attributes values + * @param string $prefix Prefix for each line displayed (optional, default: no prefix) * * @return string The formated attributes values message **/ @@ -2230,8 +2307,8 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI helper to export the object info as JSON * - * @param string $dn Export attributes raw values (instead of display ones) - * @param string $dn Prettify JSON export + * @param bool $raw_values Export attributes raw values (instead of display ones) + * @param bool $pretty Prettify JSON export * * @return void **/ @@ -2293,7 +2370,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI remove command * - * @param string $dn Command arguments : + * @param string $command_args Command arguments : * - Positional arguments : * - LSobject type * - object DN @@ -2349,12 +2426,12 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI remove 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 **/ public static function cli_remove_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $opts = array_merge($opts, array ('-N', '--no-confirm')); @@ -2405,10 +2482,10 @@ class LSldapObject extends LSlog_staticLoggerClass { * * attr=value1|value2 * - * @param LSattribute &$attr The LDAP object + * @param LSldapObject $obj The LDAP object * @param array &$attrs_values The reference of the array that store attributes values - * @param string $dn The command argument to parse - * @param string $dn The delimiter of multiple-value attribute (optional, default: '|') + * @param string $command_arg The command argument to parse + * @param string $delimiter The delimiter of multiple-value attribute (optional, default: '|') * * @return boolean True if attribute values successfully parsed, False otherwise **/ @@ -2435,7 +2512,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI create command * - * @param string $dn Command arguments : + * @param string $command_args Command arguments : * - Positional arguments : * - LSobject type * - object DN @@ -2536,12 +2613,12 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI create 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 **/ public static function cli_create_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $opts = array_merge($opts, array ('-j', '--just-try', '-D', '--delimiter', '-N', '--no-confirm')); @@ -2600,7 +2677,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI modify command * - * @param string $dn Command arguments : + * @param string $command_args Command arguments : * - Positional arguments : * - LSobject type * - object DN @@ -2705,12 +2782,12 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI modify 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 **/ public static function cli_modify_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $opts = array_merge($opts, array ('-j', '--just-try', '-D', '--delimiter', '-N', '--no-confirm')); @@ -2785,7 +2862,7 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * CLI relation command * - * @param string $dn Command arguments : + * @param string $command_args Command arguments : * - Positional arguments : * - LSobject type * - object DN @@ -2917,12 +2994,12 @@ class LSldapObject extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI relation 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 **/ public static function cli_relation_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $opts = array_merge($opts, array ('-a', '--add', '-r', '--remove')); @@ -3039,13 +3116,13 @@ class LSldapObject extends LSlog_staticLoggerClass { return LScli :: autocomplete_opts($opts, $comp_word); } - /* + /** * Check validity of a LSobject type name * * A LSobjet type name must only contain letter, digits or dash or * underscore. * - * @param string $dn The LSobject type name to check + * @param string $name The LSobject type name to check * * @return boolean True is type name is valid, False otherwise */ diff --git a/src/includes/class/class.LSlog.php b/src/includes/class/class.LSlog.php index b14a36f4..859acf64 100644 --- a/src/includes/class/class.LSlog.php +++ b/src/includes/class/class.LSlog.php @@ -27,25 +27,48 @@ */ class LSlog { - // Enable state - private static $enabled = false; + /** + * Enable state + * @var bool + */ + private static bool $enabled = false; - // Configured handlers - private static $handlers = array(); + /** + * Configured handlers + * @see self::start() + * @see self::add_handler() + * @var array + */ + private static array $handlers = array(); - // Default handlers (if not configured) - private static $default_handlers = array( + /** + * Default handlers (if not configured) + * @see self::start() + * @var array + */ + private static array $default_handlers = array( array ( 'handler' => 'file', ), ); - // Current level + /** + * Current level + * @var string|null + */ private static $level; - private static $default_level = 'WARNING'; - // Levels - private static $levels=array( + /** + * Default level + * @var string + */ + private static string $default_level = 'WARNING'; + + /** + * Available levels + * @var array + */ + private static array $levels = array( 'TRACE' => 0, 'DEBUG' => 1, 'INFO' => 2, @@ -54,8 +77,11 @@ class LSlog { 'FATAL' => 5, ); - // Current existing loggers - private static $loggers = array(); + /** + * Current existing loggers + * @var array + */ + private static array $loggers = array(); /** * Start/initialize logging @@ -315,7 +341,7 @@ class LSlog { * Could be used as PHP set_exception_handler callable * @see https://www.php.net/set_exception_handler * - * @param Exception $exceptionThe exception to log + * @param Exception $exception The exception to log * @param string|null $prefix Custom message prefix (optional, default: "An exception occured :\n") * @param boolean $fatal Log exception as a fatal error (optional, default: true) * @param string|null $logger The logger name (optional, default: null) diff --git a/src/includes/class/class.LSlog_console.php b/src/includes/class/class.LSlog_console.php index 5435962f..f5fbefa6 100644 --- a/src/includes/class/class.LSlog_console.php +++ b/src/includes/class/class.LSlog_console.php @@ -27,8 +27,18 @@ */ class LSlog_console extends LSlog_handler { - // File-descriptors for stdout/stderr + /** + * Stdout file descriptor + * @see self:__construct() + * @var resource + */ private $stdout; + + /** + * Stderr file descriptor + * @see self:__construct() + * @var resource + */ private $stderr; /** @@ -49,8 +59,8 @@ class LSlog_console extends LSlog_handler { /** * Log a message * - * @param array $config The message level - * @param array $config The message + * @param string $level The message level + * @param string $message The message * @param string|null $logger The logger name (optional, default: null) * * @return void diff --git a/src/includes/class/class.LSlog_email.php b/src/includes/class/class.LSlog_email.php index 06420c4d..c106ae03 100644 --- a/src/includes/class/class.LSlog_email.php +++ b/src/includes/class/class.LSlog_email.php @@ -27,11 +27,18 @@ */ class LSlog_email extends LSlog_handler { - // The configured email recipient + /** + * The configured email recipient + * @var string|null + */ private $recipient = null; - // Default datetime prefix (enabled/disabled) - protected $default_datetime_prefix = false; + /** + * Defaultly add datetime prefix (enabled/disabled) + * @see LSlog_handler::__get() + * @var bool + */ + protected bool $default_datetime_prefix = false; /** * Constructor @@ -62,8 +69,8 @@ class LSlog_email extends LSlog_handler { /** * Log a message * - * @param array $config The message level - * @param array $config The message + * @param string $level The message level + * @param string $message The message * @param string|null $logger The logger name (optional, default: null) * * @return void diff --git a/src/includes/class/class.LSlog_file.php b/src/includes/class/class.LSlog_file.php index 41970ade..d35c8d05 100644 --- a/src/includes/class/class.LSlog_file.php +++ b/src/includes/class/class.LSlog_file.php @@ -62,8 +62,8 @@ class LSlog_file extends LSlog_handler { /** * Log a message * - * @param array $config The message level - * @param array $config The message + * @param string $level The message level + * @param string $message The message * @param string|null $logger The logger name (optional, default: null) * * @return void diff --git a/src/includes/class/class.LSlog_handler.php b/src/includes/class/class.LSlog_handler.php index 01570d32..0d6589f3 100644 --- a/src/includes/class/class.LSlog_handler.php +++ b/src/includes/class/class.LSlog_handler.php @@ -25,34 +25,72 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); /** * Default logging handler * + * @property-read bool $enabled + * @property-read string $format * @author Benjamin Renard */ class LSlog_handler extends LSlog_staticLoggerClass { - // The handler configuration - protected $config; + /** + * The handler configuration + * (LSconfig.handlers.) + * @see LSlog::start() + * @see LSlog_handler::__construct() + * @var array + */ + protected array $config = array(); - // Log level + /** + * Log level + * @var string|null + */ protected $level; - // Default log formats - protected $default_format = '%{requesturi} - %{remoteaddr} - %{ldapservername} - %{authuser} - %{logger} - %{level} - %{message}'; - protected $default_cli_format = '%{clibinpath} - %{logger} - %{level} - %{message}'; + /** + * Default log formats + * @var LSformat + */ + protected string $default_format = '%{requesturi} - %{remoteaddr} - %{ldapservername} - %{authuser} - %{logger} - %{level} - %{message}'; - // Default datetime prefix (enabled/disabled) - protected $default_datetime_prefix = true; + /** + * Default CLI log formats + * @var LSformat + */ + protected string $default_cli_format = '%{clibinpath} - %{logger} - %{level} - %{message}'; - // Default datetime format - protected $default_datetime_format = 'Y/m/d H:i:s'; + /** + * Defaultly add datetime prefix (enabled/disabled) + * @see LSlog_handler::__get() + * @var bool + */ + protected bool $default_datetime_prefix = true; - // Loggers filters - protected $loggers = array(); - protected $excluded_loggers = array(); + /** + * Default datetime format (as expected by date()) + * @see LSlog_handler::__get() + * @see date() + * @var string + */ + protected string $default_datetime_format = 'Y/m/d H:i:s'; + + /** + * Explicity included loggers + * (LSconfig.handlers..loggers) + * @var array + */ + protected array $loggers = array(); + + /** + * Explicity excluded loggers + * (LSconfig.handlers..excluded_loggers) + * @var array + */ + protected array $excluded_loggers = array(); /** * Constructor * - * @param array $config The handler configuration + * @param array $config The handler configuration (LSconfig.handlers.) * * @return void **/ @@ -92,7 +130,7 @@ class LSlog_handler extends LSlog_staticLoggerClass { /** * Get handler info * - * @param array $config The info name + * @param string $key The info name * * @return mixed The info value **/ @@ -131,10 +169,10 @@ class LSlog_handler extends LSlog_staticLoggerClass { /** * Get a configuration variable value * - * @param array $config The configuration variable name - * @param array $config The default value to return if configuration variable + * @param string $var The configuration variable name + * @param mixed $default The default value to return if configuration variable * is not set (Default : null) - * @param array $config The type of expected value. The configuration variable + * @param string|null $cast The type of expected value. The configuration variable * value will be cast as this type. Could be : bool, int, * float or string. (Optional, default : raw value) * @@ -147,7 +185,7 @@ class LSlog_handler extends LSlog_staticLoggerClass { /** * Set log level * - * @param array $config The level + * @param string $level The level * * @return bool True if log level set, False otherwise **/ @@ -158,12 +196,13 @@ class LSlog_handler extends LSlog_staticLoggerClass { } self :: log_debug("Log handler ".get_called_class()." level set to ".(is_null($level)?'default':$level)); $this -> level = $level; + return true; } /** * Check level against configured level * - * @param array $config The level + * @param string $level The level * * @return bool True if a message with this level have to be logged, False otherwise **/ @@ -174,7 +213,7 @@ class LSlog_handler extends LSlog_staticLoggerClass { /** * Check logger against configured loggers filters * - * @param array $config The logger + * @param string $logger The logger name * * @return bool True if message of this logger have to be logged, False otherwise **/ @@ -191,8 +230,8 @@ class LSlog_handler extends LSlog_staticLoggerClass { /** * Log a message * - * @param array $config The message level - * @param array $config The message + * @param array $level The message level + * @param array $message The message * @param string|null $logger The logger name (optional, default: null) * * @return void @@ -204,8 +243,8 @@ class LSlog_handler extends LSlog_staticLoggerClass { /** * Format a message * - * @param array $config The message level - * @param array $config The message + * @param string $level The message level + * @param string $message The message * @param string|null $logger The logger name (optional, default: null) * * @return string The formated message to log diff --git a/src/includes/class/class.LSlog_logger.php b/src/includes/class/class.LSlog_logger.php index 320d817f..699d7b42 100644 --- a/src/includes/class/class.LSlog_logger.php +++ b/src/includes/class/class.LSlog_logger.php @@ -25,20 +25,35 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); /** * Logger class for LSlog * + * @property-read string $name + * @property-read bool $enabled + * @property-read string $level * @author Benjamin Renard */ class LSlog_logger extends LSlog_staticLoggerClass { - // Name + /** + * The logger name + * @var string + */ private $name; - // The handler configuration - private $config; + /** + * The handler configuration + * @var array + */ + private array $config = array(); - // Enabled/disabled - private $enabled; + /** + * Enabled state + * @var bool + */ + private bool $enabled = true; - // Level + /** + * Logger custom level + * @var string|null + */ private $level; /** @@ -203,7 +218,7 @@ class LSlog_logger extends LSlog_staticLoggerClass { /** * Log an exception * - * @param Exception $exceptionThe exception to log + * @param Exception $exception The exception to log * @param string|null $prefix Custom message prefix (optional, see LSlog :: exception()) * @param boolean $fatal Log exception as a fatal error (optional, default: true) * diff --git a/src/includes/class/class.LSlog_staticLoggerClass.php b/src/includes/class/class.LSlog_staticLoggerClass.php index 4f579c02..848f148e 100644 --- a/src/includes/class/class.LSlog_staticLoggerClass.php +++ b/src/includes/class/class.LSlog_staticLoggerClass.php @@ -27,7 +27,7 @@ */ class LSlog_staticLoggerClass { - /* + /** * Log a message via class logger * * @param string $level The log level (see LSlog) @@ -42,7 +42,7 @@ class LSlog_staticLoggerClass { /** * Log an exception via class logger * - * @param Exception $exceptionThe exception to log + * @param Exception $exception The exception to log * @param string|null $prefix Custom message prefix (optional, see self :: log_exception()) * @param boolean $fatal Log exception as a fatal error (optional, default: true) * diff --git a/src/includes/class/class.LSlog_syslog.php b/src/includes/class/class.LSlog_syslog.php index 23e6146b..6320e478 100644 --- a/src/includes/class/class.LSlog_syslog.php +++ b/src/includes/class/class.LSlog_syslog.php @@ -27,7 +27,10 @@ */ class LSlog_syslog extends LSlog_handler { - // Force syslog priority + /** + * Force syslog priority + * @var string|null + */ private $priority = null; // Levels to syslog priority mapping @@ -43,11 +46,18 @@ class LSlog_syslog extends LSlog_handler { 'TRACE' => LOG_DEBUG, // also debug-level message ); - // Default syslog priority (used if level is not provided or invalid) - private static $default_priority = LOG_WARNING; + /** + * Default syslog priority (used if level is not provided or invalid) + * @var int + */ + private static int $default_priority = LOG_WARNING; - // Default datetime prefix (enabled/disabled) - protected $default_datetime_prefix = false; + /** + * Defaultly add datetime prefix (enabled/disabled) + * @see LSlog_handler::__get() + * @var bool + */ + protected bool $default_datetime_prefix = false; /** * Constructor @@ -87,8 +97,8 @@ class LSlog_syslog extends LSlog_handler { /** * Log a message * - * @param array $config The message level - * @param array $config The message + * @param string $level The message level + * @param string $message The message * @param string|null $logger The logger name (optional, default: null) * * @return void @@ -103,15 +113,15 @@ class LSlog_syslog extends LSlog_handler { /** * Get syslog corresponding priority to a specific log level * - * @param array $config The log level + * @param string $level The log level * * @return int Syslog corresponding priority **/ private function level2priority($level) { if ($this -> priority && $level != $this -> priority) return $this -> level2priority($this -> priority); - if (array_key_exists($level, static :: $levels2priority)) - return static :: $levels2priority[$level]; - return static :: $default_priority; + if (array_key_exists($level, self :: $levels2priority)) + return self :: $levels2priority[$level]; + return self :: $default_priority; } } diff --git a/src/includes/class/class.LSlog_system.php b/src/includes/class/class.LSlog_system.php index e4589ecf..acf4d5de 100644 --- a/src/includes/class/class.LSlog_system.php +++ b/src/includes/class/class.LSlog_system.php @@ -27,8 +27,12 @@ */ class LSlog_system extends LSlog_handler { - // Default datetime prefix (enabled/disabled) - protected $default_datetime_prefix = false; + /** + * Defaultly add datetime prefix (enabled/disabled) + * @see LSlog_handler::__get() + * @var bool + */ + protected bool $default_datetime_prefix = false; /** * Constructor @@ -46,8 +50,8 @@ class LSlog_system extends LSlog_handler { /** * Log a message * - * @param array $config The message level - * @param array $config The message + * @param string $level The message level + * @param string $message The message * @param string|null $logger The logger name (optional, default: null) * * @return void diff --git a/src/includes/class/class.LSobjects.LSgroup.php b/src/includes/class/class.LSobjects.LSgroup.php index cc8acbe9..edc97e44 100644 --- a/src/includes/class/class.LSobjects.LSgroup.php +++ b/src/includes/class/class.LSobjects.LSgroup.php @@ -27,9 +27,9 @@ */ class LSgroup extends LSldapObject { - var $userObjectType = 'LSpeople'; - var $memberAttr = 'uniqueMember'; - var $memberAttrValue = 'dn'; + var string $userObjectType = 'LSpeople'; + var string $memberAttr = 'uniqueMember'; + var string $memberAttrValue = 'dn'; /* ========== Members ========== */ /** diff --git a/src/includes/class/class.LSrelation.php b/src/includes/class/class.LSrelation.php index 6cae0dbf..e28f72a1 100644 --- a/src/includes/class/class.LSrelation.php +++ b/src/includes/class/class.LSrelation.php @@ -22,16 +22,47 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); +/** + * This class implement relation between LDAP objects + * + * @property-read string $name + * @property-read bool $correctly_configured + * @property-read string $LSobject + * @property-read string $linkAttribute + * @property-read string $linkAttributeValue + * @property-read string $linkAttributeOtherValues + * @property-read string $list_function + * @property-read string $getkeyvalue_function + * @property-read string $update_function + * @property-read string $remove_function + * @property-read string $rename_function + * @property-read string $canEdit_function + * @property-read string $canEdit_attribute + * @property-read array $linkAttributeValues + * @property-read string $relatedEditableAttribute + */ class LSrelation extends LSlog_staticLoggerClass { - // Reference to the LSldapObject + /** + * Reference to the LSldapObject + * @var LSldapObject|null + */ private $obj = null; - // Relation name + /** + * Relation name + * @var string + */ private $name = null; - // Relation config - private $config = null; + /** + * Relation config + * @see self::__construct() + * @see self::checkConfig() + * @see self::getConfig() + * @var array + */ + private array $config = array(); /** * LSrelation constructor @@ -41,24 +72,28 @@ class LSrelation extends LSlog_staticLoggerClass { * of relation of the object specified at constuct time. * * @param LSldapObject &$obj A reference to the LSldapObject - * @param [in] $relationName string The relation name + * @param string $relationName The relation name * * @return void */ public function __construct(&$obj, $relationName) { $this -> obj =& $obj; $this -> name = $relationName; - $this -> config = $obj -> getConfig("LSrelation.$relationName"); - if (!is_array($this -> config) || !$this -> checkConfig()) { - $this -> config = null; - LSerror :: addErrorCode( - 'LSrelation_02', - array( - 'relation' => $relationName, - 'LSobject' => $obj -> getType() - ) - ); + $config = $obj -> getConfig("LSrelation.$relationName"); + if (is_array($config)) { + $this -> config = $config; + if ($this -> checkConfig()) + return; + // Bad configuration + $this -> config = array(); } + LSerror :: addErrorCode( + 'LSrelation_02', + array( + 'relation' => $relationName, + 'LSobject' => $obj -> getType(), + ) + ); } /** @@ -73,9 +108,9 @@ class LSrelation 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 **/ @@ -645,7 +680,7 @@ class LSrelation extends LSlog_staticLoggerClass { )); } - /* + /** * Load LSrelations information of an object to display it on LSview. * * LSrelations information are provided to template by usind LSrelations variable. @@ -749,7 +784,9 @@ class LSrelation extends LSlog_staticLoggerClass { * LSldapObject and LSrelation objects. * * @param array &$data Reference to AJAX returned data array - * @param array|string|null $additional_parameters List of additional required parameter + * @param array &$conf Reference to the configuration array of the relation + * @param LSldapObject &$object Reference to the related LSldapObject + * @param array|string|null $additional_required_parameters List of additional required parameter * * @return array|false Array with LSobject and LSrelation */ diff --git a/src/includes/class/class.LSsearch.php b/src/includes/class/class.LSsearch.php index dc97429e..1c072de7 100644 --- a/src/includes/class/class.LSsearch.php +++ b/src/includes/class/class.LSsearch.php @@ -25,21 +25,61 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); /** * Object LSsearch * + * @property-read string $basedn + * @property-read string $sortBy + * @property-read string $sortDirection 'ASC' or 'DESC' + * @property-read array $attributes + * @property-read string $LSobject + * @property-read string $LSobject + * @property-read string $label_objectName + * @property-read string $label_level + * @property-read string $label_actions + * @property-read string $label_no_result + * @property-read bool $sort + * @property-read int $sortlimit + * @property-read int $total + * @property-read bool $displaySubDn + * @property-read bool $canCopy + * @property-read array $predefinedFilters + * @property-read array $extraDisplayedColumns + * @property-read array $visibleExtraDisplayedColumns + * @property-read string $hash * @author Benjamin Renard */ class LSsearch extends LSlog_staticLoggerClass { - // The LdapObject type of search - private $LSobject=NULL; + /** + * The LdapObject type of search + * @var string + */ + private $LSobject = NULL; - // The configuration of search + /** + * The configuration of search + * LSobjects..LSsearch + * @see self::loadConfig() + * @var array + */ private $config; - // The context of search + /** + * The context of search + * @see self::__construct() + * @var string + */ private $context; - // The parameters of the search - private $params=array ( + /** + * The parameters of the search + * @see self::setParams() + * @see self::setParam() + * @see self::getParam() + * @see self::loadParamsFromSession() + * @see self::saveParamsInSession() + * @see self::setParamsFromRequest() + * @var array + */ + private array $params = array ( // Search params 'filter' => NULL, 'pattern' => NULL, @@ -66,21 +106,33 @@ class LSsearch extends LSlog_staticLoggerClass { 'extraDisplayedColumns' => false, ); - // The cache of search parameters - private $_searchParams = NULL; + /** + * The cache of search parameters + * @see self::generateSearchParams() + * @see self::formatSearchParams() + * @var array + */ + private array $_searchParams = array(); - // The result of the search - private $result=NULL; + /** + * The result of the search + * @var array|null + */ + private $result = NULL; - // Caches - private $_canCopy=NULL; + /** + * Cache about $this->canCopy + * @see self::__get() + * @var bool|null + */ + private $_canCopy = NULL; /** * Constructor * * @param string $LSobject The LdapObject type of search - * @param string $LSobject Context of search (LSrelation / LSldapObject/ ...) - * @param string $LSobject Parameters of search + * @param string $context Context of search (LSrelation / LSldapObject/ ...) + * @param array|null $params Parameters of search * @param boolean $purgeParams If params in session have to be purged * **/ @@ -230,8 +282,8 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Define one search parameter * - * @param string $LSobject The parameter name - * @param string $LSobject The parameter value + * @param string $param The parameter name + * @param string $value The parameter value * * @return boolean True on success or False */ @@ -242,7 +294,7 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Define search parameters * - * @param string $LSobject Parameters of search + * @param array $params Parameters of search * * @return boolean True on success or False */ @@ -660,7 +712,7 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Make a filter object with a pattern of search * - * @param string $pattern The pattern of search. If is null, the pattern in params will be used. + * @param string|null $pattern The pattern of search. If is null, the pattern in params will be used. * * @return mixed Net_LDAP2_Filter on success or False */ @@ -738,7 +790,7 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Check if search pattern is valid * - * @param string $LSobject The pattern + * @param string $pattern The pattern * * @return boolean True if pattern is valid or False **/ @@ -773,7 +825,7 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Methode for parameters value access * - * @param string $LSobject The parameter name + * @param string $key The parameter name * * @return mixed The parameter value or NULL **/ @@ -971,7 +1023,7 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Run the search * - * @param boolean $purgeParams Define if the cache can be used + * @param boolean $cache Define if the cache can be used * * @return boolean True on success or False */ @@ -1038,8 +1090,8 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Return an hash corresponding to the parameters of the search * - * @param string $LSobject An optional search params array - * @param boolean $purgeParams An optional onlyAccessible boolean flag + * @param array $searchParams An optional search params array + * @param boolean $onlyAccessible An optional onlyAccessible boolean flag * * @return string The hash of the parameters of the search **/ @@ -1097,7 +1149,7 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Get page informations to display * - * @param boolean $purgeParams The number of the page + * @param int $page The number of the page * * @return array The information of the page **/ @@ -1174,7 +1226,7 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Access to information of this object * - * @param string $LSobject The key of the info + * @param string $key The key of the info * * @return mixed The info **/ @@ -1275,8 +1327,8 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Function use with uasort to sort two entry * - * @param string $LSobject One line of result - * @param string $LSobject One line of result + * @param LSsearchEntry &$a One entry of result + * @param LSsearchEntry &$b One entry of result * * @return int Value for uasort **/ @@ -1349,7 +1401,9 @@ class LSsearch extends LSlog_staticLoggerClass { return true; } - self :: log_debug('doSort(): sort by "'.$this -> params['sortBy'].'" (order: '.$this -> params['sortDirection']).")"; + self :: log_debug( + 'doSort(): sort by "'.$this -> params['sortBy']. + '" (order: '.$this -> params['sortDirection'].")"); $this -> result['sort'][$this -> params['sortBy']][$this -> params['sortDirection']]=range(0,($this -> total-1)); @@ -1474,7 +1528,7 @@ class LSsearch extends LSlog_staticLoggerClass { /** * CLI search command * - * @param string $LSobject Command arguments : + * @param array $command_args Command arguments : * - Positional arguments : * - LSobject type * - patterns @@ -1716,12 +1770,12 @@ class LSsearch extends LSlog_staticLoggerClass { /** * Args autocompleter for CLI command search * - * @param string $LSobject List of already typed words of the command - * @param string $LSobject The command word number to autocomplete - * @param string $LSobject The command word to autocomplete - * @param string $LSobject 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 **/ public static function cli_search_args_autocompleter($command_args, $comp_word_num, $comp_word, $opts) { $command_opts = array ( diff --git a/src/includes/class/class.LSsearchEntry.php b/src/includes/class/class.LSsearchEntry.php index 10f7e29d..e42420c6 100644 --- a/src/includes/class/class.LSsearchEntry.php +++ b/src/includes/class/class.LSsearchEntry.php @@ -25,43 +25,84 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); /** * Object LSsearchEntry * + * @property-read string $displayName + * @property-read string $LSobject + * @property-read string $type + * @property-read string $type_name + * @property-read string $dn + * @property-read string $subDn + * @property-read string $subDnName + * @property-read array $actions * @author Benjamin Renard */ class LSsearchEntry extends LSlog_staticLoggerClass { - // The LSsearch object - private $LSsearch=NULL; + /** + * Reference of the related LSsearch object + * @var LSsearch + */ + private $LSsearch = NULL; - // The LdapObject type of search - private $LSobject=NULL; + /** + * The LdapObject type of search + * @var string + */ + private $LSobject = NULL; - // DN + /** + * Entry DN + * @var string + */ private $dn; - // The parameters of the search - private $params = array(); + /** + * The parameters of the search + * @see LSsearch::$params + * @var array + */ + private array $params = array(); - // The attributes list - private $attrs_list = array(); + /** + * The attributes list + * @var array + */ + private array $attrs_list = array(); - // The attributes values - private $attrs = array(); + /** + * The list of attributes requested in the search + * @see LSsearch::getAttributes() + * @var array + */ + private array $attrs = array(); - // The index of the entry in the result of the search + /** + * The index of the entry in the result of the search + * @var int + */ private $id = null; - // Cache - private $cache = array(); + /** + * Cached information of the entry + * @var array + */ + private array $cache = array(); - // Other values - private $other_values = array(); + /** + * Other values + * @see self::registerOtherValue() + * @see self::__get() + * @var array + */ + private array $other_values = array(); /** * Constructor * + * @param LSsearch &$LSsearch A reference to the current LSsearch object * @param string $LSobject The LdapObject type of search - * @param string $LSobject Parameters of search - * @param string $LSobject The data of the result entry + * @param string $params The parameters of the search + * @param array &$result The data of the search result + * @param int $id The index of the entry in the search result * **/ public function __construct(&$LSsearch, $LSobject, $params, &$result, $id) { @@ -90,7 +131,7 @@ class LSsearchEntry extends LSlog_staticLoggerClass { /** * Get text value of entry * - * @param string $LSobject The name of the value + * @param string $key The name of the value * * @return mixed The value **/ @@ -112,8 +153,8 @@ class LSsearchEntry extends LSlog_staticLoggerClass { /** * Add value in array $this -> other_values * - * @param string $LSobject The value name - * @param string $LSobject The value + * @param string $name The value name + * @param mixed $value The value * * @return void **/ @@ -124,9 +165,9 @@ class LSsearchEntry extends LSlog_staticLoggerClass { /** * Get formated text value of entry * - * @param string $LSobject The format of the value + * @param string $format The format of the value * - * @return mixed The formated value + * @return string The formated value **/ public function getFData($format) { return getFData($format,$this,'get'); @@ -136,7 +177,7 @@ class LSsearchEntry extends LSlog_staticLoggerClass { /** * Access to infos of the entry * - * @param string $LSobject The name of the value + * @param string $key The name of the value * * @return mixed The value **/ @@ -267,9 +308,9 @@ class LSsearchEntry 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|null $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 **/ diff --git a/src/includes/class/class.LSselect.php b/src/includes/class/class.LSselect.php index 194dab7b..d4927a6f 100644 --- a/src/includes/class/class.LSselect.php +++ b/src/includes/class/class.LSselect.php @@ -83,10 +83,10 @@ class LSselect extends LSlog_staticLoggerClass { /** * Return a configuration parameter (or default value) * - * @param[] $id string The LSselect ID - * @param[] $param string The configuration parameter - * @param[] $default mixed The default value (optional, default : null) - * @param[] $cast Cast string|null resulting value in specific type + * @param string $id The LSselect ID + * @param string $key The configuration parameter + * @param mixed $default The default value (optional, default : null) + * @param string $cast Cast string|null resulting value in specific type * (optional, default : null=disabled) * * @return mixed The configuration parameter value or default value if not set diff --git a/src/includes/class/class.LSsession.php b/src/includes/class/class.LSsession.php index 4658e524..2e72c63b 100644 --- a/src/includes/class/class.LSsession.php +++ b/src/includes/class/class.LSsession.php @@ -33,81 +33,199 @@ class LSsession { * Class constants store and restore from PHP session */ - // Current LDAP server ID + /** + * Current LDAP server ID + * @var int + */ private static $ldapServerId = NULL; - // LDAP servers subDns + /** + * LDAP servers subDns + * @see self::getSubDnLdapServer() + * @var array + */ private static $_subDnLdapServer = array(); - // The current topDN + /** + * The current topDN + * @var string|null + */ private static $topDn = NULL; - // The LSldapObject type of current connected user + /** + * The LSldapObject type of current connected user + * @var string + */ private static $LSuserObjectType = NULL; - // Current connected user DN + /** + * Current connected user DN + * @var string + */ private static $dn = NULL; - // Current connected user RDN value (his login) + /** + * Current connected user RDN value (his login) + * @var string + */ private static $rdn = NULL; - // User LDAP credentials + /** + * User LDAP credentials + * + * array('dn' => [DN], 'pwd' => [password]) + * + * @see self :: startLSsession() + * @see LSauth :: getLDAPcredentials() + * @see LSauthMethod :: getLDAPcredentials() + * @var array|false + */ private static $userLDAPcreds = false; - // Current connected user LSprofiles - private static $LSprofiles = array(); + /** + * Current connected user LSprofiles + * + * array( + * '[LSprofile1]' => array( + * 'topDN1', 'topDN2', [...] + * ), + * [...] + * ) + * + * @see self::loadLSprofiles() + * @see self::cacheLSprofiles() + * @see $_SESSION['LSsession']['LSprofiles'] + * @var array + */ + private static array $LSprofiles = array(); - // Current connected user LSaccess (access rights) - private static $LSaccess = array(); + /** + * Current connected user LSaccess (access rights) + * + * array( + * 'topDN1' => array( + * 'SELF' => '[label]', + * '[LSobject type1]' => '[label]', + * '[LSobject type2]' => '[label]', + * [...] + * ), + * ) + * + * @see self::loadLSaccess() + * @see $_SESSION['LSsession']['LSaccess'] + * @var array + */ + private static array $LSaccess = array(); - // Current connected user LSaddonsViewsAccess (access on LSaddons views) - private static $LSaddonsViewsAccess = array(); + /** + * Current connected user LSaddonsViewsAccess (access on LSaddons views) + * + * array ( + * "[addon]::[view ID]" => array ( + * 'LSaddon' => [addon name], + * 'id' => [view ID], + * 'label' => [view label], + * 'showInMenu' => [bool], + * ), + * [...] + * ) + * + * @see self::loadLSaddonsViewsAccess() + * @see $_SESSION['LSsession']['LSaddonsViewsAccess'] + * @var array + */ + private static array $LSaddonsViewsAccess = array(); - // Temporary files - private static $tmp_file = array(); + /** + * Temporary files of the session + * + * array ( + * '[filepath]' => '[content hash]', + * [...] + * ) + * + * @see self::addTmpFile() + * @see $_SESSION['LSsession']['tmp_file'] + * @var array + */ + private static array $tmp_file = array(); /* * Class constants not store in session */ - // Current LDAP server config + /** + * Current LDAP server config + * (LSconfig.ldap_servers.) + * @see self::setLdapServer() + * @var array + */ public static $ldapServer = NULL; - // The template to display + /** + * The template to display + * @see self::setTemplate() + * @var string + */ private static $template = NULL; - // Ajax display flag - private static $ajaxDisplay = false; + /** + * Ajax display telltale + * @see self::setAjaxDisplay() + * @see self::getAjaxDisplay() + * @var bool + */ + private static bool $ajaxDisplay = false; - // JS files to load on page - private static $JSscripts = array(); - - // Libs JS files to load on page - private static $LibsJSscripts = array(); - - // CSS files to load on page - private static $CssFiles = array(); - - // Libs CSS files to load on page - private static $LibsCssFiles = array(); - - // The LSldapObject of connected user + /** + * The LSldapObject of connected user + * @see self::getLSuserObject() + * @var LSldapObject + */ private static $LSuserObject = NULL; - // The LSauht object of the session - private static $LSauthObject = false; + /** + * Initialized session telltale + * @see self::initialize() + * @var bool + */ + private static bool $initialized = false; - // Initialized flag - private static $initialized = false; + /** + * List of currently loaded LSaddons + * @see self::loadLSaddon() + * @var array + */ + private static array $loadedAddons = array(); - // List of currently loaded LSaddons - private static $loadedAddons = array(); - - // LSaddons views + /** + * Currently registered LSaddons views + * + * array( + * '[addon]' => array ( + * '[view ID]' => array ( + * 'LSaddon' => '[addon name]', + * 'label' => '[View label]', + * 'function' => '[View function]', + * 'allowedLSprofiles' => array( + * '[LSprofile1]', + * [...] + * ), + * 'showInMenu' => [bool] + * ), + * ), + * )$LSaddon][$viewId]=array ( + * + * @see self::registerLSaddonView() + * @var array + */ private static $LSaddonsViews = array(); - // API mode - private static $api_mode = false; + /** + * API mode telltale + * @var bool + */ + private static bool $api_mode = false; /** * Get session info by key @@ -149,12 +267,12 @@ class LSsession { /** * Include PHP file * - * @param string $key The path to the file to include : + * @param string $file The path to the file to include : * - if $external == false : the path must be relative to LS_ROOT_DIR * - if $external == true : the path could be absolute or relative. If * relative, it will be treated with PHP include path. * @param boolean $external If true, file consided as external (optional, default: false) - * @param boolean $external If true, a warning will be log if file not found (optional, default: true) + * @param boolean $warn If true, a warning will be log if file not found (optional, default: true) * This warning will be emit using LSlog if it's already loaded or error_log() * otherwise. * @author Benjamin Renard @@ -231,7 +349,7 @@ class LSsession { * Log a message via class logger (of other method if LSlog is not loaded) * * @param string $key The log level (see LSlog) - * @param string $key The message to log + * @param string $message The message to log * * @return void **/ @@ -257,9 +375,9 @@ class LSsession { /** * Log an exception via class logger * - * @param Exception $exceptionThe exception to log + * @param Exception $exception The exception to log * @param string|null $prefix Custom message prefix (optional, see self :: log_exception()) - * @param boolean $external Log exception as a fatal error (optional, default: true) + * @param boolean $fatal Log exception as a fatal error (optional, default: true) * * @return void **/ @@ -435,7 +553,7 @@ class LSsession { * Load an LdapSaisie class * * @param string $class The class name to load (Example : LSpeople) - * @param string $type (Optionnel) The class type to load (Example : LSobjects) + * @param string|null $type (Optionnel) The class type to load (Example : LSobjects) * @param bool $warn (Optionnel) Trigger LSsession_05 error if an error occured loading this class (Default: false) * * @author Benjamin Renard * * @return void @@ -2742,7 +2859,7 @@ class LSsession { * * @author Benjamin Renard * - * @param string $template A specific temporary file path to delete + * @param string|null $filePath A specific temporary file path to delete * (optional, default: all temporary files wil be deleted) * * @return void @@ -2849,7 +2966,7 @@ class LSsession { /** * Return the name of a specifed subDn * - * @param string $key The subDn (optional, default: the current one) + * @param string|false $subDn The subDn (optional, default: the current one) * * @return string The name of the current subDn if found or an empty string otherwise */ @@ -2869,7 +2986,7 @@ class LSsession { /** * Check if object type is used to list current LDAP server subDns * - * @param string $key The LSobject type + * @param string $type The LSobject type * * @return boolean True if specified object type is used to list current LDAP server subDns, false otherwise */ @@ -2888,8 +3005,8 @@ class LSsession { /** * Check if specified LSobject type is in current interface menu * - * @param string $key The LSobject type - * @param string $key The topDn to check (optional, default: current one) + * @param string $LSobject The LSobject type + * @param string|null $topDn The topDn to check (optional, default: current one) * * @return boolean True if specified LSobject type is in current interface menu, false otherwise */ @@ -2912,7 +3029,7 @@ class LSsession { /** * Add an information to display to user (on next displayed page or in API result) * - * @param string $key The message + * @param string $msg The message * * @return void */ @@ -2925,8 +3042,8 @@ class LSsession { * * /!\ DEPRECATED /!\ : please use LSurl :: redirect() * - * @param string $key The destination URL - * @param boolean $external Unsed (keep for reto-compatibility) + * @param string $url The destination URL + * @param boolean $exit Unsed (keep for reto-compatibility) * * @return void */ @@ -2977,8 +3094,8 @@ class LSsession { /** * Add help info * - * @param string $key The group name of this information - * @param string $key Array of the information to add (name => value) + * @param string $group The group name of this information + * @param array $info Array of the information to add (name => value) * * @return void */ @@ -3092,7 +3209,7 @@ class LSsession { /** * Ajax method when change ldapserver on login/recoveryPassword form * - * @param string $key The return data address + * @param array &$data The return data address * * @return void **/ @@ -3134,14 +3251,14 @@ class LSsession { /** * Register a LSaddon view * - * @param string $key The LSaddon - * @param string $key The view ID - * @param string $key The view's label - * @param string $key The view's function name - * @param string|null $prefix Array listing allowed profiles. + * @param string $LSaddon The LSaddon + * @param string $viewId The view ID + * @param string $label The view's label + * @param callable $viewFunction The view's function name + * @param array[string]|null $allowedLSprofiles Array listing allowed profiles. * If null, no access control will * be done for this view. - * @param boolean $external Show (or not) this view in menu + * @param boolean $showInMenu Show (or not) this view in menu * * @return bool True is the view have been registred, false otherwise **/ @@ -3185,8 +3302,8 @@ class LSsession { /** * Show LSaddon view * - * @param string $key The LSaddon - * @param string $key The view ID + * @param string $LSaddon The LSaddon + * @param string $viewId The view ID * * @return void **/ diff --git a/src/includes/class/class.LStemplate.php b/src/includes/class/class.LStemplate.php index a9aa8c46..e98fcb36 100644 --- a/src/includes/class/class.LStemplate.php +++ b/src/includes/class/class.LStemplate.php @@ -31,20 +31,40 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); */ class LStemplate extends LSlog_staticLoggerClass { - // Javascript files to load on page - private static $JSscripts = array(); + /** + * Javascript files to load on page + * @see self::addJSscript() + * @var array + */ + private static array $JSscripts = array(); - // Libs JS files to load on page - private static $LibsJSscripts = array(); + /** + * Libs JS files to load on page + * @see self::addLibJSscript() + * @var array + */ + private static array $LibsJSscripts = array(); - // Javascript configuration parameter to set on page - private static $JSconfigParams = array(); + /** + * Javascript configuration parameter to set on page + * @see self::addJSconfigParam() + * @var array + */ + private static array $JSconfigParams = array(); - // CSS files to load on page - private static $CssFiles = array(); + /** + * CSS files to load on page + * @see self::addCssFile() + * @var array + */ + private static array $CssFiles = array(); - // Libs CSS files to load on page - private static $LibsCssFiles = array(); + /** + * Libs CSS files to load on page + * @see self::addLibCssFile() + * @var array + */ + private static array $LibsCssFiles = array(); /** * LStemplate configuration @@ -59,6 +79,7 @@ class LStemplate extends LSlog_staticLoggerClass { * 'debug_smarty' => True * ) * + * @var array **/ private static $config = array ( 'smarty_path' => 'smarty/libs/Smarty.class.php', @@ -72,25 +93,45 @@ class LStemplate extends LSlog_staticLoggerClass { 'debug_smarty' => False ); - // Smarty object + /** + * Smarty object + * @var Smarty + */ public static $_smarty = NULL; - // Smarty version + /** + * Smarty version + * @var int + */ private static $_smarty_version = NULL; - // Array of directories - private static $directories = array('local', LS_THEME, './'); + /** + * Array of directories where file have to be search + * @var array + */ + private static array $directories = array('local', LS_THEME, './'); - // Registered events - private static $_events = array(); + /** + * Registered events + * @see self::addEvent() + * @see self::fireEvent() + * @var array + */ + private static array $_events = array(); - // Deprecated templates files - private static $deprecated_template_files = array ( + /** + * Deprecated templates files + * @var array + */ + private const deprecated_template_files = array ( 'accueil.tpl', 'blank.tpl', 'empty.tpl', 'top.tpl', 'bottom.tpl', ); - // Keep trace of last displayed template (for loop detection) + /** + * Keep trace of last displayed template (for loop detection) + * @var string|null + */ private static $last_displayed_template = null; /** @@ -113,12 +154,12 @@ class LStemplate extends LSlog_staticLoggerClass { if (LSsession :: includeFile(self :: $config['smarty_path'], true)) { self :: $_smarty = new Smarty(); - self :: $_smarty -> template_dir = self :: $config['template_dir']; + self :: $_smarty -> setTemplateDir(self :: $config['template_dir']); if ( ! is_writable(self :: $config['compile_dir']) ) { self :: log_fatal(getFData(_("LStemplate : compile directory is not writable (dir : %{dir})"), self :: $config['compile_dir'])); } - self :: $_smarty -> compile_dir = self :: $config['compile_dir']; + self :: $_smarty -> setCompileDir(self :: $config['compile_dir']); if (self :: $config['debug']) { self :: $_smarty -> caching = 0; @@ -191,10 +232,10 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Return the path of the file to use * - * @param string $name The file name (eg: mail.png) - * @param string $name The root directory (eg: images) - * @param string $name The default directory (eg: default) - * @param string $name If true, include nocache URL param (default: false) + * @param string $file The file name (eg: mail.png) + * @param string $root_dir The root directory (eg: images) + * @param string|null $default_dir The default directory (eg: default) + * @param bool $with_nocache If true, include nocache URL param (default: false) * * @return string The path of the file **/ @@ -234,8 +275,8 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Return the path of the image file to use * - * @param string $name The image name (eg: mail) - * @param string $name If true, include nocache URL param (default: false) + * @param string $image The image name (eg: mail) + * @param bool $with_nocache If true, include nocache URL param (default: false) * * @return string The path of the image file **/ @@ -251,8 +292,8 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Return the path of the CSS file to use * - * @param string $name The CSS name (eg: main.css) - * @param string $name If true, include nocache URL param (default: false) + * @param string $css The CSS name (eg: main.css) + * @param bool $with_nocache If true, include nocache URL param (default: false) * * @return string The path of the CSS file **/ @@ -263,8 +304,8 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Return the path of the JS file to use * - * @param string $name The JS name (eg: LSdefaults.js) - * @param string $name If true, include nocache URL param (default: false) + * @param string $js The JS name (eg: LSdefaults.js) + * @param bool $with_nocache If true, include nocache URL param (default: false) * * @return string The path of the CSS file **/ @@ -275,8 +316,8 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Return the path of the libary file to use * - * @param string $name The lib file path (eg: arian-mootools-datepicker/Picker.js) - * @param string $name If true, include nocache URL param (default: false) + * @param string $file_path The lib file path (eg: arian-mootools-datepicker/Picker.js) + * @param bool $with_nocache If true, include nocache URL param (default: false) * * @return string The path of the Lib file **/ @@ -287,13 +328,13 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Return the path of the Smarty template file to use * - * @param string $name The template name (eg: base.tpl) - * @param string $name If true, include nocache URL param (default: false) + * @param string $template The template name (eg: base.tpl) + * @param bool $with_nocache If true, include nocache URL param (default: false) * * @return string The path of the Smarty template file **/ public static function getTemplatePath($template, $with_nocache=false) { - if (in_array($template, self :: $deprecated_template_files)) + if (in_array($template, self :: deprecated_template_files)) self :: log_fatal( getFData( _("LStemplate : Request template '%{tpl}' is now deprecated. Please refer to upgrade documentation to adapt your templates."), @@ -306,7 +347,7 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Return the nocache value of the specify file * - * @param string $name The file path + * @param string $file The file path * * @return string The specified file's nocache value **/ @@ -320,7 +361,7 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Return the content of a Smarty template file. * - * @param string $name The template name (eg: base.tpl) + * @param string $template The template name (eg: base.tpl) * * @return string The content of the Smarty template file **/ @@ -342,7 +383,7 @@ class LStemplate extends LSlog_staticLoggerClass { * Return the timestamp of the last change of a Smarty * template file. * - * @param string $name The template name (eg: base.tpl) + * @param string $template The template name (eg: base.tpl) * * @return string The timestamp of the last change of the Smarty template file **/ @@ -360,7 +401,7 @@ class LStemplate extends LSlog_staticLoggerClass { * Assign template variable * * @param string $name The variable name - * @param string $name The variable value + * @param string $value The variable value * * @return void **/ @@ -414,7 +455,7 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Display a template * - * @param string $name The template name (eg: base_connected.tpl) + * @param string $template The template name (eg: base_connected.tpl) * * @return void **/ @@ -445,9 +486,9 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Fetch a template * - * @param string $name The template name (eg: base_connected.tpl) + * @param string $template The template name (eg: base_connected.tpl) * - * @return string The template compiled + * @return string|false The template compiled or false in case of error **/ public static function fetch($template) { try { @@ -456,6 +497,7 @@ class LStemplate extends LSlog_staticLoggerClass { catch (Exception $e) { self :: log_exception($e, getFData(_("Smarty - An exception occured fetching template '%{template}'"), $template), false); } + return false; } /** @@ -494,7 +536,7 @@ class LStemplate extends LSlog_staticLoggerClass { * Register a template function * * @param string $name The function name in template - * @param string $name The function name in PHP + * @param string $function_name The function name in PHP * * @return void */ @@ -505,9 +547,9 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Registered an action on a specific event * - * @param array $config The event name + * @param string $event The event name * @param callable $callable The callable to run on event - * @param array $config Paremeters that will be pass to the callable + * @param array $param Paremeters that will be pass to the callable * * @return void */ @@ -521,7 +563,7 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Run triggered actions on specific event * - * @param array $config Event name + * @param string $event Event name * * @return boolean True if all triggered actions succefully runned, false otherwise */ @@ -558,7 +600,7 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Add a JS script to load on page * - * @param array $config The JS filename + * @param string $file The JS filename * * Note: about old $path of the LStemplate :: addJSscript() method, corresponding to * the sub-directory path that contain the file, you could just prefix the file name. @@ -573,7 +615,7 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Add a library JS file to load on page * - * @param array $config The JS filename + * @param string $file The JS filename * * @return void */ @@ -585,8 +627,8 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Add Javascript configuration parameter * - * @param array $config Name of the configuration parameter - * @param array $config Value of the configuration parameter + * @param string $name Name of the configuration parameter + * @param mixed $val Value of the configuration parameter * * @return void */ @@ -606,8 +648,8 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Add help info * - * @param array $config The group name of this information - * @param array $config Array of the information to add (name => value) + * @param string $group The group name of this information + * @param array $info Array of the information to add (name => value) * * @return void */ @@ -625,7 +667,7 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Add a CSS file to load on page * - * @param array $config The CSS filename + * @param string $file The CSS filename * * Note: about old $path of the LStemplate :: addCssFile() method, corresponding to * the sub-directory path that contain the file, you could just prefix the file name. @@ -640,7 +682,7 @@ class LStemplate extends LSlog_staticLoggerClass { /** * Add a library CSS file to load on page * - * @param array $config The CSS filename + * @param string $file The CSS filename * * @return void */ diff --git a/src/includes/class/class.LStemplate_smarty2_support.php b/src/includes/class/class.LStemplate_smarty2_support.php index 534ec5b6..4fe8c2b0 100644 --- a/src/includes/class/class.LStemplate_smarty2_support.php +++ b/src/includes/class/class.LStemplate_smarty2_support.php @@ -94,6 +94,7 @@ function LStemplate_smarty_get_trusted($tpl_name, &$smarty_obj) { } // Register 'ls' template ressource +// @phpstan-ignore-next-line LStemplate :: $_smarty -> register_resource('ls', array( 'LStemplate_smarty_get_template', 'LStemplate_smarty_get_timestamp', @@ -110,5 +111,6 @@ LStemplate :: $_smarty -> register_resource('ls', array( * @return void */ function LStemplate_register_function($name,$function_name) { + // @phpstan-ignore-next-line LStemplate :: $_smarty -> register_function($name,$function_name); } diff --git a/src/includes/class/class.LSurl.php b/src/includes/class/class.LSurl.php index a4c7359c..59beb546 100644 --- a/src/includes/class/class.LSurl.php +++ b/src/includes/class/class.LSurl.php @@ -30,10 +30,13 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); */ class LSurl extends LSlog_staticLoggerClass { - // Current request (defined at least current URL have been analyse by LSurl :: handle_request()) + /** + * Current request (defined at least current URL have been analyse by LSurl :: handle_request()) + * @var LSurlRequest + */ public static $request = null; - /* + /** * Configured URL patterns : * * Example : @@ -53,8 +56,10 @@ class LSurl extends LSlog_staticLoggerClass { * ), * ) * + * @see self::add_handler() + * @var array */ - private static $patterns = array(); + private static array $patterns = array(); /** * Add an URL pattern @@ -64,7 +69,7 @@ class LSurl extends LSlog_staticLoggerClass { * @param boolean $authenticated Permit to define if this URL is accessible only for authenticated users (optional, default: true) * @param boolean $authenticated Allow override if a command already exists with the same name (optional, default: false) * @param boolean $authenticated Enable API mode (optional, default: false) - * @param array|null $methods HTTP method (optional, default: array('GET', 'POST')) + * @param array[string]|string|null $methods HTTP method (optional, default: array('GET', 'POST')) **/ public static function add_handler($pattern, $handler=null, $authenticated=true, $override=true, $api_mode=false, $methods=null) { if (is_null($methods)) @@ -89,7 +94,7 @@ class LSurl extends LSlog_staticLoggerClass { ); } elseif ($override) { - self :: log_debug("URL : override pattern '$pattern' with handler '$handler' (old handler = '".self :: $patterns[$pattern]."')"); + self :: log_debug("URL : override pattern '$pattern' with handler '".format_callable($handler)."' (old handler = '".varDump(self :: $patterns[$pattern])."')"); self :: $patterns[$pattern] = array( 'handler' => $handler, 'authenticated' => $authenticated, @@ -106,7 +111,7 @@ class LSurl extends LSlog_staticLoggerClass { /** * Interprets the requested URL and return the corresponding LSurlRequest object * - * @param array|null $methods The default URL if current one does not + * @param string|null $default_url The default URL if current one does not * match with any configured pattern. * * @return LSurlRequest The LSurlRequest object corresponding to the the requested URL. @@ -157,8 +162,8 @@ class LSurl extends LSlog_staticLoggerClass { * Check if the current requested URL match with a specific pattern * * @param string $pattern The URL pattern - * @param array|null $methods The current URL (optional) - * @param array|null $methods HTTP method (optional, default: no check) + * @param string|false $current_url The current URL (optional) + * @param array[string]|string|null $methods HTTP method (optional, default: no check) * * @return array|false The URL info if pattern matched, false otherwise. **/ @@ -179,7 +184,7 @@ class LSurl extends LSlog_staticLoggerClass { /** * Get the public absolute URL * - * @param array|null $methods Relative URL to convert (Default: current URL) + * @param string|null $relative_url Relative URL to convert (Default: current URL) * * @return string The public absolute URL **/ @@ -203,7 +208,7 @@ class LSurl extends LSlog_staticLoggerClass { /** * Trigger redirect to specified URL (or homepage if omited) * - * @param array|null $methods The destination URL + * @param string|false $go The destination URL * * @return void **/ @@ -262,7 +267,7 @@ class LSurl extends LSlog_staticLoggerClass { /** * Handle the current requested URL * - * @param array|null $methods The default URL if current one does not + * @param string|null $default_url The default URL if current one does not * match with any configured pattern. * * @return void @@ -365,7 +370,7 @@ class LSurl extends LSlog_staticLoggerClass { /** * Remove trailing slash in specified URL * - * @param string $pattern The URL + * @param string $url The URL * * @return string The specified URL without trailing slash **/ diff --git a/src/includes/class/class.LSurlRequest.php b/src/includes/class/class.LSurlRequest.php index 867742e0..b7f22efb 100644 --- a/src/includes/class/class.LSurlRequest.php +++ b/src/includes/class/class.LSurlRequest.php @@ -24,24 +24,46 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass'); /** * URL request abstraction use by LSurl * + * @property-read string $current_url + * @property-read callable $handler + * @property-read bool $authenticated + * @property-read bool $api_mode + * @property-read string $referer + * @property-read string $http_method + * @property-read bool $ajax * @author Benjamin Renard */ class LSurlRequest extends LSlog_staticLoggerClass { - // The URL requested handler + /** + * The URL requested handler + * @var string + */ private $current_url = null; - // The URL requested handler + /** + * The URL requested handler + * @var callable + */ private $handler = null; - // Request need authentication ? - private $authenticated = true; + /** + * Request need authentication ? + * @var bool + */ + private bool $authenticated = true; - // API mode enabled ? - private $api_mode = false; + /** + * API mode enabled ? + * @var bool + */ + private bool $api_mode = false; - // Parameters detected on requested URL - private $url_params = array(); + /** + * Parameters detected on requested URL + * @var array + */ + private array $url_params = array(); public function __construct($current_url, $handler_infos, $url_params=array()) { $this -> current_url = $current_url; @@ -85,7 +107,7 @@ class LSurlRequest extends LSlog_staticLoggerClass { * * @param string $key The name of the info * - * @return boolval True is info is set, False otherwise + * @return bool True is info is set, False otherwise **/ public function __isset($key) { if (in_array($key, array('current_url', 'handler', 'authenticated'))) diff --git a/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po b/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po index 7cd5990f..47185d7d 100644 --- a/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po +++ b/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po @@ -1538,7 +1538,7 @@ msgid "" "LSldapObject : The attibute %{attr} of the object is not yet defined. Can't " "generate DN." msgstr "" -"LSldapObjet : L'attribut %{attr} de l'objet n'est pas encore défini. " +"LSldapObject : L'attribut %{attr} de l'objet n'est pas encore défini. " "Impossible de générer le DN." #: includes/class/class.LSldapObject.php:3098