Add support of supannRessourceEtat & supannRessourceEtatDate attributes

This commit is contained in:
Benjamin Renard 2021-06-11 14:28:08 +02:00
parent 88bb4eef49
commit ef2271e7eb
6 changed files with 352 additions and 0 deletions

View file

@ -125,6 +125,29 @@ $GLOBALS['supannNomenclatures'] = array (
'FIXEPRO' => ___('Professional landline'),
'SECOURS' => ___('Backup'),
),
'ressource' => array (
'COMPTE' => ___('User account'),
'MAIL' => ___('Mailbox'),
),
'ressourceEtat' => array (
'A' => ___('Active'),
'I' => ___('Inactive'),
'S' => ___('Suspended'),
),
'ressourceSousEtat' => array (
'SupannPrecree' => ___('Account created in advance, but not yet operational'),
'SupannCree' => ___('Account operational, but of which the user has not yet taken possession'),
'SupannAnticipe' => ___('Account operational and accessed by the user, in anticipation of their start date of activity'),
'SupannActif' => ___('Account operational and accessed by the user in regular activity'),
'SupannSursis' => ___('Account operational and accessed by the user, suspended after the date of end of activity'),
'SupannExpire' => ___('Account which is no longer operational, the date of end of activity and possible suspension having passed, but whose cancellation deadlines have not yet been reached'),
'SupannInactif' => ___('Non-operational account (without specifying the reason) whose deletion deadlines have not yet been reached'),
'SupannSupprDonnees' => ___('Expired account that has reached the data deletion deadline'),
'SupannSupprCompte' => ___('Expired account pending permanent deletion'),
'SupannVerrouille' => ___('Account locked (without specifying the reason)'),
'SupannVerrouAdministratif' => ___('Account locked for administrative reasons (account suspension, charter abuse, etc.)'),
'SupannVerrouTechnique' => ___("Account locked for a technical reason (detection of a namesake, suspicion of a hacked account, etc.)"),
),
),
'eduPerson' => array(
'affiliation' => array (

View file

@ -681,6 +681,60 @@ function supannGetAffiliationPossibleValues($options=null, $name=null, $ldapObje
return supannGetNomenclaturePossibleValues('affiliation', false);
}
/**
* Retourne les valeurs possibles des ressources.
*
* Cette fonction est prévue pour pouvoir être utilisé comme paramètre
* get_possible_values de la configuration du composant ressource de l'attribut
* supannRessourceEtat (entre autre) avec un type de composant select.
*
* @param[in] $options La configuration HTML de l'attribut
* @param[in] $name Le nom de l'attribut
* @param[in] &$ldapObject Une référence à l'object LSldapObject
*
* @retval array Tableau contenant les valeurs possibles de l'attribut
* (avec les labels traduits).
**/
function supannGetRessourcePossibleValues($options=null, $name=null, $ldapObject=null) {
return supannGetNomenclaturePossibleValues('ressource', false);
}
/**
* Retourne les valeurs possibles des états des ressources.
*
* Cette fonction est prévue pour pouvoir être utilisé comme paramètre
* get_possible_values de la configuration du composant etat de l'attribut
* supannRessourceEtat (entre autre) avec un type de composant select.
*
* @param[in] $options La configuration HTML de l'attribut
* @param[in] $name Le nom de l'attribut
* @param[in] &$ldapObject Une référence à l'object LSldapObject
*
* @retval array Tableau contenant les valeurs possibles de l'attribut
* (avec les labels traduits).
**/
function supannGetRessourceEtatPossibleValues($options=null, $name=null, $ldapObject=null) {
return supannGetNomenclaturePossibleValues('ressourceEtat', false);
}
/**
* Retourne les valeurs possibles des sous-états des ressources.
*
* Cette fonction est prévue pour pouvoir être utilisé comme paramètre
* get_possible_values de la configuration du composant sous_etat de l'attribut
* supannRessourceEtat (entre autre) avec un type de composant select.
*
* @param[in] $options La configuration HTML de l'attribut
* @param[in] $name Le nom de l'attribut
* @param[in] &$ldapObject Une référence à l'object LSldapObject
*
* @retval array Tableau contenant les valeurs possibles de l'attribut
* (avec les labels traduits).
**/
function supannGetRessourceSousEtatPossibleValues($options=null, $name=null, $ldapObject=null) {
return supannGetNomenclaturePossibleValues('ressourceSousEtat', false);
}
/**
* Vérifie les valeurs de l'attribut eduPersonAffiliation
*

View file

@ -0,0 +1,32 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/**
* Type d'attribut HTML supannRessourceEtat
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_html_supannRessourceEtat extends LSattr_html {
var $LSformElement_type = 'supannRessourceEtat';
}

View file

@ -0,0 +1,32 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/**
* Type d'attribut HTML supannRessourceEtatDate
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_html_supannRessourceEtatDate extends LSattr_html {
var $LSformElement_type = 'supannRessourceEtatDate';
}

View file

@ -0,0 +1,98 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSformElement_supannCompositeAttribute');
LSsession :: loadLSaddon('supann');
/**
* Element supannRessourceEtat d'un formulaire pour LdapSaisie
*
* Cette classe définis les éléments supannRessourceEtat des formulaires.
* Elle étant la classe basic LSformElement.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSformElement_supannRessourceEtat extends LSformElement_supannCompositeAttribute {
public function __construct(&$form, $name, $label, $params, &$attr_html){
$this -> components = array (
'ressource' => array (
'label' => _('Resource'),
'type' => 'select',
'get_possible_values' => 'supannGetRessourcePossibleValues',
'required' => true,
),
'etat' => array (
'label' => _('State'),
'type' => 'select',
'get_possible_values' => 'supannGetRessourceEtatPossibleValues',
'required' => true,
),
'sous_etat' => array (
'label' => _('Sub-state'),
'type' => 'select',
'possible_values' => array('' => '-'),
'get_possible_values' => 'supannGetRessourceSousEtatPossibleValues',
'required' => false,
),
);
return parent :: __construct($form, $name, $label, $params, $attr_html);
}
/**
* Parse une valeur composite gérer par ce type d'attribut
*
* @param $value string La valeur à parser
* @return array|null La valeur parsée, ou NULL en cas de problème
*/
public function parseCompositeValue($value) {
if (preg_match('/\{(?<ressource>[^\}]+)\}(?<etat>[AIS])(:(?<sous_etat>.*))?/', $value, $matches)) {
$parseValue = array(
'ressource' => $matches['ressource'],
'etat' => $matches['etat'],
'sous_etat' => (isset($matches['sous_etat'])?$matches['sous_etat']:null),
);
return $parseValue;
}
return;
}
/**
* Format une valeur composite gérer par ce type d'attribut
*
* @param $value string 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) {
if (is_array($value)) {
if (!$value['ressource'] || !$value['etat'])
return null;
$ret = "{".$value['ressource']."}".$value['etat'];
if ($value['sous_etat'])
$ret .= ":".$value['sous_etat'];
return $ret;
}
return False;
}
}

View file

@ -0,0 +1,113 @@
<?php
/*******************************************************************************
* Copyright (C) 2021 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSformElement_supannCompositeAttribute');
LSsession :: loadLSaddon('supann');
/**
* Element supannRessourceEtatDate d'un formulaire pour LdapSaisie
*
* Cette classe définis les éléments supannRessourceEtatDate des formulaires.
* Elle étant la classe basic LSformElement.
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSformElement_supannRessourceEtatDate extends LSformElement_supannCompositeAttribute {
public function __construct(&$form, $name, $label, $params, &$attr_html){
$this -> components = array (
'ressource' => array (
'label' => _('Resource'),
'type' => 'select',
'get_possible_values' => 'supannGetRessourcePossibleValues',
'required' => true,
),
'etat' => array (
'label' => _('State'),
'type' => 'select',
'get_possible_values' => 'supannGetRessourceEtatPossibleValues',
'required' => true,
),
'sous_etat' => array (
'label' => _('Sub-state'),
'type' => 'select',
'possible_values' => array('' => '-'),
'get_possible_values' => 'supannGetRessourceSousEtatPossibleValues',
'required' => false,
),
'date_debut' => array (
'label' => _('Start date'),
'type' => 'date',
'format' => 'Ymd',
'required' => false,
),
'date_fin' => array (
'label' => _('End date'),
'type' => 'date',
'format' => 'Ymd',
'required' => false,
),
);
return parent :: __construct($form, $name, $label, $params, $attr_html);
}
/**
* Parse une valeur composite gérer par ce type d'attribut
*
* @param $value string La valeur à parser
* @return array|null La valeur parsée, ou NULL en cas de problème
*/
public function parseCompositeValue($value) {
if (preg_match('/\{(?<ressource>[^\}]+)\}(?<etat>[AIS]):(?<sous_etat>[^\:]*):(?<date_debut>[0-9]{8})?:(?<date_fin>[0-9]{8})?/', $value, $matches)) {
$parseValue = array(
'ressource' => $matches['ressource'],
'etat' => $matches['etat'],
'sous_etat' => (isset($matches['sous_etat'])?$matches['sous_etat']:null),
'date_debut' => (isset($matches['date_debut'])?$matches['date_debut']:null),
'date_fin' => (isset($matches['date_fin'])?$matches['date_fin']:null),
);
return $parseValue;
}
return;
}
/**
* Format une valeur composite gérer par ce type d'attribut
*
* @param $value string 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) {
if (is_array($value)) {
if (!$value['ressource'] || !$value['etat'])
return null;
$ret = "{".$value['ressource']."}".$value['etat'];
$ret .= ":".($value['sous_etat']?$value['sous_etat']:'');
$ret .= ":".($value['date_debut']?$value['date_debut']:'');
$ret .= ":".($value['date_fin']?$value['date_fin']:'');
return $ret;
}
return False;
}
}